Rev 8091 | Rev 8093 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8091 | Rev 8092 | ||
---|---|---|---|
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: 8091 $ |
74 | $Revision: 8092 $ |
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 | if ~ defined extended_primary_loader |
141 | if ~ defined extended_primary_loader |
142 | file 'bootbios.bin' |
142 | file 'bootbios.bin' |
143 | else |
143 | else |
144 | file 'bootbios.bin.ext_loader' |
144 | file 'bootbios.bin.ext_loader' |
145 | end if |
145 | end if |
146 | if __REV__ > 0 |
146 | if __REV__ > 0 |
147 | cur_pos = 0 |
147 | cur_pos = 0 |
148 | cnt = 0 |
148 | cnt = 0 |
149 | repeat $ - bootbios |
149 | repeat $ - bootbios |
150 | load a byte from % |
150 | load a byte from % |
151 | if a = '*' |
151 | if a = '*' |
152 | cnt = cnt + 1 |
152 | cnt = cnt + 1 |
153 | else |
153 | else |
154 | cnt = 0 |
154 | cnt = 0 |
155 | end if |
155 | end if |
156 | if cnt = 4 |
156 | if cnt = 4 |
157 | cur_pos = % - 1 |
157 | cur_pos = % - 1 |
158 | break |
158 | break |
159 | end if |
159 | end if |
160 | end repeat |
160 | end repeat |
161 | store byte ' ' at cur_pos + 1 |
161 | store byte ' ' at cur_pos + 1 |
162 | rev_var = __REV__ |
162 | rev_var = __REV__ |
163 | while rev_var > 0 |
163 | while rev_var > 0 |
164 | store byte rev_var mod 10 + '0' at cur_pos |
164 | store byte rev_var mod 10 + '0' at cur_pos |
165 | cur_pos = cur_pos - 1 |
165 | cur_pos = cur_pos - 1 |
166 | rev_var = rev_var / 10 |
166 | rev_var = rev_var / 10 |
167 | end while |
167 | end while |
168 | store byte ' ' at cur_pos |
168 | store byte ' ' at cur_pos |
169 | store dword ' SVN' at cur_pos - 4 |
169 | store dword ' SVN' at cur_pos - 4 |
170 | end if |
170 | end if |
171 | end if |
171 | end if |
172 | 172 | ||
173 | use32 |
173 | use32 |
174 | org $+0x10000 |
174 | org $+0x10000 |
175 | 175 | ||
176 | align 4 |
176 | align 4 |
177 | B32: |
177 | B32: |
178 | mov ax, os_stack ; Selector for os |
178 | mov ax, os_stack ; Selector for os |
179 | mov ds, ax |
179 | mov ds, ax |
180 | mov es, ax |
180 | mov es, ax |
181 | mov fs, ax |
181 | mov fs, ax |
182 | mov gs, ax |
182 | mov gs, ax |
183 | mov ss, ax |
183 | mov ss, ax |
184 | mov esp, TMP_STACK_TOP ; Set stack |
184 | mov esp, TMP_STACK_TOP ; Set stack |
185 | 185 | ||
186 | ; CLEAR 0x280000 - HEAP_BASE |
186 | ; CLEAR 0x280000 - HEAP_BASE |
187 | 187 | ||
188 | xor eax, eax |
188 | xor eax, eax |
189 | mov edi, CLEAN_ZONE |
189 | mov edi, CLEAN_ZONE |
190 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
190 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
191 | cld |
191 | cld |
192 | rep stosd |
192 | rep stosd |
193 | 193 | ||
194 | ; CLEAR KERNEL UNDEFINED GLOBALS |
194 | ; CLEAR KERNEL UNDEFINED GLOBALS |
195 | mov edi, endofcode-OS_BASE |
195 | mov edi, endofcode-OS_BASE |
196 | mov ecx, 0x90000 |
196 | mov ecx, 0x90000 |
197 | sub ecx, edi |
197 | sub ecx, edi |
198 | shr ecx, 2 |
198 | shr ecx, 2 |
199 | rep stosd |
199 | rep stosd |
200 | 200 | ||
201 | ; SAVE & CLEAR 0-0xffff |
201 | ; SAVE & CLEAR 0-0xffff |
202 | 202 | ||
203 | mov edi, 0x1000 |
203 | mov edi, 0x1000 |
204 | mov ecx, 0x8000 / 4 |
204 | mov ecx, 0x8000 / 4 |
205 | rep stosd |
205 | rep stosd |
206 | mov edi, 0xa000 |
206 | mov edi, 0xa000 |
207 | mov ecx, 0x6000 / 4 |
207 | mov ecx, 0x6000 / 4 |
208 | rep stosd |
208 | rep stosd |
209 | 209 | ||
210 | call test_cpu |
210 | call test_cpu |
211 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
211 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
212 | 212 | ||
213 | call check_acpi |
213 | call check_acpi |
214 | call init_hpet |
214 | call init_hpet |
215 | call init_BIOS32 |
215 | call init_BIOS32 |
216 | ; MEMORY MODEL |
216 | ; MEMORY MODEL |
217 | call mem_test |
217 | call mem_test |
218 | call init_mem |
218 | call init_mem |
219 | call init_page_map |
219 | call init_page_map |
220 | 220 | ||
221 | ; ENABLE PAGING |
221 | ; ENABLE PAGING |
222 | 222 | ||
223 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
223 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
224 | mov cr3, eax |
224 | mov cr3, eax |
225 | 225 | ||
226 | mov eax, cr0 |
226 | mov eax, cr0 |
227 | or eax, CR0_PG+CR0_WP |
227 | or eax, CR0_PG+CR0_WP |
228 | mov cr0, eax |
228 | mov cr0, eax |
229 | 229 | ||
230 | lgdt [gdts] |
230 | lgdt [gdts] |
231 | jmp pword os_code:high_code |
231 | jmp pword os_code:high_code |
232 | 232 | ||
233 | align 4 |
233 | align 4 |
234 | bios32_entry dd ? |
234 | bios32_entry dd ? |
235 | tmp_page_tabs dd ? |
235 | tmp_page_tabs dd ? |
236 | use16 |
236 | use16 |
237 | ap_init16: |
237 | ap_init16: |
238 | cli |
238 | cli |
239 | lgdt [cs:gdts_ap-ap_init16] |
239 | lgdt [cs:gdts_ap-ap_init16] |
240 | mov eax, [cs:cr3_ap-ap_init16] |
240 | mov eax, [cs:cr3_ap-ap_init16] |
241 | mov cr3, eax |
241 | mov cr3, eax |
242 | mov eax, [cs:cr4_ap-ap_init16] |
242 | mov eax, [cs:cr4_ap-ap_init16] |
243 | mov cr4, eax |
243 | mov cr4, eax |
244 | mov eax, CR0_PE+CR0_PG+CR0_WP |
244 | mov eax, CR0_PE+CR0_PG+CR0_WP |
245 | mov cr0, eax |
245 | mov cr0, eax |
246 | jmp pword os_code:ap_init_high |
246 | jmp pword os_code:ap_init_high |
247 | align 16 |
247 | align 16 |
248 | gdts_ap: |
248 | gdts_ap: |
249 | dw gdte-gdts-1 |
249 | dw gdte-gdts-1 |
250 | dd gdts |
250 | dd gdts |
251 | dw 0 |
251 | dw 0 |
252 | cr3_ap dd ? |
252 | cr3_ap dd ? |
253 | cr4_ap dd ? |
253 | cr4_ap dd ? |
254 | ap_init16_size = $ - ap_init16 |
254 | ap_init16_size = $ - ap_init16 |
255 | use32 |
255 | use32 |
256 | 256 | ||
257 | __DEBUG__ fix 1 |
257 | __DEBUG__ fix 1 |
258 | __DEBUG_LEVEL__ fix 1 |
258 | __DEBUG_LEVEL__ fix 1 |
259 | include 'init.inc' |
259 | include 'init.inc' |
260 | 260 | ||
261 | org OS_BASE+$ |
261 | org OS_BASE+$ |
262 | 262 | ||
263 | include 'fdo.inc' |
263 | include 'fdo.inc' |
264 | 264 | ||
265 | align 4 |
265 | align 4 |
266 | high_code: |
266 | high_code: |
267 | mov ax, os_stack |
267 | mov ax, os_stack |
268 | mov bx, app_data |
268 | mov bx, app_data |
269 | mov cx, app_tls |
269 | mov cx, app_tls |
270 | mov ss, ax |
270 | mov ss, ax |
271 | add esp, OS_BASE |
271 | add esp, OS_BASE |
272 | 272 | ||
273 | mov ds, bx |
273 | mov ds, bx |
274 | mov es, bx |
274 | mov es, bx |
275 | mov fs, cx |
275 | mov fs, cx |
276 | mov gs, bx |
276 | mov gs, bx |
277 | 277 | ||
278 | xor eax, eax |
278 | xor eax, eax |
279 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
279 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
280 | bt [cpu_caps], CAPS_PAT |
280 | bt [cpu_caps], CAPS_PAT |
281 | setc al |
281 | setc al |
282 | shl eax, 7 |
282 | shl eax, 7 |
283 | or ebx, eax |
283 | or ebx, eax |
284 | 284 | ||
285 | mov eax, PG_GLOBAL |
285 | mov eax, PG_GLOBAL |
286 | bt [cpu_caps], CAPS_PGE |
286 | bt [cpu_caps], CAPS_PGE |
287 | jnc @F |
287 | jnc @F |
288 | 288 | ||
289 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
289 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
290 | or ebx, eax |
290 | or ebx, eax |
291 | 291 | ||
292 | mov eax, cr4 |
292 | mov eax, cr4 |
293 | or eax, CR4_PGE |
293 | or eax, CR4_PGE |
294 | mov cr4, eax |
294 | mov cr4, eax |
295 | @@: |
295 | @@: |
296 | mov [pte_valid_mask], ebx |
296 | mov [pte_valid_mask], ebx |
297 | 297 | ||
298 | xor eax, eax |
298 | xor eax, eax |
299 | mov dword [sys_proc+PROC.pdt_0], eax |
299 | mov dword [sys_proc+PROC.pdt_0], eax |
300 | mov dword [sys_proc+PROC.pdt_0+4], eax |
300 | mov dword [sys_proc+PROC.pdt_0+4], eax |
301 | 301 | ||
302 | mov eax, cr3 |
302 | mov eax, cr3 |
303 | mov cr3, eax ; flush TLB |
303 | mov cr3, eax ; flush TLB |
304 | 304 | ||
305 | mov ecx, pg_data.mutex |
305 | mov ecx, pg_data.mutex |
306 | call mutex_init |
306 | call mutex_init |
307 | 307 | ||
308 | mov ecx, disk_list_mutex |
308 | mov ecx, disk_list_mutex |
309 | call mutex_init |
309 | call mutex_init |
310 | 310 | ||
311 | mov ecx, keyboard_list_mutex |
311 | mov ecx, keyboard_list_mutex |
312 | call mutex_init |
312 | call mutex_init |
313 | 313 | ||
314 | mov ecx, unpack_mutex |
314 | mov ecx, unpack_mutex |
315 | call mutex_init |
315 | call mutex_init |
316 | 316 | ||
317 | mov ecx, application_table_mutex |
317 | mov ecx, application_table_mutex |
318 | call mutex_init |
318 | call mutex_init |
319 | 319 | ||
320 | mov ecx, ide_mutex |
320 | mov ecx, ide_mutex |
321 | call mutex_init |
321 | call mutex_init |
322 | mov ecx, ide_channel1_mutex |
322 | mov ecx, ide_channel1_mutex |
323 | call mutex_init |
323 | call mutex_init |
324 | mov ecx, ide_channel2_mutex |
324 | mov ecx, ide_channel2_mutex |
325 | call mutex_init |
325 | call mutex_init |
326 | mov ecx, ide_channel3_mutex |
326 | mov ecx, ide_channel3_mutex |
327 | call mutex_init |
327 | call mutex_init |
328 | mov ecx, ide_channel4_mutex |
328 | mov ecx, ide_channel4_mutex |
329 | call mutex_init |
329 | call mutex_init |
330 | mov ecx, ide_channel5_mutex |
330 | mov ecx, ide_channel5_mutex |
331 | call mutex_init |
331 | call mutex_init |
332 | mov ecx, ide_channel6_mutex |
332 | mov ecx, ide_channel6_mutex |
333 | call mutex_init |
333 | call mutex_init |
334 | ;----------------------------------------------------------------------------- |
334 | ;----------------------------------------------------------------------------- |
335 | ; SAVE REAL MODE VARIABLES |
335 | ; SAVE REAL MODE VARIABLES |
336 | ;----------------------------------------------------------------------------- |
336 | ;----------------------------------------------------------------------------- |
337 | ; --------------- APM --------------------- |
337 | ; --------------- APM --------------------- |
338 | 338 | ||
339 | ; init selectors |
339 | ; init selectors |
340 | mov ebx, [BOOT.apm_entry] ; offset of APM entry point |
340 | mov ebx, [BOOT.apm_entry] ; offset of APM entry point |
341 | movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of |
341 | movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of |
342 | ; protected-mode 32-bit code segment |
342 | ; protected-mode 32-bit code segment |
343 | movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of |
343 | movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of |
344 | ; protected-mode 16-bit code segment |
344 | ; protected-mode 16-bit code segment |
345 | movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of |
345 | movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of |
346 | ; protected-mode 16-bit data segment |
346 | ; protected-mode 16-bit data segment |
347 | 347 | ||
348 | shl eax, 4 |
348 | shl eax, 4 |
349 | mov [dword apm_code_32 + 2], ax |
349 | mov [dword apm_code_32 + 2], ax |
350 | shr eax, 16 |
350 | shr eax, 16 |
351 | mov [dword apm_code_32 + 4], al |
351 | mov [dword apm_code_32 + 4], al |
352 | 352 | ||
353 | shl ecx, 4 |
353 | shl ecx, 4 |
354 | mov [dword apm_code_16 + 2], cx |
354 | mov [dword apm_code_16 + 2], cx |
355 | shr ecx, 16 |
355 | shr ecx, 16 |
356 | mov [dword apm_code_16 + 4], cl |
356 | mov [dword apm_code_16 + 4], cl |
357 | 357 | ||
358 | shl edx, 4 |
358 | shl edx, 4 |
359 | mov [dword apm_data_16 + 2], dx |
359 | mov [dword apm_data_16 + 2], dx |
360 | shr edx, 16 |
360 | shr edx, 16 |
361 | mov [dword apm_data_16 + 4], dl |
361 | mov [dword apm_data_16 + 4], dl |
362 | 362 | ||
363 | mov dword[apm_entry], ebx |
363 | mov dword[apm_entry], ebx |
364 | mov word [apm_entry + 4], apm_code_32 - gdts |
364 | mov word [apm_entry + 4], apm_code_32 - gdts |
365 | 365 | ||
366 | mov eax, dword[BOOT.apm_version] ; version & flags |
366 | mov eax, dword[BOOT.apm_version] ; version & flags |
367 | mov [apm_vf], eax |
367 | mov [apm_vf], eax |
368 | ; ----------------------------------------- |
368 | ; ----------------------------------------- |
369 | mov al, [BOOT.dma] ; DMA access |
369 | mov al, [BOOT.dma] ; DMA access |
370 | mov [allow_dma_access], al |
370 | mov [allow_dma_access], al |
371 | 371 | ||
372 | mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen |
372 | mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen |
373 | mov [debug_direct_print], al |
373 | mov [debug_direct_print], al |
374 | 374 | ||
375 | mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded? |
375 | mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded? |
376 | mov [launcher_start], al |
376 | mov [launcher_start], al |
- | 377 | ||
- | 378 | mov eax, [BOOT.devicesdat_size] |
|
- | 379 | mov [acpi_dev_size], eax |
|
- | 380 | mov eax, [BOOT.devicesdat_data] |
|
- | 381 | mov [acpi_dev_data], eax |
|
377 | 382 | ||
378 | mov esi, BOOT.bios_hd |
383 | mov esi, BOOT.bios_hd |
379 | movzx ecx, byte [esi-1] |
384 | movzx ecx, byte [esi-1] |
380 | mov [NumBiosDisks], ecx |
385 | mov [NumBiosDisks], ecx |
381 | mov edi, BiosDisksData |
386 | mov edi, BiosDisksData |
382 | shl ecx, 2 |
387 | shl ecx, 2 |
383 | rep movsd |
388 | rep movsd |
384 | 389 | ||
385 | ; -------- Fast System Call init ---------- |
390 | ; -------- Fast System Call init ---------- |
386 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
391 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
387 | bt [cpu_caps], CAPS_SEP |
392 | bt [cpu_caps], CAPS_SEP |
388 | jnc .SEnP ; SysEnter not Present |
393 | jnc .SEnP ; SysEnter not Present |
389 | xor edx, edx |
394 | xor edx, edx |
390 | mov ecx, MSR_SYSENTER_CS |
395 | mov ecx, MSR_SYSENTER_CS |
391 | mov eax, os_code |
396 | mov eax, os_code |
392 | wrmsr |
397 | wrmsr |
393 | mov ecx, MSR_SYSENTER_ESP |
398 | mov ecx, MSR_SYSENTER_ESP |
394 | ; mov eax, sysenter_stack ; Check it |
399 | ; mov eax, sysenter_stack ; Check it |
395 | xor eax, eax |
400 | xor eax, eax |
396 | wrmsr |
401 | wrmsr |
397 | mov ecx, MSR_SYSENTER_EIP |
402 | mov ecx, MSR_SYSENTER_EIP |
398 | mov eax, sysenter_entry |
403 | mov eax, sysenter_entry |
399 | wrmsr |
404 | wrmsr |
400 | .SEnP: |
405 | .SEnP: |
401 | ; AMD SYSCALL/SYSRET |
406 | ; AMD SYSCALL/SYSRET |
402 | cmp byte[cpu_vendor], 'A' |
407 | cmp byte[cpu_vendor], 'A' |
403 | jne .noSYSCALL |
408 | jne .noSYSCALL |
404 | mov eax, 0x80000001 |
409 | mov eax, 0x80000001 |
405 | cpuid |
410 | cpuid |
406 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
411 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
407 | jz .noSYSCALL |
412 | jz .noSYSCALL |
408 | mov ecx, MSR_AMD_EFER |
413 | mov ecx, MSR_AMD_EFER |
409 | rdmsr |
414 | rdmsr |
410 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
415 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
411 | wrmsr |
416 | wrmsr |
412 | 417 | ||
413 | ; !!!! It`s dirty hack, fix it !!! |
418 | ; !!!! It`s dirty hack, fix it !!! |
414 | ; Bits of EDX : |
419 | ; Bits of EDX : |
415 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
420 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
416 | ; and the contents of this field, plus 8, are copied into the SS register. |
421 | ; and the contents of this field, plus 8, are copied into the SS register. |
417 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
422 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
418 | ; and the contents of this field, plus 8, are copied into the SS register. |
423 | ; and the contents of this field, plus 8, are copied into the SS register. |
419 | 424 | ||
420 | ; mov edx, (os_code + 16) * 65536 + os_code |
425 | ; mov edx, (os_code + 16) * 65536 + os_code |
421 | mov edx, 0x1B0008 |
426 | mov edx, 0x1B0008 |
422 | 427 | ||
423 | mov eax, syscall_entry |
428 | mov eax, syscall_entry |
424 | mov ecx, MSR_AMD_STAR |
429 | mov ecx, MSR_AMD_STAR |
425 | wrmsr |
430 | wrmsr |
426 | .noSYSCALL: |
431 | .noSYSCALL: |
427 | ; ----------------------------------------- |
432 | ; ----------------------------------------- |
428 | stdcall alloc_page |
433 | stdcall alloc_page |
429 | stdcall map_page, tss-0xF80, eax, PG_SWR |
434 | stdcall map_page, tss-0xF80, eax, PG_SWR |
430 | stdcall alloc_page |
435 | stdcall alloc_page |
431 | stdcall map_page, tss+0x80, eax, PG_SWR |
436 | stdcall map_page, tss+0x80, eax, PG_SWR |
432 | stdcall alloc_page |
437 | stdcall alloc_page |
433 | stdcall map_page, tss+0x1080, eax, PG_SWR |
438 | stdcall map_page, tss+0x1080, eax, PG_SWR |
434 | 439 | ||
435 | ; LOAD IDT |
440 | ; LOAD IDT |
436 | 441 | ||
437 | call build_interrupt_table ;lidt is executed |
442 | call build_interrupt_table ;lidt is executed |
438 | ;lidt [idtreg] |
443 | ;lidt [idtreg] |
439 | 444 | ||
440 | call init_kernel_heap |
445 | call init_kernel_heap |
441 | call init_fpu |
446 | call init_fpu |
442 | mov eax, [xsave_area_size] |
447 | mov eax, [xsave_area_size] |
443 | lea eax, [eax*2 + RING0_STACK_SIZE*2] |
448 | lea eax, [eax*2 + RING0_STACK_SIZE*2] |
444 | stdcall kernel_alloc, eax |
449 | stdcall kernel_alloc, eax |
445 | mov [os_stack_seg], eax |
450 | mov [os_stack_seg], eax |
446 | 451 | ||
447 | lea esp, [eax+RING0_STACK_SIZE] |
452 | lea esp, [eax+RING0_STACK_SIZE] |
448 | 453 | ||
449 | mov [tss._ss0], os_stack |
454 | mov [tss._ss0], os_stack |
450 | mov [tss._esp0], esp |
455 | mov [tss._esp0], esp |
451 | mov [tss._esp], esp |
456 | mov [tss._esp], esp |
452 | mov [tss._cs], os_code |
457 | mov [tss._cs], os_code |
453 | mov [tss._ss], os_stack |
458 | mov [tss._ss], os_stack |
454 | mov [tss._ds], app_data |
459 | mov [tss._ds], app_data |
455 | mov [tss._es], app_data |
460 | mov [tss._es], app_data |
456 | mov [tss._fs], app_data |
461 | mov [tss._fs], app_data |
457 | mov [tss._gs], app_data |
462 | mov [tss._gs], app_data |
458 | mov [tss._io], 128 |
463 | mov [tss._io], 128 |
459 | ;Add IO access table - bit array of permitted ports |
464 | ;Add IO access table - bit array of permitted ports |
460 | mov edi, tss._io_map_0 |
465 | mov edi, tss._io_map_0 |
461 | xor eax, eax |
466 | xor eax, eax |
462 | not eax |
467 | not eax |
463 | mov ecx, 8192/4 |
468 | mov ecx, 8192/4 |
464 | rep stosd ; access to 4096*8=65536 ports |
469 | rep stosd ; access to 4096*8=65536 ports |
465 | 470 | ||
466 | mov ax, tss0 |
471 | mov ax, tss0 |
467 | ltr ax |
472 | ltr ax |
468 | 473 | ||
469 | mov eax, sys_proc |
474 | mov eax, sys_proc |
470 | list_init eax |
475 | list_init eax |
471 | add eax, PROC.thr_list |
476 | add eax, PROC.thr_list |
472 | list_init eax |
477 | list_init eax |
473 | 478 | ||
474 | call init_video |
479 | call init_video |
475 | call init_mtrr |
480 | call init_mtrr |
476 | mov [LFBAddress], LFB_BASE |
481 | mov [LFBAddress], LFB_BASE |
477 | mov ecx, bios_fb |
482 | mov ecx, bios_fb |
478 | call set_framebuffer |
483 | call set_framebuffer |
479 | call init_malloc |
484 | call init_malloc |
480 | 485 | ||
481 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
486 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
482 | mov [default_io_map], eax |
487 | mov [default_io_map], eax |
483 | 488 | ||
484 | add eax, 0x2000 |
489 | add eax, 0x2000 |
485 | mov [ipc_tmp], eax |
490 | mov [ipc_tmp], eax |
486 | mov ebx, 0x1000 |
491 | mov ebx, 0x1000 |
487 | 492 | ||
488 | add eax, 0x40000 |
493 | add eax, 0x40000 |
489 | mov [proc_mem_map], eax |
494 | mov [proc_mem_map], eax |
490 | 495 | ||
491 | add eax, 0x8000 |
496 | add eax, 0x8000 |
492 | mov [proc_mem_pdir], eax |
497 | mov [proc_mem_pdir], eax |
493 | 498 | ||
494 | add eax, ebx |
499 | add eax, ebx |
495 | mov [proc_mem_tab], eax |
500 | mov [proc_mem_tab], eax |
496 | 501 | ||
497 | add eax, ebx |
502 | add eax, ebx |
498 | mov [tmp_task_ptab], eax |
503 | mov [tmp_task_ptab], eax |
499 | 504 | ||
500 | add eax, ebx |
505 | add eax, ebx |
501 | mov [ipc_pdir], eax |
506 | mov [ipc_pdir], eax |
502 | 507 | ||
503 | add eax, ebx |
508 | add eax, ebx |
504 | mov [ipc_ptab], eax |
509 | mov [ipc_ptab], eax |
505 | 510 | ||
506 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
511 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
507 | (unpack.lc+unpack.lp)))*4 |
512 | (unpack.lc+unpack.lp)))*4 |
508 | 513 | ||
509 | mov [unpack.p], eax |
514 | mov [unpack.p], eax |
510 | 515 | ||
511 | call init_events |
516 | call init_events |
512 | mov eax, srv.fd-SRV.fd |
517 | mov eax, srv.fd-SRV.fd |
513 | mov [srv.fd], eax |
518 | mov [srv.fd], eax |
514 | mov [srv.bk], eax |
519 | mov [srv.bk], eax |
515 | 520 | ||
516 | ;Set base of graphic segment to linear address of LFB |
521 | ;Set base of graphic segment to linear address of LFB |
517 | mov eax, [LFBAddress] ; set for gs |
522 | mov eax, [LFBAddress] ; set for gs |
518 | mov [graph_data_l+2], ax |
523 | mov [graph_data_l+2], ax |
519 | shr eax, 16 |
524 | shr eax, 16 |
520 | mov [graph_data_l+4], al |
525 | mov [graph_data_l+4], al |
521 | mov [graph_data_l+7], ah |
526 | mov [graph_data_l+7], ah |
522 | 527 | ||
523 | stdcall kernel_alloc, [_display.win_map_size] |
528 | stdcall kernel_alloc, [_display.win_map_size] |
524 | mov [_display.win_map], eax |
529 | mov [_display.win_map], eax |
525 | 530 | ||
526 | xor eax, eax |
531 | xor eax, eax |
527 | inc eax |
532 | inc eax |
528 | 533 | ||
529 | ; set background |
534 | ; set background |
530 | 535 | ||
531 | mov [BgrDrawMode], eax |
536 | mov [BgrDrawMode], eax |
532 | mov [BgrDataWidth], eax |
537 | mov [BgrDataWidth], eax |
533 | mov [BgrDataHeight], eax |
538 | mov [BgrDataHeight], eax |
534 | mov [mem_BACKGROUND], 4 |
539 | mov [mem_BACKGROUND], 4 |
535 | mov [img_background], static_background_data |
540 | mov [img_background], static_background_data |
536 | 541 | ||
537 | ; set clipboard |
542 | ; set clipboard |
538 | 543 | ||
539 | xor eax, eax |
544 | xor eax, eax |
540 | mov [clipboard_slots], eax |
545 | mov [clipboard_slots], eax |
541 | mov [clipboard_write_lock], eax |
546 | mov [clipboard_write_lock], eax |
542 | stdcall kernel_alloc, 4096 |
547 | stdcall kernel_alloc, 4096 |
543 | test eax, eax |
548 | test eax, eax |
544 | jnz @f |
549 | jnz @f |
545 | 550 | ||
546 | dec eax |
551 | dec eax |
547 | @@: |
552 | @@: |
548 | mov [clipboard_main_list], eax |
553 | mov [clipboard_main_list], eax |
549 | 554 | ||
550 | mov eax, [hpet_base] |
555 | mov eax, [hpet_base] |
551 | test eax, eax |
556 | test eax, eax |
552 | jz @F |
557 | jz @F |
553 | mov eax, [hpet_base] |
558 | mov eax, [hpet_base] |
554 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
559 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
555 | mov [hpet_base], eax |
560 | mov [hpet_base], eax |
556 | mov eax, [eax] |
561 | mov eax, [eax] |
557 | DEBUGF 1, "K : HPET caps %x\n", eax |
562 | DEBUGF 1, "K : HPET caps %x\n", eax |
558 | @@: |
563 | @@: |
559 | ; SET UP OS TASK |
564 | ; SET UP OS TASK |
560 | 565 | ||
561 | mov esi, boot_setostask |
566 | mov esi, boot_setostask |
562 | call boot_log |
567 | call boot_log |
563 | 568 | ||
564 | mov edi, sys_proc+PROC.heap_lock |
569 | mov edi, sys_proc+PROC.heap_lock |
565 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
570 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
566 | 571 | ||
567 | xor eax, eax |
572 | xor eax, eax |
568 | cld |
573 | cld |
569 | rep stosd |
574 | rep stosd |
570 | 575 | ||
571 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
576 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
572 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
577 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
573 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
578 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
574 | add edi, 8 |
579 | add edi, 8 |
575 | inc eax |
580 | inc eax |
576 | @@: |
581 | @@: |
577 | stosd |
582 | stosd |
578 | inc eax |
583 | inc eax |
579 | cmp eax, ecx |
584 | cmp eax, ecx |
580 | jbe @B |
585 | jbe @B |
581 | 586 | ||
582 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
587 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
583 | 588 | ||
584 | mov eax, -1 |
589 | mov eax, -1 |
585 | mov edi, thr_slot_map+4 |
590 | mov edi, thr_slot_map+4 |
586 | mov [edi-4], dword 0xFFFFFFF8 |
591 | mov [edi-4], dword 0xFFFFFFF8 |
587 | stosd |
592 | stosd |
588 | stosd |
593 | stosd |
589 | stosd |
594 | stosd |
590 | stosd |
595 | stosd |
591 | stosd |
596 | stosd |
592 | stosd |
597 | stosd |
593 | stosd |
598 | stosd |
594 | 599 | ||
595 | mov [current_process], sys_proc |
600 | mov [current_process], sys_proc |
596 | 601 | ||
597 | mov edx, SLOT_BASE+256*1 |
602 | mov edx, SLOT_BASE+256*1 |
598 | mov ebx, [os_stack_seg] |
603 | mov ebx, [os_stack_seg] |
599 | add ebx, RING0_STACK_SIZE |
604 | add ebx, RING0_STACK_SIZE |
600 | add ebx, [xsave_area_size] |
605 | add ebx, [xsave_area_size] |
601 | call setup_os_slot |
606 | call setup_os_slot |
602 | mov dword [edx], 'IDLE' |
607 | mov dword [edx], 'IDLE' |
603 | sub [edx+APPDATA.saved_esp], 4 |
608 | sub [edx+APPDATA.saved_esp], 4 |
604 | mov eax, [edx+APPDATA.saved_esp] |
609 | mov eax, [edx+APPDATA.saved_esp] |
605 | mov dword [eax], idle_thread |
610 | mov dword [eax], idle_thread |
606 | mov ecx, IDLE_PRIORITY |
611 | mov ecx, IDLE_PRIORITY |
607 | call scheduler_add_thread |
612 | call scheduler_add_thread |
608 | 613 | ||
609 | mov edx, SLOT_BASE+256*2 |
614 | mov edx, SLOT_BASE+256*2 |
610 | mov ebx, [os_stack_seg] |
615 | mov ebx, [os_stack_seg] |
611 | call setup_os_slot |
616 | call setup_os_slot |
612 | mov dword [edx], 'OS' |
617 | mov dword [edx], 'OS' |
613 | xor ecx, ecx |
618 | xor ecx, ecx |
614 | call scheduler_add_thread |
619 | call scheduler_add_thread |
615 | 620 | ||
616 | mov dword [CURRENT_TASK], 2 |
621 | mov dword [CURRENT_TASK], 2 |
617 | mov dword [TASK_COUNT], 2 |
622 | mov dword [TASK_COUNT], 2 |
618 | mov dword [current_slot], SLOT_BASE + 256*2 |
623 | mov dword [current_slot], SLOT_BASE + 256*2 |
619 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
624 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
620 | 625 | ||
621 | ; Move other CPUs to deep sleep, if it is useful |
626 | ; Move other CPUs to deep sleep, if it is useful |
622 | uglobal |
627 | uglobal |
623 | use_mwait_for_idle db 0 |
628 | use_mwait_for_idle db 0 |
624 | endg |
629 | endg |
625 | cmp [cpu_vendor+8], 'ntel' |
630 | cmp [cpu_vendor+8], 'ntel' |
626 | jnz .no_wake_cpus |
631 | jnz .no_wake_cpus |
627 | bt [cpu_caps+4], CAPS_MONITOR-32 |
632 | bt [cpu_caps+4], CAPS_MONITOR-32 |
628 | jnc .no_wake_cpus |
633 | jnc .no_wake_cpus |
629 | dbgstr 'using mwait for idle loop' |
634 | dbgstr 'using mwait for idle loop' |
630 | inc [use_mwait_for_idle] |
635 | inc [use_mwait_for_idle] |
631 | mov ebx, [cpu_count] |
636 | mov ebx, [cpu_count] |
632 | cmp ebx, 1 |
637 | cmp ebx, 1 |
633 | jbe .no_wake_cpus |
638 | jbe .no_wake_cpus |
634 | call create_trampoline_pgmap |
639 | call create_trampoline_pgmap |
635 | mov [cr3_ap+OS_BASE], eax |
640 | mov [cr3_ap+OS_BASE], eax |
636 | mov eax, cr4 |
641 | mov eax, cr4 |
637 | mov [cr4_ap+OS_BASE], eax |
642 | mov [cr4_ap+OS_BASE], eax |
638 | mov esi, OS_BASE + ap_init16 |
643 | mov esi, OS_BASE + ap_init16 |
639 | mov edi, OS_BASE + 8000h |
644 | mov edi, OS_BASE + 8000h |
640 | mov ecx, (ap_init16_size + 3) / 4 |
645 | mov ecx, (ap_init16_size + 3) / 4 |
641 | rep movsd |
646 | rep movsd |
642 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
647 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
643 | mov [LAPIC_BASE], eax |
648 | mov [LAPIC_BASE], eax |
644 | lea edi, [eax+300h] |
649 | lea edi, [eax+300h] |
645 | mov esi, smpt+4 |
650 | mov esi, smpt+4 |
646 | dec ebx |
651 | dec ebx |
647 | .wake_cpus_loop: |
652 | .wake_cpus_loop: |
648 | lodsd |
653 | lodsd |
649 | push esi |
654 | push esi |
650 | xor esi, esi |
655 | xor esi, esi |
651 | inc esi |
656 | inc esi |
652 | shl eax, 24 |
657 | shl eax, 24 |
653 | mov [edi+10h], eax |
658 | mov [edi+10h], eax |
654 | ; assert INIT IPI |
659 | ; assert INIT IPI |
655 | mov dword [edi], 0C500h |
660 | mov dword [edi], 0C500h |
656 | call delay_ms |
661 | call delay_ms |
657 | @@: |
662 | @@: |
658 | test dword [edi], 1000h |
663 | test dword [edi], 1000h |
659 | jnz @b |
664 | jnz @b |
660 | ; deassert INIT IPI |
665 | ; deassert INIT IPI |
661 | mov dword [edi], 8500h |
666 | mov dword [edi], 8500h |
662 | call delay_ms |
667 | call delay_ms |
663 | @@: |
668 | @@: |
664 | test dword [edi], 1000h |
669 | test dword [edi], 1000h |
665 | jnz @b |
670 | jnz @b |
666 | ; send STARTUP IPI |
671 | ; send STARTUP IPI |
667 | mov dword [edi], 600h + (8000h shr 12) |
672 | mov dword [edi], 600h + (8000h shr 12) |
668 | call delay_ms |
673 | call delay_ms |
669 | @@: |
674 | @@: |
670 | test dword [edi], 1000h |
675 | test dword [edi], 1000h |
671 | jnz @b |
676 | jnz @b |
672 | pop esi |
677 | pop esi |
673 | dec ebx |
678 | dec ebx |
674 | jnz .wake_cpus_loop |
679 | jnz .wake_cpus_loop |
675 | mov eax, [cpu_count] |
680 | mov eax, [cpu_count] |
676 | dec eax |
681 | dec eax |
677 | @@: |
682 | @@: |
678 | cmp [ap_initialized], eax |
683 | cmp [ap_initialized], eax |
679 | jnz @b |
684 | jnz @b |
680 | mov eax, [cr3_ap+OS_BASE] |
685 | mov eax, [cr3_ap+OS_BASE] |
681 | call free_page |
686 | call free_page |
682 | .no_wake_cpus: |
687 | .no_wake_cpus: |
683 | 688 | ||
684 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
689 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
685 | mov esi, boot_initirq |
690 | mov esi, boot_initirq |
686 | call boot_log |
691 | call boot_log |
687 | call init_irqs |
692 | call init_irqs |
688 | 693 | ||
689 | mov esi, boot_picinit |
694 | mov esi, boot_picinit |
690 | call boot_log |
695 | call boot_log |
691 | call PIC_init |
696 | call PIC_init |
692 | 697 | ||
693 | mov esi, boot_v86machine |
698 | mov esi, boot_v86machine |
694 | call boot_log |
699 | call boot_log |
695 | ; Initialize system V86 machine |
700 | ; Initialize system V86 machine |
696 | call init_sys_v86 |
701 | call init_sys_v86 |
697 | 702 | ||
698 | mov esi, boot_inittimer |
703 | mov esi, boot_inittimer |
699 | call boot_log |
704 | call boot_log |
700 | ; Initialize system timer (IRQ0) |
705 | ; Initialize system timer (IRQ0) |
701 | call PIT_init |
706 | call PIT_init |
702 | 707 | ||
703 | ; Register ramdisk file system |
708 | ; Register ramdisk file system |
704 | if ~ defined extended_primary_loader |
709 | if ~ defined extended_primary_loader |
705 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD ; will be loaded later |
710 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD ; will be loaded later |
706 | je @f |
711 | je @f |
707 | end if |
712 | end if |
708 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_NONE |
713 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_NONE |
709 | je @f |
714 | je @f |
710 | call register_ramdisk |
715 | call register_ramdisk |
711 | ;-------------------------------------- |
716 | ;-------------------------------------- |
712 | @@: |
717 | @@: |
713 | mov esi, boot_initapic |
718 | mov esi, boot_initapic |
714 | call boot_log |
719 | call boot_log |
715 | ; Try to Initialize APIC |
720 | ; Try to Initialize APIC |
716 | call APIC_init |
721 | call APIC_init |
717 | 722 | ||
718 | mov esi, boot_enableirq |
723 | mov esi, boot_enableirq |
719 | call boot_log |
724 | call boot_log |
720 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
725 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
721 | ; they are used: when partitions are scanned, hd_read relies on timer |
726 | ; they are used: when partitions are scanned, hd_read relies on timer |
722 | call unmask_timer |
727 | call unmask_timer |
723 | ; Prevent duplicate timer IRQs in APIC mode |
728 | ; Prevent duplicate timer IRQs in APIC mode |
724 | cmp [irq_mode], IRQ_APIC |
729 | cmp [irq_mode], IRQ_APIC |
725 | jz @f |
730 | jz @f |
726 | stdcall enable_irq, 2 ; @#$%! PIC |
731 | stdcall enable_irq, 2 ; @#$%! PIC |
727 | @@: |
732 | @@: |
728 | stdcall enable_irq, 13 ; co-processor |
733 | stdcall enable_irq, 13 ; co-processor |
729 | 734 | ||
730 | ; Setup serial output console (if enabled) |
735 | ; Setup serial output console (if enabled) |
731 | if defined debug_com_base |
736 | if defined debug_com_base |
732 | 737 | ||
733 | ; reserve port so nobody else will use it |
738 | ; reserve port so nobody else will use it |
734 | xor ebx, ebx |
739 | xor ebx, ebx |
735 | mov ecx, debug_com_base |
740 | mov ecx, debug_com_base |
736 | mov edx, debug_com_base+7 |
741 | mov edx, debug_com_base+7 |
737 | call r_f_port_area |
742 | call r_f_port_area |
738 | 743 | ||
739 | ; enable Divisor latch |
744 | ; enable Divisor latch |
740 | mov dx, debug_com_base+3 |
745 | mov dx, debug_com_base+3 |
741 | mov al, 1 shl 7 |
746 | mov al, 1 shl 7 |
742 | out dx, al |
747 | out dx, al |
743 | 748 | ||
744 | ; Set speed to 115200 baud (max speed) |
749 | ; Set speed to 115200 baud (max speed) |
745 | mov dx, debug_com_base |
750 | mov dx, debug_com_base |
746 | mov al, 0x01 |
751 | mov al, 0x01 |
747 | out dx, al |
752 | out dx, al |
748 | 753 | ||
749 | mov dx, debug_com_base+1 |
754 | mov dx, debug_com_base+1 |
750 | mov al, 0x00 |
755 | mov al, 0x00 |
751 | out dx, al |
756 | out dx, al |
752 | 757 | ||
753 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
758 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
754 | mov dx, debug_com_base+3 |
759 | mov dx, debug_com_base+3 |
755 | mov al, 3 |
760 | mov al, 3 |
756 | out dx, al |
761 | out dx, al |
757 | 762 | ||
758 | ; disable interrupts |
763 | ; disable interrupts |
759 | mov dx, debug_com_base+1 |
764 | mov dx, debug_com_base+1 |
760 | mov al, 0 |
765 | mov al, 0 |
761 | out dx, al |
766 | out dx, al |
762 | 767 | ||
763 | ; clear + enable fifo (64 bits) |
768 | ; clear + enable fifo (64 bits) |
764 | mov dx, debug_com_base+2 |
769 | mov dx, debug_com_base+2 |
765 | mov al, 0x7 + 1 shl 5 |
770 | mov al, 0x7 + 1 shl 5 |
766 | out dx, al |
771 | out dx, al |
767 | 772 | ||
768 | end if |
773 | end if |
769 | 774 | ||
770 | 775 | ||
771 | ;----------------------------------------------------------------------------- |
776 | ;----------------------------------------------------------------------------- |
772 | ; show SVN version of kernel on the message board |
777 | ; show SVN version of kernel on the message board |
773 | ;----------------------------------------------------------------------------- |
778 | ;----------------------------------------------------------------------------- |
774 | mov eax, [version_inf.rev] |
779 | mov eax, [version_inf.rev] |
775 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
780 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
776 | ;----------------------------------------------------------------------------- |
781 | ;----------------------------------------------------------------------------- |
777 | ; show CPU count on the message board |
782 | ; show CPU count on the message board |
778 | ;----------------------------------------------------------------------------- |
783 | ;----------------------------------------------------------------------------- |
779 | mov eax, [cpu_count] |
784 | mov eax, [cpu_count] |
780 | test eax, eax |
785 | test eax, eax |
781 | jnz @F |
786 | jnz @F |
782 | mov al, 1 ; at least one CPU |
787 | mov al, 1 ; at least one CPU |
783 | @@: |
788 | @@: |
784 | DEBUGF 1, "K : %d CPU detected\n", eax |
789 | DEBUGF 1, "K : %d CPU detected\n", eax |
785 | ;----------------------------------------------------------------------------- |
790 | ;----------------------------------------------------------------------------- |
786 | ; detect Floppy drives |
791 | ; detect Floppy drives |
787 | ;----------------------------------------------------------------------------- |
792 | ;----------------------------------------------------------------------------- |
788 | mov esi, boot_detectfloppy |
793 | mov esi, boot_detectfloppy |
789 | call boot_log |
794 | call boot_log |
790 | include 'detect/dev_fd.inc' |
795 | include 'detect/dev_fd.inc' |
791 | ;----------------------------------------------------------------------------- |
796 | ;----------------------------------------------------------------------------- |
792 | ; create pci-devices list |
797 | ; create pci-devices list |
793 | ;----------------------------------------------------------------------------- |
798 | ;----------------------------------------------------------------------------- |
794 | mov [pci_access_enabled], 1 |
799 | mov [pci_access_enabled], 1 |
795 | call pci_enum |
800 | call pci_enum |
796 | ;----------------------------------------------------------------------------- |
801 | ;----------------------------------------------------------------------------- |
797 | ; initialisation IDE ATA code |
802 | ; initialisation IDE ATA code |
798 | ;----------------------------------------------------------------------------- |
803 | ;----------------------------------------------------------------------------- |
799 | include 'detect/init_ata.inc' |
804 | include 'detect/init_ata.inc' |
800 | ;----------------------------------------------------------------------------- |
805 | ;----------------------------------------------------------------------------- |
801 | if 0 |
806 | if 0 |
802 | mov ax, [BOOT.sys_disk] |
807 | mov ax, [BOOT.sys_disk] |
803 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
808 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
804 | je no_lib_load |
809 | je no_lib_load |
805 | 810 | ||
806 | mov esi, boot_loadlibs |
811 | mov esi, boot_loadlibs |
807 | call boot_log |
812 | call boot_log |
808 | ; LOADING LIBRARES |
813 | ; LOADING LIBRARES |
809 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
814 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
810 | call load_file_parse_table ; prepare file parse table |
815 | call load_file_parse_table ; prepare file parse table |
811 | call set_kernel_conf ; configure devices and gui |
816 | call set_kernel_conf ; configure devices and gui |
812 | no_lib_load: |
817 | no_lib_load: |
813 | end if |
818 | end if |
814 | 819 | ||
815 | ; Display APIC status |
820 | ; Display APIC status |
816 | mov esi, boot_APIC_found |
821 | mov esi, boot_APIC_found |
817 | cmp [irq_mode], IRQ_APIC |
822 | cmp [irq_mode], IRQ_APIC |
818 | je @f |
823 | je @f |
819 | mov esi, boot_APIC_nfound |
824 | mov esi, boot_APIC_nfound |
820 | @@: |
825 | @@: |
821 | call boot_log |
826 | call boot_log |
822 | 827 | ||
823 | ; PRINT AMOUNT OF MEMORY |
828 | ; PRINT AMOUNT OF MEMORY |
824 | mov esi, boot_memdetect |
829 | mov esi, boot_memdetect |
825 | call boot_log |
830 | call boot_log |
826 | 831 | ||
827 | movzx ecx, word [boot_y] |
832 | movzx ecx, word [boot_y] |
828 | if lang eq ru |
833 | if lang eq ru |
829 | or ecx, (10+30*6) shl 16 |
834 | or ecx, (10+30*6) shl 16 |
830 | else if lang eq sp |
835 | else if lang eq sp |
831 | or ecx, (10+33*6) shl 16 |
836 | or ecx, (10+33*6) shl 16 |
832 | else |
837 | else |
833 | or ecx, (10+29*6) shl 16 |
838 | or ecx, (10+29*6) shl 16 |
834 | end if |
839 | end if |
835 | sub ecx, 10 |
840 | sub ecx, 10 |
836 | mov edx, 0xFFFFFF |
841 | mov edx, 0xFFFFFF |
837 | mov ebx, [MEM_AMOUNT] |
842 | mov ebx, [MEM_AMOUNT] |
838 | shr ebx, 20 |
843 | shr ebx, 20 |
839 | xor edi, edi |
844 | xor edi, edi |
840 | mov eax, 0x00040000 |
845 | mov eax, 0x00040000 |
841 | inc edi |
846 | inc edi |
842 | call display_number_force |
847 | call display_number_force |
843 | 848 | ||
844 | ; BUILD SCHEDULER |
849 | ; BUILD SCHEDULER |
845 | 850 | ||
846 | ; call build_scheduler; sys32.inc |
851 | ; call build_scheduler; sys32.inc |
847 | 852 | ||
848 | ; mov esi, boot_devices |
853 | ; mov esi, boot_devices |
849 | ; call boot_log |
854 | ; call boot_log |
850 | 855 | ||
851 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
856 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
852 | 857 | ||
853 | stdcall load_pe_driver, szVidintel, 0 |
858 | stdcall load_pe_driver, szVidintel, 0 |
854 | 859 | ||
855 | call usb_init |
860 | call usb_init |
856 | 861 | ||
857 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
862 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
858 | 863 | ||
859 | mov esi, boot_windefs |
864 | mov esi, boot_windefs |
860 | call boot_log |
865 | call boot_log |
861 | call set_window_defaults |
866 | call set_window_defaults |
862 | 867 | ||
863 | ; SET BACKGROUND DEFAULTS |
868 | ; SET BACKGROUND DEFAULTS |
864 | 869 | ||
865 | mov esi, boot_bgr |
870 | mov esi, boot_bgr |
866 | call boot_log |
871 | call boot_log |
867 | call init_background |
872 | call init_background |
868 | call calculatebackground |
873 | call calculatebackground |
869 | 874 | ||
870 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
875 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
871 | 876 | ||
872 | mov esi, boot_resirqports |
877 | mov esi, boot_resirqports |
873 | call boot_log |
878 | call boot_log |
874 | call reserve_irqs_ports |
879 | call reserve_irqs_ports |
875 | 880 | ||
876 | call init_display |
881 | call init_display |
877 | mov eax, [def_cursor] |
882 | mov eax, [def_cursor] |
878 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
883 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
879 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
884 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
880 | 885 | ||
881 | ; PRINT CPU FREQUENCY |
886 | ; PRINT CPU FREQUENCY |
882 | 887 | ||
883 | mov esi, boot_cpufreq |
888 | mov esi, boot_cpufreq |
884 | call boot_log |
889 | call boot_log |
885 | 890 | ||
886 | cli |
891 | cli |
887 | mov ebx, [hpet_base] |
892 | mov ebx, [hpet_base] |
888 | test ebx, ebx |
893 | test ebx, ebx |
889 | jz @F |
894 | jz @F |
890 | mov ebx, [ebx+0xF0] |
895 | mov ebx, [ebx+0xF0] |
891 | 896 | ||
892 | rdtsc |
897 | rdtsc |
893 | mov ecx, 1000 |
898 | mov ecx, 1000 |
894 | sub eax, [hpet_tsc_start] |
899 | sub eax, [hpet_tsc_start] |
895 | sbb edx, [hpet_tsc_start+4] |
900 | sbb edx, [hpet_tsc_start+4] |
896 | shld edx, eax, 10 |
901 | shld edx, eax, 10 |
897 | shl eax, 10 |
902 | shl eax, 10 |
898 | mov esi, eax |
903 | mov esi, eax |
899 | mov eax, edx |
904 | mov eax, edx |
900 | mul ecx |
905 | mul ecx |
901 | xchg eax, esi |
906 | xchg eax, esi |
902 | mul ecx |
907 | mul ecx |
903 | adc edx, esi |
908 | adc edx, esi |
904 | div ebx |
909 | div ebx |
905 | mul ecx |
910 | mul ecx |
906 | div [hpet_period] |
911 | div [hpet_period] |
907 | mul ecx |
912 | mul ecx |
908 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
913 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
909 | jmp .next |
914 | jmp .next |
910 | @@: |
915 | @@: |
911 | rdtsc |
916 | rdtsc |
912 | mov ecx, eax |
917 | mov ecx, eax |
913 | mov esi, 250 ; wait 1/4 a second |
918 | mov esi, 250 ; wait 1/4 a second |
914 | call delay_ms |
919 | call delay_ms |
915 | rdtsc |
920 | rdtsc |
916 | 921 | ||
917 | sub eax, ecx |
922 | sub eax, ecx |
918 | xor edx, edx |
923 | xor edx, edx |
919 | shld edx, eax, 2 |
924 | shld edx, eax, 2 |
920 | shl eax, 2 |
925 | shl eax, 2 |
921 | .next: |
926 | .next: |
922 | mov dword [cpu_freq], eax |
927 | mov dword [cpu_freq], eax |
923 | mov dword [cpu_freq+4], edx |
928 | mov dword [cpu_freq+4], edx |
924 | mov ebx, 1000000 |
929 | mov ebx, 1000000 |
925 | div ebx |
930 | div ebx |
926 | mov ebx, eax |
931 | mov ebx, eax |
927 | 932 | ||
928 | movzx ecx, word [boot_y] |
933 | movzx ecx, word [boot_y] |
929 | if lang eq ru |
934 | if lang eq ru |
930 | add ecx, (10+19*6) shl 16 - 10 |
935 | add ecx, (10+19*6) shl 16 - 10 |
931 | else if lang eq sp |
936 | else if lang eq sp |
932 | add ecx, (10+25*6) shl 16 - 10 |
937 | add ecx, (10+25*6) shl 16 - 10 |
933 | else |
938 | else |
934 | add ecx, (10+17*6) shl 16 - 10 |
939 | add ecx, (10+17*6) shl 16 - 10 |
935 | end if |
940 | end if |
936 | 941 | ||
937 | mov edx, 0xFFFFFF |
942 | mov edx, 0xFFFFFF |
938 | xor edi, edi |
943 | xor edi, edi |
939 | mov eax, 0x00040000 |
944 | mov eax, 0x00040000 |
940 | inc edi |
945 | inc edi |
941 | call display_number_force |
946 | call display_number_force |
942 | 947 | ||
943 | ; SET VARIABLES |
948 | ; SET VARIABLES |
944 | 949 | ||
945 | call set_variables |
950 | call set_variables |
946 | 951 | ||
947 | ; STACK AND FDC |
952 | ; STACK AND FDC |
948 | 953 | ||
949 | call stack_init |
954 | call stack_init |
950 | call fdc_init |
955 | call fdc_init |
951 | 956 | ||
952 | ; PALETTE FOR 320x200 and 640x480 16 col |
957 | ; PALETTE FOR 320x200 and 640x480 16 col |
953 | 958 | ||
954 | cmp [SCR_MODE], word 0x12 |
959 | cmp [SCR_MODE], word 0x12 |
955 | jne no_pal_vga |
960 | jne no_pal_vga |
956 | mov esi, boot_pal_vga |
961 | mov esi, boot_pal_vga |
957 | call boot_log |
962 | call boot_log |
958 | call paletteVGA |
963 | call paletteVGA |
959 | no_pal_vga: |
964 | no_pal_vga: |
960 | 965 | ||
961 | cmp [SCR_MODE], word 0x13 |
966 | cmp [SCR_MODE], word 0x13 |
962 | jne no_pal_ega |
967 | jne no_pal_ega |
963 | mov esi, boot_pal_ega |
968 | mov esi, boot_pal_ega |
964 | call boot_log |
969 | call boot_log |
965 | call palette320x200 |
970 | call palette320x200 |
966 | no_pal_ega: |
971 | no_pal_ega: |
967 | 972 | ||
968 | ; LOAD DEFAULT SKIN |
973 | ; LOAD DEFAULT SKIN |
969 | 974 | ||
970 | call load_default_skin |
975 | call load_default_skin |
971 | 976 | ||
972 | ; Protect I/O permission map |
977 | ; Protect I/O permission map |
973 | 978 | ||
974 | mov esi, [default_io_map] |
979 | mov esi, [default_io_map] |
975 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
980 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
976 | add esi, 0x1000 |
981 | add esi, 0x1000 |
977 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
982 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
978 | 983 | ||
979 | stdcall map_page, tss._io_map_0, \ |
984 | stdcall map_page, tss._io_map_0, \ |
980 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
985 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
981 | stdcall map_page, tss._io_map_1, \ |
986 | stdcall map_page, tss._io_map_1, \ |
982 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
987 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
983 | 988 | ||
984 | ; SET KEYBOARD PARAMETERS |
989 | ; SET KEYBOARD PARAMETERS |
985 | mov al, 0xf6 ; reset keyboard, scan enabled |
990 | mov al, 0xf6 ; reset keyboard, scan enabled |
986 | call kb_write_wait_ack |
991 | call kb_write_wait_ack |
987 | test ah, ah |
992 | test ah, ah |
988 | jnz .no_keyboard |
993 | jnz .no_keyboard |
989 | 994 | ||
990 | iglobal |
995 | iglobal |
991 | align 4 |
996 | align 4 |
992 | ps2_keyboard_functions: |
997 | ps2_keyboard_functions: |
993 | dd .end - $ |
998 | dd .end - $ |
994 | dd 0 ; no close |
999 | dd 0 ; no close |
995 | dd ps2_set_lights |
1000 | dd ps2_set_lights |
996 | .end: |
1001 | .end: |
997 | endg |
1002 | endg |
998 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1003 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
999 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1004 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1000 | ; call kb_write_wait_ack |
1005 | ; call kb_write_wait_ack |
1001 | ; mov al, 111b |
1006 | ; mov al, 111b |
1002 | ; call kb_write_wait_ack |
1007 | ; call kb_write_wait_ack |
1003 | 1008 | ||
1004 | mov al, 0xF3 ; set repeat rate & delay |
1009 | mov al, 0xF3 ; set repeat rate & delay |
1005 | call kb_write_wait_ack |
1010 | call kb_write_wait_ack |
1006 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1011 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1007 | call kb_write_wait_ack |
1012 | call kb_write_wait_ack |
1008 | ;// mike.dld [ |
1013 | ;// mike.dld [ |
1009 | call set_lights |
1014 | call set_lights |
1010 | ;// mike.dld ] |
1015 | ;// mike.dld ] |
1011 | stdcall attach_int_handler, 1, irq1, 0 |
1016 | stdcall attach_int_handler, 1, irq1, 0 |
1012 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1017 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1013 | .no_keyboard: |
1018 | .no_keyboard: |
1014 | 1019 | ||
1015 | ; Load PS/2 mouse driver |
1020 | ; Load PS/2 mouse driver |
1016 | 1021 | ||
1017 | stdcall load_pe_driver, szPS2MDriver, 0 |
1022 | stdcall load_pe_driver, szPS2MDriver, 0 |
1018 | 1023 | ||
1019 | mov esi, boot_setmouse |
1024 | mov esi, boot_setmouse |
1020 | call boot_log |
1025 | call boot_log |
1021 | call setmouse |
1026 | call setmouse |
1022 | 1027 | ||
1023 | ; LOAD FIRST APPLICATION |
1028 | ; LOAD FIRST APPLICATION |
1024 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1029 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1025 | jnz first_app_found |
1030 | jnz first_app_found |
1026 | 1031 | ||
1027 | cli |
1032 | cli |
1028 | mov ebp, firstapp |
1033 | mov ebp, firstapp |
1029 | call fs_execute_from_sysdir |
1034 | call fs_execute_from_sysdir |
1030 | test eax, eax |
1035 | test eax, eax |
1031 | jns first_app_found |
1036 | jns first_app_found |
1032 | 1037 | ||
1033 | mov esi, boot_failed |
1038 | mov esi, boot_failed |
1034 | call boot_log |
1039 | call boot_log |
1035 | 1040 | ||
1036 | mov eax, 0xDEADBEEF ; otherwise halt |
1041 | mov eax, 0xDEADBEEF ; otherwise halt |
1037 | hlt |
1042 | hlt |
1038 | 1043 | ||
1039 | first_app_found: |
1044 | first_app_found: |
1040 | 1045 | ||
1041 | ; START MULTITASKING |
1046 | ; START MULTITASKING |
1042 | preboot_blogesc = 0 ; start immediately after bootlog |
1047 | preboot_blogesc = 0 ; start immediately after bootlog |
1043 | 1048 | ||
1044 | ; A 'All set - press ESC to start' messages if need |
1049 | ; A 'All set - press ESC to start' messages if need |
1045 | if preboot_blogesc |
1050 | if preboot_blogesc |
1046 | mov esi, boot_tasking |
1051 | mov esi, boot_tasking |
1047 | call boot_log |
1052 | call boot_log |
1048 | .bll1: |
1053 | .bll1: |
1049 | in al, 0x60 ; wait for ESC key press |
1054 | in al, 0x60 ; wait for ESC key press |
1050 | cmp al, 129 |
1055 | cmp al, 129 |
1051 | jne .bll1 |
1056 | jne .bll1 |
1052 | end if |
1057 | end if |
1053 | 1058 | ||
1054 | mov [timer_ticks_enable], 1 ; for cd driver |
1059 | mov [timer_ticks_enable], 1 ; for cd driver |
1055 | 1060 | ||
1056 | sti |
1061 | sti |
1057 | 1062 | ||
1058 | call mtrr_validate |
1063 | call mtrr_validate |
1059 | 1064 | ||
1060 | jmp osloop |
1065 | jmp osloop |
1061 | 1066 | ||
1062 | 1067 | ||
1063 | ; Fly :) |
1068 | ; Fly :) |
1064 | 1069 | ||
1065 | uglobal |
1070 | uglobal |
1066 | align 4 |
1071 | align 4 |
1067 | ap_initialized dd 0 |
1072 | ap_initialized dd 0 |
1068 | endg |
1073 | endg |
1069 | 1074 | ||
1070 | ap_init_high: |
1075 | ap_init_high: |
1071 | mov ax, os_stack |
1076 | mov ax, os_stack |
1072 | mov bx, app_data |
1077 | mov bx, app_data |
1073 | mov cx, app_tls |
1078 | mov cx, app_tls |
1074 | mov ss, ax |
1079 | mov ss, ax |
1075 | mov ds, bx |
1080 | mov ds, bx |
1076 | mov es, bx |
1081 | mov es, bx |
1077 | mov fs, cx |
1082 | mov fs, cx |
1078 | mov gs, bx |
1083 | mov gs, bx |
1079 | xor esp, esp |
1084 | xor esp, esp |
1080 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1085 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1081 | mov cr3, eax |
1086 | mov cr3, eax |
1082 | lock inc [ap_initialized] |
1087 | lock inc [ap_initialized] |
1083 | jmp idle_loop |
1088 | jmp idle_loop |
1084 | 1089 | ||
1085 | 1090 | ||
1086 | include 'unpacker.inc' |
1091 | include 'unpacker.inc' |
1087 | 1092 | ||
1088 | align 4 |
1093 | align 4 |
1089 | boot_log: |
1094 | boot_log: |
1090 | pushad |
1095 | pushad |
1091 | 1096 | ||
1092 | mov ebx, 10*65536 |
1097 | mov ebx, 10*65536 |
1093 | mov bx, word [boot_y] |
1098 | mov bx, word [boot_y] |
1094 | add [boot_y], dword 10 |
1099 | add [boot_y], dword 10 |
1095 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1100 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1096 | xor edi, edi |
1101 | xor edi, edi |
1097 | mov edx, esi |
1102 | mov edx, esi |
1098 | inc edi |
1103 | inc edi |
1099 | call dtext |
1104 | call dtext |
1100 | 1105 | ||
1101 | mov [novesachecksum], 1000 |
1106 | mov [novesachecksum], 1000 |
1102 | call checkVga_N13 |
1107 | call checkVga_N13 |
1103 | 1108 | ||
1104 | popad |
1109 | popad |
1105 | 1110 | ||
1106 | ret |
1111 | ret |
1107 | 1112 | ||
1108 | ;----------------------------------------------------------------------------- |
1113 | ;----------------------------------------------------------------------------- |
1109 | ; Register ramdisk file system |
1114 | ; Register ramdisk file system |
1110 | register_ramdisk: |
1115 | register_ramdisk: |
1111 | mov esi, boot_initramdisk |
1116 | mov esi, boot_initramdisk |
1112 | call boot_log |
1117 | call boot_log |
1113 | call ramdisk_init |
1118 | call ramdisk_init |
1114 | ret |
1119 | ret |
1115 | 1120 | ||
1116 | ; in: edx -> APPDATA for OS/IDLE slot |
1121 | ; in: edx -> APPDATA for OS/IDLE slot |
1117 | ; in: ebx = stack base |
1122 | ; in: ebx = stack base |
1118 | proc setup_os_slot |
1123 | proc setup_os_slot |
1119 | xor eax, eax |
1124 | xor eax, eax |
1120 | mov ecx, 256/4 |
1125 | mov ecx, 256/4 |
1121 | mov edi, edx |
1126 | mov edi, edx |
1122 | rep stosd |
1127 | rep stosd |
1123 | 1128 | ||
1124 | mov eax, tss+0x80 |
1129 | mov eax, tss+0x80 |
1125 | call get_pg_addr |
1130 | call get_pg_addr |
1126 | inc eax |
1131 | inc eax |
1127 | mov [edx+APPDATA.io_map], eax |
1132 | mov [edx+APPDATA.io_map], eax |
1128 | mov eax, tss+0x1080 |
1133 | mov eax, tss+0x1080 |
1129 | call get_pg_addr |
1134 | call get_pg_addr |
1130 | inc eax |
1135 | inc eax |
1131 | mov [edx+APPDATA.io_map+4], eax |
1136 | mov [edx+APPDATA.io_map+4], eax |
1132 | 1137 | ||
1133 | mov dword [edx+APPDATA.pl0_stack], ebx |
1138 | mov dword [edx+APPDATA.pl0_stack], ebx |
1134 | lea edi, [ebx+RING0_STACK_SIZE] |
1139 | lea edi, [ebx+RING0_STACK_SIZE] |
1135 | mov dword [edx+APPDATA.fpu_state], edi |
1140 | mov dword [edx+APPDATA.fpu_state], edi |
1136 | mov dword [edx+APPDATA.saved_esp0], edi |
1141 | mov dword [edx+APPDATA.saved_esp0], edi |
1137 | mov dword [edx+APPDATA.saved_esp], edi |
1142 | mov dword [edx+APPDATA.saved_esp], edi |
1138 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1143 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1139 | 1144 | ||
1140 | mov esi, fpu_data |
1145 | mov esi, fpu_data |
1141 | mov ecx, [xsave_area_size] |
1146 | mov ecx, [xsave_area_size] |
1142 | add ecx, 3 |
1147 | add ecx, 3 |
1143 | shr ecx, 2 |
1148 | shr ecx, 2 |
1144 | rep movsd |
1149 | rep movsd |
1145 | 1150 | ||
1146 | lea eax, [edx+APP_EV_OFFSET] |
1151 | lea eax, [edx+APP_EV_OFFSET] |
1147 | mov dword [edx+APPDATA.fd_ev], eax |
1152 | mov dword [edx+APPDATA.fd_ev], eax |
1148 | mov dword [edx+APPDATA.bk_ev], eax |
1153 | mov dword [edx+APPDATA.bk_ev], eax |
1149 | 1154 | ||
1150 | lea eax, [edx+APP_OBJ_OFFSET] |
1155 | lea eax, [edx+APP_OBJ_OFFSET] |
1151 | mov dword [edx+APPDATA.fd_obj], eax |
1156 | mov dword [edx+APPDATA.fd_obj], eax |
1152 | mov dword [edx+APPDATA.bk_obj], eax |
1157 | mov dword [edx+APPDATA.bk_obj], eax |
1153 | 1158 | ||
1154 | mov dword [edx+APPDATA.cur_dir], sysdir_path-2 |
1159 | mov dword [edx+APPDATA.cur_dir], sysdir_path-2 |
1155 | 1160 | ||
1156 | mov [edx + APPDATA.process], sys_proc |
1161 | mov [edx + APPDATA.process], sys_proc |
1157 | 1162 | ||
1158 | lea ebx, [edx+APPDATA.list] |
1163 | lea ebx, [edx+APPDATA.list] |
1159 | lea ecx, [sys_proc+PROC.thr_list] |
1164 | lea ecx, [sys_proc+PROC.thr_list] |
1160 | list_add_tail ebx, ecx |
1165 | list_add_tail ebx, ecx |
1161 | 1166 | ||
1162 | mov eax, edx |
1167 | mov eax, edx |
1163 | shr eax, 3 |
1168 | shr eax, 3 |
1164 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1169 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1165 | mov [eax+TASKDATA.wnd_number], dh |
1170 | mov [eax+TASKDATA.wnd_number], dh |
1166 | mov byte [eax+TASKDATA.pid], dh |
1171 | mov byte [eax+TASKDATA.pid], dh |
1167 | 1172 | ||
1168 | ret |
1173 | ret |
1169 | endp |
1174 | endp |
1170 | 1175 | ||
1171 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1172 | ; ; |
1177 | ; ; |
1173 | ; MAIN OS LOOP START ; |
1178 | ; MAIN OS LOOP START ; |
1174 | ; ; |
1179 | ; ; |
1175 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1180 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1176 | align 32 |
1181 | align 32 |
1177 | osloop: |
1182 | osloop: |
1178 | mov edx, osloop_has_work? |
1183 | mov edx, osloop_has_work? |
1179 | xor ecx, ecx |
1184 | xor ecx, ecx |
1180 | call Wait_events |
1185 | call Wait_events |
1181 | xor eax, eax |
1186 | xor eax, eax |
1182 | xchg eax, [osloop_nonperiodic_work] |
1187 | xchg eax, [osloop_nonperiodic_work] |
1183 | test eax, eax |
1188 | test eax, eax |
1184 | jz .no_periodic |
1189 | jz .no_periodic |
1185 | 1190 | ||
1186 | call __sys_draw_pointer |
1191 | call __sys_draw_pointer |
1187 | call window_check_events |
1192 | call window_check_events |
1188 | call mouse_check_events |
1193 | call mouse_check_events |
1189 | call checkmisc |
1194 | call checkmisc |
1190 | call checkVga_N13 |
1195 | call checkVga_N13 |
1191 | ;-------------------------------------- |
1196 | ;-------------------------------------- |
1192 | .no_periodic: |
1197 | .no_periodic: |
1193 | call stack_handler |
1198 | call stack_handler |
1194 | call check_fdd_motor_status |
1199 | call check_fdd_motor_status |
1195 | call check_ATAPI_device_event |
1200 | call check_ATAPI_device_event |
1196 | call check_lights_state |
1201 | call check_lights_state |
1197 | call check_timers |
1202 | call check_timers |
1198 | 1203 | ||
1199 | jmp osloop |
1204 | jmp osloop |
1200 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1205 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1201 | ; ; |
1206 | ; ; |
1202 | ; MAIN OS LOOP END ; |
1207 | ; MAIN OS LOOP END ; |
1203 | ; ; |
1208 | ; ; |
1204 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1209 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1205 | proc osloop_has_work? |
1210 | proc osloop_has_work? |
1206 | cmp [osloop_nonperiodic_work], 0 |
1211 | cmp [osloop_nonperiodic_work], 0 |
1207 | jnz .yes |
1212 | jnz .yes |
1208 | call stack_handler_has_work? |
1213 | call stack_handler_has_work? |
1209 | jnz .yes |
1214 | jnz .yes |
1210 | call check_fdd_motor_status_has_work? |
1215 | call check_fdd_motor_status_has_work? |
1211 | jnz .yes |
1216 | jnz .yes |
1212 | call check_ATAPI_device_event_has_work? |
1217 | call check_ATAPI_device_event_has_work? |
1213 | jnz .yes |
1218 | jnz .yes |
1214 | call check_lights_state_has_work? |
1219 | call check_lights_state_has_work? |
1215 | jnz .yes |
1220 | jnz .yes |
1216 | call check_timers_has_work? |
1221 | call check_timers_has_work? |
1217 | jnz .yes |
1222 | jnz .yes |
1218 | .no: |
1223 | .no: |
1219 | xor eax, eax |
1224 | xor eax, eax |
1220 | ret |
1225 | ret |
1221 | .yes: |
1226 | .yes: |
1222 | xor eax, eax |
1227 | xor eax, eax |
1223 | inc eax |
1228 | inc eax |
1224 | ret |
1229 | ret |
1225 | endp |
1230 | endp |
1226 | 1231 | ||
1227 | proc wakeup_osloop |
1232 | proc wakeup_osloop |
1228 | mov [osloop_nonperiodic_work], 1 |
1233 | mov [osloop_nonperiodic_work], 1 |
1229 | ret |
1234 | ret |
1230 | endp |
1235 | endp |
1231 | 1236 | ||
1232 | uglobal |
1237 | uglobal |
1233 | align 4 |
1238 | align 4 |
1234 | osloop_nonperiodic_work dd ? |
1239 | osloop_nonperiodic_work dd ? |
1235 | endg |
1240 | endg |
1236 | 1241 | ||
1237 | uglobal |
1242 | uglobal |
1238 | align 64 |
1243 | align 64 |
1239 | idle_addr rb 64 |
1244 | idle_addr rb 64 |
1240 | endg |
1245 | endg |
1241 | 1246 | ||
1242 | idle_thread: |
1247 | idle_thread: |
1243 | sti |
1248 | sti |
1244 | 1249 | ||
1245 | ; The following code can be executed by all CPUs in the system. |
1250 | ; The following code can be executed by all CPUs in the system. |
1246 | ; All other parts of the kernel do not expect multi-CPU. |
1251 | ; All other parts of the kernel do not expect multi-CPU. |
1247 | ; Also, APs don't even have a stack here. |
1252 | ; Also, APs don't even have a stack here. |
1248 | ; Beware. Don't do anything here. Anything at all. |
1253 | ; Beware. Don't do anything here. Anything at all. |
1249 | idle_loop: |
1254 | idle_loop: |
1250 | cmp [use_mwait_for_idle], 0 |
1255 | cmp [use_mwait_for_idle], 0 |
1251 | jnz idle_loop_mwait |
1256 | jnz idle_loop_mwait |
1252 | 1257 | ||
1253 | idle_loop_hlt: |
1258 | idle_loop_hlt: |
1254 | hlt |
1259 | hlt |
1255 | jmp idle_loop_hlt |
1260 | jmp idle_loop_hlt |
1256 | 1261 | ||
1257 | idle_loop_mwait: |
1262 | idle_loop_mwait: |
1258 | mov eax, idle_addr |
1263 | mov eax, idle_addr |
1259 | xor ecx, ecx |
1264 | xor ecx, ecx |
1260 | xor edx, edx |
1265 | xor edx, edx |
1261 | monitor |
1266 | monitor |
1262 | xor ecx, ecx |
1267 | xor ecx, ecx |
1263 | mov eax, 20h ; or 10h |
1268 | mov eax, 20h ; or 10h |
1264 | mwait |
1269 | mwait |
1265 | jmp idle_loop_mwait |
1270 | jmp idle_loop_mwait |
1266 | 1271 | ||
1267 | 1272 | ||
1268 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1273 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1269 | ; ; |
1274 | ; ; |
1270 | ; INCLUDED SYSTEM FILES ; |
1275 | ; INCLUDED SYSTEM FILES ; |
1271 | ; ; |
1276 | ; ; |
1272 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1277 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1273 | 1278 | ||
1274 | 1279 | ||
1275 | include "kernel32.inc" |
1280 | include "kernel32.inc" |
1276 | 1281 | ||
1277 | 1282 | ||
1278 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1283 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1279 | ; ; |
1284 | ; ; |
1280 | ; KERNEL FUNCTIONS ; |
1285 | ; KERNEL FUNCTIONS ; |
1281 | ; ; |
1286 | ; ; |
1282 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1287 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1283 | 1288 | ||
1284 | reserve_irqs_ports: |
1289 | reserve_irqs_ports: |
1285 | 1290 | ||
1286 | 1291 | ||
1287 | ; RESERVE PORTS |
1292 | ; RESERVE PORTS |
1288 | mov eax, RESERVED_PORTS |
1293 | mov eax, RESERVED_PORTS |
1289 | mov ecx, 1 |
1294 | mov ecx, 1 |
1290 | 1295 | ||
1291 | mov [eax], dword 4 |
1296 | mov [eax], dword 4 |
1292 | 1297 | ||
1293 | mov [eax+16], ecx |
1298 | mov [eax+16], ecx |
1294 | mov [eax+16+4], dword 0 |
1299 | mov [eax+16+4], dword 0 |
1295 | mov [eax+16+8], dword 0x2D |
1300 | mov [eax+16+8], dword 0x2D |
1296 | 1301 | ||
1297 | mov [eax+32], ecx |
1302 | mov [eax+32], ecx |
1298 | mov [eax+32+4], dword 0x30 |
1303 | mov [eax+32+4], dword 0x30 |
1299 | mov [eax+32+8], dword 0x4D |
1304 | mov [eax+32+8], dword 0x4D |
1300 | 1305 | ||
1301 | mov [eax+48], ecx |
1306 | mov [eax+48], ecx |
1302 | mov [eax+48+4], dword 0x50 |
1307 | mov [eax+48+4], dword 0x50 |
1303 | mov [eax+48+8], dword 0xDF |
1308 | mov [eax+48+8], dword 0xDF |
1304 | 1309 | ||
1305 | mov [eax+64], ecx |
1310 | mov [eax+64], ecx |
1306 | mov [eax+64+4], dword 0xE5 |
1311 | mov [eax+64+4], dword 0xE5 |
1307 | mov [eax+64+8], dword 0xFF |
1312 | mov [eax+64+8], dword 0xFF |
1308 | 1313 | ||
1309 | ret |
1314 | ret |
1310 | 1315 | ||
1311 | 1316 | ||
1312 | iglobal |
1317 | iglobal |
1313 | process_number dd 0x2 |
1318 | process_number dd 0x2 |
1314 | endg |
1319 | endg |
1315 | 1320 | ||
1316 | set_variables: |
1321 | set_variables: |
1317 | 1322 | ||
1318 | mov ecx, 0x16 ; flush port 0x60 |
1323 | mov ecx, 0x16 ; flush port 0x60 |
1319 | .fl60: |
1324 | .fl60: |
1320 | in al, 0x60 |
1325 | in al, 0x60 |
1321 | loop .fl60 |
1326 | loop .fl60 |
1322 | push eax |
1327 | push eax |
1323 | 1328 | ||
1324 | mov ax, [BOOT.y_res] |
1329 | mov ax, [BOOT.y_res] |
1325 | shr ax, 1 |
1330 | shr ax, 1 |
1326 | shl eax, 16 |
1331 | shl eax, 16 |
1327 | mov ax, [BOOT.x_res] |
1332 | mov ax, [BOOT.x_res] |
1328 | shr ax, 1 |
1333 | shr ax, 1 |
1329 | mov [MOUSE_X], eax |
1334 | mov [MOUSE_X], eax |
1330 | call wakeup_osloop |
1335 | call wakeup_osloop |
1331 | 1336 | ||
1332 | xor eax, eax |
1337 | xor eax, eax |
1333 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1338 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1334 | 1339 | ||
1335 | mov byte [KEY_COUNT], al ; keyboard buffer |
1340 | mov byte [KEY_COUNT], al ; keyboard buffer |
1336 | mov byte [BTN_COUNT], al ; button buffer |
1341 | mov byte [BTN_COUNT], al ; button buffer |
1337 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1342 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1338 | 1343 | ||
1339 | pop eax |
1344 | pop eax |
1340 | ret |
1345 | ret |
1341 | 1346 | ||
1342 | align 4 |
1347 | align 4 |
1343 | ;input eax=43,bl-byte of output, ecx - number of port |
1348 | ;input eax=43,bl-byte of output, ecx - number of port |
1344 | sys_outport: |
1349 | sys_outport: |
1345 | 1350 | ||
1346 | mov edi, ecx ; separate flag for read / write |
1351 | mov edi, ecx ; separate flag for read / write |
1347 | and ecx, 65535 |
1352 | and ecx, 65535 |
1348 | 1353 | ||
1349 | mov eax, [RESERVED_PORTS] |
1354 | mov eax, [RESERVED_PORTS] |
1350 | test eax, eax |
1355 | test eax, eax |
1351 | jnz .sopl8 |
1356 | jnz .sopl8 |
1352 | inc eax |
1357 | inc eax |
1353 | mov [esp+32], eax |
1358 | mov [esp+32], eax |
1354 | ret |
1359 | ret |
1355 | 1360 | ||
1356 | .sopl8: |
1361 | .sopl8: |
1357 | mov edx, [TASK_BASE] |
1362 | mov edx, [TASK_BASE] |
1358 | mov edx, [edx+0x4] |
1363 | mov edx, [edx+0x4] |
1359 | ;and ecx,65535 |
1364 | ;and ecx,65535 |
1360 | ;cld - set on interrupt 0x40 |
1365 | ;cld - set on interrupt 0x40 |
1361 | .sopl1: |
1366 | .sopl1: |
1362 | 1367 | ||
1363 | mov esi, eax |
1368 | mov esi, eax |
1364 | shl esi, 4 |
1369 | shl esi, 4 |
1365 | add esi, RESERVED_PORTS |
1370 | add esi, RESERVED_PORTS |
1366 | cmp edx, [esi+0] |
1371 | cmp edx, [esi+0] |
1367 | jne .sopl2 |
1372 | jne .sopl2 |
1368 | cmp ecx, [esi+4] |
1373 | cmp ecx, [esi+4] |
1369 | jb .sopl2 |
1374 | jb .sopl2 |
1370 | cmp ecx, [esi+8] |
1375 | cmp ecx, [esi+8] |
1371 | jg .sopl2 |
1376 | jg .sopl2 |
1372 | .sopl3: |
1377 | .sopl3: |
1373 | 1378 | ||
1374 | test edi, 0x80000000; read ? |
1379 | test edi, 0x80000000; read ? |
1375 | jnz .sopl4 |
1380 | jnz .sopl4 |
1376 | 1381 | ||
1377 | mov eax, ebx |
1382 | mov eax, ebx |
1378 | mov dx, cx ; write |
1383 | mov dx, cx ; write |
1379 | out dx, al |
1384 | out dx, al |
1380 | and [esp+32], dword 0 |
1385 | and [esp+32], dword 0 |
1381 | ret |
1386 | ret |
1382 | 1387 | ||
1383 | .sopl2: |
1388 | .sopl2: |
1384 | 1389 | ||
1385 | dec eax |
1390 | dec eax |
1386 | jnz .sopl1 |
1391 | jnz .sopl1 |
1387 | inc eax |
1392 | inc eax |
1388 | mov [esp+32], eax |
1393 | mov [esp+32], eax |
1389 | ret |
1394 | ret |
1390 | 1395 | ||
1391 | 1396 | ||
1392 | .sopl4: |
1397 | .sopl4: |
1393 | 1398 | ||
1394 | mov dx, cx ; read |
1399 | mov dx, cx ; read |
1395 | in al, dx |
1400 | in al, dx |
1396 | and eax, 0xff |
1401 | and eax, 0xff |
1397 | and [esp+32], dword 0 |
1402 | and [esp+32], dword 0 |
1398 | mov [esp+20], eax |
1403 | mov [esp+20], eax |
1399 | ret |
1404 | ret |
1400 | 1405 | ||
1401 | display_number: |
1406 | display_number: |
1402 | ;It is not optimization |
1407 | ;It is not optimization |
1403 | mov eax, ebx |
1408 | mov eax, ebx |
1404 | mov ebx, ecx |
1409 | mov ebx, ecx |
1405 | mov ecx, edx |
1410 | mov ecx, edx |
1406 | mov edx, esi |
1411 | mov edx, esi |
1407 | mov esi, edi |
1412 | mov esi, edi |
1408 | ; eax = print type, al=0 -> ebx is number |
1413 | ; eax = print type, al=0 -> ebx is number |
1409 | ; al=1 -> ebx is pointer |
1414 | ; al=1 -> ebx is pointer |
1410 | ; ah=0 -> display decimal |
1415 | ; ah=0 -> display decimal |
1411 | ; ah=1 -> display hexadecimal |
1416 | ; ah=1 -> display hexadecimal |
1412 | ; ah=2 -> display binary |
1417 | ; ah=2 -> display binary |
1413 | ; eax bits 16-21 = number of digits to display (0-32) |
1418 | ; eax bits 16-21 = number of digits to display (0-32) |
1414 | ; eax bits 22-31 = reserved |
1419 | ; eax bits 22-31 = reserved |
1415 | ; |
1420 | ; |
1416 | ; ebx = number or pointer |
1421 | ; ebx = number or pointer |
1417 | ; ecx = x shl 16 + y |
1422 | ; ecx = x shl 16 + y |
1418 | ; edx = color |
1423 | ; edx = color |
1419 | xor edi, edi |
1424 | xor edi, edi |
1420 | display_number_force: |
1425 | display_number_force: |
1421 | push eax |
1426 | push eax |
1422 | and eax, 0x3fffffff |
1427 | and eax, 0x3fffffff |
1423 | cmp eax, 0xffff ; length > 0 ? |
1428 | cmp eax, 0xffff ; length > 0 ? |
1424 | pop eax |
1429 | pop eax |
1425 | jge cont_displ |
1430 | jge cont_displ |
1426 | ret |
1431 | ret |
1427 | cont_displ: |
1432 | cont_displ: |
1428 | push eax |
1433 | push eax |
1429 | and eax, 0x3fffffff |
1434 | and eax, 0x3fffffff |
1430 | cmp eax, 61*0x10000 ; length <= 60 ? |
1435 | cmp eax, 61*0x10000 ; length <= 60 ? |
1431 | pop eax |
1436 | pop eax |
1432 | jb cont_displ2 |
1437 | jb cont_displ2 |
1433 | ret |
1438 | ret |
1434 | cont_displ2: |
1439 | cont_displ2: |
1435 | 1440 | ||
1436 | pushad |
1441 | pushad |
1437 | 1442 | ||
1438 | cmp al, 1 ; ecx is a pointer ? |
1443 | cmp al, 1 ; ecx is a pointer ? |
1439 | jne displnl1 |
1444 | jne displnl1 |
1440 | mov ebp, ebx |
1445 | mov ebp, ebx |
1441 | add ebp, 4 |
1446 | add ebp, 4 |
1442 | mov ebp, [ebp+std_application_base_address] |
1447 | mov ebp, [ebp+std_application_base_address] |
1443 | mov ebx, [ebx+std_application_base_address] |
1448 | mov ebx, [ebx+std_application_base_address] |
1444 | displnl1: |
1449 | displnl1: |
1445 | sub esp, 64 |
1450 | sub esp, 64 |
1446 | 1451 | ||
1447 | test ah, ah ; DECIMAL |
1452 | test ah, ah ; DECIMAL |
1448 | jnz no_display_desnum |
1453 | jnz no_display_desnum |
1449 | shr eax, 16 |
1454 | shr eax, 16 |
1450 | and eax, 0xC03f |
1455 | and eax, 0xC03f |
1451 | ; and eax,0x3f |
1456 | ; and eax,0x3f |
1452 | push eax |
1457 | push eax |
1453 | and eax, 0x3f |
1458 | and eax, 0x3f |
1454 | mov edi, esp |
1459 | mov edi, esp |
1455 | add edi, 4+64-1 |
1460 | add edi, 4+64-1 |
1456 | mov ecx, eax |
1461 | mov ecx, eax |
1457 | mov eax, ebx |
1462 | mov eax, ebx |
1458 | mov ebx, 10 |
1463 | mov ebx, 10 |
1459 | d_desnum: |
1464 | d_desnum: |
1460 | xor edx, edx |
1465 | xor edx, edx |
1461 | call division_64_bits |
1466 | call division_64_bits |
1462 | div ebx |
1467 | div ebx |
1463 | add dl, 48 |
1468 | add dl, 48 |
1464 | mov [edi], dl |
1469 | mov [edi], dl |
1465 | dec edi |
1470 | dec edi |
1466 | loop d_desnum |
1471 | loop d_desnum |
1467 | pop eax |
1472 | pop eax |
1468 | call normalize_number |
1473 | call normalize_number |
1469 | call draw_num_text |
1474 | call draw_num_text |
1470 | add esp, 64 |
1475 | add esp, 64 |
1471 | popad |
1476 | popad |
1472 | ret |
1477 | ret |
1473 | no_display_desnum: |
1478 | no_display_desnum: |
1474 | 1479 | ||
1475 | cmp ah, 0x01 ; HEXADECIMAL |
1480 | cmp ah, 0x01 ; HEXADECIMAL |
1476 | jne no_display_hexnum |
1481 | jne no_display_hexnum |
1477 | shr eax, 16 |
1482 | shr eax, 16 |
1478 | and eax, 0xC03f |
1483 | and eax, 0xC03f |
1479 | ; and eax,0x3f |
1484 | ; and eax,0x3f |
1480 | push eax |
1485 | push eax |
1481 | and eax, 0x3f |
1486 | and eax, 0x3f |
1482 | mov edi, esp |
1487 | mov edi, esp |
1483 | add edi, 4+64-1 |
1488 | add edi, 4+64-1 |
1484 | mov ecx, eax |
1489 | mov ecx, eax |
1485 | mov eax, ebx |
1490 | mov eax, ebx |
1486 | mov ebx, 16 |
1491 | mov ebx, 16 |
1487 | d_hexnum: |
1492 | d_hexnum: |
1488 | xor edx, edx |
1493 | xor edx, edx |
1489 | call division_64_bits |
1494 | call division_64_bits |
1490 | div ebx |
1495 | div ebx |
1491 | hexletters = __fdo_hexdigits |
1496 | hexletters = __fdo_hexdigits |
1492 | add edx, hexletters |
1497 | add edx, hexletters |
1493 | mov dl, [edx] |
1498 | mov dl, [edx] |
1494 | mov [edi], dl |
1499 | mov [edi], dl |
1495 | dec edi |
1500 | dec edi |
1496 | loop d_hexnum |
1501 | loop d_hexnum |
1497 | pop eax |
1502 | pop eax |
1498 | call normalize_number |
1503 | call normalize_number |
1499 | call draw_num_text |
1504 | call draw_num_text |
1500 | add esp, 64 |
1505 | add esp, 64 |
1501 | popad |
1506 | popad |
1502 | ret |
1507 | ret |
1503 | no_display_hexnum: |
1508 | no_display_hexnum: |
1504 | 1509 | ||
1505 | cmp ah, 0x02 ; BINARY |
1510 | cmp ah, 0x02 ; BINARY |
1506 | jne no_display_binnum |
1511 | jne no_display_binnum |
1507 | shr eax, 16 |
1512 | shr eax, 16 |
1508 | and eax, 0xC03f |
1513 | and eax, 0xC03f |
1509 | ; and eax,0x3f |
1514 | ; and eax,0x3f |
1510 | push eax |
1515 | push eax |
1511 | and eax, 0x3f |
1516 | and eax, 0x3f |
1512 | mov edi, esp |
1517 | mov edi, esp |
1513 | add edi, 4+64-1 |
1518 | add edi, 4+64-1 |
1514 | mov ecx, eax |
1519 | mov ecx, eax |
1515 | mov eax, ebx |
1520 | mov eax, ebx |
1516 | mov ebx, 2 |
1521 | mov ebx, 2 |
1517 | d_binnum: |
1522 | d_binnum: |
1518 | xor edx, edx |
1523 | xor edx, edx |
1519 | call division_64_bits |
1524 | call division_64_bits |
1520 | div ebx |
1525 | div ebx |
1521 | add dl, 48 |
1526 | add dl, 48 |
1522 | mov [edi], dl |
1527 | mov [edi], dl |
1523 | dec edi |
1528 | dec edi |
1524 | loop d_binnum |
1529 | loop d_binnum |
1525 | pop eax |
1530 | pop eax |
1526 | call normalize_number |
1531 | call normalize_number |
1527 | call draw_num_text |
1532 | call draw_num_text |
1528 | add esp, 64 |
1533 | add esp, 64 |
1529 | popad |
1534 | popad |
1530 | ret |
1535 | ret |
1531 | no_display_binnum: |
1536 | no_display_binnum: |
1532 | 1537 | ||
1533 | add esp, 64 |
1538 | add esp, 64 |
1534 | popad |
1539 | popad |
1535 | ret |
1540 | ret |
1536 | 1541 | ||
1537 | normalize_number: |
1542 | normalize_number: |
1538 | test ah, 0x80 |
1543 | test ah, 0x80 |
1539 | jz .continue |
1544 | jz .continue |
1540 | mov ecx, 48 |
1545 | mov ecx, 48 |
1541 | and eax, 0x3f |
1546 | and eax, 0x3f |
1542 | @@: |
1547 | @@: |
1543 | inc edi |
1548 | inc edi |
1544 | cmp [edi], cl |
1549 | cmp [edi], cl |
1545 | jne .continue |
1550 | jne .continue |
1546 | dec eax |
1551 | dec eax |
1547 | cmp eax, 1 |
1552 | cmp eax, 1 |
1548 | ja @r |
1553 | ja @r |
1549 | mov al, 1 |
1554 | mov al, 1 |
1550 | .continue: |
1555 | .continue: |
1551 | and eax, 0x3f |
1556 | and eax, 0x3f |
1552 | ret |
1557 | ret |
1553 | 1558 | ||
1554 | division_64_bits: |
1559 | division_64_bits: |
1555 | test [esp+1+4], byte 0x40 |
1560 | test [esp+1+4], byte 0x40 |
1556 | jz .continue |
1561 | jz .continue |
1557 | push eax |
1562 | push eax |
1558 | mov eax, ebp |
1563 | mov eax, ebp |
1559 | div ebx |
1564 | div ebx |
1560 | mov ebp, eax |
1565 | mov ebp, eax |
1561 | pop eax |
1566 | pop eax |
1562 | .continue: |
1567 | .continue: |
1563 | ret |
1568 | ret |
1564 | 1569 | ||
1565 | draw_num_text: |
1570 | draw_num_text: |
1566 | mov esi, eax |
1571 | mov esi, eax |
1567 | mov edx, 64+4 |
1572 | mov edx, 64+4 |
1568 | sub edx, eax |
1573 | sub edx, eax |
1569 | add edx, esp |
1574 | add edx, esp |
1570 | mov ebx, [esp+64+32-8+4] |
1575 | mov ebx, [esp+64+32-8+4] |
1571 | ; add window start x & y |
1576 | ; add window start x & y |
1572 | mov ecx, [TASK_BASE] |
1577 | mov ecx, [TASK_BASE] |
1573 | 1578 | ||
1574 | mov edi, [CURRENT_TASK] |
1579 | mov edi, [CURRENT_TASK] |
1575 | shl edi, 8 |
1580 | shl edi, 8 |
1576 | 1581 | ||
1577 | mov eax, [ecx-twdw+WDATA.box.left] |
1582 | mov eax, [ecx-twdw+WDATA.box.left] |
1578 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1583 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1579 | shl eax, 16 |
1584 | shl eax, 16 |
1580 | add eax, [ecx-twdw+WDATA.box.top] |
1585 | add eax, [ecx-twdw+WDATA.box.top] |
1581 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1586 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1582 | add ebx, eax |
1587 | add ebx, eax |
1583 | mov ecx, [esp+64+32-12+4] |
1588 | mov ecx, [esp+64+32-12+4] |
1584 | mov eax, [esp+64+8] ; background color (if given) |
1589 | mov eax, [esp+64+8] ; background color (if given) |
1585 | mov edi, [esp+64+4] |
1590 | mov edi, [esp+64+4] |
1586 | and ecx, 5FFFFFFFh |
1591 | and ecx, 5FFFFFFFh |
1587 | bt ecx, 27 |
1592 | bt ecx, 27 |
1588 | jnc @f |
1593 | jnc @f |
1589 | mov edi, eax |
1594 | mov edi, eax |
1590 | @@: |
1595 | @@: |
1591 | jmp dtext |
1596 | jmp dtext |
1592 | ;----------------------------------------------------------------------------- |
1597 | ;----------------------------------------------------------------------------- |
1593 | iglobal |
1598 | iglobal |
1594 | midi_base dw 0 |
1599 | midi_base dw 0 |
1595 | endg |
1600 | endg |
1596 | ;----------------------------------------------------------------------------- |
1601 | ;----------------------------------------------------------------------------- |
1597 | align 4 |
1602 | align 4 |
1598 | sys_setup: |
1603 | sys_setup: |
1599 | ; 1 = roland mpu midi base , base io address |
1604 | ; 1 = roland mpu midi base , base io address |
1600 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1605 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1601 | ; 3 = not used |
1606 | ; 3 = not used |
1602 | ; 4 = not used |
1607 | ; 4 = not used |
1603 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1608 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1604 | ; 6 = not used |
1609 | ; 6 = not used |
1605 | ; 7 = not used |
1610 | ; 7 = not used |
1606 | ; 8 = not used |
1611 | ; 8 = not used |
1607 | ; 9 = not used |
1612 | ; 9 = not used |
1608 | ; 10 = not used |
1613 | ; 10 = not used |
1609 | ; 11 = enable lba read |
1614 | ; 11 = enable lba read |
1610 | ; 12 = enable pci access |
1615 | ; 12 = enable pci access |
1611 | ;----------------------------------------------------------------------------- |
1616 | ;----------------------------------------------------------------------------- |
1612 | and [esp+32], dword 0 |
1617 | and [esp+32], dword 0 |
1613 | ; F.21.1 - set MPU MIDI base port |
1618 | ; F.21.1 - set MPU MIDI base port |
1614 | dec ebx |
1619 | dec ebx |
1615 | jnz @f |
1620 | jnz @f |
1616 | 1621 | ||
1617 | cmp ecx, 0x100 |
1622 | cmp ecx, 0x100 |
1618 | jb @f |
1623 | jb @f |
1619 | 1624 | ||
1620 | mov esi, 65535 |
1625 | mov esi, 65535 |
1621 | cmp esi, ecx |
1626 | cmp esi, ecx |
1622 | jb @f |
1627 | jb @f |
1623 | 1628 | ||
1624 | mov [midi_base], cx |
1629 | mov [midi_base], cx |
1625 | mov word [mididp], cx |
1630 | mov word [mididp], cx |
1626 | inc cx |
1631 | inc cx |
1627 | mov word [midisp], cx |
1632 | mov word [midisp], cx |
1628 | ret |
1633 | ret |
1629 | ;-------------------------------------- |
1634 | ;-------------------------------------- |
1630 | @@: |
1635 | @@: |
1631 | ; F.21.2 - set keyboard layout |
1636 | ; F.21.2 - set keyboard layout |
1632 | dec ebx |
1637 | dec ebx |
1633 | jnz @f |
1638 | jnz @f |
1634 | 1639 | ||
1635 | mov edi, [TASK_BASE] |
1640 | mov edi, [TASK_BASE] |
1636 | mov eax, [edi+TASKDATA.mem_start] |
1641 | mov eax, [edi+TASKDATA.mem_start] |
1637 | add eax, edx |
1642 | add eax, edx |
1638 | ; 1 = normal layout |
1643 | ; 1 = normal layout |
1639 | dec ecx |
1644 | dec ecx |
1640 | jnz .shift |
1645 | jnz .shift |
1641 | 1646 | ||
1642 | mov ebx, keymap |
1647 | mov ebx, keymap |
1643 | mov ecx, 128 |
1648 | mov ecx, 128 |
1644 | call memmove |
1649 | call memmove |
1645 | ret |
1650 | ret |
1646 | ;-------------------------------------- |
1651 | ;-------------------------------------- |
1647 | .shift: |
1652 | .shift: |
1648 | ; 2 = layout at pressed Shift |
1653 | ; 2 = layout at pressed Shift |
1649 | dec ecx |
1654 | dec ecx |
1650 | jnz .alt |
1655 | jnz .alt |
1651 | 1656 | ||
1652 | mov ebx, keymap_shift |
1657 | mov ebx, keymap_shift |
1653 | mov ecx, 128 |
1658 | mov ecx, 128 |
1654 | call memmove |
1659 | call memmove |
1655 | ret |
1660 | ret |
1656 | ;-------------------------------------- |
1661 | ;-------------------------------------- |
1657 | .alt: |
1662 | .alt: |
1658 | ; 3 = layout at pressed Alt |
1663 | ; 3 = layout at pressed Alt |
1659 | dec ecx |
1664 | dec ecx |
1660 | jnz .country |
1665 | jnz .country |
1661 | 1666 | ||
1662 | mov ebx, keymap_alt |
1667 | mov ebx, keymap_alt |
1663 | mov ecx, 128 |
1668 | mov ecx, 128 |
1664 | call memmove |
1669 | call memmove |
1665 | ret |
1670 | ret |
1666 | ;-------------------------------------- |
1671 | ;-------------------------------------- |
1667 | .country: |
1672 | .country: |
1668 | ; country identifier |
1673 | ; country identifier |
1669 | sub ecx, 6 |
1674 | sub ecx, 6 |
1670 | jnz .error |
1675 | jnz .error |
1671 | 1676 | ||
1672 | mov word [keyboard], dx |
1677 | mov word [keyboard], dx |
1673 | ret |
1678 | ret |
1674 | ;-------------------------------------- |
1679 | ;-------------------------------------- |
1675 | @@: |
1680 | @@: |
1676 | ; F.21.5 - set system language |
1681 | ; F.21.5 - set system language |
1677 | sub ebx, 3 |
1682 | sub ebx, 3 |
1678 | jnz @f |
1683 | jnz @f |
1679 | 1684 | ||
1680 | mov [syslang], ecx |
1685 | mov [syslang], ecx |
1681 | ret |
1686 | ret |
1682 | ;-------------------------------------- |
1687 | ;-------------------------------------- |
1683 | @@: |
1688 | @@: |
1684 | ; F.21.11 - enable/disable low-level access to HD |
1689 | ; F.21.11 - enable/disable low-level access to HD |
1685 | and ecx, 1 |
1690 | and ecx, 1 |
1686 | sub ebx, 6 |
1691 | sub ebx, 6 |
1687 | jnz @f |
1692 | jnz @f |
1688 | 1693 | ||
1689 | mov [lba_read_enabled], ecx |
1694 | mov [lba_read_enabled], ecx |
1690 | ret |
1695 | ret |
1691 | ;-------------------------------------- |
1696 | ;-------------------------------------- |
1692 | @@: |
1697 | @@: |
1693 | ; F.21.12 - enable/disable low-level access to PCI |
1698 | ; F.21.12 - enable/disable low-level access to PCI |
1694 | dec ebx |
1699 | dec ebx |
1695 | jnz .error |
1700 | jnz .error |
1696 | 1701 | ||
1697 | mov [pci_access_enabled], ecx |
1702 | mov [pci_access_enabled], ecx |
1698 | ret |
1703 | ret |
1699 | ;-------------------------------------- |
1704 | ;-------------------------------------- |
1700 | .error: |
1705 | .error: |
1701 | or [esp+32], dword -1 |
1706 | or [esp+32], dword -1 |
1702 | ret |
1707 | ret |
1703 | ;----------------------------------------------------------------------------- |
1708 | ;----------------------------------------------------------------------------- |
1704 | align 4 |
1709 | align 4 |
1705 | sys_getsetup: |
1710 | sys_getsetup: |
1706 | ; 1 = roland mpu midi base , base io address |
1711 | ; 1 = roland mpu midi base , base io address |
1707 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1712 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1708 | ; 3 = not used |
1713 | ; 3 = not used |
1709 | ; 4 = not used |
1714 | ; 4 = not used |
1710 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1715 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1711 | ; 6 = not used |
1716 | ; 6 = not used |
1712 | ; 7 = not used |
1717 | ; 7 = not used |
1713 | ; 8 = not used |
1718 | ; 8 = not used |
1714 | ; 9 = get hs timer tic |
1719 | ; 9 = get hs timer tic |
1715 | ; 10 = not used |
1720 | ; 10 = not used |
1716 | ; 11 = get the state "lba read" |
1721 | ; 11 = get the state "lba read" |
1717 | ; 12 = get the state "pci access" |
1722 | ; 12 = get the state "pci access" |
1718 | ;----------------------------------------------------------------------------- |
1723 | ;----------------------------------------------------------------------------- |
1719 | ; F.26.1 - get MPU MIDI base port |
1724 | ; F.26.1 - get MPU MIDI base port |
1720 | dec ebx |
1725 | dec ebx |
1721 | jnz @f |
1726 | jnz @f |
1722 | 1727 | ||
1723 | movzx eax, [midi_base] |
1728 | movzx eax, [midi_base] |
1724 | mov [esp+32], eax |
1729 | mov [esp+32], eax |
1725 | ret |
1730 | ret |
1726 | ;-------------------------------------- |
1731 | ;-------------------------------------- |
1727 | @@: |
1732 | @@: |
1728 | ; F.26.2 - get keyboard layout |
1733 | ; F.26.2 - get keyboard layout |
1729 | dec ebx |
1734 | dec ebx |
1730 | jnz @f |
1735 | jnz @f |
1731 | 1736 | ||
1732 | mov edi, [TASK_BASE] |
1737 | mov edi, [TASK_BASE] |
1733 | mov ebx, [edi+TASKDATA.mem_start] |
1738 | mov ebx, [edi+TASKDATA.mem_start] |
1734 | add ebx, edx |
1739 | add ebx, edx |
1735 | ; 1 = normal layout |
1740 | ; 1 = normal layout |
1736 | dec ecx |
1741 | dec ecx |
1737 | jnz .shift |
1742 | jnz .shift |
1738 | 1743 | ||
1739 | mov eax, keymap |
1744 | mov eax, keymap |
1740 | mov ecx, 128 |
1745 | mov ecx, 128 |
1741 | call memmove |
1746 | call memmove |
1742 | ret |
1747 | ret |
1743 | ;-------------------------------------- |
1748 | ;-------------------------------------- |
1744 | .shift: |
1749 | .shift: |
1745 | ; 2 = layout with pressed Shift |
1750 | ; 2 = layout with pressed Shift |
1746 | dec ecx |
1751 | dec ecx |
1747 | jnz .alt |
1752 | jnz .alt |
1748 | 1753 | ||
1749 | mov eax, keymap_shift |
1754 | mov eax, keymap_shift |
1750 | mov ecx, 128 |
1755 | mov ecx, 128 |
1751 | call memmove |
1756 | call memmove |
1752 | ret |
1757 | ret |
1753 | ;-------------------------------------- |
1758 | ;-------------------------------------- |
1754 | .alt: |
1759 | .alt: |
1755 | ; 3 = layout with pressed Alt |
1760 | ; 3 = layout with pressed Alt |
1756 | dec ecx |
1761 | dec ecx |
1757 | jne .country |
1762 | jne .country |
1758 | 1763 | ||
1759 | mov eax, keymap_alt |
1764 | mov eax, keymap_alt |
1760 | mov ecx, 128 |
1765 | mov ecx, 128 |
1761 | call memmove |
1766 | call memmove |
1762 | ret |
1767 | ret |
1763 | ;-------------------------------------- |
1768 | ;-------------------------------------- |
1764 | .country: |
1769 | .country: |
1765 | ; 9 = country identifier |
1770 | ; 9 = country identifier |
1766 | sub ecx, 6 |
1771 | sub ecx, 6 |
1767 | jnz .error |
1772 | jnz .error |
1768 | 1773 | ||
1769 | movzx eax, word [keyboard] |
1774 | movzx eax, word [keyboard] |
1770 | mov [esp+32], eax |
1775 | mov [esp+32], eax |
1771 | ret |
1776 | ret |
1772 | ;-------------------------------------- |
1777 | ;-------------------------------------- |
1773 | @@: |
1778 | @@: |
1774 | ; F.26.5 - get system language |
1779 | ; F.26.5 - get system language |
1775 | sub ebx, 3 |
1780 | sub ebx, 3 |
1776 | jnz @f |
1781 | jnz @f |
1777 | 1782 | ||
1778 | mov eax, [syslang] |
1783 | mov eax, [syslang] |
1779 | mov [esp+32], eax |
1784 | mov [esp+32], eax |
1780 | ret |
1785 | ret |
1781 | ;-------------------------------------- |
1786 | ;-------------------------------------- |
1782 | @@: |
1787 | @@: |
1783 | ; F.26.9 - get the value of the time counter |
1788 | ; F.26.9 - get the value of the time counter |
1784 | sub ebx, 4 |
1789 | sub ebx, 4 |
1785 | jnz @f |
1790 | jnz @f |
1786 | 1791 | ||
1787 | mov eax, [timer_ticks] |
1792 | mov eax, [timer_ticks] |
1788 | mov [esp+32], eax |
1793 | mov [esp+32], eax |
1789 | ret |
1794 | ret |
1790 | ;-------------------------------------- |
1795 | ;-------------------------------------- |
1791 | @@: |
1796 | @@: |
1792 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1797 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1793 | sub ebx, 1 |
1798 | sub ebx, 1 |
1794 | jnz @f |
1799 | jnz @f |
1795 | 1800 | ||
1796 | call get_clock_ns |
1801 | call get_clock_ns |
1797 | mov [esp+24], edx |
1802 | mov [esp+24], edx |
1798 | mov [esp+32], eax |
1803 | mov [esp+32], eax |
1799 | ret |
1804 | ret |
1800 | ;-------------------------------------- |
1805 | ;-------------------------------------- |
1801 | @@: |
1806 | @@: |
1802 | ; F.26.11 - Find out whether low-level HD access is enabled |
1807 | ; F.26.11 - Find out whether low-level HD access is enabled |
1803 | sub ebx, 1 |
1808 | sub ebx, 1 |
1804 | jnz @f |
1809 | jnz @f |
1805 | 1810 | ||
1806 | mov eax, [lba_read_enabled] |
1811 | mov eax, [lba_read_enabled] |
1807 | mov [esp+32], eax |
1812 | mov [esp+32], eax |
1808 | ret |
1813 | ret |
1809 | ;-------------------------------------- |
1814 | ;-------------------------------------- |
1810 | @@: |
1815 | @@: |
1811 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1816 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1812 | dec ebx |
1817 | dec ebx |
1813 | jnz .error |
1818 | jnz .error |
1814 | 1819 | ||
1815 | mov eax, [pci_access_enabled] |
1820 | mov eax, [pci_access_enabled] |
1816 | mov [esp+32], eax |
1821 | mov [esp+32], eax |
1817 | ret |
1822 | ret |
1818 | ;-------------------------------------- |
1823 | ;-------------------------------------- |
1819 | .error: |
1824 | .error: |
1820 | or [esp+32], dword -1 |
1825 | or [esp+32], dword -1 |
1821 | ret |
1826 | ret |
1822 | ;----------------------------------------------------------------------------- |
1827 | ;----------------------------------------------------------------------------- |
1823 | get_timer_ticks: |
1828 | get_timer_ticks: |
1824 | mov eax, [timer_ticks] |
1829 | mov eax, [timer_ticks] |
1825 | ret |
1830 | ret |
1826 | ;----------------------------------------------------------------------------- |
1831 | ;----------------------------------------------------------------------------- |
1827 | readmousepos: |
1832 | readmousepos: |
1828 | ; eax=0 screen relative |
1833 | ; eax=0 screen relative |
1829 | ; eax=1 window relative |
1834 | ; eax=1 window relative |
1830 | ; eax=2 buttons pressed |
1835 | ; eax=2 buttons pressed |
1831 | ; eax=3 buttons pressed ext |
1836 | ; eax=3 buttons pressed ext |
1832 | ; eax=4 load cursor |
1837 | ; eax=4 load cursor |
1833 | ; eax=5 set cursor |
1838 | ; eax=5 set cursor |
1834 | ; eax=6 delete cursor |
1839 | ; eax=6 delete cursor |
1835 | ; eax=7 get mouse_z |
1840 | ; eax=7 get mouse_z |
1836 | ; eax=8 load cursor unicode |
1841 | ; eax=8 load cursor unicode |
1837 | cmp ebx, 8 |
1842 | cmp ebx, 8 |
1838 | ja @f |
1843 | ja @f |
1839 | jmp dword[.mousefn+ebx*4] |
1844 | jmp dword[.mousefn+ebx*4] |
1840 | 1845 | ||
1841 | align 4 |
1846 | align 4 |
1842 | .mousefn: |
1847 | .mousefn: |
1843 | dd .msscreen |
1848 | dd .msscreen |
1844 | dd .mswin |
1849 | dd .mswin |
1845 | dd .msbutton |
1850 | dd .msbutton |
1846 | dd .msbuttonExt |
1851 | dd .msbuttonExt |
1847 | dd .app_load_cursor |
1852 | dd .app_load_cursor |
1848 | dd .app_set_cursor |
1853 | dd .app_set_cursor |
1849 | dd .app_delete_cursor |
1854 | dd .app_delete_cursor |
1850 | dd .msz |
1855 | dd .msz |
1851 | dd .loadCursorUni |
1856 | dd .loadCursorUni |
1852 | 1857 | ||
1853 | .msscreen: |
1858 | .msscreen: |
1854 | mov eax, [MOUSE_X] |
1859 | mov eax, [MOUSE_X] |
1855 | shl eax, 16 |
1860 | shl eax, 16 |
1856 | mov ax, [MOUSE_Y] |
1861 | mov ax, [MOUSE_Y] |
1857 | mov [esp+36-4], eax |
1862 | mov [esp+36-4], eax |
1858 | @@: |
1863 | @@: |
1859 | ret |
1864 | ret |
1860 | 1865 | ||
1861 | .mswin: |
1866 | .mswin: |
1862 | mov eax, [MOUSE_X] |
1867 | mov eax, [MOUSE_X] |
1863 | shl eax, 16 |
1868 | shl eax, 16 |
1864 | mov ax, [MOUSE_Y] |
1869 | mov ax, [MOUSE_Y] |
1865 | mov esi, [TASK_BASE] |
1870 | mov esi, [TASK_BASE] |
1866 | mov bx, word [esi-twdw+WDATA.box.left] |
1871 | mov bx, word [esi-twdw+WDATA.box.left] |
1867 | shl ebx, 16 |
1872 | shl ebx, 16 |
1868 | mov bx, word [esi-twdw+WDATA.box.top] |
1873 | mov bx, word [esi-twdw+WDATA.box.top] |
1869 | sub eax, ebx |
1874 | sub eax, ebx |
1870 | mov edi, [CURRENT_TASK] |
1875 | mov edi, [CURRENT_TASK] |
1871 | shl edi, 8 |
1876 | shl edi, 8 |
1872 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1877 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1873 | rol eax, 16 |
1878 | rol eax, 16 |
1874 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1879 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1875 | rol eax, 16 |
1880 | rol eax, 16 |
1876 | mov [esp+36-4], eax |
1881 | mov [esp+36-4], eax |
1877 | ret |
1882 | ret |
1878 | 1883 | ||
1879 | .msbutton: |
1884 | .msbutton: |
1880 | movzx eax, byte [BTN_DOWN] |
1885 | movzx eax, byte [BTN_DOWN] |
1881 | mov [esp+36-4], eax |
1886 | mov [esp+36-4], eax |
1882 | ret |
1887 | ret |
1883 | 1888 | ||
1884 | .msbuttonExt: |
1889 | .msbuttonExt: |
1885 | mov eax, [BTN_DOWN] |
1890 | mov eax, [BTN_DOWN] |
1886 | mov [esp+36-4], eax |
1891 | mov [esp+36-4], eax |
1887 | ret |
1892 | ret |
1888 | 1893 | ||
1889 | .app_load_cursor: |
1894 | .app_load_cursor: |
1890 | cmp ecx, OS_BASE |
1895 | cmp ecx, OS_BASE |
1891 | jae @f |
1896 | jae @f |
1892 | stdcall load_cursor, ecx, edx |
1897 | stdcall load_cursor, ecx, edx |
1893 | mov [esp+36-4], eax |
1898 | mov [esp+36-4], eax |
1894 | @@: |
1899 | @@: |
1895 | ret |
1900 | ret |
1896 | 1901 | ||
1897 | .loadCursorUni: |
1902 | .loadCursorUni: |
1898 | cmp ecx, OS_BASE |
1903 | cmp ecx, OS_BASE |
1899 | jae @b |
1904 | jae @b |
1900 | push ecx edx |
1905 | push ecx edx |
1901 | stdcall kernel_alloc, maxPathLength |
1906 | stdcall kernel_alloc, maxPathLength |
1902 | mov edi, eax |
1907 | mov edi, eax |
1903 | pop eax esi |
1908 | pop eax esi |
1904 | push edi |
1909 | push edi |
1905 | call getFullPath |
1910 | call getFullPath |
1906 | pop ebp |
1911 | pop ebp |
1907 | test eax, eax |
1912 | test eax, eax |
1908 | jz @f |
1913 | jz @f |
1909 | stdcall load_cursor, ebp, LOAD_FROM_FILE |
1914 | stdcall load_cursor, ebp, LOAD_FROM_FILE |
1910 | mov [esp+32], eax |
1915 | mov [esp+32], eax |
1911 | @@: |
1916 | @@: |
1912 | stdcall kernel_free, ebp |
1917 | stdcall kernel_free, ebp |
1913 | ret |
1918 | ret |
1914 | 1919 | ||
1915 | .app_set_cursor: |
1920 | .app_set_cursor: |
1916 | stdcall set_cursor, ecx |
1921 | stdcall set_cursor, ecx |
1917 | mov [esp+36-4], eax |
1922 | mov [esp+36-4], eax |
1918 | ret |
1923 | ret |
1919 | 1924 | ||
1920 | .app_delete_cursor: |
1925 | .app_delete_cursor: |
1921 | stdcall delete_cursor, ecx |
1926 | stdcall delete_cursor, ecx |
1922 | mov [esp+36-4], eax |
1927 | mov [esp+36-4], eax |
1923 | ret |
1928 | ret |
1924 | 1929 | ||
1925 | .msz: |
1930 | .msz: |
1926 | mov edi, [TASK_COUNT] |
1931 | mov edi, [TASK_COUNT] |
1927 | movzx edi, word [WIN_POS + edi*2] |
1932 | movzx edi, word [WIN_POS + edi*2] |
1928 | cmp edi, [CURRENT_TASK] |
1933 | cmp edi, [CURRENT_TASK] |
1929 | jne @f |
1934 | jne @f |
1930 | mov ax, [MOUSE_SCROLL_H] |
1935 | mov ax, [MOUSE_SCROLL_H] |
1931 | shl eax, 16 |
1936 | shl eax, 16 |
1932 | mov ax, [MOUSE_SCROLL_V] |
1937 | mov ax, [MOUSE_SCROLL_V] |
1933 | mov [esp+36-4], eax |
1938 | mov [esp+36-4], eax |
1934 | and [MOUSE_SCROLL_H], word 0 |
1939 | and [MOUSE_SCROLL_H], word 0 |
1935 | and [MOUSE_SCROLL_V], word 0 |
1940 | and [MOUSE_SCROLL_V], word 0 |
1936 | ret |
1941 | ret |
1937 | @@: |
1942 | @@: |
1938 | and [esp+36-4], dword 0 |
1943 | and [esp+36-4], dword 0 |
1939 | ret |
1944 | ret |
1940 | 1945 | ||
1941 | is_input: |
1946 | is_input: |
1942 | 1947 | ||
1943 | push edx |
1948 | push edx |
1944 | mov dx, word [midisp] |
1949 | mov dx, word [midisp] |
1945 | in al, dx |
1950 | in al, dx |
1946 | and al, 0x80 |
1951 | and al, 0x80 |
1947 | pop edx |
1952 | pop edx |
1948 | ret |
1953 | ret |
1949 | 1954 | ||
1950 | is_output: |
1955 | is_output: |
1951 | 1956 | ||
1952 | push edx |
1957 | push edx |
1953 | mov dx, word [midisp] |
1958 | mov dx, word [midisp] |
1954 | in al, dx |
1959 | in al, dx |
1955 | and al, 0x40 |
1960 | and al, 0x40 |
1956 | pop edx |
1961 | pop edx |
1957 | ret |
1962 | ret |
1958 | 1963 | ||
1959 | 1964 | ||
1960 | get_mpu_in: |
1965 | get_mpu_in: |
1961 | 1966 | ||
1962 | push edx |
1967 | push edx |
1963 | mov dx, word [mididp] |
1968 | mov dx, word [mididp] |
1964 | in al, dx |
1969 | in al, dx |
1965 | pop edx |
1970 | pop edx |
1966 | ret |
1971 | ret |
1967 | 1972 | ||
1968 | 1973 | ||
1969 | put_mpu_out: |
1974 | put_mpu_out: |
1970 | 1975 | ||
1971 | push edx |
1976 | push edx |
1972 | mov dx, word [mididp] |
1977 | mov dx, word [mididp] |
1973 | out dx, al |
1978 | out dx, al |
1974 | pop edx |
1979 | pop edx |
1975 | ret |
1980 | ret |
1976 | 1981 | ||
1977 | 1982 | ||
1978 | 1983 | ||
1979 | align 4 |
1984 | align 4 |
1980 | 1985 | ||
1981 | sys_midi: |
1986 | sys_midi: |
1982 | cmp [mididp], 0 |
1987 | cmp [mididp], 0 |
1983 | jnz sm0 |
1988 | jnz sm0 |
1984 | mov [esp+36], dword 1 |
1989 | mov [esp+36], dword 1 |
1985 | ret |
1990 | ret |
1986 | sm0: |
1991 | sm0: |
1987 | and [esp+36], dword 0 |
1992 | and [esp+36], dword 0 |
1988 | dec ebx |
1993 | dec ebx |
1989 | jnz smn1 |
1994 | jnz smn1 |
1990 | ; call setuart |
1995 | ; call setuart |
1991 | su1: |
1996 | su1: |
1992 | call is_output |
1997 | call is_output |
1993 | test al, al |
1998 | test al, al |
1994 | jnz su1 |
1999 | jnz su1 |
1995 | mov dx, word [midisp] |
2000 | mov dx, word [midisp] |
1996 | mov al, 0xff |
2001 | mov al, 0xff |
1997 | out dx, al |
2002 | out dx, al |
1998 | su2: |
2003 | su2: |
1999 | mov dx, word [midisp] |
2004 | mov dx, word [midisp] |
2000 | mov al, 0xff |
2005 | mov al, 0xff |
2001 | out dx, al |
2006 | out dx, al |
2002 | call is_input |
2007 | call is_input |
2003 | test al, al |
2008 | test al, al |
2004 | jnz su2 |
2009 | jnz su2 |
2005 | call get_mpu_in |
2010 | call get_mpu_in |
2006 | cmp al, 0xfe |
2011 | cmp al, 0xfe |
2007 | jnz su2 |
2012 | jnz su2 |
2008 | su3: |
2013 | su3: |
2009 | call is_output |
2014 | call is_output |
2010 | test al, al |
2015 | test al, al |
2011 | jnz su3 |
2016 | jnz su3 |
2012 | mov dx, word [midisp] |
2017 | mov dx, word [midisp] |
2013 | mov al, 0x3f |
2018 | mov al, 0x3f |
2014 | out dx, al |
2019 | out dx, al |
2015 | ret |
2020 | ret |
2016 | smn1: |
2021 | smn1: |
2017 | dec ebx |
2022 | dec ebx |
2018 | jnz smn2 |
2023 | jnz smn2 |
2019 | sm10: |
2024 | sm10: |
2020 | call get_mpu_in |
2025 | call get_mpu_in |
2021 | call is_output |
2026 | call is_output |
2022 | test al, al |
2027 | test al, al |
2023 | jnz sm10 |
2028 | jnz sm10 |
2024 | mov al, bl |
2029 | mov al, bl |
2025 | call put_mpu_out |
2030 | call put_mpu_out |
2026 | smn2: |
2031 | smn2: |
2027 | ret |
2032 | ret |
2028 | 2033 | ||
2029 | detect_devices: |
2034 | detect_devices: |
2030 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2035 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2031 | ;include 'detect/commouse.inc' |
2036 | ;include 'detect/commouse.inc' |
2032 | ;include 'detect/ps2mouse.inc' |
2037 | ;include 'detect/ps2mouse.inc' |
2033 | ;include 'detect/dev_fd.inc' |
2038 | ;include 'detect/dev_fd.inc' |
2034 | ;include 'detect/dev_hdcd.inc' |
2039 | ;include 'detect/dev_hdcd.inc' |
2035 | ;include 'detect/sear_par.inc' |
2040 | ;include 'detect/sear_par.inc' |
2036 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2041 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2037 | ret |
2042 | ret |
2038 | 2043 | ||
2039 | sys_end: |
2044 | sys_end: |
2040 | ;-------------------------------------- |
2045 | ;-------------------------------------- |
2041 | cmp [_display.select_cursor], 0 |
2046 | cmp [_display.select_cursor], 0 |
2042 | je @f |
2047 | je @f |
2043 | ; restore default cursor before killing |
2048 | ; restore default cursor before killing |
2044 | pusha |
2049 | pusha |
2045 | mov ecx, [current_slot] |
2050 | mov ecx, [current_slot] |
2046 | call restore_default_cursor_before_killing |
2051 | call restore_default_cursor_before_killing |
2047 | popa |
2052 | popa |
2048 | @@: |
2053 | @@: |
2049 | ;-------------------------------------- |
2054 | ;-------------------------------------- |
2050 | ; kill all sockets this process owns |
2055 | ; kill all sockets this process owns |
2051 | pusha |
2056 | pusha |
2052 | mov edx, [TASK_BASE] |
2057 | mov edx, [TASK_BASE] |
2053 | mov edx, [edx+TASKDATA.pid] |
2058 | mov edx, [edx+TASKDATA.pid] |
2054 | call socket_process_end |
2059 | call socket_process_end |
2055 | popa |
2060 | popa |
2056 | ;-------------------------------------- |
2061 | ;-------------------------------------- |
2057 | mov ecx, [current_slot] |
2062 | mov ecx, [current_slot] |
2058 | mov eax, [ecx+APPDATA.tls_base] |
2063 | mov eax, [ecx+APPDATA.tls_base] |
2059 | test eax, eax |
2064 | test eax, eax |
2060 | jz @F |
2065 | jz @F |
2061 | 2066 | ||
2062 | stdcall user_free, eax |
2067 | stdcall user_free, eax |
2063 | @@: |
2068 | @@: |
2064 | 2069 | ||
2065 | mov eax, [TASK_BASE] |
2070 | mov eax, [TASK_BASE] |
2066 | mov [eax+TASKDATA.state], TSTATE_ZOMBIE |
2071 | mov [eax+TASKDATA.state], TSTATE_ZOMBIE |
2067 | call wakeup_osloop |
2072 | call wakeup_osloop |
2068 | 2073 | ||
2069 | .waitterm: ; wait here for termination |
2074 | .waitterm: ; wait here for termination |
2070 | call change_task |
2075 | call change_task |
2071 | jmp .waitterm |
2076 | jmp .waitterm |
2072 | ;------------------------------------------------------------------------------ |
2077 | ;------------------------------------------------------------------------------ |
2073 | align 4 |
2078 | align 4 |
2074 | restore_default_cursor_before_killing: |
2079 | restore_default_cursor_before_killing: |
2075 | pushfd |
2080 | pushfd |
2076 | cli |
2081 | cli |
2077 | mov eax, [def_cursor] |
2082 | mov eax, [def_cursor] |
2078 | mov [ecx+APPDATA.cursor], eax |
2083 | mov [ecx+APPDATA.cursor], eax |
2079 | 2084 | ||
2080 | movzx eax, word [MOUSE_Y] |
2085 | movzx eax, word [MOUSE_Y] |
2081 | movzx ebx, word [MOUSE_X] |
2086 | movzx ebx, word [MOUSE_X] |
2082 | mov eax, [d_width_calc_area + eax*4] |
2087 | mov eax, [d_width_calc_area + eax*4] |
2083 | 2088 | ||
2084 | add eax, [_display.win_map] |
2089 | add eax, [_display.win_map] |
2085 | movzx edx, byte [ebx+eax] |
2090 | movzx edx, byte [ebx+eax] |
2086 | shl edx, 8 |
2091 | shl edx, 8 |
2087 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2092 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2088 | 2093 | ||
2089 | cmp esi, [current_cursor] |
2094 | cmp esi, [current_cursor] |
2090 | je @f |
2095 | je @f |
2091 | 2096 | ||
2092 | push esi |
2097 | push esi |
2093 | call [_display.select_cursor] |
2098 | call [_display.select_cursor] |
2094 | mov [current_cursor], esi |
2099 | mov [current_cursor], esi |
2095 | @@: |
2100 | @@: |
2096 | mov [redrawmouse_unconditional], 1 |
2101 | mov [redrawmouse_unconditional], 1 |
2097 | call wakeup_osloop |
2102 | call wakeup_osloop |
2098 | popfd |
2103 | popfd |
2099 | ret |
2104 | ret |
2100 | ;------------------------------------------------------------------------------ |
2105 | ;------------------------------------------------------------------------------ |
2101 | iglobal |
2106 | iglobal |
2102 | align 4 |
2107 | align 4 |
2103 | sys_system_table: |
2108 | sys_system_table: |
2104 | dd sysfn_deactivate ; 1 = deactivate window |
2109 | dd sysfn_deactivate ; 1 = deactivate window |
2105 | dd sysfn_terminate ; 2 = terminate thread |
2110 | dd sysfn_terminate ; 2 = terminate thread |
2106 | dd sysfn_activate ; 3 = activate window |
2111 | dd sysfn_activate ; 3 = activate window |
2107 | dd sysfn_getidletime ; 4 = get idle time |
2112 | dd sysfn_getidletime ; 4 = get idle time |
2108 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2113 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2109 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2114 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2110 | dd sysfn_getactive ; 7 = get active window |
2115 | dd sysfn_getactive ; 7 = get active window |
2111 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2116 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2112 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2117 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2113 | dd sysfn_minimize ; 10 = minimize window |
2118 | dd sysfn_minimize ; 10 = minimize window |
2114 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2119 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2115 | dd sysfn_lastkey ; 12 = get last pressed key |
2120 | dd sysfn_lastkey ; 12 = get last pressed key |
2116 | dd sysfn_getversion ; 13 = get kernel version |
2121 | dd sysfn_getversion ; 13 = get kernel version |
2117 | dd sysfn_waitretrace ; 14 = wait retrace |
2122 | dd sysfn_waitretrace ; 14 = wait retrace |
2118 | dd sysfn_centermouse ; 15 = center mouse cursor |
2123 | dd sysfn_centermouse ; 15 = center mouse cursor |
2119 | dd sysfn_getfreemem ; 16 = get free memory size |
2124 | dd sysfn_getfreemem ; 16 = get free memory size |
2120 | dd sysfn_getallmem ; 17 = get total memory size |
2125 | dd sysfn_getallmem ; 17 = get total memory size |
2121 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2126 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2122 | ; instead of slot |
2127 | ; instead of slot |
2123 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2128 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2124 | dd sysfn_meminfo ; 20 = get extended memory info |
2129 | dd sysfn_meminfo ; 20 = get extended memory info |
2125 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2130 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2126 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2131 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2127 | dd sysfn_min_windows ; 23 = minimize all windows |
2132 | dd sysfn_min_windows ; 23 = minimize all windows |
2128 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2133 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2129 | 2134 | ||
2130 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
2135 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
2131 | sysfn_num = ($ - sys_system_table)/4 |
2136 | sysfn_num = ($ - sys_system_table)/4 |
2132 | endg |
2137 | endg |
2133 | ;------------------------------------------------------------------------------ |
2138 | ;------------------------------------------------------------------------------ |
2134 | sys_system: |
2139 | sys_system: |
2135 | dec ebx |
2140 | dec ebx |
2136 | cmp ebx, sysfn_num |
2141 | cmp ebx, sysfn_num |
2137 | jae @f |
2142 | jae @f |
2138 | jmp dword [sys_system_table + ebx*4] |
2143 | jmp dword [sys_system_table + ebx*4] |
2139 | @@: |
2144 | @@: |
2140 | ret |
2145 | ret |
2141 | ;------------------------------------------------------------------------------ |
2146 | ;------------------------------------------------------------------------------ |
2142 | sysfn_shutdown: ; 18.9 = system shutdown |
2147 | sysfn_shutdown: ; 18.9 = system shutdown |
2143 | cmp ecx, SYSTEM_SHUTDOWN |
2148 | cmp ecx, SYSTEM_SHUTDOWN |
2144 | jl exit_for_anyone |
2149 | jl exit_for_anyone |
2145 | cmp ecx, SYSTEM_RESTART |
2150 | cmp ecx, SYSTEM_RESTART |
2146 | jg exit_for_anyone |
2151 | jg exit_for_anyone |
2147 | mov [BOOT.shutdown_type], cl |
2152 | mov [BOOT.shutdown_type], cl |
2148 | 2153 | ||
2149 | mov eax, [TASK_COUNT] |
2154 | mov eax, [TASK_COUNT] |
2150 | mov [SYS_SHUTDOWN], al |
2155 | mov [SYS_SHUTDOWN], al |
2151 | mov [shutdown_processes], eax |
2156 | mov [shutdown_processes], eax |
2152 | call wakeup_osloop |
2157 | call wakeup_osloop |
2153 | and dword [esp+32], 0 |
2158 | and dword [esp+32], 0 |
2154 | exit_for_anyone: |
2159 | exit_for_anyone: |
2155 | ret |
2160 | ret |
2156 | uglobal |
2161 | uglobal |
2157 | shutdown_processes: |
2162 | shutdown_processes: |
2158 | dd 0x0 |
2163 | dd 0x0 |
2159 | endg |
2164 | endg |
2160 | ;------------------------------------------------------------------------------ |
2165 | ;------------------------------------------------------------------------------ |
2161 | sysfn_terminate: ; 18.2 = TERMINATE |
2166 | sysfn_terminate: ; 18.2 = TERMINATE |
2162 | push ecx |
2167 | push ecx |
2163 | cmp ecx, 2 |
2168 | cmp ecx, 2 |
2164 | jb noprocessterminate |
2169 | jb noprocessterminate |
2165 | mov edx, [TASK_COUNT] |
2170 | mov edx, [TASK_COUNT] |
2166 | cmp ecx, edx |
2171 | cmp ecx, edx |
2167 | ja noprocessterminate |
2172 | ja noprocessterminate |
2168 | mov eax, [TASK_COUNT] |
2173 | mov eax, [TASK_COUNT] |
2169 | shl ecx, 5 |
2174 | shl ecx, 5 |
2170 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2175 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2171 | add ecx, CURRENT_TASK+TASKDATA.state |
2176 | add ecx, CURRENT_TASK+TASKDATA.state |
2172 | cmp byte [ecx], 9 |
2177 | cmp byte [ecx], 9 |
2173 | jz noprocessterminate |
2178 | jz noprocessterminate |
2174 | push ecx edx |
2179 | push ecx edx |
2175 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2180 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2176 | call request_terminate |
2181 | call request_terminate |
2177 | pop edx ecx |
2182 | pop edx ecx |
2178 | test eax, eax |
2183 | test eax, eax |
2179 | jz noprocessterminate |
2184 | jz noprocessterminate |
2180 | ;-------------------------------------- |
2185 | ;-------------------------------------- |
2181 | ; terminate all network sockets it used |
2186 | ; terminate all network sockets it used |
2182 | pusha |
2187 | pusha |
2183 | mov eax, edx |
2188 | mov eax, edx |
2184 | call socket_process_end |
2189 | call socket_process_end |
2185 | popa |
2190 | popa |
2186 | ;-------------------------------------- |
2191 | ;-------------------------------------- |
2187 | cmp [_display.select_cursor], 0 |
2192 | cmp [_display.select_cursor], 0 |
2188 | je .restore_end |
2193 | je .restore_end |
2189 | ; restore default cursor before killing |
2194 | ; restore default cursor before killing |
2190 | pusha |
2195 | pusha |
2191 | mov ecx, [esp+32] |
2196 | mov ecx, [esp+32] |
2192 | shl ecx, 8 |
2197 | shl ecx, 8 |
2193 | add ecx, SLOT_BASE |
2198 | add ecx, SLOT_BASE |
2194 | mov eax, [def_cursor] |
2199 | mov eax, [def_cursor] |
2195 | cmp [ecx+APPDATA.cursor], eax |
2200 | cmp [ecx+APPDATA.cursor], eax |
2196 | je @f |
2201 | je @f |
2197 | call restore_default_cursor_before_killing |
2202 | call restore_default_cursor_before_killing |
2198 | @@: |
2203 | @@: |
2199 | popa |
2204 | popa |
2200 | .restore_end: |
2205 | .restore_end: |
2201 | ;-------------------------------------- |
2206 | ;-------------------------------------- |
2202 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2207 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2203 | mov [ecx], byte 3; clear possible i40's |
2208 | mov [ecx], byte 3; clear possible i40's |
2204 | call wakeup_osloop |
2209 | call wakeup_osloop |
2205 | ;call MEM_Heap_UnLock |
2210 | ;call MEM_Heap_UnLock |
2206 | 2211 | ||
2207 | cmp edx, [application_table_owner]; clear app table stat |
2212 | cmp edx, [application_table_owner]; clear app table stat |
2208 | jne noatsc |
2213 | jne noatsc |
2209 | call unlock_application_table |
2214 | call unlock_application_table |
2210 | noatsc: |
2215 | noatsc: |
2211 | noprocessterminate: |
2216 | noprocessterminate: |
2212 | add esp, 4 |
2217 | add esp, 4 |
2213 | ret |
2218 | ret |
2214 | ;------------------------------------------------------------------------------ |
2219 | ;------------------------------------------------------------------------------ |
2215 | sysfn_terminate2: |
2220 | sysfn_terminate2: |
2216 | ;lock application_table_status mutex |
2221 | ;lock application_table_status mutex |
2217 | .table_status: |
2222 | .table_status: |
2218 | call lock_application_table |
2223 | call lock_application_table |
2219 | mov eax, ecx |
2224 | mov eax, ecx |
2220 | call pid_to_slot |
2225 | call pid_to_slot |
2221 | test eax, eax |
2226 | test eax, eax |
2222 | jz .not_found |
2227 | jz .not_found |
2223 | mov ecx, eax |
2228 | mov ecx, eax |
2224 | cli |
2229 | cli |
2225 | call sysfn_terminate |
2230 | call sysfn_terminate |
2226 | call unlock_application_table |
2231 | call unlock_application_table |
2227 | sti |
2232 | sti |
2228 | and dword [esp+32], 0 |
2233 | and dword [esp+32], 0 |
2229 | ret |
2234 | ret |
2230 | .not_found: |
2235 | .not_found: |
2231 | call unlock_application_table |
2236 | call unlock_application_table |
2232 | or dword [esp+32], -1 |
2237 | or dword [esp+32], -1 |
2233 | ret |
2238 | ret |
2234 | ;------------------------------------------------------------------------------ |
2239 | ;------------------------------------------------------------------------------ |
2235 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2240 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2236 | cmp ecx, 2 |
2241 | cmp ecx, 2 |
2237 | jb .nowindowdeactivate |
2242 | jb .nowindowdeactivate |
2238 | cmp ecx, [TASK_COUNT] |
2243 | cmp ecx, [TASK_COUNT] |
2239 | ja .nowindowdeactivate |
2244 | ja .nowindowdeactivate |
2240 | 2245 | ||
2241 | movzx esi, word [WIN_STACK + ecx*2] |
2246 | movzx esi, word [WIN_STACK + ecx*2] |
2242 | cmp esi, 1 |
2247 | cmp esi, 1 |
2243 | je .nowindowdeactivate ; already deactive |
2248 | je .nowindowdeactivate ; already deactive |
2244 | 2249 | ||
2245 | mov edi, ecx |
2250 | mov edi, ecx |
2246 | shl edi, 5 |
2251 | shl edi, 5 |
2247 | add edi, window_data |
2252 | add edi, window_data |
2248 | movzx esi, word [WIN_STACK + ecx * 2] |
2253 | movzx esi, word [WIN_STACK + ecx * 2] |
2249 | lea esi, [WIN_POS + esi * 2] |
2254 | lea esi, [WIN_POS + esi * 2] |
2250 | call window._.window_deactivate |
2255 | call window._.window_deactivate |
2251 | call syscall_display_settings.calculateScreen |
2256 | call syscall_display_settings.calculateScreen |
2252 | call syscall_display_settings.redrawScreen |
2257 | call syscall_display_settings.redrawScreen |
2253 | .nowindowdeactivate: |
2258 | .nowindowdeactivate: |
2254 | ret |
2259 | ret |
2255 | ;------------------------------------------------------------------------------ |
2260 | ;------------------------------------------------------------------------------ |
2256 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2261 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2257 | cmp ecx, 2 |
2262 | cmp ecx, 2 |
2258 | jb .nowindowactivate |
2263 | jb .nowindowactivate |
2259 | cmp ecx, [TASK_COUNT] |
2264 | cmp ecx, [TASK_COUNT] |
2260 | ja .nowindowactivate |
2265 | ja .nowindowactivate |
2261 | ;------------------------------------- |
2266 | ;------------------------------------- |
2262 | @@: |
2267 | @@: |
2263 | ; If the window is captured and moved by the user, |
2268 | ; If the window is captured and moved by the user, |
2264 | ; then you can't change the position in window stack!!! |
2269 | ; then you can't change the position in window stack!!! |
2265 | mov al, [mouse.active_sys_window.action] |
2270 | mov al, [mouse.active_sys_window.action] |
2266 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2271 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2267 | test al, al |
2272 | test al, al |
2268 | jz @f |
2273 | jz @f |
2269 | call change_task |
2274 | call change_task |
2270 | jmp @b |
2275 | jmp @b |
2271 | @@: |
2276 | @@: |
2272 | ;------------------------------------- |
2277 | ;------------------------------------- |
2273 | mov [window_minimize], 2; restore window if minimized |
2278 | mov [window_minimize], 2; restore window if minimized |
2274 | call wakeup_osloop |
2279 | call wakeup_osloop |
2275 | 2280 | ||
2276 | movzx esi, word [WIN_STACK + ecx*2] |
2281 | movzx esi, word [WIN_STACK + ecx*2] |
2277 | cmp esi, [TASK_COUNT] |
2282 | cmp esi, [TASK_COUNT] |
2278 | je .nowindowactivate; already active |
2283 | je .nowindowactivate; already active |
2279 | 2284 | ||
2280 | mov edi, ecx |
2285 | mov edi, ecx |
2281 | shl edi, 5 |
2286 | shl edi, 5 |
2282 | add edi, window_data |
2287 | add edi, window_data |
2283 | movzx esi, word [WIN_STACK + ecx * 2] |
2288 | movzx esi, word [WIN_STACK + ecx * 2] |
2284 | lea esi, [WIN_POS + esi * 2] |
2289 | lea esi, [WIN_POS + esi * 2] |
2285 | call waredraw |
2290 | call waredraw |
2286 | .nowindowactivate: |
2291 | .nowindowactivate: |
2287 | ret |
2292 | ret |
2288 | ;------------------------------------------------------------------------------ |
2293 | ;------------------------------------------------------------------------------ |
2289 | align 4 |
2294 | align 4 |
2290 | sysfn_zmodif: |
2295 | sysfn_zmodif: |
2291 | ;18,25,1 - get z_modif |
2296 | ;18,25,1 - get z_modif |
2292 | ;18,25,2 - set z_modif |
2297 | ;18,25,2 - set z_modif |
2293 | ;edx = -1(for current task) or TID |
2298 | ;edx = -1(for current task) or TID |
2294 | ;esi(for 2) = new value z_modif |
2299 | ;esi(for 2) = new value z_modif |
2295 | ;return: |
2300 | ;return: |
2296 | ;1: eax = z_modif |
2301 | ;1: eax = z_modif |
2297 | ;2: eax=0(fail),1(success) for set z_modif |
2302 | ;2: eax=0(fail),1(success) for set z_modif |
2298 | 2303 | ||
2299 | cmp edx, -1 |
2304 | cmp edx, -1 |
2300 | jne @f |
2305 | jne @f |
2301 | mov edx, [CURRENT_TASK] |
2306 | mov edx, [CURRENT_TASK] |
2302 | @@: |
2307 | @@: |
2303 | cmp edx, [TASK_COUNT] |
2308 | cmp edx, [TASK_COUNT] |
2304 | ja .fail |
2309 | ja .fail |
2305 | cmp edx, 1 |
2310 | cmp edx, 1 |
2306 | je .fail |
2311 | je .fail |
2307 | 2312 | ||
2308 | mov eax, edx |
2313 | mov eax, edx |
2309 | shl edx, 5 |
2314 | shl edx, 5 |
2310 | 2315 | ||
2311 | cmp [edx + CURRENT_TASK + TASKDATA.state], 9 |
2316 | cmp [edx + CURRENT_TASK + TASKDATA.state], 9 |
2312 | je .fail |
2317 | je .fail |
2313 | 2318 | ||
2314 | cmp ecx, 1 |
2319 | cmp ecx, 1 |
2315 | jnz .set_zmod |
2320 | jnz .set_zmod |
2316 | 2321 | ||
2317 | mov al, [edx + window_data + WDATA.z_modif] |
2322 | mov al, [edx + window_data + WDATA.z_modif] |
2318 | jmp .exit |
2323 | jmp .exit |
2319 | 2324 | ||
2320 | .set_zmod: |
2325 | .set_zmod: |
2321 | cmp ecx, 2 |
2326 | cmp ecx, 2 |
2322 | jnz .fail |
2327 | jnz .fail |
2323 | 2328 | ||
2324 | mov ebx, esi |
2329 | mov ebx, esi |
2325 | mov esi, eax |
2330 | mov esi, eax |
2326 | 2331 | ||
2327 | cmp bl, ZPOS_ALWAYS_TOP |
2332 | cmp bl, ZPOS_ALWAYS_TOP |
2328 | jg .fail |
2333 | jg .fail |
2329 | 2334 | ||
2330 | mov [edx + window_data + WDATA.z_modif], bl |
2335 | mov [edx + window_data + WDATA.z_modif], bl |
2331 | 2336 | ||
2332 | mov eax, [edx + window_data + WDATA.box.left] |
2337 | mov eax, [edx + window_data + WDATA.box.left] |
2333 | mov ebx, [edx + window_data + WDATA.box.top] |
2338 | mov ebx, [edx + window_data + WDATA.box.top] |
2334 | mov ecx, [edx + window_data + WDATA.box.width] |
2339 | mov ecx, [edx + window_data + WDATA.box.width] |
2335 | mov edx, [edx + window_data + WDATA.box.height] |
2340 | mov edx, [edx + window_data + WDATA.box.height] |
2336 | add ecx, eax |
2341 | add ecx, eax |
2337 | add edx, ebx |
2342 | add edx, ebx |
2338 | call window._.set_screen |
2343 | call window._.set_screen |
2339 | call window._.set_top_wnd |
2344 | call window._.set_top_wnd |
2340 | call window._.redraw_top_wnd |
2345 | call window._.redraw_top_wnd |
2341 | 2346 | ||
2342 | shl esi, 5 |
2347 | shl esi, 5 |
2343 | mov [esi + window_data + WDATA.fl_redraw], 1 |
2348 | mov [esi + window_data + WDATA.fl_redraw], 1 |
2344 | 2349 | ||
2345 | 2350 | ||
2346 | mov eax, 1 |
2351 | mov eax, 1 |
2347 | jmp .exit |
2352 | jmp .exit |
2348 | .fail: |
2353 | .fail: |
2349 | xor eax, eax |
2354 | xor eax, eax |
2350 | .exit: |
2355 | .exit: |
2351 | mov [esp+32], eax |
2356 | mov [esp+32], eax |
2352 | ret |
2357 | ret |
2353 | 2358 | ||
2354 | ;------------------------------------------------------------------------------ |
2359 | ;------------------------------------------------------------------------------ |
2355 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2360 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2356 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2361 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2357 | mov [esp+32], eax |
2362 | mov [esp+32], eax |
2358 | ret |
2363 | ret |
2359 | ;------------------------------------------------------------------------------ |
2364 | ;------------------------------------------------------------------------------ |
2360 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2365 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2361 | mov eax, dword [cpu_freq] |
2366 | mov eax, dword [cpu_freq] |
2362 | mov [esp+32], eax |
2367 | mov [esp+32], eax |
2363 | ret |
2368 | ret |
2364 | ;------------------------------------------------------------------------------ |
2369 | ;------------------------------------------------------------------------------ |
2365 | get_cpu_freq: |
2370 | get_cpu_freq: |
2366 | mov eax, dword [cpu_freq] |
2371 | mov eax, dword [cpu_freq] |
2367 | mov edx, dword [cpu_freq+4] |
2372 | mov edx, dword [cpu_freq+4] |
2368 | ret |
2373 | ret |
2369 | ; SAVE ramdisk to /hd/1/menuet.img |
2374 | ; SAVE ramdisk to /hd/1/menuet.img |
2370 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2375 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2371 | include 'blkdev/rdsave.inc' |
2376 | include 'blkdev/rdsave.inc' |
2372 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2377 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2373 | ;------------------------------------------------------------------------------ |
2378 | ;------------------------------------------------------------------------------ |
2374 | align 4 |
2379 | align 4 |
2375 | sysfn_getactive: ; 18.7 = get active window |
2380 | sysfn_getactive: ; 18.7 = get active window |
2376 | mov eax, [TASK_COUNT] |
2381 | mov eax, [TASK_COUNT] |
2377 | movzx eax, word [WIN_POS + eax*2] |
2382 | movzx eax, word [WIN_POS + eax*2] |
2378 | mov [esp+32], eax |
2383 | mov [esp+32], eax |
2379 | ret |
2384 | ret |
2380 | ;------------------------------------------------------------------------------ |
2385 | ;------------------------------------------------------------------------------ |
2381 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2386 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2382 | ; cmp ecx,1 |
2387 | ; cmp ecx,1 |
2383 | dec ecx |
2388 | dec ecx |
2384 | jnz nogetsoundflag |
2389 | jnz nogetsoundflag |
2385 | movzx eax, byte [sound_flag]; get sound_flag |
2390 | movzx eax, byte [sound_flag]; get sound_flag |
2386 | mov [esp+32], eax |
2391 | mov [esp+32], eax |
2387 | ret |
2392 | ret |
2388 | nogetsoundflag: |
2393 | nogetsoundflag: |
2389 | ; cmp ecx,2 |
2394 | ; cmp ecx,2 |
2390 | dec ecx |
2395 | dec ecx |
2391 | jnz nosoundflag |
2396 | jnz nosoundflag |
2392 | xor byte [sound_flag], 1 |
2397 | xor byte [sound_flag], 1 |
2393 | nosoundflag: |
2398 | nosoundflag: |
2394 | ret |
2399 | ret |
2395 | ;------------------------------------------------------------------------------ |
2400 | ;------------------------------------------------------------------------------ |
2396 | sysfn_minimize: ; 18.10 = minimize window |
2401 | sysfn_minimize: ; 18.10 = minimize window |
2397 | mov [window_minimize], 1 |
2402 | mov [window_minimize], 1 |
2398 | call wakeup_osloop |
2403 | call wakeup_osloop |
2399 | ret |
2404 | ret |
2400 | ;------------------------------------------------------------------------------ |
2405 | ;------------------------------------------------------------------------------ |
2401 | align 4 |
2406 | align 4 |
2402 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2407 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2403 | dec ecx |
2408 | dec ecx |
2404 | jnz .exit |
2409 | jnz .exit |
2405 | .small_table: |
2410 | .small_table: |
2406 | mov edi, edx |
2411 | mov edi, edx |
2407 | mov esi, DRIVE_DATA |
2412 | mov esi, DRIVE_DATA |
2408 | mov ecx, DRIVE_DATA_SIZE ;10 |
2413 | mov ecx, DRIVE_DATA_SIZE ;10 |
2409 | cld |
2414 | cld |
2410 | rep movsb |
2415 | rep movsb |
2411 | .exit: |
2416 | .exit: |
2412 | ret |
2417 | ret |
2413 | ;------------------------------------------------------------------------------ |
2418 | ;------------------------------------------------------------------------------ |
2414 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2419 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2415 | and dword [esp+32], 0 |
2420 | and dword [esp+32], 0 |
2416 | ret |
2421 | ret |
2417 | ;------------------------------------------------------------------------------ |
2422 | ;------------------------------------------------------------------------------ |
2418 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2423 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2419 | mov edi, ecx |
2424 | mov edi, ecx |
2420 | mov esi, version_inf |
2425 | mov esi, version_inf |
2421 | mov ecx, version_end-version_inf |
2426 | mov ecx, version_end-version_inf |
2422 | rep movsb |
2427 | rep movsb |
2423 | ret |
2428 | ret |
2424 | ;------------------------------------------------------------------------------ |
2429 | ;------------------------------------------------------------------------------ |
2425 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2430 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2426 | ;wait retrace functions |
2431 | ;wait retrace functions |
2427 | sys_wait_retrace: |
2432 | sys_wait_retrace: |
2428 | mov edx, 0x3da |
2433 | mov edx, 0x3da |
2429 | WaitRetrace_loop: |
2434 | WaitRetrace_loop: |
2430 | in al, dx |
2435 | in al, dx |
2431 | test al, 1000b |
2436 | test al, 1000b |
2432 | jz WaitRetrace_loop |
2437 | jz WaitRetrace_loop |
2433 | and [esp+32], dword 0 |
2438 | and [esp+32], dword 0 |
2434 | ret |
2439 | ret |
2435 | ;------------------------------------------------------------------------------ |
2440 | ;------------------------------------------------------------------------------ |
2436 | align 4 |
2441 | align 4 |
2437 | sysfn_centermouse: ; 18.15 = mouse centered |
2442 | sysfn_centermouse: ; 18.15 = mouse centered |
2438 | mov eax, [_display.width] |
2443 | mov eax, [_display.width] |
2439 | shr eax, 1 |
2444 | shr eax, 1 |
2440 | mov [MOUSE_X], ax |
2445 | mov [MOUSE_X], ax |
2441 | mov eax, [_display.height] |
2446 | mov eax, [_display.height] |
2442 | shr eax, 1 |
2447 | shr eax, 1 |
2443 | mov [MOUSE_Y], ax |
2448 | mov [MOUSE_Y], ax |
2444 | call wakeup_osloop |
2449 | call wakeup_osloop |
2445 | xor eax, eax |
2450 | xor eax, eax |
2446 | and [esp+32], eax |
2451 | and [esp+32], eax |
2447 | ret |
2452 | ret |
2448 | ;------------------------------------------------------------------------------ |
2453 | ;------------------------------------------------------------------------------ |
2449 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2454 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2450 | cmp ecx, 8 |
2455 | cmp ecx, 8 |
2451 | jnc @f |
2456 | jnc @f |
2452 | jmp dword [.table+ecx*4] |
2457 | jmp dword [.table+ecx*4] |
2453 | .get_mouse_acceleration: |
2458 | .get_mouse_acceleration: |
2454 | xor eax, eax |
2459 | xor eax, eax |
2455 | mov ax, [mouse_speed_factor] |
2460 | mov ax, [mouse_speed_factor] |
2456 | mov [esp+32], eax |
2461 | mov [esp+32], eax |
2457 | ret |
2462 | ret |
2458 | .set_mouse_acceleration: |
2463 | .set_mouse_acceleration: |
2459 | mov [mouse_speed_factor], dx |
2464 | mov [mouse_speed_factor], dx |
2460 | ret |
2465 | ret |
2461 | .get_mouse_delay: |
2466 | .get_mouse_delay: |
2462 | xor eax, eax |
2467 | xor eax, eax |
2463 | mov al, [mouse_delay] |
2468 | mov al, [mouse_delay] |
2464 | mov [esp+32], eax |
2469 | mov [esp+32], eax |
2465 | ret |
2470 | ret |
2466 | .set_mouse_delay: |
2471 | .set_mouse_delay: |
2467 | mov [mouse_delay], dl |
2472 | mov [mouse_delay], dl |
2468 | @@: |
2473 | @@: |
2469 | ret |
2474 | ret |
2470 | .set_pointer_position: |
2475 | .set_pointer_position: |
2471 | cmp dx, word[_display.height] |
2476 | cmp dx, word[_display.height] |
2472 | jae @b |
2477 | jae @b |
2473 | rol edx, 16 |
2478 | rol edx, 16 |
2474 | cmp dx, word[_display.width] |
2479 | cmp dx, word[_display.width] |
2475 | jae @b |
2480 | jae @b |
2476 | mov [MOUSE_X], edx |
2481 | mov [MOUSE_X], edx |
2477 | mov [mouse_active], 1 |
2482 | mov [mouse_active], 1 |
2478 | jmp wakeup_osloop |
2483 | jmp wakeup_osloop |
2479 | .set_mouse_button: |
2484 | .set_mouse_button: |
2480 | mov [BTN_DOWN], edx |
2485 | mov [BTN_DOWN], edx |
2481 | mov [mouse_active], 1 |
2486 | mov [mouse_active], 1 |
2482 | jmp wakeup_osloop |
2487 | jmp wakeup_osloop |
2483 | .get_doubleclick_delay: |
2488 | .get_doubleclick_delay: |
2484 | xor eax, eax |
2489 | xor eax, eax |
2485 | mov al, [mouse_doubleclick_delay] |
2490 | mov al, [mouse_doubleclick_delay] |
2486 | mov [esp+32], eax |
2491 | mov [esp+32], eax |
2487 | ret |
2492 | ret |
2488 | .set_doubleclick_delay: |
2493 | .set_doubleclick_delay: |
2489 | mov [mouse_doubleclick_delay], dl |
2494 | mov [mouse_doubleclick_delay], dl |
2490 | ret |
2495 | ret |
2491 | align 4 |
2496 | align 4 |
2492 | .table: |
2497 | .table: |
2493 | dd .get_mouse_acceleration |
2498 | dd .get_mouse_acceleration |
2494 | dd .set_mouse_acceleration |
2499 | dd .set_mouse_acceleration |
2495 | dd .get_mouse_delay |
2500 | dd .get_mouse_delay |
2496 | dd .set_mouse_delay |
2501 | dd .set_mouse_delay |
2497 | dd .set_pointer_position |
2502 | dd .set_pointer_position |
2498 | dd .set_mouse_button |
2503 | dd .set_mouse_button |
2499 | dd .get_doubleclick_delay |
2504 | dd .get_doubleclick_delay |
2500 | dd .set_doubleclick_delay |
2505 | dd .set_doubleclick_delay |
2501 | ;------------------------------------------------------------------------------ |
2506 | ;------------------------------------------------------------------------------ |
2502 | sysfn_getfreemem: |
2507 | sysfn_getfreemem: |
2503 | mov eax, [pg_data.pages_free] |
2508 | mov eax, [pg_data.pages_free] |
2504 | shl eax, 2 |
2509 | shl eax, 2 |
2505 | mov [esp+32], eax |
2510 | mov [esp+32], eax |
2506 | ret |
2511 | ret |
2507 | ;------------------------------------------------------------------------------ |
2512 | ;------------------------------------------------------------------------------ |
2508 | sysfn_getallmem: |
2513 | sysfn_getallmem: |
2509 | mov eax, [MEM_AMOUNT] |
2514 | mov eax, [MEM_AMOUNT] |
2510 | shr eax, 10 |
2515 | shr eax, 10 |
2511 | mov [esp+32], eax |
2516 | mov [esp+32], eax |
2512 | ret |
2517 | ret |
2513 | ;------------------------------------------------------------------------------ |
2518 | ;------------------------------------------------------------------------------ |
2514 | sysfn_pid_to_slot: |
2519 | sysfn_pid_to_slot: |
2515 | mov eax, ecx |
2520 | mov eax, ecx |
2516 | call pid_to_slot |
2521 | call pid_to_slot |
2517 | mov [esp+32], eax |
2522 | mov [esp+32], eax |
2518 | ret |
2523 | ret |
2519 | ;------------------------------------------------------------------------------ |
2524 | ;------------------------------------------------------------------------------ |
2520 | sysfn_min_rest_window: |
2525 | sysfn_min_rest_window: |
2521 | pushad |
2526 | pushad |
2522 | mov eax, edx ; ebx - operating |
2527 | mov eax, edx ; ebx - operating |
2523 | shr ecx, 1 |
2528 | shr ecx, 1 |
2524 | jnc @f |
2529 | jnc @f |
2525 | call pid_to_slot |
2530 | call pid_to_slot |
2526 | @@: |
2531 | @@: |
2527 | or eax, eax ; eax - number of slot |
2532 | or eax, eax ; eax - number of slot |
2528 | jz .error |
2533 | jz .error |
2529 | cmp eax, 255 ; varify maximal slot number |
2534 | cmp eax, 255 ; varify maximal slot number |
2530 | ja .error |
2535 | ja .error |
2531 | movzx eax, word [WIN_STACK + eax*2] |
2536 | movzx eax, word [WIN_STACK + eax*2] |
2532 | shr ecx, 1 |
2537 | shr ecx, 1 |
2533 | jc .restore |
2538 | jc .restore |
2534 | ; .minimize: |
2539 | ; .minimize: |
2535 | call minimize_window |
2540 | call minimize_window |
2536 | jmp .exit |
2541 | jmp .exit |
2537 | .restore: |
2542 | .restore: |
2538 | call restore_minimized_window |
2543 | call restore_minimized_window |
2539 | .exit: |
2544 | .exit: |
2540 | popad |
2545 | popad |
2541 | xor eax, eax |
2546 | xor eax, eax |
2542 | mov [esp+32], eax |
2547 | mov [esp+32], eax |
2543 | ret |
2548 | ret |
2544 | .error: |
2549 | .error: |
2545 | popad |
2550 | popad |
2546 | xor eax, eax |
2551 | xor eax, eax |
2547 | dec eax |
2552 | dec eax |
2548 | mov [esp+32], eax |
2553 | mov [esp+32], eax |
2549 | ret |
2554 | ret |
2550 | ;------------------------------------------------------------------------------ |
2555 | ;------------------------------------------------------------------------------ |
2551 | sysfn_min_windows: |
2556 | sysfn_min_windows: |
2552 | call minimize_all_window |
2557 | call minimize_all_window |
2553 | mov [esp+32], eax |
2558 | mov [esp+32], eax |
2554 | call change_task |
2559 | call change_task |
2555 | ret |
2560 | ret |
2556 | ;------------------------------------------------------------------------------ |
2561 | ;------------------------------------------------------------------------------ |
2557 | sysfn_set_screen_sizes: |
2562 | sysfn_set_screen_sizes: |
2558 | cmp [SCR_MODE], word 0x13 |
2563 | cmp [SCR_MODE], word 0x13 |
2559 | jbe .exit |
2564 | jbe .exit |
2560 | 2565 | ||
2561 | cmp [_display.select_cursor], select_cursor |
2566 | cmp [_display.select_cursor], select_cursor |
2562 | jne .exit |
2567 | jne .exit |
2563 | 2568 | ||
2564 | cmp ecx, [display_width_standard] |
2569 | cmp ecx, [display_width_standard] |
2565 | ja .exit |
2570 | ja .exit |
2566 | 2571 | ||
2567 | cmp edx, [display_height_standard] |
2572 | cmp edx, [display_height_standard] |
2568 | ja .exit |
2573 | ja .exit |
2569 | 2574 | ||
2570 | pushfd |
2575 | pushfd |
2571 | cli |
2576 | cli |
2572 | mov eax, ecx |
2577 | mov eax, ecx |
2573 | mov ecx, [_display.lfb_pitch] |
2578 | mov ecx, [_display.lfb_pitch] |
2574 | mov [_display.width], eax |
2579 | mov [_display.width], eax |
2575 | dec eax |
2580 | dec eax |
2576 | mov [_display.height], edx |
2581 | mov [_display.height], edx |
2577 | dec edx |
2582 | dec edx |
2578 | ; eax - new Screen_Max_X |
2583 | ; eax - new Screen_Max_X |
2579 | ; edx - new Screen_Max_Y |
2584 | ; edx - new Screen_Max_Y |
2580 | mov [do_not_touch_winmap], 1 |
2585 | mov [do_not_touch_winmap], 1 |
2581 | call set_screen |
2586 | call set_screen |
2582 | mov [do_not_touch_winmap], 0 |
2587 | mov [do_not_touch_winmap], 0 |
2583 | popfd |
2588 | popfd |
2584 | call change_task |
2589 | call change_task |
2585 | .exit: |
2590 | .exit: |
2586 | ret |
2591 | ret |
2587 | ;------------------------------------------------------------------------------ |
2592 | ;------------------------------------------------------------------------------ |
2588 | uglobal |
2593 | uglobal |
2589 | screen_workarea RECT |
2594 | screen_workarea RECT |
2590 | display_width_standard dd 0 |
2595 | display_width_standard dd 0 |
2591 | display_height_standard dd 0 |
2596 | display_height_standard dd 0 |
2592 | do_not_touch_winmap db 0 |
2597 | do_not_touch_winmap db 0 |
2593 | window_minimize db 0 |
2598 | window_minimize db 0 |
2594 | sound_flag db 0 |
2599 | sound_flag db 0 |
2595 | 2600 | ||
2596 | endg |
2601 | endg |
2597 | 2602 | ||
2598 | UID_NONE=0 |
2603 | UID_NONE=0 |
2599 | UID_MENUETOS=1 ;official |
2604 | UID_MENUETOS=1 ;official |
2600 | UID_KOLIBRI=2 ;russian |
2605 | UID_KOLIBRI=2 ;russian |
2601 | 2606 | ||
2602 | iglobal |
2607 | iglobal |
2603 | version_inf: |
2608 | version_inf: |
2604 | db 0,7,7,0 ; version 0.7.7.0 |
2609 | db 0,7,7,0 ; version 0.7.7.0 |
2605 | db 0 |
2610 | db 0 |
2606 | .rev dd __REV__ |
2611 | .rev dd __REV__ |
2607 | version_end: |
2612 | version_end: |
2608 | endg |
2613 | endg |
2609 | ;------------------------------------------------------------------------------ |
2614 | ;------------------------------------------------------------------------------ |
2610 | align 4 |
2615 | align 4 |
2611 | sys_cachetodiskette: |
2616 | sys_cachetodiskette: |
2612 | cmp ebx, 1 |
2617 | cmp ebx, 1 |
2613 | jb .no_floppy_save |
2618 | jb .no_floppy_save |
2614 | cmp ebx, 2 |
2619 | cmp ebx, 2 |
2615 | ja .no_floppy_save |
2620 | ja .no_floppy_save |
2616 | call save_image |
2621 | call save_image |
2617 | mov [esp + 32], eax |
2622 | mov [esp + 32], eax |
2618 | ret |
2623 | ret |
2619 | .no_floppy_save: |
2624 | .no_floppy_save: |
2620 | mov [esp + 32], dword 1 |
2625 | mov [esp + 32], dword 1 |
2621 | ret |
2626 | ret |
2622 | ;------------------------------------------------------------------------------ |
2627 | ;------------------------------------------------------------------------------ |
2623 | uglobal |
2628 | uglobal |
2624 | ; bgrchanged dd 0x0 |
2629 | ; bgrchanged dd 0x0 |
2625 | align 4 |
2630 | align 4 |
2626 | bgrlockpid dd 0 |
2631 | bgrlockpid dd 0 |
2627 | bgrlock db 0 |
2632 | bgrlock db 0 |
2628 | endg |
2633 | endg |
2629 | ;------------------------------------------------------------------------------ |
2634 | ;------------------------------------------------------------------------------ |
2630 | align 4 |
2635 | align 4 |
2631 | sys_background: |
2636 | sys_background: |
2632 | cmp ebx, 1 ; BACKGROUND SIZE |
2637 | cmp ebx, 1 ; BACKGROUND SIZE |
2633 | jnz nosb1 |
2638 | jnz nosb1 |
2634 | test ecx, ecx |
2639 | test ecx, ecx |
2635 | jz sbgrr |
2640 | jz sbgrr |
2636 | 2641 | ||
2637 | test edx, edx |
2642 | test edx, edx |
2638 | jz sbgrr |
2643 | jz sbgrr |
2639 | ;-------------------------------------- |
2644 | ;-------------------------------------- |
2640 | align 4 |
2645 | align 4 |
2641 | @@: |
2646 | @@: |
2642 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2647 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2643 | bts dword [bgrlock], 0 |
2648 | bts dword [bgrlock], 0 |
2644 | jnc @f |
2649 | jnc @f |
2645 | call change_task |
2650 | call change_task |
2646 | jmp @b |
2651 | jmp @b |
2647 | ;-------------------------------------- |
2652 | ;-------------------------------------- |
2648 | align 4 |
2653 | align 4 |
2649 | @@: |
2654 | @@: |
2650 | mov [BgrDataWidth], ecx |
2655 | mov [BgrDataWidth], ecx |
2651 | mov [BgrDataHeight], edx |
2656 | mov [BgrDataHeight], edx |
2652 | ; mov [bgrchanged],1 |
2657 | ; mov [bgrchanged],1 |
2653 | 2658 | ||
2654 | pushad |
2659 | pushad |
2655 | ; return memory for old background |
2660 | ; return memory for old background |
2656 | mov eax, [img_background] |
2661 | mov eax, [img_background] |
2657 | cmp eax, static_background_data |
2662 | cmp eax, static_background_data |
2658 | jz @f |
2663 | jz @f |
2659 | stdcall kernel_free, eax |
2664 | stdcall kernel_free, eax |
2660 | ;-------------------------------------- |
2665 | ;-------------------------------------- |
2661 | align 4 |
2666 | align 4 |
2662 | @@: |
2667 | @@: |
2663 | ; calculate RAW size |
2668 | ; calculate RAW size |
2664 | xor eax, eax |
2669 | xor eax, eax |
2665 | inc eax |
2670 | inc eax |
2666 | cmp [BgrDataWidth], eax |
2671 | cmp [BgrDataWidth], eax |
2667 | jae @f |
2672 | jae @f |
2668 | mov [BgrDataWidth], eax |
2673 | mov [BgrDataWidth], eax |
2669 | ;-------------------------------------- |
2674 | ;-------------------------------------- |
2670 | align 4 |
2675 | align 4 |
2671 | @@: |
2676 | @@: |
2672 | cmp [BgrDataHeight], eax |
2677 | cmp [BgrDataHeight], eax |
2673 | jae @f |
2678 | jae @f |
2674 | mov [BgrDataHeight], eax |
2679 | mov [BgrDataHeight], eax |
2675 | ;-------------------------------------- |
2680 | ;-------------------------------------- |
2676 | align 4 |
2681 | align 4 |
2677 | @@: |
2682 | @@: |
2678 | mov eax, [BgrDataWidth] |
2683 | mov eax, [BgrDataWidth] |
2679 | imul eax, [BgrDataHeight] |
2684 | imul eax, [BgrDataHeight] |
2680 | lea eax, [eax*3] |
2685 | lea eax, [eax*3] |
2681 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2686 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2682 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2687 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2683 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2688 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2684 | shr eax, 12 |
2689 | shr eax, 12 |
2685 | inc eax |
2690 | inc eax |
2686 | shl eax, 12 |
2691 | shl eax, 12 |
2687 | mov [mem_BACKGROUND], eax |
2692 | mov [mem_BACKGROUND], eax |
2688 | ; get memory for new background |
2693 | ; get memory for new background |
2689 | stdcall kernel_alloc, eax |
2694 | stdcall kernel_alloc, eax |
2690 | test eax, eax |
2695 | test eax, eax |
2691 | jz .memfailed |
2696 | jz .memfailed |
2692 | mov [img_background], eax |
2697 | mov [img_background], eax |
2693 | jmp .exit |
2698 | jmp .exit |
2694 | ;-------------------------------------- |
2699 | ;-------------------------------------- |
2695 | align 4 |
2700 | align 4 |
2696 | .memfailed: |
2701 | .memfailed: |
2697 | ; revert to static monotone data |
2702 | ; revert to static monotone data |
2698 | mov [img_background], static_background_data |
2703 | mov [img_background], static_background_data |
2699 | xor eax, eax |
2704 | xor eax, eax |
2700 | inc eax |
2705 | inc eax |
2701 | mov [BgrDataWidth], eax |
2706 | mov [BgrDataWidth], eax |
2702 | mov [BgrDataHeight], eax |
2707 | mov [BgrDataHeight], eax |
2703 | mov [mem_BACKGROUND], 4 |
2708 | mov [mem_BACKGROUND], 4 |
2704 | ;-------------------------------------- |
2709 | ;-------------------------------------- |
2705 | align 4 |
2710 | align 4 |
2706 | .exit: |
2711 | .exit: |
2707 | popad |
2712 | popad |
2708 | mov [bgrlock], 0 |
2713 | mov [bgrlock], 0 |
2709 | ;-------------------------------------- |
2714 | ;-------------------------------------- |
2710 | align 4 |
2715 | align 4 |
2711 | sbgrr: |
2716 | sbgrr: |
2712 | ret |
2717 | ret |
2713 | ;------------------------------------------------------------------------------ |
2718 | ;------------------------------------------------------------------------------ |
2714 | align 4 |
2719 | align 4 |
2715 | nosb1: |
2720 | nosb1: |
2716 | cmp ebx, 2 ; SET PIXEL |
2721 | cmp ebx, 2 ; SET PIXEL |
2717 | jnz nosb2 |
2722 | jnz nosb2 |
2718 | 2723 | ||
2719 | mov eax, [img_background] |
2724 | mov eax, [img_background] |
2720 | test ecx, ecx |
2725 | test ecx, ecx |
2721 | jz @f |
2726 | jz @f |
2722 | cmp eax, static_background_data |
2727 | cmp eax, static_background_data |
2723 | jz .ret |
2728 | jz .ret |
2724 | ;-------------------------------------- |
2729 | ;-------------------------------------- |
2725 | align 4 |
2730 | align 4 |
2726 | @@: |
2731 | @@: |
2727 | mov ebx, [mem_BACKGROUND] |
2732 | mov ebx, [mem_BACKGROUND] |
2728 | add ebx, 4095 |
2733 | add ebx, 4095 |
2729 | and ebx, -4096 |
2734 | and ebx, -4096 |
2730 | sub ebx, 4 |
2735 | sub ebx, 4 |
2731 | cmp ecx, ebx |
2736 | cmp ecx, ebx |
2732 | ja .ret |
2737 | ja .ret |
2733 | 2738 | ||
2734 | mov ebx, [eax+ecx] |
2739 | mov ebx, [eax+ecx] |
2735 | and ebx, 0xFF000000;255*256*256*256 |
2740 | and ebx, 0xFF000000;255*256*256*256 |
2736 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2741 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2737 | add edx, ebx |
2742 | add edx, ebx |
2738 | mov [eax+ecx], edx |
2743 | mov [eax+ecx], edx |
2739 | ;-------------------------------------- |
2744 | ;-------------------------------------- |
2740 | align 4 |
2745 | align 4 |
2741 | .ret: |
2746 | .ret: |
2742 | ret |
2747 | ret |
2743 | ;------------------------------------------------------------------------------ |
2748 | ;------------------------------------------------------------------------------ |
2744 | align 4 |
2749 | align 4 |
2745 | nosb2: |
2750 | nosb2: |
2746 | cmp ebx, 3 ; DRAW BACKGROUND |
2751 | cmp ebx, 3 ; DRAW BACKGROUND |
2747 | jnz nosb3 |
2752 | jnz nosb3 |
2748 | ;-------------------------------------- |
2753 | ;-------------------------------------- |
2749 | align 4 |
2754 | align 4 |
2750 | draw_background_temp: |
2755 | draw_background_temp: |
2751 | mov [background_defined], 1 |
2756 | mov [background_defined], 1 |
2752 | call force_redraw_background |
2757 | call force_redraw_background |
2753 | ;-------------------------------------- |
2758 | ;-------------------------------------- |
2754 | align 4 |
2759 | align 4 |
2755 | nosb31: |
2760 | nosb31: |
2756 | ret |
2761 | ret |
2757 | ;------------------------------------------------------------------------------ |
2762 | ;------------------------------------------------------------------------------ |
2758 | align 4 |
2763 | align 4 |
2759 | nosb3: |
2764 | nosb3: |
2760 | cmp ebx, 4 ; TILED / STRETCHED |
2765 | cmp ebx, 4 ; TILED / STRETCHED |
2761 | jnz nosb4 |
2766 | jnz nosb4 |
2762 | cmp ecx, [BgrDrawMode] |
2767 | cmp ecx, [BgrDrawMode] |
2763 | je nosb41 |
2768 | je nosb41 |
2764 | mov [BgrDrawMode], ecx |
2769 | mov [BgrDrawMode], ecx |
2765 | ;-------------------------------------- |
2770 | ;-------------------------------------- |
2766 | align 4 |
2771 | align 4 |
2767 | nosb41: |
2772 | nosb41: |
2768 | ret |
2773 | ret |
2769 | ;------------------------------------------------------------------------------ |
2774 | ;------------------------------------------------------------------------------ |
2770 | align 4 |
2775 | align 4 |
2771 | nosb4: |
2776 | nosb4: |
2772 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2777 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2773 | jnz nosb5 |
2778 | jnz nosb5 |
2774 | cmp [img_background], static_background_data |
2779 | cmp [img_background], static_background_data |
2775 | jnz @f |
2780 | jnz @f |
2776 | test edx, edx |
2781 | test edx, edx |
2777 | jnz .fin |
2782 | jnz .fin |
2778 | cmp esi, 4 |
2783 | cmp esi, 4 |
2779 | ja .fin |
2784 | ja .fin |
2780 | ;-------------------------------------- |
2785 | ;-------------------------------------- |
2781 | align 4 |
2786 | align 4 |
2782 | @@: |
2787 | @@: |
2783 | ; bughere |
2788 | ; bughere |
2784 | mov eax, ecx |
2789 | mov eax, ecx |
2785 | mov ebx, edx |
2790 | mov ebx, edx |
2786 | add ebx, [img_background];IMG_BACKGROUND |
2791 | add ebx, [img_background];IMG_BACKGROUND |
2787 | mov ecx, esi |
2792 | mov ecx, esi |
2788 | call memmove |
2793 | call memmove |
2789 | ;-------------------------------------- |
2794 | ;-------------------------------------- |
2790 | align 4 |
2795 | align 4 |
2791 | .fin: |
2796 | .fin: |
2792 | ret |
2797 | ret |
2793 | ;------------------------------------------------------------------------------ |
2798 | ;------------------------------------------------------------------------------ |
2794 | align 4 |
2799 | align 4 |
2795 | nosb5: |
2800 | nosb5: |
2796 | cmp ebx, 6 |
2801 | cmp ebx, 6 |
2797 | jnz nosb6 |
2802 | jnz nosb6 |
2798 | ;-------------------------------------- |
2803 | ;-------------------------------------- |
2799 | align 4 |
2804 | align 4 |
2800 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2805 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2801 | @@: |
2806 | @@: |
2802 | bts dword [bgrlock], 0 |
2807 | bts dword [bgrlock], 0 |
2803 | jnc @f |
2808 | jnc @f |
2804 | call change_task |
2809 | call change_task |
2805 | jmp @b |
2810 | jmp @b |
2806 | ;-------------------------------------- |
2811 | ;-------------------------------------- |
2807 | align 4 |
2812 | align 4 |
2808 | @@: |
2813 | @@: |
2809 | mov eax, [CURRENT_TASK] |
2814 | mov eax, [CURRENT_TASK] |
2810 | mov [bgrlockpid], eax |
2815 | mov [bgrlockpid], eax |
2811 | cmp [img_background], static_background_data |
2816 | cmp [img_background], static_background_data |
2812 | jz .nomem |
2817 | jz .nomem |
2813 | stdcall user_alloc, [mem_BACKGROUND] |
2818 | stdcall user_alloc, [mem_BACKGROUND] |
2814 | mov [esp+32], eax |
2819 | mov [esp+32], eax |
2815 | test eax, eax |
2820 | test eax, eax |
2816 | jz .nomem |
2821 | jz .nomem |
2817 | mov ebx, eax |
2822 | mov ebx, eax |
2818 | shr ebx, 12 |
2823 | shr ebx, 12 |
2819 | or dword [page_tabs+(ebx-1)*4], MEM_BLOCK_DONT_FREE |
2824 | or dword [page_tabs+(ebx-1)*4], MEM_BLOCK_DONT_FREE |
2820 | mov esi, [img_background] |
2825 | mov esi, [img_background] |
2821 | shr esi, 12 |
2826 | shr esi, 12 |
2822 | mov ecx, [mem_BACKGROUND] |
2827 | mov ecx, [mem_BACKGROUND] |
2823 | add ecx, 0xFFF |
2828 | add ecx, 0xFFF |
2824 | shr ecx, 12 |
2829 | shr ecx, 12 |
2825 | ;-------------------------------------- |
2830 | ;-------------------------------------- |
2826 | align 4 |
2831 | align 4 |
2827 | .z: |
2832 | .z: |
2828 | mov eax, [page_tabs+ebx*4] |
2833 | mov eax, [page_tabs+ebx*4] |
2829 | test al, 1 |
2834 | test al, 1 |
2830 | jz @f |
2835 | jz @f |
2831 | call free_page |
2836 | call free_page |
2832 | ;-------------------------------------- |
2837 | ;-------------------------------------- |
2833 | align 4 |
2838 | align 4 |
2834 | @@: |
2839 | @@: |
2835 | mov eax, [page_tabs+esi*4] |
2840 | mov eax, [page_tabs+esi*4] |
2836 | or al, PG_UWR |
2841 | or al, PG_UWR |
2837 | mov [page_tabs+ebx*4], eax |
2842 | mov [page_tabs+ebx*4], eax |
2838 | mov eax, ebx |
2843 | mov eax, ebx |
2839 | shl eax, 12 |
2844 | shl eax, 12 |
2840 | invlpg [eax] |
2845 | invlpg [eax] |
2841 | inc ebx |
2846 | inc ebx |
2842 | inc esi |
2847 | inc esi |
2843 | loop .z |
2848 | loop .z |
2844 | ret |
2849 | ret |
2845 | ;-------------------------------------- |
2850 | ;-------------------------------------- |
2846 | align 4 |
2851 | align 4 |
2847 | .nomem: |
2852 | .nomem: |
2848 | and [bgrlockpid], 0 |
2853 | and [bgrlockpid], 0 |
2849 | mov [bgrlock], 0 |
2854 | mov [bgrlock], 0 |
2850 | ;------------------------------------------------------------------------------ |
2855 | ;------------------------------------------------------------------------------ |
2851 | align 4 |
2856 | align 4 |
2852 | nosb6: |
2857 | nosb6: |
2853 | cmp ebx, 7 |
2858 | cmp ebx, 7 |
2854 | jnz nosb7 |
2859 | jnz nosb7 |
2855 | cmp [bgrlock], 0 |
2860 | cmp [bgrlock], 0 |
2856 | jz .err |
2861 | jz .err |
2857 | mov eax, [CURRENT_TASK] |
2862 | mov eax, [CURRENT_TASK] |
2858 | cmp [bgrlockpid], eax |
2863 | cmp [bgrlockpid], eax |
2859 | jnz .err |
2864 | jnz .err |
2860 | mov eax, ecx |
2865 | mov eax, ecx |
2861 | mov ebx, ecx |
2866 | mov ebx, ecx |
2862 | shr eax, 12 |
2867 | shr eax, 12 |
2863 | mov ecx, [page_tabs+(eax-1)*4] |
2868 | mov ecx, [page_tabs+(eax-1)*4] |
2864 | test cl, MEM_BLOCK_USED or MEM_BLOCK_DONT_FREE |
2869 | test cl, MEM_BLOCK_USED or MEM_BLOCK_DONT_FREE |
2865 | jz .err |
2870 | jz .err |
2866 | jnp .err |
2871 | jnp .err |
2867 | push eax |
2872 | push eax |
2868 | shr ecx, 12 |
2873 | shr ecx, 12 |
2869 | dec ecx |
2874 | dec ecx |
2870 | ;-------------------------------------- |
2875 | ;-------------------------------------- |
2871 | align 4 |
2876 | align 4 |
2872 | @@: |
2877 | @@: |
2873 | and dword [page_tabs+eax*4], 0 |
2878 | and dword [page_tabs+eax*4], 0 |
2874 | mov edx, eax |
2879 | mov edx, eax |
2875 | shl edx, 12 |
2880 | shl edx, 12 |
2876 | push eax |
2881 | push eax |
2877 | invlpg [edx] |
2882 | invlpg [edx] |
2878 | pop eax |
2883 | pop eax |
2879 | inc eax |
2884 | inc eax |
2880 | loop @b |
2885 | loop @b |
2881 | pop eax |
2886 | pop eax |
2882 | and dword [page_tabs+(eax-1)*4], not MEM_BLOCK_DONT_FREE |
2887 | and dword [page_tabs+(eax-1)*4], not MEM_BLOCK_DONT_FREE |
2883 | stdcall user_free, ebx |
2888 | stdcall user_free, ebx |
2884 | mov [esp+32], eax |
2889 | mov [esp+32], eax |
2885 | and [bgrlockpid], 0 |
2890 | and [bgrlockpid], 0 |
2886 | mov [bgrlock], 0 |
2891 | mov [bgrlock], 0 |
2887 | ret |
2892 | ret |
2888 | ;-------------------------------------- |
2893 | ;-------------------------------------- |
2889 | align 4 |
2894 | align 4 |
2890 | .err: |
2895 | .err: |
2891 | and dword [esp+32], 0 |
2896 | and dword [esp+32], 0 |
2892 | ret |
2897 | ret |
2893 | ;------------------------------------------------------------------------------ |
2898 | ;------------------------------------------------------------------------------ |
2894 | align 4 |
2899 | align 4 |
2895 | nosb7: |
2900 | nosb7: |
2896 | cmp ebx, 8 |
2901 | cmp ebx, 8 |
2897 | jnz nosb8 |
2902 | jnz nosb8 |
2898 | 2903 | ||
2899 | mov ecx, [current_slot] |
2904 | mov ecx, [current_slot] |
2900 | xor eax, eax |
2905 | xor eax, eax |
2901 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2906 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2902 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2907 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2903 | xor eax, eax |
2908 | xor eax, eax |
2904 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2909 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2905 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2910 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2906 | ret |
2911 | ret |
2907 | ;------------------------------------------------------------------------------ |
2912 | ;------------------------------------------------------------------------------ |
2908 | align 4 |
2913 | align 4 |
2909 | nosb8: |
2914 | nosb8: |
2910 | cmp ebx, 9 |
2915 | cmp ebx, 9 |
2911 | jnz nosb9 |
2916 | jnz nosb9 |
2912 | ; ecx = [left]*65536 + [right] |
2917 | ; ecx = [left]*65536 + [right] |
2913 | ; edx = [top]*65536 + [bottom] |
2918 | ; edx = [top]*65536 + [bottom] |
2914 | mov eax, [_display.width] |
2919 | mov eax, [_display.width] |
2915 | mov ebx, [_display.height] |
2920 | mov ebx, [_display.height] |
2916 | ; check [right] |
2921 | ; check [right] |
2917 | cmp cx, ax |
2922 | cmp cx, ax |
2918 | jae .exit |
2923 | jae .exit |
2919 | ; check [left] |
2924 | ; check [left] |
2920 | ror ecx, 16 |
2925 | ror ecx, 16 |
2921 | cmp cx, ax |
2926 | cmp cx, ax |
2922 | jae .exit |
2927 | jae .exit |
2923 | ; check [bottom] |
2928 | ; check [bottom] |
2924 | cmp dx, bx |
2929 | cmp dx, bx |
2925 | jae .exit |
2930 | jae .exit |
2926 | ; check [top] |
2931 | ; check [top] |
2927 | ror edx, 16 |
2932 | ror edx, 16 |
2928 | cmp dx, bx |
2933 | cmp dx, bx |
2929 | jae .exit |
2934 | jae .exit |
2930 | 2935 | ||
2931 | movzx eax, cx ; [left] |
2936 | movzx eax, cx ; [left] |
2932 | movzx ebx, dx ; [top] |
2937 | movzx ebx, dx ; [top] |
2933 | 2938 | ||
2934 | shr ecx, 16 ; [right] |
2939 | shr ecx, 16 ; [right] |
2935 | shr edx, 16 ; [bottom] |
2940 | shr edx, 16 ; [bottom] |
2936 | 2941 | ||
2937 | mov [background_defined], 1 |
2942 | mov [background_defined], 1 |
2938 | 2943 | ||
2939 | mov [draw_data+32 + RECT.left], eax |
2944 | mov [draw_data+32 + RECT.left], eax |
2940 | mov [draw_data+32 + RECT.top], ebx |
2945 | mov [draw_data+32 + RECT.top], ebx |
2941 | 2946 | ||
2942 | mov [draw_data+32 + RECT.right], ecx |
2947 | mov [draw_data+32 + RECT.right], ecx |
2943 | mov [draw_data+32 + RECT.bottom], edx |
2948 | mov [draw_data+32 + RECT.bottom], edx |
2944 | 2949 | ||
2945 | inc [REDRAW_BACKGROUND] |
2950 | inc [REDRAW_BACKGROUND] |
2946 | call wakeup_osloop |
2951 | call wakeup_osloop |
2947 | ;-------------------------------------- |
2952 | ;-------------------------------------- |
2948 | align 4 |
2953 | align 4 |
2949 | .exit: |
2954 | .exit: |
2950 | ret |
2955 | ret |
2951 | ;------------------------------------------------------------------------------ |
2956 | ;------------------------------------------------------------------------------ |
2952 | align 4 |
2957 | align 4 |
2953 | nosb9: |
2958 | nosb9: |
2954 | ret |
2959 | ret |
2955 | ;------------------------------------------------------------------------------ |
2960 | ;------------------------------------------------------------------------------ |
2956 | align 4 |
2961 | align 4 |
2957 | uglobal |
2962 | uglobal |
2958 | BG_Rect_X_left_right dd 0x0 |
2963 | BG_Rect_X_left_right dd 0x0 |
2959 | BG_Rect_Y_top_bottom dd 0x0 |
2964 | BG_Rect_Y_top_bottom dd 0x0 |
2960 | endg |
2965 | endg |
2961 | ;------------------------------------------------------------------------------ |
2966 | ;------------------------------------------------------------------------------ |
2962 | align 4 |
2967 | align 4 |
2963 | force_redraw_background: |
2968 | force_redraw_background: |
2964 | and [draw_data+32 + RECT.left], 0 |
2969 | and [draw_data+32 + RECT.left], 0 |
2965 | and [draw_data+32 + RECT.top], 0 |
2970 | and [draw_data+32 + RECT.top], 0 |
2966 | push eax ebx |
2971 | push eax ebx |
2967 | mov eax, [_display.width] |
2972 | mov eax, [_display.width] |
2968 | mov ebx, [_display.height] |
2973 | mov ebx, [_display.height] |
2969 | dec eax |
2974 | dec eax |
2970 | dec ebx |
2975 | dec ebx |
2971 | mov [draw_data+32 + RECT.right], eax |
2976 | mov [draw_data+32 + RECT.right], eax |
2972 | mov [draw_data+32 + RECT.bottom], ebx |
2977 | mov [draw_data+32 + RECT.bottom], ebx |
2973 | pop ebx eax |
2978 | pop ebx eax |
2974 | inc [REDRAW_BACKGROUND] |
2979 | inc [REDRAW_BACKGROUND] |
2975 | call wakeup_osloop |
2980 | call wakeup_osloop |
2976 | ret |
2981 | ret |
2977 | ;------------------------------------------------------------------------------ |
2982 | ;------------------------------------------------------------------------------ |
2978 | align 4 |
2983 | align 4 |
2979 | sys_getbackground: |
2984 | sys_getbackground: |
2980 | ; cmp eax,1 ; SIZE |
2985 | ; cmp eax,1 ; SIZE |
2981 | dec ebx |
2986 | dec ebx |
2982 | jnz nogb1 |
2987 | jnz nogb1 |
2983 | mov eax, [BgrDataWidth] |
2988 | mov eax, [BgrDataWidth] |
2984 | shl eax, 16 |
2989 | shl eax, 16 |
2985 | mov ax, word [BgrDataHeight] |
2990 | mov ax, word [BgrDataHeight] |
2986 | mov [esp+32], eax |
2991 | mov [esp+32], eax |
2987 | ret |
2992 | ret |
2988 | ;------------------------------------------------------------------------------ |
2993 | ;------------------------------------------------------------------------------ |
2989 | align 4 |
2994 | align 4 |
2990 | nogb1: |
2995 | nogb1: |
2991 | ; cmp eax,2 ; PIXEL |
2996 | ; cmp eax,2 ; PIXEL |
2992 | dec ebx |
2997 | dec ebx |
2993 | jnz nogb2 |
2998 | jnz nogb2 |
2994 | 2999 | ||
2995 | mov eax, [img_background] |
3000 | mov eax, [img_background] |
2996 | test ecx, ecx |
3001 | test ecx, ecx |
2997 | jz @f |
3002 | jz @f |
2998 | cmp eax, static_background_data |
3003 | cmp eax, static_background_data |
2999 | jz .ret |
3004 | jz .ret |
3000 | ;-------------------------------------- |
3005 | ;-------------------------------------- |
3001 | align 4 |
3006 | align 4 |
3002 | @@: |
3007 | @@: |
3003 | mov ebx, [mem_BACKGROUND] |
3008 | mov ebx, [mem_BACKGROUND] |
3004 | add ebx, 4095 |
3009 | add ebx, 4095 |
3005 | and ebx, -4096 |
3010 | and ebx, -4096 |
3006 | sub ebx, 4 |
3011 | sub ebx, 4 |
3007 | cmp ecx, ebx |
3012 | cmp ecx, ebx |
3008 | ja .ret |
3013 | ja .ret |
3009 | 3014 | ||
3010 | mov eax, [ecx+eax] |
3015 | mov eax, [ecx+eax] |
3011 | 3016 | ||
3012 | and eax, 0xFFFFFF |
3017 | and eax, 0xFFFFFF |
3013 | mov [esp+32], eax |
3018 | mov [esp+32], eax |
3014 | ;-------------------------------------- |
3019 | ;-------------------------------------- |
3015 | align 4 |
3020 | align 4 |
3016 | .ret: |
3021 | .ret: |
3017 | ret |
3022 | ret |
3018 | ;------------------------------------------------------------------------------ |
3023 | ;------------------------------------------------------------------------------ |
3019 | align 4 |
3024 | align 4 |
3020 | nogb2: |
3025 | nogb2: |
3021 | 3026 | ||
3022 | ; cmp eax,4 ; TILED / STRETCHED |
3027 | ; cmp eax,4 ; TILED / STRETCHED |
3023 | dec ebx |
3028 | dec ebx |
3024 | dec ebx |
3029 | dec ebx |
3025 | jnz nogb4 |
3030 | jnz nogb4 |
3026 | mov eax, [BgrDrawMode] |
3031 | mov eax, [BgrDrawMode] |
3027 | ;-------------------------------------- |
3032 | ;-------------------------------------- |
3028 | align 4 |
3033 | align 4 |
3029 | nogb4: |
3034 | nogb4: |
3030 | mov [esp+32], eax |
3035 | mov [esp+32], eax |
3031 | ret |
3036 | ret |
3032 | ;------------------------------------------------------------------------------ |
3037 | ;------------------------------------------------------------------------------ |
3033 | align 4 |
3038 | align 4 |
3034 | sys_getkey: |
3039 | sys_getkey: |
3035 | mov [esp + 32], dword 1 |
3040 | mov [esp + 32], dword 1 |
3036 | ; test main buffer |
3041 | ; test main buffer |
3037 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3042 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3038 | movzx ecx, word [WIN_STACK + ebx * 2] |
3043 | movzx ecx, word [WIN_STACK + ebx * 2] |
3039 | mov edx, [TASK_COUNT] |
3044 | mov edx, [TASK_COUNT] |
3040 | cmp ecx, edx |
3045 | cmp ecx, edx |
3041 | jne .finish |
3046 | jne .finish |
3042 | cmp [KEY_COUNT], byte 0 |
3047 | cmp [KEY_COUNT], byte 0 |
3043 | je .finish |
3048 | je .finish |
3044 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3049 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3045 | shl eax, 8 |
3050 | shl eax, 8 |
3046 | mov al, byte [KEY_BUFF] |
3051 | mov al, byte [KEY_BUFF] |
3047 | shl eax, 8 |
3052 | shl eax, 8 |
3048 | push eax |
3053 | push eax |
3049 | dec byte [KEY_COUNT] |
3054 | dec byte [KEY_COUNT] |
3050 | and byte [KEY_COUNT], 127 |
3055 | and byte [KEY_COUNT], 127 |
3051 | movzx ecx, byte [KEY_COUNT] |
3056 | movzx ecx, byte [KEY_COUNT] |
3052 | add ecx, 2 |
3057 | add ecx, 2 |
3053 | mov eax, KEY_BUFF + 1 |
3058 | mov eax, KEY_BUFF + 1 |
3054 | mov ebx, KEY_BUFF |
3059 | mov ebx, KEY_BUFF |
3055 | call memmove |
3060 | call memmove |
3056 | add eax, 120 + 2 |
3061 | add eax, 120 + 2 |
3057 | add ebx, 120 + 2 |
3062 | add ebx, 120 + 2 |
3058 | call memmove |
3063 | call memmove |
3059 | pop eax |
3064 | pop eax |
3060 | ;-------------------------------------- |
3065 | ;-------------------------------------- |
3061 | align 4 |
3066 | align 4 |
3062 | .ret_eax: |
3067 | .ret_eax: |
3063 | mov [esp + 32], eax |
3068 | mov [esp + 32], eax |
3064 | ret |
3069 | ret |
3065 | ;-------------------------------------- |
3070 | ;-------------------------------------- |
3066 | align 4 |
3071 | align 4 |
3067 | .finish: |
3072 | .finish: |
3068 | ; test hotkeys buffer |
3073 | ; test hotkeys buffer |
3069 | mov ecx, hotkey_buffer |
3074 | mov ecx, hotkey_buffer |
3070 | ;-------------------------------------- |
3075 | ;-------------------------------------- |
3071 | align 4 |
3076 | align 4 |
3072 | @@: |
3077 | @@: |
3073 | cmp [ecx], ebx |
3078 | cmp [ecx], ebx |
3074 | jz .found |
3079 | jz .found |
3075 | add ecx, 8 |
3080 | add ecx, 8 |
3076 | cmp ecx, hotkey_buffer + 120 * 8 |
3081 | cmp ecx, hotkey_buffer + 120 * 8 |
3077 | jb @b |
3082 | jb @b |
3078 | ret |
3083 | ret |
3079 | ;-------------------------------------- |
3084 | ;-------------------------------------- |
3080 | align 4 |
3085 | align 4 |
3081 | .found: |
3086 | .found: |
3082 | mov ax, [ecx + 6] |
3087 | mov ax, [ecx + 6] |
3083 | shl eax, 16 |
3088 | shl eax, 16 |
3084 | mov ah, [ecx + 4] |
3089 | mov ah, [ecx + 4] |
3085 | mov al, 2 |
3090 | mov al, 2 |
3086 | and dword [ecx + 4], 0 |
3091 | and dword [ecx + 4], 0 |
3087 | and dword [ecx], 0 |
3092 | and dword [ecx], 0 |
3088 | jmp .ret_eax |
3093 | jmp .ret_eax |
3089 | ;------------------------------------------------------------------------------ |
3094 | ;------------------------------------------------------------------------------ |
3090 | align 4 |
3095 | align 4 |
3091 | sys_getbutton: |
3096 | sys_getbutton: |
3092 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3097 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3093 | mov [esp + 32], dword 1 |
3098 | mov [esp + 32], dword 1 |
3094 | movzx ecx, word [WIN_STACK + ebx * 2] |
3099 | movzx ecx, word [WIN_STACK + ebx * 2] |
3095 | mov edx, [TASK_COUNT] ; less than 256 processes |
3100 | mov edx, [TASK_COUNT] ; less than 256 processes |
3096 | cmp ecx, edx |
3101 | cmp ecx, edx |
3097 | jne .exit |
3102 | jne .exit |
3098 | movzx eax, byte [BTN_COUNT] |
3103 | movzx eax, byte [BTN_COUNT] |
3099 | test eax, eax |
3104 | test eax, eax |
3100 | jz .exit |
3105 | jz .exit |
3101 | mov eax, [BTN_BUFF] |
3106 | mov eax, [BTN_BUFF] |
3102 | and al, 0xFE ; delete left button bit |
3107 | and al, 0xFE ; delete left button bit |
3103 | mov [BTN_COUNT], byte 0 |
3108 | mov [BTN_COUNT], byte 0 |
3104 | mov [esp + 32], eax |
3109 | mov [esp + 32], eax |
3105 | ;-------------------------------------- |
3110 | ;-------------------------------------- |
3106 | align 4 |
3111 | align 4 |
3107 | .exit: |
3112 | .exit: |
3108 | ret |
3113 | ret |
3109 | ;------------------------------------------------------------------------------ |
3114 | ;------------------------------------------------------------------------------ |
3110 | align 4 |
3115 | align 4 |
3111 | sys_cpuusage: |
3116 | sys_cpuusage: |
3112 | 3117 | ||
3113 | ; RETURN: |
3118 | ; RETURN: |
3114 | ; |
3119 | ; |
3115 | ; +00 dword process cpu usage |
3120 | ; +00 dword process cpu usage |
3116 | ; +04 word position in windowing stack |
3121 | ; +04 word position in windowing stack |
3117 | ; +06 word windowing stack value at current position (cpu nro) |
3122 | ; +06 word windowing stack value at current position (cpu nro) |
3118 | ; +10 12 bytes name |
3123 | ; +10 12 bytes name |
3119 | ; +22 dword start in mem |
3124 | ; +22 dword start in mem |
3120 | ; +26 dword used mem |
3125 | ; +26 dword used mem |
3121 | ; +30 dword PID , process idenfification number |
3126 | ; +30 dword PID , process idenfification number |
3122 | ; |
3127 | ; |
3123 | 3128 | ||
3124 | cmp ecx, -1 ; who am I ? |
3129 | cmp ecx, -1 ; who am I ? |
3125 | jne .no_who_am_i |
3130 | jne .no_who_am_i |
3126 | mov ecx, [CURRENT_TASK] |
3131 | mov ecx, [CURRENT_TASK] |
3127 | .no_who_am_i: |
3132 | .no_who_am_i: |
3128 | cmp ecx, max_processes |
3133 | cmp ecx, max_processes |
3129 | ja .nofillbuf |
3134 | ja .nofillbuf |
3130 | 3135 | ||
3131 | ; +4: word: position of the window of thread in the window stack |
3136 | ; +4: word: position of the window of thread in the window stack |
3132 | mov ax, [WIN_STACK + ecx * 2] |
3137 | mov ax, [WIN_STACK + ecx * 2] |
3133 | mov [ebx+4], ax |
3138 | mov [ebx+4], ax |
3134 | ; +6: word: number of the thread slot, which window has in the window stack |
3139 | ; +6: word: number of the thread slot, which window has in the window stack |
3135 | ; position ecx (has no relation to the specific thread) |
3140 | ; position ecx (has no relation to the specific thread) |
3136 | mov ax, [WIN_POS + ecx * 2] |
3141 | mov ax, [WIN_POS + ecx * 2] |
3137 | mov [ebx+6], ax |
3142 | mov [ebx+6], ax |
3138 | 3143 | ||
3139 | shl ecx, 5 |
3144 | shl ecx, 5 |
3140 | 3145 | ||
3141 | ; +0: dword: memory usage |
3146 | ; +0: dword: memory usage |
3142 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3147 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3143 | mov [ebx], eax |
3148 | mov [ebx], eax |
3144 | ; +10: 11 bytes: name of the process |
3149 | ; +10: 11 bytes: name of the process |
3145 | push ecx |
3150 | push ecx |
3146 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3151 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3147 | add ebx, 10 |
3152 | add ebx, 10 |
3148 | mov ecx, 11 |
3153 | mov ecx, 11 |
3149 | call memmove |
3154 | call memmove |
3150 | pop ecx |
3155 | pop ecx |
3151 | 3156 | ||
3152 | ; +22: address of the process in memory |
3157 | ; +22: address of the process in memory |
3153 | ; +26: size of used memory - 1 |
3158 | ; +26: size of used memory - 1 |
3154 | push edi |
3159 | push edi |
3155 | lea edi, [ebx+12] |
3160 | lea edi, [ebx+12] |
3156 | xor eax, eax |
3161 | xor eax, eax |
3157 | mov edx, 0x100000*16 |
3162 | mov edx, 0x100000*16 |
3158 | cmp ecx, 1 shl 5 |
3163 | cmp ecx, 1 shl 5 |
3159 | je .os_mem |
3164 | je .os_mem |
3160 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3165 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3161 | mov edx, [edx+PROC.mem_used] |
3166 | mov edx, [edx+PROC.mem_used] |
3162 | mov eax, std_application_base_address |
3167 | mov eax, std_application_base_address |
3163 | .os_mem: |
3168 | .os_mem: |
3164 | stosd |
3169 | stosd |
3165 | lea eax, [edx-1] |
3170 | lea eax, [edx-1] |
3166 | stosd |
3171 | stosd |
3167 | 3172 | ||
3168 | ; +30: PID/TID |
3173 | ; +30: PID/TID |
3169 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3174 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3170 | stosd |
3175 | stosd |
3171 | 3176 | ||
3172 | ; window position and size |
3177 | ; window position and size |
3173 | push esi |
3178 | push esi |
3174 | lea esi, [ecx + window_data + WDATA.box] |
3179 | lea esi, [ecx + window_data + WDATA.box] |
3175 | movsd |
3180 | movsd |
3176 | movsd |
3181 | movsd |
3177 | movsd |
3182 | movsd |
3178 | movsd |
3183 | movsd |
3179 | 3184 | ||
3180 | ; Process state (+50) |
3185 | ; Process state (+50) |
3181 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3186 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3182 | stosd |
3187 | stosd |
3183 | 3188 | ||
3184 | ; Window client area box |
3189 | ; Window client area box |
3185 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3190 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3186 | movsd |
3191 | movsd |
3187 | movsd |
3192 | movsd |
3188 | movsd |
3193 | movsd |
3189 | movsd |
3194 | movsd |
3190 | 3195 | ||
3191 | ; Window state |
3196 | ; Window state |
3192 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3197 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3193 | stosb |
3198 | stosb |
3194 | 3199 | ||
3195 | ; Event mask (+71) |
3200 | ; Event mask (+71) |
3196 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3201 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3197 | stosd |
3202 | stosd |
3198 | 3203 | ||
3199 | ; Keyboard mode (+75) |
3204 | ; Keyboard mode (+75) |
3200 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3205 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3201 | stosb |
3206 | stosb |
3202 | 3207 | ||
3203 | pop esi |
3208 | pop esi |
3204 | pop edi |
3209 | pop edi |
3205 | 3210 | ||
3206 | .nofillbuf: |
3211 | .nofillbuf: |
3207 | ; return number of processes |
3212 | ; return number of processes |
3208 | 3213 | ||
3209 | mov eax, [TASK_COUNT] |
3214 | mov eax, [TASK_COUNT] |
3210 | mov [esp+32], eax |
3215 | mov [esp+32], eax |
3211 | ret |
3216 | ret |
3212 | 3217 | ||
3213 | align 4 |
3218 | align 4 |
3214 | sys_clock: |
3219 | sys_clock: |
3215 | cli |
3220 | cli |
3216 | ; Mikhail Lisovin xx Jan 2005 |
3221 | ; Mikhail Lisovin xx Jan 2005 |
3217 | @@: |
3222 | @@: |
3218 | mov al, 10 |
3223 | mov al, 10 |
3219 | out 0x70, al |
3224 | out 0x70, al |
3220 | in al, 0x71 |
3225 | in al, 0x71 |
3221 | test al, al |
3226 | test al, al |
3222 | jns @f |
3227 | jns @f |
3223 | mov esi, 1 |
3228 | mov esi, 1 |
3224 | call delay_ms |
3229 | call delay_ms |
3225 | jmp @b |
3230 | jmp @b |
3226 | @@: |
3231 | @@: |
3227 | ; end Lisovin's fix |
3232 | ; end Lisovin's fix |
3228 | 3233 | ||
3229 | xor al, al ; seconds |
3234 | xor al, al ; seconds |
3230 | out 0x70, al |
3235 | out 0x70, al |
3231 | in al, 0x71 |
3236 | in al, 0x71 |
3232 | movzx ecx, al |
3237 | movzx ecx, al |
3233 | mov al, 02 ; minutes |
3238 | mov al, 02 ; minutes |
3234 | shl ecx, 16 |
3239 | shl ecx, 16 |
3235 | out 0x70, al |
3240 | out 0x70, al |
3236 | in al, 0x71 |
3241 | in al, 0x71 |
3237 | movzx edx, al |
3242 | movzx edx, al |
3238 | mov al, 04 ; hours |
3243 | mov al, 04 ; hours |
3239 | shl edx, 8 |
3244 | shl edx, 8 |
3240 | out 0x70, al |
3245 | out 0x70, al |
3241 | in al, 0x71 |
3246 | in al, 0x71 |
3242 | add ecx, edx |
3247 | add ecx, edx |
3243 | movzx edx, al |
3248 | movzx edx, al |
3244 | add ecx, edx |
3249 | add ecx, edx |
3245 | sti |
3250 | sti |
3246 | mov [esp + 32], ecx |
3251 | mov [esp + 32], ecx |
3247 | ret |
3252 | ret |
3248 | 3253 | ||
3249 | 3254 | ||
3250 | align 4 |
3255 | align 4 |
3251 | 3256 | ||
3252 | sys_date: |
3257 | sys_date: |
3253 | 3258 | ||
3254 | cli |
3259 | cli |
3255 | @@: |
3260 | @@: |
3256 | mov al, 10 |
3261 | mov al, 10 |
3257 | out 0x70, al |
3262 | out 0x70, al |
3258 | in al, 0x71 |
3263 | in al, 0x71 |
3259 | test al, al |
3264 | test al, al |
3260 | jns @f |
3265 | jns @f |
3261 | mov esi, 1 |
3266 | mov esi, 1 |
3262 | call delay_ms |
3267 | call delay_ms |
3263 | jmp @b |
3268 | jmp @b |
3264 | @@: |
3269 | @@: |
3265 | 3270 | ||
3266 | mov ch, 0 |
3271 | mov ch, 0 |
3267 | mov al, 7 ; date |
3272 | mov al, 7 ; date |
3268 | out 0x70, al |
3273 | out 0x70, al |
3269 | in al, 0x71 |
3274 | in al, 0x71 |
3270 | mov cl, al |
3275 | mov cl, al |
3271 | mov al, 8 ; month |
3276 | mov al, 8 ; month |
3272 | shl ecx, 16 |
3277 | shl ecx, 16 |
3273 | out 0x70, al |
3278 | out 0x70, al |
3274 | in al, 0x71 |
3279 | in al, 0x71 |
3275 | mov ch, al |
3280 | mov ch, al |
3276 | mov al, 9 ; year |
3281 | mov al, 9 ; year |
3277 | out 0x70, al |
3282 | out 0x70, al |
3278 | in al, 0x71 |
3283 | in al, 0x71 |
3279 | mov cl, al |
3284 | mov cl, al |
3280 | sti |
3285 | sti |
3281 | mov [esp+32], ecx |
3286 | mov [esp+32], ecx |
3282 | ret |
3287 | ret |
3283 | 3288 | ||
3284 | 3289 | ||
3285 | ; redraw status |
3290 | ; redraw status |
3286 | 3291 | ||
3287 | sys_redrawstat: |
3292 | sys_redrawstat: |
3288 | cmp ebx, 1 |
3293 | cmp ebx, 1 |
3289 | jne no_widgets_away |
3294 | jne no_widgets_away |
3290 | ; buttons away |
3295 | ; buttons away |
3291 | mov ecx, [CURRENT_TASK] |
3296 | mov ecx, [CURRENT_TASK] |
3292 | sys_newba2: |
3297 | sys_newba2: |
3293 | mov edi, [BTN_ADDR] |
3298 | mov edi, [BTN_ADDR] |
3294 | cmp [edi], dword 0 ; empty button list ? |
3299 | cmp [edi], dword 0 ; empty button list ? |
3295 | je end_of_buttons_away |
3300 | je end_of_buttons_away |
3296 | movzx ebx, word [edi] |
3301 | movzx ebx, word [edi] |
3297 | inc ebx |
3302 | inc ebx |
3298 | mov eax, edi |
3303 | mov eax, edi |
3299 | sys_newba: |
3304 | sys_newba: |
3300 | dec ebx |
3305 | dec ebx |
3301 | jz end_of_buttons_away |
3306 | jz end_of_buttons_away |
3302 | 3307 | ||
3303 | add eax, 0x10 |
3308 | add eax, 0x10 |
3304 | cmp cx, [eax] |
3309 | cmp cx, [eax] |
3305 | jnz sys_newba |
3310 | jnz sys_newba |
3306 | 3311 | ||
3307 | push eax ebx ecx |
3312 | push eax ebx ecx |
3308 | mov ecx, ebx |
3313 | mov ecx, ebx |
3309 | inc ecx |
3314 | inc ecx |
3310 | shl ecx, 4 |
3315 | shl ecx, 4 |
3311 | mov ebx, eax |
3316 | mov ebx, eax |
3312 | add eax, 0x10 |
3317 | add eax, 0x10 |
3313 | call memmove |
3318 | call memmove |
3314 | dec dword [edi] |
3319 | dec dword [edi] |
3315 | pop ecx ebx eax |
3320 | pop ecx ebx eax |
3316 | 3321 | ||
3317 | jmp sys_newba2 |
3322 | jmp sys_newba2 |
3318 | 3323 | ||
3319 | end_of_buttons_away: |
3324 | end_of_buttons_away: |
3320 | 3325 | ||
3321 | ret |
3326 | ret |
3322 | 3327 | ||
3323 | no_widgets_away: |
3328 | no_widgets_away: |
3324 | 3329 | ||
3325 | cmp ebx, 2 |
3330 | cmp ebx, 2 |
3326 | jnz srl1 |
3331 | jnz srl1 |
3327 | 3332 | ||
3328 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3333 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3329 | add edx, draw_data - CURRENT_TASK |
3334 | add edx, draw_data - CURRENT_TASK |
3330 | mov [edx + RECT.left], 0 |
3335 | mov [edx + RECT.left], 0 |
3331 | mov [edx + RECT.top], 0 |
3336 | mov [edx + RECT.top], 0 |
3332 | mov eax, [_display.width] |
3337 | mov eax, [_display.width] |
3333 | dec eax |
3338 | dec eax |
3334 | mov [edx + RECT.right], eax |
3339 | mov [edx + RECT.right], eax |
3335 | mov eax, [_display.height] |
3340 | mov eax, [_display.height] |
3336 | dec eax |
3341 | dec eax |
3337 | mov [edx + RECT.bottom], eax |
3342 | mov [edx + RECT.bottom], eax |
3338 | 3343 | ||
3339 | srl1: |
3344 | srl1: |
3340 | ret |
3345 | ret |
3341 | 3346 | ||
3342 | ;ok - 100% work |
3347 | ;ok - 100% work |
3343 | ;nt - not tested |
3348 | ;nt - not tested |
3344 | ;--------------------------------------------------------------------------------------------- |
3349 | ;--------------------------------------------------------------------------------------------- |
3345 | ;eax |
3350 | ;eax |
3346 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3351 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3347 | ;1 - change task. Ret nothing. Block. ok. |
3352 | ;1 - change task. Ret nothing. Block. ok. |
3348 | ;2 - performance control |
3353 | ;2 - performance control |
3349 | ; ebx |
3354 | ; ebx |
3350 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3355 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3351 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3356 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3352 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3357 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3353 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3358 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3354 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3359 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3355 | ;eax |
3360 | ;eax |
3356 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3361 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3357 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3362 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3358 | ;--------------------------------------------------------------------------------------------- |
3363 | ;--------------------------------------------------------------------------------------------- |
3359 | iglobal |
3364 | iglobal |
3360 | align 4 |
3365 | align 4 |
3361 | sheduler: |
3366 | sheduler: |
3362 | dd sys_sheduler.00 |
3367 | dd sys_sheduler.00 |
3363 | dd change_task |
3368 | dd change_task |
3364 | dd sys_sheduler.02 |
3369 | dd sys_sheduler.02 |
3365 | dd sys_sheduler.03 |
3370 | dd sys_sheduler.03 |
3366 | dd sys_sheduler.04 |
3371 | dd sys_sheduler.04 |
3367 | endg |
3372 | endg |
3368 | sys_sheduler: |
3373 | sys_sheduler: |
3369 | ;rewritten by |
3374 | ;rewritten by |
3370 | jmp dword [sheduler+ebx*4] |
3375 | jmp dword [sheduler+ebx*4] |
3371 | ;.shed_counter: |
3376 | ;.shed_counter: |
3372 | .00: |
3377 | .00: |
3373 | mov eax, [context_counter] |
3378 | mov eax, [context_counter] |
3374 | mov [esp+32], eax |
3379 | mov [esp+32], eax |
3375 | ret |
3380 | ret |
3376 | 3381 | ||
3377 | .02: |
3382 | .02: |
3378 | ;.perf_control: |
3383 | ;.perf_control: |
3379 | inc ebx ;before ebx=2, ebx=3 |
3384 | inc ebx ;before ebx=2, ebx=3 |
3380 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3385 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3381 | jz cache_disable |
3386 | jz cache_disable |
3382 | 3387 | ||
3383 | dec ebx ;ebx=2 |
3388 | dec ebx ;ebx=2 |
3384 | cmp ebx, ecx ; |
3389 | cmp ebx, ecx ; |
3385 | jz cache_enable ;if ecx=2 and ebx=2 |
3390 | jz cache_enable ;if ecx=2 and ebx=2 |
3386 | 3391 | ||
3387 | dec ebx ;ebx=1 |
3392 | dec ebx ;ebx=1 |
3388 | cmp ebx, ecx |
3393 | cmp ebx, ecx |
3389 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3394 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3390 | 3395 | ||
3391 | dec ebx |
3396 | dec ebx |
3392 | test ebx, ecx ;ebx=0 and ecx=0 |
3397 | test ebx, ecx ;ebx=0 and ecx=0 |
3393 | jz modify_pce ;if ecx=0 |
3398 | jz modify_pce ;if ecx=0 |
3394 | 3399 | ||
3395 | ret |
3400 | ret |
3396 | 3401 | ||
3397 | .03: |
3402 | .03: |
3398 | ;.rdmsr_instr: |
3403 | ;.rdmsr_instr: |
3399 | ;now counter in ecx |
3404 | ;now counter in ecx |
3400 | ;(edx:eax) esi:edi => edx:esi |
3405 | ;(edx:eax) esi:edi => edx:esi |
3401 | mov eax, esi |
3406 | mov eax, esi |
3402 | mov ecx, edx |
3407 | mov ecx, edx |
3403 | rdmsr |
3408 | rdmsr |
3404 | mov [esp+32], eax |
3409 | mov [esp+32], eax |
3405 | mov [esp+20], edx ;ret in ebx? |
3410 | mov [esp+20], edx ;ret in ebx? |
3406 | ret |
3411 | ret |
3407 | 3412 | ||
3408 | .04: |
3413 | .04: |
3409 | ;.wrmsr_instr: |
3414 | ;.wrmsr_instr: |
3410 | ;now counter in ecx |
3415 | ;now counter in ecx |
3411 | ;(edx:eax) esi:edi => edx:esi |
3416 | ;(edx:eax) esi:edi => edx:esi |
3412 | ; Fast Call MSR can't be destroy |
3417 | ; Fast Call MSR can't be destroy |
3413 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3418 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3414 | ; включаются/выключаются расширенные возможности |
3419 | ; включаются/выключаются расширенные возможности |
3415 | cmp edx, MSR_SYSENTER_CS |
3420 | cmp edx, MSR_SYSENTER_CS |
3416 | je @f |
3421 | je @f |
3417 | cmp edx, MSR_SYSENTER_ESP |
3422 | cmp edx, MSR_SYSENTER_ESP |
3418 | je @f |
3423 | je @f |
3419 | cmp edx, MSR_SYSENTER_EIP |
3424 | cmp edx, MSR_SYSENTER_EIP |
3420 | je @f |
3425 | je @f |
3421 | cmp edx, MSR_AMD_STAR |
3426 | cmp edx, MSR_AMD_STAR |
3422 | je @f |
3427 | je @f |
3423 | 3428 | ||
3424 | mov eax, esi |
3429 | mov eax, esi |
3425 | mov ecx, edx |
3430 | mov ecx, edx |
3426 | wrmsr |
3431 | wrmsr |
3427 | ; mov [esp + 32], eax |
3432 | ; mov [esp + 32], eax |
3428 | ; mov [esp + 20], edx ;ret in ebx? |
3433 | ; mov [esp + 20], edx ;ret in ebx? |
3429 | @@: |
3434 | @@: |
3430 | ret |
3435 | ret |
3431 | 3436 | ||
3432 | cache_disable: |
3437 | cache_disable: |
3433 | mov eax, cr0 |
3438 | mov eax, cr0 |
3434 | or eax, 01100000000000000000000000000000b |
3439 | or eax, 01100000000000000000000000000000b |
3435 | mov cr0, eax |
3440 | mov cr0, eax |
3436 | wbinvd ;set MESI |
3441 | wbinvd ;set MESI |
3437 | ret |
3442 | ret |
3438 | 3443 | ||
3439 | cache_enable: |
3444 | cache_enable: |
3440 | mov eax, cr0 |
3445 | mov eax, cr0 |
3441 | and eax, 10011111111111111111111111111111b |
3446 | and eax, 10011111111111111111111111111111b |
3442 | mov cr0, eax |
3447 | mov cr0, eax |
3443 | ret |
3448 | ret |
3444 | 3449 | ||
3445 | is_cache_enabled: |
3450 | is_cache_enabled: |
3446 | mov eax, cr0 |
3451 | mov eax, cr0 |
3447 | mov ebx, eax |
3452 | mov ebx, eax |
3448 | and eax, 01100000000000000000000000000000b |
3453 | and eax, 01100000000000000000000000000000b |
3449 | jz cache_disabled |
3454 | jz cache_disabled |
3450 | mov [esp+32], ebx |
3455 | mov [esp+32], ebx |
3451 | cache_disabled: |
3456 | cache_disabled: |
3452 | mov dword [esp+32], eax;0 |
3457 | mov dword [esp+32], eax;0 |
3453 | ret |
3458 | ret |
3454 | 3459 | ||
3455 | modify_pce: |
3460 | modify_pce: |
3456 | mov eax, cr4 |
3461 | mov eax, cr4 |
3457 | ; mov ebx,0 |
3462 | ; mov ebx,0 |
3458 | ; or bx,100000000b ;pce |
3463 | ; or bx,100000000b ;pce |
3459 | ; xor eax,ebx ;invert pce |
3464 | ; xor eax,ebx ;invert pce |
3460 | bts eax, 8;pce=cr4[8] |
3465 | bts eax, 8;pce=cr4[8] |
3461 | mov cr4, eax |
3466 | mov cr4, eax |
3462 | mov [esp+32], eax |
3467 | mov [esp+32], eax |
3463 | ret |
3468 | ret |
3464 | ;--------------------------------------------------------------------------------------------- |
3469 | ;--------------------------------------------------------------------------------------------- |
3465 | 3470 | ||
3466 | 3471 | ||
3467 | iglobal |
3472 | iglobal |
3468 | cpustring db 'CPU',0 |
3473 | cpustring db 'CPU',0 |
3469 | endg |
3474 | endg |
3470 | 3475 | ||
3471 | uglobal |
3476 | uglobal |
3472 | background_defined db 0 ; diamond, 11.04.2006 |
3477 | background_defined db 0 ; diamond, 11.04.2006 |
3473 | endg |
3478 | endg |
3474 | ;----------------------------------------------------------------------------- |
3479 | ;----------------------------------------------------------------------------- |
3475 | align 4 |
3480 | align 4 |
3476 | checkmisc: |
3481 | checkmisc: |
3477 | cmp [ctrl_alt_del], 1 |
3482 | cmp [ctrl_alt_del], 1 |
3478 | jne nocpustart |
3483 | jne nocpustart |
3479 | 3484 | ||
3480 | mov ebp, cpustring |
3485 | mov ebp, cpustring |
3481 | call fs_execute_from_sysdir |
3486 | call fs_execute_from_sysdir |
3482 | 3487 | ||
3483 | mov [ctrl_alt_del], 0 |
3488 | mov [ctrl_alt_del], 0 |
3484 | ;-------------------------------------- |
3489 | ;-------------------------------------- |
3485 | align 4 |
3490 | align 4 |
3486 | nocpustart: |
3491 | nocpustart: |
3487 | cmp [mouse_active], 1 |
3492 | cmp [mouse_active], 1 |
3488 | jne mouse_not_active |
3493 | jne mouse_not_active |
3489 | mov [mouse_active], 0 |
3494 | mov [mouse_active], 0 |
3490 | 3495 | ||
3491 | xor edi, edi |
3496 | xor edi, edi |
3492 | mov ebx, CURRENT_TASK |
3497 | mov ebx, CURRENT_TASK |
3493 | 3498 | ||
3494 | mov ecx, [TASK_COUNT] |
3499 | mov ecx, [TASK_COUNT] |
3495 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3500 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3496 | shl eax, 8 |
3501 | shl eax, 8 |
3497 | push eax |
3502 | push eax |
3498 | 3503 | ||
3499 | movzx eax, word [MOUSE_X] |
3504 | movzx eax, word [MOUSE_X] |
3500 | movzx edx, word [MOUSE_Y] |
3505 | movzx edx, word [MOUSE_Y] |
3501 | ;-------------------------------------- |
3506 | ;-------------------------------------- |
3502 | align 4 |
3507 | align 4 |
3503 | .set_mouse_event: |
3508 | .set_mouse_event: |
3504 | add edi, 256 |
3509 | add edi, 256 |
3505 | add ebx, 32 |
3510 | add ebx, 32 |
3506 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3511 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3507 | jz .pos_filter |
3512 | jz .pos_filter |
3508 | 3513 | ||
3509 | cmp edi, [esp] ; skip if filtration active |
3514 | cmp edi, [esp] ; skip if filtration active |
3510 | jne .skip |
3515 | jne .skip |
3511 | ;-------------------------------------- |
3516 | ;-------------------------------------- |
3512 | align 4 |
3517 | align 4 |
3513 | .pos_filter: |
3518 | .pos_filter: |
3514 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3519 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3515 | jz .set |
3520 | jz .set |
3516 | 3521 | ||
3517 | mov esi, [ebx-twdw+WDATA.box.left] |
3522 | mov esi, [ebx-twdw+WDATA.box.left] |
3518 | cmp eax, esi |
3523 | cmp eax, esi |
3519 | jb .skip |
3524 | jb .skip |
3520 | add esi, [ebx-twdw+WDATA.box.width] |
3525 | add esi, [ebx-twdw+WDATA.box.width] |
3521 | cmp eax, esi |
3526 | cmp eax, esi |
3522 | ja .skip |
3527 | ja .skip |
3523 | 3528 | ||
3524 | mov esi, [ebx-twdw+WDATA.box.top] |
3529 | mov esi, [ebx-twdw+WDATA.box.top] |
3525 | cmp edx, esi |
3530 | cmp edx, esi |
3526 | jb .skip |
3531 | jb .skip |
3527 | add esi, [ebx-twdw+WDATA.box.height] |
3532 | add esi, [ebx-twdw+WDATA.box.height] |
3528 | cmp edx, esi |
3533 | cmp edx, esi |
3529 | ja .skip |
3534 | ja .skip |
3530 | ;-------------------------------------- |
3535 | ;-------------------------------------- |
3531 | align 4 |
3536 | align 4 |
3532 | .set: |
3537 | .set: |
3533 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3538 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3534 | ;-------------------------------------- |
3539 | ;-------------------------------------- |
3535 | align 4 |
3540 | align 4 |
3536 | .skip: |
3541 | .skip: |
3537 | loop .set_mouse_event |
3542 | loop .set_mouse_event |
3538 | 3543 | ||
3539 | pop eax |
3544 | pop eax |
3540 | ;-------------------------------------- |
3545 | ;-------------------------------------- |
3541 | align 4 |
3546 | align 4 |
3542 | mouse_not_active: |
3547 | mouse_not_active: |
3543 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
3548 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
3544 | jz nobackgr |
3549 | jz nobackgr |
3545 | 3550 | ||
3546 | cmp [background_defined], 0 |
3551 | cmp [background_defined], 0 |
3547 | jz nobackgr |
3552 | jz nobackgr |
3548 | ;-------------------------------------- |
3553 | ;-------------------------------------- |
3549 | align 4 |
3554 | align 4 |
3550 | backgr: |
3555 | backgr: |
3551 | mov eax, [draw_data+32 + RECT.left] |
3556 | mov eax, [draw_data+32 + RECT.left] |
3552 | shl eax, 16 |
3557 | shl eax, 16 |
3553 | add eax, [draw_data+32 + RECT.right] |
3558 | add eax, [draw_data+32 + RECT.right] |
3554 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3559 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3555 | 3560 | ||
3556 | mov eax, [draw_data+32 + RECT.top] |
3561 | mov eax, [draw_data+32 + RECT.top] |
3557 | shl eax, 16 |
3562 | shl eax, 16 |
3558 | add eax, [draw_data+32 + RECT.bottom] |
3563 | add eax, [draw_data+32 + RECT.bottom] |
3559 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3564 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3560 | 3565 | ||
3561 | call drawbackground |
3566 | call drawbackground |
3562 | ; DEBUGF 1, "K : drawbackground\n" |
3567 | ; DEBUGF 1, "K : drawbackground\n" |
3563 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3568 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3564 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3569 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3565 | ;--------- set event 5 start ---------- |
3570 | ;--------- set event 5 start ---------- |
3566 | push ecx edi |
3571 | push ecx edi |
3567 | xor edi, edi |
3572 | xor edi, edi |
3568 | mov ecx, [TASK_COUNT] |
3573 | mov ecx, [TASK_COUNT] |
3569 | ;-------------------------------------- |
3574 | ;-------------------------------------- |
3570 | align 4 |
3575 | align 4 |
3571 | set_bgr_event: |
3576 | set_bgr_event: |
3572 | add edi, 256 |
3577 | add edi, 256 |
3573 | mov eax, [BG_Rect_X_left_right] |
3578 | mov eax, [BG_Rect_X_left_right] |
3574 | mov edx, [BG_Rect_Y_top_bottom] |
3579 | mov edx, [BG_Rect_Y_top_bottom] |
3575 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3580 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3576 | jz .set |
3581 | jz .set |
3577 | .join: |
3582 | .join: |
3578 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3583 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3579 | jae @f |
3584 | jae @f |
3580 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3585 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3581 | @@: |
3586 | @@: |
3582 | shr eax, 16 |
3587 | shr eax, 16 |
3583 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3588 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3584 | jbe @f |
3589 | jbe @f |
3585 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3590 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3586 | @@: |
3591 | @@: |
3587 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3592 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3588 | jae @f |
3593 | jae @f |
3589 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3594 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3590 | @@: |
3595 | @@: |
3591 | shr edx, 16 |
3596 | shr edx, 16 |
3592 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3597 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3593 | jbe @f |
3598 | jbe @f |
3594 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3599 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3595 | @@: |
3600 | @@: |
3596 | jmp .common |
3601 | jmp .common |
3597 | .set: |
3602 | .set: |
3598 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3603 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3599 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3604 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3600 | .common: |
3605 | .common: |
3601 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3606 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3602 | loop set_bgr_event |
3607 | loop set_bgr_event |
3603 | pop edi ecx |
3608 | pop edi ecx |
3604 | ;--------- set event 5 stop ----------- |
3609 | ;--------- set event 5 stop ----------- |
3605 | dec [REDRAW_BACKGROUND] ; got new update request? |
3610 | dec [REDRAW_BACKGROUND] ; got new update request? |
3606 | jnz backgr |
3611 | jnz backgr |
3607 | 3612 | ||
3608 | xor eax, eax |
3613 | xor eax, eax |
3609 | mov [draw_data+32 + RECT.left], eax |
3614 | mov [draw_data+32 + RECT.left], eax |
3610 | mov [draw_data+32 + RECT.top], eax |
3615 | mov [draw_data+32 + RECT.top], eax |
3611 | mov [draw_data+32 + RECT.right], eax |
3616 | mov [draw_data+32 + RECT.right], eax |
3612 | mov [draw_data+32 + RECT.bottom], eax |
3617 | mov [draw_data+32 + RECT.bottom], eax |
3613 | ;-------------------------------------- |
3618 | ;-------------------------------------- |
3614 | align 4 |
3619 | align 4 |
3615 | nobackgr: |
3620 | nobackgr: |
3616 | ; system shutdown request |
3621 | ; system shutdown request |
3617 | cmp [SYS_SHUTDOWN], byte 0 |
3622 | cmp [SYS_SHUTDOWN], byte 0 |
3618 | je noshutdown |
3623 | je noshutdown |
3619 | 3624 | ||
3620 | mov edx, [shutdown_processes] |
3625 | mov edx, [shutdown_processes] |
3621 | 3626 | ||
3622 | cmp [SYS_SHUTDOWN], dl |
3627 | cmp [SYS_SHUTDOWN], dl |
3623 | jne noshutdown |
3628 | jne noshutdown |
3624 | 3629 | ||
3625 | lea ecx, [edx-1] |
3630 | lea ecx, [edx-1] |
3626 | mov edx, OS_BASE+0x3040 |
3631 | mov edx, OS_BASE+0x3040 |
3627 | jecxz no_mark_system_shutdown |
3632 | jecxz no_mark_system_shutdown |
3628 | ;-------------------------------------- |
3633 | ;-------------------------------------- |
3629 | align 4 |
3634 | align 4 |
3630 | markz: |
3635 | markz: |
3631 | push ecx edx |
3636 | push ecx edx |
3632 | cmp [edx+TASKDATA.state], TSTATE_FREE |
3637 | cmp [edx+TASKDATA.state], TSTATE_FREE |
3633 | jz .nokill |
3638 | jz .nokill |
3634 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3639 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3635 | cmp [edx+APPDATA.process], sys_proc |
3640 | cmp [edx+APPDATA.process], sys_proc |
3636 | jz .nokill |
3641 | jz .nokill |
3637 | call request_terminate |
3642 | call request_terminate |
3638 | jmp .common |
3643 | jmp .common |
3639 | .nokill: |
3644 | .nokill: |
3640 | dec byte [SYS_SHUTDOWN] |
3645 | dec byte [SYS_SHUTDOWN] |
3641 | xor eax, eax |
3646 | xor eax, eax |
3642 | .common: |
3647 | .common: |
3643 | pop edx ecx |
3648 | pop edx ecx |
3644 | test eax, eax |
3649 | test eax, eax |
3645 | jz @f |
3650 | jz @f |
3646 | mov [edx+TASKDATA.state], TSTATE_ZOMBIE |
3651 | mov [edx+TASKDATA.state], TSTATE_ZOMBIE |
3647 | @@: |
3652 | @@: |
3648 | add edx, 0x20 |
3653 | add edx, 0x20 |
3649 | loop markz |
3654 | loop markz |
3650 | call wakeup_osloop |
3655 | call wakeup_osloop |
3651 | ;-------------------------------------- |
3656 | ;-------------------------------------- |
3652 | align 4 |
3657 | align 4 |
3653 | @@: |
3658 | @@: |
3654 | no_mark_system_shutdown: |
3659 | no_mark_system_shutdown: |
3655 | dec byte [SYS_SHUTDOWN] |
3660 | dec byte [SYS_SHUTDOWN] |
3656 | je system_shutdown |
3661 | je system_shutdown |
3657 | ;-------------------------------------- |
3662 | ;-------------------------------------- |
3658 | align 4 |
3663 | align 4 |
3659 | noshutdown: |
3664 | noshutdown: |
3660 | mov eax, [TASK_COUNT] ; termination |
3665 | mov eax, [TASK_COUNT] ; termination |
3661 | mov ebx, TASK_DATA+TASKDATA.state |
3666 | mov ebx, TASK_DATA+TASKDATA.state |
3662 | mov esi, 1 |
3667 | mov esi, 1 |
3663 | ;-------------------------------------- |
3668 | ;-------------------------------------- |
3664 | align 4 |
3669 | align 4 |
3665 | newct: |
3670 | newct: |
3666 | mov cl, [ebx] |
3671 | mov cl, [ebx] |
3667 | cmp cl, byte 3 |
3672 | cmp cl, byte 3 |
3668 | jz .terminate |
3673 | jz .terminate |
3669 | 3674 | ||
3670 | cmp cl, byte 4 |
3675 | cmp cl, byte 4 |
3671 | jnz .noterminate |
3676 | jnz .noterminate |
3672 | .terminate: |
3677 | .terminate: |
3673 | pushad |
3678 | pushad |
3674 | mov ecx, eax |
3679 | mov ecx, eax |
3675 | shl ecx, 8 |
3680 | shl ecx, 8 |
3676 | add ecx, SLOT_BASE |
3681 | add ecx, SLOT_BASE |
3677 | call restore_default_cursor_before_killing |
3682 | call restore_default_cursor_before_killing |
3678 | popad |
3683 | popad |
3679 | 3684 | ||
3680 | pushad |
3685 | pushad |
3681 | call terminate |
3686 | call terminate |
3682 | popad |
3687 | popad |
3683 | cmp byte [SYS_SHUTDOWN], 0 |
3688 | cmp byte [SYS_SHUTDOWN], 0 |
3684 | jz .noterminate |
3689 | jz .noterminate |
3685 | dec byte [SYS_SHUTDOWN] |
3690 | dec byte [SYS_SHUTDOWN] |
3686 | je system_shutdown |
3691 | je system_shutdown |
3687 | 3692 | ||
3688 | .noterminate: |
3693 | .noterminate: |
3689 | add ebx, 0x20 |
3694 | add ebx, 0x20 |
3690 | inc esi |
3695 | inc esi |
3691 | dec eax |
3696 | dec eax |
3692 | jnz newct |
3697 | jnz newct |
3693 | ret |
3698 | ret |
3694 | ;----------------------------------------------------------------------------- |
3699 | ;----------------------------------------------------------------------------- |
3695 | align 4 |
3700 | align 4 |
3696 | redrawscreen: |
3701 | redrawscreen: |
3697 | ; eax , if process window_data base is eax, do not set flag/limits |
3702 | ; eax , if process window_data base is eax, do not set flag/limits |
3698 | 3703 | ||
3699 | pushad |
3704 | pushad |
3700 | push eax |
3705 | push eax |
3701 | 3706 | ||
3702 | ;;; mov ebx,2 |
3707 | ;;; mov ebx,2 |
3703 | ;;; call delay_hs |
3708 | ;;; call delay_hs |
3704 | 3709 | ||
3705 | ;mov ecx,0 ; redraw flags for apps |
3710 | ;mov ecx,0 ; redraw flags for apps |
3706 | xor ecx, ecx |
3711 | xor ecx, ecx |
3707 | ;-------------------------------------- |
3712 | ;-------------------------------------- |
3708 | align 4 |
3713 | align 4 |
3709 | newdw2: |
3714 | newdw2: |
3710 | inc ecx |
3715 | inc ecx |
3711 | push ecx |
3716 | push ecx |
3712 | 3717 | ||
3713 | mov eax, ecx |
3718 | mov eax, ecx |
3714 | shl eax, 5 |
3719 | shl eax, 5 |
3715 | add eax, window_data |
3720 | add eax, window_data |
3716 | 3721 | ||
3717 | cmp eax, [esp+4] |
3722 | cmp eax, [esp+4] |
3718 | je not_this_task |
3723 | je not_this_task |
3719 | ; check if window in redraw area |
3724 | ; check if window in redraw area |
3720 | mov edi, eax |
3725 | mov edi, eax |
3721 | 3726 | ||
3722 | cmp ecx, 1 ; limit for background |
3727 | cmp ecx, 1 ; limit for background |
3723 | jz bgli |
3728 | jz bgli |
3724 | 3729 | ||
3725 | mov eax, [esp+4] ;if upper in z-position - no redraw |
3730 | mov eax, [esp+4] ;if upper in z-position - no redraw |
3726 | test eax, eax |
3731 | test eax, eax |
3727 | jz @f |
3732 | jz @f |
3728 | mov al, [eax + WDATA.z_modif] |
3733 | mov al, [eax + WDATA.z_modif] |
3729 | cmp [edi + WDATA.z_modif], al |
3734 | cmp [edi + WDATA.z_modif], al |
3730 | jg ricino |
3735 | jg ricino |
3731 | @@: |
3736 | @@: |
3732 | 3737 | ||
3733 | mov eax, [edi + WDATA.box.left] |
3738 | mov eax, [edi + WDATA.box.left] |
3734 | mov ebx, [edi + WDATA.box.top] |
3739 | mov ebx, [edi + WDATA.box.top] |
3735 | 3740 | ||
3736 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3741 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3737 | cmp ecx, ebx |
3742 | cmp ecx, ebx |
3738 | jb ricino |
3743 | jb ricino |
3739 | 3744 | ||
3740 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3745 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3741 | cmp ecx, eax |
3746 | cmp ecx, eax |
3742 | jb ricino |
3747 | jb ricino |
3743 | 3748 | ||
3744 | mov eax, [edi + WDATA.box.left] |
3749 | mov eax, [edi + WDATA.box.left] |
3745 | mov ebx, [edi + WDATA.box.top] |
3750 | mov ebx, [edi + WDATA.box.top] |
3746 | mov ecx, [edi + WDATA.box.width] |
3751 | mov ecx, [edi + WDATA.box.width] |
3747 | mov edx, [edi + WDATA.box.height] |
3752 | mov edx, [edi + WDATA.box.height] |
3748 | add ecx, eax |
3753 | add ecx, eax |
3749 | add edx, ebx |
3754 | add edx, ebx |
3750 | 3755 | ||
3751 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3756 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3752 | cmp edx, eax |
3757 | cmp edx, eax |
3753 | jb ricino |
3758 | jb ricino |
3754 | 3759 | ||
3755 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3760 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3756 | cmp ecx, eax |
3761 | cmp ecx, eax |
3757 | jb ricino |
3762 | jb ricino |
3758 | ;-------------------------------------- |
3763 | ;-------------------------------------- |
3759 | align 4 |
3764 | align 4 |
3760 | bgli: |
3765 | bgli: |
3761 | cmp dword[esp], 1 |
3766 | cmp dword[esp], 1 |
3762 | jnz .az |
3767 | jnz .az |
3763 | 3768 | ||
3764 | cmp [REDRAW_BACKGROUND], 0 |
3769 | cmp [REDRAW_BACKGROUND], 0 |
3765 | jz .az |
3770 | jz .az |
3766 | 3771 | ||
3767 | mov dl, 0 |
3772 | mov dl, 0 |
3768 | lea eax, [edi+draw_data-window_data] |
3773 | lea eax, [edi+draw_data-window_data] |
3769 | mov ebx, [draw_limits.left] |
3774 | mov ebx, [draw_limits.left] |
3770 | cmp ebx, [eax+RECT.left] |
3775 | cmp ebx, [eax+RECT.left] |
3771 | jae @f |
3776 | jae @f |
3772 | 3777 | ||
3773 | mov [eax+RECT.left], ebx |
3778 | mov [eax+RECT.left], ebx |
3774 | mov dl, 1 |
3779 | mov dl, 1 |
3775 | ;-------------------------------------- |
3780 | ;-------------------------------------- |
3776 | align 4 |
3781 | align 4 |
3777 | @@: |
3782 | @@: |
3778 | mov ebx, [draw_limits.top] |
3783 | mov ebx, [draw_limits.top] |
3779 | cmp ebx, [eax+RECT.top] |
3784 | cmp ebx, [eax+RECT.top] |
3780 | jae @f |
3785 | jae @f |
3781 | 3786 | ||
3782 | mov [eax+RECT.top], ebx |
3787 | mov [eax+RECT.top], ebx |
3783 | mov dl, 1 |
3788 | mov dl, 1 |
3784 | ;-------------------------------------- |
3789 | ;-------------------------------------- |
3785 | align 4 |
3790 | align 4 |
3786 | @@: |
3791 | @@: |
3787 | mov ebx, [draw_limits.right] |
3792 | mov ebx, [draw_limits.right] |
3788 | cmp ebx, [eax+RECT.right] |
3793 | cmp ebx, [eax+RECT.right] |
3789 | jbe @f |
3794 | jbe @f |
3790 | 3795 | ||
3791 | mov [eax+RECT.right], ebx |
3796 | mov [eax+RECT.right], ebx |
3792 | mov dl, 1 |
3797 | mov dl, 1 |
3793 | ;-------------------------------------- |
3798 | ;-------------------------------------- |
3794 | align 4 |
3799 | align 4 |
3795 | @@: |
3800 | @@: |
3796 | mov ebx, [draw_limits.bottom] |
3801 | mov ebx, [draw_limits.bottom] |
3797 | cmp ebx, [eax+RECT.bottom] |
3802 | cmp ebx, [eax+RECT.bottom] |
3798 | jbe @f |
3803 | jbe @f |
3799 | 3804 | ||
3800 | mov [eax+RECT.bottom], ebx |
3805 | mov [eax+RECT.bottom], ebx |
3801 | mov dl, 1 |
3806 | mov dl, 1 |
3802 | ;-------------------------------------- |
3807 | ;-------------------------------------- |
3803 | align 4 |
3808 | align 4 |
3804 | @@: |
3809 | @@: |
3805 | add [REDRAW_BACKGROUND], dl |
3810 | add [REDRAW_BACKGROUND], dl |
3806 | call wakeup_osloop |
3811 | call wakeup_osloop |
3807 | jmp newdw8 |
3812 | jmp newdw8 |
3808 | ;-------------------------------------- |
3813 | ;-------------------------------------- |
3809 | align 4 |
3814 | align 4 |
3810 | .az: |
3815 | .az: |
3811 | mov eax, edi |
3816 | mov eax, edi |
3812 | add eax, draw_data-window_data |
3817 | add eax, draw_data-window_data |
3813 | 3818 | ||
3814 | mov ebx, [draw_limits.left] ; set limits |
3819 | mov ebx, [draw_limits.left] ; set limits |
3815 | mov [eax + RECT.left], ebx |
3820 | mov [eax + RECT.left], ebx |
3816 | mov ebx, [draw_limits.top] |
3821 | mov ebx, [draw_limits.top] |
3817 | mov [eax + RECT.top], ebx |
3822 | mov [eax + RECT.top], ebx |
3818 | mov ebx, [draw_limits.right] |
3823 | mov ebx, [draw_limits.right] |
3819 | mov [eax + RECT.right], ebx |
3824 | mov [eax + RECT.right], ebx |
3820 | mov ebx, [draw_limits.bottom] |
3825 | mov ebx, [draw_limits.bottom] |
3821 | mov [eax + RECT.bottom], ebx |
3826 | mov [eax + RECT.bottom], ebx |
3822 | 3827 | ||
3823 | sub eax, draw_data-window_data |
3828 | sub eax, draw_data-window_data |
3824 | 3829 | ||
3825 | cmp dword [esp], 1 |
3830 | cmp dword [esp], 1 |
3826 | jne nobgrd |
3831 | jne nobgrd |
3827 | inc [REDRAW_BACKGROUND] |
3832 | inc [REDRAW_BACKGROUND] |
3828 | call wakeup_osloop |
3833 | call wakeup_osloop |
3829 | ;-------------------------------------- |
3834 | ;-------------------------------------- |
3830 | align 4 |
3835 | align 4 |
3831 | newdw8: |
3836 | newdw8: |
3832 | nobgrd: |
3837 | nobgrd: |
3833 | ;-------------------------------------- |
3838 | ;-------------------------------------- |
3834 | push eax edi ebp |
3839 | push eax edi ebp |
3835 | mov edi, [esp+12] |
3840 | mov edi, [esp+12] |
3836 | cmp edi, 1 |
3841 | cmp edi, 1 |
3837 | je .found |
3842 | je .found |
3838 | 3843 | ||
3839 | mov eax, [draw_limits.left] |
3844 | mov eax, [draw_limits.left] |
3840 | mov ebx, [draw_limits.top] |
3845 | mov ebx, [draw_limits.top] |
3841 | mov ecx, [draw_limits.right] |
3846 | mov ecx, [draw_limits.right] |
3842 | sub ecx, eax |
3847 | sub ecx, eax |
3843 | test ecx, ecx |
3848 | test ecx, ecx |
3844 | jz .not_found |
3849 | jz .not_found |
3845 | 3850 | ||
3846 | mov edx, [draw_limits.bottom] |
3851 | mov edx, [draw_limits.bottom] |
3847 | sub edx, ebx |
3852 | sub edx, ebx |
3848 | test edx, edx |
3853 | test edx, edx |
3849 | jz .not_found |
3854 | jz .not_found |
3850 | 3855 | ||
3851 | ; eax - x, ebx - y |
3856 | ; eax - x, ebx - y |
3852 | ; ecx - size x, edx - size y |
3857 | ; ecx - size x, edx - size y |
3853 | add ebx, edx |
3858 | add ebx, edx |
3854 | ;-------------------------------------- |
3859 | ;-------------------------------------- |
3855 | align 4 |
3860 | align 4 |
3856 | .start_y: |
3861 | .start_y: |
3857 | push ecx |
3862 | push ecx |
3858 | ;-------------------------------------- |
3863 | ;-------------------------------------- |
3859 | align 4 |
3864 | align 4 |
3860 | .start_x: |
3865 | .start_x: |
3861 | add eax, ecx |
3866 | add eax, ecx |
3862 | mov ebp, [d_width_calc_area + ebx*4] |
3867 | mov ebp, [d_width_calc_area + ebx*4] |
3863 | add ebp, [_display.win_map] |
3868 | add ebp, [_display.win_map] |
3864 | movzx ebp, byte[eax+ebp] ; get value for current point |
3869 | movzx ebp, byte[eax+ebp] ; get value for current point |
3865 | cmp ebp, edi |
3870 | cmp ebp, edi |
3866 | jne @f |
3871 | jne @f |
3867 | 3872 | ||
3868 | pop ecx |
3873 | pop ecx |
3869 | jmp .found |
3874 | jmp .found |
3870 | ;-------------------------------------- |
3875 | ;-------------------------------------- |
3871 | align 4 |
3876 | align 4 |
3872 | @@: |
3877 | @@: |
3873 | sub eax, ecx |
3878 | sub eax, ecx |
3874 | 3879 | ||
3875 | dec ecx |
3880 | dec ecx |
3876 | jnz .start_x |
3881 | jnz .start_x |
3877 | 3882 | ||
3878 | pop ecx |
3883 | pop ecx |
3879 | dec ebx |
3884 | dec ebx |
3880 | dec edx |
3885 | dec edx |
3881 | jnz .start_y |
3886 | jnz .start_y |
3882 | ;-------------------------------------- |
3887 | ;-------------------------------------- |
3883 | align 4 |
3888 | align 4 |
3884 | .not_found: |
3889 | .not_found: |
3885 | pop ebp edi eax |
3890 | pop ebp edi eax |
3886 | jmp ricino |
3891 | jmp ricino |
3887 | ;-------------------------------------- |
3892 | ;-------------------------------------- |
3888 | align 4 |
3893 | align 4 |
3889 | .found: |
3894 | .found: |
3890 | pop ebp edi eax |
3895 | pop ebp edi eax |
3891 | 3896 | ||
3892 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3897 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3893 | ;-------------------------------------- |
3898 | ;-------------------------------------- |
3894 | align 4 |
3899 | align 4 |
3895 | ricino: |
3900 | ricino: |
3896 | not_this_task: |
3901 | not_this_task: |
3897 | pop ecx |
3902 | pop ecx |
3898 | 3903 | ||
3899 | cmp ecx, [TASK_COUNT] |
3904 | cmp ecx, [TASK_COUNT] |
3900 | jle newdw2 |
3905 | jle newdw2 |
3901 | 3906 | ||
3902 | pop eax |
3907 | pop eax |
3903 | popad |
3908 | popad |
3904 | ret |
3909 | ret |
3905 | ;----------------------------------------------------------------------------- |
3910 | ;----------------------------------------------------------------------------- |
3906 | align 4 |
3911 | align 4 |
3907 | calculatebackground: ; background |
3912 | calculatebackground: ; background |
3908 | mov edi, [_display.win_map] ; set os to use all pixels |
3913 | mov edi, [_display.win_map] ; set os to use all pixels |
3909 | mov eax, 0x01010101 |
3914 | mov eax, 0x01010101 |
3910 | mov ecx, [_display.win_map_size] |
3915 | mov ecx, [_display.win_map_size] |
3911 | shr ecx, 2 |
3916 | shr ecx, 2 |
3912 | rep stosd |
3917 | rep stosd |
3913 | mov byte[window_data+32+WDATA.z_modif], ZPOS_DESKTOP |
3918 | mov byte[window_data+32+WDATA.z_modif], ZPOS_DESKTOP |
3914 | mov [REDRAW_BACKGROUND], 0 |
3919 | mov [REDRAW_BACKGROUND], 0 |
3915 | ret |
3920 | ret |
3916 | ;----------------------------------------------------------------------------- |
3921 | ;----------------------------------------------------------------------------- |
3917 | uglobal |
3922 | uglobal |
3918 | imax dd 0x0 |
3923 | imax dd 0x0 |
3919 | endg |
3924 | endg |
3920 | ;----------------------------------------------------------------------------- |
3925 | ;----------------------------------------------------------------------------- |
3921 | align 4 |
3926 | align 4 |
3922 | delay_ms: ; delay in 1/1000 sec |
3927 | delay_ms: ; delay in 1/1000 sec |
3923 | push eax |
3928 | push eax |
3924 | push ecx |
3929 | push ecx |
3925 | 3930 | ||
3926 | mov ecx, esi |
3931 | mov ecx, esi |
3927 | ; |
3932 | ; |
3928 | imul ecx, 33941 |
3933 | imul ecx, 33941 |
3929 | shr ecx, 9 |
3934 | shr ecx, 9 |
3930 | ; |
3935 | ; |
3931 | 3936 | ||
3932 | in al, 0x61 |
3937 | in al, 0x61 |
3933 | and al, 0x10 |
3938 | and al, 0x10 |
3934 | mov ah, al |
3939 | mov ah, al |
3935 | cld |
3940 | cld |
3936 | ;-------------------------------------- |
3941 | ;-------------------------------------- |
3937 | align 4 |
3942 | align 4 |
3938 | cnt1: |
3943 | cnt1: |
3939 | in al, 0x61 |
3944 | in al, 0x61 |
3940 | and al, 0x10 |
3945 | and al, 0x10 |
3941 | cmp al, ah |
3946 | cmp al, ah |
3942 | jz cnt1 |
3947 | jz cnt1 |
3943 | 3948 | ||
3944 | mov ah, al |
3949 | mov ah, al |
3945 | loop cnt1 |
3950 | loop cnt1 |
3946 | 3951 | ||
3947 | pop ecx |
3952 | pop ecx |
3948 | pop eax |
3953 | pop eax |
3949 | ret |
3954 | ret |
3950 | ;----------------------------------------------------------------------------- |
3955 | ;----------------------------------------------------------------------------- |
3951 | align 4 |
3956 | align 4 |
3952 | set_app_param: |
3957 | set_app_param: |
3953 | mov edi, [TASK_BASE] |
3958 | mov edi, [TASK_BASE] |
3954 | mov eax, ebx |
3959 | mov eax, ebx |
3955 | btr eax, 3 ; move MOUSE_FILTRATION |
3960 | btr eax, 3 ; move MOUSE_FILTRATION |
3956 | mov ebx, [current_slot] ; bit into event_filter |
3961 | mov ebx, [current_slot] ; bit into event_filter |
3957 | setc byte [ebx+APPDATA.event_filter] |
3962 | setc byte [ebx+APPDATA.event_filter] |
3958 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3963 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3959 | mov [esp+32], eax ; return old mask value |
3964 | mov [esp+32], eax ; return old mask value |
3960 | ret |
3965 | ret |
3961 | ;----------------------------------------------------------------------------- |
3966 | ;----------------------------------------------------------------------------- |
3962 | 3967 | ||
3963 | ; this is for syscall |
3968 | ; this is for syscall |
3964 | proc delay_hs_unprotected |
3969 | proc delay_hs_unprotected |
3965 | call unprotect_from_terminate |
3970 | call unprotect_from_terminate |
3966 | call delay_hs |
3971 | call delay_hs |
3967 | call protect_from_terminate |
3972 | call protect_from_terminate |
3968 | ret |
3973 | ret |
3969 | endp |
3974 | endp |
3970 | 3975 | ||
3971 | if 1 |
3976 | if 1 |
3972 | align 4 |
3977 | align 4 |
3973 | delay_hs: ; delay in 1/100 secs |
3978 | delay_hs: ; delay in 1/100 secs |
3974 | ; ebx = delay time |
3979 | ; ebx = delay time |
3975 | 3980 | ||
3976 | pushad |
3981 | pushad |
3977 | push ebx |
3982 | push ebx |
3978 | xor esi, esi |
3983 | xor esi, esi |
3979 | mov ecx, MANUAL_DESTROY |
3984 | mov ecx, MANUAL_DESTROY |
3980 | call create_event |
3985 | call create_event |
3981 | test eax, eax |
3986 | test eax, eax |
3982 | jz .done |
3987 | jz .done |
3983 | 3988 | ||
3984 | mov ebx, edx |
3989 | mov ebx, edx |
3985 | mov ecx, [esp] |
3990 | mov ecx, [esp] |
3986 | push edx |
3991 | push edx |
3987 | push eax |
3992 | push eax |
3988 | call wait_event_timeout |
3993 | call wait_event_timeout |
3989 | pop eax |
3994 | pop eax |
3990 | pop ebx |
3995 | pop ebx |
3991 | call destroy_event |
3996 | call destroy_event |
3992 | .done: |
3997 | .done: |
3993 | add esp, 4 |
3998 | add esp, 4 |
3994 | popad |
3999 | popad |
3995 | ret |
4000 | ret |
3996 | 4001 | ||
3997 | else |
4002 | else |
3998 | 4003 | ||
3999 | align 4 |
4004 | align 4 |
4000 | delay_hs: ; delay in 1/100 secs |
4005 | delay_hs: ; delay in 1/100 secs |
4001 | ; ebx = delay time |
4006 | ; ebx = delay time |
4002 | push ecx |
4007 | push ecx |
4003 | push edx |
4008 | push edx |
4004 | 4009 | ||
4005 | mov edx, [timer_ticks] |
4010 | mov edx, [timer_ticks] |
4006 | ;-------------------------------------- |
4011 | ;-------------------------------------- |
4007 | align 4 |
4012 | align 4 |
4008 | newtic: |
4013 | newtic: |
4009 | mov ecx, [timer_ticks] |
4014 | mov ecx, [timer_ticks] |
4010 | sub ecx, edx |
4015 | sub ecx, edx |
4011 | cmp ecx, ebx |
4016 | cmp ecx, ebx |
4012 | jae zerodelay |
4017 | jae zerodelay |
4013 | 4018 | ||
4014 | call change_task |
4019 | call change_task |
4015 | 4020 | ||
4016 | jmp newtic |
4021 | jmp newtic |
4017 | ;-------------------------------------- |
4022 | ;-------------------------------------- |
4018 | align 4 |
4023 | align 4 |
4019 | zerodelay: |
4024 | zerodelay: |
4020 | pop edx |
4025 | pop edx |
4021 | pop ecx |
4026 | pop ecx |
4022 | ret |
4027 | ret |
4023 | end if |
4028 | end if |
4024 | 4029 | ||
4025 | ;----------------------------------------------------------------------------- |
4030 | ;----------------------------------------------------------------------------- |
4026 | align 16 ;very often call this subrutine |
4031 | align 16 ;very often call this subrutine |
4027 | memmove: ; memory move in bytes |
4032 | memmove: ; memory move in bytes |
4028 | ; eax = from |
4033 | ; eax = from |
4029 | ; ebx = to |
4034 | ; ebx = to |
4030 | ; ecx = no of bytes |
4035 | ; ecx = no of bytes |
4031 | test ecx, ecx |
4036 | test ecx, ecx |
4032 | jle .ret |
4037 | jle .ret |
4033 | 4038 | ||
4034 | push esi edi ecx |
4039 | push esi edi ecx |
4035 | 4040 | ||
4036 | mov edi, ebx |
4041 | mov edi, ebx |
4037 | mov esi, eax |
4042 | mov esi, eax |
4038 | 4043 | ||
4039 | test ecx, not 11b |
4044 | test ecx, not 11b |
4040 | jz @f |
4045 | jz @f |
4041 | 4046 | ||
4042 | push ecx |
4047 | push ecx |
4043 | shr ecx, 2 |
4048 | shr ecx, 2 |
4044 | rep movsd |
4049 | rep movsd |
4045 | pop ecx |
4050 | pop ecx |
4046 | and ecx, 11b |
4051 | and ecx, 11b |
4047 | jz .finish |
4052 | jz .finish |
4048 | ;-------------------------------------- |
4053 | ;-------------------------------------- |
4049 | align 4 |
4054 | align 4 |
4050 | @@: |
4055 | @@: |
4051 | rep movsb |
4056 | rep movsb |
4052 | ;-------------------------------------- |
4057 | ;-------------------------------------- |
4053 | align 4 |
4058 | align 4 |
4054 | .finish: |
4059 | .finish: |
4055 | pop ecx edi esi |
4060 | pop ecx edi esi |
4056 | ;-------------------------------------- |
4061 | ;-------------------------------------- |
4057 | align 4 |
4062 | align 4 |
4058 | .ret: |
4063 | .ret: |
4059 | ret |
4064 | ret |
4060 | ;----------------------------------------------------------------------------- |
4065 | ;----------------------------------------------------------------------------- |
4061 | ; |
4066 | ; |
4062 | ;align 4 |
4067 | ;align 4 |
4063 | ; |
4068 | ; |
4064 | ;read_floppy_file: |
4069 | ;read_floppy_file: |
4065 | ; |
4070 | ; |
4066 | ;; as input |
4071 | ;; as input |
4067 | ;; |
4072 | ;; |
4068 | ;; eax pointer to file |
4073 | ;; eax pointer to file |
4069 | ;; ebx file lenght |
4074 | ;; ebx file lenght |
4070 | ;; ecx start 512 byte block number |
4075 | ;; ecx start 512 byte block number |
4071 | ;; edx number of blocks to read |
4076 | ;; edx number of blocks to read |
4072 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4077 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4073 | ;; |
4078 | ;; |
4074 | ;; |
4079 | ;; |
4075 | ;; on return |
4080 | ;; on return |
4076 | ;; |
4081 | ;; |
4077 | ;; eax = 0 command succesful |
4082 | ;; eax = 0 command succesful |
4078 | ;; 1 no fd base and/or partition defined |
4083 | ;; 1 no fd base and/or partition defined |
4079 | ;; 2 yet unsupported FS |
4084 | ;; 2 yet unsupported FS |
4080 | ;; 3 unknown FS |
4085 | ;; 3 unknown FS |
4081 | ;; 4 partition not defined at hd |
4086 | ;; 4 partition not defined at hd |
4082 | ;; 5 file not found |
4087 | ;; 5 file not found |
4083 | ;; ebx = size of file |
4088 | ;; ebx = size of file |
4084 | ; |
4089 | ; |
4085 | ; mov edi,[TASK_BASE] |
4090 | ; mov edi,[TASK_BASE] |
4086 | ; add edi,0x10 |
4091 | ; add edi,0x10 |
4087 | ; add esi,[edi] |
4092 | ; add esi,[edi] |
4088 | ; add eax,[edi] |
4093 | ; add eax,[edi] |
4089 | ; |
4094 | ; |
4090 | ; pushad |
4095 | ; pushad |
4091 | ; mov edi,esi |
4096 | ; mov edi,esi |
4092 | ; add edi,1024 |
4097 | ; add edi,1024 |
4093 | ; mov esi,0x100000+19*512 |
4098 | ; mov esi,0x100000+19*512 |
4094 | ; sub ecx,1 |
4099 | ; sub ecx,1 |
4095 | ; shl ecx,9 |
4100 | ; shl ecx,9 |
4096 | ; add esi,ecx |
4101 | ; add esi,ecx |
4097 | ; shl edx,9 |
4102 | ; shl edx,9 |
4098 | ; mov ecx,edx |
4103 | ; mov ecx,edx |
4099 | ; cld |
4104 | ; cld |
4100 | ; rep movsb |
4105 | ; rep movsb |
4101 | ; popad |
4106 | ; popad |
4102 | ; |
4107 | ; |
4103 | ; mov [esp+36],eax |
4108 | ; mov [esp+36],eax |
4104 | ; mov [esp+24],ebx |
4109 | ; mov [esp+24],ebx |
4105 | ; ret |
4110 | ; ret |
4106 | 4111 | ||
4107 | 4112 | ||
4108 | 4113 | ||
4109 | align 4 |
4114 | align 4 |
4110 | set_io_access_rights: |
4115 | set_io_access_rights: |
4111 | push edi eax |
4116 | push edi eax |
4112 | mov edi, tss._io_map_0 |
4117 | mov edi, tss._io_map_0 |
4113 | ; mov ecx,eax |
4118 | ; mov ecx,eax |
4114 | ; and ecx,7 ; offset in byte |
4119 | ; and ecx,7 ; offset in byte |
4115 | ; shr eax,3 ; number of byte |
4120 | ; shr eax,3 ; number of byte |
4116 | ; add edi,eax |
4121 | ; add edi,eax |
4117 | ; mov ebx,1 |
4122 | ; mov ebx,1 |
4118 | ; shl ebx,cl |
4123 | ; shl ebx,cl |
4119 | test ebp, ebp |
4124 | test ebp, ebp |
4120 | ; cmp ebp,0 ; enable access - ebp = 0 |
4125 | ; cmp ebp,0 ; enable access - ebp = 0 |
4121 | jnz .siar1 |
4126 | jnz .siar1 |
4122 | ; not ebx |
4127 | ; not ebx |
4123 | ; and [edi],byte bl |
4128 | ; and [edi],byte bl |
4124 | btr [edi], eax |
4129 | btr [edi], eax |
4125 | pop eax edi |
4130 | pop eax edi |
4126 | ret |
4131 | ret |
4127 | .siar1: |
4132 | .siar1: |
4128 | bts [edi], eax |
4133 | bts [edi], eax |
4129 | ; or [edi],byte bl ; disable access - ebp = 1 |
4134 | ; or [edi],byte bl ; disable access - ebp = 1 |
4130 | pop eax edi |
4135 | pop eax edi |
4131 | ret |
4136 | ret |
4132 | ;reserve/free group of ports |
4137 | ;reserve/free group of ports |
4133 | ; * eax = 46 - number function |
4138 | ; * eax = 46 - number function |
4134 | ; * ebx = 0 - reserve, 1 - free |
4139 | ; * ebx = 0 - reserve, 1 - free |
4135 | ; * ecx = number start arrea of ports |
4140 | ; * ecx = number start arrea of ports |
4136 | ; * edx = number end arrea of ports (include last number of port) |
4141 | ; * edx = number end arrea of ports (include last number of port) |
4137 | ;Return value: |
4142 | ;Return value: |
4138 | ; * eax = 0 - succesful |
4143 | ; * eax = 0 - succesful |
4139 | ; * eax = 1 - error |
4144 | ; * eax = 1 - error |
4140 | ; * The system has reserve this ports: |
4145 | ; * The system has reserve this ports: |
4141 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4146 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4142 | ;destroys eax,ebx, ebp |
4147 | ;destroys eax,ebx, ebp |
4143 | r_f_port_area: |
4148 | r_f_port_area: |
4144 | 4149 | ||
4145 | test ebx, ebx |
4150 | test ebx, ebx |
4146 | jnz free_port_area |
4151 | jnz free_port_area |
4147 | ; je r_port_area |
4152 | ; je r_port_area |
4148 | ; jmp free_port_area |
4153 | ; jmp free_port_area |
4149 | 4154 | ||
4150 | ; r_port_area: |
4155 | ; r_port_area: |
4151 | 4156 | ||
4152 | ; pushad |
4157 | ; pushad |
4153 | 4158 | ||
4154 | cmp ecx, edx ; beginning > end ? |
4159 | cmp ecx, edx ; beginning > end ? |
4155 | ja rpal1 |
4160 | ja rpal1 |
4156 | cmp edx, 65536 |
4161 | cmp edx, 65536 |
4157 | jae rpal1 |
4162 | jae rpal1 |
4158 | mov eax, [RESERVED_PORTS] |
4163 | mov eax, [RESERVED_PORTS] |
4159 | test eax, eax ; no reserved areas ? |
4164 | test eax, eax ; no reserved areas ? |
4160 | je rpal2 |
4165 | je rpal2 |
4161 | cmp eax, 255 ; max reserved |
4166 | cmp eax, 255 ; max reserved |
4162 | jae rpal1 |
4167 | jae rpal1 |
4163 | rpal3: |
4168 | rpal3: |
4164 | mov ebx, eax |
4169 | mov ebx, eax |
4165 | shl ebx, 4 |
4170 | shl ebx, 4 |
4166 | add ebx, RESERVED_PORTS |
4171 | add ebx, RESERVED_PORTS |
4167 | cmp ecx, [ebx+8] |
4172 | cmp ecx, [ebx+8] |
4168 | ja rpal4 |
4173 | ja rpal4 |
4169 | cmp edx, [ebx+4] |
4174 | cmp edx, [ebx+4] |
4170 | jae rpal1 |
4175 | jae rpal1 |
4171 | ; jb rpal4 |
4176 | ; jb rpal4 |
4172 | ; jmp rpal1 |
4177 | ; jmp rpal1 |
4173 | rpal4: |
4178 | rpal4: |
4174 | dec eax |
4179 | dec eax |
4175 | jnz rpal3 |
4180 | jnz rpal3 |
4176 | jmp rpal2 |
4181 | jmp rpal2 |
4177 | rpal1: |
4182 | rpal1: |
4178 | ; popad |
4183 | ; popad |
4179 | ; mov eax,1 |
4184 | ; mov eax,1 |
4180 | xor eax, eax |
4185 | xor eax, eax |
4181 | inc eax |
4186 | inc eax |
4182 | ret |
4187 | ret |
4183 | rpal2: |
4188 | rpal2: |
4184 | ; popad |
4189 | ; popad |
4185 | ; enable port access at port IO map |
4190 | ; enable port access at port IO map |
4186 | cli |
4191 | cli |
4187 | pushad ; start enable io map |
4192 | pushad ; start enable io map |
4188 | 4193 | ||
4189 | cmp edx, 65536;16384 |
4194 | cmp edx, 65536;16384 |
4190 | jae no_unmask_io; jge |
4195 | jae no_unmask_io; jge |
4191 | mov eax, ecx |
4196 | mov eax, ecx |
4192 | ; push ebp |
4197 | ; push ebp |
4193 | xor ebp, ebp ; enable - eax = port |
4198 | xor ebp, ebp ; enable - eax = port |
4194 | new_port_access: |
4199 | new_port_access: |
4195 | ; pushad |
4200 | ; pushad |
4196 | call set_io_access_rights |
4201 | call set_io_access_rights |
4197 | ; popad |
4202 | ; popad |
4198 | inc eax |
4203 | inc eax |
4199 | cmp eax, edx |
4204 | cmp eax, edx |
4200 | jbe new_port_access |
4205 | jbe new_port_access |
4201 | ; pop ebp |
4206 | ; pop ebp |
4202 | no_unmask_io: |
4207 | no_unmask_io: |
4203 | popad ; end enable io map |
4208 | popad ; end enable io map |
4204 | sti |
4209 | sti |
4205 | 4210 | ||
4206 | mov eax, [RESERVED_PORTS] |
4211 | mov eax, [RESERVED_PORTS] |
4207 | add eax, 1 |
4212 | add eax, 1 |
4208 | mov [RESERVED_PORTS], eax |
4213 | mov [RESERVED_PORTS], eax |
4209 | shl eax, 4 |
4214 | shl eax, 4 |
4210 | add eax, RESERVED_PORTS |
4215 | add eax, RESERVED_PORTS |
4211 | mov ebx, [TASK_BASE] |
4216 | mov ebx, [TASK_BASE] |
4212 | mov ebx, [ebx+TASKDATA.pid] |
4217 | mov ebx, [ebx+TASKDATA.pid] |
4213 | mov [eax], ebx |
4218 | mov [eax], ebx |
4214 | mov [eax+4], ecx |
4219 | mov [eax+4], ecx |
4215 | mov [eax+8], edx |
4220 | mov [eax+8], edx |
4216 | 4221 | ||
4217 | xor eax, eax |
4222 | xor eax, eax |
4218 | ret |
4223 | ret |
4219 | 4224 | ||
4220 | free_port_area: |
4225 | free_port_area: |
4221 | 4226 | ||
4222 | ; pushad |
4227 | ; pushad |
4223 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4228 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4224 | test eax, eax |
4229 | test eax, eax |
4225 | jz frpal2 |
4230 | jz frpal2 |
4226 | mov ebx, [TASK_BASE] |
4231 | mov ebx, [TASK_BASE] |
4227 | mov ebx, [ebx+TASKDATA.pid] |
4232 | mov ebx, [ebx+TASKDATA.pid] |
4228 | frpal3: |
4233 | frpal3: |
4229 | mov edi, eax |
4234 | mov edi, eax |
4230 | shl edi, 4 |
4235 | shl edi, 4 |
4231 | add edi, RESERVED_PORTS |
4236 | add edi, RESERVED_PORTS |
4232 | cmp ebx, [edi] |
4237 | cmp ebx, [edi] |
4233 | jne frpal4 |
4238 | jne frpal4 |
4234 | cmp ecx, [edi+4] |
4239 | cmp ecx, [edi+4] |
4235 | jne frpal4 |
4240 | jne frpal4 |
4236 | cmp edx, [edi+8] |
4241 | cmp edx, [edi+8] |
4237 | jne frpal4 |
4242 | jne frpal4 |
4238 | jmp frpal1 |
4243 | jmp frpal1 |
4239 | frpal4: |
4244 | frpal4: |
4240 | dec eax |
4245 | dec eax |
4241 | jnz frpal3 |
4246 | jnz frpal3 |
4242 | frpal2: |
4247 | frpal2: |
4243 | ; popad |
4248 | ; popad |
4244 | inc eax |
4249 | inc eax |
4245 | ret |
4250 | ret |
4246 | frpal1: |
4251 | frpal1: |
4247 | push ecx |
4252 | push ecx |
4248 | mov ecx, 256 |
4253 | mov ecx, 256 |
4249 | sub ecx, eax |
4254 | sub ecx, eax |
4250 | shl ecx, 4 |
4255 | shl ecx, 4 |
4251 | mov esi, edi |
4256 | mov esi, edi |
4252 | add esi, 16 |
4257 | add esi, 16 |
4253 | cld |
4258 | cld |
4254 | rep movsb |
4259 | rep movsb |
4255 | 4260 | ||
4256 | dec dword [RESERVED_PORTS] |
4261 | dec dword [RESERVED_PORTS] |
4257 | ;popad |
4262 | ;popad |
4258 | ;disable port access at port IO map |
4263 | ;disable port access at port IO map |
4259 | 4264 | ||
4260 | ; pushad ; start disable io map |
4265 | ; pushad ; start disable io map |
4261 | pop eax ;start port |
4266 | pop eax ;start port |
4262 | cmp edx, 65536;16384 |
4267 | cmp edx, 65536;16384 |
4263 | jge no_mask_io |
4268 | jge no_mask_io |
4264 | 4269 | ||
4265 | ; mov eax,ecx |
4270 | ; mov eax,ecx |
4266 | xor ebp, ebp |
4271 | xor ebp, ebp |
4267 | inc ebp |
4272 | inc ebp |
4268 | new_port_access_disable: |
4273 | new_port_access_disable: |
4269 | ; pushad |
4274 | ; pushad |
4270 | ; mov ebp,1 ; disable - eax = port |
4275 | ; mov ebp,1 ; disable - eax = port |
4271 | call set_io_access_rights |
4276 | call set_io_access_rights |
4272 | ; popad |
4277 | ; popad |
4273 | inc eax |
4278 | inc eax |
4274 | cmp eax, edx |
4279 | cmp eax, edx |
4275 | jbe new_port_access_disable |
4280 | jbe new_port_access_disable |
4276 | no_mask_io: |
4281 | no_mask_io: |
4277 | ; popad ; end disable io map |
4282 | ; popad ; end disable io map |
4278 | xor eax, eax |
4283 | xor eax, eax |
4279 | ret |
4284 | ret |
4280 | ;----------------------------------------------------------------------------- |
4285 | ;----------------------------------------------------------------------------- |
4281 | align 4 |
4286 | align 4 |
4282 | drawbackground: |
4287 | drawbackground: |
4283 | dbrv20: |
4288 | dbrv20: |
4284 | cmp [BgrDrawMode], dword 1 |
4289 | cmp [BgrDrawMode], dword 1 |
4285 | jne bgrstr |
4290 | jne bgrstr |
4286 | call vesa20_drawbackground_tiled |
4291 | call vesa20_drawbackground_tiled |
4287 | ; call [draw_pointer] |
4292 | ; call [draw_pointer] |
4288 | call __sys_draw_pointer |
4293 | call __sys_draw_pointer |
4289 | ret |
4294 | ret |
4290 | ;-------------------------------------- |
4295 | ;-------------------------------------- |
4291 | align 4 |
4296 | align 4 |
4292 | bgrstr: |
4297 | bgrstr: |
4293 | call vesa20_drawbackground_stretch |
4298 | call vesa20_drawbackground_stretch |
4294 | ; call [draw_pointer] |
4299 | ; call [draw_pointer] |
4295 | call __sys_draw_pointer |
4300 | call __sys_draw_pointer |
4296 | ret |
4301 | ret |
4297 | ;----------------------------------------------------------------------------- |
4302 | ;----------------------------------------------------------------------------- |
4298 | align 4 |
4303 | align 4 |
4299 | syscall_putimage: ; PutImage |
4304 | syscall_putimage: ; PutImage |
4300 | sys_putimage: |
4305 | sys_putimage: |
4301 | test ecx, 0x80008000 |
4306 | test ecx, 0x80008000 |
4302 | jnz .exit |
4307 | jnz .exit |
4303 | test ecx, 0x0000FFFF |
4308 | test ecx, 0x0000FFFF |
4304 | jz .exit |
4309 | jz .exit |
4305 | test ecx, 0xFFFF0000 |
4310 | test ecx, 0xFFFF0000 |
4306 | jnz @f |
4311 | jnz @f |
4307 | ;-------------------------------------- |
4312 | ;-------------------------------------- |
4308 | align 4 |
4313 | align 4 |
4309 | .exit: |
4314 | .exit: |
4310 | ret |
4315 | ret |
4311 | ;-------------------------------------- |
4316 | ;-------------------------------------- |
4312 | align 4 |
4317 | align 4 |
4313 | @@: |
4318 | @@: |
4314 | mov edi, [current_slot] |
4319 | mov edi, [current_slot] |
4315 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4320 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4316 | rol edx, 16 |
4321 | rol edx, 16 |
4317 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4322 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4318 | rol edx, 16 |
4323 | rol edx, 16 |
4319 | ;-------------------------------------- |
4324 | ;-------------------------------------- |
4320 | align 4 |
4325 | align 4 |
4321 | .forced: |
4326 | .forced: |
4322 | push ebp esi 0 |
4327 | push ebp esi 0 |
4323 | mov ebp, putimage_get24bpp |
4328 | mov ebp, putimage_get24bpp |
4324 | mov esi, putimage_init24bpp |
4329 | mov esi, putimage_init24bpp |
4325 | ;-------------------------------------- |
4330 | ;-------------------------------------- |
4326 | align 4 |
4331 | align 4 |
4327 | sys_putimage_bpp: |
4332 | sys_putimage_bpp: |
4328 | call vesa20_putimage |
4333 | call vesa20_putimage |
4329 | pop ebp esi ebp |
4334 | pop ebp esi ebp |
4330 | ret |
4335 | ret |
4331 | ; jmp [draw_pointer] |
4336 | ; jmp [draw_pointer] |
4332 | ;----------------------------------------------------------------------------- |
4337 | ;----------------------------------------------------------------------------- |
4333 | align 4 |
4338 | align 4 |
4334 | sys_putimage_palette: |
4339 | sys_putimage_palette: |
4335 | ; ebx = pointer to image |
4340 | ; ebx = pointer to image |
4336 | ; ecx = [xsize]*65536 + [ysize] |
4341 | ; ecx = [xsize]*65536 + [ysize] |
4337 | ; edx = [xstart]*65536 + [ystart] |
4342 | ; edx = [xstart]*65536 + [ystart] |
4338 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4343 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4339 | ; edi = pointer to palette |
4344 | ; edi = pointer to palette |
4340 | ; ebp = row delta |
4345 | ; ebp = row delta |
4341 | mov eax, [CURRENT_TASK] |
4346 | mov eax, [CURRENT_TASK] |
4342 | shl eax, 8 |
4347 | shl eax, 8 |
4343 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4348 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4344 | rol edx, 16 |
4349 | rol edx, 16 |
4345 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4350 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4346 | rol edx, 16 |
4351 | rol edx, 16 |
4347 | ;-------------------------------------- |
4352 | ;-------------------------------------- |
4348 | align 4 |
4353 | align 4 |
4349 | .forced: |
4354 | .forced: |
4350 | cmp esi, 1 |
4355 | cmp esi, 1 |
4351 | jnz @f |
4356 | jnz @f |
4352 | push edi |
4357 | push edi |
4353 | mov eax, [edi+4] |
4358 | mov eax, [edi+4] |
4354 | sub eax, [edi] |
4359 | sub eax, [edi] |
4355 | push eax |
4360 | push eax |
4356 | push dword [edi] |
4361 | push dword [edi] |
4357 | push 0ffffff80h |
4362 | push 0ffffff80h |
4358 | mov edi, esp |
4363 | mov edi, esp |
4359 | call put_mono_image |
4364 | call put_mono_image |
4360 | add esp, 12 |
4365 | add esp, 12 |
4361 | pop edi |
4366 | pop edi |
4362 | ret |
4367 | ret |
4363 | ;-------------------------------------- |
4368 | ;-------------------------------------- |
4364 | align 4 |
4369 | align 4 |
4365 | @@: |
4370 | @@: |
4366 | cmp esi, 2 |
4371 | cmp esi, 2 |
4367 | jnz @f |
4372 | jnz @f |
4368 | push edi |
4373 | push edi |
4369 | push 0ffffff80h |
4374 | push 0ffffff80h |
4370 | mov edi, esp |
4375 | mov edi, esp |
4371 | call put_2bit_image |
4376 | call put_2bit_image |
4372 | pop eax |
4377 | pop eax |
4373 | pop edi |
4378 | pop edi |
4374 | ret |
4379 | ret |
4375 | ;-------------------------------------- |
4380 | ;-------------------------------------- |
4376 | align 4 |
4381 | align 4 |
4377 | @@: |
4382 | @@: |
4378 | cmp esi, 4 |
4383 | cmp esi, 4 |
4379 | jnz @f |
4384 | jnz @f |
4380 | push edi |
4385 | push edi |
4381 | push 0ffffff80h |
4386 | push 0ffffff80h |
4382 | mov edi, esp |
4387 | mov edi, esp |
4383 | call put_4bit_image |
4388 | call put_4bit_image |
4384 | pop eax |
4389 | pop eax |
4385 | pop edi |
4390 | pop edi |
4386 | ret |
4391 | ret |
4387 | ;-------------------------------------- |
4392 | ;-------------------------------------- |
4388 | align 4 |
4393 | align 4 |
4389 | @@: |
4394 | @@: |
4390 | push ebp esi ebp |
4395 | push ebp esi ebp |
4391 | cmp esi, 8 |
4396 | cmp esi, 8 |
4392 | jnz @f |
4397 | jnz @f |
4393 | mov ebp, putimage_get8bpp |
4398 | mov ebp, putimage_get8bpp |
4394 | mov esi, putimage_init8bpp |
4399 | mov esi, putimage_init8bpp |
4395 | jmp sys_putimage_bpp |
4400 | jmp sys_putimage_bpp |
4396 | ;-------------------------------------- |
4401 | ;-------------------------------------- |
4397 | align 4 |
4402 | align 4 |
4398 | @@: |
4403 | @@: |
4399 | cmp esi, 9 |
4404 | cmp esi, 9 |
4400 | jnz @f |
4405 | jnz @f |
4401 | mov ebp, putimage_get9bpp |
4406 | mov ebp, putimage_get9bpp |
4402 | mov esi, putimage_init9bpp |
4407 | mov esi, putimage_init9bpp |
4403 | jmp sys_putimage_bpp |
4408 | jmp sys_putimage_bpp |
4404 | ;-------------------------------------- |
4409 | ;-------------------------------------- |
4405 | align 4 |
4410 | align 4 |
4406 | @@: |
4411 | @@: |
4407 | cmp esi, 15 |
4412 | cmp esi, 15 |
4408 | jnz @f |
4413 | jnz @f |
4409 | mov ebp, putimage_get15bpp |
4414 | mov ebp, putimage_get15bpp |
4410 | mov esi, putimage_init15bpp |
4415 | mov esi, putimage_init15bpp |
4411 | jmp sys_putimage_bpp |
4416 | jmp sys_putimage_bpp |
4412 | ;-------------------------------------- |
4417 | ;-------------------------------------- |
4413 | align 4 |
4418 | align 4 |
4414 | @@: |
4419 | @@: |
4415 | cmp esi, 16 |
4420 | cmp esi, 16 |
4416 | jnz @f |
4421 | jnz @f |
4417 | mov ebp, putimage_get16bpp |
4422 | mov ebp, putimage_get16bpp |
4418 | mov esi, putimage_init16bpp |
4423 | mov esi, putimage_init16bpp |
4419 | jmp sys_putimage_bpp |
4424 | jmp sys_putimage_bpp |
4420 | ;-------------------------------------- |
4425 | ;-------------------------------------- |
4421 | align 4 |
4426 | align 4 |
4422 | @@: |
4427 | @@: |
4423 | cmp esi, 24 |
4428 | cmp esi, 24 |
4424 | jnz @f |
4429 | jnz @f |
4425 | mov ebp, putimage_get24bpp |
4430 | mov ebp, putimage_get24bpp |
4426 | mov esi, putimage_init24bpp |
4431 | mov esi, putimage_init24bpp |
4427 | jmp sys_putimage_bpp |
4432 | jmp sys_putimage_bpp |
4428 | ;-------------------------------------- |
4433 | ;-------------------------------------- |
4429 | align 4 |
4434 | align 4 |
4430 | @@: |
4435 | @@: |
4431 | cmp esi, 32 |
4436 | cmp esi, 32 |
4432 | jnz @f |
4437 | jnz @f |
4433 | mov ebp, putimage_get32bpp |
4438 | mov ebp, putimage_get32bpp |
4434 | mov esi, putimage_init32bpp |
4439 | mov esi, putimage_init32bpp |
4435 | jmp sys_putimage_bpp |
4440 | jmp sys_putimage_bpp |
4436 | ;-------------------------------------- |
4441 | ;-------------------------------------- |
4437 | align 4 |
4442 | align 4 |
4438 | @@: |
4443 | @@: |
4439 | pop ebp esi ebp |
4444 | pop ebp esi ebp |
4440 | ret |
4445 | ret |
4441 | ;----------------------------------------------------------------------------- |
4446 | ;----------------------------------------------------------------------------- |
4442 | align 4 |
4447 | align 4 |
4443 | put_mono_image: |
4448 | put_mono_image: |
4444 | push ebp esi ebp |
4449 | push ebp esi ebp |
4445 | mov ebp, putimage_get1bpp |
4450 | mov ebp, putimage_get1bpp |
4446 | mov esi, putimage_init1bpp |
4451 | mov esi, putimage_init1bpp |
4447 | jmp sys_putimage_bpp |
4452 | jmp sys_putimage_bpp |
4448 | ;----------------------------------------------------------------------------- |
4453 | ;----------------------------------------------------------------------------- |
4449 | align 4 |
4454 | align 4 |
4450 | put_2bit_image: |
4455 | put_2bit_image: |
4451 | push ebp esi ebp |
4456 | push ebp esi ebp |
4452 | mov ebp, putimage_get2bpp |
4457 | mov ebp, putimage_get2bpp |
4453 | mov esi, putimage_init2bpp |
4458 | mov esi, putimage_init2bpp |
4454 | jmp sys_putimage_bpp |
4459 | jmp sys_putimage_bpp |
4455 | ;----------------------------------------------------------------------------- |
4460 | ;----------------------------------------------------------------------------- |
4456 | align 4 |
4461 | align 4 |
4457 | put_4bit_image: |
4462 | put_4bit_image: |
4458 | push ebp esi ebp |
4463 | push ebp esi ebp |
4459 | mov ebp, putimage_get4bpp |
4464 | mov ebp, putimage_get4bpp |
4460 | mov esi, putimage_init4bpp |
4465 | mov esi, putimage_init4bpp |
4461 | jmp sys_putimage_bpp |
4466 | jmp sys_putimage_bpp |
4462 | ;----------------------------------------------------------------------------- |
4467 | ;----------------------------------------------------------------------------- |
4463 | align 4 |
4468 | align 4 |
4464 | putimage_init24bpp: |
4469 | putimage_init24bpp: |
4465 | lea eax, [eax*3] |
4470 | lea eax, [eax*3] |
4466 | putimage_init8bpp: |
4471 | putimage_init8bpp: |
4467 | putimage_init9bpp: |
4472 | putimage_init9bpp: |
4468 | ret |
4473 | ret |
4469 | ;----------------------------------------------------------------------------- |
4474 | ;----------------------------------------------------------------------------- |
4470 | align 16 |
4475 | align 16 |
4471 | putimage_get24bpp: |
4476 | putimage_get24bpp: |
4472 | movzx eax, byte [esi+2] |
4477 | movzx eax, byte [esi+2] |
4473 | shl eax, 16 |
4478 | shl eax, 16 |
4474 | mov ax, [esi] |
4479 | mov ax, [esi] |
4475 | add esi, 3 |
4480 | add esi, 3 |
4476 | ret 4 |
4481 | ret 4 |
4477 | ;----------------------------------------------------------------------------- |
4482 | ;----------------------------------------------------------------------------- |
4478 | align 16 |
4483 | align 16 |
4479 | putimage_get8bpp: |
4484 | putimage_get8bpp: |
4480 | movzx eax, byte [esi] |
4485 | movzx eax, byte [esi] |
4481 | push edx |
4486 | push edx |
4482 | mov edx, [esp+8] |
4487 | mov edx, [esp+8] |
4483 | mov eax, [edx+eax*4] |
4488 | mov eax, [edx+eax*4] |
4484 | pop edx |
4489 | pop edx |
4485 | inc esi |
4490 | inc esi |
4486 | ret 4 |
4491 | ret 4 |
4487 | ;----------------------------------------------------------------------------- |
4492 | ;----------------------------------------------------------------------------- |
4488 | align 16 |
4493 | align 16 |
4489 | putimage_get9bpp: |
4494 | putimage_get9bpp: |
4490 | lodsb |
4495 | lodsb |
4491 | mov ah, al |
4496 | mov ah, al |
4492 | shl eax, 8 |
4497 | shl eax, 8 |
4493 | mov al, ah |
4498 | mov al, ah |
4494 | ret 4 |
4499 | ret 4 |
4495 | ;----------------------------------------------------------------------------- |
4500 | ;----------------------------------------------------------------------------- |
4496 | align 4 |
4501 | align 4 |
4497 | putimage_init1bpp: |
4502 | putimage_init1bpp: |
4498 | add eax, ecx |
4503 | add eax, ecx |
4499 | push ecx |
4504 | push ecx |
4500 | add eax, 7 |
4505 | add eax, 7 |
4501 | add ecx, 7 |
4506 | add ecx, 7 |
4502 | shr eax, 3 |
4507 | shr eax, 3 |
4503 | shr ecx, 3 |
4508 | shr ecx, 3 |
4504 | sub eax, ecx |
4509 | sub eax, ecx |
4505 | pop ecx |
4510 | pop ecx |
4506 | ret |
4511 | ret |
4507 | ;----------------------------------------------------------------------------- |
4512 | ;----------------------------------------------------------------------------- |
4508 | align 16 |
4513 | align 16 |
4509 | putimage_get1bpp: |
4514 | putimage_get1bpp: |
4510 | push edx |
4515 | push edx |
4511 | mov edx, [esp+8] |
4516 | mov edx, [esp+8] |
4512 | mov al, [edx] |
4517 | mov al, [edx] |
4513 | add al, al |
4518 | add al, al |
4514 | jnz @f |
4519 | jnz @f |
4515 | lodsb |
4520 | lodsb |
4516 | adc al, al |
4521 | adc al, al |
4517 | @@: |
4522 | @@: |
4518 | mov [edx], al |
4523 | mov [edx], al |
4519 | sbb eax, eax |
4524 | sbb eax, eax |
4520 | and eax, [edx+8] |
4525 | and eax, [edx+8] |
4521 | add eax, [edx+4] |
4526 | add eax, [edx+4] |
4522 | pop edx |
4527 | pop edx |
4523 | ret 4 |
4528 | ret 4 |
4524 | ;----------------------------------------------------------------------------- |
4529 | ;----------------------------------------------------------------------------- |
4525 | align 4 |
4530 | align 4 |
4526 | putimage_init2bpp: |
4531 | putimage_init2bpp: |
4527 | add eax, ecx |
4532 | add eax, ecx |
4528 | push ecx |
4533 | push ecx |
4529 | add ecx, 3 |
4534 | add ecx, 3 |
4530 | add eax, 3 |
4535 | add eax, 3 |
4531 | shr ecx, 2 |
4536 | shr ecx, 2 |
4532 | shr eax, 2 |
4537 | shr eax, 2 |
4533 | sub eax, ecx |
4538 | sub eax, ecx |
4534 | pop ecx |
4539 | pop ecx |
4535 | ret |
4540 | ret |
4536 | ;----------------------------------------------------------------------------- |
4541 | ;----------------------------------------------------------------------------- |
4537 | align 16 |
4542 | align 16 |
4538 | putimage_get2bpp: |
4543 | putimage_get2bpp: |
4539 | push edx |
4544 | push edx |
4540 | mov edx, [esp+8] |
4545 | mov edx, [esp+8] |
4541 | mov al, [edx] |
4546 | mov al, [edx] |
4542 | mov ah, al |
4547 | mov ah, al |
4543 | shr al, 6 |
4548 | shr al, 6 |
4544 | shl ah, 2 |
4549 | shl ah, 2 |
4545 | jnz .nonewbyte |
4550 | jnz .nonewbyte |
4546 | lodsb |
4551 | lodsb |
4547 | mov ah, al |
4552 | mov ah, al |
4548 | shr al, 6 |
4553 | shr al, 6 |
4549 | shl ah, 2 |
4554 | shl ah, 2 |
4550 | add ah, 1 |
4555 | add ah, 1 |
4551 | .nonewbyte: |
4556 | .nonewbyte: |
4552 | mov [edx], ah |
4557 | mov [edx], ah |
4553 | mov edx, [edx+4] |
4558 | mov edx, [edx+4] |
4554 | movzx eax, al |
4559 | movzx eax, al |
4555 | mov eax, [edx+eax*4] |
4560 | mov eax, [edx+eax*4] |
4556 | pop edx |
4561 | pop edx |
4557 | ret 4 |
4562 | ret 4 |
4558 | ;----------------------------------------------------------------------------- |
4563 | ;----------------------------------------------------------------------------- |
4559 | align 4 |
4564 | align 4 |
4560 | putimage_init4bpp: |
4565 | putimage_init4bpp: |
4561 | add eax, ecx |
4566 | add eax, ecx |
4562 | push ecx |
4567 | push ecx |
4563 | add ecx, 1 |
4568 | add ecx, 1 |
4564 | add eax, 1 |
4569 | add eax, 1 |
4565 | shr ecx, 1 |
4570 | shr ecx, 1 |
4566 | shr eax, 1 |
4571 | shr eax, 1 |
4567 | sub eax, ecx |
4572 | sub eax, ecx |
4568 | pop ecx |
4573 | pop ecx |
4569 | ret |
4574 | ret |
4570 | ;----------------------------------------------------------------------------- |
4575 | ;----------------------------------------------------------------------------- |
4571 | align 16 |
4576 | align 16 |
4572 | putimage_get4bpp: |
4577 | putimage_get4bpp: |
4573 | push edx |
4578 | push edx |
4574 | mov edx, [esp+8] |
4579 | mov edx, [esp+8] |
4575 | add byte [edx], 80h |
4580 | add byte [edx], 80h |
4576 | jc @f |
4581 | jc @f |
4577 | movzx eax, byte [edx+1] |
4582 | movzx eax, byte [edx+1] |
4578 | mov edx, [edx+4] |
4583 | mov edx, [edx+4] |
4579 | and eax, 0x0F |
4584 | and eax, 0x0F |
4580 | mov eax, [edx+eax*4] |
4585 | mov eax, [edx+eax*4] |
4581 | pop edx |
4586 | pop edx |
4582 | ret 4 |
4587 | ret 4 |
4583 | @@: |
4588 | @@: |
4584 | movzx eax, byte [esi] |
4589 | movzx eax, byte [esi] |
4585 | add esi, 1 |
4590 | add esi, 1 |
4586 | mov [edx+1], al |
4591 | mov [edx+1], al |
4587 | shr eax, 4 |
4592 | shr eax, 4 |
4588 | mov edx, [edx+4] |
4593 | mov edx, [edx+4] |
4589 | mov eax, [edx+eax*4] |
4594 | mov eax, [edx+eax*4] |
4590 | pop edx |
4595 | pop edx |
4591 | ret 4 |
4596 | ret 4 |
4592 | ;----------------------------------------------------------------------------- |
4597 | ;----------------------------------------------------------------------------- |
4593 | align 4 |
4598 | align 4 |
4594 | putimage_init32bpp: |
4599 | putimage_init32bpp: |
4595 | shl eax, 2 |
4600 | shl eax, 2 |
4596 | ret |
4601 | ret |
4597 | ;----------------------------------------------------------------------------- |
4602 | ;----------------------------------------------------------------------------- |
4598 | align 16 |
4603 | align 16 |
4599 | putimage_get32bpp: |
4604 | putimage_get32bpp: |
4600 | lodsd |
4605 | lodsd |
4601 | ret 4 |
4606 | ret 4 |
4602 | ;----------------------------------------------------------------------------- |
4607 | ;----------------------------------------------------------------------------- |
4603 | align 4 |
4608 | align 4 |
4604 | putimage_init15bpp: |
4609 | putimage_init15bpp: |
4605 | putimage_init16bpp: |
4610 | putimage_init16bpp: |
4606 | add eax, eax |
4611 | add eax, eax |
4607 | ret |
4612 | ret |
4608 | ;----------------------------------------------------------------------------- |
4613 | ;----------------------------------------------------------------------------- |
4609 | align 16 |
4614 | align 16 |
4610 | putimage_get15bpp: |
4615 | putimage_get15bpp: |
4611 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4616 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4612 | push ecx edx |
4617 | push ecx edx |
4613 | movzx eax, word [esi] |
4618 | movzx eax, word [esi] |
4614 | add esi, 2 |
4619 | add esi, 2 |
4615 | mov ecx, eax |
4620 | mov ecx, eax |
4616 | mov edx, eax |
4621 | mov edx, eax |
4617 | and eax, 0x1F |
4622 | and eax, 0x1F |
4618 | and ecx, 0x1F shl 5 |
4623 | and ecx, 0x1F shl 5 |
4619 | and edx, 0x1F shl 10 |
4624 | and edx, 0x1F shl 10 |
4620 | shl eax, 3 |
4625 | shl eax, 3 |
4621 | shl ecx, 6 |
4626 | shl ecx, 6 |
4622 | shl edx, 9 |
4627 | shl edx, 9 |
4623 | or eax, ecx |
4628 | or eax, ecx |
4624 | or eax, edx |
4629 | or eax, edx |
4625 | pop edx ecx |
4630 | pop edx ecx |
4626 | ret 4 |
4631 | ret 4 |
4627 | ;----------------------------------------------------------------------------- |
4632 | ;----------------------------------------------------------------------------- |
4628 | align 16 |
4633 | align 16 |
4629 | putimage_get16bpp: |
4634 | putimage_get16bpp: |
4630 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4635 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4631 | push ecx edx |
4636 | push ecx edx |
4632 | movzx eax, word [esi] |
4637 | movzx eax, word [esi] |
4633 | add esi, 2 |
4638 | add esi, 2 |
4634 | mov ecx, eax |
4639 | mov ecx, eax |
4635 | mov edx, eax |
4640 | mov edx, eax |
4636 | and eax, 0x1F |
4641 | and eax, 0x1F |
4637 | and ecx, 0x3F shl 5 |
4642 | and ecx, 0x3F shl 5 |
4638 | and edx, 0x1F shl 11 |
4643 | and edx, 0x1F shl 11 |
4639 | shl eax, 3 |
4644 | shl eax, 3 |
4640 | shl ecx, 5 |
4645 | shl ecx, 5 |
4641 | shl edx, 8 |
4646 | shl edx, 8 |
4642 | or eax, ecx |
4647 | or eax, ecx |
4643 | or eax, edx |
4648 | or eax, edx |
4644 | pop edx ecx |
4649 | pop edx ecx |
4645 | ret 4 |
4650 | ret 4 |
4646 | ;----------------------------------------------------------------------------- |
4651 | ;----------------------------------------------------------------------------- |
4647 | ;align 4 |
4652 | ;align 4 |
4648 | ; eax x beginning |
4653 | ; eax x beginning |
4649 | ; ebx y beginning |
4654 | ; ebx y beginning |
4650 | ; ecx x end |
4655 | ; ecx x end |
4651 | ; edx y end |
4656 | ; edx y end |
4652 | ; edi color |
4657 | ; edi color |
4653 | ;__sys_drawbar: |
4658 | ;__sys_drawbar: |
4654 | ; mov esi, [current_slot] |
4659 | ; mov esi, [current_slot] |
4655 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4660 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4656 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4661 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4657 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4662 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4658 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4663 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4659 | ;-------------------------------------- |
4664 | ;-------------------------------------- |
4660 | ;align 4 |
4665 | ;align 4 |
4661 | ;.forced: |
4666 | ;.forced: |
4662 | ; call vesa20_drawbar |
4667 | ; call vesa20_drawbar |
4663 | ; call [draw_pointer] |
4668 | ; call [draw_pointer] |
4664 | ; ret |
4669 | ; ret |
4665 | ;----------------------------------------------------------------------------- |
4670 | ;----------------------------------------------------------------------------- |
4666 | align 4 |
4671 | align 4 |
4667 | kb_write_wait_ack: |
4672 | kb_write_wait_ack: |
4668 | 4673 | ||
4669 | push ecx edx |
4674 | push ecx edx |
4670 | 4675 | ||
4671 | mov dl, al |
4676 | mov dl, al |
4672 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4677 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4673 | .wait_output_ready: |
4678 | .wait_output_ready: |
4674 | in al, 0x64 |
4679 | in al, 0x64 |
4675 | test al, 2 |
4680 | test al, 2 |
4676 | jz @f |
4681 | jz @f |
4677 | loop .wait_output_ready |
4682 | loop .wait_output_ready |
4678 | mov ah, 1 |
4683 | mov ah, 1 |
4679 | jmp .nothing |
4684 | jmp .nothing |
4680 | @@: |
4685 | @@: |
4681 | mov al, dl |
4686 | mov al, dl |
4682 | out 0x60, al |
4687 | out 0x60, al |
4683 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4688 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4684 | .wait_ack: |
4689 | .wait_ack: |
4685 | in al, 0x64 |
4690 | in al, 0x64 |
4686 | test al, 1 |
4691 | test al, 1 |
4687 | jnz @f |
4692 | jnz @f |
4688 | loop .wait_ack |
4693 | loop .wait_ack |
4689 | mov ah, 1 |
4694 | mov ah, 1 |
4690 | jmp .nothing |
4695 | jmp .nothing |
4691 | @@: |
4696 | @@: |
4692 | in al, 0x60 |
4697 | in al, 0x60 |
4693 | xor ah, ah |
4698 | xor ah, ah |
4694 | 4699 | ||
4695 | .nothing: |
4700 | .nothing: |
4696 | pop edx ecx |
4701 | pop edx ecx |
4697 | 4702 | ||
4698 | ret |
4703 | ret |
4699 | ;----------------------------------------------------------------------------- |
4704 | ;----------------------------------------------------------------------------- |
4700 | 4705 | ||
4701 | setmouse: ; set mousepicture -pointer |
4706 | setmouse: ; set mousepicture -pointer |
4702 | ; ps2 mouse enable |
4707 | ; ps2 mouse enable |
4703 | 4708 | ||
4704 | ; mov [MOUSE_PICTURE], dword mousepointer |
4709 | ; mov [MOUSE_PICTURE], dword mousepointer |
4705 | 4710 | ||
4706 | cli |
4711 | cli |
4707 | 4712 | ||
4708 | ret |
4713 | ret |
4709 | 4714 | ||
4710 | if used _rdtsc |
4715 | if used _rdtsc |
4711 | _rdtsc: |
4716 | _rdtsc: |
4712 | bt [cpu_caps], CAPS_TSC |
4717 | bt [cpu_caps], CAPS_TSC |
4713 | jnc ret_rdtsc |
4718 | jnc ret_rdtsc |
4714 | rdtsc |
4719 | rdtsc |
4715 | ret |
4720 | ret |
4716 | ret_rdtsc: |
4721 | ret_rdtsc: |
4717 | mov edx, 0xffffffff |
4722 | mov edx, 0xffffffff |
4718 | mov eax, 0xffffffff |
4723 | mov eax, 0xffffffff |
4719 | ret |
4724 | ret |
4720 | end if |
4725 | end if |
4721 | 4726 | ||
4722 | sys_msg_board_str: |
4727 | sys_msg_board_str: |
4723 | 4728 | ||
4724 | pushad |
4729 | pushad |
4725 | @@: |
4730 | @@: |
4726 | cmp [esi], byte 0 |
4731 | cmp [esi], byte 0 |
4727 | je @f |
4732 | je @f |
4728 | mov ebx, 1 |
4733 | mov ebx, 1 |
4729 | movzx ecx, byte [esi] |
4734 | movzx ecx, byte [esi] |
4730 | call sys_msg_board |
4735 | call sys_msg_board |
4731 | inc esi |
4736 | inc esi |
4732 | jmp @b |
4737 | jmp @b |
4733 | @@: |
4738 | @@: |
4734 | popad |
4739 | popad |
4735 | ret |
4740 | ret |
4736 | 4741 | ||
4737 | sys_msg_board_byte: |
4742 | sys_msg_board_byte: |
4738 | ; in: al = byte to display |
4743 | ; in: al = byte to display |
4739 | ; out: nothing |
4744 | ; out: nothing |
4740 | ; destroys: nothing |
4745 | ; destroys: nothing |
4741 | pushad |
4746 | pushad |
4742 | mov ecx, 2 |
4747 | mov ecx, 2 |
4743 | shl eax, 24 |
4748 | shl eax, 24 |
4744 | jmp @f |
4749 | jmp @f |
4745 | 4750 | ||
4746 | sys_msg_board_word: |
4751 | sys_msg_board_word: |
4747 | ; in: ax = word to display |
4752 | ; in: ax = word to display |
4748 | ; out: nothing |
4753 | ; out: nothing |
4749 | ; destroys: nothing |
4754 | ; destroys: nothing |
4750 | pushad |
4755 | pushad |
4751 | mov ecx, 4 |
4756 | mov ecx, 4 |
4752 | shl eax, 16 |
4757 | shl eax, 16 |
4753 | jmp @f |
4758 | jmp @f |
4754 | 4759 | ||
4755 | sys_msg_board_dword: |
4760 | sys_msg_board_dword: |
4756 | ; in: eax = dword to display |
4761 | ; in: eax = dword to display |
4757 | ; out: nothing |
4762 | ; out: nothing |
4758 | ; destroys: nothing |
4763 | ; destroys: nothing |
4759 | pushad |
4764 | pushad |
4760 | mov ecx, 8 |
4765 | mov ecx, 8 |
4761 | @@: |
4766 | @@: |
4762 | push ecx |
4767 | push ecx |
4763 | rol eax, 4 |
4768 | rol eax, 4 |
4764 | push eax |
4769 | push eax |
4765 | and al, 0xF |
4770 | and al, 0xF |
4766 | cmp al, 10 |
4771 | cmp al, 10 |
4767 | sbb al, 69h |
4772 | sbb al, 69h |
4768 | das |
4773 | das |
4769 | mov cl, al |
4774 | mov cl, al |
4770 | xor ebx, ebx |
4775 | xor ebx, ebx |
4771 | inc ebx |
4776 | inc ebx |
4772 | call sys_msg_board |
4777 | call sys_msg_board |
4773 | pop eax |
4778 | pop eax |
4774 | pop ecx |
4779 | pop ecx |
4775 | loop @b |
4780 | loop @b |
4776 | popad |
4781 | popad |
4777 | ret |
4782 | ret |
4778 | 4783 | ||
4779 | msg_board_data_size = 65536 ; Must be power of two |
4784 | msg_board_data_size = 65536 ; Must be power of two |
4780 | 4785 | ||
4781 | uglobal |
4786 | uglobal |
4782 | msg_board_data rb msg_board_data_size |
4787 | msg_board_data rb msg_board_data_size |
4783 | msg_board_count dd ? |
4788 | msg_board_count dd ? |
4784 | endg |
4789 | endg |
4785 | 4790 | ||
4786 | iglobal |
4791 | iglobal |
4787 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
4792 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
4788 | endg |
4793 | endg |
4789 | 4794 | ||
4790 | sys_msg_board: |
4795 | sys_msg_board: |
4791 | ; ebx=1 -> write, cl = byte to write |
4796 | ; ebx=1 -> write, cl = byte to write |
4792 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
4797 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
4793 | push eax ebx |
4798 | push eax ebx |
4794 | mov eax, ebx |
4799 | mov eax, ebx |
4795 | mov ebx, ecx |
4800 | mov ebx, ecx |
4796 | mov ecx, [msg_board_count] |
4801 | mov ecx, [msg_board_count] |
4797 | cmp eax, 1 |
4802 | cmp eax, 1 |
4798 | jne .read |
4803 | jne .read |
4799 | 4804 | ||
4800 | if defined debug_com_base |
4805 | if defined debug_com_base |
4801 | push dx ax |
4806 | push dx ax |
4802 | @@: ; wait for empty transmit register |
4807 | @@: ; wait for empty transmit register |
4803 | mov dx, debug_com_base+5 |
4808 | mov dx, debug_com_base+5 |
4804 | in al, dx |
4809 | in al, dx |
4805 | test al, 1 shl 5 |
4810 | test al, 1 shl 5 |
4806 | jz @r |
4811 | jz @r |
4807 | mov dx, debug_com_base ; Output the byte |
4812 | mov dx, debug_com_base ; Output the byte |
4808 | mov al, bl |
4813 | mov al, bl |
4809 | out dx, al |
4814 | out dx, al |
4810 | pop ax dx |
4815 | pop ax dx |
4811 | end if |
4816 | end if |
4812 | 4817 | ||
4813 | mov [msg_board_data+ecx], bl |
4818 | mov [msg_board_data+ecx], bl |
4814 | cmp byte [debug_direct_print], 1 |
4819 | cmp byte [debug_direct_print], 1 |
4815 | jnz .end |
4820 | jnz .end |
4816 | pusha |
4821 | pusha |
4817 | lea edx, [msg_board_data+ecx] |
4822 | lea edx, [msg_board_data+ecx] |
4818 | mov ecx, 0x40FFFFFF |
4823 | mov ecx, 0x40FFFFFF |
4819 | mov ebx, [msg_board_pos] |
4824 | mov ebx, [msg_board_pos] |
4820 | mov edi, 1 |
4825 | mov edi, 1 |
4821 | mov esi, 1 |
4826 | mov esi, 1 |
4822 | call dtext |
4827 | call dtext |
4823 | popa |
4828 | popa |
4824 | add word [msg_board_pos+2], 6 |
4829 | add word [msg_board_pos+2], 6 |
4825 | cmp word [msg_board_pos+2], 105*6 |
4830 | cmp word [msg_board_pos+2], 105*6 |
4826 | jnc @f |
4831 | jnc @f |
4827 | cmp bl, 10 |
4832 | cmp bl, 10 |
4828 | jnz .end |
4833 | jnz .end |
4829 | @@: |
4834 | @@: |
4830 | mov word [msg_board_pos+2], 42*6 |
4835 | mov word [msg_board_pos+2], 42*6 |
4831 | add word [msg_board_pos], 10 |
4836 | add word [msg_board_pos], 10 |
4832 | mov eax, [_display.height] |
4837 | mov eax, [_display.height] |
4833 | sub eax, 10 |
4838 | sub eax, 10 |
4834 | cmp ax, word [msg_board_pos] |
4839 | cmp ax, word [msg_board_pos] |
4835 | jnc @f |
4840 | jnc @f |
4836 | mov word [msg_board_pos], 10 |
4841 | mov word [msg_board_pos], 10 |
4837 | @@: |
4842 | @@: |
4838 | pusha |
4843 | pusha |
4839 | mov eax, [msg_board_pos] |
4844 | mov eax, [msg_board_pos] |
4840 | movzx ebx, ax |
4845 | movzx ebx, ax |
4841 | shr eax, 16 |
4846 | shr eax, 16 |
4842 | mov edx, 105*6 |
4847 | mov edx, 105*6 |
4843 | xor ecx, ecx |
4848 | xor ecx, ecx |
4844 | mov edi, 1 |
4849 | mov edi, 1 |
4845 | mov esi, 9 |
4850 | mov esi, 9 |
4846 | @@: |
4851 | @@: |
4847 | call hline |
4852 | call hline |
4848 | inc ebx |
4853 | inc ebx |
4849 | dec esi |
4854 | dec esi |
4850 | jnz @b |
4855 | jnz @b |
4851 | popa |
4856 | popa |
4852 | .end: |
4857 | .end: |
4853 | inc ecx |
4858 | inc ecx |
4854 | and ecx, msg_board_data_size - 1 |
4859 | and ecx, msg_board_data_size - 1 |
4855 | mov [msg_board_count], ecx |
4860 | mov [msg_board_count], ecx |
4856 | .ret: |
4861 | .ret: |
4857 | pop ebx eax |
4862 | pop ebx eax |
4858 | ret |
4863 | ret |
4859 | 4864 | ||
4860 | @@: |
4865 | @@: |
4861 | mov [esp+32], ecx |
4866 | mov [esp+32], ecx |
4862 | mov [esp+20], ecx |
4867 | mov [esp+20], ecx |
4863 | jmp .ret |
4868 | jmp .ret |
4864 | 4869 | ||
4865 | .read: |
4870 | .read: |
4866 | cmp eax, 2 |
4871 | cmp eax, 2 |
4867 | jne .ret |
4872 | jne .ret |
4868 | test ecx, ecx |
4873 | test ecx, ecx |
4869 | jz @b |
4874 | jz @b |
4870 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4875 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4871 | mov eax, msg_board_data+1 |
4876 | mov eax, msg_board_data+1 |
4872 | mov ebx, msg_board_data |
4877 | mov ebx, msg_board_data |
4873 | movzx edx, byte [ebx] |
4878 | movzx edx, byte [ebx] |
4874 | call memmove |
4879 | call memmove |
4875 | dec [msg_board_count] |
4880 | dec [msg_board_count] |
4876 | mov [esp + 32], edx ;eax |
4881 | mov [esp + 32], edx ;eax |
4877 | mov [esp + 20], dword 1 |
4882 | mov [esp + 20], dword 1 |
4878 | ret |
4883 | ret |
4879 | 4884 | ||
4880 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4885 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4881 | ;; 66 sys function. ;; |
4886 | ;; 66 sys function. ;; |
4882 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4887 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4883 | ;; out eax ;; |
4888 | ;; out eax ;; |
4884 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4889 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4885 | iglobal |
4890 | iglobal |
4886 | align 4 |
4891 | align 4 |
4887 | f66call: |
4892 | f66call: |
4888 | dd sys_process_def.1 ; 1 = set keyboard mode |
4893 | dd sys_process_def.1 ; 1 = set keyboard mode |
4889 | dd sys_process_def.2 ; 2 = get keyboard mode |
4894 | dd sys_process_def.2 ; 2 = get keyboard mode |
4890 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4895 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4891 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4896 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4892 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4897 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4893 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4898 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4894 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4899 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4895 | endg |
4900 | endg |
4896 | ;----------------------------------------------------------------------------- |
4901 | ;----------------------------------------------------------------------------- |
4897 | align 4 |
4902 | align 4 |
4898 | sys_process_def: |
4903 | sys_process_def: |
4899 | dec ebx |
4904 | dec ebx |
4900 | cmp ebx, 7 |
4905 | cmp ebx, 7 |
4901 | jae .not_support ;if >=8 then or eax,-1 |
4906 | jae .not_support ;if >=8 then or eax,-1 |
4902 | 4907 | ||
4903 | mov edi, [CURRENT_TASK] |
4908 | mov edi, [CURRENT_TASK] |
4904 | jmp dword [f66call+ebx*4] |
4909 | jmp dword [f66call+ebx*4] |
4905 | 4910 | ||
4906 | .not_support: |
4911 | .not_support: |
4907 | or eax, -1 |
4912 | or eax, -1 |
4908 | ret |
4913 | ret |
4909 | ;----------------------------------------------------------------------------- |
4914 | ;----------------------------------------------------------------------------- |
4910 | align 4 |
4915 | align 4 |
4911 | .1: |
4916 | .1: |
4912 | shl edi, 8 |
4917 | shl edi, 8 |
4913 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4918 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4914 | 4919 | ||
4915 | ret |
4920 | ret |
4916 | ;----------------------------------------------------------------------------- |
4921 | ;----------------------------------------------------------------------------- |
4917 | align 4 |
4922 | align 4 |
4918 | .2: ; 2 = get keyboard mode |
4923 | .2: ; 2 = get keyboard mode |
4919 | shl edi, 8 |
4924 | shl edi, 8 |
4920 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4925 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4921 | mov [esp+32], eax |
4926 | mov [esp+32], eax |
4922 | ret |
4927 | ret |
4923 | ;----------------------------------------------------------------------------- |
4928 | ;----------------------------------------------------------------------------- |
4924 | align 4 |
4929 | align 4 |
4925 | .3: ;3 = get keyboard ctrl, alt, shift |
4930 | .3: ;3 = get keyboard ctrl, alt, shift |
4926 | mov eax, [kb_state] |
4931 | mov eax, [kb_state] |
4927 | mov [esp+32], eax |
4932 | mov [esp+32], eax |
4928 | ret |
4933 | ret |
4929 | ;----------------------------------------------------------------------------- |
4934 | ;----------------------------------------------------------------------------- |
4930 | align 4 |
4935 | align 4 |
4931 | .4: |
4936 | .4: |
4932 | mov eax, hotkey_list |
4937 | mov eax, hotkey_list |
4933 | @@: |
4938 | @@: |
4934 | cmp dword [eax+8], 0 |
4939 | cmp dword [eax+8], 0 |
4935 | jz .found_free |
4940 | jz .found_free |
4936 | add eax, 16 |
4941 | add eax, 16 |
4937 | cmp eax, hotkey_list+16*256 |
4942 | cmp eax, hotkey_list+16*256 |
4938 | jb @b |
4943 | jb @b |
4939 | mov dword [esp+32], 1 |
4944 | mov dword [esp+32], 1 |
4940 | ret |
4945 | ret |
4941 | .found_free: |
4946 | .found_free: |
4942 | mov [eax+8], edi |
4947 | mov [eax+8], edi |
4943 | mov [eax+4], edx |
4948 | mov [eax+4], edx |
4944 | movzx ecx, cl |
4949 | movzx ecx, cl |
4945 | lea ecx, [hotkey_scancodes+ecx*4] |
4950 | lea ecx, [hotkey_scancodes+ecx*4] |
4946 | mov edx, [ecx] |
4951 | mov edx, [ecx] |
4947 | mov [eax], edx |
4952 | mov [eax], edx |
4948 | mov [ecx], eax |
4953 | mov [ecx], eax |
4949 | mov [eax+12], ecx |
4954 | mov [eax+12], ecx |
4950 | test edx, edx |
4955 | test edx, edx |
4951 | jz @f |
4956 | jz @f |
4952 | mov [edx+12], eax |
4957 | mov [edx+12], eax |
4953 | @@: |
4958 | @@: |
4954 | and dword [esp+32], 0 |
4959 | and dword [esp+32], 0 |
4955 | ret |
4960 | ret |
4956 | ;----------------------------------------------------------------------------- |
4961 | ;----------------------------------------------------------------------------- |
4957 | align 4 |
4962 | align 4 |
4958 | .5: |
4963 | .5: |
4959 | movzx ebx, cl |
4964 | movzx ebx, cl |
4960 | lea ebx, [hotkey_scancodes+ebx*4] |
4965 | lea ebx, [hotkey_scancodes+ebx*4] |
4961 | mov eax, [ebx] |
4966 | mov eax, [ebx] |
4962 | .scan: |
4967 | .scan: |
4963 | test eax, eax |
4968 | test eax, eax |
4964 | jz .notfound |
4969 | jz .notfound |
4965 | cmp [eax+8], edi |
4970 | cmp [eax+8], edi |
4966 | jnz .next |
4971 | jnz .next |
4967 | cmp [eax+4], edx |
4972 | cmp [eax+4], edx |
4968 | jz .found |
4973 | jz .found |
4969 | .next: |
4974 | .next: |
4970 | mov eax, [eax] |
4975 | mov eax, [eax] |
4971 | jmp .scan |
4976 | jmp .scan |
4972 | .notfound: |
4977 | .notfound: |
4973 | mov dword [esp+32], 1 |
4978 | mov dword [esp+32], 1 |
4974 | ret |
4979 | ret |
4975 | .found: |
4980 | .found: |
4976 | mov ecx, [eax] |
4981 | mov ecx, [eax] |
4977 | jecxz @f |
4982 | jecxz @f |
4978 | mov edx, [eax+12] |
4983 | mov edx, [eax+12] |
4979 | mov [ecx+12], edx |
4984 | mov [ecx+12], edx |
4980 | @@: |
4985 | @@: |
4981 | mov ecx, [eax+12] |
4986 | mov ecx, [eax+12] |
4982 | mov edx, [eax] |
4987 | mov edx, [eax] |
4983 | mov [ecx], edx |
4988 | mov [ecx], edx |
4984 | xor edx, edx |
4989 | xor edx, edx |
4985 | mov [eax+4], edx |
4990 | mov [eax+4], edx |
4986 | mov [eax+8], edx |
4991 | mov [eax+8], edx |
4987 | mov [eax+12], edx |
4992 | mov [eax+12], edx |
4988 | mov [eax], edx |
4993 | mov [eax], edx |
4989 | mov [esp+32], edx |
4994 | mov [esp+32], edx |
4990 | ret |
4995 | ret |
4991 | ;----------------------------------------------------------------------------- |
4996 | ;----------------------------------------------------------------------------- |
4992 | align 4 |
4997 | align 4 |
4993 | .6: |
4998 | .6: |
4994 | pushfd |
4999 | pushfd |
4995 | cli |
5000 | cli |
4996 | mov eax, [PID_lock_input] |
5001 | mov eax, [PID_lock_input] |
4997 | test eax, eax |
5002 | test eax, eax |
4998 | jnz @f |
5003 | jnz @f |
4999 | ; get current PID |
5004 | ; get current PID |
5000 | mov eax, [CURRENT_TASK] |
5005 | mov eax, [CURRENT_TASK] |
5001 | shl eax, 5 |
5006 | shl eax, 5 |
5002 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5007 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5003 | ; set current PID for lock input |
5008 | ; set current PID for lock input |
5004 | mov [PID_lock_input], eax |
5009 | mov [PID_lock_input], eax |
5005 | @@: |
5010 | @@: |
5006 | popfd |
5011 | popfd |
5007 | ret |
5012 | ret |
5008 | ;----------------------------------------------------------------------------- |
5013 | ;----------------------------------------------------------------------------- |
5009 | align 4 |
5014 | align 4 |
5010 | .7: |
5015 | .7: |
5011 | mov eax, [PID_lock_input] |
5016 | mov eax, [PID_lock_input] |
5012 | test eax, eax |
5017 | test eax, eax |
5013 | jz @f |
5018 | jz @f |
5014 | ; get current PID |
5019 | ; get current PID |
5015 | mov ebx, [CURRENT_TASK] |
5020 | mov ebx, [CURRENT_TASK] |
5016 | shl ebx, 5 |
5021 | shl ebx, 5 |
5017 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5022 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5018 | ; compare current lock input with current PID |
5023 | ; compare current lock input with current PID |
5019 | cmp ebx, eax |
5024 | cmp ebx, eax |
5020 | jne @f |
5025 | jne @f |
5021 | 5026 | ||
5022 | xor eax, eax |
5027 | xor eax, eax |
5023 | mov [PID_lock_input], eax |
5028 | mov [PID_lock_input], eax |
5024 | @@: |
5029 | @@: |
5025 | ret |
5030 | ret |
5026 | ;----------------------------------------------------------------------------- |
5031 | ;----------------------------------------------------------------------------- |
5027 | uglobal |
5032 | uglobal |
5028 | PID_lock_input dd 0x0 |
5033 | PID_lock_input dd 0x0 |
5029 | endg |
5034 | endg |
5030 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5035 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5031 | ;; 61 sys function. ;; |
5036 | ;; 61 sys function. ;; |
5032 | ;; in eax=61,ebx in [1..3] ;; |
5037 | ;; in eax=61,ebx in [1..3] ;; |
5033 | ;; out eax ;; |
5038 | ;; out eax ;; |
5034 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5039 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5035 | iglobal |
5040 | iglobal |
5036 | align 4 |
5041 | align 4 |
5037 | f61call: |
5042 | f61call: |
5038 | dd sys_gs.1 ; resolution |
5043 | dd sys_gs.1 ; resolution |
5039 | dd sys_gs.2 ; bits per pixel |
5044 | dd sys_gs.2 ; bits per pixel |
5040 | dd sys_gs.3 ; bytes per scanline |
5045 | dd sys_gs.3 ; bytes per scanline |
5041 | endg |
5046 | endg |
5042 | 5047 | ||
5043 | 5048 | ||
5044 | align 4 |
5049 | align 4 |
5045 | 5050 | ||
5046 | sys_gs: ; direct screen access |
5051 | sys_gs: ; direct screen access |
5047 | dec ebx |
5052 | dec ebx |
5048 | cmp ebx, 2 |
5053 | cmp ebx, 2 |
5049 | ja .not_support |
5054 | ja .not_support |
5050 | jmp dword [f61call+ebx*4] |
5055 | jmp dword [f61call+ebx*4] |
5051 | .not_support: |
5056 | .not_support: |
5052 | or [esp+32], dword -1 |
5057 | or [esp+32], dword -1 |
5053 | ret |
5058 | ret |
5054 | 5059 | ||
5055 | 5060 | ||
5056 | .1: ; resolution |
5061 | .1: ; resolution |
5057 | mov eax, [_display.width] |
5062 | mov eax, [_display.width] |
5058 | shl eax, 16 |
5063 | shl eax, 16 |
5059 | mov ax, word [_display.height] |
5064 | mov ax, word [_display.height] |
5060 | mov [esp+32], eax |
5065 | mov [esp+32], eax |
5061 | ret |
5066 | ret |
5062 | .2: ; bits per pixel |
5067 | .2: ; bits per pixel |
5063 | mov eax, [_display.bits_per_pixel] |
5068 | mov eax, [_display.bits_per_pixel] |
5064 | mov [esp+32], eax |
5069 | mov [esp+32], eax |
5065 | ret |
5070 | ret |
5066 | .3: ; bytes per scanline |
5071 | .3: ; bytes per scanline |
5067 | mov eax, [_display.lfb_pitch] |
5072 | mov eax, [_display.lfb_pitch] |
5068 | mov [esp+32], eax |
5073 | mov [esp+32], eax |
5069 | ret |
5074 | ret |
5070 | 5075 | ||
5071 | align 4 ; system functions |
5076 | align 4 ; system functions |
5072 | 5077 | ||
5073 | syscall_setpixel: ; SetPixel |
5078 | syscall_setpixel: ; SetPixel |
5074 | 5079 | ||
5075 | mov eax, ebx |
5080 | mov eax, ebx |
5076 | mov ebx, ecx |
5081 | mov ebx, ecx |
5077 | mov ecx, edx |
5082 | mov ecx, edx |
5078 | mov edx, [TASK_BASE] |
5083 | mov edx, [TASK_BASE] |
5079 | add eax, [edx-twdw+WDATA.box.left] |
5084 | add eax, [edx-twdw+WDATA.box.left] |
5080 | add ebx, [edx-twdw+WDATA.box.top] |
5085 | add ebx, [edx-twdw+WDATA.box.top] |
5081 | mov edi, [current_slot] |
5086 | mov edi, [current_slot] |
5082 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5087 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5083 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5088 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5084 | xor edi, edi ; no force |
5089 | xor edi, edi ; no force |
5085 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5090 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5086 | ; jmp [putpixel] |
5091 | ; jmp [putpixel] |
5087 | jmp __sys_putpixel |
5092 | jmp __sys_putpixel |
5088 | 5093 | ||
5089 | align 4 |
5094 | align 4 |
5090 | 5095 | ||
5091 | syscall_writetext: ; WriteText |
5096 | syscall_writetext: ; WriteText |
5092 | 5097 | ||
5093 | mov eax, [TASK_BASE] |
5098 | mov eax, [TASK_BASE] |
5094 | mov ebp, [eax-twdw+WDATA.box.left] |
5099 | mov ebp, [eax-twdw+WDATA.box.left] |
5095 | push esi |
5100 | push esi |
5096 | mov esi, [current_slot] |
5101 | mov esi, [current_slot] |
5097 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5102 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5098 | shl ebp, 16 |
5103 | shl ebp, 16 |
5099 | add ebp, [eax-twdw+WDATA.box.top] |
5104 | add ebp, [eax-twdw+WDATA.box.top] |
5100 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5105 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5101 | pop esi |
5106 | pop esi |
5102 | test ecx, 0x08000000 ; redirect the output to the user area |
5107 | test ecx, 0x08000000 ; redirect the output to the user area |
5103 | jnz @f |
5108 | jnz @f |
5104 | add ebx, ebp |
5109 | add ebx, ebp |
5105 | align 4 |
5110 | align 4 |
5106 | @@: |
5111 | @@: |
5107 | mov eax, edi |
5112 | mov eax, edi |
5108 | test ecx, 0x08000000 ; redirect the output to the user area |
5113 | test ecx, 0x08000000 ; redirect the output to the user area |
5109 | jnz dtext |
5114 | jnz dtext |
5110 | xor edi, edi |
5115 | xor edi, edi |
5111 | jmp dtext |
5116 | jmp dtext |
5112 | 5117 | ||
5113 | align 4 |
5118 | align 4 |
5114 | 5119 | ||
5115 | syscall_drawrect: ; DrawRect |
5120 | syscall_drawrect: ; DrawRect |
5116 | 5121 | ||
5117 | mov edi, edx ; color + gradient |
5122 | mov edi, edx ; color + gradient |
5118 | and edi, 0x80FFFFFF |
5123 | and edi, 0x80FFFFFF |
5119 | test bx, bx ; x.size |
5124 | test bx, bx ; x.size |
5120 | je .drectr |
5125 | je .drectr |
5121 | test cx, cx ; y.size |
5126 | test cx, cx ; y.size |
5122 | je .drectr |
5127 | je .drectr |
5123 | 5128 | ||
5124 | mov eax, ebx ; bad idea |
5129 | mov eax, ebx ; bad idea |
5125 | mov ebx, ecx |
5130 | mov ebx, ecx |
5126 | 5131 | ||
5127 | movzx ecx, ax ; ecx - x.size |
5132 | movzx ecx, ax ; ecx - x.size |
5128 | shr eax, 16 ; eax - x.coord |
5133 | shr eax, 16 ; eax - x.coord |
5129 | movzx edx, bx ; edx - y.size |
5134 | movzx edx, bx ; edx - y.size |
5130 | shr ebx, 16 ; ebx - y.coord |
5135 | shr ebx, 16 ; ebx - y.coord |
5131 | mov esi, [current_slot] |
5136 | mov esi, [current_slot] |
5132 | 5137 | ||
5133 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5138 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5134 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5139 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5135 | add ecx, eax |
5140 | add ecx, eax |
5136 | add edx, ebx |
5141 | add edx, ebx |
5137 | ; jmp [drawbar] |
5142 | ; jmp [drawbar] |
5138 | jmp vesa20_drawbar |
5143 | jmp vesa20_drawbar |
5139 | .drectr: |
5144 | .drectr: |
5140 | ret |
5145 | ret |
5141 | 5146 | ||
5142 | align 4 |
5147 | align 4 |
5143 | syscall_getscreensize: ; GetScreenSize |
5148 | syscall_getscreensize: ; GetScreenSize |
5144 | mov ax, word [_display.width] |
5149 | mov ax, word [_display.width] |
5145 | dec ax |
5150 | dec ax |
5146 | shl eax, 16 |
5151 | shl eax, 16 |
5147 | mov ax, word [_display.height] |
5152 | mov ax, word [_display.height] |
5148 | dec ax |
5153 | dec ax |
5149 | mov [esp + 32], eax |
5154 | mov [esp + 32], eax |
5150 | ret |
5155 | ret |
5151 | ;----------------------------------------------------------------------------- |
5156 | ;----------------------------------------------------------------------------- |
5152 | align 4 |
5157 | align 4 |
5153 | syscall_cdaudio: |
5158 | syscall_cdaudio: |
5154 | ; ECX - position of CD/DVD-drive |
5159 | ; ECX - position of CD/DVD-drive |
5155 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5160 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5156 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5161 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5157 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5162 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5158 | cmp ecx, 11 |
5163 | cmp ecx, 11 |
5159 | ja .exit |
5164 | ja .exit |
5160 | 5165 | ||
5161 | mov eax, ecx |
5166 | mov eax, ecx |
5162 | shr eax, 2 |
5167 | shr eax, 2 |
5163 | lea eax, [eax*5] |
5168 | lea eax, [eax*5] |
5164 | mov al, [eax+DRIVE_DATA+1] |
5169 | mov al, [eax+DRIVE_DATA+1] |
5165 | 5170 | ||
5166 | push ecx ebx |
5171 | push ecx ebx |
5167 | mov ebx, ecx |
5172 | mov ebx, ecx |
5168 | and ebx, 11b |
5173 | and ebx, 11b |
5169 | shl ebx, 1 |
5174 | shl ebx, 1 |
5170 | mov cl, 6 |
5175 | mov cl, 6 |
5171 | sub cl, bl |
5176 | sub cl, bl |
5172 | shr al, cl |
5177 | shr al, cl |
5173 | test al, 2 ; it's not an ATAPI device |
5178 | test al, 2 ; it's not an ATAPI device |
5174 | pop ebx ecx |
5179 | pop ebx ecx |
5175 | 5180 | ||
5176 | jz .exit |
5181 | jz .exit |
5177 | 5182 | ||
5178 | cmp ebx, 4 |
5183 | cmp ebx, 4 |
5179 | je .eject |
5184 | je .eject |
5180 | 5185 | ||
5181 | cmp ebx, 5 |
5186 | cmp ebx, 5 |
5182 | je .load |
5187 | je .load |
5183 | ;-------------------------------------- |
5188 | ;-------------------------------------- |
5184 | .exit: |
5189 | .exit: |
5185 | ret |
5190 | ret |
5186 | ;-------------------------------------- |
5191 | ;-------------------------------------- |
5187 | .load: |
5192 | .load: |
5188 | call .reserve |
5193 | call .reserve |
5189 | call LoadMedium |
5194 | call LoadMedium |
5190 | jmp .free |
5195 | jmp .free |
5191 | ;-------------------------------------- |
5196 | ;-------------------------------------- |
5192 | .eject: |
5197 | .eject: |
5193 | call .reserve |
5198 | call .reserve |
5194 | call clear_CD_cache |
5199 | call clear_CD_cache |
5195 | call allow_medium_removal |
5200 | call allow_medium_removal |
5196 | call EjectMedium |
5201 | call EjectMedium |
5197 | jmp .free |
5202 | jmp .free |
5198 | ;-------------------------------------- |
5203 | ;-------------------------------------- |
5199 | .reserve: |
5204 | .reserve: |
5200 | call reserve_cd |
5205 | call reserve_cd |
5201 | 5206 | ||
5202 | mov ebx, ecx |
5207 | mov ebx, ecx |
5203 | inc ebx |
5208 | inc ebx |
5204 | mov [cdpos], ebx |
5209 | mov [cdpos], ebx |
5205 | 5210 | ||
5206 | mov eax, ecx |
5211 | mov eax, ecx |
5207 | shr eax, 1 |
5212 | shr eax, 1 |
5208 | and eax, 1 |
5213 | and eax, 1 |
5209 | inc eax |
5214 | inc eax |
5210 | mov [ChannelNumber], al |
5215 | mov [ChannelNumber], al |
5211 | mov eax, ecx |
5216 | mov eax, ecx |
5212 | and eax, 1 |
5217 | and eax, 1 |
5213 | mov [DiskNumber], al |
5218 | mov [DiskNumber], al |
5214 | call reserve_cd_channel |
5219 | call reserve_cd_channel |
5215 | ret |
5220 | ret |
5216 | ;-------------------------------------- |
5221 | ;-------------------------------------- |
5217 | .free: |
5222 | .free: |
5218 | call free_cd_channel |
5223 | call free_cd_channel |
5219 | and [cd_status], 0 |
5224 | and [cd_status], 0 |
5220 | ret |
5225 | ret |
5221 | ;----------------------------------------------------------------------------- |
5226 | ;----------------------------------------------------------------------------- |
5222 | align 4 |
5227 | align 4 |
5223 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5228 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5224 | cmp ebx, [_display.width] |
5229 | cmp ebx, [_display.width] |
5225 | jb @f |
5230 | jb @f |
5226 | cmp ecx, [_display.height] |
5231 | cmp ecx, [_display.height] |
5227 | jb @f |
5232 | jb @f |
5228 | xor eax, eax |
5233 | xor eax, eax |
5229 | jmp .store |
5234 | jmp .store |
5230 | ;-------------------------------------- |
5235 | ;-------------------------------------- |
5231 | align 4 |
5236 | align 4 |
5232 | @@: |
5237 | @@: |
5233 | mov eax, [d_width_calc_area + ecx*4] |
5238 | mov eax, [d_width_calc_area + ecx*4] |
5234 | add eax, [_display.win_map] |
5239 | add eax, [_display.win_map] |
5235 | movzx eax, byte[eax+ebx] ; get value for current point |
5240 | movzx eax, byte[eax+ebx] ; get value for current point |
5236 | ;-------------------------------------- |
5241 | ;-------------------------------------- |
5237 | align 4 |
5242 | align 4 |
5238 | .store: |
5243 | .store: |
5239 | mov [esp + 32], eax |
5244 | mov [esp + 32], eax |
5240 | ret |
5245 | ret |
5241 | ;----------------------------------------------------------------------------- |
5246 | ;----------------------------------------------------------------------------- |
5242 | align 4 |
5247 | align 4 |
5243 | syscall_getpixel: ; GetPixel |
5248 | syscall_getpixel: ; GetPixel |
5244 | mov ecx, [_display.width] |
5249 | mov ecx, [_display.width] |
5245 | xor edx, edx |
5250 | xor edx, edx |
5246 | mov eax, ebx |
5251 | mov eax, ebx |
5247 | div ecx |
5252 | div ecx |
5248 | mov ebx, edx |
5253 | mov ebx, edx |
5249 | xchg eax, ebx |
5254 | xchg eax, ebx |
5250 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5255 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5251 | call dword [GETPIXEL]; eax - x, ebx - y |
5256 | call dword [GETPIXEL]; eax - x, ebx - y |
5252 | mov [esp + 32], ecx |
5257 | mov [esp + 32], ecx |
5253 | ret |
5258 | ret |
5254 | ;----------------------------------------------------------------------------- |
5259 | ;----------------------------------------------------------------------------- |
5255 | align 4 |
5260 | align 4 |
5256 | syscall_getarea: |
5261 | syscall_getarea: |
5257 | ;eax = 36 |
5262 | ;eax = 36 |
5258 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5263 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5259 | ;ecx = [size x]*65536 + [size y] |
5264 | ;ecx = [size x]*65536 + [size y] |
5260 | ;edx = [start x]*65536 + [start y] |
5265 | ;edx = [start x]*65536 + [start y] |
5261 | pushad |
5266 | pushad |
5262 | mov edi, ebx |
5267 | mov edi, ebx |
5263 | mov eax, edx |
5268 | mov eax, edx |
5264 | shr eax, 16 |
5269 | shr eax, 16 |
5265 | mov ebx, edx |
5270 | mov ebx, edx |
5266 | and ebx, 0xffff |
5271 | and ebx, 0xffff |
5267 | dec eax |
5272 | dec eax |
5268 | dec ebx |
5273 | dec ebx |
5269 | ; eax - x, ebx - y |
5274 | ; eax - x, ebx - y |
5270 | mov edx, ecx |
5275 | mov edx, ecx |
5271 | 5276 | ||
5272 | shr ecx, 16 |
5277 | shr ecx, 16 |
5273 | and edx, 0xffff |
5278 | and edx, 0xffff |
5274 | mov esi, ecx |
5279 | mov esi, ecx |
5275 | ; ecx - size x, edx - size y |
5280 | ; ecx - size x, edx - size y |
5276 | 5281 | ||
5277 | mov ebp, edx |
5282 | mov ebp, edx |
5278 | dec ebp |
5283 | dec ebp |
5279 | lea ebp, [ebp*3] |
5284 | lea ebp, [ebp*3] |
5280 | 5285 | ||
5281 | imul ebp, esi |
5286 | imul ebp, esi |
5282 | 5287 | ||
5283 | mov esi, ecx |
5288 | mov esi, ecx |
5284 | dec esi |
5289 | dec esi |
5285 | lea esi, [esi*3] |
5290 | lea esi, [esi*3] |
5286 | 5291 | ||
5287 | add ebp, esi |
5292 | add ebp, esi |
5288 | add ebp, edi |
5293 | add ebp, edi |
5289 | 5294 | ||
5290 | add ebx, edx |
5295 | add ebx, edx |
5291 | ;-------------------------------------- |
5296 | ;-------------------------------------- |
5292 | align 4 |
5297 | align 4 |
5293 | .start_y: |
5298 | .start_y: |
5294 | push ecx edx |
5299 | push ecx edx |
5295 | ;-------------------------------------- |
5300 | ;-------------------------------------- |
5296 | align 4 |
5301 | align 4 |
5297 | .start_x: |
5302 | .start_x: |
5298 | push eax ebx ecx |
5303 | push eax ebx ecx |
5299 | add eax, ecx |
5304 | add eax, ecx |
5300 | 5305 | ||
5301 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5306 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5302 | call dword [GETPIXEL]; eax - x, ebx - y |
5307 | call dword [GETPIXEL]; eax - x, ebx - y |
5303 | 5308 | ||
5304 | mov [ebp], cx |
5309 | mov [ebp], cx |
5305 | shr ecx, 16 |
5310 | shr ecx, 16 |
5306 | mov [ebp+2], cl |
5311 | mov [ebp+2], cl |
5307 | 5312 | ||
5308 | pop ecx ebx eax |
5313 | pop ecx ebx eax |
5309 | sub ebp, 3 |
5314 | sub ebp, 3 |
5310 | dec ecx |
5315 | dec ecx |
5311 | jnz .start_x |
5316 | jnz .start_x |
5312 | pop edx ecx |
5317 | pop edx ecx |
5313 | dec ebx |
5318 | dec ebx |
5314 | dec edx |
5319 | dec edx |
5315 | jnz .start_y |
5320 | jnz .start_y |
5316 | popad |
5321 | popad |
5317 | ret |
5322 | ret |
5318 | ;----------------------------------------------------------------------------- |
5323 | ;----------------------------------------------------------------------------- |
5319 | align 4 |
5324 | align 4 |
5320 | syscall_putarea_backgr: |
5325 | syscall_putarea_backgr: |
5321 | ;eax = 25 |
5326 | ;eax = 25 |
5322 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5327 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5323 | ;ecx = [size x]*65536 + [size y] |
5328 | ;ecx = [size x]*65536 + [size y] |
5324 | ;edx = [start x]*65536 + [start y] |
5329 | ;edx = [start x]*65536 + [start y] |
5325 | pushad |
5330 | pushad |
5326 | mov edi, ebx |
5331 | mov edi, ebx |
5327 | mov eax, edx |
5332 | mov eax, edx |
5328 | shr eax, 16 |
5333 | shr eax, 16 |
5329 | mov ebx, edx |
5334 | mov ebx, edx |
5330 | and ebx, 0xffff |
5335 | and ebx, 0xffff |
5331 | dec eax |
5336 | dec eax |
5332 | dec ebx |
5337 | dec ebx |
5333 | ; eax - x, ebx - y |
5338 | ; eax - x, ebx - y |
5334 | mov edx, ecx |
5339 | mov edx, ecx |
5335 | shr ecx, 16 |
5340 | shr ecx, 16 |
5336 | and edx, 0xffff |
5341 | and edx, 0xffff |
5337 | mov esi, ecx |
5342 | mov esi, ecx |
5338 | ; ecx - size x, edx - size y |
5343 | ; ecx - size x, edx - size y |
5339 | mov ebp, edx |
5344 | mov ebp, edx |
5340 | dec ebp |
5345 | dec ebp |
5341 | shl ebp, 2 |
5346 | shl ebp, 2 |
5342 | 5347 | ||
5343 | imul ebp, esi |
5348 | imul ebp, esi |
5344 | 5349 | ||
5345 | mov esi, ecx |
5350 | mov esi, ecx |
5346 | dec esi |
5351 | dec esi |
5347 | shl esi, 2 |
5352 | shl esi, 2 |
5348 | 5353 | ||
5349 | add ebp, esi |
5354 | add ebp, esi |
5350 | add ebp, edi |
5355 | add ebp, edi |
5351 | 5356 | ||
5352 | add ebx, edx |
5357 | add ebx, edx |
5353 | ;-------------------------------------- |
5358 | ;-------------------------------------- |
5354 | align 4 |
5359 | align 4 |
5355 | .start_y: |
5360 | .start_y: |
5356 | push ecx edx |
5361 | push ecx edx |
5357 | ;-------------------------------------- |
5362 | ;-------------------------------------- |
5358 | align 4 |
5363 | align 4 |
5359 | .start_x: |
5364 | .start_x: |
5360 | push eax ecx |
5365 | push eax ecx |
5361 | add eax, ecx |
5366 | add eax, ecx |
5362 | 5367 | ||
5363 | mov ecx, [ebp] |
5368 | mov ecx, [ebp] |
5364 | rol ecx, 8 |
5369 | rol ecx, 8 |
5365 | test cl, cl ; transparensy = 0 |
5370 | test cl, cl ; transparensy = 0 |
5366 | jz .no_put |
5371 | jz .no_put |
5367 | 5372 | ||
5368 | xor cl, cl |
5373 | xor cl, cl |
5369 | ror ecx, 8 |
5374 | ror ecx, 8 |
5370 | 5375 | ||
5371 | pushad |
5376 | pushad |
5372 | mov edx, [d_width_calc_area + ebx*4] |
5377 | mov edx, [d_width_calc_area + ebx*4] |
5373 | add edx, [_display.win_map] |
5378 | add edx, [_display.win_map] |
5374 | movzx edx, byte [eax+edx] |
5379 | movzx edx, byte [eax+edx] |
5375 | cmp dl, byte 1 |
5380 | cmp dl, byte 1 |
5376 | jne @f |
5381 | jne @f |
5377 | 5382 | ||
5378 | call dword [PUTPIXEL]; eax - x, ebx - y |
5383 | call dword [PUTPIXEL]; eax - x, ebx - y |
5379 | ;-------------------------------------- |
5384 | ;-------------------------------------- |
5380 | align 4 |
5385 | align 4 |
5381 | @@: |
5386 | @@: |
5382 | popad |
5387 | popad |
5383 | ;-------------------------------------- |
5388 | ;-------------------------------------- |
5384 | align 4 |
5389 | align 4 |
5385 | .no_put: |
5390 | .no_put: |
5386 | pop ecx eax |
5391 | pop ecx eax |
5387 | 5392 | ||
5388 | sub ebp, 4 |
5393 | sub ebp, 4 |
5389 | dec ecx |
5394 | dec ecx |
5390 | jnz .start_x |
5395 | jnz .start_x |
5391 | 5396 | ||
5392 | pop edx ecx |
5397 | pop edx ecx |
5393 | dec ebx |
5398 | dec ebx |
5394 | dec edx |
5399 | dec edx |
5395 | jnz .start_y |
5400 | jnz .start_y |
5396 | 5401 | ||
5397 | popad |
5402 | popad |
5398 | ret |
5403 | ret |
5399 | ;----------------------------------------------------------------------------- |
5404 | ;----------------------------------------------------------------------------- |
5400 | align 4 |
5405 | align 4 |
5401 | syscall_drawline: ; DrawLine |
5406 | syscall_drawline: ; DrawLine |
5402 | 5407 | ||
5403 | mov edi, [TASK_BASE] |
5408 | mov edi, [TASK_BASE] |
5404 | movzx eax, word[edi-twdw+WDATA.box.left] |
5409 | movzx eax, word[edi-twdw+WDATA.box.left] |
5405 | mov ebp, eax |
5410 | mov ebp, eax |
5406 | mov esi, [current_slot] |
5411 | mov esi, [current_slot] |
5407 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5412 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5408 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5413 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5409 | add ebp, ebx |
5414 | add ebp, ebx |
5410 | shl eax, 16 |
5415 | shl eax, 16 |
5411 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5416 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5412 | add eax, ebp |
5417 | add eax, ebp |
5413 | mov ebp, ebx |
5418 | mov ebp, ebx |
5414 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5419 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5415 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5420 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5416 | add ebp, ecx |
5421 | add ebp, ecx |
5417 | shl ebx, 16 |
5422 | shl ebx, 16 |
5418 | xor edi, edi |
5423 | xor edi, edi |
5419 | add ebx, ebp |
5424 | add ebx, ebp |
5420 | mov ecx, edx |
5425 | mov ecx, edx |
5421 | ; jmp [draw_line] |
5426 | ; jmp [draw_line] |
5422 | jmp __sys_draw_line |
5427 | jmp __sys_draw_line |
5423 | 5428 | ||
5424 | 5429 | ||
5425 | align 4 |
5430 | align 4 |
5426 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5431 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5427 | 5432 | ||
5428 | call r_f_port_area |
5433 | call r_f_port_area |
5429 | mov [esp+32], eax |
5434 | mov [esp+32], eax |
5430 | ret |
5435 | ret |
5431 | 5436 | ||
5432 | align 4 |
5437 | align 4 |
5433 | syscall_threads: ; CreateThreads |
5438 | syscall_threads: ; CreateThreads |
5434 | ; |
5439 | ; |
5435 | ; ecx=thread entry point |
5440 | ; ecx=thread entry point |
5436 | ; edx=thread stack pointer |
5441 | ; edx=thread stack pointer |
5437 | ; |
5442 | ; |
5438 | ; on return : eax = pid |
5443 | ; on return : eax = pid |
5439 | 5444 | ||
5440 | xor ebx, ebx |
5445 | xor ebx, ebx |
5441 | call new_sys_threads |
5446 | call new_sys_threads |
5442 | 5447 | ||
5443 | mov [esp+32], eax |
5448 | mov [esp+32], eax |
5444 | ret |
5449 | ret |
5445 | 5450 | ||
5446 | align 4 |
5451 | align 4 |
5447 | 5452 | ||
5448 | paleholder: |
5453 | paleholder: |
5449 | ret |
5454 | ret |
5450 | ;------------------------------------------------------------------------------ |
5455 | ;------------------------------------------------------------------------------ |
5451 | align 4 |
5456 | align 4 |
5452 | calculate_fast_getting_offset_for_WinMapAddress: |
5457 | calculate_fast_getting_offset_for_WinMapAddress: |
5453 | ; calculate data area for fast getting offset to _WinMapAddress |
5458 | ; calculate data area for fast getting offset to _WinMapAddress |
5454 | xor eax, eax |
5459 | xor eax, eax |
5455 | mov ecx, [_display.height] |
5460 | mov ecx, [_display.height] |
5456 | mov edi, d_width_calc_area |
5461 | mov edi, d_width_calc_area |
5457 | cld |
5462 | cld |
5458 | @@: |
5463 | @@: |
5459 | stosd |
5464 | stosd |
5460 | add eax, [_display.width] |
5465 | add eax, [_display.width] |
5461 | dec ecx |
5466 | dec ecx |
5462 | jnz @r |
5467 | jnz @r |
5463 | ret |
5468 | ret |
5464 | ;------------------------------------------------------------------------------ |
5469 | ;------------------------------------------------------------------------------ |
5465 | align 4 |
5470 | align 4 |
5466 | calculate_fast_getting_offset_for_LFB: |
5471 | calculate_fast_getting_offset_for_LFB: |
5467 | ; calculate data area for fast getting offset to LFB |
5472 | ; calculate data area for fast getting offset to LFB |
5468 | xor eax, eax |
5473 | xor eax, eax |
5469 | mov ecx, [_display.height] |
5474 | mov ecx, [_display.height] |
5470 | mov edi, BPSLine_calc_area |
5475 | mov edi, BPSLine_calc_area |
5471 | cld |
5476 | cld |
5472 | @@: |
5477 | @@: |
5473 | stosd |
5478 | stosd |
5474 | add eax, [_display.lfb_pitch] |
5479 | add eax, [_display.lfb_pitch] |
5475 | dec ecx |
5480 | dec ecx |
5476 | jnz @r |
5481 | jnz @r |
5477 | ret |
5482 | ret |
5478 | ;------------------------------------------------------------------------------ |
5483 | ;------------------------------------------------------------------------------ |
5479 | align 4 |
5484 | align 4 |
5480 | set_screen: |
5485 | set_screen: |
5481 | ; in: |
5486 | ; in: |
5482 | ; eax - new Screen_Max_X |
5487 | ; eax - new Screen_Max_X |
5483 | ; ecx - new BytesPerScanLine |
5488 | ; ecx - new BytesPerScanLine |
5484 | ; edx - new Screen_Max_Y |
5489 | ; edx - new Screen_Max_Y |
5485 | 5490 | ||
5486 | pushfd |
5491 | pushfd |
5487 | cli |
5492 | cli |
5488 | 5493 | ||
5489 | mov [_display.lfb_pitch], ecx |
5494 | mov [_display.lfb_pitch], ecx |
5490 | 5495 | ||
5491 | mov [screen_workarea.right], eax |
5496 | mov [screen_workarea.right], eax |
5492 | mov [screen_workarea.bottom], edx |
5497 | mov [screen_workarea.bottom], edx |
5493 | 5498 | ||
5494 | push ebx |
5499 | push ebx |
5495 | push esi |
5500 | push esi |
5496 | push edi |
5501 | push edi |
5497 | 5502 | ||
5498 | pushad |
5503 | pushad |
5499 | 5504 | ||
5500 | cmp [do_not_touch_winmap], 1 |
5505 | cmp [do_not_touch_winmap], 1 |
5501 | je @f |
5506 | je @f |
5502 | 5507 | ||
5503 | stdcall kernel_free, [_display.win_map] |
5508 | stdcall kernel_free, [_display.win_map] |
5504 | 5509 | ||
5505 | mov eax, [_display.width] |
5510 | mov eax, [_display.width] |
5506 | mul [_display.height] |
5511 | mul [_display.height] |
5507 | mov [_display.win_map_size], eax |
5512 | mov [_display.win_map_size], eax |
5508 | 5513 | ||
5509 | stdcall kernel_alloc, eax |
5514 | stdcall kernel_alloc, eax |
5510 | mov [_display.win_map], eax |
5515 | mov [_display.win_map], eax |
5511 | test eax, eax |
5516 | test eax, eax |
5512 | jz .epic_fail |
5517 | jz .epic_fail |
5513 | ; store for f.18.24 |
5518 | ; store for f.18.24 |
5514 | mov eax, [_display.width] |
5519 | mov eax, [_display.width] |
5515 | mov [display_width_standard], eax |
5520 | mov [display_width_standard], eax |
5516 | 5521 | ||
5517 | mov eax, [_display.height] |
5522 | mov eax, [_display.height] |
5518 | mov [display_height_standard], eax |
5523 | mov [display_height_standard], eax |
5519 | @@: |
5524 | @@: |
5520 | call calculate_fast_getting_offset_for_WinMapAddress |
5525 | call calculate_fast_getting_offset_for_WinMapAddress |
5521 | ; for Qemu or non standart video cards |
5526 | ; for Qemu or non standart video cards |
5522 | ; Unfortunately [BytesPerScanLine] does not always |
5527 | ; Unfortunately [BytesPerScanLine] does not always |
5523 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5528 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5524 | call calculate_fast_getting_offset_for_LFB |
5529 | call calculate_fast_getting_offset_for_LFB |
5525 | popad |
5530 | popad |
5526 | 5531 | ||
5527 | call repos_windows |
5532 | call repos_windows |
5528 | xor eax, eax |
5533 | xor eax, eax |
5529 | xor ebx, ebx |
5534 | xor ebx, ebx |
5530 | mov ecx, [_display.width] |
5535 | mov ecx, [_display.width] |
5531 | mov edx, [_display.height] |
5536 | mov edx, [_display.height] |
5532 | dec ecx |
5537 | dec ecx |
5533 | dec edx |
5538 | dec edx |
5534 | call calculatescreen |
5539 | call calculatescreen |
5535 | pop edi |
5540 | pop edi |
5536 | pop esi |
5541 | pop esi |
5537 | pop ebx |
5542 | pop ebx |
5538 | 5543 | ||
5539 | popfd |
5544 | popfd |
5540 | ret |
5545 | ret |
5541 | 5546 | ||
5542 | .epic_fail: |
5547 | .epic_fail: |
5543 | hlt ; Houston, we've had a problem |
5548 | hlt ; Houston, we've had a problem |
5544 | 5549 | ||
5545 | ; --------------- APM --------------------- |
5550 | ; --------------- APM --------------------- |
5546 | uglobal |
5551 | uglobal |
5547 | apm_entry dp 0 |
5552 | apm_entry dp 0 |
5548 | apm_vf dd 0 |
5553 | apm_vf dd 0 |
5549 | endg |
5554 | endg |
5550 | 5555 | ||
5551 | align 4 |
5556 | align 4 |
5552 | sys_apm: |
5557 | sys_apm: |
5553 | xor eax, eax |
5558 | xor eax, eax |
5554 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5559 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5555 | jne @f |
5560 | jne @f |
5556 | inc eax |
5561 | inc eax |
5557 | or dword [esp + 44], eax ; error |
5562 | or dword [esp + 44], eax ; error |
5558 | add eax, 7 |
5563 | add eax, 7 |
5559 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5564 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5560 | ret |
5565 | ret |
5561 | 5566 | ||
5562 | @@: |
5567 | @@: |
5563 | ; xchg eax, ecx |
5568 | ; xchg eax, ecx |
5564 | ; xchg ebx, ecx |
5569 | ; xchg ebx, ecx |
5565 | 5570 | ||
5566 | cmp dx, 3 |
5571 | cmp dx, 3 |
5567 | ja @f |
5572 | ja @f |
5568 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5573 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5569 | mov eax, [apm_vf] |
5574 | mov eax, [apm_vf] |
5570 | mov [esp + 32], eax |
5575 | mov [esp + 32], eax |
5571 | shr eax, 16 |
5576 | shr eax, 16 |
5572 | mov [esp + 28], eax |
5577 | mov [esp + 28], eax |
5573 | ret |
5578 | ret |
5574 | 5579 | ||
5575 | @@: |
5580 | @@: |
5576 | 5581 | ||
5577 | mov esi, [master_tab+(OS_BASE shr 20)] |
5582 | mov esi, [master_tab+(OS_BASE shr 20)] |
5578 | xchg [master_tab], esi |
5583 | xchg [master_tab], esi |
5579 | push esi |
5584 | push esi |
5580 | mov edi, cr3 |
5585 | mov edi, cr3 |
5581 | mov cr3, edi ;flush TLB |
5586 | mov cr3, edi ;flush TLB |
5582 | 5587 | ||
5583 | call pword [apm_entry] ;call APM BIOS |
5588 | call pword [apm_entry] ;call APM BIOS |
5584 | 5589 | ||
5585 | xchg eax, [esp] |
5590 | xchg eax, [esp] |
5586 | mov [master_tab], eax |
5591 | mov [master_tab], eax |
5587 | mov eax, cr3 |
5592 | mov eax, cr3 |
5588 | mov cr3, eax |
5593 | mov cr3, eax |
5589 | pop eax |
5594 | pop eax |
5590 | 5595 | ||
5591 | mov [esp + 4 ], edi |
5596 | mov [esp + 4 ], edi |
5592 | mov [esp + 8], esi |
5597 | mov [esp + 8], esi |
5593 | mov [esp + 20], ebx |
5598 | mov [esp + 20], ebx |
5594 | mov [esp + 24], edx |
5599 | mov [esp + 24], edx |
5595 | mov [esp + 28], ecx |
5600 | mov [esp + 28], ecx |
5596 | mov [esp + 32], eax |
5601 | mov [esp + 32], eax |
5597 | setc al |
5602 | setc al |
5598 | and [esp + 44], byte 0xfe |
5603 | and [esp + 44], byte 0xfe |
5599 | or [esp + 44], al |
5604 | or [esp + 44], al |
5600 | ret |
5605 | ret |
5601 | ; ----------------------------------------- |
5606 | ; ----------------------------------------- |
5602 | 5607 | ||
5603 | align 4 |
5608 | align 4 |
5604 | 5609 | ||
5605 | undefined_syscall: ; Undefined system call |
5610 | undefined_syscall: ; Undefined system call |
5606 | mov [esp + 32], dword -1 |
5611 | mov [esp + 32], dword -1 |
5607 | ret |
5612 | ret |
5608 | 5613 | ||
5609 | 5614 | ||
5610 | if ~ lang eq sp |
5615 | if ~ lang eq sp |
5611 | diff16 "end of .text segment",0,$ |
5616 | diff16 "end of .text segment",0,$ |
5612 | end if |
5617 | end if |
5613 | 5618 | ||
5614 | include "data32.inc" |
5619 | include "data32.inc" |
5615 | 5620 | ||
5616 | __REV__ = __REV |
5621 | __REV__ = __REV |
5617 | 5622 | ||
5618 | if ~ lang eq sp |
5623 | if ~ lang eq sp |
5619 | diff16 "end of kernel code",0,$ |
5624 | diff16 "end of kernel code",0,$ |
5620 | end if=> |
5625 | end if=> |