Rev 3606 | Rev 3613 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3606 | Rev 3611 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2012. 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: 3606 $ |
74 | $Revision: 3611 $ |
75 | 75 | ||
76 | 76 | ||
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
78 | 78 | ||
79 | ; Enabling the next line will enable serial output console |
79 | ; Enabling the next line will enable serial output console |
80 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
80 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
81 | ; The following constant, if nonzero, duplicates debug output to the screen. |
81 | ; The following constant, if nonzero, duplicates debug output to the screen. |
82 | debug_direct_print equ 0 |
82 | debug_direct_print equ 0 |
83 | 83 | ||
84 | include "proc32.inc" |
84 | include "proc32.inc" |
85 | include "kglobals.inc" |
85 | include "kglobals.inc" |
86 | include "lang.inc" |
86 | include "lang.inc" |
87 | include "encoding.inc" |
87 | include "encoding.inc" |
88 | 88 | ||
89 | include "const.inc" |
89 | include "const.inc" |
90 | max_processes equ 255 |
90 | max_processes equ 255 |
91 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
91 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
92 | 92 | ||
93 | 93 | ||
94 | os_stack equ (os_data_l-gdts) ; GDTs |
94 | os_stack equ (os_data_l-gdts) ; GDTs |
95 | os_code equ (os_code_l-gdts) |
95 | os_code equ (os_code_l-gdts) |
96 | graph_data equ (3+graph_data_l-gdts) |
96 | graph_data equ (3+graph_data_l-gdts) |
97 | tss0 equ (tss0_l-gdts) |
97 | tss0 equ (tss0_l-gdts) |
98 | app_code equ (3+app_code_l-gdts) |
98 | app_code equ (3+app_code_l-gdts) |
99 | app_data equ (3+app_data_l-gdts) |
99 | app_data equ (3+app_data_l-gdts) |
100 | app_tls equ (3+tls_data_l-gdts) |
100 | app_tls equ (3+tls_data_l-gdts) |
101 | pci_code_sel equ (pci_code_32-gdts) |
101 | pci_code_sel equ (pci_code_32-gdts) |
102 | pci_data_sel equ (pci_data_32-gdts) |
102 | pci_data_sel equ (pci_data_32-gdts) |
103 | 103 | ||
104 | 104 | ||
105 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
105 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
106 | ;; |
106 | ;; |
107 | ;; Included files: |
107 | ;; Included files: |
108 | ;; |
108 | ;; |
109 | ;; Kernel16.inc |
109 | ;; Kernel16.inc |
110 | ;; - Booteng.inc English text for bootup |
110 | ;; - Booteng.inc English text for bootup |
111 | ;; - Bootcode.inc Hardware setup |
111 | ;; - Bootcode.inc Hardware setup |
112 | ;; - Pci16.inc PCI functions |
112 | ;; - Pci16.inc PCI functions |
113 | ;; |
113 | ;; |
114 | ;; Kernel32.inc |
114 | ;; Kernel32.inc |
115 | ;; - Sys32.inc Process management |
115 | ;; - Sys32.inc Process management |
116 | ;; - Shutdown.inc Shutdown and restart |
116 | ;; - Shutdown.inc Shutdown and restart |
117 | ;; - Fat32.inc Read / write hd |
117 | ;; - Fat32.inc Read / write hd |
118 | ;; - Vesa12.inc Vesa 1.2 driver |
118 | ;; - Vesa12.inc Vesa 1.2 driver |
119 | ;; - Vesa20.inc Vesa 2.0 driver |
119 | ;; - Vesa20.inc Vesa 2.0 driver |
120 | ;; - Vga.inc VGA driver |
120 | ;; - Vga.inc VGA driver |
121 | ;; - Stack.inc Network interface |
121 | ;; - Stack.inc Network interface |
122 | ;; - Mouse.inc Mouse pointer |
122 | ;; - Mouse.inc Mouse pointer |
123 | ;; - Scincode.inc Window skinning |
123 | ;; - Scincode.inc Window skinning |
124 | ;; - Pci32.inc PCI functions |
124 | ;; - Pci32.inc PCI functions |
125 | ;; |
125 | ;; |
126 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
126 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
127 | 127 | ||
128 | 128 | ||
129 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
129 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
130 | ;; ;; |
130 | ;; ;; |
131 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
131 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
132 | ;; ;; |
132 | ;; ;; |
133 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
133 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
134 | 134 | ||
135 | use16 |
135 | use16 |
136 | org 0x0 |
136 | org 0x0 |
137 | jmp start_of_code |
137 | jmp start_of_code |
138 | 138 | ||
139 | if lang eq sp |
139 | if lang eq sp |
140 | include "kernelsp.inc" ; spanish kernel messages |
140 | include "kernelsp.inc" ; spanish kernel messages |
141 | else |
141 | else |
142 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
142 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
143 | end if |
143 | end if |
144 | 144 | ||
145 | include "boot/bootstr.inc" ; language-independent boot messages |
145 | include "boot/bootstr.inc" ; language-independent boot messages |
146 | include "boot/preboot.inc" |
146 | include "boot/preboot.inc" |
147 | 147 | ||
148 | if lang eq ge |
148 | if lang eq ge |
149 | include "boot/bootge.inc" ; german system boot messages |
149 | include "boot/bootge.inc" ; german system boot messages |
150 | else if lang eq sp |
150 | else if lang eq sp |
151 | include "boot/bootsp.inc" ; spanish system boot messages |
151 | include "boot/bootsp.inc" ; spanish system boot messages |
152 | else if lang eq ru |
152 | else if lang eq ru |
153 | include "boot/bootru.inc" ; russian system boot messages |
153 | include "boot/bootru.inc" ; russian system boot messages |
154 | include "boot/ru.inc" ; Russian font |
154 | include "boot/ru.inc" ; Russian font |
155 | else if lang eq et |
155 | else if lang eq et |
156 | include "boot/bootet.inc" ; estonian system boot messages |
156 | include "boot/bootet.inc" ; estonian system boot messages |
157 | include "boot/et.inc" ; Estonian font |
157 | include "boot/et.inc" ; Estonian font |
158 | else |
158 | else |
159 | include "boot/booten.inc" ; english system boot messages |
159 | include "boot/booten.inc" ; english system boot messages |
160 | end if |
160 | end if |
161 | 161 | ||
162 | include "boot/bootcode.inc" ; 16 bit system boot code |
162 | include "boot/bootcode.inc" ; 16 bit system boot code |
163 | include "bus/pci/pci16.inc" |
163 | include "bus/pci/pci16.inc" |
164 | include "detect/biosdisk.inc" |
164 | include "detect/biosdisk.inc" |
165 | 165 | ||
166 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
166 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
167 | ;; ;; |
167 | ;; ;; |
168 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
168 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
169 | ;; ;; |
169 | ;; ;; |
170 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
170 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
171 | 171 | ||
172 | 172 | ||
173 | ; CR0 Flags - Protected mode and Paging |
173 | ; CR0 Flags - Protected mode and Paging |
174 | 174 | ||
175 | mov ecx, CR0_PE |
175 | mov ecx, CR0_PE |
176 | 176 | ||
177 | ; Enabling 32 bit protected mode |
177 | ; Enabling 32 bit protected mode |
178 | 178 | ||
179 | sidt [cs:old_ints_h] |
179 | sidt [cs:old_ints_h] |
180 | 180 | ||
181 | cli ; disable all irqs |
181 | cli ; disable all irqs |
182 | cld |
182 | cld |
183 | mov al, 255 ; mask all irqs |
183 | mov al, 255 ; mask all irqs |
184 | out 0xa1, al |
184 | out 0xa1, al |
185 | out 0x21, al |
185 | out 0x21, al |
186 | l.5: |
186 | l.5: |
187 | in al, 0x64 ; Enable A20 |
187 | in al, 0x64 ; Enable A20 |
188 | test al, 2 |
188 | test al, 2 |
189 | jnz l.5 |
189 | jnz l.5 |
190 | mov al, 0xD1 |
190 | mov al, 0xD1 |
191 | out 0x64, al |
191 | out 0x64, al |
192 | l.6: |
192 | l.6: |
193 | in al, 0x64 |
193 | in al, 0x64 |
194 | test al, 2 |
194 | test al, 2 |
195 | jnz l.6 |
195 | jnz l.6 |
196 | mov al, 0xDF |
196 | mov al, 0xDF |
197 | out 0x60, al |
197 | out 0x60, al |
198 | l.7: |
198 | l.7: |
199 | in al, 0x64 |
199 | in al, 0x64 |
200 | test al, 2 |
200 | test al, 2 |
201 | jnz l.7 |
201 | jnz l.7 |
202 | mov al, 0xFF |
202 | mov al, 0xFF |
203 | out 0x64, al |
203 | out 0x64, al |
204 | 204 | ||
205 | lgdt [cs:tmp_gdt] ; Load GDT |
205 | lgdt [cs:tmp_gdt] ; Load GDT |
206 | mov eax, cr0 ; protected mode |
206 | mov eax, cr0 ; protected mode |
207 | or eax, ecx |
207 | or eax, ecx |
208 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
208 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
209 | mov cr0, eax |
209 | mov cr0, eax |
210 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
210 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
211 | 211 | ||
212 | align 8 |
212 | align 8 |
213 | tmp_gdt: |
213 | tmp_gdt: |
214 | 214 | ||
215 | dw 23 |
215 | dw 23 |
216 | dd tmp_gdt+0x10000 |
216 | dd tmp_gdt+0x10000 |
217 | dw 0 |
217 | dw 0 |
218 | 218 | ||
219 | dw 0xffff |
219 | dw 0xffff |
220 | dw 0x0000 |
220 | dw 0x0000 |
221 | db 0x00 |
221 | db 0x00 |
222 | dw 11011111b *256 +10011010b |
222 | dw 11011111b *256 +10011010b |
223 | db 0x00 |
223 | db 0x00 |
224 | 224 | ||
225 | dw 0xffff |
225 | dw 0xffff |
226 | dw 0x0000 |
226 | dw 0x0000 |
227 | db 0x00 |
227 | db 0x00 |
228 | dw 11011111b *256 +10010010b |
228 | dw 11011111b *256 +10010010b |
229 | db 0x00 |
229 | db 0x00 |
230 | 230 | ||
231 | include "data16.inc" |
231 | include "data16.inc" |
232 | 232 | ||
233 | use32 |
233 | use32 |
234 | org $+0x10000 |
234 | org $+0x10000 |
235 | 235 | ||
236 | align 4 |
236 | align 4 |
237 | B32: |
237 | B32: |
238 | mov ax, os_stack ; Selector for os |
238 | mov ax, os_stack ; Selector for os |
239 | mov ds, ax |
239 | mov ds, ax |
240 | mov es, ax |
240 | mov es, ax |
241 | mov fs, ax |
241 | mov fs, ax |
242 | mov gs, ax |
242 | mov gs, ax |
243 | mov ss, ax |
243 | mov ss, ax |
244 | mov esp, 0x006CC00 ; Set stack |
244 | mov esp, 0x006CC00 ; Set stack |
245 | 245 | ||
246 | ; CLEAR 0x280000 - HEAP_BASE |
246 | ; CLEAR 0x280000 - HEAP_BASE |
247 | 247 | ||
248 | xor eax, eax |
248 | xor eax, eax |
249 | mov edi, CLEAN_ZONE |
249 | mov edi, CLEAN_ZONE |
250 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
250 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
251 | cld |
251 | cld |
252 | rep stosd |
252 | rep stosd |
253 | 253 | ||
254 | ; CLEAR KERNEL UNDEFINED GLOBALS |
254 | ; CLEAR KERNEL UNDEFINED GLOBALS |
255 | mov edi, endofcode-OS_BASE |
255 | mov edi, endofcode-OS_BASE |
256 | mov ecx, 0x90000 |
256 | mov ecx, 0x90000 |
257 | sub ecx, edi |
257 | sub ecx, edi |
258 | shr ecx, 2 |
258 | shr ecx, 2 |
259 | rep stosd |
259 | rep stosd |
260 | 260 | ||
261 | ; SAVE & CLEAR 0-0xffff |
261 | ; SAVE & CLEAR 0-0xffff |
262 | 262 | ||
263 | xor esi, esi |
263 | xor esi, esi |
264 | mov edi, (BOOT_VAR-OS_BASE) |
264 | mov edi, (BOOT_VAR-OS_BASE) |
265 | mov ecx, 0x10000 / 4 |
265 | mov ecx, 0x10000 / 4 |
266 | rep movsd |
266 | rep movsd |
267 | mov edi, 0x1000 |
267 | mov edi, 0x1000 |
268 | mov ecx, 0xf000 / 4 |
268 | mov ecx, 0xf000 / 4 |
269 | rep stosd |
269 | rep stosd |
270 | 270 | ||
271 | call test_cpu |
271 | call test_cpu |
272 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
272 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
273 | 273 | ||
274 | call check_acpi |
274 | call check_acpi |
275 | call init_BIOS32 |
275 | call init_BIOS32 |
276 | ; MEMORY MODEL |
276 | ; MEMORY MODEL |
277 | call mem_test |
277 | call mem_test |
278 | call init_mem |
278 | call init_mem |
279 | call init_page_map |
279 | call init_page_map |
280 | 280 | ||
281 | ; ENABLE PAGING |
281 | ; ENABLE PAGING |
282 | 282 | ||
283 | mov eax, sys_pgdir-OS_BASE |
283 | mov eax, sys_pgdir-OS_BASE |
284 | mov cr3, eax |
284 | mov cr3, eax |
285 | 285 | ||
286 | mov eax, cr0 |
286 | mov eax, cr0 |
287 | or eax, CR0_PG+CR0_WP |
287 | or eax, CR0_PG+CR0_WP |
288 | mov cr0, eax |
288 | mov cr0, eax |
289 | 289 | ||
290 | lgdt [gdts] |
290 | lgdt [gdts] |
291 | jmp pword os_code:high_code |
291 | jmp pword os_code:high_code |
292 | 292 | ||
293 | align 4 |
293 | align 4 |
294 | bios32_entry dd ? |
294 | bios32_entry dd ? |
295 | tmp_page_tabs dd ? |
295 | tmp_page_tabs dd ? |
296 | 296 | ||
297 | use16 |
297 | use16 |
298 | org $-0x10000 |
298 | org $-0x10000 |
299 | include "boot/shutdown.inc" ; shutdown or restart |
299 | include "boot/shutdown.inc" ; shutdown or restart |
300 | org $+0x10000 |
300 | org $+0x10000 |
301 | use32 |
301 | use32 |
302 | 302 | ||
303 | __DEBUG__ fix 1 |
303 | __DEBUG__ fix 1 |
304 | __DEBUG_LEVEL__ fix 1 |
304 | __DEBUG_LEVEL__ fix 1 |
305 | include 'init.inc' |
305 | include 'init.inc' |
306 | 306 | ||
307 | org OS_BASE+$ |
307 | org OS_BASE+$ |
308 | 308 | ||
309 | include 'fdo.inc' |
309 | include 'fdo.inc' |
310 | 310 | ||
311 | align 4 |
311 | align 4 |
312 | high_code: |
312 | high_code: |
313 | mov ax, os_stack |
313 | mov ax, os_stack |
314 | mov bx, app_data |
314 | mov bx, app_data |
315 | mov cx, app_tls |
315 | mov cx, app_tls |
316 | mov ss, ax |
316 | mov ss, ax |
317 | add esp, OS_BASE |
317 | add esp, OS_BASE |
318 | 318 | ||
319 | mov ds, bx |
319 | mov ds, bx |
320 | mov es, bx |
320 | mov es, bx |
321 | mov fs, cx |
321 | mov fs, cx |
322 | mov gs, bx |
322 | mov gs, bx |
323 | 323 | ||
324 | bt [cpu_caps], CAPS_PGE |
324 | bt [cpu_caps], CAPS_PGE |
325 | jnc @F |
325 | jnc @F |
326 | 326 | ||
327 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
327 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
328 | 328 | ||
329 | mov ebx, cr4 |
329 | mov ebx, cr4 |
330 | or ebx, CR4_PGE |
330 | or ebx, CR4_PGE |
331 | mov cr4, ebx |
331 | mov cr4, ebx |
332 | @@: |
332 | @@: |
333 | xor eax, eax |
333 | xor eax, eax |
334 | mov dword [sys_pgdir], eax |
334 | mov dword [sys_pgdir], eax |
335 | mov dword [sys_pgdir+4], eax |
335 | mov dword [sys_pgdir+4], eax |
336 | 336 | ||
337 | mov eax, cr3 |
337 | mov eax, cr3 |
338 | mov cr3, eax ; flush TLB |
338 | mov cr3, eax ; flush TLB |
339 | 339 | ||
340 | mov ecx, pg_data.mutex |
340 | mov ecx, pg_data.mutex |
341 | call mutex_init |
341 | call mutex_init |
342 | 342 | ||
343 | mov ecx, disk_list_mutex |
343 | mov ecx, disk_list_mutex |
344 | call mutex_init |
344 | call mutex_init |
345 | 345 | ||
346 | mov ecx, keyboard_list_mutex |
346 | mov ecx, keyboard_list_mutex |
347 | call mutex_init |
347 | call mutex_init |
348 | 348 | ||
349 | mov ecx, unpack_mutex |
349 | mov ecx, unpack_mutex |
350 | call mutex_init |
350 | call mutex_init |
351 | 351 | ||
352 | mov ecx, application_table_mutex |
352 | mov ecx, application_table_mutex |
353 | call mutex_init |
353 | call mutex_init |
354 | 354 | ||
355 | ; SAVE REAL MODE VARIABLES |
355 | ; SAVE REAL MODE VARIABLES |
356 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
356 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
357 | mov [IDEContrRegsBaseAddr], ax |
357 | mov [IDEContrRegsBaseAddr], ax |
358 | ; --------------- APM --------------------- |
358 | ; --------------- APM --------------------- |
359 | 359 | ||
360 | ; init selectors |
360 | ; init selectors |
361 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
361 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
362 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
362 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
363 | ; protected-mode 32-bit code segment |
363 | ; protected-mode 32-bit code segment |
364 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
364 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
365 | ; protected-mode 16-bit code segment |
365 | ; protected-mode 16-bit code segment |
366 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
366 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
367 | ; protected-mode 16-bit data segment |
367 | ; protected-mode 16-bit data segment |
368 | 368 | ||
369 | shl eax, 4 |
369 | shl eax, 4 |
370 | mov [dword apm_code_32 + 2], ax |
370 | mov [dword apm_code_32 + 2], ax |
371 | shr eax, 16 |
371 | shr eax, 16 |
372 | mov [dword apm_code_32 + 4], al |
372 | mov [dword apm_code_32 + 4], al |
373 | 373 | ||
374 | shl ecx, 4 |
374 | shl ecx, 4 |
375 | mov [dword apm_code_16 + 2], cx |
375 | mov [dword apm_code_16 + 2], cx |
376 | shr ecx, 16 |
376 | shr ecx, 16 |
377 | mov [dword apm_code_16 + 4], cl |
377 | mov [dword apm_code_16 + 4], cl |
378 | 378 | ||
379 | shl edx, 4 |
379 | shl edx, 4 |
380 | mov [dword apm_data_16 + 2], dx |
380 | mov [dword apm_data_16 + 2], dx |
381 | shr edx, 16 |
381 | shr edx, 16 |
382 | mov [dword apm_data_16 + 4], dl |
382 | mov [dword apm_data_16 + 4], dl |
383 | 383 | ||
384 | mov dword[apm_entry], ebx |
384 | mov dword[apm_entry], ebx |
385 | mov word [apm_entry + 4], apm_code_32 - gdts |
385 | mov word [apm_entry + 4], apm_code_32 - gdts |
386 | 386 | ||
387 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
387 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
388 | mov [apm_vf], eax |
388 | mov [apm_vf], eax |
389 | ; ----------------------------------------- |
389 | ; ----------------------------------------- |
390 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
390 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
391 | mov [allow_dma_access], al |
391 | mov [allow_dma_access], al |
392 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
392 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
393 | mov [_display.bpp], eax |
393 | mov [_display.bpp], eax |
394 | mov [_display.vrefresh], 60 |
394 | mov [_display.vrefresh], 60 |
395 | 395 | ||
396 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
396 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
397 | mov [_display.width], eax |
397 | mov [_display.width], eax |
398 | mov [display_width_standard], eax |
398 | mov [display_width_standard], eax |
399 | dec eax |
399 | dec eax |
400 | mov [Screen_Max_X], eax |
400 | mov [Screen_Max_X], eax |
401 | mov [screen_workarea.right], eax |
401 | mov [screen_workarea.right], eax |
402 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
402 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
403 | mov [_display.height], eax |
403 | mov [_display.height], eax |
404 | mov [display_height_standard], eax |
404 | mov [display_height_standard], eax |
405 | dec eax |
405 | dec eax |
406 | mov [Screen_Max_Y], eax |
406 | mov [Screen_Max_Y], eax |
407 | mov [screen_workarea.bottom], eax |
407 | mov [screen_workarea.bottom], eax |
408 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE] ; screen mode |
408 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE] ; screen mode |
409 | mov dword [SCR_MODE], eax |
409 | mov dword [SCR_MODE], eax |
410 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
410 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
411 | ; mov [BANK_SWITCH], eax |
411 | ; mov [BANK_SWITCH], eax |
412 | mov eax, 640 *4 ; Bytes PerScanLine |
412 | mov eax, 640 *4 ; Bytes PerScanLine |
413 | cmp [SCR_MODE], word 0x13 ; 320x200 |
413 | cmp [SCR_MODE], word 0x13 ; 320x200 |
414 | je @f |
414 | je @f |
415 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
415 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
416 | je @f |
416 | je @f |
417 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
417 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
418 | @@: |
418 | @@: |
419 | mov [_display.pitch], eax |
419 | mov [_display.pitch], eax |
420 | mov eax, [_display.width] |
420 | mov eax, [_display.width] |
421 | mul [_display.height] |
421 | mul [_display.height] |
422 | mov [_WinMapSize], eax |
422 | mov [_WinMapSize], eax |
423 | 423 | ||
424 | call calculate_fast_getting_offset_for_WinMapAddress |
424 | call calculate_fast_getting_offset_for_WinMapAddress |
425 | ; for Qemu or non standart video cards |
425 | ; for Qemu or non standart video cards |
426 | ; Unfortunately [BytesPerScanLine] does not always |
426 | ; Unfortunately [BytesPerScanLine] does not always |
427 | ; equal to [_display.width] * [ScreenBPP] / 8 |
427 | ; equal to [_display.width] * [ScreenBPP] / 8 |
428 | call calculate_fast_getting_offset_for_LFB |
428 | call calculate_fast_getting_offset_for_LFB |
429 | 429 | ||
430 | mov esi, BOOT_VAR+0x9080 |
430 | mov esi, BOOT_VAR+0x9080 |
431 | movzx ecx, byte [esi-1] |
431 | movzx ecx, byte [esi-1] |
432 | mov [NumBiosDisks], ecx |
432 | mov [NumBiosDisks], ecx |
433 | mov edi, BiosDisksData |
433 | mov edi, BiosDisksData |
434 | rep movsd |
434 | rep movsd |
435 | 435 | ||
436 | ; GRAPHICS ADDRESSES |
436 | ; GRAPHICS ADDRESSES |
437 | 437 | ||
438 | mov eax, [BOOT_VAR+BOOT_LFB] |
438 | mov eax, [BOOT_VAR+BOOT_LFB] |
439 | mov [LFBAddress], eax |
439 | mov [LFBAddress], eax |
440 | 440 | ||
441 | cmp [SCR_MODE], word 0100000000000000b |
441 | cmp [SCR_MODE], word 0100000000000000b |
442 | jge setvesa20 |
442 | jge setvesa20 |
443 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
443 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
444 | je v20ga32 |
444 | je v20ga32 |
445 | jmp v20ga24 |
445 | jmp v20ga24 |
446 | 446 | ||
447 | setvesa20: |
447 | setvesa20: |
448 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
448 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
449 | mov [GETPIXEL], dword Vesa20_getpixel24 |
449 | mov [GETPIXEL], dword Vesa20_getpixel24 |
450 | cmp byte [_display.bpp], 24 |
450 | cmp byte [_display.bpp], 24 |
451 | jz v20ga24 |
451 | jz v20ga24 |
452 | v20ga32: |
452 | v20ga32: |
453 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
453 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
454 | mov [GETPIXEL], dword Vesa20_getpixel32 |
454 | mov [GETPIXEL], dword Vesa20_getpixel32 |
455 | jmp no_mode_0x12 |
455 | jmp no_mode_0x12 |
456 | v20ga24: |
456 | v20ga24: |
457 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
457 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
458 | jne no_mode_0x12 |
458 | jne no_mode_0x12 |
459 | mov [PUTPIXEL], dword VGA_putpixel |
459 | mov [PUTPIXEL], dword VGA_putpixel |
460 | mov [GETPIXEL], dword Vesa20_getpixel32 |
460 | mov [GETPIXEL], dword Vesa20_getpixel32 |
461 | no_mode_0x12: |
461 | no_mode_0x12: |
462 | 462 | ||
463 | mov [MOUSE_PICTURE], dword mousepointer |
463 | mov [MOUSE_PICTURE], dword mousepointer |
464 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
464 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
465 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
465 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
466 | 466 | ||
467 | ; -------- Fast System Call init ---------- |
467 | ; -------- Fast System Call init ---------- |
468 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
468 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
469 | bt [cpu_caps], CAPS_SEP |
469 | bt [cpu_caps], CAPS_SEP |
470 | jnc .SEnP ; SysEnter not Present |
470 | jnc .SEnP ; SysEnter not Present |
471 | xor edx, edx |
471 | xor edx, edx |
472 | mov ecx, MSR_SYSENTER_CS |
472 | mov ecx, MSR_SYSENTER_CS |
473 | mov eax, os_code |
473 | mov eax, os_code |
474 | wrmsr |
474 | wrmsr |
475 | mov ecx, MSR_SYSENTER_ESP |
475 | mov ecx, MSR_SYSENTER_ESP |
476 | ; mov eax, sysenter_stack ; Check it |
476 | ; mov eax, sysenter_stack ; Check it |
477 | xor eax, eax |
477 | xor eax, eax |
478 | wrmsr |
478 | wrmsr |
479 | mov ecx, MSR_SYSENTER_EIP |
479 | mov ecx, MSR_SYSENTER_EIP |
480 | mov eax, sysenter_entry |
480 | mov eax, sysenter_entry |
481 | wrmsr |
481 | wrmsr |
482 | .SEnP: |
482 | .SEnP: |
483 | ; AMD SYSCALL/SYSRET |
483 | ; AMD SYSCALL/SYSRET |
484 | cmp byte[cpu_vendor], 'A' |
484 | cmp byte[cpu_vendor], 'A' |
485 | jne .noSYSCALL |
485 | jne .noSYSCALL |
486 | mov eax, 0x80000001 |
486 | mov eax, 0x80000001 |
487 | cpuid |
487 | cpuid |
488 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
488 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
489 | jz .noSYSCALL |
489 | jz .noSYSCALL |
490 | mov ecx, MSR_AMD_EFER |
490 | mov ecx, MSR_AMD_EFER |
491 | rdmsr |
491 | rdmsr |
492 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
492 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
493 | wrmsr |
493 | wrmsr |
494 | 494 | ||
495 | ; !!!! It`s dirty hack, fix it !!! |
495 | ; !!!! It`s dirty hack, fix it !!! |
496 | ; Bits of EDX : |
496 | ; Bits of EDX : |
497 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
497 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
498 | ; and the contents of this field, plus 8, are copied into the SS register. |
498 | ; and the contents of this field, plus 8, are copied into the SS register. |
499 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
499 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
500 | ; and the contents of this field, plus 8, are copied into the SS register. |
500 | ; and the contents of this field, plus 8, are copied into the SS register. |
501 | 501 | ||
502 | ; mov edx, (os_code + 16) * 65536 + os_code |
502 | ; mov edx, (os_code + 16) * 65536 + os_code |
503 | mov edx, 0x1B0008 |
503 | mov edx, 0x1B0008 |
504 | 504 | ||
505 | mov eax, syscall_entry |
505 | mov eax, syscall_entry |
506 | mov ecx, MSR_AMD_STAR |
506 | mov ecx, MSR_AMD_STAR |
507 | wrmsr |
507 | wrmsr |
508 | .noSYSCALL: |
508 | .noSYSCALL: |
509 | ; ----------------------------------------- |
509 | ; ----------------------------------------- |
510 | stdcall alloc_page |
510 | stdcall alloc_page |
511 | stdcall map_page, tss-0xF80, eax, PG_SW |
511 | stdcall map_page, tss-0xF80, eax, PG_SW |
512 | stdcall alloc_page |
512 | stdcall alloc_page |
513 | stdcall map_page, tss+0x80, eax, PG_SW |
513 | stdcall map_page, tss+0x80, eax, PG_SW |
514 | stdcall alloc_page |
514 | stdcall alloc_page |
515 | stdcall map_page, tss+0x1080, eax, PG_SW |
515 | stdcall map_page, tss+0x1080, eax, PG_SW |
516 | 516 | ||
517 | ; LOAD IDT |
517 | ; LOAD IDT |
518 | 518 | ||
519 | call build_interrupt_table ;lidt is executed |
519 | call build_interrupt_table ;lidt is executed |
520 | ;lidt [idtreg] |
520 | ;lidt [idtreg] |
521 | 521 | ||
522 | call init_kernel_heap |
522 | call init_kernel_heap |
523 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
523 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
524 | mov [os_stack_seg], eax |
524 | mov [os_stack_seg], eax |
525 | 525 | ||
526 | lea esp, [eax+RING0_STACK_SIZE] |
526 | lea esp, [eax+RING0_STACK_SIZE] |
527 | 527 | ||
528 | mov [tss._ss0], os_stack |
528 | mov [tss._ss0], os_stack |
529 | mov [tss._esp0], esp |
529 | mov [tss._esp0], esp |
530 | mov [tss._esp], esp |
530 | mov [tss._esp], esp |
531 | mov [tss._cs], os_code |
531 | mov [tss._cs], os_code |
532 | mov [tss._ss], os_stack |
532 | mov [tss._ss], os_stack |
533 | mov [tss._ds], app_data |
533 | mov [tss._ds], app_data |
534 | mov [tss._es], app_data |
534 | mov [tss._es], app_data |
535 | mov [tss._fs], app_data |
535 | mov [tss._fs], app_data |
536 | mov [tss._gs], app_data |
536 | mov [tss._gs], app_data |
537 | mov [tss._io], 128 |
537 | mov [tss._io], 128 |
538 | ;Add IO access table - bit array of permitted ports |
538 | ;Add IO access table - bit array of permitted ports |
539 | mov edi, tss._io_map_0 |
539 | mov edi, tss._io_map_0 |
540 | xor eax, eax |
540 | xor eax, eax |
541 | not eax |
541 | not eax |
542 | mov ecx, 8192/4 |
542 | mov ecx, 8192/4 |
543 | rep stosd ; access to 4096*8=65536 ports |
543 | rep stosd ; access to 4096*8=65536 ports |
544 | 544 | ||
545 | mov ax, tss0 |
545 | mov ax, tss0 |
546 | ltr ax |
546 | ltr ax |
547 | 547 | ||
548 | mov [LFBSize], 0xC00000 |
548 | mov [LFBSize], 0xC00000 |
549 | call init_LFB |
549 | call init_LFB |
550 | call init_fpu |
550 | call init_fpu |
551 | call init_malloc |
551 | call init_malloc |
552 | 552 | ||
553 | stdcall alloc_kernel_space, 0x51000 |
553 | stdcall alloc_kernel_space, 0x51000 |
554 | mov [default_io_map], eax |
554 | mov [default_io_map], eax |
555 | 555 | ||
556 | add eax, 0x2000 |
556 | add eax, 0x2000 |
557 | mov [ipc_tmp], eax |
557 | mov [ipc_tmp], eax |
558 | mov ebx, 0x1000 |
558 | mov ebx, 0x1000 |
559 | 559 | ||
560 | add eax, 0x40000 |
560 | add eax, 0x40000 |
561 | mov [proc_mem_map], eax |
561 | mov [proc_mem_map], eax |
562 | 562 | ||
563 | add eax, 0x8000 |
563 | add eax, 0x8000 |
564 | mov [proc_mem_pdir], eax |
564 | mov [proc_mem_pdir], eax |
565 | 565 | ||
566 | add eax, ebx |
566 | add eax, ebx |
567 | mov [proc_mem_tab], eax |
567 | mov [proc_mem_tab], eax |
568 | 568 | ||
569 | add eax, ebx |
569 | add eax, ebx |
570 | mov [tmp_task_pdir], eax |
570 | mov [tmp_task_pdir], eax |
571 | 571 | ||
572 | add eax, ebx |
572 | add eax, ebx |
573 | mov [tmp_task_ptab], eax |
573 | mov [tmp_task_ptab], eax |
574 | 574 | ||
575 | add eax, ebx |
575 | add eax, ebx |
576 | mov [ipc_pdir], eax |
576 | mov [ipc_pdir], eax |
577 | 577 | ||
578 | add eax, ebx |
578 | add eax, ebx |
579 | mov [ipc_ptab], eax |
579 | mov [ipc_ptab], eax |
580 | 580 | ||
581 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
581 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
582 | (unpack.lc+unpack.lp)))*4 |
582 | (unpack.lc+unpack.lp)))*4 |
583 | 583 | ||
584 | mov [unpack.p], eax |
584 | mov [unpack.p], eax |
585 | 585 | ||
586 | call init_events |
586 | call init_events |
587 | mov eax, srv.fd-SRV.fd |
587 | mov eax, srv.fd-SRV.fd |
588 | mov [srv.fd], eax |
588 | mov [srv.fd], eax |
589 | mov [srv.bk], eax |
589 | mov [srv.bk], eax |
590 | 590 | ||
591 | ;Set base of graphic segment to linear address of LFB |
591 | ;Set base of graphic segment to linear address of LFB |
592 | mov eax, [LFBAddress] ; set for gs |
592 | mov eax, [LFBAddress] ; set for gs |
593 | mov [graph_data_l+2], ax |
593 | mov [graph_data_l+2], ax |
594 | shr eax, 16 |
594 | shr eax, 16 |
595 | mov [graph_data_l+4], al |
595 | mov [graph_data_l+4], al |
596 | mov [graph_data_l+7], ah |
596 | mov [graph_data_l+7], ah |
597 | 597 | ||
598 | stdcall kernel_alloc, [_WinMapSize] |
598 | stdcall kernel_alloc, [_WinMapSize] |
599 | mov [_WinMapAddress], eax |
599 | mov [_WinMapAddress], eax |
600 | 600 | ||
601 | xor eax, eax |
601 | xor eax, eax |
602 | inc eax |
602 | inc eax |
603 | 603 | ||
604 | ; set background |
604 | ; set background |
605 | 605 | ||
606 | mov [BgrDrawMode], eax |
606 | mov [BgrDrawMode], eax |
607 | mov [BgrDataWidth], eax |
607 | mov [BgrDataWidth], eax |
608 | mov [BgrDataHeight], eax |
608 | mov [BgrDataHeight], eax |
609 | mov [mem_BACKGROUND], 4 |
609 | mov [mem_BACKGROUND], 4 |
610 | mov [img_background], static_background_data |
610 | mov [img_background], static_background_data |
611 | 611 | ||
612 | ; SET UP OS TASK |
612 | ; SET UP OS TASK |
613 | 613 | ||
614 | mov esi, boot_setostask |
614 | mov esi, boot_setostask |
615 | call boot_log |
615 | call boot_log |
616 | 616 | ||
617 | mov edx, SLOT_BASE+256 |
617 | mov edx, SLOT_BASE+256 |
618 | mov ebx, [os_stack_seg] |
618 | mov ebx, [os_stack_seg] |
619 | add ebx, 0x2000 |
619 | add ebx, 0x2000 |
620 | call setup_os_slot |
620 | call setup_os_slot |
621 | mov dword [edx], 'IDLE' |
621 | mov dword [edx], 'IDLE' |
622 | sub [edx+APPDATA.saved_esp], 4 |
622 | sub [edx+APPDATA.saved_esp], 4 |
623 | mov eax, [edx+APPDATA.saved_esp] |
623 | mov eax, [edx+APPDATA.saved_esp] |
624 | mov dword [eax], idle_thread |
624 | mov dword [eax], idle_thread |
625 | mov ecx, IDLE_PRIORITY |
625 | mov ecx, IDLE_PRIORITY |
626 | call scheduler_add_thread |
626 | call scheduler_add_thread |
627 | 627 | ||
628 | mov edx, SLOT_BASE+256*2 |
628 | mov edx, SLOT_BASE+256*2 |
629 | mov ebx, [os_stack_seg] |
629 | mov ebx, [os_stack_seg] |
630 | call setup_os_slot |
630 | call setup_os_slot |
631 | mov dword [edx], 'OS' |
631 | mov dword [edx], 'OS' |
632 | xor ecx, ecx |
632 | xor ecx, ecx |
633 | call scheduler_add_thread |
633 | call scheduler_add_thread |
634 | 634 | ||
635 | mov dword [CURRENT_TASK], 2 |
635 | mov dword [CURRENT_TASK], 2 |
636 | mov dword [TASK_COUNT], 2 |
636 | mov dword [TASK_COUNT], 2 |
637 | mov dword [current_slot], SLOT_BASE + 256*2 |
637 | mov dword [current_slot], SLOT_BASE + 256*2 |
638 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
638 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
639 | 639 | ||
640 | 640 | ||
641 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
641 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
642 | mov esi, boot_initirq |
642 | mov esi, boot_initirq |
643 | call boot_log |
643 | call boot_log |
644 | call init_irqs |
644 | call init_irqs |
645 | 645 | ||
646 | mov esi, boot_picinit |
646 | mov esi, boot_picinit |
647 | call boot_log |
647 | call boot_log |
648 | call PIC_init |
648 | call PIC_init |
649 | 649 | ||
650 | mov esi, boot_v86machine |
650 | mov esi, boot_v86machine |
651 | call boot_log |
651 | call boot_log |
652 | ; Initialize system V86 machine |
652 | ; Initialize system V86 machine |
653 | call init_sys_v86 |
653 | call init_sys_v86 |
654 | 654 | ||
655 | mov esi, boot_inittimer |
655 | mov esi, boot_inittimer |
656 | call boot_log |
656 | call boot_log |
657 | ; Initialize system timer (IRQ0) |
657 | ; Initialize system timer (IRQ0) |
658 | call PIT_init |
658 | call PIT_init |
659 | 659 | ||
660 | mov esi, boot_initapic |
660 | mov esi, boot_initapic |
661 | call boot_log |
661 | call boot_log |
662 | ; Try to Initialize APIC |
662 | ; Try to Initialize APIC |
663 | call APIC_init |
663 | call APIC_init |
664 | 664 | ||
665 | mov esi, boot_enableirq |
665 | mov esi, boot_enableirq |
666 | call boot_log |
666 | call boot_log |
667 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
667 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
668 | ; they are used: when partitions are scanned, hd_read relies on timer |
668 | ; they are used: when partitions are scanned, hd_read relies on timer |
669 | call unmask_timer |
669 | call unmask_timer |
670 | stdcall enable_irq, 2 ; @#$%! PIC |
670 | stdcall enable_irq, 2 ; @#$%! PIC |
671 | stdcall enable_irq, 6 ; FDD |
671 | stdcall enable_irq, 6 ; FDD |
672 | stdcall enable_irq, 13 ; co-processor |
672 | stdcall enable_irq, 13 ; co-processor |
673 | stdcall enable_irq, 14 |
673 | stdcall enable_irq, 14 |
674 | stdcall enable_irq, 15 |
674 | stdcall enable_irq, 15 |
675 | 675 | ||
676 | mov esi, boot_enablint_ide |
676 | mov esi, boot_enablint_ide |
677 | call boot_log |
677 | call boot_log |
678 | ; Enable interrupts in IDE controller |
678 | ; Enable interrupts in IDE controller |
679 | mov al, 0 |
679 | mov al, 0 |
680 | mov dx, 0x3F6 |
680 | mov dx, 0x3F6 |
681 | out dx, al |
681 | out dx, al |
682 | mov dl, 0x76 |
682 | mov dl, 0x76 |
683 | out dx, al |
683 | out dx, al |
684 | 684 | ||
685 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
685 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
686 | ; mov esi, boot_detectdisks |
686 | ; mov esi, boot_detectdisks |
687 | ; call boot_log |
687 | ; call boot_log |
688 | ;include 'detect/disks.inc' |
688 | ;include 'detect/disks.inc' |
689 | mov esi, boot_detectfloppy |
689 | mov esi, boot_detectfloppy |
690 | call boot_log |
690 | call boot_log |
691 | include 'detect/dev_fd.inc' |
691 | include 'detect/dev_fd.inc' |
692 | mov esi, boot_detecthdcd |
692 | mov esi, boot_detecthdcd |
693 | call boot_log |
693 | call boot_log |
694 | include 'detect/dev_hdcd.inc' |
694 | include 'detect/dev_hdcd.inc' |
695 | mov esi, boot_getcache |
695 | mov esi, boot_getcache |
696 | call boot_log |
696 | call boot_log |
697 | include 'detect/getcache.inc' |
697 | include 'detect/getcache.inc' |
698 | mov esi, boot_detectpart |
698 | mov esi, boot_detectpart |
699 | call boot_log |
699 | call boot_log |
700 | include 'detect/sear_par.inc' |
700 | include 'detect/sear_par.inc' |
701 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
701 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
702 | 702 | ||
703 | mov esi, boot_init_sys |
703 | mov esi, boot_init_sys |
704 | call boot_log |
704 | call boot_log |
705 | call Parser_params |
705 | call Parser_params |
706 | 706 | ||
707 | if ~ defined extended_primary_loader |
707 | if ~ defined extended_primary_loader |
708 | ; ramdisk image should be loaded by extended primary loader if it exists |
708 | ; ramdisk image should be loaded by extended primary loader if it exists |
709 | ; READ RAMDISK IMAGE FROM HD |
709 | ; READ RAMDISK IMAGE FROM HD |
710 | 710 | ||
711 | ;!!!!!!!!!!!!!!!!!!!!!!! |
711 | ;!!!!!!!!!!!!!!!!!!!!!!! |
712 | include 'boot/rdload.inc' |
712 | include 'boot/rdload.inc' |
713 | ;!!!!!!!!!!!!!!!!!!!!!!! |
713 | ;!!!!!!!!!!!!!!!!!!!!!!! |
714 | end if |
714 | end if |
715 | ; mov [dma_hdd],1 |
715 | ; mov [dma_hdd],1 |
716 | ; CALCULATE FAT CHAIN FOR RAMDISK |
716 | ; CALCULATE FAT CHAIN FOR RAMDISK |
717 | 717 | ||
718 | call calculatefatchain |
718 | call calculatefatchain |
719 | 719 | ||
720 | if 0 |
720 | if 0 |
721 | mov ax, [OS_BASE+0x10000+bx_from_load] |
721 | mov ax, [OS_BASE+0x10000+bx_from_load] |
722 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
722 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
723 | je no_lib_load |
723 | je no_lib_load |
724 | 724 | ||
725 | mov esi, boot_loadlibs |
725 | mov esi, boot_loadlibs |
726 | call boot_log |
726 | call boot_log |
727 | ; LOADING LIBRARES |
727 | ; LOADING LIBRARES |
728 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
728 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
729 | call load_file_parse_table ; prepare file parse table |
729 | call load_file_parse_table ; prepare file parse table |
730 | call set_kernel_conf ; configure devices and gui |
730 | call set_kernel_conf ; configure devices and gui |
731 | no_lib_load: |
731 | no_lib_load: |
732 | end if |
732 | end if |
733 | 733 | ||
734 | ; Display APIC status |
734 | ; Display APIC status |
735 | mov esi, boot_APIC_found |
735 | mov esi, boot_APIC_found |
736 | cmp [irq_mode], IRQ_APIC |
736 | cmp [irq_mode], IRQ_APIC |
737 | je @f |
737 | je @f |
738 | mov esi, boot_APIC_nfound |
738 | mov esi, boot_APIC_nfound |
739 | @@: |
739 | @@: |
740 | call boot_log |
740 | call boot_log |
741 | 741 | ||
742 | ; PRINT AMOUNT OF MEMORY |
742 | ; PRINT AMOUNT OF MEMORY |
743 | mov esi, boot_memdetect |
743 | mov esi, boot_memdetect |
744 | call boot_log |
744 | call boot_log |
745 | 745 | ||
746 | movzx ecx, word [boot_y] |
746 | movzx ecx, word [boot_y] |
747 | if lang eq ru |
747 | if lang eq ru |
748 | or ecx, (10+30*6) shl 16 |
748 | or ecx, (10+30*6) shl 16 |
749 | else if lang eq sp |
749 | else if lang eq sp |
750 | or ecx, (10+33*6) shl 16 |
750 | or ecx, (10+33*6) shl 16 |
751 | else |
751 | else |
752 | or ecx, (10+29*6) shl 16 |
752 | or ecx, (10+29*6) shl 16 |
753 | end if |
753 | end if |
754 | sub ecx, 10 |
754 | sub ecx, 10 |
755 | mov edx, 0xFFFFFF |
755 | mov edx, 0xFFFFFF |
756 | mov ebx, [MEM_AMOUNT] |
756 | mov ebx, [MEM_AMOUNT] |
757 | shr ebx, 20 |
757 | shr ebx, 20 |
758 | xor edi, edi |
758 | xor edi, edi |
759 | mov eax, 0x00040000 |
759 | mov eax, 0x00040000 |
760 | inc edi |
760 | inc edi |
761 | call display_number_force |
761 | call display_number_force |
762 | 762 | ||
763 | ; BUILD SCHEDULER |
763 | ; BUILD SCHEDULER |
764 | 764 | ||
765 | ; call build_scheduler; sys32.inc |
765 | ; call build_scheduler; sys32.inc |
766 | 766 | ||
767 | ; mov esi, boot_devices |
767 | ; mov esi, boot_devices |
768 | ; call boot_log |
768 | ; call boot_log |
769 | 769 | ||
770 | mov [pci_access_enabled], 1 |
770 | mov [pci_access_enabled], 1 |
771 | call pci_enum |
771 | call pci_enum |
772 | 772 | ||
773 | stdcall load_driver, szVidintel |
773 | stdcall load_driver, szVidintel |
774 | 774 | ||
775 | call usb_init |
775 | call usb_init |
776 | 776 | ||
777 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
777 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
778 | 778 | ||
779 | mov esi, boot_windefs |
779 | mov esi, boot_windefs |
780 | call boot_log |
780 | call boot_log |
781 | call set_window_defaults |
781 | call set_window_defaults |
782 | 782 | ||
783 | ; SET BACKGROUND DEFAULTS |
783 | ; SET BACKGROUND DEFAULTS |
784 | 784 | ||
785 | mov esi, boot_bgr |
785 | mov esi, boot_bgr |
786 | call boot_log |
786 | call boot_log |
787 | call init_background |
787 | call init_background |
788 | call calculatebackground |
788 | call calculatebackground |
789 | 789 | ||
790 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
790 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
791 | 791 | ||
792 | mov esi, boot_resirqports |
792 | mov esi, boot_resirqports |
793 | call boot_log |
793 | call boot_log |
794 | call reserve_irqs_ports |
794 | call reserve_irqs_ports |
795 | 795 | ||
796 | call init_display |
796 | call init_display |
797 | mov eax, [def_cursor] |
797 | mov eax, [def_cursor] |
798 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
798 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
799 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
799 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
800 | 800 | ||
801 | ; PRINT CPU FREQUENCY |
801 | ; PRINT CPU FREQUENCY |
802 | 802 | ||
803 | mov esi, boot_cpufreq |
803 | mov esi, boot_cpufreq |
804 | call boot_log |
804 | call boot_log |
805 | 805 | ||
806 | cli ;FIXME check IF |
806 | cli ;FIXME check IF |
807 | rdtsc |
807 | rdtsc |
808 | mov ecx, eax |
808 | mov ecx, eax |
809 | mov esi, 250 ; wait 1/4 a second |
809 | mov esi, 250 ; wait 1/4 a second |
810 | call delay_ms |
810 | call delay_ms |
811 | rdtsc |
811 | rdtsc |
812 | 812 | ||
813 | sub eax, ecx |
813 | sub eax, ecx |
814 | xor edx, edx |
814 | xor edx, edx |
815 | shld edx, eax, 2 |
815 | shld edx, eax, 2 |
816 | shl eax, 2 |
816 | shl eax, 2 |
817 | mov dword [cpu_freq], eax |
817 | mov dword [cpu_freq], eax |
818 | mov dword [cpu_freq+4], edx |
818 | mov dword [cpu_freq+4], edx |
819 | mov ebx, 1000000 |
819 | mov ebx, 1000000 |
820 | div ebx |
820 | div ebx |
821 | mov ebx, eax |
821 | mov ebx, eax |
822 | 822 | ||
823 | movzx ecx, word [boot_y] |
823 | movzx ecx, word [boot_y] |
824 | if lang eq ru |
824 | if lang eq ru |
825 | add ecx, (10+19*6) shl 16 - 10 |
825 | add ecx, (10+19*6) shl 16 - 10 |
826 | else if lang eq sp |
826 | else if lang eq sp |
827 | add ecx, (10+25*6) shl 16 - 10 |
827 | add ecx, (10+25*6) shl 16 - 10 |
828 | else |
828 | else |
829 | add ecx, (10+17*6) shl 16 - 10 |
829 | add ecx, (10+17*6) shl 16 - 10 |
830 | end if |
830 | end if |
831 | 831 | ||
832 | mov edx, 0xFFFFFF |
832 | mov edx, 0xFFFFFF |
833 | xor edi, edi |
833 | xor edi, edi |
834 | mov eax, 0x00040000 |
834 | mov eax, 0x00040000 |
835 | inc edi |
835 | inc edi |
836 | call display_number_force |
836 | call display_number_force |
837 | 837 | ||
838 | ; SET VARIABLES |
838 | ; SET VARIABLES |
839 | 839 | ||
840 | call set_variables |
840 | call set_variables |
841 | 841 | ||
842 | ; STACK AND FDC |
842 | ; STACK AND FDC |
843 | 843 | ||
844 | call stack_init |
844 | call stack_init |
845 | call fdc_init |
845 | call fdc_init |
846 | 846 | ||
847 | ; PALETTE FOR 320x200 and 640x480 16 col |
847 | ; PALETTE FOR 320x200 and 640x480 16 col |
848 | 848 | ||
849 | cmp [SCR_MODE], word 0x12 |
849 | cmp [SCR_MODE], word 0x12 |
850 | jne no_pal_vga |
850 | jne no_pal_vga |
851 | mov esi, boot_pal_vga |
851 | mov esi, boot_pal_vga |
852 | call boot_log |
852 | call boot_log |
853 | call paletteVGA |
853 | call paletteVGA |
854 | no_pal_vga: |
854 | no_pal_vga: |
855 | 855 | ||
856 | cmp [SCR_MODE], word 0x13 |
856 | cmp [SCR_MODE], word 0x13 |
857 | jne no_pal_ega |
857 | jne no_pal_ega |
858 | mov esi, boot_pal_ega |
858 | mov esi, boot_pal_ega |
859 | call boot_log |
859 | call boot_log |
860 | call palette320x200 |
860 | call palette320x200 |
861 | no_pal_ega: |
861 | no_pal_ega: |
862 | 862 | ||
863 | ; LOAD DEFAULT SKIN |
863 | ; LOAD DEFAULT SKIN |
864 | 864 | ||
865 | call load_default_skin |
865 | call load_default_skin |
866 | 866 | ||
867 | ;protect io permission map |
867 | ;protect io permission map |
868 | 868 | ||
869 | mov esi, [default_io_map] |
869 | mov esi, [default_io_map] |
870 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
870 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
871 | add esi, 0x1000 |
871 | add esi, 0x1000 |
872 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
872 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
873 | 873 | ||
874 | stdcall map_page, tss._io_map_0, \ |
874 | stdcall map_page, tss._io_map_0, \ |
875 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
875 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
876 | stdcall map_page, tss._io_map_1, \ |
876 | stdcall map_page, tss._io_map_1, \ |
877 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
877 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
878 | 878 | ||
879 | ; LOAD FIRST APPLICATION |
879 | ; LOAD FIRST APPLICATION |
880 | cli |
880 | cli |
881 | 881 | ||
882 | ; cmp byte [BOOT_VAR+0x9030],1 |
882 | ; cmp byte [BOOT_VAR+0x9030],1 |
883 | ; jne no_load_vrr_m |
883 | ; jne no_load_vrr_m |
884 | 884 | ||
885 | ; mov ebp, vrr_m |
885 | ; mov ebp, vrr_m |
886 | ; call fs_execute_from_sysdir |
886 | ; call fs_execute_from_sysdir |
887 | ; |
887 | ; |
888 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
888 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
889 | ; sub eax,2 |
889 | ; sub eax,2 |
890 | ; jz first_app_found |
890 | ; jz first_app_found |
891 | ; |
891 | ; |
892 | ;no_load_vrr_m: |
892 | ;no_load_vrr_m: |
893 | 893 | ||
894 | mov ebp, firstapp |
894 | mov ebp, firstapp |
895 | call fs_execute_from_sysdir |
895 | call fs_execute_from_sysdir |
896 | 896 | ||
897 | ; cmp eax,2 ; continue if a process has been loaded |
897 | ; cmp eax,2 ; continue if a process has been loaded |
898 | test eax, eax |
898 | test eax, eax |
899 | jns first_app_found |
899 | jns first_app_found |
900 | 900 | ||
901 | mov esi, boot_failed |
901 | mov esi, boot_failed |
902 | call boot_log |
902 | call boot_log |
903 | 903 | ||
904 | mov eax, 0xDEADBEEF ; otherwise halt |
904 | mov eax, 0xDEADBEEF ; otherwise halt |
905 | hlt |
905 | hlt |
906 | 906 | ||
907 | first_app_found: |
907 | first_app_found: |
908 | 908 | ||
909 | cli |
909 | cli |
910 | 910 | ||
911 | ; SET KEYBOARD PARAMETERS |
911 | ; SET KEYBOARD PARAMETERS |
912 | mov al, 0xf6 ; reset keyboard, scan enabled |
912 | mov al, 0xf6 ; reset keyboard, scan enabled |
913 | call kb_write |
913 | call kb_write |
914 | test ah, ah |
914 | test ah, ah |
915 | jnz .no_keyboard |
915 | jnz .no_keyboard |
916 | 916 | ||
917 | ; wait until 8042 is ready |
917 | ; wait until 8042 is ready |
918 | xor ecx, ecx |
918 | xor ecx, ecx |
919 | @@: |
919 | @@: |
920 | in al, 64h |
920 | in al, 64h |
921 | and al, 00000010b |
921 | and al, 00000010b |
922 | loopnz @b |
922 | loopnz @b |
923 | 923 | ||
924 | iglobal |
924 | iglobal |
925 | align 4 |
925 | align 4 |
926 | ps2_keyboard_functions: |
926 | ps2_keyboard_functions: |
927 | dd .end - $ |
927 | dd .end - $ |
928 | dd 0 ; no close |
928 | dd 0 ; no close |
929 | dd ps2_set_lights |
929 | dd ps2_set_lights |
930 | .end: |
930 | .end: |
931 | endg |
931 | endg |
932 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
932 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
933 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
933 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
934 | ; call kb_write |
934 | ; call kb_write |
935 | ; call kb_read |
935 | ; call kb_read |
936 | ; mov al, 111b |
936 | ; mov al, 111b |
937 | ; call kb_write |
937 | ; call kb_write |
938 | ; call kb_read |
938 | ; call kb_read |
939 | 939 | ||
940 | mov al, 0xF3 ; set repeat rate & delay |
940 | mov al, 0xF3 ; set repeat rate & delay |
941 | call kb_write |
941 | call kb_write |
942 | ; call kb_read |
942 | ; call kb_read |
943 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
943 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
944 | call kb_write |
944 | call kb_write |
945 | ; call kb_read |
945 | ; call kb_read |
946 | ;// mike.dld [ |
946 | ;// mike.dld [ |
947 | call set_lights |
947 | call set_lights |
948 | ;// mike.dld ] |
948 | ;// mike.dld ] |
949 | stdcall attach_int_handler, 1, irq1, 0 |
949 | stdcall attach_int_handler, 1, irq1, 0 |
950 | .no_keyboard: |
950 | .no_keyboard: |
951 | 951 | ||
952 | ; SET MOUSE |
952 | ; SET MOUSE |
953 | 953 | ||
954 | stdcall load_driver, szPS2MDriver |
954 | stdcall load_driver, szPS2MDriver |
955 | ; stdcall load_driver, szCOM_MDriver |
955 | ; stdcall load_driver, szCOM_MDriver |
956 | 956 | ||
957 | mov esi, boot_setmouse |
957 | mov esi, boot_setmouse |
958 | call boot_log |
958 | call boot_log |
959 | call setmouse |
959 | call setmouse |
960 | 960 | ||
961 | ; Setup serial output console (if enabled) |
961 | ; Setup serial output console (if enabled) |
962 | 962 | ||
963 | if defined debug_com_base |
963 | if defined debug_com_base |
964 | 964 | ||
965 | ; enable Divisor latch |
965 | ; enable Divisor latch |
966 | 966 | ||
967 | mov dx, debug_com_base+3 |
967 | mov dx, debug_com_base+3 |
968 | mov al, 1 shl 7 |
968 | mov al, 1 shl 7 |
969 | out dx, al |
969 | out dx, al |
970 | 970 | ||
971 | ; Set speed to 115200 baud (max speed) |
971 | ; Set speed to 115200 baud (max speed) |
972 | 972 | ||
973 | mov dx, debug_com_base |
973 | mov dx, debug_com_base |
974 | mov al, 0x01 |
974 | mov al, 0x01 |
975 | out dx, al |
975 | out dx, al |
976 | 976 | ||
977 | mov dx, debug_com_base+1 |
977 | mov dx, debug_com_base+1 |
978 | mov al, 0x00 |
978 | mov al, 0x00 |
979 | out dx, al |
979 | out dx, al |
980 | 980 | ||
981 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
981 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
982 | 982 | ||
983 | mov dx, debug_com_base+3 |
983 | mov dx, debug_com_base+3 |
984 | mov al, 3 |
984 | mov al, 3 |
985 | out dx, al |
985 | out dx, al |
986 | 986 | ||
987 | ; disable interrupts |
987 | ; disable interrupts |
988 | 988 | ||
989 | mov dx, debug_com_base+1 |
989 | mov dx, debug_com_base+1 |
990 | mov al, 0 |
990 | mov al, 0 |
991 | out dx, al |
991 | out dx, al |
992 | 992 | ||
993 | ; clear + enable fifo (64 bits) |
993 | ; clear + enable fifo (64 bits) |
994 | 994 | ||
995 | mov dx, debug_com_base+2 |
995 | mov dx, debug_com_base+2 |
996 | mov al, 0x7 + 1 shl 5 |
996 | mov al, 0x7 + 1 shl 5 |
997 | out dx, al |
997 | out dx, al |
998 | 998 | ||
999 | 999 | ||
1000 | end if |
1000 | end if |
1001 | mov eax, [version_inf.rev] |
1001 | mov eax, [version_inf.rev] |
1002 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1002 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1003 | 1003 | ||
1004 | mov eax, [cpu_count] |
1004 | mov eax, [cpu_count] |
1005 | test eax, eax |
1005 | test eax, eax |
1006 | jnz @F |
1006 | jnz @F |
1007 | mov al, 1 ; at least one CPU |
1007 | mov al, 1 ; at least one CPU |
1008 | @@: |
1008 | @@: |
1009 | DEBUGF 1, "K : %d CPU detected\n", eax |
1009 | DEBUGF 1, "K : %d CPU detected\n", eax |
1010 | 1010 | ||
1011 | ; START MULTITASKING |
1011 | ; START MULTITASKING |
1012 | 1012 | ||
1013 | ; A 'All set - press ESC to start' messages if need |
1013 | ; A 'All set - press ESC to start' messages if need |
1014 | if preboot_blogesc |
1014 | if preboot_blogesc |
1015 | mov esi, boot_tasking |
1015 | mov esi, boot_tasking |
1016 | call boot_log |
1016 | call boot_log |
1017 | .bll1: |
1017 | .bll1: |
1018 | in al, 0x60 ; wait for ESC key press |
1018 | in al, 0x60 ; wait for ESC key press |
1019 | cmp al, 129 |
1019 | cmp al, 129 |
1020 | jne .bll1 |
1020 | jne .bll1 |
1021 | end if |
1021 | end if |
1022 | 1022 | ||
1023 | cmp [IDEContrRegsBaseAddr], 0 |
1023 | cmp [IDEContrRegsBaseAddr], 0 |
1024 | setnz [dma_hdd] |
1024 | setnz [dma_hdd] |
1025 | mov [timer_ticks_enable], 1 ; for cd driver |
1025 | mov [timer_ticks_enable], 1 ; for cd driver |
1026 | 1026 | ||
1027 | sti |
1027 | sti |
1028 | ; call change_task |
1028 | ; call change_task |
1029 | 1029 | ||
1030 | jmp osloop |
1030 | jmp osloop |
1031 | 1031 | ||
1032 | 1032 | ||
1033 | ; Fly :) |
1033 | ; Fly :) |
1034 | 1034 | ||
1035 | include 'unpacker.inc' |
1035 | include 'unpacker.inc' |
1036 | 1036 | ||
1037 | align 4 |
1037 | align 4 |
1038 | boot_log: |
1038 | boot_log: |
1039 | pushad |
1039 | pushad |
1040 | 1040 | ||
1041 | mov ebx, 10*65536 |
1041 | mov ebx, 10*65536 |
1042 | mov bx, word [boot_y] |
1042 | mov bx, word [boot_y] |
1043 | add [boot_y], dword 10 |
1043 | add [boot_y], dword 10 |
1044 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1044 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1045 | xor edi, edi |
1045 | xor edi, edi |
1046 | mov edx, esi |
1046 | mov edx, esi |
1047 | inc edi |
1047 | inc edi |
1048 | call dtext |
1048 | call dtext |
1049 | 1049 | ||
1050 | mov [novesachecksum], 1000 |
1050 | mov [novesachecksum], 1000 |
1051 | call checkVga_N13 |
1051 | call checkVga_N13 |
1052 | 1052 | ||
1053 | popad |
1053 | popad |
1054 | 1054 | ||
1055 | ret |
1055 | ret |
1056 | 1056 | ||
1057 | ; in: edx -> APPDATA for OS/IDLE slot |
1057 | ; in: edx -> APPDATA for OS/IDLE slot |
1058 | ; in: ebx = stack base |
1058 | ; in: ebx = stack base |
1059 | proc setup_os_slot |
1059 | proc setup_os_slot |
1060 | xor eax, eax |
1060 | xor eax, eax |
1061 | mov ecx, 256/4 |
1061 | mov ecx, 256/4 |
1062 | mov edi, edx |
1062 | mov edi, edx |
1063 | rep stosd |
1063 | rep stosd |
1064 | 1064 | ||
1065 | mov eax, tss+0x80 |
1065 | mov eax, tss+0x80 |
1066 | call get_pg_addr |
1066 | call get_pg_addr |
1067 | inc eax |
1067 | inc eax |
1068 | mov [edx+APPDATA.io_map], eax |
1068 | mov [edx+APPDATA.io_map], eax |
1069 | mov eax, tss+0x1080 |
1069 | mov eax, tss+0x1080 |
1070 | call get_pg_addr |
1070 | call get_pg_addr |
1071 | inc eax |
1071 | inc eax |
1072 | mov [edx+APPDATA.io_map+4], eax |
1072 | mov [edx+APPDATA.io_map+4], eax |
1073 | 1073 | ||
1074 | mov dword [edx+APPDATA.pl0_stack], ebx |
1074 | mov dword [edx+APPDATA.pl0_stack], ebx |
1075 | lea edi, [ebx+0x2000-512] |
1075 | lea edi, [ebx+0x2000-512] |
1076 | mov dword [edx+APPDATA.fpu_state], edi |
1076 | mov dword [edx+APPDATA.fpu_state], edi |
1077 | mov dword [edx+APPDATA.saved_esp0], edi |
1077 | mov dword [edx+APPDATA.saved_esp0], edi |
1078 | mov dword [edx+APPDATA.saved_esp], edi |
1078 | mov dword [edx+APPDATA.saved_esp], edi |
1079 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1079 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1080 | 1080 | ||
1081 | mov esi, fpu_data |
1081 | mov esi, fpu_data |
1082 | mov ecx, 512/4 |
1082 | mov ecx, 512/4 |
1083 | cld |
1083 | cld |
1084 | rep movsd |
1084 | rep movsd |
1085 | 1085 | ||
1086 | lea eax, [edx+APP_OBJ_OFFSET] |
1086 | lea eax, [edx+APP_OBJ_OFFSET] |
1087 | mov dword [edx+APPDATA.fd_obj], eax |
1087 | mov dword [edx+APPDATA.fd_obj], eax |
1088 | mov dword [edx+APPDATA.bk_obj], eax |
1088 | mov dword [edx+APPDATA.bk_obj], eax |
1089 | 1089 | ||
1090 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1090 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1091 | 1091 | ||
1092 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1092 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1093 | 1093 | ||
1094 | mov eax, edx |
1094 | mov eax, edx |
1095 | shr eax, 3 |
1095 | shr eax, 3 |
1096 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1096 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1097 | mov [eax+TASKDATA.wnd_number], dh |
1097 | mov [eax+TASKDATA.wnd_number], dh |
1098 | mov byte [eax+TASKDATA.pid], dh |
1098 | mov byte [eax+TASKDATA.pid], dh |
1099 | 1099 | ||
1100 | ret |
1100 | ret |
1101 | endp |
1101 | endp |
1102 | 1102 | ||
1103 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1103 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1104 | ; ; |
1104 | ; ; |
1105 | ; MAIN OS LOOP START ; |
1105 | ; MAIN OS LOOP START ; |
1106 | ; ; |
1106 | ; ; |
1107 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1107 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1108 | align 32 |
1108 | align 32 |
1109 | osloop: |
1109 | osloop: |
1110 | mov edx, osloop_has_work? |
1110 | mov edx, osloop_has_work? |
1111 | xor ecx, ecx |
1111 | xor ecx, ecx |
1112 | call Wait_events |
1112 | call Wait_events |
1113 | xor eax, eax |
1113 | xor eax, eax |
1114 | xchg eax, [osloop_nonperiodic_work] |
1114 | xchg eax, [osloop_nonperiodic_work] |
1115 | test eax, eax |
1115 | test eax, eax |
1116 | jz .no_periodic |
1116 | jz .no_periodic |
1117 | ; call [draw_pointer] |
1117 | ; call [draw_pointer] |
1118 | call __sys_draw_pointer |
1118 | call __sys_draw_pointer |
1119 | call window_check_events |
1119 | call window_check_events |
1120 | call mouse_check_events |
1120 | call mouse_check_events |
1121 | call checkmisc |
1121 | call checkmisc |
1122 | call checkVga_N13 |
1122 | call checkVga_N13 |
1123 | .no_periodic: |
1123 | .no_periodic: |
1124 | call stack_handler |
1124 | call stack_handler |
1125 | call check_fdd_motor_status |
1125 | call check_fdd_motor_status |
1126 | call check_ATAPI_device_event |
1126 | call check_ATAPI_device_event |
1127 | call check_lights_state |
1127 | call check_lights_state |
1128 | call check_timers |
1128 | call check_timers |
1129 | jmp osloop |
1129 | jmp osloop |
1130 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1130 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1131 | ; ; |
1131 | ; ; |
1132 | ; MAIN OS LOOP END ; |
1132 | ; MAIN OS LOOP END ; |
1133 | ; ; |
1133 | ; ; |
1134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1135 | proc osloop_has_work? |
1135 | proc osloop_has_work? |
1136 | cmp [osloop_nonperiodic_work], 0 |
1136 | cmp [osloop_nonperiodic_work], 0 |
1137 | jnz .yes |
1137 | jnz .yes |
1138 | call stack_handler_has_work? |
1138 | call stack_handler_has_work? |
1139 | jnz .yes |
1139 | jnz .yes |
1140 | call check_fdd_motor_status_has_work? |
1140 | call check_fdd_motor_status_has_work? |
1141 | jnz .yes |
1141 | jnz .yes |
1142 | call check_ATAPI_device_event_has_work? |
1142 | call check_ATAPI_device_event_has_work? |
1143 | jnz .yes |
1143 | jnz .yes |
1144 | call check_lights_state_has_work? |
1144 | call check_lights_state_has_work? |
1145 | jnz .yes |
1145 | jnz .yes |
1146 | call check_timers_has_work? |
1146 | call check_timers_has_work? |
1147 | jnz .yes |
1147 | jnz .yes |
1148 | .no: |
1148 | .no: |
1149 | xor eax, eax |
1149 | xor eax, eax |
1150 | ret |
1150 | ret |
1151 | .yes: |
1151 | .yes: |
1152 | xor eax, eax |
1152 | xor eax, eax |
1153 | inc eax |
1153 | inc eax |
1154 | ret |
1154 | ret |
1155 | endp |
1155 | endp |
1156 | 1156 | ||
1157 | proc wakeup_osloop |
1157 | proc wakeup_osloop |
1158 | mov [osloop_nonperiodic_work], 1 |
1158 | mov [osloop_nonperiodic_work], 1 |
1159 | ret |
1159 | ret |
1160 | endp |
1160 | endp |
1161 | 1161 | ||
1162 | uglobal |
1162 | uglobal |
1163 | align 4 |
1163 | align 4 |
1164 | osloop_nonperiodic_work dd ? |
1164 | osloop_nonperiodic_work dd ? |
1165 | endg |
1165 | endg |
1166 | 1166 | ||
1167 | align 4 |
1167 | align 4 |
1168 | idle_thread: |
1168 | idle_thread: |
1169 | sti |
1169 | sti |
1170 | idle_loop: |
1170 | idle_loop: |
1171 | hlt |
1171 | hlt |
1172 | jmp idle_loop |
1172 | jmp idle_loop |
1173 | 1173 | ||
1174 | 1174 | ||
1175 | 1175 | ||
1176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1177 | ; ; |
1177 | ; ; |
1178 | ; INCLUDED SYSTEM FILES ; |
1178 | ; INCLUDED SYSTEM FILES ; |
1179 | ; ; |
1179 | ; ; |
1180 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1180 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1181 | 1181 | ||
1182 | 1182 | ||
1183 | include "kernel32.inc" |
1183 | include "kernel32.inc" |
1184 | 1184 | ||
1185 | 1185 | ||
1186 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1186 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1187 | ; ; |
1187 | ; ; |
1188 | ; KERNEL FUNCTIONS ; |
1188 | ; KERNEL FUNCTIONS ; |
1189 | ; ; |
1189 | ; ; |
1190 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1190 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1191 | 1191 | ||
1192 | reserve_irqs_ports: |
1192 | reserve_irqs_ports: |
1193 | 1193 | ||
1194 | 1194 | ||
1195 | ; RESERVE PORTS |
1195 | ; RESERVE PORTS |
1196 | mov eax, RESERVED_PORTS |
1196 | mov eax, RESERVED_PORTS |
1197 | mov ecx, 1 |
1197 | mov ecx, 1 |
1198 | 1198 | ||
1199 | mov [eax], dword 4 |
1199 | mov [eax], dword 4 |
1200 | 1200 | ||
1201 | mov [eax+16], ecx |
1201 | mov [eax+16], ecx |
1202 | mov [eax+16+4], dword 0 |
1202 | mov [eax+16+4], dword 0 |
1203 | mov [eax+16+8], dword 0x2D |
1203 | mov [eax+16+8], dword 0x2D |
1204 | 1204 | ||
1205 | mov [eax+32], ecx |
1205 | mov [eax+32], ecx |
1206 | mov [eax+32+4], dword 0x30 |
1206 | mov [eax+32+4], dword 0x30 |
1207 | mov [eax+32+8], dword 0x4D |
1207 | mov [eax+32+8], dword 0x4D |
1208 | 1208 | ||
1209 | mov [eax+48], ecx |
1209 | mov [eax+48], ecx |
1210 | mov [eax+48+4], dword 0x50 |
1210 | mov [eax+48+4], dword 0x50 |
1211 | mov [eax+48+8], dword 0xDF |
1211 | mov [eax+48+8], dword 0xDF |
1212 | 1212 | ||
1213 | mov [eax+64], ecx |
1213 | mov [eax+64], ecx |
1214 | mov [eax+64+4], dword 0xE5 |
1214 | mov [eax+64+4], dword 0xE5 |
1215 | mov [eax+64+8], dword 0xFF |
1215 | mov [eax+64+8], dword 0xFF |
1216 | 1216 | ||
1217 | ret |
1217 | ret |
1218 | 1218 | ||
1219 | 1219 | ||
1220 | iglobal |
1220 | iglobal |
1221 | process_number dd 0x2 |
1221 | process_number dd 0x2 |
1222 | endg |
1222 | endg |
1223 | 1223 | ||
1224 | set_variables: |
1224 | set_variables: |
1225 | 1225 | ||
1226 | mov ecx, 0x16 ; flush port 0x60 |
1226 | mov ecx, 0x16 ; flush port 0x60 |
1227 | .fl60: |
1227 | .fl60: |
1228 | in al, 0x60 |
1228 | in al, 0x60 |
1229 | loop .fl60 |
1229 | loop .fl60 |
1230 | push eax |
1230 | push eax |
1231 | 1231 | ||
1232 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1232 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1233 | shr ax, 1 |
1233 | shr ax, 1 |
1234 | shl eax, 16 |
1234 | shl eax, 16 |
1235 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1235 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1236 | shr ax, 1 |
1236 | shr ax, 1 |
1237 | mov [MOUSE_X], eax |
1237 | mov [MOUSE_X], eax |
1238 | call wakeup_osloop |
1238 | call wakeup_osloop |
1239 | 1239 | ||
1240 | xor eax, eax |
1240 | xor eax, eax |
1241 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1241 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1242 | 1242 | ||
1243 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1243 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1244 | mov byte [KEY_COUNT], al ; keyboard buffer |
1244 | mov byte [KEY_COUNT], al ; keyboard buffer |
1245 | mov byte [BTN_COUNT], al ; button buffer |
1245 | mov byte [BTN_COUNT], al ; button buffer |
1246 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1246 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1247 | 1247 | ||
1248 | ;!! IP 04.02.2005: |
1248 | ;!! IP 04.02.2005: |
1249 | ; mov byte [DONT_SWITCH], al; change task if possible |
1249 | ; mov byte [DONT_SWITCH], al; change task if possible |
1250 | pop eax |
1250 | pop eax |
1251 | ret |
1251 | ret |
1252 | 1252 | ||
1253 | align 4 |
1253 | align 4 |
1254 | ;input eax=43,bl-byte of output, ecx - number of port |
1254 | ;input eax=43,bl-byte of output, ecx - number of port |
1255 | sys_outport: |
1255 | sys_outport: |
1256 | 1256 | ||
1257 | mov edi, ecx ; separate flag for read / write |
1257 | mov edi, ecx ; separate flag for read / write |
1258 | and ecx, 65535 |
1258 | and ecx, 65535 |
1259 | 1259 | ||
1260 | mov eax, [RESERVED_PORTS] |
1260 | mov eax, [RESERVED_PORTS] |
1261 | test eax, eax |
1261 | test eax, eax |
1262 | jnz .sopl8 |
1262 | jnz .sopl8 |
1263 | inc eax |
1263 | inc eax |
1264 | mov [esp+32], eax |
1264 | mov [esp+32], eax |
1265 | ret |
1265 | ret |
1266 | 1266 | ||
1267 | .sopl8: |
1267 | .sopl8: |
1268 | mov edx, [TASK_BASE] |
1268 | mov edx, [TASK_BASE] |
1269 | mov edx, [edx+0x4] |
1269 | mov edx, [edx+0x4] |
1270 | ;and ecx,65535 |
1270 | ;and ecx,65535 |
1271 | ;cld - set on interrupt 0x40 |
1271 | ;cld - set on interrupt 0x40 |
1272 | .sopl1: |
1272 | .sopl1: |
1273 | 1273 | ||
1274 | mov esi, eax |
1274 | mov esi, eax |
1275 | shl esi, 4 |
1275 | shl esi, 4 |
1276 | add esi, RESERVED_PORTS |
1276 | add esi, RESERVED_PORTS |
1277 | cmp edx, [esi+0] |
1277 | cmp edx, [esi+0] |
1278 | jne .sopl2 |
1278 | jne .sopl2 |
1279 | cmp ecx, [esi+4] |
1279 | cmp ecx, [esi+4] |
1280 | jb .sopl2 |
1280 | jb .sopl2 |
1281 | cmp ecx, [esi+8] |
1281 | cmp ecx, [esi+8] |
1282 | jg .sopl2 |
1282 | jg .sopl2 |
1283 | .sopl3: |
1283 | .sopl3: |
1284 | 1284 | ||
1285 | test edi, 0x80000000; read ? |
1285 | test edi, 0x80000000; read ? |
1286 | jnz .sopl4 |
1286 | jnz .sopl4 |
1287 | 1287 | ||
1288 | mov eax, ebx |
1288 | mov eax, ebx |
1289 | mov dx, cx ; write |
1289 | mov dx, cx ; write |
1290 | out dx, al |
1290 | out dx, al |
1291 | and [esp+32], dword 0 |
1291 | and [esp+32], dword 0 |
1292 | ret |
1292 | ret |
1293 | 1293 | ||
1294 | .sopl2: |
1294 | .sopl2: |
1295 | 1295 | ||
1296 | dec eax |
1296 | dec eax |
1297 | jnz .sopl1 |
1297 | jnz .sopl1 |
1298 | inc eax |
1298 | inc eax |
1299 | mov [esp+32], eax |
1299 | mov [esp+32], eax |
1300 | ret |
1300 | ret |
1301 | 1301 | ||
1302 | 1302 | ||
1303 | .sopl4: |
1303 | .sopl4: |
1304 | 1304 | ||
1305 | mov dx, cx ; read |
1305 | mov dx, cx ; read |
1306 | in al, dx |
1306 | in al, dx |
1307 | and eax, 0xff |
1307 | and eax, 0xff |
1308 | and [esp+32], dword 0 |
1308 | and [esp+32], dword 0 |
1309 | mov [esp+20], eax |
1309 | mov [esp+20], eax |
1310 | ret |
1310 | ret |
1311 | 1311 | ||
1312 | display_number: |
1312 | display_number: |
1313 | ;It is not optimization |
1313 | ;It is not optimization |
1314 | mov eax, ebx |
1314 | mov eax, ebx |
1315 | mov ebx, ecx |
1315 | mov ebx, ecx |
1316 | mov ecx, edx |
1316 | mov ecx, edx |
1317 | mov edx, esi |
1317 | mov edx, esi |
1318 | mov esi, edi |
1318 | mov esi, edi |
1319 | ; eax = print type, al=0 -> ebx is number |
1319 | ; eax = print type, al=0 -> ebx is number |
1320 | ; al=1 -> ebx is pointer |
1320 | ; al=1 -> ebx is pointer |
1321 | ; ah=0 -> display decimal |
1321 | ; ah=0 -> display decimal |
1322 | ; ah=1 -> display hexadecimal |
1322 | ; ah=1 -> display hexadecimal |
1323 | ; ah=2 -> display binary |
1323 | ; ah=2 -> display binary |
1324 | ; eax bits 16-21 = number of digits to display (0-32) |
1324 | ; eax bits 16-21 = number of digits to display (0-32) |
1325 | ; eax bits 22-31 = reserved |
1325 | ; eax bits 22-31 = reserved |
1326 | ; |
1326 | ; |
1327 | ; ebx = number or pointer |
1327 | ; ebx = number or pointer |
1328 | ; ecx = x shl 16 + y |
1328 | ; ecx = x shl 16 + y |
1329 | ; edx = color |
1329 | ; edx = color |
1330 | xor edi, edi |
1330 | xor edi, edi |
1331 | display_number_force: |
1331 | display_number_force: |
1332 | push eax |
1332 | push eax |
1333 | and eax, 0x3fffffff |
1333 | and eax, 0x3fffffff |
1334 | cmp eax, 0xffff ; length > 0 ? |
1334 | cmp eax, 0xffff ; length > 0 ? |
1335 | pop eax |
1335 | pop eax |
1336 | jge cont_displ |
1336 | jge cont_displ |
1337 | ret |
1337 | ret |
1338 | cont_displ: |
1338 | cont_displ: |
1339 | push eax |
1339 | push eax |
1340 | and eax, 0x3fffffff |
1340 | and eax, 0x3fffffff |
1341 | cmp eax, 61*0x10000 ; length <= 60 ? |
1341 | cmp eax, 61*0x10000 ; length <= 60 ? |
1342 | pop eax |
1342 | pop eax |
1343 | jb cont_displ2 |
1343 | jb cont_displ2 |
1344 | ret |
1344 | ret |
1345 | cont_displ2: |
1345 | cont_displ2: |
1346 | 1346 | ||
1347 | pushad |
1347 | pushad |
1348 | 1348 | ||
1349 | cmp al, 1 ; ecx is a pointer ? |
1349 | cmp al, 1 ; ecx is a pointer ? |
1350 | jne displnl1 |
1350 | jne displnl1 |
1351 | mov ebp, ebx |
1351 | mov ebp, ebx |
1352 | add ebp, 4 |
1352 | add ebp, 4 |
1353 | mov ebp, [ebp+std_application_base_address] |
1353 | mov ebp, [ebp+std_application_base_address] |
1354 | mov ebx, [ebx+std_application_base_address] |
1354 | mov ebx, [ebx+std_application_base_address] |
1355 | displnl1: |
1355 | displnl1: |
1356 | sub esp, 64 |
1356 | sub esp, 64 |
1357 | 1357 | ||
1358 | test ah, ah ; DECIMAL |
1358 | test ah, ah ; DECIMAL |
1359 | jnz no_display_desnum |
1359 | jnz no_display_desnum |
1360 | shr eax, 16 |
1360 | shr eax, 16 |
1361 | and eax, 0xC03f |
1361 | and eax, 0xC03f |
1362 | ; and eax,0x3f |
1362 | ; and eax,0x3f |
1363 | push eax |
1363 | push eax |
1364 | and eax, 0x3f |
1364 | and eax, 0x3f |
1365 | mov edi, esp |
1365 | mov edi, esp |
1366 | add edi, 4+64-1 |
1366 | add edi, 4+64-1 |
1367 | mov ecx, eax |
1367 | mov ecx, eax |
1368 | mov eax, ebx |
1368 | mov eax, ebx |
1369 | mov ebx, 10 |
1369 | mov ebx, 10 |
1370 | d_desnum: |
1370 | d_desnum: |
1371 | xor edx, edx |
1371 | xor edx, edx |
1372 | call division_64_bits |
1372 | call division_64_bits |
1373 | div ebx |
1373 | div ebx |
1374 | add dl, 48 |
1374 | add dl, 48 |
1375 | mov [edi], dl |
1375 | mov [edi], dl |
1376 | dec edi |
1376 | dec edi |
1377 | loop d_desnum |
1377 | loop d_desnum |
1378 | pop eax |
1378 | pop eax |
1379 | call normalize_number |
1379 | call normalize_number |
1380 | call draw_num_text |
1380 | call draw_num_text |
1381 | add esp, 64 |
1381 | add esp, 64 |
1382 | popad |
1382 | popad |
1383 | ret |
1383 | ret |
1384 | no_display_desnum: |
1384 | no_display_desnum: |
1385 | 1385 | ||
1386 | cmp ah, 0x01 ; HEXADECIMAL |
1386 | cmp ah, 0x01 ; HEXADECIMAL |
1387 | jne no_display_hexnum |
1387 | jne no_display_hexnum |
1388 | shr eax, 16 |
1388 | shr eax, 16 |
1389 | and eax, 0xC03f |
1389 | and eax, 0xC03f |
1390 | ; and eax,0x3f |
1390 | ; and eax,0x3f |
1391 | push eax |
1391 | push eax |
1392 | and eax, 0x3f |
1392 | and eax, 0x3f |
1393 | mov edi, esp |
1393 | mov edi, esp |
1394 | add edi, 4+64-1 |
1394 | add edi, 4+64-1 |
1395 | mov ecx, eax |
1395 | mov ecx, eax |
1396 | mov eax, ebx |
1396 | mov eax, ebx |
1397 | mov ebx, 16 |
1397 | mov ebx, 16 |
1398 | d_hexnum: |
1398 | d_hexnum: |
1399 | xor edx, edx |
1399 | xor edx, edx |
1400 | call division_64_bits |
1400 | call division_64_bits |
1401 | div ebx |
1401 | div ebx |
1402 | hexletters = __fdo_hexdigits |
1402 | hexletters = __fdo_hexdigits |
1403 | add edx, hexletters |
1403 | add edx, hexletters |
1404 | mov dl, [edx] |
1404 | mov dl, [edx] |
1405 | mov [edi], dl |
1405 | mov [edi], dl |
1406 | dec edi |
1406 | dec edi |
1407 | loop d_hexnum |
1407 | loop d_hexnum |
1408 | pop eax |
1408 | pop eax |
1409 | call normalize_number |
1409 | call normalize_number |
1410 | call draw_num_text |
1410 | call draw_num_text |
1411 | add esp, 64 |
1411 | add esp, 64 |
1412 | popad |
1412 | popad |
1413 | ret |
1413 | ret |
1414 | no_display_hexnum: |
1414 | no_display_hexnum: |
1415 | 1415 | ||
1416 | cmp ah, 0x02 ; BINARY |
1416 | cmp ah, 0x02 ; BINARY |
1417 | jne no_display_binnum |
1417 | jne no_display_binnum |
1418 | shr eax, 16 |
1418 | shr eax, 16 |
1419 | and eax, 0xC03f |
1419 | and eax, 0xC03f |
1420 | ; and eax,0x3f |
1420 | ; and eax,0x3f |
1421 | push eax |
1421 | push eax |
1422 | and eax, 0x3f |
1422 | and eax, 0x3f |
1423 | mov edi, esp |
1423 | mov edi, esp |
1424 | add edi, 4+64-1 |
1424 | add edi, 4+64-1 |
1425 | mov ecx, eax |
1425 | mov ecx, eax |
1426 | mov eax, ebx |
1426 | mov eax, ebx |
1427 | mov ebx, 2 |
1427 | mov ebx, 2 |
1428 | d_binnum: |
1428 | d_binnum: |
1429 | xor edx, edx |
1429 | xor edx, edx |
1430 | call division_64_bits |
1430 | call division_64_bits |
1431 | div ebx |
1431 | div ebx |
1432 | add dl, 48 |
1432 | add dl, 48 |
1433 | mov [edi], dl |
1433 | mov [edi], dl |
1434 | dec edi |
1434 | dec edi |
1435 | loop d_binnum |
1435 | loop d_binnum |
1436 | pop eax |
1436 | pop eax |
1437 | call normalize_number |
1437 | call normalize_number |
1438 | call draw_num_text |
1438 | call draw_num_text |
1439 | add esp, 64 |
1439 | add esp, 64 |
1440 | popad |
1440 | popad |
1441 | ret |
1441 | ret |
1442 | no_display_binnum: |
1442 | no_display_binnum: |
1443 | 1443 | ||
1444 | add esp, 64 |
1444 | add esp, 64 |
1445 | popad |
1445 | popad |
1446 | ret |
1446 | ret |
1447 | 1447 | ||
1448 | normalize_number: |
1448 | normalize_number: |
1449 | test ah, 0x80 |
1449 | test ah, 0x80 |
1450 | jz .continue |
1450 | jz .continue |
1451 | mov ecx, 48 |
1451 | mov ecx, 48 |
1452 | and eax, 0x3f |
1452 | and eax, 0x3f |
1453 | @@: |
1453 | @@: |
1454 | inc edi |
1454 | inc edi |
1455 | cmp [edi], cl |
1455 | cmp [edi], cl |
1456 | jne .continue |
1456 | jne .continue |
1457 | dec eax |
1457 | dec eax |
1458 | cmp eax, 1 |
1458 | cmp eax, 1 |
1459 | ja @r |
1459 | ja @r |
1460 | mov al, 1 |
1460 | mov al, 1 |
1461 | .continue: |
1461 | .continue: |
1462 | and eax, 0x3f |
1462 | and eax, 0x3f |
1463 | ret |
1463 | ret |
1464 | 1464 | ||
1465 | division_64_bits: |
1465 | division_64_bits: |
1466 | test [esp+1+4], byte 0x40 |
1466 | test [esp+1+4], byte 0x40 |
1467 | jz .continue |
1467 | jz .continue |
1468 | push eax |
1468 | push eax |
1469 | mov eax, ebp |
1469 | mov eax, ebp |
1470 | div ebx |
1470 | div ebx |
1471 | mov ebp, eax |
1471 | mov ebp, eax |
1472 | pop eax |
1472 | pop eax |
1473 | .continue: |
1473 | .continue: |
1474 | ret |
1474 | ret |
1475 | 1475 | ||
1476 | draw_num_text: |
1476 | draw_num_text: |
1477 | mov esi, eax |
1477 | mov esi, eax |
1478 | mov edx, 64+4 |
1478 | mov edx, 64+4 |
1479 | sub edx, eax |
1479 | sub edx, eax |
1480 | add edx, esp |
1480 | add edx, esp |
1481 | mov ebx, [esp+64+32-8+4] |
1481 | mov ebx, [esp+64+32-8+4] |
1482 | ; add window start x & y |
1482 | ; add window start x & y |
1483 | mov ecx, [TASK_BASE] |
1483 | mov ecx, [TASK_BASE] |
1484 | 1484 | ||
1485 | mov edi, [CURRENT_TASK] |
1485 | mov edi, [CURRENT_TASK] |
1486 | shl edi, 8 |
1486 | shl edi, 8 |
1487 | 1487 | ||
1488 | mov eax, [ecx-twdw+WDATA.box.left] |
1488 | mov eax, [ecx-twdw+WDATA.box.left] |
1489 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1489 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1490 | shl eax, 16 |
1490 | shl eax, 16 |
1491 | add eax, [ecx-twdw+WDATA.box.top] |
1491 | add eax, [ecx-twdw+WDATA.box.top] |
1492 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1492 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1493 | add ebx, eax |
1493 | add ebx, eax |
1494 | mov ecx, [esp+64+32-12+4] |
1494 | mov ecx, [esp+64+32-12+4] |
1495 | and ecx, not 0x80000000 ; force counted string |
1495 | and ecx, not 0x80000000 ; force counted string |
1496 | mov eax, [esp+64+8] ; background color (if given) |
1496 | mov eax, [esp+64+8] ; background color (if given) |
1497 | mov edi, [esp+64+4] |
1497 | mov edi, [esp+64+4] |
1498 | jmp dtext |
1498 | jmp dtext |
1499 | 1499 | ||
1500 | align 4 |
1500 | align 4 |
1501 | 1501 | ||
1502 | sys_setup: |
1502 | sys_setup: |
1503 | 1503 | ||
1504 | ; 1=roland mpu midi base , base io address |
1504 | ; 1=roland mpu midi base , base io address |
1505 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1505 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1506 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1506 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1507 | ; 5=system language, 1eng 2fi 3ger 4rus |
1507 | ; 5=system language, 1eng 2fi 3ger 4rus |
1508 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1508 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1509 | ; 8=fat32 partition in hd |
1509 | ; 8=fat32 partition in hd |
1510 | ; 9 |
1510 | ; 9 |
1511 | ; 10 = sound dma channel |
1511 | ; 10 = sound dma channel |
1512 | ; 11 = enable lba read |
1512 | ; 11 = enable lba read |
1513 | ; 12 = enable pci access |
1513 | ; 12 = enable pci access |
1514 | 1514 | ||
1515 | 1515 | ||
1516 | and [esp+32], dword 0 |
1516 | and [esp+32], dword 0 |
1517 | dec ebx ; MIDI |
1517 | dec ebx ; MIDI |
1518 | jnz nsyse1 |
1518 | jnz nsyse1 |
1519 | cmp ecx, 0x100 |
1519 | cmp ecx, 0x100 |
1520 | 1520 | ||
1521 | jb nsyse1 |
1521 | jb nsyse1 |
1522 | mov esi, 65535 |
1522 | mov esi, 65535 |
1523 | cmp esi, ecx |
1523 | cmp esi, ecx |
1524 | 1524 | ||
1525 | jb nsyse1 |
1525 | jb nsyse1 |
1526 | mov [midi_base], cx ;bx |
1526 | mov [midi_base], cx ;bx |
1527 | mov word [mididp], cx;bx |
1527 | mov word [mididp], cx;bx |
1528 | inc cx ;bx |
1528 | inc cx ;bx |
1529 | mov word [midisp], cx;bx |
1529 | mov word [midisp], cx;bx |
1530 | ret |
1530 | ret |
1531 | 1531 | ||
1532 | iglobal |
1532 | iglobal |
1533 | midi_base dw 0 |
1533 | midi_base dw 0 |
1534 | endg |
1534 | endg |
1535 | 1535 | ||
1536 | nsyse1: |
1536 | nsyse1: |
1537 | dec ebx ; KEYBOARD |
1537 | dec ebx ; KEYBOARD |
1538 | jnz nsyse2 |
1538 | jnz nsyse2 |
1539 | mov edi, [TASK_BASE] |
1539 | mov edi, [TASK_BASE] |
1540 | mov eax, [edi+TASKDATA.mem_start] |
1540 | mov eax, [edi+TASKDATA.mem_start] |
1541 | add eax, edx |
1541 | add eax, edx |
1542 | 1542 | ||
1543 | dec ecx |
1543 | dec ecx |
1544 | jnz kbnobase |
1544 | jnz kbnobase |
1545 | mov ebx, keymap |
1545 | mov ebx, keymap |
1546 | mov ecx, 128 |
1546 | mov ecx, 128 |
1547 | call memmove |
1547 | call memmove |
1548 | ret |
1548 | ret |
1549 | kbnobase: |
1549 | kbnobase: |
1550 | dec ecx |
1550 | dec ecx |
1551 | jnz kbnoshift |
1551 | jnz kbnoshift |
1552 | 1552 | ||
1553 | mov ebx, keymap_shift |
1553 | mov ebx, keymap_shift |
1554 | mov ecx, 128 |
1554 | mov ecx, 128 |
1555 | call memmove |
1555 | call memmove |
1556 | ret |
1556 | ret |
1557 | kbnoshift: |
1557 | kbnoshift: |
1558 | dec ecx |
1558 | dec ecx |
1559 | jnz kbnoalt |
1559 | jnz kbnoalt |
1560 | mov ebx, keymap_alt |
1560 | mov ebx, keymap_alt |
1561 | mov ecx, 128 |
1561 | mov ecx, 128 |
1562 | call memmove |
1562 | call memmove |
1563 | ret |
1563 | ret |
1564 | kbnoalt: |
1564 | kbnoalt: |
1565 | sub ecx, 6 |
1565 | sub ecx, 6 |
1566 | jnz kbnocountry |
1566 | jnz kbnocountry |
1567 | mov word [keyboard], dx |
1567 | mov word [keyboard], dx |
1568 | ret |
1568 | ret |
1569 | kbnocountry: |
1569 | kbnocountry: |
1570 | mov [esp+32], dword 1 |
1570 | mov [esp+32], dword 1 |
1571 | ret |
1571 | ret |
1572 | nsyse2: |
1572 | nsyse2: |
1573 | dec ebx ; CD |
1573 | dec ebx ; CD |
1574 | jnz nsyse4 |
1574 | jnz nsyse4 |
1575 | 1575 | ||
1576 | test ecx, ecx |
1576 | test ecx, ecx |
1577 | jz nosesl |
1577 | jz nosesl |
1578 | 1578 | ||
1579 | cmp ecx, 4 |
1579 | cmp ecx, 4 |
1580 | ja nosesl |
1580 | ja nosesl |
1581 | mov [cd_base], cl |
1581 | mov [cd_base], cl |
1582 | 1582 | ||
1583 | dec ecx |
1583 | dec ecx |
1584 | jnz noprma |
1584 | jnz noprma |
1585 | mov [cdbase], 0x1f0 |
1585 | mov [cdbase], 0x1f0 |
1586 | mov [cdid], 0xa0 |
1586 | mov [cdid], 0xa0 |
1587 | noprma: |
1587 | noprma: |
1588 | 1588 | ||
1589 | dec ecx |
1589 | dec ecx |
1590 | jnz noprsl |
1590 | jnz noprsl |
1591 | mov [cdbase], 0x1f0 |
1591 | mov [cdbase], 0x1f0 |
1592 | mov [cdid], 0xb0 |
1592 | mov [cdid], 0xb0 |
1593 | noprsl: |
1593 | noprsl: |
1594 | dec ecx |
1594 | dec ecx |
1595 | jnz nosema |
1595 | jnz nosema |
1596 | mov [cdbase], 0x170 |
1596 | mov [cdbase], 0x170 |
1597 | mov [cdid], 0xa0 |
1597 | mov [cdid], 0xa0 |
1598 | nosema: |
1598 | nosema: |
1599 | dec ecx |
1599 | dec ecx |
1600 | jnz nosesl |
1600 | jnz nosesl |
1601 | mov [cdbase], 0x170 |
1601 | mov [cdbase], 0x170 |
1602 | mov [cdid], 0xb0 |
1602 | mov [cdid], 0xb0 |
1603 | nosesl: |
1603 | nosesl: |
1604 | ret |
1604 | ret |
1605 | 1605 | ||
1606 | iglobal |
1606 | iglobal |
1607 | cd_base db 0 |
1607 | cd_base db 0 |
1608 | 1608 | ||
1609 | endg |
1609 | endg |
1610 | nsyse4: |
1610 | nsyse4: |
1611 | 1611 | ||
1612 | sub ebx, 2 ; SYSTEM LANGUAGE |
1612 | sub ebx, 2 ; SYSTEM LANGUAGE |
1613 | jnz nsyse5 |
1613 | jnz nsyse5 |
1614 | mov [syslang], ecx |
1614 | mov [syslang], ecx |
1615 | ret |
1615 | ret |
1616 | nsyse5: |
1616 | nsyse5: |
1617 | 1617 | ||
1618 | sub ebx, 2 ; HD BASE |
1618 | sub ebx, 2 ; HD BASE |
1619 | jnz nsyse7 |
1619 | jnz nsyse7 |
1620 | 1620 | ||
1621 | test ecx, ecx |
1621 | test ecx, ecx |
1622 | jz nosethd |
1622 | jz nosethd |
1623 | 1623 | ||
1624 | cmp ecx, 4 |
1624 | cmp ecx, 4 |
1625 | ja nosethd |
1625 | ja nosethd |
1626 | mov [hd_base], cl |
1626 | mov [hd_base], cl |
1627 | 1627 | ||
1628 | cmp ecx, 1 |
1628 | cmp ecx, 1 |
1629 | jnz noprmahd |
1629 | jnz noprmahd |
1630 | mov [hdbase], 0x1f0 |
1630 | mov [hdbase], 0x1f0 |
1631 | and dword [hdid], 0x0 |
1631 | and dword [hdid], 0x0 |
1632 | mov dword [hdpos], ecx |
1632 | mov dword [hdpos], ecx |
1633 | ; call set_FAT32_variables |
1633 | ; call set_FAT32_variables |
1634 | noprmahd: |
1634 | noprmahd: |
1635 | 1635 | ||
1636 | cmp ecx, 2 |
1636 | cmp ecx, 2 |
1637 | jnz noprslhd |
1637 | jnz noprslhd |
1638 | mov [hdbase], 0x1f0 |
1638 | mov [hdbase], 0x1f0 |
1639 | mov [hdid], 0x10 |
1639 | mov [hdid], 0x10 |
1640 | mov dword [hdpos], ecx |
1640 | mov dword [hdpos], ecx |
1641 | ; call set_FAT32_variables |
1641 | ; call set_FAT32_variables |
1642 | noprslhd: |
1642 | noprslhd: |
1643 | 1643 | ||
1644 | cmp ecx, 3 |
1644 | cmp ecx, 3 |
1645 | jnz nosemahd |
1645 | jnz nosemahd |
1646 | mov [hdbase], 0x170 |
1646 | mov [hdbase], 0x170 |
1647 | and dword [hdid], 0x0 |
1647 | and dword [hdid], 0x0 |
1648 | mov dword [hdpos], ecx |
1648 | mov dword [hdpos], ecx |
1649 | ; call set_FAT32_variables |
1649 | ; call set_FAT32_variables |
1650 | nosemahd: |
1650 | nosemahd: |
1651 | 1651 | ||
1652 | cmp ecx, 4 |
1652 | cmp ecx, 4 |
1653 | jnz noseslhd |
1653 | jnz noseslhd |
1654 | mov [hdbase], 0x170 |
1654 | mov [hdbase], 0x170 |
1655 | mov [hdid], 0x10 |
1655 | mov [hdid], 0x10 |
1656 | mov dword [hdpos], ecx |
1656 | mov dword [hdpos], ecx |
1657 | ; call set_FAT32_variables |
1657 | ; call set_FAT32_variables |
1658 | noseslhd: |
1658 | noseslhd: |
1659 | call reserve_hd1 |
1659 | call reserve_hd1 |
1660 | call reserve_hd_channel |
1660 | call reserve_hd_channel |
1661 | call free_hd_channel |
1661 | call free_hd_channel |
1662 | and dword [hd1_status], 0 ; free |
1662 | and dword [hd1_status], 0 ; free |
1663 | nosethd: |
1663 | nosethd: |
1664 | ret |
1664 | ret |
1665 | 1665 | ||
1666 | iglobal |
1666 | iglobal |
1667 | hd_base db 0 |
1667 | hd_base db 0 |
1668 | endg |
1668 | endg |
1669 | 1669 | ||
1670 | nsyse7: |
1670 | nsyse7: |
1671 | 1671 | ||
1672 | ; cmp eax,8 ; HD PARTITION |
1672 | ; cmp eax,8 ; HD PARTITION |
1673 | dec ebx |
1673 | dec ebx |
1674 | jnz nsyse8 |
1674 | jnz nsyse8 |
1675 | mov [fat32part], ecx |
1675 | mov [fat32part], ecx |
1676 | ; call set_FAT32_variables |
1676 | ; call set_FAT32_variables |
1677 | call reserve_hd1 |
1677 | call reserve_hd1 |
1678 | call reserve_hd_channel |
1678 | call reserve_hd_channel |
1679 | call free_hd_channel |
1679 | call free_hd_channel |
1680 | ; pusha |
1680 | ; pusha |
1681 | call choice_necessity_partition_1 |
1681 | call choice_necessity_partition_1 |
1682 | ; popa |
1682 | ; popa |
1683 | and dword [hd1_status], 0 ; free |
1683 | and dword [hd1_status], 0 ; free |
1684 | ret |
1684 | ret |
1685 | 1685 | ||
1686 | nsyse8: |
1686 | nsyse8: |
1687 | ; cmp eax,11 ; ENABLE LBA READ |
1687 | ; cmp eax,11 ; ENABLE LBA READ |
1688 | and ecx, 1 |
1688 | and ecx, 1 |
1689 | sub ebx, 3 |
1689 | sub ebx, 3 |
1690 | jnz no_set_lba_read |
1690 | jnz no_set_lba_read |
1691 | mov [lba_read_enabled], ecx |
1691 | mov [lba_read_enabled], ecx |
1692 | ret |
1692 | ret |
1693 | 1693 | ||
1694 | no_set_lba_read: |
1694 | no_set_lba_read: |
1695 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1695 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1696 | dec ebx |
1696 | dec ebx |
1697 | jnz sys_setup_err |
1697 | jnz sys_setup_err |
1698 | mov [pci_access_enabled], ecx |
1698 | mov [pci_access_enabled], ecx |
1699 | ret |
1699 | ret |
1700 | 1700 | ||
1701 | sys_setup_err: |
1701 | sys_setup_err: |
1702 | or [esp+32], dword -1 |
1702 | or [esp+32], dword -1 |
1703 | ret |
1703 | ret |
1704 | 1704 | ||
1705 | align 4 |
1705 | align 4 |
1706 | 1706 | ||
1707 | sys_getsetup: |
1707 | sys_getsetup: |
1708 | 1708 | ||
1709 | ; 1=roland mpu midi base , base io address |
1709 | ; 1=roland mpu midi base , base io address |
1710 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1710 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1711 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1711 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1712 | ; 5=system language, 1eng 2fi 3ger 4rus |
1712 | ; 5=system language, 1eng 2fi 3ger 4rus |
1713 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1713 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1714 | ; 8=fat32 partition in hd |
1714 | ; 8=fat32 partition in hd |
1715 | ; 9=get hs timer tic |
1715 | ; 9=get hs timer tic |
1716 | 1716 | ||
1717 | ; cmp eax,1 |
1717 | ; cmp eax,1 |
1718 | dec ebx |
1718 | dec ebx |
1719 | jnz ngsyse1 |
1719 | jnz ngsyse1 |
1720 | movzx eax, [midi_base] |
1720 | movzx eax, [midi_base] |
1721 | mov [esp+32], eax |
1721 | mov [esp+32], eax |
1722 | ret |
1722 | ret |
1723 | ngsyse1: |
1723 | ngsyse1: |
1724 | ; cmp eax,2 |
1724 | ; cmp eax,2 |
1725 | dec ebx |
1725 | dec ebx |
1726 | jnz ngsyse2 |
1726 | jnz ngsyse2 |
1727 | 1727 | ||
1728 | mov edi, [TASK_BASE] |
1728 | mov edi, [TASK_BASE] |
1729 | mov ebx, [edi+TASKDATA.mem_start] |
1729 | mov ebx, [edi+TASKDATA.mem_start] |
1730 | add ebx, edx |
1730 | add ebx, edx |
1731 | 1731 | ||
1732 | ; cmp ebx,1 |
1732 | ; cmp ebx,1 |
1733 | dec ecx |
1733 | dec ecx |
1734 | jnz kbnobaseret |
1734 | jnz kbnobaseret |
1735 | mov eax, keymap |
1735 | mov eax, keymap |
1736 | mov ecx, 128 |
1736 | mov ecx, 128 |
1737 | call memmove |
1737 | call memmove |
1738 | ret |
1738 | ret |
1739 | kbnobaseret: |
1739 | kbnobaseret: |
1740 | ; cmp ebx,2 |
1740 | ; cmp ebx,2 |
1741 | dec ecx |
1741 | dec ecx |
1742 | jnz kbnoshiftret |
1742 | jnz kbnoshiftret |
1743 | 1743 | ||
1744 | mov eax, keymap_shift |
1744 | mov eax, keymap_shift |
1745 | mov ecx, 128 |
1745 | mov ecx, 128 |
1746 | call memmove |
1746 | call memmove |
1747 | ret |
1747 | ret |
1748 | kbnoshiftret: |
1748 | kbnoshiftret: |
1749 | ; cmp ebx,3 |
1749 | ; cmp ebx,3 |
1750 | dec ecx |
1750 | dec ecx |
1751 | jne kbnoaltret |
1751 | jne kbnoaltret |
1752 | 1752 | ||
1753 | mov eax, keymap_alt |
1753 | mov eax, keymap_alt |
1754 | mov ecx, 128 |
1754 | mov ecx, 128 |
1755 | call memmove |
1755 | call memmove |
1756 | ret |
1756 | ret |
1757 | kbnoaltret: |
1757 | kbnoaltret: |
1758 | ; cmp ebx,9 |
1758 | ; cmp ebx,9 |
1759 | sub ecx, 6 |
1759 | sub ecx, 6 |
1760 | jnz ngsyse2 |
1760 | jnz ngsyse2 |
1761 | movzx eax, word [keyboard] |
1761 | movzx eax, word [keyboard] |
1762 | mov [esp+32], eax |
1762 | mov [esp+32], eax |
1763 | ret |
1763 | ret |
1764 | 1764 | ||
1765 | 1765 | ||
1766 | ngsyse2: |
1766 | ngsyse2: |
1767 | ; cmp eax,3 |
1767 | ; cmp eax,3 |
1768 | dec ebx |
1768 | dec ebx |
1769 | jnz ngsyse3 |
1769 | jnz ngsyse3 |
1770 | movzx eax, [cd_base] |
1770 | movzx eax, [cd_base] |
1771 | mov [esp+32], eax |
1771 | mov [esp+32], eax |
1772 | ret |
1772 | ret |
1773 | ngsyse3: |
1773 | ngsyse3: |
1774 | ; cmp eax,5 |
1774 | ; cmp eax,5 |
1775 | sub ebx, 2 |
1775 | sub ebx, 2 |
1776 | jnz ngsyse5 |
1776 | jnz ngsyse5 |
1777 | mov eax, [syslang] |
1777 | mov eax, [syslang] |
1778 | mov [esp+32], eax |
1778 | mov [esp+32], eax |
1779 | ret |
1779 | ret |
1780 | ngsyse5: |
1780 | ngsyse5: |
1781 | ; cmp eax,7 |
1781 | ; cmp eax,7 |
1782 | sub ebx, 2 |
1782 | sub ebx, 2 |
1783 | jnz ngsyse7 |
1783 | jnz ngsyse7 |
1784 | movzx eax, [hd_base] |
1784 | movzx eax, [hd_base] |
1785 | mov [esp+32], eax |
1785 | mov [esp+32], eax |
1786 | ret |
1786 | ret |
1787 | ngsyse7: |
1787 | ngsyse7: |
1788 | ; cmp eax,8 |
1788 | ; cmp eax,8 |
1789 | dec ebx |
1789 | dec ebx |
1790 | jnz ngsyse8 |
1790 | jnz ngsyse8 |
1791 | mov eax, [fat32part] |
1791 | mov eax, [fat32part] |
1792 | mov [esp+32], eax |
1792 | mov [esp+32], eax |
1793 | ret |
1793 | ret |
1794 | ngsyse8: |
1794 | ngsyse8: |
1795 | ; cmp eax,9 |
1795 | ; cmp eax,9 |
1796 | dec ebx |
1796 | dec ebx |
1797 | jnz ngsyse9 |
1797 | jnz ngsyse9 |
1798 | mov eax, [timer_ticks];[0xfdf0] |
1798 | mov eax, [timer_ticks];[0xfdf0] |
1799 | mov [esp+32], eax |
1799 | mov [esp+32], eax |
1800 | ret |
1800 | ret |
1801 | ngsyse9: |
1801 | ngsyse9: |
1802 | ; cmp eax,11 |
1802 | ; cmp eax,11 |
1803 | sub ebx, 2 |
1803 | sub ebx, 2 |
1804 | jnz ngsyse11 |
1804 | jnz ngsyse11 |
1805 | mov eax, [lba_read_enabled] |
1805 | mov eax, [lba_read_enabled] |
1806 | mov [esp+32], eax |
1806 | mov [esp+32], eax |
1807 | ret |
1807 | ret |
1808 | ngsyse11: |
1808 | ngsyse11: |
1809 | ; cmp eax,12 |
1809 | ; cmp eax,12 |
1810 | dec ebx |
1810 | dec ebx |
1811 | jnz ngsyse12 |
1811 | jnz ngsyse12 |
1812 | mov eax, [pci_access_enabled] |
1812 | mov eax, [pci_access_enabled] |
1813 | mov [esp+32], eax |
1813 | mov [esp+32], eax |
1814 | ret |
1814 | ret |
1815 | ngsyse12: |
1815 | ngsyse12: |
1816 | mov [esp+32], dword 1 |
1816 | mov [esp+32], dword 1 |
1817 | ret |
1817 | ret |
1818 | 1818 | ||
1819 | 1819 | ||
1820 | get_timer_ticks: |
1820 | get_timer_ticks: |
1821 | mov eax, [timer_ticks] |
1821 | mov eax, [timer_ticks] |
1822 | ret |
1822 | ret |
1823 | 1823 | ||
1824 | iglobal |
1824 | iglobal |
1825 | align 4 |
1825 | align 4 |
1826 | mousefn dd msscreen, mswin, msbutton, msset |
1826 | mousefn dd msscreen, mswin, msbutton, msset |
1827 | dd app_load_cursor |
1827 | dd app_load_cursor |
1828 | dd app_set_cursor |
1828 | dd app_set_cursor |
1829 | dd app_delete_cursor |
1829 | dd app_delete_cursor |
1830 | dd msz |
1830 | dd msz |
1831 | endg |
1831 | endg |
1832 | 1832 | ||
1833 | readmousepos: |
1833 | readmousepos: |
1834 | 1834 | ||
1835 | ; eax=0 screen relative |
1835 | ; eax=0 screen relative |
1836 | ; eax=1 window relative |
1836 | ; eax=1 window relative |
1837 | ; eax=2 buttons pressed |
1837 | ; eax=2 buttons pressed |
1838 | ; eax=3 set mouse pos ; reserved |
1838 | ; eax=3 set mouse pos ; reserved |
1839 | ; eax=4 load cursor |
1839 | ; eax=4 load cursor |
1840 | ; eax=5 set cursor |
1840 | ; eax=5 set cursor |
1841 | ; eax=6 delete cursor ; reserved |
1841 | ; eax=6 delete cursor ; reserved |
1842 | ; eax=7 get mouse_z |
1842 | ; eax=7 get mouse_z |
1843 | 1843 | ||
1844 | cmp ebx, 7 |
1844 | cmp ebx, 7 |
1845 | ja msset |
1845 | ja msset |
1846 | jmp [mousefn+ebx*4] |
1846 | jmp [mousefn+ebx*4] |
1847 | msscreen: |
1847 | msscreen: |
1848 | mov eax, [MOUSE_X] |
1848 | mov eax, [MOUSE_X] |
1849 | shl eax, 16 |
1849 | shl eax, 16 |
1850 | mov ax, [MOUSE_Y] |
1850 | mov ax, [MOUSE_Y] |
1851 | mov [esp+36-4], eax |
1851 | mov [esp+36-4], eax |
1852 | ret |
1852 | ret |
1853 | mswin: |
1853 | mswin: |
1854 | mov eax, [MOUSE_X] |
1854 | mov eax, [MOUSE_X] |
1855 | shl eax, 16 |
1855 | shl eax, 16 |
1856 | mov ax, [MOUSE_Y] |
1856 | mov ax, [MOUSE_Y] |
1857 | mov esi, [TASK_BASE] |
1857 | mov esi, [TASK_BASE] |
1858 | mov bx, word [esi-twdw+WDATA.box.left] |
1858 | mov bx, word [esi-twdw+WDATA.box.left] |
1859 | shl ebx, 16 |
1859 | shl ebx, 16 |
1860 | mov bx, word [esi-twdw+WDATA.box.top] |
1860 | mov bx, word [esi-twdw+WDATA.box.top] |
1861 | sub eax, ebx |
1861 | sub eax, ebx |
1862 | 1862 | ||
1863 | mov edi, [CURRENT_TASK] |
1863 | mov edi, [CURRENT_TASK] |
1864 | shl edi, 8 |
1864 | shl edi, 8 |
1865 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1865 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1866 | rol eax, 16 |
1866 | rol eax, 16 |
1867 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1867 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1868 | rol eax, 16 |
1868 | rol eax, 16 |
1869 | mov [esp+36-4], eax |
1869 | mov [esp+36-4], eax |
1870 | ret |
1870 | ret |
1871 | msbutton: |
1871 | msbutton: |
1872 | movzx eax, byte [BTN_DOWN] |
1872 | movzx eax, byte [BTN_DOWN] |
1873 | mov [esp+36-4], eax |
1873 | mov [esp+36-4], eax |
1874 | ret |
1874 | ret |
1875 | msz: |
1875 | msz: |
1876 | mov edi, [TASK_COUNT] |
1876 | mov edi, [TASK_COUNT] |
1877 | movzx edi, word [WIN_POS + edi*2] |
1877 | movzx edi, word [WIN_POS + edi*2] |
1878 | cmp edi, [CURRENT_TASK] |
1878 | cmp edi, [CURRENT_TASK] |
1879 | jne @f |
1879 | jne @f |
1880 | mov ax, [MOUSE_SCROLL_H] |
1880 | mov ax, [MOUSE_SCROLL_H] |
1881 | shl eax, 16 |
1881 | shl eax, 16 |
1882 | mov ax, [MOUSE_SCROLL_V] |
1882 | mov ax, [MOUSE_SCROLL_V] |
1883 | mov [esp+36-4], eax |
1883 | mov [esp+36-4], eax |
1884 | and [MOUSE_SCROLL_H], word 0 |
1884 | and [MOUSE_SCROLL_H], word 0 |
1885 | and [MOUSE_SCROLL_V], word 0 |
1885 | and [MOUSE_SCROLL_V], word 0 |
1886 | ret |
1886 | ret |
1887 | @@: |
1887 | @@: |
1888 | and [esp+36-4], dword 0 |
1888 | and [esp+36-4], dword 0 |
1889 | ; ret |
1889 | ; ret |
1890 | msset: |
1890 | msset: |
1891 | ret |
1891 | ret |
1892 | 1892 | ||
1893 | app_load_cursor: |
1893 | app_load_cursor: |
1894 | cmp ecx, OS_BASE |
1894 | cmp ecx, OS_BASE |
1895 | jae msset |
1895 | jae msset |
1896 | stdcall load_cursor, ecx, edx |
1896 | stdcall load_cursor, ecx, edx |
1897 | mov [esp+36-4], eax |
1897 | mov [esp+36-4], eax |
1898 | ret |
1898 | ret |
1899 | 1899 | ||
1900 | app_set_cursor: |
1900 | app_set_cursor: |
1901 | stdcall set_cursor, ecx |
1901 | stdcall set_cursor, ecx |
1902 | mov [esp+36-4], eax |
1902 | mov [esp+36-4], eax |
1903 | ret |
1903 | ret |
1904 | 1904 | ||
1905 | app_delete_cursor: |
1905 | app_delete_cursor: |
1906 | stdcall delete_cursor, ecx |
1906 | stdcall delete_cursor, ecx |
1907 | mov [esp+36-4], eax |
1907 | mov [esp+36-4], eax |
1908 | ret |
1908 | ret |
1909 | 1909 | ||
1910 | is_input: |
1910 | is_input: |
1911 | 1911 | ||
1912 | push edx |
1912 | push edx |
1913 | mov dx, word [midisp] |
1913 | mov dx, word [midisp] |
1914 | in al, dx |
1914 | in al, dx |
1915 | and al, 0x80 |
1915 | and al, 0x80 |
1916 | pop edx |
1916 | pop edx |
1917 | ret |
1917 | ret |
1918 | 1918 | ||
1919 | is_output: |
1919 | is_output: |
1920 | 1920 | ||
1921 | push edx |
1921 | push edx |
1922 | mov dx, word [midisp] |
1922 | mov dx, word [midisp] |
1923 | in al, dx |
1923 | in al, dx |
1924 | and al, 0x40 |
1924 | and al, 0x40 |
1925 | pop edx |
1925 | pop edx |
1926 | ret |
1926 | ret |
1927 | 1927 | ||
1928 | 1928 | ||
1929 | get_mpu_in: |
1929 | get_mpu_in: |
1930 | 1930 | ||
1931 | push edx |
1931 | push edx |
1932 | mov dx, word [mididp] |
1932 | mov dx, word [mididp] |
1933 | in al, dx |
1933 | in al, dx |
1934 | pop edx |
1934 | pop edx |
1935 | ret |
1935 | ret |
1936 | 1936 | ||
1937 | 1937 | ||
1938 | put_mpu_out: |
1938 | put_mpu_out: |
1939 | 1939 | ||
1940 | push edx |
1940 | push edx |
1941 | mov dx, word [mididp] |
1941 | mov dx, word [mididp] |
1942 | out dx, al |
1942 | out dx, al |
1943 | pop edx |
1943 | pop edx |
1944 | ret |
1944 | ret |
1945 | 1945 | ||
1946 | 1946 | ||
1947 | 1947 | ||
1948 | align 4 |
1948 | align 4 |
1949 | 1949 | ||
1950 | sys_midi: |
1950 | sys_midi: |
1951 | cmp [mididp], 0 |
1951 | cmp [mididp], 0 |
1952 | jnz sm0 |
1952 | jnz sm0 |
1953 | mov [esp+36], dword 1 |
1953 | mov [esp+36], dword 1 |
1954 | ret |
1954 | ret |
1955 | sm0: |
1955 | sm0: |
1956 | and [esp+36], dword 0 |
1956 | and [esp+36], dword 0 |
1957 | dec ebx |
1957 | dec ebx |
1958 | jnz smn1 |
1958 | jnz smn1 |
1959 | ; call setuart |
1959 | ; call setuart |
1960 | su1: |
1960 | su1: |
1961 | call is_output |
1961 | call is_output |
1962 | test al, al |
1962 | test al, al |
1963 | jnz su1 |
1963 | jnz su1 |
1964 | mov dx, word [midisp] |
1964 | mov dx, word [midisp] |
1965 | mov al, 0xff |
1965 | mov al, 0xff |
1966 | out dx, al |
1966 | out dx, al |
1967 | su2: |
1967 | su2: |
1968 | mov dx, word [midisp] |
1968 | mov dx, word [midisp] |
1969 | mov al, 0xff |
1969 | mov al, 0xff |
1970 | out dx, al |
1970 | out dx, al |
1971 | call is_input |
1971 | call is_input |
1972 | test al, al |
1972 | test al, al |
1973 | jnz su2 |
1973 | jnz su2 |
1974 | call get_mpu_in |
1974 | call get_mpu_in |
1975 | cmp al, 0xfe |
1975 | cmp al, 0xfe |
1976 | jnz su2 |
1976 | jnz su2 |
1977 | su3: |
1977 | su3: |
1978 | call is_output |
1978 | call is_output |
1979 | test al, al |
1979 | test al, al |
1980 | jnz su3 |
1980 | jnz su3 |
1981 | mov dx, word [midisp] |
1981 | mov dx, word [midisp] |
1982 | mov al, 0x3f |
1982 | mov al, 0x3f |
1983 | out dx, al |
1983 | out dx, al |
1984 | ret |
1984 | ret |
1985 | smn1: |
1985 | smn1: |
1986 | dec ebx |
1986 | dec ebx |
1987 | jnz smn2 |
1987 | jnz smn2 |
1988 | sm10: |
1988 | sm10: |
1989 | call get_mpu_in |
1989 | call get_mpu_in |
1990 | call is_output |
1990 | call is_output |
1991 | test al, al |
1991 | test al, al |
1992 | jnz sm10 |
1992 | jnz sm10 |
1993 | mov al, bl |
1993 | mov al, bl |
1994 | call put_mpu_out |
1994 | call put_mpu_out |
1995 | smn2: |
1995 | smn2: |
1996 | ret |
1996 | ret |
1997 | 1997 | ||
1998 | detect_devices: |
1998 | detect_devices: |
1999 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1999 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2000 | ;include 'detect/commouse.inc' |
2000 | ;include 'detect/commouse.inc' |
2001 | ;include 'detect/ps2mouse.inc' |
2001 | ;include 'detect/ps2mouse.inc' |
2002 | ;include 'detect/dev_fd.inc' |
2002 | ;include 'detect/dev_fd.inc' |
2003 | ;include 'detect/dev_hdcd.inc' |
2003 | ;include 'detect/dev_hdcd.inc' |
2004 | ;include 'detect/sear_par.inc' |
2004 | ;include 'detect/sear_par.inc' |
2005 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2005 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2006 | ret |
2006 | ret |
2007 | 2007 | ||
2008 | sys_end: |
2008 | sys_end: |
2009 | ;-------------------------------------- |
2009 | ;-------------------------------------- |
2010 | cmp [_display.select_cursor], 0 |
2010 | cmp [_display.select_cursor], 0 |
2011 | je @f |
2011 | je @f |
2012 | ; restore default cursor before killing |
2012 | ; restore default cursor before killing |
2013 | pusha |
2013 | pusha |
2014 | mov ecx, [current_slot] |
2014 | mov ecx, [current_slot] |
2015 | call restore_default_cursor_before_killing |
2015 | call restore_default_cursor_before_killing |
2016 | popa |
2016 | popa |
2017 | @@: |
2017 | @@: |
2018 | ;-------------------------------------- |
2018 | ;-------------------------------------- |
2019 | ; kill all sockets this process owns |
2019 | ; kill all sockets this process owns |
2020 | pusha |
2020 | pusha |
2021 | mov edx, [TASK_BASE] |
2021 | mov edx, [TASK_BASE] |
2022 | mov edx, [edx+TASKDATA.pid] |
2022 | mov edx, [edx+TASKDATA.pid] |
2023 | call SOCKET_process_end |
2023 | call SOCKET_process_end |
2024 | popa |
2024 | popa |
2025 | ;-------------------------------------- |
2025 | ;-------------------------------------- |
2026 | mov ecx, [current_slot] |
2026 | mov ecx, [current_slot] |
2027 | mov eax, [ecx+APPDATA.tls_base] |
2027 | mov eax, [ecx+APPDATA.tls_base] |
2028 | test eax, eax |
2028 | test eax, eax |
2029 | jz @F |
2029 | jz @F |
2030 | 2030 | ||
2031 | stdcall user_free, eax |
2031 | stdcall user_free, eax |
2032 | @@: |
2032 | @@: |
2033 | 2033 | ||
2034 | mov eax, [TASK_BASE] |
2034 | mov eax, [TASK_BASE] |
2035 | mov [eax+TASKDATA.state], 3; terminate this program |
2035 | mov [eax+TASKDATA.state], 3; terminate this program |
2036 | call wakeup_osloop |
2036 | call wakeup_osloop |
2037 | 2037 | ||
2038 | .waitterm: ; wait here for termination |
2038 | .waitterm: ; wait here for termination |
2039 | call change_task |
2039 | call change_task |
2040 | jmp .waitterm |
2040 | jmp .waitterm |
2041 | ;------------------------------------------------------------------------------ |
2041 | ;------------------------------------------------------------------------------ |
2042 | align 4 |
2042 | align 4 |
2043 | restore_default_cursor_before_killing: |
2043 | restore_default_cursor_before_killing: |
2044 | pushfd |
2044 | pushfd |
2045 | cli |
2045 | cli |
2046 | mov eax, [def_cursor] |
2046 | mov eax, [def_cursor] |
2047 | mov [ecx+APPDATA.cursor], eax |
2047 | mov [ecx+APPDATA.cursor], eax |
2048 | 2048 | ||
2049 | movzx eax, word [MOUSE_Y] |
2049 | movzx eax, word [MOUSE_Y] |
2050 | movzx ebx, word [MOUSE_X] |
2050 | movzx ebx, word [MOUSE_X] |
2051 | ; mov ecx, [Screen_Max_X] |
2051 | ; mov ecx, [Screen_Max_X] |
2052 | ; inc ecx |
2052 | ; inc ecx |
2053 | ; mul ecx |
2053 | ; mul ecx |
2054 | mov eax, [d_width_calc_area + eax*4] |
2054 | mov eax, [d_width_calc_area + eax*4] |
2055 | 2055 | ||
2056 | add eax, [_WinMapAddress] |
2056 | add eax, [_WinMapAddress] |
2057 | movzx edx, byte [ebx+eax] |
2057 | movzx edx, byte [ebx+eax] |
2058 | shl edx, 8 |
2058 | shl edx, 8 |
2059 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2059 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2060 | 2060 | ||
2061 | cmp esi, [current_cursor] |
2061 | cmp esi, [current_cursor] |
2062 | je @f |
2062 | je @f |
2063 | 2063 | ||
2064 | push esi |
2064 | push esi |
2065 | call [_display.select_cursor] |
2065 | call [_display.select_cursor] |
2066 | mov [current_cursor], esi |
2066 | mov [current_cursor], esi |
2067 | @@: |
2067 | @@: |
2068 | mov [redrawmouse_unconditional], 1 |
2068 | mov [redrawmouse_unconditional], 1 |
2069 | call wakeup_osloop |
2069 | call wakeup_osloop |
2070 | popfd |
2070 | popfd |
2071 | ret |
2071 | ret |
2072 | ;------------------------------------------------------------------------------ |
2072 | ;------------------------------------------------------------------------------ |
2073 | iglobal |
2073 | iglobal |
2074 | align 4 |
2074 | align 4 |
2075 | sys_system_table: |
2075 | sys_system_table: |
2076 | dd sysfn_deactivate ; 1 = deactivate window |
2076 | dd sysfn_deactivate ; 1 = deactivate window |
2077 | dd sysfn_terminate ; 2 = terminate thread |
2077 | dd sysfn_terminate ; 2 = terminate thread |
2078 | dd sysfn_activate ; 3 = activate window |
2078 | dd sysfn_activate ; 3 = activate window |
2079 | dd sysfn_getidletime ; 4 = get idle time |
2079 | dd sysfn_getidletime ; 4 = get idle time |
2080 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2080 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2081 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2081 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2082 | dd sysfn_getactive ; 7 = get active window |
2082 | dd sysfn_getactive ; 7 = get active window |
2083 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2083 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2084 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2084 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2085 | dd sysfn_minimize ; 10 = minimize window |
2085 | dd sysfn_minimize ; 10 = minimize window |
2086 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2086 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2087 | dd sysfn_lastkey ; 12 = get last pressed key |
2087 | dd sysfn_lastkey ; 12 = get last pressed key |
2088 | dd sysfn_getversion ; 13 = get kernel version |
2088 | dd sysfn_getversion ; 13 = get kernel version |
2089 | dd sysfn_waitretrace ; 14 = wait retrace |
2089 | dd sysfn_waitretrace ; 14 = wait retrace |
2090 | dd sysfn_centermouse ; 15 = center mouse cursor |
2090 | dd sysfn_centermouse ; 15 = center mouse cursor |
2091 | dd sysfn_getfreemem ; 16 = get free memory size |
2091 | dd sysfn_getfreemem ; 16 = get free memory size |
2092 | dd sysfn_getallmem ; 17 = get total memory size |
2092 | dd sysfn_getallmem ; 17 = get total memory size |
2093 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2093 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2094 | ; instead of slot |
2094 | ; instead of slot |
2095 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2095 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2096 | dd sysfn_meminfo ; 20 = get extended memory info |
2096 | dd sysfn_meminfo ; 20 = get extended memory info |
2097 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2097 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2098 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2098 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2099 | dd sysfn_min_windows ; 23 = minimize all windows |
2099 | dd sysfn_min_windows ; 23 = minimize all windows |
2100 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2100 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2101 | sysfn_num = ($ - sys_system_table)/4 |
2101 | sysfn_num = ($ - sys_system_table)/4 |
2102 | endg |
2102 | endg |
2103 | ;------------------------------------------------------------------------------ |
2103 | ;------------------------------------------------------------------------------ |
2104 | sys_system: |
2104 | sys_system: |
2105 | dec ebx |
2105 | dec ebx |
2106 | cmp ebx, sysfn_num |
2106 | cmp ebx, sysfn_num |
2107 | jae @f |
2107 | jae @f |
2108 | jmp dword [sys_system_table + ebx*4] |
2108 | jmp dword [sys_system_table + ebx*4] |
2109 | @@: |
2109 | @@: |
2110 | ret |
2110 | ret |
2111 | ;------------------------------------------------------------------------------ |
2111 | ;------------------------------------------------------------------------------ |
2112 | sysfn_shutdown: ; 18.9 = system shutdown |
2112 | sysfn_shutdown: ; 18.9 = system shutdown |
2113 | cmp ecx, 1 |
2113 | cmp ecx, 1 |
2114 | jl exit_for_anyone |
2114 | jl exit_for_anyone |
2115 | cmp ecx, 4 |
2115 | cmp ecx, 4 |
2116 | jg exit_for_anyone |
2116 | jg exit_for_anyone |
2117 | mov [BOOT_VAR+0x9030], cl |
2117 | mov [BOOT_VAR+0x9030], cl |
2118 | 2118 | ||
2119 | mov eax, [TASK_COUNT] |
2119 | mov eax, [TASK_COUNT] |
2120 | mov [SYS_SHUTDOWN], al |
2120 | mov [SYS_SHUTDOWN], al |
2121 | mov [shutdown_processes], eax |
2121 | mov [shutdown_processes], eax |
2122 | call wakeup_osloop |
2122 | call wakeup_osloop |
2123 | and dword [esp+32], 0 |
2123 | and dword [esp+32], 0 |
2124 | exit_for_anyone: |
2124 | exit_for_anyone: |
2125 | ret |
2125 | ret |
2126 | uglobal |
2126 | uglobal |
2127 | shutdown_processes: |
2127 | shutdown_processes: |
2128 | dd 0x0 |
2128 | dd 0x0 |
2129 | endg |
2129 | endg |
2130 | ;------------------------------------------------------------------------------ |
2130 | ;------------------------------------------------------------------------------ |
2131 | sysfn_terminate: ; 18.2 = TERMINATE |
2131 | sysfn_terminate: ; 18.2 = TERMINATE |
2132 | push ecx |
2132 | push ecx |
2133 | cmp ecx, 2 |
2133 | cmp ecx, 2 |
2134 | jb noprocessterminate |
2134 | jb noprocessterminate |
2135 | mov edx, [TASK_COUNT] |
2135 | mov edx, [TASK_COUNT] |
2136 | cmp ecx, edx |
2136 | cmp ecx, edx |
2137 | ja noprocessterminate |
2137 | ja noprocessterminate |
2138 | mov eax, [TASK_COUNT] |
2138 | mov eax, [TASK_COUNT] |
2139 | shl ecx, 5 |
2139 | shl ecx, 5 |
2140 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2140 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2141 | add ecx, CURRENT_TASK+TASKDATA.state |
2141 | add ecx, CURRENT_TASK+TASKDATA.state |
2142 | cmp byte [ecx], 9 |
2142 | cmp byte [ecx], 9 |
2143 | jz noprocessterminate |
2143 | jz noprocessterminate |
2144 | push ecx edx |
2144 | push ecx edx |
2145 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2145 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2146 | call request_terminate |
2146 | call request_terminate |
2147 | pop edx ecx |
2147 | pop edx ecx |
2148 | test eax, eax |
2148 | test eax, eax |
2149 | jz noprocessterminate |
2149 | jz noprocessterminate |
2150 | ;-------------------------------------- |
2150 | ;-------------------------------------- |
2151 | ; terminate all network sockets it used |
2151 | ; terminate all network sockets it used |
2152 | pusha |
2152 | pusha |
2153 | mov eax, edx |
2153 | mov eax, edx |
2154 | call SOCKET_process_end |
2154 | call SOCKET_process_end |
2155 | popa |
2155 | popa |
2156 | ;-------------------------------------- |
2156 | ;-------------------------------------- |
2157 | cmp [_display.select_cursor], 0 |
2157 | cmp [_display.select_cursor], 0 |
2158 | je .restore_end |
2158 | je .restore_end |
2159 | ; restore default cursor before killing |
2159 | ; restore default cursor before killing |
2160 | pusha |
2160 | pusha |
2161 | mov ecx, [esp+32] |
2161 | mov ecx, [esp+32] |
2162 | shl ecx, 8 |
2162 | shl ecx, 8 |
2163 | add ecx, SLOT_BASE |
2163 | add ecx, SLOT_BASE |
2164 | mov eax, [def_cursor] |
2164 | mov eax, [def_cursor] |
2165 | cmp [ecx+APPDATA.cursor], eax |
2165 | cmp [ecx+APPDATA.cursor], eax |
2166 | je @f |
2166 | je @f |
2167 | call restore_default_cursor_before_killing |
2167 | call restore_default_cursor_before_killing |
2168 | @@: |
2168 | @@: |
2169 | popa |
2169 | popa |
2170 | .restore_end: |
2170 | .restore_end: |
2171 | ;-------------------------------------- |
2171 | ;-------------------------------------- |
2172 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2172 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2173 | mov [ecx], byte 3; clear possible i40's |
2173 | mov [ecx], byte 3; clear possible i40's |
2174 | call wakeup_osloop |
2174 | call wakeup_osloop |
2175 | ;call MEM_Heap_UnLock |
2175 | ;call MEM_Heap_UnLock |
2176 | 2176 | ||
2177 | cmp edx, [application_table_owner]; clear app table stat |
2177 | cmp edx, [application_table_owner]; clear app table stat |
2178 | jne noatsc |
2178 | jne noatsc |
2179 | call unlock_application_table |
2179 | call unlock_application_table |
2180 | noatsc: |
2180 | noatsc: |
2181 | noprocessterminate: |
2181 | noprocessterminate: |
2182 | add esp, 4 |
2182 | add esp, 4 |
2183 | ret |
2183 | ret |
2184 | ;------------------------------------------------------------------------------ |
2184 | ;------------------------------------------------------------------------------ |
2185 | sysfn_terminate2: |
2185 | sysfn_terminate2: |
2186 | ;lock application_table_status mutex |
2186 | ;lock application_table_status mutex |
2187 | .table_status: |
2187 | .table_status: |
2188 | call lock_application_table |
2188 | call lock_application_table |
2189 | mov eax, ecx |
2189 | mov eax, ecx |
2190 | call pid_to_slot |
2190 | call pid_to_slot |
2191 | test eax, eax |
2191 | test eax, eax |
2192 | jz .not_found |
2192 | jz .not_found |
2193 | mov ecx, eax |
2193 | mov ecx, eax |
2194 | cli |
2194 | cli |
2195 | call sysfn_terminate |
2195 | call sysfn_terminate |
2196 | call unlock_application_table |
2196 | call unlock_application_table |
2197 | sti |
2197 | sti |
2198 | and dword [esp+32], 0 |
2198 | and dword [esp+32], 0 |
2199 | ret |
2199 | ret |
2200 | .not_found: |
2200 | .not_found: |
2201 | call unlock_application_table |
2201 | call unlock_application_table |
2202 | or dword [esp+32], -1 |
2202 | or dword [esp+32], -1 |
2203 | ret |
2203 | ret |
2204 | ;------------------------------------------------------------------------------ |
2204 | ;------------------------------------------------------------------------------ |
2205 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2205 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2206 | cmp ecx, 2 |
2206 | cmp ecx, 2 |
2207 | jb .nowindowdeactivate |
2207 | jb .nowindowdeactivate |
2208 | cmp ecx, [TASK_COUNT] |
2208 | cmp ecx, [TASK_COUNT] |
2209 | ja .nowindowdeactivate |
2209 | ja .nowindowdeactivate |
2210 | 2210 | ||
2211 | movzx esi, word [WIN_STACK + ecx*2] |
2211 | movzx esi, word [WIN_STACK + ecx*2] |
2212 | cmp esi, 1 |
2212 | cmp esi, 1 |
2213 | je .nowindowdeactivate ; already deactive |
2213 | je .nowindowdeactivate ; already deactive |
2214 | 2214 | ||
2215 | mov edi, ecx |
2215 | mov edi, ecx |
2216 | shl edi, 5 |
2216 | shl edi, 5 |
2217 | add edi, window_data |
2217 | add edi, window_data |
2218 | movzx esi, word [WIN_STACK + ecx * 2] |
2218 | movzx esi, word [WIN_STACK + ecx * 2] |
2219 | lea esi, [WIN_POS + esi * 2] |
2219 | lea esi, [WIN_POS + esi * 2] |
2220 | call window._.window_deactivate |
2220 | call window._.window_deactivate |
2221 | 2221 | ||
2222 | call syscall_display_settings._.calculate_whole_screen |
2222 | call syscall_display_settings._.calculate_whole_screen |
2223 | call syscall_display_settings._.redraw_whole_screen |
2223 | call syscall_display_settings._.redraw_whole_screen |
2224 | .nowindowdeactivate: |
2224 | .nowindowdeactivate: |
2225 | ret |
2225 | ret |
2226 | ;------------------------------------------------------------------------------ |
2226 | ;------------------------------------------------------------------------------ |
2227 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2227 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2228 | cmp ecx, 2 |
2228 | cmp ecx, 2 |
2229 | jb .nowindowactivate |
2229 | jb .nowindowactivate |
2230 | cmp ecx, [TASK_COUNT] |
2230 | cmp ecx, [TASK_COUNT] |
2231 | ja .nowindowactivate |
2231 | ja .nowindowactivate |
2232 | ;------------------------------------- |
2232 | ;------------------------------------- |
2233 | @@: |
2233 | @@: |
2234 | ; If the window is captured and moved by the user, |
2234 | ; If the window is captured and moved by the user, |
2235 | ; then you can't change the position in window stack!!! |
2235 | ; then you can't change the position in window stack!!! |
2236 | mov al, [mouse.active_sys_window.action] |
2236 | mov al, [mouse.active_sys_window.action] |
2237 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2237 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2238 | test al, al |
2238 | test al, al |
2239 | jz @f |
2239 | jz @f |
2240 | call change_task |
2240 | call change_task |
2241 | jmp @b |
2241 | jmp @b |
2242 | @@: |
2242 | @@: |
2243 | ;------------------------------------- |
2243 | ;------------------------------------- |
2244 | mov [window_minimize], 2; restore window if minimized |
2244 | mov [window_minimize], 2; restore window if minimized |
2245 | call wakeup_osloop |
2245 | call wakeup_osloop |
2246 | 2246 | ||
2247 | movzx esi, word [WIN_STACK + ecx*2] |
2247 | movzx esi, word [WIN_STACK + ecx*2] |
2248 | cmp esi, [TASK_COUNT] |
2248 | cmp esi, [TASK_COUNT] |
2249 | je .nowindowactivate; already active |
2249 | je .nowindowactivate; already active |
2250 | 2250 | ||
2251 | mov edi, ecx |
2251 | mov edi, ecx |
2252 | shl edi, 5 |
2252 | shl edi, 5 |
2253 | add edi, window_data |
2253 | add edi, window_data |
2254 | movzx esi, word [WIN_STACK + ecx * 2] |
2254 | movzx esi, word [WIN_STACK + ecx * 2] |
2255 | lea esi, [WIN_POS + esi * 2] |
2255 | lea esi, [WIN_POS + esi * 2] |
2256 | call waredraw |
2256 | call waredraw |
2257 | .nowindowactivate: |
2257 | .nowindowactivate: |
2258 | ret |
2258 | ret |
2259 | ;------------------------------------------------------------------------------ |
2259 | ;------------------------------------------------------------------------------ |
2260 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2260 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2261 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2261 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2262 | mov [esp+32], eax |
2262 | mov [esp+32], eax |
2263 | ret |
2263 | ret |
2264 | ;------------------------------------------------------------------------------ |
2264 | ;------------------------------------------------------------------------------ |
2265 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2265 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2266 | mov eax, dword [cpu_freq] |
2266 | mov eax, dword [cpu_freq] |
2267 | mov [esp+32], eax |
2267 | mov [esp+32], eax |
2268 | ret |
2268 | ret |
2269 | ;------------------------------------------------------------------------------ |
2269 | ;------------------------------------------------------------------------------ |
2270 | get_cpu_freq: |
2270 | get_cpu_freq: |
2271 | mov eax, dword [cpu_freq] |
2271 | mov eax, dword [cpu_freq] |
2272 | mov edx, dword [cpu_freq+4] |
2272 | mov edx, dword [cpu_freq+4] |
2273 | ret |
2273 | ret |
2274 | ; SAVE ramdisk to /hd/1/menuet.img |
2274 | ; SAVE ramdisk to /hd/1/menuet.img |
2275 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2275 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2276 | include 'blkdev/rdsave.inc' |
2276 | include 'blkdev/rdsave.inc' |
2277 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2277 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2278 | ;------------------------------------------------------------------------------ |
2278 | ;------------------------------------------------------------------------------ |
2279 | align 4 |
2279 | align 4 |
2280 | sysfn_getactive: ; 18.7 = get active window |
2280 | sysfn_getactive: ; 18.7 = get active window |
2281 | mov eax, [TASK_COUNT] |
2281 | mov eax, [TASK_COUNT] |
2282 | movzx eax, word [WIN_POS + eax*2] |
2282 | movzx eax, word [WIN_POS + eax*2] |
2283 | mov [esp+32], eax |
2283 | mov [esp+32], eax |
2284 | ret |
2284 | ret |
2285 | ;------------------------------------------------------------------------------ |
2285 | ;------------------------------------------------------------------------------ |
2286 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2286 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2287 | ; cmp ecx,1 |
2287 | ; cmp ecx,1 |
2288 | dec ecx |
2288 | dec ecx |
2289 | jnz nogetsoundflag |
2289 | jnz nogetsoundflag |
2290 | movzx eax, byte [sound_flag]; get sound_flag |
2290 | movzx eax, byte [sound_flag]; get sound_flag |
2291 | mov [esp+32], eax |
2291 | mov [esp+32], eax |
2292 | ret |
2292 | ret |
2293 | nogetsoundflag: |
2293 | nogetsoundflag: |
2294 | ; cmp ecx,2 |
2294 | ; cmp ecx,2 |
2295 | dec ecx |
2295 | dec ecx |
2296 | jnz nosoundflag |
2296 | jnz nosoundflag |
2297 | xor byte [sound_flag], 1 |
2297 | xor byte [sound_flag], 1 |
2298 | nosoundflag: |
2298 | nosoundflag: |
2299 | ret |
2299 | ret |
2300 | ;------------------------------------------------------------------------------ |
2300 | ;------------------------------------------------------------------------------ |
2301 | sysfn_minimize: ; 18.10 = minimize window |
2301 | sysfn_minimize: ; 18.10 = minimize window |
2302 | mov [window_minimize], 1 |
2302 | mov [window_minimize], 1 |
2303 | call wakeup_osloop |
2303 | call wakeup_osloop |
2304 | ret |
2304 | ret |
2305 | ;------------------------------------------------------------------------------ |
2305 | ;------------------------------------------------------------------------------ |
2306 | align 4 |
2306 | align 4 |
2307 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2307 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2308 | ; cmp ecx,1 |
2308 | ; cmp ecx,1 |
2309 | dec ecx |
2309 | dec ecx |
2310 | jnz full_table |
2310 | jnz full_table |
2311 | small_table: |
2311 | small_table: |
2312 | call for_all_tables |
2312 | call for_all_tables |
2313 | mov ecx, 10 |
2313 | mov ecx, 10 |
2314 | cld |
2314 | cld |
2315 | rep movsb |
2315 | rep movsb |
2316 | ret |
2316 | ret |
2317 | for_all_tables: |
2317 | for_all_tables: |
2318 | mov edi, edx |
2318 | mov edi, edx |
2319 | mov esi, DRIVE_DATA |
2319 | mov esi, DRIVE_DATA |
2320 | ret |
2320 | ret |
2321 | full_table: |
2321 | full_table: |
2322 | ; cmp ecx,2 |
2322 | ; cmp ecx,2 |
2323 | dec ecx |
2323 | dec ecx |
2324 | jnz exit_for_anyone |
2324 | jnz exit_for_anyone |
2325 | call for_all_tables |
2325 | call for_all_tables |
2326 | mov ecx, 16384 |
2326 | mov ecx, 16384 |
2327 | cld |
2327 | cld |
2328 | rep movsd |
2328 | rep movsd |
2329 | ret |
2329 | ret |
2330 | ;------------------------------------------------------------------------------ |
2330 | ;------------------------------------------------------------------------------ |
2331 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2331 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2332 | and dword [esp+32], 0 |
2332 | and dword [esp+32], 0 |
2333 | ret |
2333 | ret |
2334 | ;------------------------------------------------------------------------------ |
2334 | ;------------------------------------------------------------------------------ |
2335 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2335 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2336 | mov edi, ecx |
2336 | mov edi, ecx |
2337 | mov esi, version_inf |
2337 | mov esi, version_inf |
2338 | mov ecx, version_end-version_inf |
2338 | mov ecx, version_end-version_inf |
2339 | rep movsb |
2339 | rep movsb |
2340 | ret |
2340 | ret |
2341 | ;------------------------------------------------------------------------------ |
2341 | ;------------------------------------------------------------------------------ |
2342 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2342 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2343 | ;wait retrace functions |
2343 | ;wait retrace functions |
2344 | sys_wait_retrace: |
2344 | sys_wait_retrace: |
2345 | mov edx, 0x3da |
2345 | mov edx, 0x3da |
2346 | WaitRetrace_loop: |
2346 | WaitRetrace_loop: |
2347 | in al, dx |
2347 | in al, dx |
2348 | test al, 1000b |
2348 | test al, 1000b |
2349 | jz WaitRetrace_loop |
2349 | jz WaitRetrace_loop |
2350 | and [esp+32], dword 0 |
2350 | and [esp+32], dword 0 |
2351 | ret |
2351 | ret |
2352 | ;------------------------------------------------------------------------------ |
2352 | ;------------------------------------------------------------------------------ |
2353 | align 4 |
2353 | align 4 |
2354 | sysfn_centermouse: ; 18.15 = mouse centered |
2354 | sysfn_centermouse: ; 18.15 = mouse centered |
2355 | ; removed here by |
2355 | ; removed here by |
2356 | ; call mouse_centered |
2356 | ; call mouse_centered |
2357 | ;* mouse centered - start code- Mario79 |
2357 | ;* mouse centered - start code- Mario79 |
2358 | ;mouse_centered: |
2358 | ;mouse_centered: |
2359 | ; push eax |
2359 | ; push eax |
2360 | mov eax, [Screen_Max_X] |
2360 | mov eax, [Screen_Max_X] |
2361 | shr eax, 1 |
2361 | shr eax, 1 |
2362 | mov [MOUSE_X], ax |
2362 | mov [MOUSE_X], ax |
2363 | mov eax, [Screen_Max_Y] |
2363 | mov eax, [Screen_Max_Y] |
2364 | shr eax, 1 |
2364 | shr eax, 1 |
2365 | mov [MOUSE_Y], ax |
2365 | mov [MOUSE_Y], ax |
2366 | call wakeup_osloop |
2366 | call wakeup_osloop |
2367 | ; ret |
2367 | ; ret |
2368 | ;* mouse centered - end code- Mario79 |
2368 | ;* mouse centered - end code- Mario79 |
2369 | xor eax, eax |
2369 | xor eax, eax |
2370 | and [esp+32], eax |
2370 | and [esp+32], eax |
2371 | ; pop eax |
2371 | ; pop eax |
2372 | ret |
2372 | ret |
2373 | ;------------------------------------------------------------------------------ |
2373 | ;------------------------------------------------------------------------------ |
2374 | align 4 |
2374 | align 4 |
2375 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2375 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2376 | test ecx, ecx; get mouse speed factor |
2376 | test ecx, ecx; get mouse speed factor |
2377 | jnz .set_mouse_acceleration |
2377 | jnz .set_mouse_acceleration |
2378 | xor eax, eax |
2378 | xor eax, eax |
2379 | mov ax, [mouse_speed_factor] |
2379 | mov ax, [mouse_speed_factor] |
2380 | mov [esp+32], eax |
2380 | mov [esp+32], eax |
2381 | ret |
2381 | ret |
2382 | .set_mouse_acceleration: |
2382 | .set_mouse_acceleration: |
2383 | ; cmp ecx,1 ; set mouse speed factor |
2383 | ; cmp ecx,1 ; set mouse speed factor |
2384 | dec ecx |
2384 | dec ecx |
2385 | jnz .get_mouse_delay |
2385 | jnz .get_mouse_delay |
2386 | mov [mouse_speed_factor], dx |
2386 | mov [mouse_speed_factor], dx |
2387 | ret |
2387 | ret |
2388 | .get_mouse_delay: |
2388 | .get_mouse_delay: |
2389 | ; cmp ecx,2 ; get mouse delay |
2389 | ; cmp ecx,2 ; get mouse delay |
2390 | dec ecx |
2390 | dec ecx |
2391 | jnz .set_mouse_delay |
2391 | jnz .set_mouse_delay |
2392 | mov eax, [mouse_delay] |
2392 | mov eax, [mouse_delay] |
2393 | mov [esp+32], eax |
2393 | mov [esp+32], eax |
2394 | ret |
2394 | ret |
2395 | .set_mouse_delay: |
2395 | .set_mouse_delay: |
2396 | ; cmp ecx,3 ; set mouse delay |
2396 | ; cmp ecx,3 ; set mouse delay |
2397 | dec ecx |
2397 | dec ecx |
2398 | jnz .set_pointer_position |
2398 | jnz .set_pointer_position |
2399 | mov [mouse_delay], edx |
2399 | mov [mouse_delay], edx |
2400 | ret |
2400 | ret |
2401 | .set_pointer_position: |
2401 | .set_pointer_position: |
2402 | ; cmp ecx,4 ; set mouse pointer position |
2402 | ; cmp ecx,4 ; set mouse pointer position |
2403 | dec ecx |
2403 | dec ecx |
2404 | jnz .set_mouse_button |
2404 | jnz .set_mouse_button |
2405 | cmp dx, word[Screen_Max_Y] |
2405 | cmp dx, word[Screen_Max_Y] |
2406 | ja .end |
2406 | ja .end |
2407 | rol edx, 16 |
2407 | rol edx, 16 |
2408 | cmp dx, word[Screen_Max_X] |
2408 | cmp dx, word[Screen_Max_X] |
2409 | ja .end |
2409 | ja .end |
2410 | mov [MOUSE_X], edx |
2410 | mov [MOUSE_X], edx |
2411 | call wakeup_osloop |
2411 | call wakeup_osloop |
2412 | ret |
2412 | ret |
2413 | .set_mouse_button: |
2413 | .set_mouse_button: |
2414 | ; cmp ecx,5 ; set mouse button features |
2414 | ; cmp ecx,5 ; set mouse button features |
2415 | dec ecx |
2415 | dec ecx |
2416 | jnz .end |
2416 | jnz .end |
2417 | mov [BTN_DOWN], dl |
2417 | mov [BTN_DOWN], dl |
2418 | mov [mouse_active], 1 |
2418 | mov [mouse_active], 1 |
2419 | call wakeup_osloop |
2419 | call wakeup_osloop |
2420 | .end: |
2420 | .end: |
2421 | ret |
2421 | ret |
2422 | ;------------------------------------------------------------------------------ |
2422 | ;------------------------------------------------------------------------------ |
2423 | sysfn_getfreemem: |
2423 | sysfn_getfreemem: |
2424 | mov eax, [pg_data.pages_free] |
2424 | mov eax, [pg_data.pages_free] |
2425 | shl eax, 2 |
2425 | shl eax, 2 |
2426 | mov [esp+32], eax |
2426 | mov [esp+32], eax |
2427 | ret |
2427 | ret |
2428 | ;------------------------------------------------------------------------------ |
2428 | ;------------------------------------------------------------------------------ |
2429 | sysfn_getallmem: |
2429 | sysfn_getallmem: |
2430 | mov eax, [MEM_AMOUNT] |
2430 | mov eax, [MEM_AMOUNT] |
2431 | shr eax, 10 |
2431 | shr eax, 10 |
2432 | mov [esp+32], eax |
2432 | mov [esp+32], eax |
2433 | ret |
2433 | ret |
2434 | ;------------------------------------------------------------------------------ |
2434 | ;------------------------------------------------------------------------------ |
2435 | sysfn_pid_to_slot: |
2435 | sysfn_pid_to_slot: |
2436 | mov eax, ecx |
2436 | mov eax, ecx |
2437 | call pid_to_slot |
2437 | call pid_to_slot |
2438 | mov [esp+32], eax |
2438 | mov [esp+32], eax |
2439 | ret |
2439 | ret |
2440 | ;------------------------------------------------------------------------------ |
2440 | ;------------------------------------------------------------------------------ |
2441 | sysfn_min_rest_window: |
2441 | sysfn_min_rest_window: |
2442 | pushad |
2442 | pushad |
2443 | mov eax, edx ; ebx - operating |
2443 | mov eax, edx ; ebx - operating |
2444 | shr ecx, 1 |
2444 | shr ecx, 1 |
2445 | jnc @f |
2445 | jnc @f |
2446 | call pid_to_slot |
2446 | call pid_to_slot |
2447 | @@: |
2447 | @@: |
2448 | or eax, eax ; eax - number of slot |
2448 | or eax, eax ; eax - number of slot |
2449 | jz .error |
2449 | jz .error |
2450 | cmp eax, 255 ; varify maximal slot number |
2450 | cmp eax, 255 ; varify maximal slot number |
2451 | ja .error |
2451 | ja .error |
2452 | movzx eax, word [WIN_STACK + eax*2] |
2452 | movzx eax, word [WIN_STACK + eax*2] |
2453 | shr ecx, 1 |
2453 | shr ecx, 1 |
2454 | jc .restore |
2454 | jc .restore |
2455 | ; .minimize: |
2455 | ; .minimize: |
2456 | call minimize_window |
2456 | call minimize_window |
2457 | jmp .exit |
2457 | jmp .exit |
2458 | .restore: |
2458 | .restore: |
2459 | call restore_minimized_window |
2459 | call restore_minimized_window |
2460 | .exit: |
2460 | .exit: |
2461 | popad |
2461 | popad |
2462 | xor eax, eax |
2462 | xor eax, eax |
2463 | mov [esp+32], eax |
2463 | mov [esp+32], eax |
2464 | ret |
2464 | ret |
2465 | .error: |
2465 | .error: |
2466 | popad |
2466 | popad |
2467 | xor eax, eax |
2467 | xor eax, eax |
2468 | dec eax |
2468 | dec eax |
2469 | mov [esp+32], eax |
2469 | mov [esp+32], eax |
2470 | ret |
2470 | ret |
2471 | ;------------------------------------------------------------------------------ |
2471 | ;------------------------------------------------------------------------------ |
2472 | sysfn_min_windows: |
2472 | sysfn_min_windows: |
2473 | call minimize_all_window |
2473 | call minimize_all_window |
2474 | mov [esp+32], eax |
2474 | mov [esp+32], eax |
2475 | call change_task |
2475 | call change_task |
2476 | ret |
2476 | ret |
2477 | ;------------------------------------------------------------------------------ |
2477 | ;------------------------------------------------------------------------------ |
2478 | sysfn_set_screen_sizes: |
2478 | sysfn_set_screen_sizes: |
2479 | cmp [SCR_MODE], word 0x13 |
2479 | cmp [SCR_MODE], word 0x13 |
2480 | jbe .exit |
2480 | jbe .exit |
2481 | 2481 | ||
2482 | cmp [_display.select_cursor], select_cursor |
2482 | cmp [_display.select_cursor], select_cursor |
2483 | jne .exit |
2483 | jne .exit |
2484 | 2484 | ||
2485 | cmp ecx, [display_width_standard] |
2485 | cmp ecx, [display_width_standard] |
2486 | ja .exit |
2486 | ja .exit |
2487 | 2487 | ||
2488 | cmp edx, [display_height_standard] |
2488 | cmp edx, [display_height_standard] |
2489 | ja .exit |
2489 | ja .exit |
2490 | 2490 | ||
2491 | pushfd |
2491 | pushfd |
2492 | cli |
2492 | cli |
2493 | mov eax, ecx |
2493 | mov eax, ecx |
2494 | mov ecx, [_display.pitch] |
2494 | mov ecx, [_display.pitch] |
2495 | mov [_display.width], eax |
2495 | mov [_display.width], eax |
2496 | dec eax |
2496 | dec eax |
2497 | mov [_display.height], edx |
2497 | mov [_display.height], edx |
2498 | dec edx |
2498 | dec edx |
2499 | ; eax - new Screen_Max_X |
2499 | ; eax - new Screen_Max_X |
2500 | ; edx - new Screen_Max_Y |
2500 | ; edx - new Screen_Max_Y |
2501 | mov [do_not_touch_winmap], 1 |
2501 | mov [do_not_touch_winmap], 1 |
2502 | call set_screen |
2502 | call set_screen |
2503 | mov [do_not_touch_winmap], 0 |
2503 | mov [do_not_touch_winmap], 0 |
2504 | popfd |
2504 | popfd |
2505 | call change_task |
2505 | call change_task |
2506 | .exit: |
2506 | .exit: |
2507 | ret |
2507 | ret |
2508 | ;------------------------------------------------------------------------------ |
2508 | ;------------------------------------------------------------------------------ |
2509 | uglobal |
2509 | uglobal |
2510 | screen_workarea RECT |
2510 | screen_workarea RECT |
2511 | display_width_standard dd 0 |
2511 | display_width_standard dd 0 |
2512 | display_height_standard dd 0 |
2512 | display_height_standard dd 0 |
2513 | do_not_touch_winmap db 0 |
2513 | do_not_touch_winmap db 0 |
2514 | window_minimize db 0 |
2514 | window_minimize db 0 |
2515 | sound_flag db 0 |
2515 | sound_flag db 0 |
2516 | 2516 | ||
2517 | endg |
2517 | endg |
2518 | 2518 | ||
2519 | UID_NONE=0 |
2519 | UID_NONE=0 |
2520 | UID_MENUETOS=1 ;official |
2520 | UID_MENUETOS=1 ;official |
2521 | UID_KOLIBRI=2 ;russian |
2521 | UID_KOLIBRI=2 ;russian |
2522 | 2522 | ||
2523 | iglobal |
2523 | iglobal |
2524 | version_inf: |
2524 | version_inf: |
2525 | db 0,7,7,0 ; version 0.7.7.0 |
2525 | db 0,7,7,0 ; version 0.7.7.0 |
2526 | db 0 |
2526 | db 0 |
2527 | .rev dd __REV__ |
2527 | .rev dd __REV__ |
2528 | version_end: |
2528 | version_end: |
2529 | endg |
2529 | endg |
2530 | ;------------------------------------------------------------------------------ |
2530 | ;------------------------------------------------------------------------------ |
2531 | align 4 |
2531 | align 4 |
2532 | sys_cachetodiskette: |
2532 | sys_cachetodiskette: |
2533 | cmp ebx, 1 |
2533 | cmp ebx, 1 |
2534 | jne .no_floppy_a_save |
2534 | jne .no_floppy_a_save |
2535 | mov [flp_number], 1 |
2535 | mov [flp_number], 1 |
2536 | jmp .save_image_on_floppy |
2536 | jmp .save_image_on_floppy |
2537 | ;-------------------------------------- |
2537 | ;-------------------------------------- |
2538 | align 4 |
2538 | align 4 |
2539 | .no_floppy_a_save: |
2539 | .no_floppy_a_save: |
2540 | cmp ebx, 2 |
2540 | cmp ebx, 2 |
2541 | jne .no_floppy_b_save |
2541 | jne .no_floppy_b_save |
2542 | mov [flp_number], 2 |
2542 | mov [flp_number], 2 |
2543 | ;-------------------------------------- |
2543 | ;-------------------------------------- |
2544 | align 4 |
2544 | align 4 |
2545 | .save_image_on_floppy: |
2545 | .save_image_on_floppy: |
2546 | call save_image |
2546 | call save_image |
2547 | mov [esp + 32], dword 0 |
2547 | mov [esp + 32], dword 0 |
2548 | cmp [FDC_Status], 0 |
2548 | cmp [FDC_Status], 0 |
2549 | je .yes_floppy_save |
2549 | je .yes_floppy_save |
2550 | ;-------------------------------------- |
2550 | ;-------------------------------------- |
2551 | align 4 |
2551 | align 4 |
2552 | .no_floppy_b_save: |
2552 | .no_floppy_b_save: |
2553 | mov [esp + 32], dword 1 |
2553 | mov [esp + 32], dword 1 |
2554 | ;-------------------------------------- |
2554 | ;-------------------------------------- |
2555 | align 4 |
2555 | align 4 |
2556 | .yes_floppy_save: |
2556 | .yes_floppy_save: |
2557 | ret |
2557 | ret |
2558 | ;------------------------------------------------------------------------------ |
2558 | ;------------------------------------------------------------------------------ |
2559 | uglobal |
2559 | uglobal |
2560 | ; bgrchanged dd 0x0 |
2560 | ; bgrchanged dd 0x0 |
2561 | align 4 |
2561 | align 4 |
2562 | bgrlockpid dd 0 |
2562 | bgrlockpid dd 0 |
2563 | bgrlock db 0 |
2563 | bgrlock db 0 |
2564 | endg |
2564 | endg |
2565 | ;------------------------------------------------------------------------------ |
2565 | ;------------------------------------------------------------------------------ |
2566 | align 4 |
2566 | align 4 |
2567 | sys_background: |
2567 | sys_background: |
2568 | cmp ebx, 1 ; BACKGROUND SIZE |
2568 | cmp ebx, 1 ; BACKGROUND SIZE |
2569 | jnz nosb1 |
2569 | jnz nosb1 |
2570 | test ecx, ecx |
2570 | test ecx, ecx |
2571 | jz sbgrr |
2571 | jz sbgrr |
2572 | 2572 | ||
2573 | test edx, edx |
2573 | test edx, edx |
2574 | jz sbgrr |
2574 | jz sbgrr |
2575 | ;-------------------------------------- |
2575 | ;-------------------------------------- |
2576 | align 4 |
2576 | align 4 |
2577 | @@: |
2577 | @@: |
2578 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2578 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2579 | bts dword [bgrlock], 0 |
2579 | bts dword [bgrlock], 0 |
2580 | jnc @f |
2580 | jnc @f |
2581 | call change_task |
2581 | call change_task |
2582 | jmp @b |
2582 | jmp @b |
2583 | ;-------------------------------------- |
2583 | ;-------------------------------------- |
2584 | align 4 |
2584 | align 4 |
2585 | @@: |
2585 | @@: |
2586 | mov [BgrDataWidth], ecx |
2586 | mov [BgrDataWidth], ecx |
2587 | mov [BgrDataHeight], edx |
2587 | mov [BgrDataHeight], edx |
2588 | ; mov [bgrchanged],1 |
2588 | ; mov [bgrchanged],1 |
2589 | 2589 | ||
2590 | pushad |
2590 | pushad |
2591 | ; return memory for old background |
2591 | ; return memory for old background |
2592 | mov eax, [img_background] |
2592 | mov eax, [img_background] |
2593 | cmp eax, static_background_data |
2593 | cmp eax, static_background_data |
2594 | jz @f |
2594 | jz @f |
2595 | stdcall kernel_free, eax |
2595 | stdcall kernel_free, eax |
2596 | ;-------------------------------------- |
2596 | ;-------------------------------------- |
2597 | align 4 |
2597 | align 4 |
2598 | @@: |
2598 | @@: |
2599 | ; calculate RAW size |
2599 | ; calculate RAW size |
2600 | xor eax, eax |
2600 | xor eax, eax |
2601 | inc eax |
2601 | inc eax |
2602 | cmp [BgrDataWidth], eax |
2602 | cmp [BgrDataWidth], eax |
2603 | jae @f |
2603 | jae @f |
2604 | mov [BgrDataWidth], eax |
2604 | mov [BgrDataWidth], eax |
2605 | ;-------------------------------------- |
2605 | ;-------------------------------------- |
2606 | align 4 |
2606 | align 4 |
2607 | @@: |
2607 | @@: |
2608 | cmp [BgrDataHeight], eax |
2608 | cmp [BgrDataHeight], eax |
2609 | jae @f |
2609 | jae @f |
2610 | mov [BgrDataHeight], eax |
2610 | mov [BgrDataHeight], eax |
2611 | ;-------------------------------------- |
2611 | ;-------------------------------------- |
2612 | align 4 |
2612 | align 4 |
2613 | @@: |
2613 | @@: |
2614 | mov eax, [BgrDataWidth] |
2614 | mov eax, [BgrDataWidth] |
2615 | imul eax, [BgrDataHeight] |
2615 | imul eax, [BgrDataHeight] |
2616 | lea eax, [eax*3] |
2616 | lea eax, [eax*3] |
2617 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2617 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2618 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2618 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2619 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2619 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2620 | shr eax, 12 |
2620 | shr eax, 12 |
2621 | inc eax |
2621 | inc eax |
2622 | shl eax, 12 |
2622 | shl eax, 12 |
2623 | mov [mem_BACKGROUND], eax |
2623 | mov [mem_BACKGROUND], eax |
2624 | ; get memory for new background |
2624 | ; get memory for new background |
2625 | stdcall kernel_alloc, eax |
2625 | stdcall kernel_alloc, eax |
2626 | test eax, eax |
2626 | test eax, eax |
2627 | jz .memfailed |
2627 | jz .memfailed |
2628 | mov [img_background], eax |
2628 | mov [img_background], eax |
2629 | jmp .exit |
2629 | jmp .exit |
2630 | ;-------------------------------------- |
2630 | ;-------------------------------------- |
2631 | align 4 |
2631 | align 4 |
2632 | .memfailed: |
2632 | .memfailed: |
2633 | ; revert to static monotone data |
2633 | ; revert to static monotone data |
2634 | mov [img_background], static_background_data |
2634 | mov [img_background], static_background_data |
2635 | xor eax, eax |
2635 | xor eax, eax |
2636 | inc eax |
2636 | inc eax |
2637 | mov [BgrDataWidth], eax |
2637 | mov [BgrDataWidth], eax |
2638 | mov [BgrDataHeight], eax |
2638 | mov [BgrDataHeight], eax |
2639 | mov [mem_BACKGROUND], 4 |
2639 | mov [mem_BACKGROUND], 4 |
2640 | ;-------------------------------------- |
2640 | ;-------------------------------------- |
2641 | align 4 |
2641 | align 4 |
2642 | .exit: |
2642 | .exit: |
2643 | popad |
2643 | popad |
2644 | mov [bgrlock], 0 |
2644 | mov [bgrlock], 0 |
2645 | ;-------------------------------------- |
2645 | ;-------------------------------------- |
2646 | align 4 |
2646 | align 4 |
2647 | sbgrr: |
2647 | sbgrr: |
2648 | ret |
2648 | ret |
2649 | ;------------------------------------------------------------------------------ |
2649 | ;------------------------------------------------------------------------------ |
2650 | align 4 |
2650 | align 4 |
2651 | nosb1: |
2651 | nosb1: |
2652 | cmp ebx, 2 ; SET PIXEL |
2652 | cmp ebx, 2 ; SET PIXEL |
2653 | jnz nosb2 |
2653 | jnz nosb2 |
2654 | 2654 | ||
2655 | mov eax, [img_background] |
2655 | mov eax, [img_background] |
2656 | test ecx, ecx |
2656 | test ecx, ecx |
2657 | jz @f |
2657 | jz @f |
2658 | cmp eax, static_background_data |
2658 | cmp eax, static_background_data |
2659 | jz .ret |
2659 | jz .ret |
2660 | ;-------------------------------------- |
2660 | ;-------------------------------------- |
2661 | align 4 |
2661 | align 4 |
2662 | @@: |
2662 | @@: |
2663 | mov ebx, [mem_BACKGROUND] |
2663 | mov ebx, [mem_BACKGROUND] |
2664 | add ebx, 4095 |
2664 | add ebx, 4095 |
2665 | and ebx, -4096 |
2665 | and ebx, -4096 |
2666 | sub ebx, 4 |
2666 | sub ebx, 4 |
2667 | cmp ecx, ebx |
2667 | cmp ecx, ebx |
2668 | ja .ret |
2668 | ja .ret |
2669 | 2669 | ||
2670 | mov ebx, [eax+ecx] |
2670 | mov ebx, [eax+ecx] |
2671 | and ebx, 0xFF000000;255*256*256*256 |
2671 | and ebx, 0xFF000000;255*256*256*256 |
2672 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2672 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2673 | add edx, ebx |
2673 | add edx, ebx |
2674 | mov [eax+ecx], edx |
2674 | mov [eax+ecx], edx |
2675 | ;-------------------------------------- |
2675 | ;-------------------------------------- |
2676 | align 4 |
2676 | align 4 |
2677 | .ret: |
2677 | .ret: |
2678 | ret |
2678 | ret |
2679 | ;------------------------------------------------------------------------------ |
2679 | ;------------------------------------------------------------------------------ |
2680 | align 4 |
2680 | align 4 |
2681 | nosb2: |
2681 | nosb2: |
2682 | cmp ebx, 3 ; DRAW BACKGROUND |
2682 | cmp ebx, 3 ; DRAW BACKGROUND |
2683 | jnz nosb3 |
2683 | jnz nosb3 |
2684 | ;-------------------------------------- |
2684 | ;-------------------------------------- |
2685 | align 4 |
2685 | align 4 |
2686 | draw_background_temp: |
2686 | draw_background_temp: |
2687 | mov [background_defined], 1 |
2687 | mov [background_defined], 1 |
2688 | call force_redraw_background |
2688 | call force_redraw_background |
2689 | ;-------------------------------------- |
2689 | ;-------------------------------------- |
2690 | align 4 |
2690 | align 4 |
2691 | nosb31: |
2691 | nosb31: |
2692 | ret |
2692 | ret |
2693 | ;------------------------------------------------------------------------------ |
2693 | ;------------------------------------------------------------------------------ |
2694 | align 4 |
2694 | align 4 |
2695 | nosb3: |
2695 | nosb3: |
2696 | cmp ebx, 4 ; TILED / STRETCHED |
2696 | cmp ebx, 4 ; TILED / STRETCHED |
2697 | jnz nosb4 |
2697 | jnz nosb4 |
2698 | cmp ecx, [BgrDrawMode] |
2698 | cmp ecx, [BgrDrawMode] |
2699 | je nosb41 |
2699 | je nosb41 |
2700 | mov [BgrDrawMode], ecx |
2700 | mov [BgrDrawMode], ecx |
2701 | ;-------------------------------------- |
2701 | ;-------------------------------------- |
2702 | align 4 |
2702 | align 4 |
2703 | nosb41: |
2703 | nosb41: |
2704 | ret |
2704 | ret |
2705 | ;------------------------------------------------------------------------------ |
2705 | ;------------------------------------------------------------------------------ |
2706 | align 4 |
2706 | align 4 |
2707 | nosb4: |
2707 | nosb4: |
2708 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2708 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2709 | jnz nosb5 |
2709 | jnz nosb5 |
2710 | cmp [img_background], static_background_data |
2710 | cmp [img_background], static_background_data |
2711 | jnz @f |
2711 | jnz @f |
2712 | test edx, edx |
2712 | test edx, edx |
2713 | jnz .fin |
2713 | jnz .fin |
2714 | cmp esi, 4 |
2714 | cmp esi, 4 |
2715 | ja .fin |
2715 | ja .fin |
2716 | ;-------------------------------------- |
2716 | ;-------------------------------------- |
2717 | align 4 |
2717 | align 4 |
2718 | @@: |
2718 | @@: |
2719 | ; bughere |
2719 | ; bughere |
2720 | mov eax, ecx |
2720 | mov eax, ecx |
2721 | mov ebx, edx |
2721 | mov ebx, edx |
2722 | add ebx, [img_background];IMG_BACKGROUND |
2722 | add ebx, [img_background];IMG_BACKGROUND |
2723 | mov ecx, esi |
2723 | mov ecx, esi |
2724 | call memmove |
2724 | call memmove |
2725 | ;-------------------------------------- |
2725 | ;-------------------------------------- |
2726 | align 4 |
2726 | align 4 |
2727 | .fin: |
2727 | .fin: |
2728 | ret |
2728 | ret |
2729 | ;------------------------------------------------------------------------------ |
2729 | ;------------------------------------------------------------------------------ |
2730 | align 4 |
2730 | align 4 |
2731 | nosb5: |
2731 | nosb5: |
2732 | cmp ebx, 6 |
2732 | cmp ebx, 6 |
2733 | jnz nosb6 |
2733 | jnz nosb6 |
2734 | ;-------------------------------------- |
2734 | ;-------------------------------------- |
2735 | align 4 |
2735 | align 4 |
2736 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2736 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2737 | @@: |
2737 | @@: |
2738 | bts dword [bgrlock], 0 |
2738 | bts dword [bgrlock], 0 |
2739 | jnc @f |
2739 | jnc @f |
2740 | call change_task |
2740 | call change_task |
2741 | jmp @b |
2741 | jmp @b |
2742 | ;-------------------------------------- |
2742 | ;-------------------------------------- |
2743 | align 4 |
2743 | align 4 |
2744 | @@: |
2744 | @@: |
2745 | mov eax, [CURRENT_TASK] |
2745 | mov eax, [CURRENT_TASK] |
2746 | mov [bgrlockpid], eax |
2746 | mov [bgrlockpid], eax |
2747 | cmp [img_background], static_background_data |
2747 | cmp [img_background], static_background_data |
2748 | jz .nomem |
2748 | jz .nomem |
2749 | stdcall user_alloc, [mem_BACKGROUND] |
2749 | stdcall user_alloc, [mem_BACKGROUND] |
2750 | mov [esp+32], eax |
2750 | mov [esp+32], eax |
2751 | test eax, eax |
2751 | test eax, eax |
2752 | jz .nomem |
2752 | jz .nomem |
2753 | mov ebx, eax |
2753 | mov ebx, eax |
2754 | shr ebx, 12 |
2754 | shr ebx, 12 |
2755 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2755 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2756 | mov esi, [img_background] |
2756 | mov esi, [img_background] |
2757 | shr esi, 12 |
2757 | shr esi, 12 |
2758 | mov ecx, [mem_BACKGROUND] |
2758 | mov ecx, [mem_BACKGROUND] |
2759 | add ecx, 0xFFF |
2759 | add ecx, 0xFFF |
2760 | shr ecx, 12 |
2760 | shr ecx, 12 |
2761 | ;-------------------------------------- |
2761 | ;-------------------------------------- |
2762 | align 4 |
2762 | align 4 |
2763 | .z: |
2763 | .z: |
2764 | mov eax, [page_tabs+ebx*4] |
2764 | mov eax, [page_tabs+ebx*4] |
2765 | test al, 1 |
2765 | test al, 1 |
2766 | jz @f |
2766 | jz @f |
2767 | call free_page |
2767 | call free_page |
2768 | ;-------------------------------------- |
2768 | ;-------------------------------------- |
2769 | align 4 |
2769 | align 4 |
2770 | @@: |
2770 | @@: |
2771 | mov eax, [page_tabs+esi*4] |
2771 | mov eax, [page_tabs+esi*4] |
2772 | or al, PG_UW |
2772 | or al, PG_UW |
2773 | mov [page_tabs+ebx*4], eax |
2773 | mov [page_tabs+ebx*4], eax |
2774 | mov eax, ebx |
2774 | mov eax, ebx |
2775 | shl eax, 12 |
2775 | shl eax, 12 |
2776 | invlpg [eax] |
2776 | invlpg [eax] |
2777 | inc ebx |
2777 | inc ebx |
2778 | inc esi |
2778 | inc esi |
2779 | loop .z |
2779 | loop .z |
2780 | ret |
2780 | ret |
2781 | ;-------------------------------------- |
2781 | ;-------------------------------------- |
2782 | align 4 |
2782 | align 4 |
2783 | .nomem: |
2783 | .nomem: |
2784 | and [bgrlockpid], 0 |
2784 | and [bgrlockpid], 0 |
2785 | mov [bgrlock], 0 |
2785 | mov [bgrlock], 0 |
2786 | ;------------------------------------------------------------------------------ |
2786 | ;------------------------------------------------------------------------------ |
2787 | align 4 |
2787 | align 4 |
2788 | nosb6: |
2788 | nosb6: |
2789 | cmp ebx, 7 |
2789 | cmp ebx, 7 |
2790 | jnz nosb7 |
2790 | jnz nosb7 |
2791 | cmp [bgrlock], 0 |
2791 | cmp [bgrlock], 0 |
2792 | jz .err |
2792 | jz .err |
2793 | mov eax, [CURRENT_TASK] |
2793 | mov eax, [CURRENT_TASK] |
2794 | cmp [bgrlockpid], eax |
2794 | cmp [bgrlockpid], eax |
2795 | jnz .err |
2795 | jnz .err |
2796 | mov eax, ecx |
2796 | mov eax, ecx |
2797 | mov ebx, ecx |
2797 | mov ebx, ecx |
2798 | shr eax, 12 |
2798 | shr eax, 12 |
2799 | mov ecx, [page_tabs+(eax-1)*4] |
2799 | mov ecx, [page_tabs+(eax-1)*4] |
2800 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2800 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2801 | jz .err |
2801 | jz .err |
2802 | jnp .err |
2802 | jnp .err |
2803 | push eax |
2803 | push eax |
2804 | shr ecx, 12 |
2804 | shr ecx, 12 |
2805 | dec ecx |
2805 | dec ecx |
2806 | ;-------------------------------------- |
2806 | ;-------------------------------------- |
2807 | align 4 |
2807 | align 4 |
2808 | @@: |
2808 | @@: |
2809 | and dword [page_tabs+eax*4], 0 |
2809 | and dword [page_tabs+eax*4], 0 |
2810 | mov edx, eax |
2810 | mov edx, eax |
2811 | shl edx, 12 |
2811 | shl edx, 12 |
2812 | push eax |
2812 | push eax |
2813 | invlpg [edx] |
2813 | invlpg [edx] |
2814 | pop eax |
2814 | pop eax |
2815 | inc eax |
2815 | inc eax |
2816 | loop @b |
2816 | loop @b |
2817 | pop eax |
2817 | pop eax |
2818 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2818 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2819 | stdcall user_free, ebx |
2819 | stdcall user_free, ebx |
2820 | mov [esp+32], eax |
2820 | mov [esp+32], eax |
2821 | and [bgrlockpid], 0 |
2821 | and [bgrlockpid], 0 |
2822 | mov [bgrlock], 0 |
2822 | mov [bgrlock], 0 |
2823 | ret |
2823 | ret |
2824 | ;-------------------------------------- |
2824 | ;-------------------------------------- |
2825 | align 4 |
2825 | align 4 |
2826 | .err: |
2826 | .err: |
2827 | and dword [esp+32], 0 |
2827 | and dword [esp+32], 0 |
2828 | ret |
2828 | ret |
2829 | ;------------------------------------------------------------------------------ |
2829 | ;------------------------------------------------------------------------------ |
2830 | align 4 |
2830 | align 4 |
2831 | nosb7: |
2831 | nosb7: |
2832 | cmp ebx, 8 |
2832 | cmp ebx, 8 |
2833 | jnz nosb8 |
2833 | jnz nosb8 |
2834 | 2834 | ||
2835 | mov ecx, [current_slot] |
2835 | mov ecx, [current_slot] |
2836 | xor eax, eax |
2836 | xor eax, eax |
2837 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2837 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2838 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2838 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2839 | xor eax, eax |
2839 | xor eax, eax |
2840 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2840 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2841 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2841 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2842 | ret |
2842 | ret |
2843 | ;------------------------------------------------------------------------------ |
2843 | ;------------------------------------------------------------------------------ |
2844 | align 4 |
2844 | align 4 |
2845 | nosb8: |
2845 | nosb8: |
2846 | cmp ebx, 9 |
2846 | cmp ebx, 9 |
2847 | jnz nosb9 |
2847 | jnz nosb9 |
2848 | ; ecx = [left]*65536 + [right] |
2848 | ; ecx = [left]*65536 + [right] |
2849 | ; edx = [top]*65536 + [bottom] |
2849 | ; edx = [top]*65536 + [bottom] |
2850 | mov eax, [Screen_Max_X] |
2850 | mov eax, [Screen_Max_X] |
2851 | mov ebx, [Screen_Max_Y] |
2851 | mov ebx, [Screen_Max_Y] |
2852 | ; check [right] |
2852 | ; check [right] |
2853 | cmp cx, ax |
2853 | cmp cx, ax |
2854 | ja .exit |
2854 | ja .exit |
2855 | ; check [left] |
2855 | ; check [left] |
2856 | ror ecx, 16 |
2856 | ror ecx, 16 |
2857 | cmp cx, ax |
2857 | cmp cx, ax |
2858 | ja .exit |
2858 | ja .exit |
2859 | ; check [bottom] |
2859 | ; check [bottom] |
2860 | cmp dx, bx |
2860 | cmp dx, bx |
2861 | ja .exit |
2861 | ja .exit |
2862 | ; check [top] |
2862 | ; check [top] |
2863 | ror edx, 16 |
2863 | ror edx, 16 |
2864 | cmp dx, bx |
2864 | cmp dx, bx |
2865 | ja .exit |
2865 | ja .exit |
2866 | 2866 | ||
2867 | movzx eax, cx ; [left] |
2867 | movzx eax, cx ; [left] |
2868 | movzx ebx, dx ; [top] |
2868 | movzx ebx, dx ; [top] |
2869 | 2869 | ||
2870 | shr ecx, 16 ; [right] |
2870 | shr ecx, 16 ; [right] |
2871 | shr edx, 16 ; [bottom] |
2871 | shr edx, 16 ; [bottom] |
2872 | 2872 | ||
2873 | mov [background_defined], 1 |
2873 | mov [background_defined], 1 |
2874 | 2874 | ||
2875 | mov [draw_data+32 + RECT.left], eax |
2875 | mov [draw_data+32 + RECT.left], eax |
2876 | mov [draw_data+32 + RECT.top], ebx |
2876 | mov [draw_data+32 + RECT.top], ebx |
2877 | 2877 | ||
2878 | mov [draw_data+32 + RECT.right], ecx |
2878 | mov [draw_data+32 + RECT.right], ecx |
2879 | mov [draw_data+32 + RECT.bottom], edx |
2879 | mov [draw_data+32 + RECT.bottom], edx |
2880 | 2880 | ||
2881 | inc byte[REDRAW_BACKGROUND] |
2881 | inc byte[REDRAW_BACKGROUND] |
2882 | call wakeup_osloop |
2882 | call wakeup_osloop |
2883 | ;-------------------------------------- |
2883 | ;-------------------------------------- |
2884 | align 4 |
2884 | align 4 |
2885 | .exit: |
2885 | .exit: |
2886 | ret |
2886 | ret |
2887 | ;------------------------------------------------------------------------------ |
2887 | ;------------------------------------------------------------------------------ |
2888 | align 4 |
2888 | align 4 |
2889 | nosb9: |
2889 | nosb9: |
2890 | ret |
2890 | ret |
2891 | ;------------------------------------------------------------------------------ |
2891 | ;------------------------------------------------------------------------------ |
2892 | align 4 |
2892 | align 4 |
2893 | uglobal |
2893 | uglobal |
2894 | BG_Rect_X_left_right dd 0x0 |
2894 | BG_Rect_X_left_right dd 0x0 |
2895 | BG_Rect_Y_top_bottom dd 0x0 |
2895 | BG_Rect_Y_top_bottom dd 0x0 |
2896 | endg |
2896 | endg |
2897 | ;------------------------------------------------------------------------------ |
2897 | ;------------------------------------------------------------------------------ |
2898 | align 4 |
2898 | align 4 |
2899 | force_redraw_background: |
2899 | force_redraw_background: |
2900 | and [draw_data+32 + RECT.left], 0 |
2900 | and [draw_data+32 + RECT.left], 0 |
2901 | and [draw_data+32 + RECT.top], 0 |
2901 | and [draw_data+32 + RECT.top], 0 |
2902 | push eax ebx |
2902 | push eax ebx |
2903 | mov eax, [Screen_Max_X] |
2903 | mov eax, [Screen_Max_X] |
2904 | mov ebx, [Screen_Max_Y] |
2904 | mov ebx, [Screen_Max_Y] |
2905 | mov [draw_data+32 + RECT.right], eax |
2905 | mov [draw_data+32 + RECT.right], eax |
2906 | mov [draw_data+32 + RECT.bottom], ebx |
2906 | mov [draw_data+32 + RECT.bottom], ebx |
2907 | pop ebx eax |
2907 | pop ebx eax |
2908 | inc byte[REDRAW_BACKGROUND] |
2908 | inc byte[REDRAW_BACKGROUND] |
2909 | call wakeup_osloop |
2909 | call wakeup_osloop |
2910 | ret |
2910 | ret |
2911 | ;------------------------------------------------------------------------------ |
2911 | ;------------------------------------------------------------------------------ |
2912 | align 4 |
2912 | align 4 |
2913 | sys_getbackground: |
2913 | sys_getbackground: |
2914 | ; cmp eax,1 ; SIZE |
2914 | ; cmp eax,1 ; SIZE |
2915 | dec ebx |
2915 | dec ebx |
2916 | jnz nogb1 |
2916 | jnz nogb1 |
2917 | mov eax, [BgrDataWidth] |
2917 | mov eax, [BgrDataWidth] |
2918 | shl eax, 16 |
2918 | shl eax, 16 |
2919 | mov ax, word [BgrDataHeight] |
2919 | mov ax, word [BgrDataHeight] |
2920 | mov [esp+32], eax |
2920 | mov [esp+32], eax |
2921 | ret |
2921 | ret |
2922 | ;------------------------------------------------------------------------------ |
2922 | ;------------------------------------------------------------------------------ |
2923 | align 4 |
2923 | align 4 |
2924 | nogb1: |
2924 | nogb1: |
2925 | ; cmp eax,2 ; PIXEL |
2925 | ; cmp eax,2 ; PIXEL |
2926 | dec ebx |
2926 | dec ebx |
2927 | jnz nogb2 |
2927 | jnz nogb2 |
2928 | 2928 | ||
2929 | mov eax, [img_background] |
2929 | mov eax, [img_background] |
2930 | test ecx, ecx |
2930 | test ecx, ecx |
2931 | jz @f |
2931 | jz @f |
2932 | cmp eax, static_background_data |
2932 | cmp eax, static_background_data |
2933 | jz .ret |
2933 | jz .ret |
2934 | ;-------------------------------------- |
2934 | ;-------------------------------------- |
2935 | align 4 |
2935 | align 4 |
2936 | @@: |
2936 | @@: |
2937 | mov ebx, [mem_BACKGROUND] |
2937 | mov ebx, [mem_BACKGROUND] |
2938 | add ebx, 4095 |
2938 | add ebx, 4095 |
2939 | and ebx, -4096 |
2939 | and ebx, -4096 |
2940 | sub ebx, 4 |
2940 | sub ebx, 4 |
2941 | cmp ecx, ebx |
2941 | cmp ecx, ebx |
2942 | ja .ret |
2942 | ja .ret |
2943 | 2943 | ||
2944 | mov eax, [ecx+eax] |
2944 | mov eax, [ecx+eax] |
2945 | 2945 | ||
2946 | and eax, 0xFFFFFF |
2946 | and eax, 0xFFFFFF |
2947 | mov [esp+32], eax |
2947 | mov [esp+32], eax |
2948 | ;-------------------------------------- |
2948 | ;-------------------------------------- |
2949 | align 4 |
2949 | align 4 |
2950 | .ret: |
2950 | .ret: |
2951 | ret |
2951 | ret |
2952 | ;------------------------------------------------------------------------------ |
2952 | ;------------------------------------------------------------------------------ |
2953 | align 4 |
2953 | align 4 |
2954 | nogb2: |
2954 | nogb2: |
2955 | 2955 | ||
2956 | ; cmp eax,4 ; TILED / STRETCHED |
2956 | ; cmp eax,4 ; TILED / STRETCHED |
2957 | dec ebx |
2957 | dec ebx |
2958 | dec ebx |
2958 | dec ebx |
2959 | jnz nogb4 |
2959 | jnz nogb4 |
2960 | mov eax, [BgrDrawMode] |
2960 | mov eax, [BgrDrawMode] |
2961 | ;-------------------------------------- |
2961 | ;-------------------------------------- |
2962 | align 4 |
2962 | align 4 |
2963 | nogb4: |
2963 | nogb4: |
2964 | mov [esp+32], eax |
2964 | mov [esp+32], eax |
2965 | ret |
2965 | ret |
2966 | ;------------------------------------------------------------------------------ |
2966 | ;------------------------------------------------------------------------------ |
2967 | align 4 |
2967 | align 4 |
2968 | sys_getkey: |
2968 | sys_getkey: |
2969 | mov [esp + 32], dword 1 |
2969 | mov [esp + 32], dword 1 |
2970 | ; test main buffer |
2970 | ; test main buffer |
2971 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2971 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2972 | movzx ecx, word [WIN_STACK + ebx * 2] |
2972 | movzx ecx, word [WIN_STACK + ebx * 2] |
2973 | mov edx, [TASK_COUNT] |
2973 | mov edx, [TASK_COUNT] |
2974 | cmp ecx, edx |
2974 | cmp ecx, edx |
2975 | jne .finish |
2975 | jne .finish |
2976 | cmp [KEY_COUNT], byte 0 |
2976 | cmp [KEY_COUNT], byte 0 |
2977 | je .finish |
2977 | je .finish |
2978 | movzx eax, byte [KEY_BUFF] |
2978 | movzx eax, byte [KEY_BUFF] |
2979 | shl eax, 8 |
2979 | shl eax, 8 |
2980 | push eax |
2980 | push eax |
2981 | dec byte [KEY_COUNT] |
2981 | dec byte [KEY_COUNT] |
2982 | and byte [KEY_COUNT], 127 |
2982 | and byte [KEY_COUNT], 127 |
2983 | movzx ecx, byte [KEY_COUNT] |
2983 | movzx ecx, byte [KEY_COUNT] |
2984 | add ecx, 2 |
2984 | add ecx, 2 |
2985 | mov eax, KEY_BUFF + 1 |
2985 | mov eax, KEY_BUFF + 1 |
2986 | mov ebx, KEY_BUFF |
2986 | mov ebx, KEY_BUFF |
2987 | call memmove |
2987 | call memmove |
2988 | pop eax |
2988 | pop eax |
2989 | ;-------------------------------------- |
2989 | ;-------------------------------------- |
2990 | align 4 |
2990 | align 4 |
2991 | .ret_eax: |
2991 | .ret_eax: |
2992 | mov [esp + 32], eax |
2992 | mov [esp + 32], eax |
2993 | ret |
2993 | ret |
2994 | ;-------------------------------------- |
2994 | ;-------------------------------------- |
2995 | align 4 |
2995 | align 4 |
2996 | .finish: |
2996 | .finish: |
2997 | ; test hotkeys buffer |
2997 | ; test hotkeys buffer |
2998 | mov ecx, hotkey_buffer |
2998 | mov ecx, hotkey_buffer |
2999 | ;-------------------------------------- |
2999 | ;-------------------------------------- |
3000 | align 4 |
3000 | align 4 |
3001 | @@: |
3001 | @@: |
3002 | cmp [ecx], ebx |
3002 | cmp [ecx], ebx |
3003 | jz .found |
3003 | jz .found |
3004 | add ecx, 8 |
3004 | add ecx, 8 |
3005 | cmp ecx, hotkey_buffer + 120 * 8 |
3005 | cmp ecx, hotkey_buffer + 120 * 8 |
3006 | jb @b |
3006 | jb @b |
3007 | ret |
3007 | ret |
3008 | ;-------------------------------------- |
3008 | ;-------------------------------------- |
3009 | align 4 |
3009 | align 4 |
3010 | .found: |
3010 | .found: |
3011 | mov ax, [ecx + 6] |
3011 | mov ax, [ecx + 6] |
3012 | shl eax, 16 |
3012 | shl eax, 16 |
3013 | mov ah, [ecx + 4] |
3013 | mov ah, [ecx + 4] |
3014 | mov al, 2 |
3014 | mov al, 2 |
3015 | and dword [ecx + 4], 0 |
3015 | and dword [ecx + 4], 0 |
3016 | and dword [ecx], 0 |
3016 | and dword [ecx], 0 |
3017 | jmp .ret_eax |
3017 | jmp .ret_eax |
3018 | ;------------------------------------------------------------------------------ |
3018 | ;------------------------------------------------------------------------------ |
3019 | align 4 |
3019 | align 4 |
3020 | sys_getbutton: |
3020 | sys_getbutton: |
3021 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3021 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3022 | mov [esp + 32], dword 1 |
3022 | mov [esp + 32], dword 1 |
3023 | movzx ecx, word [WIN_STACK + ebx * 2] |
3023 | movzx ecx, word [WIN_STACK + ebx * 2] |
3024 | mov edx, [TASK_COUNT] ; less than 256 processes |
3024 | mov edx, [TASK_COUNT] ; less than 256 processes |
3025 | cmp ecx, edx |
3025 | cmp ecx, edx |
3026 | jne .exit |
3026 | jne .exit |
3027 | movzx eax, byte [BTN_COUNT] |
3027 | movzx eax, byte [BTN_COUNT] |
3028 | test eax, eax |
3028 | test eax, eax |
3029 | jz .exit |
3029 | jz .exit |
3030 | mov eax, [BTN_BUFF] |
3030 | mov eax, [BTN_BUFF] |
3031 | and al, 0xFE ; delete left button bit |
3031 | and al, 0xFE ; delete left button bit |
3032 | mov [BTN_COUNT], byte 0 |
3032 | mov [BTN_COUNT], byte 0 |
3033 | mov [esp + 32], eax |
3033 | mov [esp + 32], eax |
3034 | ;-------------------------------------- |
3034 | ;-------------------------------------- |
3035 | align 4 |
3035 | align 4 |
3036 | .exit: |
3036 | .exit: |
3037 | ret |
3037 | ret |
3038 | ;------------------------------------------------------------------------------ |
3038 | ;------------------------------------------------------------------------------ |
3039 | align 4 |
3039 | align 4 |
3040 | sys_cpuusage: |
3040 | sys_cpuusage: |
3041 | 3041 | ||
3042 | ; RETURN: |
3042 | ; RETURN: |
3043 | ; |
3043 | ; |
3044 | ; +00 dword process cpu usage |
3044 | ; +00 dword process cpu usage |
3045 | ; +04 word position in windowing stack |
3045 | ; +04 word position in windowing stack |
3046 | ; +06 word windowing stack value at current position (cpu nro) |
3046 | ; +06 word windowing stack value at current position (cpu nro) |
3047 | ; +10 12 bytes name |
3047 | ; +10 12 bytes name |
3048 | ; +22 dword start in mem |
3048 | ; +22 dword start in mem |
3049 | ; +26 dword used mem |
3049 | ; +26 dword used mem |
3050 | ; +30 dword PID , process idenfification number |
3050 | ; +30 dword PID , process idenfification number |
3051 | ; |
3051 | ; |
3052 | 3052 | ||
3053 | cmp ecx, -1 ; who am I ? |
3053 | cmp ecx, -1 ; who am I ? |
3054 | jne .no_who_am_i |
3054 | jne .no_who_am_i |
3055 | mov ecx, [CURRENT_TASK] |
3055 | mov ecx, [CURRENT_TASK] |
3056 | .no_who_am_i: |
3056 | .no_who_am_i: |
3057 | cmp ecx, max_processes |
3057 | cmp ecx, max_processes |
3058 | ja .nofillbuf |
3058 | ja .nofillbuf |
3059 | 3059 | ||
3060 | ; +4: word: position of the window of thread in the window stack |
3060 | ; +4: word: position of the window of thread in the window stack |
3061 | mov ax, [WIN_STACK + ecx * 2] |
3061 | mov ax, [WIN_STACK + ecx * 2] |
3062 | mov [ebx+4], ax |
3062 | mov [ebx+4], ax |
3063 | ; +6: word: number of the thread slot, which window has in the window stack |
3063 | ; +6: word: number of the thread slot, which window has in the window stack |
3064 | ; position ecx (has no relation to the specific thread) |
3064 | ; position ecx (has no relation to the specific thread) |
3065 | mov ax, [WIN_POS + ecx * 2] |
3065 | mov ax, [WIN_POS + ecx * 2] |
3066 | mov [ebx+6], ax |
3066 | mov [ebx+6], ax |
3067 | 3067 | ||
3068 | shl ecx, 5 |
3068 | shl ecx, 5 |
3069 | 3069 | ||
3070 | ; +0: dword: memory usage |
3070 | ; +0: dword: memory usage |
3071 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3071 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3072 | mov [ebx], eax |
3072 | mov [ebx], eax |
3073 | ; +10: 11 bytes: name of the process |
3073 | ; +10: 11 bytes: name of the process |
3074 | push ecx |
3074 | push ecx |
3075 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3075 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3076 | add ebx, 10 |
3076 | add ebx, 10 |
3077 | mov ecx, 11 |
3077 | mov ecx, 11 |
3078 | call memmove |
3078 | call memmove |
3079 | pop ecx |
3079 | pop ecx |
3080 | 3080 | ||
3081 | ; +22: address of the process in memory |
3081 | ; +22: address of the process in memory |
3082 | ; +26: size of used memory - 1 |
3082 | ; +26: size of used memory - 1 |
3083 | push edi |
3083 | push edi |
3084 | lea edi, [ebx+12] |
3084 | lea edi, [ebx+12] |
3085 | xor eax, eax |
3085 | xor eax, eax |
3086 | mov edx, 0x100000*16 |
3086 | mov edx, 0x100000*16 |
3087 | cmp ecx, 1 shl 5 |
3087 | cmp ecx, 1 shl 5 |
3088 | je .os_mem |
3088 | je .os_mem |
3089 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3089 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3090 | mov eax, std_application_base_address |
3090 | mov eax, std_application_base_address |
3091 | .os_mem: |
3091 | .os_mem: |
3092 | stosd |
3092 | stosd |
3093 | lea eax, [edx-1] |
3093 | lea eax, [edx-1] |
3094 | stosd |
3094 | stosd |
3095 | 3095 | ||
3096 | ; +30: PID/TID |
3096 | ; +30: PID/TID |
3097 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3097 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3098 | stosd |
3098 | stosd |
3099 | 3099 | ||
3100 | ; window position and size |
3100 | ; window position and size |
3101 | push esi |
3101 | push esi |
3102 | lea esi, [ecx + window_data + WDATA.box] |
3102 | lea esi, [ecx + window_data + WDATA.box] |
3103 | movsd |
3103 | movsd |
3104 | movsd |
3104 | movsd |
3105 | movsd |
3105 | movsd |
3106 | movsd |
3106 | movsd |
3107 | 3107 | ||
3108 | ; Process state (+50) |
3108 | ; Process state (+50) |
3109 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3109 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3110 | stosd |
3110 | stosd |
3111 | 3111 | ||
3112 | ; Window client area box |
3112 | ; Window client area box |
3113 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3113 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3114 | movsd |
3114 | movsd |
3115 | movsd |
3115 | movsd |
3116 | movsd |
3116 | movsd |
3117 | movsd |
3117 | movsd |
3118 | 3118 | ||
3119 | ; Window state |
3119 | ; Window state |
3120 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3120 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3121 | stosb |
3121 | stosb |
3122 | 3122 | ||
3123 | ; Event mask (+71) |
3123 | ; Event mask (+71) |
3124 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3124 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3125 | stosd |
3125 | stosd |
3126 | 3126 | ||
3127 | pop esi |
3127 | pop esi |
3128 | pop edi |
3128 | pop edi |
3129 | 3129 | ||
3130 | .nofillbuf: |
3130 | .nofillbuf: |
3131 | ; return number of processes |
3131 | ; return number of processes |
3132 | 3132 | ||
3133 | mov eax, [TASK_COUNT] |
3133 | mov eax, [TASK_COUNT] |
3134 | mov [esp+32], eax |
3134 | mov [esp+32], eax |
3135 | ret |
3135 | ret |
3136 | 3136 | ||
3137 | align 4 |
3137 | align 4 |
3138 | sys_clock: |
3138 | sys_clock: |
3139 | cli |
3139 | cli |
3140 | ; Mikhail Lisovin xx Jan 2005 |
3140 | ; Mikhail Lisovin xx Jan 2005 |
3141 | @@: |
3141 | @@: |
3142 | mov al, 10 |
3142 | mov al, 10 |
3143 | out 0x70, al |
3143 | out 0x70, al |
3144 | in al, 0x71 |
3144 | in al, 0x71 |
3145 | test al, al |
3145 | test al, al |
3146 | jns @f |
3146 | jns @f |
3147 | mov esi, 1 |
3147 | mov esi, 1 |
3148 | call delay_ms |
3148 | call delay_ms |
3149 | jmp @b |
3149 | jmp @b |
3150 | @@: |
3150 | @@: |
3151 | ; end Lisovin's fix |
3151 | ; end Lisovin's fix |
3152 | 3152 | ||
3153 | xor al, al ; seconds |
3153 | xor al, al ; seconds |
3154 | out 0x70, al |
3154 | out 0x70, al |
3155 | in al, 0x71 |
3155 | in al, 0x71 |
3156 | movzx ecx, al |
3156 | movzx ecx, al |
3157 | mov al, 02 ; minutes |
3157 | mov al, 02 ; minutes |
3158 | shl ecx, 16 |
3158 | shl ecx, 16 |
3159 | out 0x70, al |
3159 | out 0x70, al |
3160 | in al, 0x71 |
3160 | in al, 0x71 |
3161 | movzx edx, al |
3161 | movzx edx, al |
3162 | mov al, 04 ; hours |
3162 | mov al, 04 ; hours |
3163 | shl edx, 8 |
3163 | shl edx, 8 |
3164 | out 0x70, al |
3164 | out 0x70, al |
3165 | in al, 0x71 |
3165 | in al, 0x71 |
3166 | add ecx, edx |
3166 | add ecx, edx |
3167 | movzx edx, al |
3167 | movzx edx, al |
3168 | add ecx, edx |
3168 | add ecx, edx |
3169 | sti |
3169 | sti |
3170 | mov [esp + 32], ecx |
3170 | mov [esp + 32], ecx |
3171 | ret |
3171 | ret |
3172 | 3172 | ||
3173 | 3173 | ||
3174 | align 4 |
3174 | align 4 |
3175 | 3175 | ||
3176 | sys_date: |
3176 | sys_date: |
3177 | 3177 | ||
3178 | cli |
3178 | cli |
3179 | @@: |
3179 | @@: |
3180 | mov al, 10 |
3180 | mov al, 10 |
3181 | out 0x70, al |
3181 | out 0x70, al |
3182 | in al, 0x71 |
3182 | in al, 0x71 |
3183 | test al, al |
3183 | test al, al |
3184 | jns @f |
3184 | jns @f |
3185 | mov esi, 1 |
3185 | mov esi, 1 |
3186 | call delay_ms |
3186 | call delay_ms |
3187 | jmp @b |
3187 | jmp @b |
3188 | @@: |
3188 | @@: |
3189 | 3189 | ||
3190 | mov ch, 0 |
3190 | mov ch, 0 |
3191 | mov al, 7 ; date |
3191 | mov al, 7 ; date |
3192 | out 0x70, al |
3192 | out 0x70, al |
3193 | in al, 0x71 |
3193 | in al, 0x71 |
3194 | mov cl, al |
3194 | mov cl, al |
3195 | mov al, 8 ; month |
3195 | mov al, 8 ; month |
3196 | shl ecx, 16 |
3196 | shl ecx, 16 |
3197 | out 0x70, al |
3197 | out 0x70, al |
3198 | in al, 0x71 |
3198 | in al, 0x71 |
3199 | mov ch, al |
3199 | mov ch, al |
3200 | mov al, 9 ; year |
3200 | mov al, 9 ; year |
3201 | out 0x70, al |
3201 | out 0x70, al |
3202 | in al, 0x71 |
3202 | in al, 0x71 |
3203 | mov cl, al |
3203 | mov cl, al |
3204 | sti |
3204 | sti |
3205 | mov [esp+32], ecx |
3205 | mov [esp+32], ecx |
3206 | ret |
3206 | ret |
3207 | 3207 | ||
3208 | 3208 | ||
3209 | ; redraw status |
3209 | ; redraw status |
3210 | 3210 | ||
3211 | sys_redrawstat: |
3211 | sys_redrawstat: |
3212 | cmp ebx, 1 |
3212 | cmp ebx, 1 |
3213 | jne no_widgets_away |
3213 | jne no_widgets_away |
3214 | ; buttons away |
3214 | ; buttons away |
3215 | mov ecx, [CURRENT_TASK] |
3215 | mov ecx, [CURRENT_TASK] |
3216 | sys_newba2: |
3216 | sys_newba2: |
3217 | mov edi, [BTN_ADDR] |
3217 | mov edi, [BTN_ADDR] |
3218 | cmp [edi], dword 0 ; empty button list ? |
3218 | cmp [edi], dword 0 ; empty button list ? |
3219 | je end_of_buttons_away |
3219 | je end_of_buttons_away |
3220 | movzx ebx, word [edi] |
3220 | movzx ebx, word [edi] |
3221 | inc ebx |
3221 | inc ebx |
3222 | mov eax, edi |
3222 | mov eax, edi |
3223 | sys_newba: |
3223 | sys_newba: |
3224 | dec ebx |
3224 | dec ebx |
3225 | jz end_of_buttons_away |
3225 | jz end_of_buttons_away |
3226 | 3226 | ||
3227 | add eax, 0x10 |
3227 | add eax, 0x10 |
3228 | cmp cx, [eax] |
3228 | cmp cx, [eax] |
3229 | jnz sys_newba |
3229 | jnz sys_newba |
3230 | 3230 | ||
3231 | push eax ebx ecx |
3231 | push eax ebx ecx |
3232 | mov ecx, ebx |
3232 | mov ecx, ebx |
3233 | inc ecx |
3233 | inc ecx |
3234 | shl ecx, 4 |
3234 | shl ecx, 4 |
3235 | mov ebx, eax |
3235 | mov ebx, eax |
3236 | add eax, 0x10 |
3236 | add eax, 0x10 |
3237 | call memmove |
3237 | call memmove |
3238 | dec dword [edi] |
3238 | dec dword [edi] |
3239 | pop ecx ebx eax |
3239 | pop ecx ebx eax |
3240 | 3240 | ||
3241 | jmp sys_newba2 |
3241 | jmp sys_newba2 |
3242 | 3242 | ||
3243 | end_of_buttons_away: |
3243 | end_of_buttons_away: |
3244 | 3244 | ||
3245 | ret |
3245 | ret |
3246 | 3246 | ||
3247 | no_widgets_away: |
3247 | no_widgets_away: |
3248 | 3248 | ||
3249 | cmp ebx, 2 |
3249 | cmp ebx, 2 |
3250 | jnz srl1 |
3250 | jnz srl1 |
3251 | 3251 | ||
3252 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3252 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3253 | add edx, draw_data - CURRENT_TASK |
3253 | add edx, draw_data - CURRENT_TASK |
3254 | mov [edx + RECT.left], 0 |
3254 | mov [edx + RECT.left], 0 |
3255 | mov [edx + RECT.top], 0 |
3255 | mov [edx + RECT.top], 0 |
3256 | mov eax, [Screen_Max_X] |
3256 | mov eax, [Screen_Max_X] |
3257 | mov [edx + RECT.right], eax |
3257 | mov [edx + RECT.right], eax |
3258 | mov eax, [Screen_Max_Y] |
3258 | mov eax, [Screen_Max_Y] |
3259 | mov [edx + RECT.bottom], eax |
3259 | mov [edx + RECT.bottom], eax |
3260 | 3260 | ||
3261 | srl1: |
3261 | srl1: |
3262 | ret |
3262 | ret |
3263 | 3263 | ||
3264 | ;ok - 100% work |
3264 | ;ok - 100% work |
3265 | ;nt - not tested |
3265 | ;nt - not tested |
3266 | ;--------------------------------------------------------------------------------------------- |
3266 | ;--------------------------------------------------------------------------------------------- |
3267 | ;eax |
3267 | ;eax |
3268 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3268 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3269 | ;1 - change task. Ret nothing. Block. ok. |
3269 | ;1 - change task. Ret nothing. Block. ok. |
3270 | ;2 - performance control |
3270 | ;2 - performance control |
3271 | ; ebx |
3271 | ; ebx |
3272 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3272 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3273 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3273 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3274 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3274 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3275 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3275 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3276 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3276 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3277 | ;eax |
3277 | ;eax |
3278 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3278 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3279 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3279 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3280 | ;--------------------------------------------------------------------------------------------- |
3280 | ;--------------------------------------------------------------------------------------------- |
3281 | iglobal |
3281 | iglobal |
3282 | align 4 |
3282 | align 4 |
3283 | sheduler: |
3283 | sheduler: |
3284 | dd sys_sheduler.00 |
3284 | dd sys_sheduler.00 |
3285 | dd change_task |
3285 | dd change_task |
3286 | dd sys_sheduler.02 |
3286 | dd sys_sheduler.02 |
3287 | dd sys_sheduler.03 |
3287 | dd sys_sheduler.03 |
3288 | dd sys_sheduler.04 |
3288 | dd sys_sheduler.04 |
3289 | endg |
3289 | endg |
3290 | sys_sheduler: |
3290 | sys_sheduler: |
3291 | ;rewritten by |
3291 | ;rewritten by |
3292 | jmp dword [sheduler+ebx*4] |
3292 | jmp dword [sheduler+ebx*4] |
3293 | ;.shed_counter: |
3293 | ;.shed_counter: |
3294 | .00: |
3294 | .00: |
3295 | mov eax, [context_counter] |
3295 | mov eax, [context_counter] |
3296 | mov [esp+32], eax |
3296 | mov [esp+32], eax |
3297 | ret |
3297 | ret |
3298 | 3298 | ||
3299 | .02: |
3299 | .02: |
3300 | ;.perf_control: |
3300 | ;.perf_control: |
3301 | inc ebx ;before ebx=2, ebx=3 |
3301 | inc ebx ;before ebx=2, ebx=3 |
3302 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3302 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3303 | jz cache_disable |
3303 | jz cache_disable |
3304 | 3304 | ||
3305 | dec ebx ;ebx=2 |
3305 | dec ebx ;ebx=2 |
3306 | cmp ebx, ecx ; |
3306 | cmp ebx, ecx ; |
3307 | jz cache_enable ;if ecx=2 and ebx=2 |
3307 | jz cache_enable ;if ecx=2 and ebx=2 |
3308 | 3308 | ||
3309 | dec ebx ;ebx=1 |
3309 | dec ebx ;ebx=1 |
3310 | cmp ebx, ecx |
3310 | cmp ebx, ecx |
3311 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3311 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3312 | 3312 | ||
3313 | dec ebx |
3313 | dec ebx |
3314 | test ebx, ecx ;ebx=0 and ecx=0 |
3314 | test ebx, ecx ;ebx=0 and ecx=0 |
3315 | jz modify_pce ;if ecx=0 |
3315 | jz modify_pce ;if ecx=0 |
3316 | 3316 | ||
3317 | ret |
3317 | ret |
3318 | 3318 | ||
3319 | .03: |
3319 | .03: |
3320 | ;.rdmsr_instr: |
3320 | ;.rdmsr_instr: |
3321 | ;now counter in ecx |
3321 | ;now counter in ecx |
3322 | ;(edx:eax) esi:edi => edx:esi |
3322 | ;(edx:eax) esi:edi => edx:esi |
3323 | mov eax, esi |
3323 | mov eax, esi |
3324 | mov ecx, edx |
3324 | mov ecx, edx |
3325 | rdmsr |
3325 | rdmsr |
3326 | mov [esp+32], eax |
3326 | mov [esp+32], eax |
3327 | mov [esp+20], edx ;ret in ebx? |
3327 | mov [esp+20], edx ;ret in ebx? |
3328 | ret |
3328 | ret |
3329 | 3329 | ||
3330 | .04: |
3330 | .04: |
3331 | ;.wrmsr_instr: |
3331 | ;.wrmsr_instr: |
3332 | ;now counter in ecx |
3332 | ;now counter in ecx |
3333 | ;(edx:eax) esi:edi => edx:esi |
3333 | ;(edx:eax) esi:edi => edx:esi |
3334 | ; Fast Call MSR can't be destroy |
3334 | ; Fast Call MSR can't be destroy |
3335 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3335 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3336 | ; включаются/выключаются расширенные возможности |
3336 | ; включаются/выключаются расширенные возможности |
3337 | cmp edx, MSR_SYSENTER_CS |
3337 | cmp edx, MSR_SYSENTER_CS |
3338 | je @f |
3338 | je @f |
3339 | cmp edx, MSR_SYSENTER_ESP |
3339 | cmp edx, MSR_SYSENTER_ESP |
3340 | je @f |
3340 | je @f |
3341 | cmp edx, MSR_SYSENTER_EIP |
3341 | cmp edx, MSR_SYSENTER_EIP |
3342 | je @f |
3342 | je @f |
3343 | cmp edx, MSR_AMD_STAR |
3343 | cmp edx, MSR_AMD_STAR |
3344 | je @f |
3344 | je @f |
3345 | 3345 | ||
3346 | mov eax, esi |
3346 | mov eax, esi |
3347 | mov ecx, edx |
3347 | mov ecx, edx |
3348 | wrmsr |
3348 | wrmsr |
3349 | ; mov [esp + 32], eax |
3349 | ; mov [esp + 32], eax |
3350 | ; mov [esp + 20], edx ;ret in ebx? |
3350 | ; mov [esp + 20], edx ;ret in ebx? |
3351 | @@: |
3351 | @@: |
3352 | ret |
3352 | ret |
3353 | 3353 | ||
3354 | cache_disable: |
3354 | cache_disable: |
3355 | mov eax, cr0 |
3355 | mov eax, cr0 |
3356 | or eax, 01100000000000000000000000000000b |
3356 | or eax, 01100000000000000000000000000000b |
3357 | mov cr0, eax |
3357 | mov cr0, eax |
3358 | wbinvd ;set MESI |
3358 | wbinvd ;set MESI |
3359 | ret |
3359 | ret |
3360 | 3360 | ||
3361 | cache_enable: |
3361 | cache_enable: |
3362 | mov eax, cr0 |
3362 | mov eax, cr0 |
3363 | and eax, 10011111111111111111111111111111b |
3363 | and eax, 10011111111111111111111111111111b |
3364 | mov cr0, eax |
3364 | mov cr0, eax |
3365 | ret |
3365 | ret |
3366 | 3366 | ||
3367 | is_cache_enabled: |
3367 | is_cache_enabled: |
3368 | mov eax, cr0 |
3368 | mov eax, cr0 |
3369 | mov ebx, eax |
3369 | mov ebx, eax |
3370 | and eax, 01100000000000000000000000000000b |
3370 | and eax, 01100000000000000000000000000000b |
3371 | jz cache_disabled |
3371 | jz cache_disabled |
3372 | mov [esp+32], ebx |
3372 | mov [esp+32], ebx |
3373 | cache_disabled: |
3373 | cache_disabled: |
3374 | mov dword [esp+32], eax;0 |
3374 | mov dword [esp+32], eax;0 |
3375 | ret |
3375 | ret |
3376 | 3376 | ||
3377 | modify_pce: |
3377 | modify_pce: |
3378 | mov eax, cr4 |
3378 | mov eax, cr4 |
3379 | ; mov ebx,0 |
3379 | ; mov ebx,0 |
3380 | ; or bx,100000000b ;pce |
3380 | ; or bx,100000000b ;pce |
3381 | ; xor eax,ebx ;invert pce |
3381 | ; xor eax,ebx ;invert pce |
3382 | bts eax, 8;pce=cr4[8] |
3382 | bts eax, 8;pce=cr4[8] |
3383 | mov cr4, eax |
3383 | mov cr4, eax |
3384 | mov [esp+32], eax |
3384 | mov [esp+32], eax |
3385 | ret |
3385 | ret |
3386 | ;--------------------------------------------------------------------------------------------- |
3386 | ;--------------------------------------------------------------------------------------------- |
3387 | 3387 | ||
3388 | 3388 | ||
3389 | ; check if pixel is allowed to be drawn |
3389 | ; check if pixel is allowed to be drawn |
3390 | 3390 | ||
3391 | ;checkpixel: |
3391 | ;checkpixel: |
3392 | ; push eax edx |
3392 | ; push eax edx |
3393 | 3393 | ||
3394 | ;; mov edx, [Screen_Max_X] ; screen x size |
3394 | ;; mov edx, [Screen_Max_X] ; screen x size |
3395 | ;; inc edx |
3395 | ;; inc edx |
3396 | ;; imul edx, ebx |
3396 | ;; imul edx, ebx |
3397 | ; mov edx, [d_width_calc_area + ebx*4] |
3397 | ; mov edx, [d_width_calc_area + ebx*4] |
3398 | ; add eax, [_WinMapAddress] |
3398 | ; add eax, [_WinMapAddress] |
3399 | ; mov dl, [eax+edx]; lea eax, [...] |
3399 | ; mov dl, [eax+edx]; lea eax, [...] |
3400 | 3400 | ||
3401 | ; xor ecx, ecx |
3401 | ; xor ecx, ecx |
3402 | ; mov eax, [CURRENT_TASK] |
3402 | ; mov eax, [CURRENT_TASK] |
3403 | ; cmp al, dl |
3403 | ; cmp al, dl |
3404 | ; setne cl |
3404 | ; setne cl |
3405 | 3405 | ||
3406 | ; pop edx eax |
3406 | ; pop edx eax |
3407 | ; ret |
3407 | ; ret |
3408 | 3408 | ||
3409 | iglobal |
3409 | iglobal |
3410 | cpustring db 'CPU',0 |
3410 | cpustring db 'CPU',0 |
3411 | endg |
3411 | endg |
3412 | 3412 | ||
3413 | uglobal |
3413 | uglobal |
3414 | background_defined db 0 ; diamond, 11.04.2006 |
3414 | background_defined db 0 ; diamond, 11.04.2006 |
3415 | endg |
3415 | endg |
3416 | ;----------------------------------------------------------------------------- |
3416 | ;----------------------------------------------------------------------------- |
3417 | align 4 |
3417 | align 4 |
3418 | checkmisc: |
3418 | checkmisc: |
3419 | cmp [ctrl_alt_del], 1 |
3419 | cmp [ctrl_alt_del], 1 |
3420 | jne nocpustart |
3420 | jne nocpustart |
3421 | 3421 | ||
3422 | mov ebp, cpustring |
3422 | mov ebp, cpustring |
3423 | call fs_execute_from_sysdir |
3423 | call fs_execute_from_sysdir |
3424 | 3424 | ||
3425 | mov [ctrl_alt_del], 0 |
3425 | mov [ctrl_alt_del], 0 |
3426 | ;-------------------------------------- |
3426 | ;-------------------------------------- |
3427 | align 4 |
3427 | align 4 |
3428 | nocpustart: |
3428 | nocpustart: |
3429 | cmp [mouse_active], 1 |
3429 | cmp [mouse_active], 1 |
3430 | jne mouse_not_active |
3430 | jne mouse_not_active |
3431 | mov [mouse_active], 0 |
3431 | mov [mouse_active], 0 |
3432 | 3432 | ||
3433 | xor edi, edi |
3433 | xor edi, edi |
3434 | mov ebx, CURRENT_TASK |
3434 | mov ebx, CURRENT_TASK |
3435 | 3435 | ||
3436 | mov ecx, [TASK_COUNT] |
3436 | mov ecx, [TASK_COUNT] |
3437 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3437 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3438 | shl eax, 8 |
3438 | shl eax, 8 |
3439 | push eax |
3439 | push eax |
3440 | 3440 | ||
3441 | movzx eax, word [MOUSE_X] |
3441 | movzx eax, word [MOUSE_X] |
3442 | movzx edx, word [MOUSE_Y] |
3442 | movzx edx, word [MOUSE_Y] |
3443 | ;-------------------------------------- |
3443 | ;-------------------------------------- |
3444 | align 4 |
3444 | align 4 |
3445 | .set_mouse_event: |
3445 | .set_mouse_event: |
3446 | add edi, 256 |
3446 | add edi, 256 |
3447 | add ebx, 32 |
3447 | add ebx, 32 |
3448 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3448 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3449 | jz .pos_filter |
3449 | jz .pos_filter |
3450 | 3450 | ||
3451 | cmp edi, [esp] ; skip if filtration active |
3451 | cmp edi, [esp] ; skip if filtration active |
3452 | jne .skip |
3452 | jne .skip |
3453 | ;-------------------------------------- |
3453 | ;-------------------------------------- |
3454 | align 4 |
3454 | align 4 |
3455 | .pos_filter: |
3455 | .pos_filter: |
3456 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3456 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3457 | jz .set |
3457 | jz .set |
3458 | 3458 | ||
3459 | mov esi, [ebx-twdw+WDATA.box.left] |
3459 | mov esi, [ebx-twdw+WDATA.box.left] |
3460 | cmp eax, esi |
3460 | cmp eax, esi |
3461 | jb .skip |
3461 | jb .skip |
3462 | add esi, [ebx-twdw+WDATA.box.width] |
3462 | add esi, [ebx-twdw+WDATA.box.width] |
3463 | cmp eax, esi |
3463 | cmp eax, esi |
3464 | ja .skip |
3464 | ja .skip |
3465 | 3465 | ||
3466 | mov esi, [ebx-twdw+WDATA.box.top] |
3466 | mov esi, [ebx-twdw+WDATA.box.top] |
3467 | cmp edx, esi |
3467 | cmp edx, esi |
3468 | jb .skip |
3468 | jb .skip |
3469 | add esi, [ebx-twdw+WDATA.box.height] |
3469 | add esi, [ebx-twdw+WDATA.box.height] |
3470 | cmp edx, esi |
3470 | cmp edx, esi |
3471 | ja .skip |
3471 | ja .skip |
3472 | ;-------------------------------------- |
3472 | ;-------------------------------------- |
3473 | align 4 |
3473 | align 4 |
3474 | .set: |
3474 | .set: |
3475 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3475 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3476 | ;-------------------------------------- |
3476 | ;-------------------------------------- |
3477 | align 4 |
3477 | align 4 |
3478 | .skip: |
3478 | .skip: |
3479 | loop .set_mouse_event |
3479 | loop .set_mouse_event |
3480 | 3480 | ||
3481 | pop eax |
3481 | pop eax |
3482 | ;-------------------------------------- |
3482 | ;-------------------------------------- |
3483 | align 4 |
3483 | align 4 |
3484 | mouse_not_active: |
3484 | mouse_not_active: |
3485 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3485 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3486 | jz nobackgr |
3486 | jz nobackgr |
3487 | 3487 | ||
3488 | cmp [background_defined], 0 |
3488 | cmp [background_defined], 0 |
3489 | jz nobackgr |
3489 | jz nobackgr |
3490 | ;-------------------------------------- |
3490 | ;-------------------------------------- |
3491 | align 4 |
3491 | align 4 |
3492 | backgr: |
3492 | backgr: |
3493 | mov eax, [draw_data+32 + RECT.left] |
3493 | mov eax, [draw_data+32 + RECT.left] |
3494 | shl eax, 16 |
3494 | shl eax, 16 |
3495 | add eax, [draw_data+32 + RECT.right] |
3495 | add eax, [draw_data+32 + RECT.right] |
3496 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3496 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3497 | 3497 | ||
3498 | mov eax, [draw_data+32 + RECT.top] |
3498 | mov eax, [draw_data+32 + RECT.top] |
3499 | shl eax, 16 |
3499 | shl eax, 16 |
3500 | add eax, [draw_data+32 + RECT.bottom] |
3500 | add eax, [draw_data+32 + RECT.bottom] |
3501 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3501 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3502 | 3502 | ||
3503 | call drawbackground |
3503 | call drawbackground |
3504 | ; DEBUGF 1, "K : drawbackground\n" |
3504 | ; DEBUGF 1, "K : drawbackground\n" |
3505 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3505 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3506 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3506 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3507 | ;--------- set event 5 start ---------- |
3507 | ;--------- set event 5 start ---------- |
3508 | push ecx edi |
3508 | push ecx edi |
3509 | xor edi, edi |
3509 | xor edi, edi |
3510 | mov ecx, [TASK_COUNT] |
3510 | mov ecx, [TASK_COUNT] |
3511 | ;-------------------------------------- |
3511 | ;-------------------------------------- |
3512 | align 4 |
3512 | align 4 |
3513 | set_bgr_event: |
3513 | set_bgr_event: |
3514 | add edi, 256 |
3514 | add edi, 256 |
3515 | mov eax, [BG_Rect_X_left_right] |
3515 | mov eax, [BG_Rect_X_left_right] |
3516 | mov edx, [BG_Rect_Y_top_bottom] |
3516 | mov edx, [BG_Rect_Y_top_bottom] |
3517 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3517 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3518 | jz .set |
3518 | jz .set |
3519 | .join: |
3519 | .join: |
3520 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
- | |
3521 | jbe @f |
- | |
3522 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
- | |
3523 | @@: |
- | |
3524 | shr eax, 16 |
- | |
3525 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3520 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3526 | jae @f |
3521 | jae @f |
3527 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3522 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3528 | @@: |
3523 | @@: |
- | 3524 | shr eax, 16 |
|
3529 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3525 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3530 | jbe @f |
3526 | jbe @f |
3531 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3527 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3532 | @@: |
3528 | @@: |
3533 | shr edx, 16 |
- | |
3534 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3529 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3535 | jae @f |
3530 | jae @f |
3536 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3531 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3537 | @@: |
3532 | @@: |
- | 3533 | shr edx, 16 |
|
- | 3534 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
|
- | 3535 | jbe @f |
|
- | 3536 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
|
- | 3537 | @@: |
|
3538 | jmp .common |
3538 | jmp .common |
3539 | .set: |
3539 | .set: |
3540 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3540 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3541 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3541 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3542 | .common: |
3542 | .common: |
3543 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3543 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3544 | loop set_bgr_event |
3544 | loop set_bgr_event |
3545 | pop edi ecx |
3545 | pop edi ecx |
3546 | ;--------- set event 5 stop ----------- |
3546 | ;--------- set event 5 stop ----------- |
3547 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3547 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3548 | jnz backgr |
3548 | jnz backgr |
3549 | 3549 | ||
3550 | xor eax, eax |
3550 | xor eax, eax |
3551 | mov [draw_data+32 + RECT.left], eax |
3551 | mov [draw_data+32 + RECT.left], eax |
3552 | mov [draw_data+32 + RECT.top], eax |
3552 | mov [draw_data+32 + RECT.top], eax |
3553 | mov [draw_data+32 + RECT.right], eax |
3553 | mov [draw_data+32 + RECT.right], eax |
3554 | mov [draw_data+32 + RECT.bottom], eax |
3554 | mov [draw_data+32 + RECT.bottom], eax |
3555 | ;-------------------------------------- |
3555 | ;-------------------------------------- |
3556 | align 4 |
3556 | align 4 |
3557 | nobackgr: |
3557 | nobackgr: |
3558 | ; system shutdown request |
3558 | ; system shutdown request |
3559 | cmp [SYS_SHUTDOWN], byte 0 |
3559 | cmp [SYS_SHUTDOWN], byte 0 |
3560 | je noshutdown |
3560 | je noshutdown |
3561 | 3561 | ||
3562 | mov edx, [shutdown_processes] |
3562 | mov edx, [shutdown_processes] |
3563 | 3563 | ||
3564 | cmp [SYS_SHUTDOWN], dl |
3564 | cmp [SYS_SHUTDOWN], dl |
3565 | jne noshutdown |
3565 | jne noshutdown |
3566 | 3566 | ||
3567 | lea ecx, [edx-1] |
3567 | lea ecx, [edx-1] |
3568 | mov edx, OS_BASE+0x3040 |
3568 | mov edx, OS_BASE+0x3040 |
3569 | jecxz no_mark_system_shutdown |
3569 | jecxz no_mark_system_shutdown |
3570 | ;-------------------------------------- |
3570 | ;-------------------------------------- |
3571 | align 4 |
3571 | align 4 |
3572 | markz: |
3572 | markz: |
3573 | push ecx edx |
3573 | push ecx edx |
3574 | cmp [edx+TASKDATA.state], 9 |
3574 | cmp [edx+TASKDATA.state], 9 |
3575 | jz .nokill |
3575 | jz .nokill |
3576 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3576 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3577 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3577 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3578 | jz .nokill |
3578 | jz .nokill |
3579 | call request_terminate |
3579 | call request_terminate |
3580 | jmp .common |
3580 | jmp .common |
3581 | .nokill: |
3581 | .nokill: |
3582 | dec byte [SYS_SHUTDOWN] |
3582 | dec byte [SYS_SHUTDOWN] |
3583 | xor eax, eax |
3583 | xor eax, eax |
3584 | .common: |
3584 | .common: |
3585 | pop edx ecx |
3585 | pop edx ecx |
3586 | test eax, eax |
3586 | test eax, eax |
3587 | jz @f |
3587 | jz @f |
3588 | mov [edx+TASKDATA.state], byte 3 |
3588 | mov [edx+TASKDATA.state], byte 3 |
3589 | @@: |
3589 | @@: |
3590 | add edx, 0x20 |
3590 | add edx, 0x20 |
3591 | loop markz |
3591 | loop markz |
3592 | call wakeup_osloop |
3592 | call wakeup_osloop |
3593 | ;-------------------------------------- |
3593 | ;-------------------------------------- |
3594 | align 4 |
3594 | align 4 |
3595 | @@: |
3595 | @@: |
3596 | no_mark_system_shutdown: |
3596 | no_mark_system_shutdown: |
3597 | dec byte [SYS_SHUTDOWN] |
3597 | dec byte [SYS_SHUTDOWN] |
3598 | je system_shutdown |
3598 | je system_shutdown |
3599 | ;-------------------------------------- |
3599 | ;-------------------------------------- |
3600 | align 4 |
3600 | align 4 |
3601 | noshutdown: |
3601 | noshutdown: |
3602 | mov eax, [TASK_COUNT] ; termination |
3602 | mov eax, [TASK_COUNT] ; termination |
3603 | mov ebx, TASK_DATA+TASKDATA.state |
3603 | mov ebx, TASK_DATA+TASKDATA.state |
3604 | mov esi, 1 |
3604 | mov esi, 1 |
3605 | ;-------------------------------------- |
3605 | ;-------------------------------------- |
3606 | align 4 |
3606 | align 4 |
3607 | newct: |
3607 | newct: |
3608 | mov cl, [ebx] |
3608 | mov cl, [ebx] |
3609 | cmp cl, byte 3 |
3609 | cmp cl, byte 3 |
3610 | jz .terminate |
3610 | jz .terminate |
3611 | 3611 | ||
3612 | cmp cl, byte 4 |
3612 | cmp cl, byte 4 |
3613 | jnz .noterminate |
3613 | jnz .noterminate |
3614 | .terminate: |
3614 | .terminate: |
3615 | pushad |
3615 | pushad |
3616 | mov ecx, eax |
3616 | mov ecx, eax |
3617 | shl ecx, 8 |
3617 | shl ecx, 8 |
3618 | add ecx, SLOT_BASE |
3618 | add ecx, SLOT_BASE |
3619 | call restore_default_cursor_before_killing |
3619 | call restore_default_cursor_before_killing |
3620 | popad |
3620 | popad |
3621 | 3621 | ||
3622 | pushad |
3622 | pushad |
3623 | call terminate |
3623 | call terminate |
3624 | popad |
3624 | popad |
3625 | cmp byte [SYS_SHUTDOWN], 0 |
3625 | cmp byte [SYS_SHUTDOWN], 0 |
3626 | jz .noterminate |
3626 | jz .noterminate |
3627 | dec byte [SYS_SHUTDOWN] |
3627 | dec byte [SYS_SHUTDOWN] |
3628 | je system_shutdown |
3628 | je system_shutdown |
3629 | 3629 | ||
3630 | .noterminate: |
3630 | .noterminate: |
3631 | add ebx, 0x20 |
3631 | add ebx, 0x20 |
3632 | inc esi |
3632 | inc esi |
3633 | dec eax |
3633 | dec eax |
3634 | jnz newct |
3634 | jnz newct |
3635 | ret |
3635 | ret |
3636 | ;----------------------------------------------------------------------------- |
3636 | ;----------------------------------------------------------------------------- |
3637 | align 4 |
3637 | align 4 |
3638 | redrawscreen: |
3638 | redrawscreen: |
3639 | ; eax , if process window_data base is eax, do not set flag/limits |
3639 | ; eax , if process window_data base is eax, do not set flag/limits |
3640 | 3640 | ||
3641 | pushad |
3641 | pushad |
3642 | push eax |
3642 | push eax |
3643 | 3643 | ||
3644 | ;;; mov ebx,2 |
3644 | ;;; mov ebx,2 |
3645 | ;;; call delay_hs |
3645 | ;;; call delay_hs |
3646 | 3646 | ||
3647 | ;mov ecx,0 ; redraw flags for apps |
3647 | ;mov ecx,0 ; redraw flags for apps |
3648 | xor ecx, ecx |
3648 | xor ecx, ecx |
3649 | ;-------------------------------------- |
3649 | ;-------------------------------------- |
3650 | align 4 |
3650 | align 4 |
3651 | newdw2: |
3651 | newdw2: |
3652 | inc ecx |
3652 | inc ecx |
3653 | push ecx |
3653 | push ecx |
3654 | 3654 | ||
3655 | mov eax, ecx |
3655 | mov eax, ecx |
3656 | shl eax, 5 |
3656 | shl eax, 5 |
3657 | add eax, window_data |
3657 | add eax, window_data |
3658 | 3658 | ||
3659 | cmp eax, [esp+4] |
3659 | cmp eax, [esp+4] |
3660 | je not_this_task |
3660 | je not_this_task |
3661 | ; check if window in redraw area |
3661 | ; check if window in redraw area |
3662 | mov edi, eax |
3662 | mov edi, eax |
3663 | 3663 | ||
3664 | cmp ecx, 1 ; limit for background |
3664 | cmp ecx, 1 ; limit for background |
3665 | jz bgli |
3665 | jz bgli |
3666 | 3666 | ||
3667 | mov eax, [edi + WDATA.box.left] |
3667 | mov eax, [edi + WDATA.box.left] |
3668 | mov ebx, [edi + WDATA.box.top] |
3668 | mov ebx, [edi + WDATA.box.top] |
3669 | mov ecx, [edi + WDATA.box.width] |
3669 | mov ecx, [edi + WDATA.box.width] |
3670 | mov edx, [edi + WDATA.box.height] |
3670 | mov edx, [edi + WDATA.box.height] |
3671 | add ecx, eax |
3671 | add ecx, eax |
3672 | add edx, ebx |
3672 | add edx, ebx |
3673 | 3673 | ||
3674 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3674 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3675 | cmp ecx, ebx |
3675 | cmp ecx, ebx |
3676 | jb ricino |
3676 | jb ricino |
3677 | 3677 | ||
3678 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3678 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3679 | cmp ecx, eax |
3679 | cmp ecx, eax |
3680 | jb ricino |
3680 | jb ricino |
3681 | 3681 | ||
3682 | mov eax, [edi + WDATA.box.left] |
3682 | mov eax, [edi + WDATA.box.left] |
3683 | mov ebx, [edi + WDATA.box.top] |
3683 | mov ebx, [edi + WDATA.box.top] |
3684 | mov ecx, [edi + WDATA.box.width] |
3684 | mov ecx, [edi + WDATA.box.width] |
3685 | mov edx, [edi + WDATA.box.height] |
3685 | mov edx, [edi + WDATA.box.height] |
3686 | add ecx, eax |
3686 | add ecx, eax |
3687 | add edx, ebx |
3687 | add edx, ebx |
3688 | 3688 | ||
3689 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3689 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3690 | cmp edx, eax |
3690 | cmp edx, eax |
3691 | jb ricino |
3691 | jb ricino |
3692 | 3692 | ||
3693 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3693 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3694 | cmp ecx, eax |
3694 | cmp ecx, eax |
3695 | jb ricino |
3695 | jb ricino |
3696 | ;-------------------------------------- |
3696 | ;-------------------------------------- |
3697 | align 4 |
3697 | align 4 |
3698 | bgli: |
3698 | bgli: |
3699 | cmp dword[esp], 1 |
3699 | cmp dword[esp], 1 |
3700 | jnz .az |
3700 | jnz .az |
3701 | 3701 | ||
3702 | cmp byte[REDRAW_BACKGROUND], 0 |
3702 | cmp byte[REDRAW_BACKGROUND], 0 |
3703 | jz .az |
3703 | jz .az |
3704 | 3704 | ||
3705 | mov dl, 0 |
3705 | mov dl, 0 |
3706 | lea eax, [edi+draw_data-window_data] |
3706 | lea eax, [edi+draw_data-window_data] |
3707 | mov ebx, [draw_limits.left] |
3707 | mov ebx, [draw_limits.left] |
3708 | cmp ebx, [eax+RECT.left] |
3708 | cmp ebx, [eax+RECT.left] |
3709 | jae @f |
3709 | jae @f |
3710 | 3710 | ||
3711 | mov [eax+RECT.left], ebx |
3711 | mov [eax+RECT.left], ebx |
3712 | mov dl, 1 |
3712 | mov dl, 1 |
3713 | ;-------------------------------------- |
3713 | ;-------------------------------------- |
3714 | align 4 |
3714 | align 4 |
3715 | @@: |
3715 | @@: |
3716 | mov ebx, [draw_limits.top] |
3716 | mov ebx, [draw_limits.top] |
3717 | cmp ebx, [eax+RECT.top] |
3717 | cmp ebx, [eax+RECT.top] |
3718 | jae @f |
3718 | jae @f |
3719 | 3719 | ||
3720 | mov [eax+RECT.top], ebx |
3720 | mov [eax+RECT.top], ebx |
3721 | mov dl, 1 |
3721 | mov dl, 1 |
3722 | ;-------------------------------------- |
3722 | ;-------------------------------------- |
3723 | align 4 |
3723 | align 4 |
3724 | @@: |
3724 | @@: |
3725 | mov ebx, [draw_limits.right] |
3725 | mov ebx, [draw_limits.right] |
3726 | cmp ebx, [eax+RECT.right] |
3726 | cmp ebx, [eax+RECT.right] |
3727 | jbe @f |
3727 | jbe @f |
3728 | 3728 | ||
3729 | mov [eax+RECT.right], ebx |
3729 | mov [eax+RECT.right], ebx |
3730 | mov dl, 1 |
3730 | mov dl, 1 |
3731 | ;-------------------------------------- |
3731 | ;-------------------------------------- |
3732 | align 4 |
3732 | align 4 |
3733 | @@: |
3733 | @@: |
3734 | mov ebx, [draw_limits.bottom] |
3734 | mov ebx, [draw_limits.bottom] |
3735 | cmp ebx, [eax+RECT.bottom] |
3735 | cmp ebx, [eax+RECT.bottom] |
3736 | jbe @f |
3736 | jbe @f |
3737 | 3737 | ||
3738 | mov [eax+RECT.bottom], ebx |
3738 | mov [eax+RECT.bottom], ebx |
3739 | mov dl, 1 |
3739 | mov dl, 1 |
3740 | ;-------------------------------------- |
3740 | ;-------------------------------------- |
3741 | align 4 |
3741 | align 4 |
3742 | @@: |
3742 | @@: |
3743 | add byte[REDRAW_BACKGROUND], dl |
3743 | add byte[REDRAW_BACKGROUND], dl |
3744 | call wakeup_osloop |
3744 | call wakeup_osloop |
3745 | jmp newdw8 |
3745 | jmp newdw8 |
3746 | ;-------------------------------------- |
3746 | ;-------------------------------------- |
3747 | align 4 |
3747 | align 4 |
3748 | .az: |
3748 | .az: |
3749 | mov eax, edi |
3749 | mov eax, edi |
3750 | add eax, draw_data-window_data |
3750 | add eax, draw_data-window_data |
3751 | 3751 | ||
3752 | mov ebx, [draw_limits.left] ; set limits |
3752 | mov ebx, [draw_limits.left] ; set limits |
3753 | mov [eax + RECT.left], ebx |
3753 | mov [eax + RECT.left], ebx |
3754 | mov ebx, [draw_limits.top] |
3754 | mov ebx, [draw_limits.top] |
3755 | mov [eax + RECT.top], ebx |
3755 | mov [eax + RECT.top], ebx |
3756 | mov ebx, [draw_limits.right] |
3756 | mov ebx, [draw_limits.right] |
3757 | mov [eax + RECT.right], ebx |
3757 | mov [eax + RECT.right], ebx |
3758 | mov ebx, [draw_limits.bottom] |
3758 | mov ebx, [draw_limits.bottom] |
3759 | mov [eax + RECT.bottom], ebx |
3759 | mov [eax + RECT.bottom], ebx |
3760 | 3760 | ||
3761 | sub eax, draw_data-window_data |
3761 | sub eax, draw_data-window_data |
3762 | 3762 | ||
3763 | cmp dword [esp], 1 |
3763 | cmp dword [esp], 1 |
3764 | jne nobgrd |
3764 | jne nobgrd |
3765 | inc byte[REDRAW_BACKGROUND] |
3765 | inc byte[REDRAW_BACKGROUND] |
3766 | call wakeup_osloop |
3766 | call wakeup_osloop |
3767 | ;-------------------------------------- |
3767 | ;-------------------------------------- |
3768 | align 4 |
3768 | align 4 |
3769 | newdw8: |
3769 | newdw8: |
3770 | nobgrd: |
3770 | nobgrd: |
3771 | 3771 | ||
3772 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3772 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3773 | ;-------------------------------------- |
3773 | ;-------------------------------------- |
3774 | align 4 |
3774 | align 4 |
3775 | ricino: |
3775 | ricino: |
3776 | not_this_task: |
3776 | not_this_task: |
3777 | pop ecx |
3777 | pop ecx |
3778 | 3778 | ||
3779 | cmp ecx, [TASK_COUNT] |
3779 | cmp ecx, [TASK_COUNT] |
3780 | jle newdw2 |
3780 | jle newdw2 |
3781 | 3781 | ||
3782 | pop eax |
3782 | pop eax |
3783 | popad |
3783 | popad |
3784 | ret |
3784 | ret |
3785 | ;----------------------------------------------------------------------------- |
3785 | ;----------------------------------------------------------------------------- |
3786 | align 4 |
3786 | align 4 |
3787 | calculatebackground: ; background |
3787 | calculatebackground: ; background |
3788 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3788 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3789 | mov eax, 0x01010101 |
3789 | mov eax, 0x01010101 |
3790 | mov ecx, [_WinMapSize] |
3790 | mov ecx, [_WinMapSize] |
3791 | shr ecx, 2 |
3791 | shr ecx, 2 |
3792 | rep stosd |
3792 | rep stosd |
3793 | 3793 | ||
3794 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3794 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3795 | ret |
3795 | ret |
3796 | ;----------------------------------------------------------------------------- |
3796 | ;----------------------------------------------------------------------------- |
3797 | uglobal |
3797 | uglobal |
3798 | imax dd 0x0 |
3798 | imax dd 0x0 |
3799 | endg |
3799 | endg |
3800 | ;----------------------------------------------------------------------------- |
3800 | ;----------------------------------------------------------------------------- |
3801 | align 4 |
3801 | align 4 |
3802 | delay_ms: ; delay in 1/1000 sec |
3802 | delay_ms: ; delay in 1/1000 sec |
3803 | push eax |
3803 | push eax |
3804 | push ecx |
3804 | push ecx |
3805 | 3805 | ||
3806 | mov ecx, esi |
3806 | mov ecx, esi |
3807 | ; |
3807 | ; |
3808 | imul ecx, 33941 |
3808 | imul ecx, 33941 |
3809 | shr ecx, 9 |
3809 | shr ecx, 9 |
3810 | ; |
3810 | ; |
3811 | 3811 | ||
3812 | in al, 0x61 |
3812 | in al, 0x61 |
3813 | and al, 0x10 |
3813 | and al, 0x10 |
3814 | mov ah, al |
3814 | mov ah, al |
3815 | cld |
3815 | cld |
3816 | ;-------------------------------------- |
3816 | ;-------------------------------------- |
3817 | align 4 |
3817 | align 4 |
3818 | cnt1: |
3818 | cnt1: |
3819 | in al, 0x61 |
3819 | in al, 0x61 |
3820 | and al, 0x10 |
3820 | and al, 0x10 |
3821 | cmp al, ah |
3821 | cmp al, ah |
3822 | jz cnt1 |
3822 | jz cnt1 |
3823 | 3823 | ||
3824 | mov ah, al |
3824 | mov ah, al |
3825 | loop cnt1 |
3825 | loop cnt1 |
3826 | 3826 | ||
3827 | pop ecx |
3827 | pop ecx |
3828 | pop eax |
3828 | pop eax |
3829 | ret |
3829 | ret |
3830 | ;----------------------------------------------------------------------------- |
3830 | ;----------------------------------------------------------------------------- |
3831 | align 4 |
3831 | align 4 |
3832 | set_app_param: |
3832 | set_app_param: |
3833 | mov edi, [TASK_BASE] |
3833 | mov edi, [TASK_BASE] |
3834 | mov eax, ebx |
3834 | mov eax, ebx |
3835 | btr eax, 3 ; move MOUSE_FILTRATION |
3835 | btr eax, 3 ; move MOUSE_FILTRATION |
3836 | mov ebx, [current_slot] ; bit into event_filter |
3836 | mov ebx, [current_slot] ; bit into event_filter |
3837 | setc byte [ebx+APPDATA.event_filter] |
3837 | setc byte [ebx+APPDATA.event_filter] |
3838 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3838 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3839 | mov [esp+32], eax ; return old mask value |
3839 | mov [esp+32], eax ; return old mask value |
3840 | ret |
3840 | ret |
3841 | ;----------------------------------------------------------------------------- |
3841 | ;----------------------------------------------------------------------------- |
3842 | 3842 | ||
3843 | ; this is for syscall |
3843 | ; this is for syscall |
3844 | proc delay_hs_unprotected |
3844 | proc delay_hs_unprotected |
3845 | call unprotect_from_terminate |
3845 | call unprotect_from_terminate |
3846 | call delay_hs |
3846 | call delay_hs |
3847 | call protect_from_terminate |
3847 | call protect_from_terminate |
3848 | ret |
3848 | ret |
3849 | endp |
3849 | endp |
3850 | 3850 | ||
3851 | if 1 |
3851 | if 1 |
3852 | align 4 |
3852 | align 4 |
3853 | delay_hs: ; delay in 1/100 secs |
3853 | delay_hs: ; delay in 1/100 secs |
3854 | ; ebx = delay time |
3854 | ; ebx = delay time |
3855 | 3855 | ||
3856 | pushad |
3856 | pushad |
3857 | push ebx |
3857 | push ebx |
3858 | xor esi, esi |
3858 | xor esi, esi |
3859 | mov ecx, MANUAL_DESTROY |
3859 | mov ecx, MANUAL_DESTROY |
3860 | call create_event |
3860 | call create_event |
3861 | test eax, eax |
3861 | test eax, eax |
3862 | jz .done |
3862 | jz .done |
3863 | 3863 | ||
3864 | mov ebx, edx |
3864 | mov ebx, edx |
3865 | mov ecx, [esp] |
3865 | mov ecx, [esp] |
3866 | push edx |
3866 | push edx |
3867 | push eax |
3867 | push eax |
3868 | call wait_event_timeout |
3868 | call wait_event_timeout |
3869 | pop eax |
3869 | pop eax |
3870 | pop ebx |
3870 | pop ebx |
3871 | call destroy_event |
3871 | call destroy_event |
3872 | .done: |
3872 | .done: |
3873 | add esp, 4 |
3873 | add esp, 4 |
3874 | popad |
3874 | popad |
3875 | ret |
3875 | ret |
3876 | 3876 | ||
3877 | else |
3877 | else |
3878 | 3878 | ||
3879 | align 4 |
3879 | align 4 |
3880 | delay_hs: ; delay in 1/100 secs |
3880 | delay_hs: ; delay in 1/100 secs |
3881 | ; ebx = delay time |
3881 | ; ebx = delay time |
3882 | push ecx |
3882 | push ecx |
3883 | push edx |
3883 | push edx |
3884 | 3884 | ||
3885 | mov edx, [timer_ticks] |
3885 | mov edx, [timer_ticks] |
3886 | ;-------------------------------------- |
3886 | ;-------------------------------------- |
3887 | align 4 |
3887 | align 4 |
3888 | newtic: |
3888 | newtic: |
3889 | mov ecx, [timer_ticks] |
3889 | mov ecx, [timer_ticks] |
3890 | sub ecx, edx |
3890 | sub ecx, edx |
3891 | cmp ecx, ebx |
3891 | cmp ecx, ebx |
3892 | jae zerodelay |
3892 | jae zerodelay |
3893 | 3893 | ||
3894 | call change_task |
3894 | call change_task |
3895 | 3895 | ||
3896 | jmp newtic |
3896 | jmp newtic |
3897 | ;-------------------------------------- |
3897 | ;-------------------------------------- |
3898 | align 4 |
3898 | align 4 |
3899 | zerodelay: |
3899 | zerodelay: |
3900 | pop edx |
3900 | pop edx |
3901 | pop ecx |
3901 | pop ecx |
3902 | ret |
3902 | ret |
3903 | end if |
3903 | end if |
3904 | 3904 | ||
3905 | ;----------------------------------------------------------------------------- |
3905 | ;----------------------------------------------------------------------------- |
3906 | align 16 ;very often call this subrutine |
3906 | align 16 ;very often call this subrutine |
3907 | memmove: ; memory move in bytes |
3907 | memmove: ; memory move in bytes |
3908 | ; eax = from |
3908 | ; eax = from |
3909 | ; ebx = to |
3909 | ; ebx = to |
3910 | ; ecx = no of bytes |
3910 | ; ecx = no of bytes |
3911 | test ecx, ecx |
3911 | test ecx, ecx |
3912 | jle .ret |
3912 | jle .ret |
3913 | 3913 | ||
3914 | push esi edi ecx |
3914 | push esi edi ecx |
3915 | 3915 | ||
3916 | mov edi, ebx |
3916 | mov edi, ebx |
3917 | mov esi, eax |
3917 | mov esi, eax |
3918 | 3918 | ||
3919 | test ecx, not 11b |
3919 | test ecx, not 11b |
3920 | jz @f |
3920 | jz @f |
3921 | 3921 | ||
3922 | push ecx |
3922 | push ecx |
3923 | shr ecx, 2 |
3923 | shr ecx, 2 |
3924 | rep movsd |
3924 | rep movsd |
3925 | pop ecx |
3925 | pop ecx |
3926 | and ecx, 11b |
3926 | and ecx, 11b |
3927 | jz .finish |
3927 | jz .finish |
3928 | ;-------------------------------------- |
3928 | ;-------------------------------------- |
3929 | align 4 |
3929 | align 4 |
3930 | @@: |
3930 | @@: |
3931 | rep movsb |
3931 | rep movsb |
3932 | ;-------------------------------------- |
3932 | ;-------------------------------------- |
3933 | align 4 |
3933 | align 4 |
3934 | .finish: |
3934 | .finish: |
3935 | pop ecx edi esi |
3935 | pop ecx edi esi |
3936 | ;-------------------------------------- |
3936 | ;-------------------------------------- |
3937 | align 4 |
3937 | align 4 |
3938 | .ret: |
3938 | .ret: |
3939 | ret |
3939 | ret |
3940 | ;----------------------------------------------------------------------------- |
3940 | ;----------------------------------------------------------------------------- |
3941 | ; |
3941 | ; |
3942 | ;align 4 |
3942 | ;align 4 |
3943 | ; |
3943 | ; |
3944 | ;read_floppy_file: |
3944 | ;read_floppy_file: |
3945 | ; |
3945 | ; |
3946 | ;; as input |
3946 | ;; as input |
3947 | ;; |
3947 | ;; |
3948 | ;; eax pointer to file |
3948 | ;; eax pointer to file |
3949 | ;; ebx file lenght |
3949 | ;; ebx file lenght |
3950 | ;; ecx start 512 byte block number |
3950 | ;; ecx start 512 byte block number |
3951 | ;; edx number of blocks to read |
3951 | ;; edx number of blocks to read |
3952 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3952 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3953 | ;; |
3953 | ;; |
3954 | ;; |
3954 | ;; |
3955 | ;; on return |
3955 | ;; on return |
3956 | ;; |
3956 | ;; |
3957 | ;; eax = 0 command succesful |
3957 | ;; eax = 0 command succesful |
3958 | ;; 1 no fd base and/or partition defined |
3958 | ;; 1 no fd base and/or partition defined |
3959 | ;; 2 yet unsupported FS |
3959 | ;; 2 yet unsupported FS |
3960 | ;; 3 unknown FS |
3960 | ;; 3 unknown FS |
3961 | ;; 4 partition not defined at hd |
3961 | ;; 4 partition not defined at hd |
3962 | ;; 5 file not found |
3962 | ;; 5 file not found |
3963 | ;; ebx = size of file |
3963 | ;; ebx = size of file |
3964 | ; |
3964 | ; |
3965 | ; mov edi,[TASK_BASE] |
3965 | ; mov edi,[TASK_BASE] |
3966 | ; add edi,0x10 |
3966 | ; add edi,0x10 |
3967 | ; add esi,[edi] |
3967 | ; add esi,[edi] |
3968 | ; add eax,[edi] |
3968 | ; add eax,[edi] |
3969 | ; |
3969 | ; |
3970 | ; pushad |
3970 | ; pushad |
3971 | ; mov edi,esi |
3971 | ; mov edi,esi |
3972 | ; add edi,1024 |
3972 | ; add edi,1024 |
3973 | ; mov esi,0x100000+19*512 |
3973 | ; mov esi,0x100000+19*512 |
3974 | ; sub ecx,1 |
3974 | ; sub ecx,1 |
3975 | ; shl ecx,9 |
3975 | ; shl ecx,9 |
3976 | ; add esi,ecx |
3976 | ; add esi,ecx |
3977 | ; shl edx,9 |
3977 | ; shl edx,9 |
3978 | ; mov ecx,edx |
3978 | ; mov ecx,edx |
3979 | ; cld |
3979 | ; cld |
3980 | ; rep movsb |
3980 | ; rep movsb |
3981 | ; popad |
3981 | ; popad |
3982 | ; |
3982 | ; |
3983 | ; mov [esp+36],eax |
3983 | ; mov [esp+36],eax |
3984 | ; mov [esp+24],ebx |
3984 | ; mov [esp+24],ebx |
3985 | ; ret |
3985 | ; ret |
3986 | 3986 | ||
3987 | 3987 | ||
3988 | 3988 | ||
3989 | align 4 |
3989 | align 4 |
3990 | set_io_access_rights: |
3990 | set_io_access_rights: |
3991 | push edi eax |
3991 | push edi eax |
3992 | mov edi, tss._io_map_0 |
3992 | mov edi, tss._io_map_0 |
3993 | ; mov ecx,eax |
3993 | ; mov ecx,eax |
3994 | ; and ecx,7 ; offset in byte |
3994 | ; and ecx,7 ; offset in byte |
3995 | ; shr eax,3 ; number of byte |
3995 | ; shr eax,3 ; number of byte |
3996 | ; add edi,eax |
3996 | ; add edi,eax |
3997 | ; mov ebx,1 |
3997 | ; mov ebx,1 |
3998 | ; shl ebx,cl |
3998 | ; shl ebx,cl |
3999 | test ebp, ebp |
3999 | test ebp, ebp |
4000 | ; cmp ebp,0 ; enable access - ebp = 0 |
4000 | ; cmp ebp,0 ; enable access - ebp = 0 |
4001 | jnz .siar1 |
4001 | jnz .siar1 |
4002 | ; not ebx |
4002 | ; not ebx |
4003 | ; and [edi],byte bl |
4003 | ; and [edi],byte bl |
4004 | btr [edi], eax |
4004 | btr [edi], eax |
4005 | pop eax edi |
4005 | pop eax edi |
4006 | ret |
4006 | ret |
4007 | .siar1: |
4007 | .siar1: |
4008 | bts [edi], eax |
4008 | bts [edi], eax |
4009 | ; or [edi],byte bl ; disable access - ebp = 1 |
4009 | ; or [edi],byte bl ; disable access - ebp = 1 |
4010 | pop eax edi |
4010 | pop eax edi |
4011 | ret |
4011 | ret |
4012 | ;reserve/free group of ports |
4012 | ;reserve/free group of ports |
4013 | ; * eax = 46 - number function |
4013 | ; * eax = 46 - number function |
4014 | ; * ebx = 0 - reserve, 1 - free |
4014 | ; * ebx = 0 - reserve, 1 - free |
4015 | ; * ecx = number start arrea of ports |
4015 | ; * ecx = number start arrea of ports |
4016 | ; * edx = number end arrea of ports (include last number of port) |
4016 | ; * edx = number end arrea of ports (include last number of port) |
4017 | ;Return value: |
4017 | ;Return value: |
4018 | ; * eax = 0 - succesful |
4018 | ; * eax = 0 - succesful |
4019 | ; * eax = 1 - error |
4019 | ; * eax = 1 - error |
4020 | ; * The system has reserve this ports: |
4020 | ; * The system has reserve this ports: |
4021 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4021 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4022 | ;destroys eax,ebx, ebp |
4022 | ;destroys eax,ebx, ebp |
4023 | r_f_port_area: |
4023 | r_f_port_area: |
4024 | 4024 | ||
4025 | test ebx, ebx |
4025 | test ebx, ebx |
4026 | jnz free_port_area |
4026 | jnz free_port_area |
4027 | ; je r_port_area |
4027 | ; je r_port_area |
4028 | ; jmp free_port_area |
4028 | ; jmp free_port_area |
4029 | 4029 | ||
4030 | ; r_port_area: |
4030 | ; r_port_area: |
4031 | 4031 | ||
4032 | ; pushad |
4032 | ; pushad |
4033 | 4033 | ||
4034 | cmp ecx, edx ; beginning > end ? |
4034 | cmp ecx, edx ; beginning > end ? |
4035 | ja rpal1 |
4035 | ja rpal1 |
4036 | cmp edx, 65536 |
4036 | cmp edx, 65536 |
4037 | jae rpal1 |
4037 | jae rpal1 |
4038 | mov eax, [RESERVED_PORTS] |
4038 | mov eax, [RESERVED_PORTS] |
4039 | test eax, eax ; no reserved areas ? |
4039 | test eax, eax ; no reserved areas ? |
4040 | je rpal2 |
4040 | je rpal2 |
4041 | cmp eax, 255 ; max reserved |
4041 | cmp eax, 255 ; max reserved |
4042 | jae rpal1 |
4042 | jae rpal1 |
4043 | rpal3: |
4043 | rpal3: |
4044 | mov ebx, eax |
4044 | mov ebx, eax |
4045 | shl ebx, 4 |
4045 | shl ebx, 4 |
4046 | add ebx, RESERVED_PORTS |
4046 | add ebx, RESERVED_PORTS |
4047 | cmp ecx, [ebx+8] |
4047 | cmp ecx, [ebx+8] |
4048 | ja rpal4 |
4048 | ja rpal4 |
4049 | cmp edx, [ebx+4] |
4049 | cmp edx, [ebx+4] |
4050 | jae rpal1 |
4050 | jae rpal1 |
4051 | ; jb rpal4 |
4051 | ; jb rpal4 |
4052 | ; jmp rpal1 |
4052 | ; jmp rpal1 |
4053 | rpal4: |
4053 | rpal4: |
4054 | dec eax |
4054 | dec eax |
4055 | jnz rpal3 |
4055 | jnz rpal3 |
4056 | jmp rpal2 |
4056 | jmp rpal2 |
4057 | rpal1: |
4057 | rpal1: |
4058 | ; popad |
4058 | ; popad |
4059 | ; mov eax,1 |
4059 | ; mov eax,1 |
4060 | xor eax, eax |
4060 | xor eax, eax |
4061 | inc eax |
4061 | inc eax |
4062 | ret |
4062 | ret |
4063 | rpal2: |
4063 | rpal2: |
4064 | ; popad |
4064 | ; popad |
4065 | ; enable port access at port IO map |
4065 | ; enable port access at port IO map |
4066 | cli |
4066 | cli |
4067 | pushad ; start enable io map |
4067 | pushad ; start enable io map |
4068 | 4068 | ||
4069 | cmp edx, 65536;16384 |
4069 | cmp edx, 65536;16384 |
4070 | jae no_unmask_io; jge |
4070 | jae no_unmask_io; jge |
4071 | mov eax, ecx |
4071 | mov eax, ecx |
4072 | ; push ebp |
4072 | ; push ebp |
4073 | xor ebp, ebp ; enable - eax = port |
4073 | xor ebp, ebp ; enable - eax = port |
4074 | new_port_access: |
4074 | new_port_access: |
4075 | ; pushad |
4075 | ; pushad |
4076 | call set_io_access_rights |
4076 | call set_io_access_rights |
4077 | ; popad |
4077 | ; popad |
4078 | inc eax |
4078 | inc eax |
4079 | cmp eax, edx |
4079 | cmp eax, edx |
4080 | jbe new_port_access |
4080 | jbe new_port_access |
4081 | ; pop ebp |
4081 | ; pop ebp |
4082 | no_unmask_io: |
4082 | no_unmask_io: |
4083 | popad ; end enable io map |
4083 | popad ; end enable io map |
4084 | sti |
4084 | sti |
4085 | 4085 | ||
4086 | mov eax, [RESERVED_PORTS] |
4086 | mov eax, [RESERVED_PORTS] |
4087 | add eax, 1 |
4087 | add eax, 1 |
4088 | mov [RESERVED_PORTS], eax |
4088 | mov [RESERVED_PORTS], eax |
4089 | shl eax, 4 |
4089 | shl eax, 4 |
4090 | add eax, RESERVED_PORTS |
4090 | add eax, RESERVED_PORTS |
4091 | mov ebx, [TASK_BASE] |
4091 | mov ebx, [TASK_BASE] |
4092 | mov ebx, [ebx+TASKDATA.pid] |
4092 | mov ebx, [ebx+TASKDATA.pid] |
4093 | mov [eax], ebx |
4093 | mov [eax], ebx |
4094 | mov [eax+4], ecx |
4094 | mov [eax+4], ecx |
4095 | mov [eax+8], edx |
4095 | mov [eax+8], edx |
4096 | 4096 | ||
4097 | xor eax, eax |
4097 | xor eax, eax |
4098 | ret |
4098 | ret |
4099 | 4099 | ||
4100 | free_port_area: |
4100 | free_port_area: |
4101 | 4101 | ||
4102 | ; pushad |
4102 | ; pushad |
4103 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4103 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4104 | test eax, eax |
4104 | test eax, eax |
4105 | jz frpal2 |
4105 | jz frpal2 |
4106 | mov ebx, [TASK_BASE] |
4106 | mov ebx, [TASK_BASE] |
4107 | mov ebx, [ebx+TASKDATA.pid] |
4107 | mov ebx, [ebx+TASKDATA.pid] |
4108 | frpal3: |
4108 | frpal3: |
4109 | mov edi, eax |
4109 | mov edi, eax |
4110 | shl edi, 4 |
4110 | shl edi, 4 |
4111 | add edi, RESERVED_PORTS |
4111 | add edi, RESERVED_PORTS |
4112 | cmp ebx, [edi] |
4112 | cmp ebx, [edi] |
4113 | jne frpal4 |
4113 | jne frpal4 |
4114 | cmp ecx, [edi+4] |
4114 | cmp ecx, [edi+4] |
4115 | jne frpal4 |
4115 | jne frpal4 |
4116 | cmp edx, [edi+8] |
4116 | cmp edx, [edi+8] |
4117 | jne frpal4 |
4117 | jne frpal4 |
4118 | jmp frpal1 |
4118 | jmp frpal1 |
4119 | frpal4: |
4119 | frpal4: |
4120 | dec eax |
4120 | dec eax |
4121 | jnz frpal3 |
4121 | jnz frpal3 |
4122 | frpal2: |
4122 | frpal2: |
4123 | ; popad |
4123 | ; popad |
4124 | inc eax |
4124 | inc eax |
4125 | ret |
4125 | ret |
4126 | frpal1: |
4126 | frpal1: |
4127 | push ecx |
4127 | push ecx |
4128 | mov ecx, 256 |
4128 | mov ecx, 256 |
4129 | sub ecx, eax |
4129 | sub ecx, eax |
4130 | shl ecx, 4 |
4130 | shl ecx, 4 |
4131 | mov esi, edi |
4131 | mov esi, edi |
4132 | add esi, 16 |
4132 | add esi, 16 |
4133 | cld |
4133 | cld |
4134 | rep movsb |
4134 | rep movsb |
4135 | 4135 | ||
4136 | dec dword [RESERVED_PORTS] |
4136 | dec dword [RESERVED_PORTS] |
4137 | ;popad |
4137 | ;popad |
4138 | ;disable port access at port IO map |
4138 | ;disable port access at port IO map |
4139 | 4139 | ||
4140 | ; pushad ; start disable io map |
4140 | ; pushad ; start disable io map |
4141 | pop eax ;start port |
4141 | pop eax ;start port |
4142 | cmp edx, 65536;16384 |
4142 | cmp edx, 65536;16384 |
4143 | jge no_mask_io |
4143 | jge no_mask_io |
4144 | 4144 | ||
4145 | ; mov eax,ecx |
4145 | ; mov eax,ecx |
4146 | xor ebp, ebp |
4146 | xor ebp, ebp |
4147 | inc ebp |
4147 | inc ebp |
4148 | new_port_access_disable: |
4148 | new_port_access_disable: |
4149 | ; pushad |
4149 | ; pushad |
4150 | ; mov ebp,1 ; disable - eax = port |
4150 | ; mov ebp,1 ; disable - eax = port |
4151 | call set_io_access_rights |
4151 | call set_io_access_rights |
4152 | ; popad |
4152 | ; popad |
4153 | inc eax |
4153 | inc eax |
4154 | cmp eax, edx |
4154 | cmp eax, edx |
4155 | jbe new_port_access_disable |
4155 | jbe new_port_access_disable |
4156 | no_mask_io: |
4156 | no_mask_io: |
4157 | ; popad ; end disable io map |
4157 | ; popad ; end disable io map |
4158 | xor eax, eax |
4158 | xor eax, eax |
4159 | ret |
4159 | ret |
4160 | ;----------------------------------------------------------------------------- |
4160 | ;----------------------------------------------------------------------------- |
4161 | align 4 |
4161 | align 4 |
4162 | drawbackground: |
4162 | drawbackground: |
4163 | dbrv20: |
4163 | dbrv20: |
4164 | cmp [BgrDrawMode], dword 1 |
4164 | cmp [BgrDrawMode], dword 1 |
4165 | jne bgrstr |
4165 | jne bgrstr |
4166 | call vesa20_drawbackground_tiled |
4166 | call vesa20_drawbackground_tiled |
4167 | ; call [draw_pointer] |
4167 | ; call [draw_pointer] |
4168 | call __sys_draw_pointer |
4168 | call __sys_draw_pointer |
4169 | ret |
4169 | ret |
4170 | ;-------------------------------------- |
4170 | ;-------------------------------------- |
4171 | align 4 |
4171 | align 4 |
4172 | bgrstr: |
4172 | bgrstr: |
4173 | call vesa20_drawbackground_stretch |
4173 | call vesa20_drawbackground_stretch |
4174 | ; call [draw_pointer] |
4174 | ; call [draw_pointer] |
4175 | call __sys_draw_pointer |
4175 | call __sys_draw_pointer |
4176 | ret |
4176 | ret |
4177 | ;----------------------------------------------------------------------------- |
4177 | ;----------------------------------------------------------------------------- |
4178 | align 4 |
4178 | align 4 |
4179 | syscall_putimage: ; PutImage |
4179 | syscall_putimage: ; PutImage |
4180 | sys_putimage: |
4180 | sys_putimage: |
4181 | test ecx, 0x80008000 |
4181 | test ecx, 0x80008000 |
4182 | jnz .exit |
4182 | jnz .exit |
4183 | test ecx, 0x0000FFFF |
4183 | test ecx, 0x0000FFFF |
4184 | jz .exit |
4184 | jz .exit |
4185 | test ecx, 0xFFFF0000 |
4185 | test ecx, 0xFFFF0000 |
4186 | jnz @f |
4186 | jnz @f |
4187 | ;-------------------------------------- |
4187 | ;-------------------------------------- |
4188 | align 4 |
4188 | align 4 |
4189 | .exit: |
4189 | .exit: |
4190 | ret |
4190 | ret |
4191 | ;-------------------------------------- |
4191 | ;-------------------------------------- |
4192 | align 4 |
4192 | align 4 |
4193 | @@: |
4193 | @@: |
4194 | mov edi, [current_slot] |
4194 | mov edi, [current_slot] |
4195 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4195 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4196 | rol edx, 16 |
4196 | rol edx, 16 |
4197 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4197 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4198 | rol edx, 16 |
4198 | rol edx, 16 |
4199 | ;-------------------------------------- |
4199 | ;-------------------------------------- |
4200 | align 4 |
4200 | align 4 |
4201 | .forced: |
4201 | .forced: |
4202 | push ebp esi 0 |
4202 | push ebp esi 0 |
4203 | mov ebp, putimage_get24bpp |
4203 | mov ebp, putimage_get24bpp |
4204 | mov esi, putimage_init24bpp |
4204 | mov esi, putimage_init24bpp |
4205 | ;-------------------------------------- |
4205 | ;-------------------------------------- |
4206 | align 4 |
4206 | align 4 |
4207 | sys_putimage_bpp: |
4207 | sys_putimage_bpp: |
4208 | call vesa20_putimage |
4208 | call vesa20_putimage |
4209 | pop ebp esi ebp |
4209 | pop ebp esi ebp |
4210 | ret |
4210 | ret |
4211 | ; jmp [draw_pointer] |
4211 | ; jmp [draw_pointer] |
4212 | ;----------------------------------------------------------------------------- |
4212 | ;----------------------------------------------------------------------------- |
4213 | align 4 |
4213 | align 4 |
4214 | sys_putimage_palette: |
4214 | sys_putimage_palette: |
4215 | ; ebx = pointer to image |
4215 | ; ebx = pointer to image |
4216 | ; ecx = [xsize]*65536 + [ysize] |
4216 | ; ecx = [xsize]*65536 + [ysize] |
4217 | ; edx = [xstart]*65536 + [ystart] |
4217 | ; edx = [xstart]*65536 + [ystart] |
4218 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4218 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4219 | ; edi = pointer to palette |
4219 | ; edi = pointer to palette |
4220 | ; ebp = row delta |
4220 | ; ebp = row delta |
4221 | mov eax, [CURRENT_TASK] |
4221 | mov eax, [CURRENT_TASK] |
4222 | shl eax, 8 |
4222 | shl eax, 8 |
4223 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4223 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4224 | rol edx, 16 |
4224 | rol edx, 16 |
4225 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4225 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4226 | rol edx, 16 |
4226 | rol edx, 16 |
4227 | ;-------------------------------------- |
4227 | ;-------------------------------------- |
4228 | align 4 |
4228 | align 4 |
4229 | .forced: |
4229 | .forced: |
4230 | cmp esi, 1 |
4230 | cmp esi, 1 |
4231 | jnz @f |
4231 | jnz @f |
4232 | push edi |
4232 | push edi |
4233 | mov eax, [edi+4] |
4233 | mov eax, [edi+4] |
4234 | sub eax, [edi] |
4234 | sub eax, [edi] |
4235 | push eax |
4235 | push eax |
4236 | push dword [edi] |
4236 | push dword [edi] |
4237 | push 0ffffff80h |
4237 | push 0ffffff80h |
4238 | mov edi, esp |
4238 | mov edi, esp |
4239 | call put_mono_image |
4239 | call put_mono_image |
4240 | add esp, 12 |
4240 | add esp, 12 |
4241 | pop edi |
4241 | pop edi |
4242 | ret |
4242 | ret |
4243 | ;-------------------------------------- |
4243 | ;-------------------------------------- |
4244 | align 4 |
4244 | align 4 |
4245 | @@: |
4245 | @@: |
4246 | cmp esi, 2 |
4246 | cmp esi, 2 |
4247 | jnz @f |
4247 | jnz @f |
4248 | push edi |
4248 | push edi |
4249 | push 0ffffff80h |
4249 | push 0ffffff80h |
4250 | mov edi, esp |
4250 | mov edi, esp |
4251 | call put_2bit_image |
4251 | call put_2bit_image |
4252 | pop eax |
4252 | pop eax |
4253 | pop edi |
4253 | pop edi |
4254 | ret |
4254 | ret |
4255 | ;-------------------------------------- |
4255 | ;-------------------------------------- |
4256 | align 4 |
4256 | align 4 |
4257 | @@: |
4257 | @@: |
4258 | cmp esi, 4 |
4258 | cmp esi, 4 |
4259 | jnz @f |
4259 | jnz @f |
4260 | push edi |
4260 | push edi |
4261 | push 0ffffff80h |
4261 | push 0ffffff80h |
4262 | mov edi, esp |
4262 | mov edi, esp |
4263 | call put_4bit_image |
4263 | call put_4bit_image |
4264 | pop eax |
4264 | pop eax |
4265 | pop edi |
4265 | pop edi |
4266 | ret |
4266 | ret |
4267 | ;-------------------------------------- |
4267 | ;-------------------------------------- |
4268 | align 4 |
4268 | align 4 |
4269 | @@: |
4269 | @@: |
4270 | push ebp esi ebp |
4270 | push ebp esi ebp |
4271 | cmp esi, 8 |
4271 | cmp esi, 8 |
4272 | jnz @f |
4272 | jnz @f |
4273 | mov ebp, putimage_get8bpp |
4273 | mov ebp, putimage_get8bpp |
4274 | mov esi, putimage_init8bpp |
4274 | mov esi, putimage_init8bpp |
4275 | jmp sys_putimage_bpp |
4275 | jmp sys_putimage_bpp |
4276 | ;-------------------------------------- |
4276 | ;-------------------------------------- |
4277 | align 4 |
4277 | align 4 |
4278 | @@: |
4278 | @@: |
4279 | cmp esi, 9 |
4279 | cmp esi, 9 |
4280 | jnz @f |
4280 | jnz @f |
4281 | mov ebp, putimage_get9bpp |
4281 | mov ebp, putimage_get9bpp |
4282 | mov esi, putimage_init9bpp |
4282 | mov esi, putimage_init9bpp |
4283 | jmp sys_putimage_bpp |
4283 | jmp sys_putimage_bpp |
4284 | ;-------------------------------------- |
4284 | ;-------------------------------------- |
4285 | align 4 |
4285 | align 4 |
4286 | @@: |
4286 | @@: |
4287 | cmp esi, 15 |
4287 | cmp esi, 15 |
4288 | jnz @f |
4288 | jnz @f |
4289 | mov ebp, putimage_get15bpp |
4289 | mov ebp, putimage_get15bpp |
4290 | mov esi, putimage_init15bpp |
4290 | mov esi, putimage_init15bpp |
4291 | jmp sys_putimage_bpp |
4291 | jmp sys_putimage_bpp |
4292 | ;-------------------------------------- |
4292 | ;-------------------------------------- |
4293 | align 4 |
4293 | align 4 |
4294 | @@: |
4294 | @@: |
4295 | cmp esi, 16 |
4295 | cmp esi, 16 |
4296 | jnz @f |
4296 | jnz @f |
4297 | mov ebp, putimage_get16bpp |
4297 | mov ebp, putimage_get16bpp |
4298 | mov esi, putimage_init16bpp |
4298 | mov esi, putimage_init16bpp |
4299 | jmp sys_putimage_bpp |
4299 | jmp sys_putimage_bpp |
4300 | ;-------------------------------------- |
4300 | ;-------------------------------------- |
4301 | align 4 |
4301 | align 4 |
4302 | @@: |
4302 | @@: |
4303 | cmp esi, 24 |
4303 | cmp esi, 24 |
4304 | jnz @f |
4304 | jnz @f |
4305 | mov ebp, putimage_get24bpp |
4305 | mov ebp, putimage_get24bpp |
4306 | mov esi, putimage_init24bpp |
4306 | mov esi, putimage_init24bpp |
4307 | jmp sys_putimage_bpp |
4307 | jmp sys_putimage_bpp |
4308 | ;-------------------------------------- |
4308 | ;-------------------------------------- |
4309 | align 4 |
4309 | align 4 |
4310 | @@: |
4310 | @@: |
4311 | cmp esi, 32 |
4311 | cmp esi, 32 |
4312 | jnz @f |
4312 | jnz @f |
4313 | mov ebp, putimage_get32bpp |
4313 | mov ebp, putimage_get32bpp |
4314 | mov esi, putimage_init32bpp |
4314 | mov esi, putimage_init32bpp |
4315 | jmp sys_putimage_bpp |
4315 | jmp sys_putimage_bpp |
4316 | ;-------------------------------------- |
4316 | ;-------------------------------------- |
4317 | align 4 |
4317 | align 4 |
4318 | @@: |
4318 | @@: |
4319 | pop ebp esi ebp |
4319 | pop ebp esi ebp |
4320 | ret |
4320 | ret |
4321 | ;----------------------------------------------------------------------------- |
4321 | ;----------------------------------------------------------------------------- |
4322 | align 4 |
4322 | align 4 |
4323 | put_mono_image: |
4323 | put_mono_image: |
4324 | push ebp esi ebp |
4324 | push ebp esi ebp |
4325 | mov ebp, putimage_get1bpp |
4325 | mov ebp, putimage_get1bpp |
4326 | mov esi, putimage_init1bpp |
4326 | mov esi, putimage_init1bpp |
4327 | jmp sys_putimage_bpp |
4327 | jmp sys_putimage_bpp |
4328 | ;----------------------------------------------------------------------------- |
4328 | ;----------------------------------------------------------------------------- |
4329 | align 4 |
4329 | align 4 |
4330 | put_2bit_image: |
4330 | put_2bit_image: |
4331 | push ebp esi ebp |
4331 | push ebp esi ebp |
4332 | mov ebp, putimage_get2bpp |
4332 | mov ebp, putimage_get2bpp |
4333 | mov esi, putimage_init2bpp |
4333 | mov esi, putimage_init2bpp |
4334 | jmp sys_putimage_bpp |
4334 | jmp sys_putimage_bpp |
4335 | ;----------------------------------------------------------------------------- |
4335 | ;----------------------------------------------------------------------------- |
4336 | align 4 |
4336 | align 4 |
4337 | put_4bit_image: |
4337 | put_4bit_image: |
4338 | push ebp esi ebp |
4338 | push ebp esi ebp |
4339 | mov ebp, putimage_get4bpp |
4339 | mov ebp, putimage_get4bpp |
4340 | mov esi, putimage_init4bpp |
4340 | mov esi, putimage_init4bpp |
4341 | jmp sys_putimage_bpp |
4341 | jmp sys_putimage_bpp |
4342 | ;----------------------------------------------------------------------------- |
4342 | ;----------------------------------------------------------------------------- |
4343 | align 4 |
4343 | align 4 |
4344 | putimage_init24bpp: |
4344 | putimage_init24bpp: |
4345 | lea eax, [eax*3] |
4345 | lea eax, [eax*3] |
4346 | putimage_init8bpp: |
4346 | putimage_init8bpp: |
4347 | putimage_init9bpp: |
4347 | putimage_init9bpp: |
4348 | ret |
4348 | ret |
4349 | ;----------------------------------------------------------------------------- |
4349 | ;----------------------------------------------------------------------------- |
4350 | align 16 |
4350 | align 16 |
4351 | putimage_get24bpp: |
4351 | putimage_get24bpp: |
4352 | movzx eax, byte [esi+2] |
4352 | movzx eax, byte [esi+2] |
4353 | shl eax, 16 |
4353 | shl eax, 16 |
4354 | mov ax, [esi] |
4354 | mov ax, [esi] |
4355 | add esi, 3 |
4355 | add esi, 3 |
4356 | ret 4 |
4356 | ret 4 |
4357 | ;----------------------------------------------------------------------------- |
4357 | ;----------------------------------------------------------------------------- |
4358 | align 16 |
4358 | align 16 |
4359 | putimage_get8bpp: |
4359 | putimage_get8bpp: |
4360 | movzx eax, byte [esi] |
4360 | movzx eax, byte [esi] |
4361 | push edx |
4361 | push edx |
4362 | mov edx, [esp+8] |
4362 | mov edx, [esp+8] |
4363 | mov eax, [edx+eax*4] |
4363 | mov eax, [edx+eax*4] |
4364 | pop edx |
4364 | pop edx |
4365 | inc esi |
4365 | inc esi |
4366 | ret 4 |
4366 | ret 4 |
4367 | ;----------------------------------------------------------------------------- |
4367 | ;----------------------------------------------------------------------------- |
4368 | align 16 |
4368 | align 16 |
4369 | putimage_get9bpp: |
4369 | putimage_get9bpp: |
4370 | lodsb |
4370 | lodsb |
4371 | mov ah, al |
4371 | mov ah, al |
4372 | shl eax, 8 |
4372 | shl eax, 8 |
4373 | mov al, ah |
4373 | mov al, ah |
4374 | ret 4 |
4374 | ret 4 |
4375 | ;----------------------------------------------------------------------------- |
4375 | ;----------------------------------------------------------------------------- |
4376 | align 4 |
4376 | align 4 |
4377 | putimage_init1bpp: |
4377 | putimage_init1bpp: |
4378 | add eax, ecx |
4378 | add eax, ecx |
4379 | push ecx |
4379 | push ecx |
4380 | add eax, 7 |
4380 | add eax, 7 |
4381 | add ecx, 7 |
4381 | add ecx, 7 |
4382 | shr eax, 3 |
4382 | shr eax, 3 |
4383 | shr ecx, 3 |
4383 | shr ecx, 3 |
4384 | sub eax, ecx |
4384 | sub eax, ecx |
4385 | pop ecx |
4385 | pop ecx |
4386 | ret |
4386 | ret |
4387 | ;----------------------------------------------------------------------------- |
4387 | ;----------------------------------------------------------------------------- |
4388 | align 16 |
4388 | align 16 |
4389 | putimage_get1bpp: |
4389 | putimage_get1bpp: |
4390 | push edx |
4390 | push edx |
4391 | mov edx, [esp+8] |
4391 | mov edx, [esp+8] |
4392 | mov al, [edx] |
4392 | mov al, [edx] |
4393 | add al, al |
4393 | add al, al |
4394 | jnz @f |
4394 | jnz @f |
4395 | lodsb |
4395 | lodsb |
4396 | adc al, al |
4396 | adc al, al |
4397 | @@: |
4397 | @@: |
4398 | mov [edx], al |
4398 | mov [edx], al |
4399 | sbb eax, eax |
4399 | sbb eax, eax |
4400 | and eax, [edx+8] |
4400 | and eax, [edx+8] |
4401 | add eax, [edx+4] |
4401 | add eax, [edx+4] |
4402 | pop edx |
4402 | pop edx |
4403 | ret 4 |
4403 | ret 4 |
4404 | ;----------------------------------------------------------------------------- |
4404 | ;----------------------------------------------------------------------------- |
4405 | align 4 |
4405 | align 4 |
4406 | putimage_init2bpp: |
4406 | putimage_init2bpp: |
4407 | add eax, ecx |
4407 | add eax, ecx |
4408 | push ecx |
4408 | push ecx |
4409 | add ecx, 3 |
4409 | add ecx, 3 |
4410 | add eax, 3 |
4410 | add eax, 3 |
4411 | shr ecx, 2 |
4411 | shr ecx, 2 |
4412 | shr eax, 2 |
4412 | shr eax, 2 |
4413 | sub eax, ecx |
4413 | sub eax, ecx |
4414 | pop ecx |
4414 | pop ecx |
4415 | ret |
4415 | ret |
4416 | ;----------------------------------------------------------------------------- |
4416 | ;----------------------------------------------------------------------------- |
4417 | align 16 |
4417 | align 16 |
4418 | putimage_get2bpp: |
4418 | putimage_get2bpp: |
4419 | push edx |
4419 | push edx |
4420 | mov edx, [esp+8] |
4420 | mov edx, [esp+8] |
4421 | mov al, [edx] |
4421 | mov al, [edx] |
4422 | mov ah, al |
4422 | mov ah, al |
4423 | shr al, 6 |
4423 | shr al, 6 |
4424 | shl ah, 2 |
4424 | shl ah, 2 |
4425 | jnz .nonewbyte |
4425 | jnz .nonewbyte |
4426 | lodsb |
4426 | lodsb |
4427 | mov ah, al |
4427 | mov ah, al |
4428 | shr al, 6 |
4428 | shr al, 6 |
4429 | shl ah, 2 |
4429 | shl ah, 2 |
4430 | add ah, 1 |
4430 | add ah, 1 |
4431 | .nonewbyte: |
4431 | .nonewbyte: |
4432 | mov [edx], ah |
4432 | mov [edx], ah |
4433 | mov edx, [edx+4] |
4433 | mov edx, [edx+4] |
4434 | movzx eax, al |
4434 | movzx eax, al |
4435 | mov eax, [edx+eax*4] |
4435 | mov eax, [edx+eax*4] |
4436 | pop edx |
4436 | pop edx |
4437 | ret 4 |
4437 | ret 4 |
4438 | ;----------------------------------------------------------------------------- |
4438 | ;----------------------------------------------------------------------------- |
4439 | align 4 |
4439 | align 4 |
4440 | putimage_init4bpp: |
4440 | putimage_init4bpp: |
4441 | add eax, ecx |
4441 | add eax, ecx |
4442 | push ecx |
4442 | push ecx |
4443 | add ecx, 1 |
4443 | add ecx, 1 |
4444 | add eax, 1 |
4444 | add eax, 1 |
4445 | shr ecx, 1 |
4445 | shr ecx, 1 |
4446 | shr eax, 1 |
4446 | shr eax, 1 |
4447 | sub eax, ecx |
4447 | sub eax, ecx |
4448 | pop ecx |
4448 | pop ecx |
4449 | ret |
4449 | ret |
4450 | ;----------------------------------------------------------------------------- |
4450 | ;----------------------------------------------------------------------------- |
4451 | align 16 |
4451 | align 16 |
4452 | putimage_get4bpp: |
4452 | putimage_get4bpp: |
4453 | push edx |
4453 | push edx |
4454 | mov edx, [esp+8] |
4454 | mov edx, [esp+8] |
4455 | add byte [edx], 80h |
4455 | add byte [edx], 80h |
4456 | jc @f |
4456 | jc @f |
4457 | movzx eax, byte [edx+1] |
4457 | movzx eax, byte [edx+1] |
4458 | mov edx, [edx+4] |
4458 | mov edx, [edx+4] |
4459 | and eax, 0x0F |
4459 | and eax, 0x0F |
4460 | mov eax, [edx+eax*4] |
4460 | mov eax, [edx+eax*4] |
4461 | pop edx |
4461 | pop edx |
4462 | ret 4 |
4462 | ret 4 |
4463 | @@: |
4463 | @@: |
4464 | movzx eax, byte [esi] |
4464 | movzx eax, byte [esi] |
4465 | add esi, 1 |
4465 | add esi, 1 |
4466 | mov [edx+1], al |
4466 | mov [edx+1], al |
4467 | shr eax, 4 |
4467 | shr eax, 4 |
4468 | mov edx, [edx+4] |
4468 | mov edx, [edx+4] |
4469 | mov eax, [edx+eax*4] |
4469 | mov eax, [edx+eax*4] |
4470 | pop edx |
4470 | pop edx |
4471 | ret 4 |
4471 | ret 4 |
4472 | ;----------------------------------------------------------------------------- |
4472 | ;----------------------------------------------------------------------------- |
4473 | align 4 |
4473 | align 4 |
4474 | putimage_init32bpp: |
4474 | putimage_init32bpp: |
4475 | shl eax, 2 |
4475 | shl eax, 2 |
4476 | ret |
4476 | ret |
4477 | ;----------------------------------------------------------------------------- |
4477 | ;----------------------------------------------------------------------------- |
4478 | align 16 |
4478 | align 16 |
4479 | putimage_get32bpp: |
4479 | putimage_get32bpp: |
4480 | lodsd |
4480 | lodsd |
4481 | ret 4 |
4481 | ret 4 |
4482 | ;----------------------------------------------------------------------------- |
4482 | ;----------------------------------------------------------------------------- |
4483 | align 4 |
4483 | align 4 |
4484 | putimage_init15bpp: |
4484 | putimage_init15bpp: |
4485 | putimage_init16bpp: |
4485 | putimage_init16bpp: |
4486 | add eax, eax |
4486 | add eax, eax |
4487 | ret |
4487 | ret |
4488 | ;----------------------------------------------------------------------------- |
4488 | ;----------------------------------------------------------------------------- |
4489 | align 16 |
4489 | align 16 |
4490 | putimage_get15bpp: |
4490 | putimage_get15bpp: |
4491 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4491 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4492 | push ecx edx |
4492 | push ecx edx |
4493 | movzx eax, word [esi] |
4493 | movzx eax, word [esi] |
4494 | add esi, 2 |
4494 | add esi, 2 |
4495 | mov ecx, eax |
4495 | mov ecx, eax |
4496 | mov edx, eax |
4496 | mov edx, eax |
4497 | and eax, 0x1F |
4497 | and eax, 0x1F |
4498 | and ecx, 0x1F shl 5 |
4498 | and ecx, 0x1F shl 5 |
4499 | and edx, 0x1F shl 10 |
4499 | and edx, 0x1F shl 10 |
4500 | shl eax, 3 |
4500 | shl eax, 3 |
4501 | shl ecx, 6 |
4501 | shl ecx, 6 |
4502 | shl edx, 9 |
4502 | shl edx, 9 |
4503 | or eax, ecx |
4503 | or eax, ecx |
4504 | or eax, edx |
4504 | or eax, edx |
4505 | pop edx ecx |
4505 | pop edx ecx |
4506 | ret 4 |
4506 | ret 4 |
4507 | ;----------------------------------------------------------------------------- |
4507 | ;----------------------------------------------------------------------------- |
4508 | align 16 |
4508 | align 16 |
4509 | putimage_get16bpp: |
4509 | putimage_get16bpp: |
4510 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4510 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4511 | push ecx edx |
4511 | push ecx edx |
4512 | movzx eax, word [esi] |
4512 | movzx eax, word [esi] |
4513 | add esi, 2 |
4513 | add esi, 2 |
4514 | mov ecx, eax |
4514 | mov ecx, eax |
4515 | mov edx, eax |
4515 | mov edx, eax |
4516 | and eax, 0x1F |
4516 | and eax, 0x1F |
4517 | and ecx, 0x3F shl 5 |
4517 | and ecx, 0x3F shl 5 |
4518 | and edx, 0x1F shl 11 |
4518 | and edx, 0x1F shl 11 |
4519 | shl eax, 3 |
4519 | shl eax, 3 |
4520 | shl ecx, 5 |
4520 | shl ecx, 5 |
4521 | shl edx, 8 |
4521 | shl edx, 8 |
4522 | or eax, ecx |
4522 | or eax, ecx |
4523 | or eax, edx |
4523 | or eax, edx |
4524 | pop edx ecx |
4524 | pop edx ecx |
4525 | ret 4 |
4525 | ret 4 |
4526 | ;----------------------------------------------------------------------------- |
4526 | ;----------------------------------------------------------------------------- |
4527 | ;align 4 |
4527 | ;align 4 |
4528 | ; eax x beginning |
4528 | ; eax x beginning |
4529 | ; ebx y beginning |
4529 | ; ebx y beginning |
4530 | ; ecx x end |
4530 | ; ecx x end |
4531 | ; edx y end |
4531 | ; edx y end |
4532 | ; edi color |
4532 | ; edi color |
4533 | ;__sys_drawbar: |
4533 | ;__sys_drawbar: |
4534 | ; mov esi, [current_slot] |
4534 | ; mov esi, [current_slot] |
4535 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4535 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4536 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4536 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4537 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4537 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4538 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4538 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4539 | ;-------------------------------------- |
4539 | ;-------------------------------------- |
4540 | ;align 4 |
4540 | ;align 4 |
4541 | ;.forced: |
4541 | ;.forced: |
4542 | ; call vesa20_drawbar |
4542 | ; call vesa20_drawbar |
4543 | ; call [draw_pointer] |
4543 | ; call [draw_pointer] |
4544 | ; ret |
4544 | ; ret |
4545 | ;----------------------------------------------------------------------------- |
4545 | ;----------------------------------------------------------------------------- |
4546 | align 4 |
4546 | align 4 |
4547 | kb_read: |
4547 | kb_read: |
4548 | 4548 | ||
4549 | push ecx edx |
4549 | push ecx edx |
4550 | 4550 | ||
4551 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4551 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4552 | kr_loop: |
4552 | kr_loop: |
4553 | in al, 0x64 |
4553 | in al, 0x64 |
4554 | test al, 1 |
4554 | test al, 1 |
4555 | jnz kr_ready |
4555 | jnz kr_ready |
4556 | loop kr_loop |
4556 | loop kr_loop |
4557 | mov ah, 1 |
4557 | mov ah, 1 |
4558 | jmp kr_exit |
4558 | jmp kr_exit |
4559 | kr_ready: |
4559 | kr_ready: |
4560 | push ecx |
4560 | push ecx |
4561 | mov ecx, 32 |
4561 | mov ecx, 32 |
4562 | kr_delay: |
4562 | kr_delay: |
4563 | loop kr_delay |
4563 | loop kr_delay |
4564 | pop ecx |
4564 | pop ecx |
4565 | in al, 0x60 |
4565 | in al, 0x60 |
4566 | xor ah, ah |
4566 | xor ah, ah |
4567 | kr_exit: |
4567 | kr_exit: |
4568 | 4568 | ||
4569 | pop edx ecx |
4569 | pop edx ecx |
4570 | 4570 | ||
4571 | ret |
4571 | ret |
4572 | ;----------------------------------------------------------------------------- |
4572 | ;----------------------------------------------------------------------------- |
4573 | align 4 |
4573 | align 4 |
4574 | kb_write: |
4574 | kb_write: |
4575 | 4575 | ||
4576 | push ecx edx |
4576 | push ecx edx |
4577 | 4577 | ||
4578 | mov dl, al |
4578 | mov dl, al |
4579 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4579 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4580 | ; kw_loop1: |
4580 | ; kw_loop1: |
4581 | ; in al,0x64 |
4581 | ; in al,0x64 |
4582 | ; test al,0x20 |
4582 | ; test al,0x20 |
4583 | ; jz kw_ok1 |
4583 | ; jz kw_ok1 |
4584 | ; loop kw_loop1 |
4584 | ; loop kw_loop1 |
4585 | ; mov ah,1 |
4585 | ; mov ah,1 |
4586 | ; jmp kw_exit |
4586 | ; jmp kw_exit |
4587 | ; kw_ok1: |
4587 | ; kw_ok1: |
4588 | in al, 0x60 |
4588 | in al, 0x60 |
4589 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4589 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4590 | kw_loop: |
4590 | kw_loop: |
4591 | in al, 0x64 |
4591 | in al, 0x64 |
4592 | test al, 2 |
4592 | test al, 2 |
4593 | jz kw_ok |
4593 | jz kw_ok |
4594 | loop kw_loop |
4594 | loop kw_loop |
4595 | mov ah, 1 |
4595 | mov ah, 1 |
4596 | jmp kw_exit |
4596 | jmp kw_exit |
4597 | kw_ok: |
4597 | kw_ok: |
4598 | mov al, dl |
4598 | mov al, dl |
4599 | out 0x60, al |
4599 | out 0x60, al |
4600 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4600 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4601 | kw_loop3: |
4601 | kw_loop3: |
4602 | in al, 0x64 |
4602 | in al, 0x64 |
4603 | test al, 2 |
4603 | test al, 2 |
4604 | jz kw_ok3 |
4604 | jz kw_ok3 |
4605 | loop kw_loop3 |
4605 | loop kw_loop3 |
4606 | mov ah, 1 |
4606 | mov ah, 1 |
4607 | jmp kw_exit |
4607 | jmp kw_exit |
4608 | kw_ok3: |
4608 | kw_ok3: |
4609 | mov ah, 8 |
4609 | mov ah, 8 |
4610 | kw_loop4: |
4610 | kw_loop4: |
4611 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4611 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4612 | kw_loop5: |
4612 | kw_loop5: |
4613 | in al, 0x64 |
4613 | in al, 0x64 |
4614 | test al, 1 |
4614 | test al, 1 |
4615 | jnz kw_ok4 |
4615 | jnz kw_ok4 |
4616 | loop kw_loop5 |
4616 | loop kw_loop5 |
4617 | dec ah |
4617 | dec ah |
4618 | jnz kw_loop4 |
4618 | jnz kw_loop4 |
4619 | kw_ok4: |
4619 | kw_ok4: |
4620 | xor ah, ah |
4620 | xor ah, ah |
4621 | kw_exit: |
4621 | kw_exit: |
4622 | 4622 | ||
4623 | pop edx ecx |
4623 | pop edx ecx |
4624 | 4624 | ||
4625 | ret |
4625 | ret |
4626 | ;----------------------------------------------------------------------------- |
4626 | ;----------------------------------------------------------------------------- |
4627 | align 4 |
4627 | align 4 |
4628 | kb_cmd: |
4628 | kb_cmd: |
4629 | 4629 | ||
4630 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4630 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4631 | c_wait: |
4631 | c_wait: |
4632 | in al, 0x64 |
4632 | in al, 0x64 |
4633 | test al, 2 |
4633 | test al, 2 |
4634 | jz c_send |
4634 | jz c_send |
4635 | loop c_wait |
4635 | loop c_wait |
4636 | jmp c_error |
4636 | jmp c_error |
4637 | c_send: |
4637 | c_send: |
4638 | mov al, bl |
4638 | mov al, bl |
4639 | out 0x64, al |
4639 | out 0x64, al |
4640 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4640 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4641 | c_accept: |
4641 | c_accept: |
4642 | in al, 0x64 |
4642 | in al, 0x64 |
4643 | test al, 2 |
4643 | test al, 2 |
4644 | jz c_ok |
4644 | jz c_ok |
4645 | loop c_accept |
4645 | loop c_accept |
4646 | c_error: |
4646 | c_error: |
4647 | mov ah, 1 |
4647 | mov ah, 1 |
4648 | jmp c_exit |
4648 | jmp c_exit |
4649 | c_ok: |
4649 | c_ok: |
4650 | xor ah, ah |
4650 | xor ah, ah |
4651 | c_exit: |
4651 | c_exit: |
4652 | ret |
4652 | ret |
4653 | 4653 | ||
4654 | 4654 | ||
4655 | setmouse: ; set mousepicture -pointer |
4655 | setmouse: ; set mousepicture -pointer |
4656 | ; ps2 mouse enable |
4656 | ; ps2 mouse enable |
4657 | 4657 | ||
4658 | ; mov [MOUSE_PICTURE], dword mousepointer |
4658 | ; mov [MOUSE_PICTURE], dword mousepointer |
4659 | 4659 | ||
4660 | cli |
4660 | cli |
4661 | 4661 | ||
4662 | ret |
4662 | ret |
4663 | 4663 | ||
4664 | if used _rdtsc |
4664 | if used _rdtsc |
4665 | _rdtsc: |
4665 | _rdtsc: |
4666 | bt [cpu_caps], CAPS_TSC |
4666 | bt [cpu_caps], CAPS_TSC |
4667 | jnc ret_rdtsc |
4667 | jnc ret_rdtsc |
4668 | rdtsc |
4668 | rdtsc |
4669 | ret |
4669 | ret |
4670 | ret_rdtsc: |
4670 | ret_rdtsc: |
4671 | mov edx, 0xffffffff |
4671 | mov edx, 0xffffffff |
4672 | mov eax, 0xffffffff |
4672 | mov eax, 0xffffffff |
4673 | ret |
4673 | ret |
4674 | end if |
4674 | end if |
4675 | 4675 | ||
4676 | sys_msg_board_str: |
4676 | sys_msg_board_str: |
4677 | 4677 | ||
4678 | pushad |
4678 | pushad |
4679 | @@: |
4679 | @@: |
4680 | cmp [esi], byte 0 |
4680 | cmp [esi], byte 0 |
4681 | je @f |
4681 | je @f |
4682 | mov eax, 1 |
4682 | mov eax, 1 |
4683 | movzx ebx, byte [esi] |
4683 | movzx ebx, byte [esi] |
4684 | call sys_msg_board |
4684 | call sys_msg_board |
4685 | inc esi |
4685 | inc esi |
4686 | jmp @b |
4686 | jmp @b |
4687 | @@: |
4687 | @@: |
4688 | popad |
4688 | popad |
4689 | ret |
4689 | ret |
4690 | 4690 | ||
4691 | sys_msg_board_byte: |
4691 | sys_msg_board_byte: |
4692 | ; in: al = byte to display |
4692 | ; in: al = byte to display |
4693 | ; out: nothing |
4693 | ; out: nothing |
4694 | ; destroys: nothing |
4694 | ; destroys: nothing |
4695 | pushad |
4695 | pushad |
4696 | mov ecx, 2 |
4696 | mov ecx, 2 |
4697 | shl eax, 24 |
4697 | shl eax, 24 |
4698 | jmp @f |
4698 | jmp @f |
4699 | 4699 | ||
4700 | sys_msg_board_word: |
4700 | sys_msg_board_word: |
4701 | ; in: ax = word to display |
4701 | ; in: ax = word to display |
4702 | ; out: nothing |
4702 | ; out: nothing |
4703 | ; destroys: nothing |
4703 | ; destroys: nothing |
4704 | pushad |
4704 | pushad |
4705 | mov ecx, 4 |
4705 | mov ecx, 4 |
4706 | shl eax, 16 |
4706 | shl eax, 16 |
4707 | jmp @f |
4707 | jmp @f |
4708 | 4708 | ||
4709 | sys_msg_board_dword: |
4709 | sys_msg_board_dword: |
4710 | ; in: eax = dword to display |
4710 | ; in: eax = dword to display |
4711 | ; out: nothing |
4711 | ; out: nothing |
4712 | ; destroys: nothing |
4712 | ; destroys: nothing |
4713 | pushad |
4713 | pushad |
4714 | mov ecx, 8 |
4714 | mov ecx, 8 |
4715 | @@: |
4715 | @@: |
4716 | push ecx |
4716 | push ecx |
4717 | rol eax, 4 |
4717 | rol eax, 4 |
4718 | push eax |
4718 | push eax |
4719 | and al, 0xF |
4719 | and al, 0xF |
4720 | cmp al, 10 |
4720 | cmp al, 10 |
4721 | sbb al, 69h |
4721 | sbb al, 69h |
4722 | das |
4722 | das |
4723 | mov bl, al |
4723 | mov bl, al |
4724 | xor eax, eax |
4724 | xor eax, eax |
4725 | inc eax |
4725 | inc eax |
4726 | call sys_msg_board |
4726 | call sys_msg_board |
4727 | pop eax |
4727 | pop eax |
4728 | pop ecx |
4728 | pop ecx |
4729 | loop @b |
4729 | loop @b |
4730 | popad |
4730 | popad |
4731 | ret |
4731 | ret |
4732 | 4732 | ||
4733 | msg_board_data_size = 65536 ; Must be power of two |
4733 | msg_board_data_size = 65536 ; Must be power of two |
4734 | 4734 | ||
4735 | uglobal |
4735 | uglobal |
4736 | msg_board_data rb msg_board_data_size |
4736 | msg_board_data rb msg_board_data_size |
4737 | msg_board_count dd 0x0 |
4737 | msg_board_count dd 0x0 |
4738 | endg |
4738 | endg |
4739 | 4739 | ||
4740 | sys_msg_board: |
4740 | sys_msg_board: |
4741 | 4741 | ||
4742 | ; eax=1 : write : bl byte to write |
4742 | ; eax=1 : write : bl byte to write |
4743 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4743 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4744 | 4744 | ||
4745 | mov ecx, [msg_board_count] |
4745 | mov ecx, [msg_board_count] |
4746 | cmp eax, 1 |
4746 | cmp eax, 1 |
4747 | jne .smbl1 |
4747 | jne .smbl1 |
4748 | 4748 | ||
4749 | if defined debug_com_base |
4749 | if defined debug_com_base |
4750 | 4750 | ||
4751 | push dx ax |
4751 | push dx ax |
4752 | 4752 | ||
4753 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4753 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4754 | mov dx, debug_com_base+5 |
4754 | mov dx, debug_com_base+5 |
4755 | in al, dx |
4755 | in al, dx |
4756 | test al, 1 shl 5 |
4756 | test al, 1 shl 5 |
4757 | jz @r |
4757 | jz @r |
4758 | 4758 | ||
4759 | mov dx, debug_com_base ; Output the byte |
4759 | mov dx, debug_com_base ; Output the byte |
4760 | mov al, bl |
4760 | mov al, bl |
4761 | out dx, al |
4761 | out dx, al |
4762 | 4762 | ||
4763 | pop ax dx |
4763 | pop ax dx |
4764 | 4764 | ||
4765 | end if |
4765 | end if |
4766 | 4766 | ||
4767 | mov [msg_board_data+ecx], bl |
4767 | mov [msg_board_data+ecx], bl |
4768 | if debug_direct_print |
4768 | if debug_direct_print |
4769 | pusha |
4769 | pusha |
4770 | iglobal |
4770 | iglobal |
4771 | msg_board_pos dd 234*65536+10 |
4771 | msg_board_pos dd 234*65536+10 |
4772 | endg |
4772 | endg |
4773 | lea edx, [msg_board_data+ecx] |
4773 | lea edx, [msg_board_data+ecx] |
4774 | mov ecx, 0x40FFFFFF |
4774 | mov ecx, 0x40FFFFFF |
4775 | mov ebx, [msg_board_pos] |
4775 | mov ebx, [msg_board_pos] |
4776 | mov edi, 1 |
4776 | mov edi, 1 |
4777 | mov esi, 1 |
4777 | mov esi, 1 |
4778 | call dtext |
4778 | call dtext |
4779 | popa |
4779 | popa |
4780 | add word [msg_board_pos+2], 6 |
4780 | add word [msg_board_pos+2], 6 |
4781 | cmp bl, 10 |
4781 | cmp bl, 10 |
4782 | jnz @f |
4782 | jnz @f |
4783 | mov word [msg_board_pos+2], 234 |
4783 | mov word [msg_board_pos+2], 234 |
4784 | add word [msg_board_pos], 10 |
4784 | add word [msg_board_pos], 10 |
4785 | mov ax, [Screen_Max_Y] |
4785 | mov ax, [Screen_Max_Y] |
4786 | cmp word [msg_board_pos], ax |
4786 | cmp word [msg_board_pos], ax |
4787 | jbe @f |
4787 | jbe @f |
4788 | mov word [msg_board_pos], 10 |
4788 | mov word [msg_board_pos], 10 |
4789 | @@: |
4789 | @@: |
4790 | end if |
4790 | end if |
4791 | if 0 |
4791 | if 0 |
4792 | pusha |
4792 | pusha |
4793 | mov al, bl |
4793 | mov al, bl |
4794 | mov edx, 402h |
4794 | mov edx, 402h |
4795 | out dx, al |
4795 | out dx, al |
4796 | popa |
4796 | popa |
4797 | end if |
4797 | end if |
4798 | inc ecx |
4798 | inc ecx |
4799 | and ecx, msg_board_data_size - 1 |
4799 | and ecx, msg_board_data_size - 1 |
4800 | mov [msg_board_count], ecx |
4800 | mov [msg_board_count], ecx |
4801 | ret |
4801 | ret |
4802 | .smbl1: |
4802 | .smbl1: |
4803 | cmp eax, 2 |
4803 | cmp eax, 2 |
4804 | jne .smbl2 |
4804 | jne .smbl2 |
4805 | test ecx, ecx |
4805 | test ecx, ecx |
4806 | jz .smbl21 |
4806 | jz .smbl21 |
4807 | mov eax, msg_board_data+1 |
4807 | mov eax, msg_board_data+1 |
4808 | mov ebx, msg_board_data |
4808 | mov ebx, msg_board_data |
4809 | movzx edx, byte [ebx] |
4809 | movzx edx, byte [ebx] |
4810 | call memmove |
4810 | call memmove |
4811 | dec [msg_board_count] |
4811 | dec [msg_board_count] |
4812 | mov [esp + 36], edx ;eax |
4812 | mov [esp + 36], edx ;eax |
4813 | mov [esp + 24], dword 1 |
4813 | mov [esp + 24], dword 1 |
4814 | ret |
4814 | ret |
4815 | .smbl21: |
4815 | .smbl21: |
4816 | mov [esp+36], ecx |
4816 | mov [esp+36], ecx |
4817 | mov [esp+24], ecx |
4817 | mov [esp+24], ecx |
4818 | .smbl2: |
4818 | .smbl2: |
4819 | ret |
4819 | ret |
4820 | 4820 | ||
4821 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4821 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4822 | ;; 66 sys function. ;; |
4822 | ;; 66 sys function. ;; |
4823 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4823 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4824 | ;; out eax ;; |
4824 | ;; out eax ;; |
4825 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4825 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4826 | iglobal |
4826 | iglobal |
4827 | align 4 |
4827 | align 4 |
4828 | f66call: |
4828 | f66call: |
4829 | dd sys_process_def.1 ; 1 = set keyboard mode |
4829 | dd sys_process_def.1 ; 1 = set keyboard mode |
4830 | dd sys_process_def.2 ; 2 = get keyboard mode |
4830 | dd sys_process_def.2 ; 2 = get keyboard mode |
4831 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4831 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4832 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4832 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4833 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4833 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4834 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4834 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4835 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4835 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4836 | endg |
4836 | endg |
4837 | ;----------------------------------------------------------------------------- |
4837 | ;----------------------------------------------------------------------------- |
4838 | align 4 |
4838 | align 4 |
4839 | sys_process_def: |
4839 | sys_process_def: |
4840 | dec ebx |
4840 | dec ebx |
4841 | cmp ebx, 7 |
4841 | cmp ebx, 7 |
4842 | jae .not_support ;if >=8 then or eax,-1 |
4842 | jae .not_support ;if >=8 then or eax,-1 |
4843 | 4843 | ||
4844 | mov edi, [CURRENT_TASK] |
4844 | mov edi, [CURRENT_TASK] |
4845 | jmp dword [f66call+ebx*4] |
4845 | jmp dword [f66call+ebx*4] |
4846 | 4846 | ||
4847 | .not_support: |
4847 | .not_support: |
4848 | or eax, -1 |
4848 | or eax, -1 |
4849 | ret |
4849 | ret |
4850 | ;----------------------------------------------------------------------------- |
4850 | ;----------------------------------------------------------------------------- |
4851 | align 4 |
4851 | align 4 |
4852 | .1: |
4852 | .1: |
4853 | shl edi, 8 |
4853 | shl edi, 8 |
4854 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4854 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4855 | 4855 | ||
4856 | ret |
4856 | ret |
4857 | ;----------------------------------------------------------------------------- |
4857 | ;----------------------------------------------------------------------------- |
4858 | align 4 |
4858 | align 4 |
4859 | .2: ; 2 = get keyboard mode |
4859 | .2: ; 2 = get keyboard mode |
4860 | shl edi, 8 |
4860 | shl edi, 8 |
4861 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4861 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4862 | mov [esp+32], eax |
4862 | mov [esp+32], eax |
4863 | ret |
4863 | ret |
4864 | ;----------------------------------------------------------------------------- |
4864 | ;----------------------------------------------------------------------------- |
4865 | align 4 |
4865 | align 4 |
4866 | .3: ;3 = get keyboard ctrl, alt, shift |
4866 | .3: ;3 = get keyboard ctrl, alt, shift |
4867 | mov eax, [kb_state] |
4867 | mov eax, [kb_state] |
4868 | mov [esp+32], eax |
4868 | mov [esp+32], eax |
4869 | ret |
4869 | ret |
4870 | ;----------------------------------------------------------------------------- |
4870 | ;----------------------------------------------------------------------------- |
4871 | align 4 |
4871 | align 4 |
4872 | .4: |
4872 | .4: |
4873 | mov eax, hotkey_list |
4873 | mov eax, hotkey_list |
4874 | @@: |
4874 | @@: |
4875 | cmp dword [eax+8], 0 |
4875 | cmp dword [eax+8], 0 |
4876 | jz .found_free |
4876 | jz .found_free |
4877 | add eax, 16 |
4877 | add eax, 16 |
4878 | cmp eax, hotkey_list+16*256 |
4878 | cmp eax, hotkey_list+16*256 |
4879 | jb @b |
4879 | jb @b |
4880 | mov dword [esp+32], 1 |
4880 | mov dword [esp+32], 1 |
4881 | ret |
4881 | ret |
4882 | .found_free: |
4882 | .found_free: |
4883 | mov [eax+8], edi |
4883 | mov [eax+8], edi |
4884 | mov [eax+4], edx |
4884 | mov [eax+4], edx |
4885 | movzx ecx, cl |
4885 | movzx ecx, cl |
4886 | lea ecx, [hotkey_scancodes+ecx*4] |
4886 | lea ecx, [hotkey_scancodes+ecx*4] |
4887 | mov edx, [ecx] |
4887 | mov edx, [ecx] |
4888 | mov [eax], edx |
4888 | mov [eax], edx |
4889 | mov [ecx], eax |
4889 | mov [ecx], eax |
4890 | mov [eax+12], ecx |
4890 | mov [eax+12], ecx |
4891 | test edx, edx |
4891 | test edx, edx |
4892 | jz @f |
4892 | jz @f |
4893 | mov [edx+12], eax |
4893 | mov [edx+12], eax |
4894 | @@: |
4894 | @@: |
4895 | and dword [esp+32], 0 |
4895 | and dword [esp+32], 0 |
4896 | ret |
4896 | ret |
4897 | ;----------------------------------------------------------------------------- |
4897 | ;----------------------------------------------------------------------------- |
4898 | align 4 |
4898 | align 4 |
4899 | .5: |
4899 | .5: |
4900 | movzx ebx, cl |
4900 | movzx ebx, cl |
4901 | lea ebx, [hotkey_scancodes+ebx*4] |
4901 | lea ebx, [hotkey_scancodes+ebx*4] |
4902 | mov eax, [ebx] |
4902 | mov eax, [ebx] |
4903 | .scan: |
4903 | .scan: |
4904 | test eax, eax |
4904 | test eax, eax |
4905 | jz .notfound |
4905 | jz .notfound |
4906 | cmp [eax+8], edi |
4906 | cmp [eax+8], edi |
4907 | jnz .next |
4907 | jnz .next |
4908 | cmp [eax+4], edx |
4908 | cmp [eax+4], edx |
4909 | jz .found |
4909 | jz .found |
4910 | .next: |
4910 | .next: |
4911 | mov eax, [eax] |
4911 | mov eax, [eax] |
4912 | jmp .scan |
4912 | jmp .scan |
4913 | .notfound: |
4913 | .notfound: |
4914 | mov dword [esp+32], 1 |
4914 | mov dword [esp+32], 1 |
4915 | ret |
4915 | ret |
4916 | .found: |
4916 | .found: |
4917 | mov ecx, [eax] |
4917 | mov ecx, [eax] |
4918 | jecxz @f |
4918 | jecxz @f |
4919 | mov edx, [eax+12] |
4919 | mov edx, [eax+12] |
4920 | mov [ecx+12], edx |
4920 | mov [ecx+12], edx |
4921 | @@: |
4921 | @@: |
4922 | mov ecx, [eax+12] |
4922 | mov ecx, [eax+12] |
4923 | mov edx, [eax] |
4923 | mov edx, [eax] |
4924 | mov [ecx], edx |
4924 | mov [ecx], edx |
4925 | xor edx, edx |
4925 | xor edx, edx |
4926 | mov [eax+4], edx |
4926 | mov [eax+4], edx |
4927 | mov [eax+8], edx |
4927 | mov [eax+8], edx |
4928 | mov [eax+12], edx |
4928 | mov [eax+12], edx |
4929 | mov [eax], edx |
4929 | mov [eax], edx |
4930 | mov [esp+32], edx |
4930 | mov [esp+32], edx |
4931 | ret |
4931 | ret |
4932 | ;----------------------------------------------------------------------------- |
4932 | ;----------------------------------------------------------------------------- |
4933 | align 4 |
4933 | align 4 |
4934 | .6: |
4934 | .6: |
4935 | pushfd |
4935 | pushfd |
4936 | cli |
4936 | cli |
4937 | mov eax, [PID_lock_input] |
4937 | mov eax, [PID_lock_input] |
4938 | test eax, eax |
4938 | test eax, eax |
4939 | jnz @f |
4939 | jnz @f |
4940 | ; get current PID |
4940 | ; get current PID |
4941 | mov eax, [CURRENT_TASK] |
4941 | mov eax, [CURRENT_TASK] |
4942 | shl eax, 5 |
4942 | shl eax, 5 |
4943 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4943 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4944 | ; set current PID for lock input |
4944 | ; set current PID for lock input |
4945 | mov [PID_lock_input], eax |
4945 | mov [PID_lock_input], eax |
4946 | @@: |
4946 | @@: |
4947 | popfd |
4947 | popfd |
4948 | ret |
4948 | ret |
4949 | ;----------------------------------------------------------------------------- |
4949 | ;----------------------------------------------------------------------------- |
4950 | align 4 |
4950 | align 4 |
4951 | .7: |
4951 | .7: |
4952 | mov eax, [PID_lock_input] |
4952 | mov eax, [PID_lock_input] |
4953 | test eax, eax |
4953 | test eax, eax |
4954 | jz @f |
4954 | jz @f |
4955 | ; get current PID |
4955 | ; get current PID |
4956 | mov ebx, [CURRENT_TASK] |
4956 | mov ebx, [CURRENT_TASK] |
4957 | shl ebx, 5 |
4957 | shl ebx, 5 |
4958 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4958 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4959 | ; compare current lock input with current PID |
4959 | ; compare current lock input with current PID |
4960 | cmp ebx, eax |
4960 | cmp ebx, eax |
4961 | jne @f |
4961 | jne @f |
4962 | 4962 | ||
4963 | xor eax, eax |
4963 | xor eax, eax |
4964 | mov [PID_lock_input], eax |
4964 | mov [PID_lock_input], eax |
4965 | @@: |
4965 | @@: |
4966 | ret |
4966 | ret |
4967 | ;----------------------------------------------------------------------------- |
4967 | ;----------------------------------------------------------------------------- |
4968 | uglobal |
4968 | uglobal |
4969 | PID_lock_input dd 0x0 |
4969 | PID_lock_input dd 0x0 |
4970 | endg |
4970 | endg |
4971 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4971 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4972 | ;; 61 sys function. ;; |
4972 | ;; 61 sys function. ;; |
4973 | ;; in eax=61,ebx in [1..3] ;; |
4973 | ;; in eax=61,ebx in [1..3] ;; |
4974 | ;; out eax ;; |
4974 | ;; out eax ;; |
4975 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4975 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4976 | iglobal |
4976 | iglobal |
4977 | align 4 |
4977 | align 4 |
4978 | f61call: |
4978 | f61call: |
4979 | dd sys_gs.1 ; resolution |
4979 | dd sys_gs.1 ; resolution |
4980 | dd sys_gs.2 ; bits per pixel |
4980 | dd sys_gs.2 ; bits per pixel |
4981 | dd sys_gs.3 ; bytes per scanline |
4981 | dd sys_gs.3 ; bytes per scanline |
4982 | endg |
4982 | endg |
4983 | 4983 | ||
4984 | 4984 | ||
4985 | align 4 |
4985 | align 4 |
4986 | 4986 | ||
4987 | sys_gs: ; direct screen access |
4987 | sys_gs: ; direct screen access |
4988 | dec ebx |
4988 | dec ebx |
4989 | cmp ebx, 2 |
4989 | cmp ebx, 2 |
4990 | ja .not_support |
4990 | ja .not_support |
4991 | jmp dword [f61call+ebx*4] |
4991 | jmp dword [f61call+ebx*4] |
4992 | .not_support: |
4992 | .not_support: |
4993 | or [esp+32], dword -1 |
4993 | or [esp+32], dword -1 |
4994 | ret |
4994 | ret |
4995 | 4995 | ||
4996 | 4996 | ||
4997 | .1: ; resolution |
4997 | .1: ; resolution |
4998 | mov eax, [Screen_Max_X] |
4998 | mov eax, [Screen_Max_X] |
4999 | shl eax, 16 |
4999 | shl eax, 16 |
5000 | mov ax, word [Screen_Max_Y] |
5000 | mov ax, word [Screen_Max_Y] |
5001 | add eax, 0x00010001 |
5001 | add eax, 0x00010001 |
5002 | mov [esp+32], eax |
5002 | mov [esp+32], eax |
5003 | ret |
5003 | ret |
5004 | .2: ; bits per pixel |
5004 | .2: ; bits per pixel |
5005 | mov eax, [_display.bpp] |
5005 | mov eax, [_display.bpp] |
5006 | mov [esp+32], eax |
5006 | mov [esp+32], eax |
5007 | ret |
5007 | ret |
5008 | .3: ; bytes per scanline |
5008 | .3: ; bytes per scanline |
5009 | mov eax, [_display.pitch] |
5009 | mov eax, [_display.pitch] |
5010 | mov [esp+32], eax |
5010 | mov [esp+32], eax |
5011 | ret |
5011 | ret |
5012 | 5012 | ||
5013 | align 4 ; system functions |
5013 | align 4 ; system functions |
5014 | 5014 | ||
5015 | syscall_setpixel: ; SetPixel |
5015 | syscall_setpixel: ; SetPixel |
5016 | 5016 | ||
5017 | mov eax, ebx |
5017 | mov eax, ebx |
5018 | mov ebx, ecx |
5018 | mov ebx, ecx |
5019 | mov ecx, edx |
5019 | mov ecx, edx |
5020 | mov edx, [TASK_BASE] |
5020 | mov edx, [TASK_BASE] |
5021 | add eax, [edx-twdw+WDATA.box.left] |
5021 | add eax, [edx-twdw+WDATA.box.left] |
5022 | add ebx, [edx-twdw+WDATA.box.top] |
5022 | add ebx, [edx-twdw+WDATA.box.top] |
5023 | mov edi, [current_slot] |
5023 | mov edi, [current_slot] |
5024 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5024 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5025 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5025 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5026 | xor edi, edi ; no force |
5026 | xor edi, edi ; no force |
5027 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5027 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5028 | ; jmp [putpixel] |
5028 | ; jmp [putpixel] |
5029 | jmp __sys_putpixel |
5029 | jmp __sys_putpixel |
5030 | 5030 | ||
5031 | align 4 |
5031 | align 4 |
5032 | 5032 | ||
5033 | syscall_writetext: ; WriteText |
5033 | syscall_writetext: ; WriteText |
5034 | 5034 | ||
5035 | mov eax, [TASK_BASE] |
5035 | mov eax, [TASK_BASE] |
5036 | mov ebp, [eax-twdw+WDATA.box.left] |
5036 | mov ebp, [eax-twdw+WDATA.box.left] |
5037 | push esi |
5037 | push esi |
5038 | mov esi, [current_slot] |
5038 | mov esi, [current_slot] |
5039 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5039 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5040 | shl ebp, 16 |
5040 | shl ebp, 16 |
5041 | add ebp, [eax-twdw+WDATA.box.top] |
5041 | add ebp, [eax-twdw+WDATA.box.top] |
5042 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5042 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5043 | pop esi |
5043 | pop esi |
5044 | test ecx, 0x08000000 ; redirect the output to the user area |
5044 | test ecx, 0x08000000 ; redirect the output to the user area |
5045 | jnz @f |
5045 | jnz @f |
5046 | add ebx, ebp |
5046 | add ebx, ebp |
5047 | align 4 |
5047 | align 4 |
5048 | @@: |
5048 | @@: |
5049 | mov eax, edi |
5049 | mov eax, edi |
5050 | test ecx, 0x08000000 ; redirect the output to the user area |
5050 | test ecx, 0x08000000 ; redirect the output to the user area |
5051 | jnz dtext |
5051 | jnz dtext |
5052 | xor edi, edi |
5052 | xor edi, edi |
5053 | jmp dtext |
5053 | jmp dtext |
5054 | 5054 | ||
5055 | align 4 |
5055 | align 4 |
5056 | 5056 | ||
5057 | syscall_openramdiskfile: ; OpenRamdiskFile |
5057 | syscall_openramdiskfile: ; OpenRamdiskFile |
5058 | 5058 | ||
5059 | mov eax, ebx |
5059 | mov eax, ebx |
5060 | mov ebx, ecx |
5060 | mov ebx, ecx |
5061 | mov ecx, edx |
5061 | mov ecx, edx |
5062 | mov edx, esi |
5062 | mov edx, esi |
5063 | mov esi, 12 |
5063 | mov esi, 12 |
5064 | call fileread |
5064 | call fileread |
5065 | mov [esp+32], eax |
5065 | mov [esp+32], eax |
5066 | ret |
5066 | ret |
5067 | 5067 | ||
5068 | align 4 |
5068 | align 4 |
5069 | 5069 | ||
5070 | syscall_drawrect: ; DrawRect |
5070 | syscall_drawrect: ; DrawRect |
5071 | 5071 | ||
5072 | mov edi, edx ; color + gradient |
5072 | mov edi, edx ; color + gradient |
5073 | and edi, 0x80FFFFFF |
5073 | and edi, 0x80FFFFFF |
5074 | test bx, bx ; x.size |
5074 | test bx, bx ; x.size |
5075 | je .drectr |
5075 | je .drectr |
5076 | test cx, cx ; y.size |
5076 | test cx, cx ; y.size |
5077 | je .drectr |
5077 | je .drectr |
5078 | 5078 | ||
5079 | mov eax, ebx ; bad idea |
5079 | mov eax, ebx ; bad idea |
5080 | mov ebx, ecx |
5080 | mov ebx, ecx |
5081 | 5081 | ||
5082 | movzx ecx, ax ; ecx - x.size |
5082 | movzx ecx, ax ; ecx - x.size |
5083 | shr eax, 16 ; eax - x.coord |
5083 | shr eax, 16 ; eax - x.coord |
5084 | movzx edx, bx ; edx - y.size |
5084 | movzx edx, bx ; edx - y.size |
5085 | shr ebx, 16 ; ebx - y.coord |
5085 | shr ebx, 16 ; ebx - y.coord |
5086 | mov esi, [current_slot] |
5086 | mov esi, [current_slot] |
5087 | 5087 | ||
5088 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5088 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5089 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5089 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5090 | add ecx, eax |
5090 | add ecx, eax |
5091 | add edx, ebx |
5091 | add edx, ebx |
5092 | ; jmp [drawbar] |
5092 | ; jmp [drawbar] |
5093 | jmp vesa20_drawbar |
5093 | jmp vesa20_drawbar |
5094 | .drectr: |
5094 | .drectr: |
5095 | ret |
5095 | ret |
5096 | 5096 | ||
5097 | align 4 |
5097 | align 4 |
5098 | syscall_getscreensize: ; GetScreenSize |
5098 | syscall_getscreensize: ; GetScreenSize |
5099 | mov ax, word [Screen_Max_X] |
5099 | mov ax, word [Screen_Max_X] |
5100 | shl eax, 16 |
5100 | shl eax, 16 |
5101 | mov ax, word [Screen_Max_Y] |
5101 | mov ax, word [Screen_Max_Y] |
5102 | mov [esp + 32], eax |
5102 | mov [esp + 32], eax |
5103 | ret |
5103 | ret |
5104 | 5104 | ||
5105 | align 4 |
5105 | align 4 |
5106 | 5106 | ||
5107 | syscall_cdaudio: ; CD |
5107 | syscall_cdaudio: ; CD |
5108 | 5108 | ||
5109 | cmp ebx, 4 |
5109 | cmp ebx, 4 |
5110 | jb .audio |
5110 | jb .audio |
5111 | jz .eject |
5111 | jz .eject |
5112 | cmp ebx, 5 |
5112 | cmp ebx, 5 |
5113 | jnz .ret |
5113 | jnz .ret |
5114 | .load: |
5114 | .load: |
5115 | call .reserve |
5115 | call .reserve |
5116 | call LoadMedium |
5116 | call LoadMedium |
5117 | ;call .free |
5117 | ;call .free |
5118 | jmp .free |
5118 | jmp .free |
5119 | ; ret |
5119 | ; ret |
5120 | .eject: |
5120 | .eject: |
5121 | call .reserve |
5121 | call .reserve |
5122 | call clear_CD_cache |
5122 | call clear_CD_cache |
5123 | call allow_medium_removal |
5123 | call allow_medium_removal |
5124 | call EjectMedium |
5124 | call EjectMedium |
5125 | ; call .free |
5125 | ; call .free |
5126 | jmp .free |
5126 | jmp .free |
5127 | ; ret |
5127 | ; ret |
5128 | .audio: |
5128 | .audio: |
5129 | call sys_cd_audio |
5129 | call sys_cd_audio |
5130 | mov [esp+36-4], eax |
5130 | mov [esp+36-4], eax |
5131 | .ret: |
5131 | .ret: |
5132 | ret |
5132 | ret |
5133 | 5133 | ||
5134 | .reserve: |
5134 | .reserve: |
5135 | call reserve_cd |
5135 | call reserve_cd |
5136 | mov eax, ecx |
5136 | mov eax, ecx |
5137 | shr eax, 1 |
5137 | shr eax, 1 |
5138 | and eax, 1 |
5138 | and eax, 1 |
5139 | inc eax |
5139 | inc eax |
5140 | mov [ChannelNumber], ax |
5140 | mov [ChannelNumber], ax |
5141 | mov eax, ecx |
5141 | mov eax, ecx |
5142 | and eax, 1 |
5142 | and eax, 1 |
5143 | mov [DiskNumber], al |
5143 | mov [DiskNumber], al |
5144 | call reserve_cd_channel |
5144 | call reserve_cd_channel |
5145 | and ebx, 3 |
5145 | and ebx, 3 |
5146 | inc ebx |
5146 | inc ebx |
5147 | mov [cdpos], ebx |
5147 | mov [cdpos], ebx |
5148 | add ebx, ebx |
5148 | add ebx, ebx |
5149 | mov cl, 8 |
5149 | mov cl, 8 |
5150 | sub cl, bl |
5150 | sub cl, bl |
5151 | mov al, [DRIVE_DATA+1] |
5151 | mov al, [DRIVE_DATA+1] |
5152 | shr al, cl |
5152 | shr al, cl |
5153 | test al, 2 |
5153 | test al, 2 |
5154 | jz .free;.err |
5154 | jz .free;.err |
5155 | ret |
5155 | ret |
5156 | .free: |
5156 | .free: |
5157 | call free_cd_channel |
5157 | call free_cd_channel |
5158 | and [cd_status], 0 |
5158 | and [cd_status], 0 |
5159 | ret |
5159 | ret |
5160 | .err: |
5160 | .err: |
5161 | call .free |
5161 | call .free |
5162 | ; pop eax |
5162 | ; pop eax |
5163 | ret |
5163 | ret |
5164 | ;----------------------------------------------------------------------------- |
5164 | ;----------------------------------------------------------------------------- |
5165 | align 4 |
5165 | align 4 |
5166 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5166 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5167 | cmp ebx, [Screen_Max_X] |
5167 | cmp ebx, [Screen_Max_X] |
5168 | jbe @f |
5168 | jbe @f |
5169 | cmp ecx, [Screen_Max_Y] |
5169 | cmp ecx, [Screen_Max_Y] |
5170 | jbe @f |
5170 | jbe @f |
5171 | xor eax, eax |
5171 | xor eax, eax |
5172 | jmp .store |
5172 | jmp .store |
5173 | ;-------------------------------------- |
5173 | ;-------------------------------------- |
5174 | align 4 |
5174 | align 4 |
5175 | @@: |
5175 | @@: |
5176 | mov eax, [d_width_calc_area + ecx*4] |
5176 | mov eax, [d_width_calc_area + ecx*4] |
5177 | add eax, [_WinMapAddress] |
5177 | add eax, [_WinMapAddress] |
5178 | movzx eax, byte[eax+ebx] ; get value for current point |
5178 | movzx eax, byte[eax+ebx] ; get value for current point |
5179 | ;-------------------------------------- |
5179 | ;-------------------------------------- |
5180 | align 4 |
5180 | align 4 |
5181 | .store: |
5181 | .store: |
5182 | mov [esp + 32], eax |
5182 | mov [esp + 32], eax |
5183 | ret |
5183 | ret |
5184 | ;----------------------------------------------------------------------------- |
5184 | ;----------------------------------------------------------------------------- |
5185 | align 4 |
5185 | align 4 |
5186 | syscall_getpixel: ; GetPixel |
5186 | syscall_getpixel: ; GetPixel |
5187 | mov ecx, [Screen_Max_X] |
5187 | mov ecx, [Screen_Max_X] |
5188 | inc ecx |
5188 | inc ecx |
5189 | xor edx, edx |
5189 | xor edx, edx |
5190 | mov eax, ebx |
5190 | mov eax, ebx |
5191 | div ecx |
5191 | div ecx |
5192 | mov ebx, edx |
5192 | mov ebx, edx |
5193 | xchg eax, ebx |
5193 | xchg eax, ebx |
5194 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5194 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5195 | call dword [GETPIXEL]; eax - x, ebx - y |
5195 | call dword [GETPIXEL]; eax - x, ebx - y |
5196 | mov [esp + 32], ecx |
5196 | mov [esp + 32], ecx |
5197 | ret |
5197 | ret |
5198 | ;----------------------------------------------------------------------------- |
5198 | ;----------------------------------------------------------------------------- |
5199 | align 4 |
5199 | align 4 |
5200 | syscall_getarea: |
5200 | syscall_getarea: |
5201 | ;eax = 36 |
5201 | ;eax = 36 |
5202 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5202 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5203 | ;ecx = [size x]*65536 + [size y] |
5203 | ;ecx = [size x]*65536 + [size y] |
5204 | ;edx = [start x]*65536 + [start y] |
5204 | ;edx = [start x]*65536 + [start y] |
5205 | pushad |
5205 | pushad |
5206 | mov edi, ebx |
5206 | mov edi, ebx |
5207 | mov eax, edx |
5207 | mov eax, edx |
5208 | shr eax, 16 |
5208 | shr eax, 16 |
5209 | mov ebx, edx |
5209 | mov ebx, edx |
5210 | and ebx, 0xffff |
5210 | and ebx, 0xffff |
5211 | dec eax |
5211 | dec eax |
5212 | dec ebx |
5212 | dec ebx |
5213 | ; eax - x, ebx - y |
5213 | ; eax - x, ebx - y |
5214 | mov edx, ecx |
5214 | mov edx, ecx |
5215 | 5215 | ||
5216 | shr ecx, 16 |
5216 | shr ecx, 16 |
5217 | and edx, 0xffff |
5217 | and edx, 0xffff |
5218 | mov esi, ecx |
5218 | mov esi, ecx |
5219 | ; ecx - size x, edx - size y |
5219 | ; ecx - size x, edx - size y |
5220 | 5220 | ||
5221 | mov ebp, edx |
5221 | mov ebp, edx |
5222 | dec ebp |
5222 | dec ebp |
5223 | lea ebp, [ebp*3] |
5223 | lea ebp, [ebp*3] |
5224 | 5224 | ||
5225 | imul ebp, esi |
5225 | imul ebp, esi |
5226 | 5226 | ||
5227 | mov esi, ecx |
5227 | mov esi, ecx |
5228 | dec esi |
5228 | dec esi |
5229 | lea esi, [esi*3] |
5229 | lea esi, [esi*3] |
5230 | 5230 | ||
5231 | add ebp, esi |
5231 | add ebp, esi |
5232 | add ebp, edi |
5232 | add ebp, edi |
5233 | 5233 | ||
5234 | add ebx, edx |
5234 | add ebx, edx |
5235 | ;-------------------------------------- |
5235 | ;-------------------------------------- |
5236 | align 4 |
5236 | align 4 |
5237 | .start_y: |
5237 | .start_y: |
5238 | push ecx edx |
5238 | push ecx edx |
5239 | ;-------------------------------------- |
5239 | ;-------------------------------------- |
5240 | align 4 |
5240 | align 4 |
5241 | .start_x: |
5241 | .start_x: |
5242 | push eax ebx ecx |
5242 | push eax ebx ecx |
5243 | add eax, ecx |
5243 | add eax, ecx |
5244 | 5244 | ||
5245 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5245 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5246 | call dword [GETPIXEL]; eax - x, ebx - y |
5246 | call dword [GETPIXEL]; eax - x, ebx - y |
5247 | 5247 | ||
5248 | mov [ebp], cx |
5248 | mov [ebp], cx |
5249 | shr ecx, 16 |
5249 | shr ecx, 16 |
5250 | mov [ebp+2], cl |
5250 | mov [ebp+2], cl |
5251 | 5251 | ||
5252 | pop ecx ebx eax |
5252 | pop ecx ebx eax |
5253 | sub ebp, 3 |
5253 | sub ebp, 3 |
5254 | dec ecx |
5254 | dec ecx |
5255 | jnz .start_x |
5255 | jnz .start_x |
5256 | pop edx ecx |
5256 | pop edx ecx |
5257 | dec ebx |
5257 | dec ebx |
5258 | dec edx |
5258 | dec edx |
5259 | jnz .start_y |
5259 | jnz .start_y |
5260 | popad |
5260 | popad |
5261 | ret |
5261 | ret |
5262 | ;----------------------------------------------------------------------------- |
5262 | ;----------------------------------------------------------------------------- |
5263 | align 4 |
5263 | align 4 |
5264 | syscall_putarea_backgr: |
5264 | syscall_putarea_backgr: |
5265 | ;eax = 25 |
5265 | ;eax = 25 |
5266 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5266 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5267 | ;ecx = [size x]*65536 + [size y] |
5267 | ;ecx = [size x]*65536 + [size y] |
5268 | ;edx = [start x]*65536 + [start y] |
5268 | ;edx = [start x]*65536 + [start y] |
5269 | pushad |
5269 | pushad |
5270 | mov edi, ebx |
5270 | mov edi, ebx |
5271 | mov eax, edx |
5271 | mov eax, edx |
5272 | shr eax, 16 |
5272 | shr eax, 16 |
5273 | mov ebx, edx |
5273 | mov ebx, edx |
5274 | and ebx, 0xffff |
5274 | and ebx, 0xffff |
5275 | dec eax |
5275 | dec eax |
5276 | dec ebx |
5276 | dec ebx |
5277 | ; eax - x, ebx - y |
5277 | ; eax - x, ebx - y |
5278 | mov edx, ecx |
5278 | mov edx, ecx |
5279 | shr ecx, 16 |
5279 | shr ecx, 16 |
5280 | and edx, 0xffff |
5280 | and edx, 0xffff |
5281 | mov esi, ecx |
5281 | mov esi, ecx |
5282 | ; ecx - size x, edx - size y |
5282 | ; ecx - size x, edx - size y |
5283 | mov ebp, edx |
5283 | mov ebp, edx |
5284 | dec ebp |
5284 | dec ebp |
5285 | shl ebp, 2 |
5285 | shl ebp, 2 |
5286 | 5286 | ||
5287 | imul ebp, esi |
5287 | imul ebp, esi |
5288 | 5288 | ||
5289 | mov esi, ecx |
5289 | mov esi, ecx |
5290 | dec esi |
5290 | dec esi |
5291 | shl esi, 2 |
5291 | shl esi, 2 |
5292 | 5292 | ||
5293 | add ebp, esi |
5293 | add ebp, esi |
5294 | add ebp, edi |
5294 | add ebp, edi |
5295 | 5295 | ||
5296 | add ebx, edx |
5296 | add ebx, edx |
5297 | ;-------------------------------------- |
5297 | ;-------------------------------------- |
5298 | align 4 |
5298 | align 4 |
5299 | .start_y: |
5299 | .start_y: |
5300 | push ecx edx |
5300 | push ecx edx |
5301 | ;-------------------------------------- |
5301 | ;-------------------------------------- |
5302 | align 4 |
5302 | align 4 |
5303 | .start_x: |
5303 | .start_x: |
5304 | push eax ecx |
5304 | push eax ecx |
5305 | add eax, ecx |
5305 | add eax, ecx |
5306 | 5306 | ||
5307 | mov ecx, [ebp] |
5307 | mov ecx, [ebp] |
5308 | rol ecx, 8 |
5308 | rol ecx, 8 |
5309 | test cl, cl ; transparensy = 0 |
5309 | test cl, cl ; transparensy = 0 |
5310 | jz .no_put |
5310 | jz .no_put |
5311 | 5311 | ||
5312 | xor cl, cl |
5312 | xor cl, cl |
5313 | ror ecx, 8 |
5313 | ror ecx, 8 |
5314 | 5314 | ||
5315 | pushad |
5315 | pushad |
5316 | mov edx, [d_width_calc_area + ebx*4] |
5316 | mov edx, [d_width_calc_area + ebx*4] |
5317 | add edx, [_WinMapAddress] |
5317 | add edx, [_WinMapAddress] |
5318 | movzx edx, byte [eax+edx] |
5318 | movzx edx, byte [eax+edx] |
5319 | cmp dl, byte 1 |
5319 | cmp dl, byte 1 |
5320 | jne @f |
5320 | jne @f |
5321 | 5321 | ||
5322 | call dword [PUTPIXEL]; eax - x, ebx - y |
5322 | call dword [PUTPIXEL]; eax - x, ebx - y |
5323 | ;-------------------------------------- |
5323 | ;-------------------------------------- |
5324 | align 4 |
5324 | align 4 |
5325 | @@: |
5325 | @@: |
5326 | popad |
5326 | popad |
5327 | ;-------------------------------------- |
5327 | ;-------------------------------------- |
5328 | align 4 |
5328 | align 4 |
5329 | .no_put: |
5329 | .no_put: |
5330 | pop ecx eax |
5330 | pop ecx eax |
5331 | 5331 | ||
5332 | sub ebp, 4 |
5332 | sub ebp, 4 |
5333 | dec ecx |
5333 | dec ecx |
5334 | jnz .start_x |
5334 | jnz .start_x |
5335 | 5335 | ||
5336 | pop edx ecx |
5336 | pop edx ecx |
5337 | dec ebx |
5337 | dec ebx |
5338 | dec edx |
5338 | dec edx |
5339 | jnz .start_y |
5339 | jnz .start_y |
5340 | 5340 | ||
5341 | popad |
5341 | popad |
5342 | ret |
5342 | ret |
5343 | ;----------------------------------------------------------------------------- |
5343 | ;----------------------------------------------------------------------------- |
5344 | align 4 |
5344 | align 4 |
5345 | syscall_drawline: ; DrawLine |
5345 | syscall_drawline: ; DrawLine |
5346 | 5346 | ||
5347 | mov edi, [TASK_BASE] |
5347 | mov edi, [TASK_BASE] |
5348 | movzx eax, word[edi-twdw+WDATA.box.left] |
5348 | movzx eax, word[edi-twdw+WDATA.box.left] |
5349 | mov ebp, eax |
5349 | mov ebp, eax |
5350 | mov esi, [current_slot] |
5350 | mov esi, [current_slot] |
5351 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5351 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5352 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5352 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5353 | add ebp, ebx |
5353 | add ebp, ebx |
5354 | shl eax, 16 |
5354 | shl eax, 16 |
5355 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5355 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5356 | add eax, ebp |
5356 | add eax, ebp |
5357 | mov ebp, ebx |
5357 | mov ebp, ebx |
5358 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5358 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5359 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5359 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5360 | add ebp, ecx |
5360 | add ebp, ecx |
5361 | shl ebx, 16 |
5361 | shl ebx, 16 |
5362 | xor edi, edi |
5362 | xor edi, edi |
5363 | add ebx, ebp |
5363 | add ebx, ebp |
5364 | mov ecx, edx |
5364 | mov ecx, edx |
5365 | ; jmp [draw_line] |
5365 | ; jmp [draw_line] |
5366 | jmp __sys_draw_line |
5366 | jmp __sys_draw_line |
5367 | 5367 | ||
5368 | 5368 | ||
5369 | align 4 |
5369 | align 4 |
5370 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5370 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5371 | 5371 | ||
5372 | call r_f_port_area |
5372 | call r_f_port_area |
5373 | mov [esp+32], eax |
5373 | mov [esp+32], eax |
5374 | ret |
5374 | ret |
5375 | 5375 | ||
5376 | align 4 |
5376 | align 4 |
5377 | syscall_threads: ; CreateThreads |
5377 | syscall_threads: ; CreateThreads |
5378 | ; eax=1 create thread |
5378 | ; eax=1 create thread |
5379 | ; |
5379 | ; |
5380 | ; ebx=thread start |
5380 | ; ebx=thread start |
5381 | ; ecx=thread stack value |
5381 | ; ecx=thread stack value |
5382 | ; |
5382 | ; |
5383 | ; on return : eax = pid |
5383 | ; on return : eax = pid |
5384 | 5384 | ||
5385 | call new_sys_threads |
5385 | call new_sys_threads |
5386 | 5386 | ||
5387 | mov [esp+32], eax |
5387 | mov [esp+32], eax |
5388 | ret |
5388 | ret |
5389 | 5389 | ||
5390 | align 4 |
5390 | align 4 |
5391 | 5391 | ||
5392 | paleholder: |
5392 | paleholder: |
5393 | ret |
5393 | ret |
5394 | ;------------------------------------------------------------------------------ |
5394 | ;------------------------------------------------------------------------------ |
5395 | align 4 |
5395 | align 4 |
5396 | calculate_fast_getting_offset_for_WinMapAddress: |
5396 | calculate_fast_getting_offset_for_WinMapAddress: |
5397 | ; calculate data area for fast getting offset to _WinMapAddress |
5397 | ; calculate data area for fast getting offset to _WinMapAddress |
5398 | xor eax, eax |
5398 | xor eax, eax |
5399 | mov ecx, [_display.height] |
5399 | mov ecx, [_display.height] |
5400 | inc ecx |
5400 | inc ecx |
5401 | mov edi, d_width_calc_area |
5401 | mov edi, d_width_calc_area |
5402 | cld |
5402 | cld |
5403 | @@: |
5403 | @@: |
5404 | stosd |
5404 | stosd |
5405 | add eax, [_display.width] |
5405 | add eax, [_display.width] |
5406 | dec ecx |
5406 | dec ecx |
5407 | jnz @r |
5407 | jnz @r |
5408 | ret |
5408 | ret |
5409 | ;------------------------------------------------------------------------------ |
5409 | ;------------------------------------------------------------------------------ |
5410 | align 4 |
5410 | align 4 |
5411 | calculate_fast_getting_offset_for_LFB: |
5411 | calculate_fast_getting_offset_for_LFB: |
5412 | ; calculate data area for fast getting offset to LFB |
5412 | ; calculate data area for fast getting offset to LFB |
5413 | xor eax, eax |
5413 | xor eax, eax |
5414 | mov ecx, [_display.height] |
5414 | mov ecx, [_display.height] |
5415 | inc ecx |
5415 | inc ecx |
5416 | mov edi, BPSLine_calc_area |
5416 | mov edi, BPSLine_calc_area |
5417 | cld |
5417 | cld |
5418 | @@: |
5418 | @@: |
5419 | stosd |
5419 | stosd |
5420 | add eax, [_display.pitch] |
5420 | add eax, [_display.pitch] |
5421 | dec ecx |
5421 | dec ecx |
5422 | jnz @r |
5422 | jnz @r |
5423 | ret |
5423 | ret |
5424 | ;------------------------------------------------------------------------------ |
5424 | ;------------------------------------------------------------------------------ |
5425 | align 4 |
5425 | align 4 |
5426 | set_screen: |
5426 | set_screen: |
5427 | ; in: |
5427 | ; in: |
5428 | ; eax - new Screen_Max_X |
5428 | ; eax - new Screen_Max_X |
5429 | ; ecx - new BytesPerScanLine |
5429 | ; ecx - new BytesPerScanLine |
5430 | ; edx - new Screen_Max_Y |
5430 | ; edx - new Screen_Max_Y |
5431 | cmp eax, [Screen_Max_X] |
5431 | cmp eax, [Screen_Max_X] |
5432 | jne .set |
5432 | jne .set |
5433 | 5433 | ||
5434 | cmp edx, [Screen_Max_Y] |
5434 | cmp edx, [Screen_Max_Y] |
5435 | jne .set |
5435 | jne .set |
5436 | ret |
5436 | ret |
5437 | .set: |
5437 | .set: |
5438 | pushfd |
5438 | pushfd |
5439 | cli |
5439 | cli |
5440 | 5440 | ||
5441 | mov [Screen_Max_X], eax |
5441 | mov [Screen_Max_X], eax |
5442 | mov [Screen_Max_Y], edx |
5442 | mov [Screen_Max_Y], edx |
5443 | mov [_display.pitch], ecx |
5443 | mov [_display.pitch], ecx |
5444 | 5444 | ||
5445 | mov [screen_workarea.right], eax |
5445 | mov [screen_workarea.right], eax |
5446 | mov [screen_workarea.bottom], edx |
5446 | mov [screen_workarea.bottom], edx |
5447 | 5447 | ||
5448 | push ebx |
5448 | push ebx |
5449 | push esi |
5449 | push esi |
5450 | push edi |
5450 | push edi |
5451 | 5451 | ||
5452 | pushad |
5452 | pushad |
5453 | 5453 | ||
5454 | cmp [do_not_touch_winmap], 1 |
5454 | cmp [do_not_touch_winmap], 1 |
5455 | je @f |
5455 | je @f |
5456 | 5456 | ||
5457 | stdcall kernel_free, [_WinMapAddress] |
5457 | stdcall kernel_free, [_WinMapAddress] |
5458 | 5458 | ||
5459 | mov eax, [_display.width] |
5459 | mov eax, [_display.width] |
5460 | mul [_display.height] |
5460 | mul [_display.height] |
5461 | mov [_WinMapSize], eax |
5461 | mov [_WinMapSize], eax |
5462 | 5462 | ||
5463 | stdcall kernel_alloc, eax |
5463 | stdcall kernel_alloc, eax |
5464 | mov [_WinMapAddress], eax |
5464 | mov [_WinMapAddress], eax |
5465 | test eax, eax |
5465 | test eax, eax |
5466 | jz .epic_fail |
5466 | jz .epic_fail |
5467 | ; store for f.18.24 |
5467 | ; store for f.18.24 |
5468 | mov eax, [_display.width] |
5468 | mov eax, [_display.width] |
5469 | mov [display_width_standard], eax |
5469 | mov [display_width_standard], eax |
5470 | 5470 | ||
5471 | mov eax, [_display.height] |
5471 | mov eax, [_display.height] |
5472 | mov [display_height_standard], eax |
5472 | mov [display_height_standard], eax |
5473 | @@: |
5473 | @@: |
5474 | call calculate_fast_getting_offset_for_WinMapAddress |
5474 | call calculate_fast_getting_offset_for_WinMapAddress |
5475 | ; for Qemu or non standart video cards |
5475 | ; for Qemu or non standart video cards |
5476 | ; Unfortunately [BytesPerScanLine] does not always |
5476 | ; Unfortunately [BytesPerScanLine] does not always |
5477 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5477 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5478 | call calculate_fast_getting_offset_for_LFB |
5478 | call calculate_fast_getting_offset_for_LFB |
5479 | popad |
5479 | popad |
5480 | 5480 | ||
5481 | call repos_windows |
5481 | call repos_windows |
5482 | xor eax, eax |
5482 | xor eax, eax |
5483 | xor ebx, ebx |
5483 | xor ebx, ebx |
5484 | mov ecx, [Screen_Max_X] |
5484 | mov ecx, [Screen_Max_X] |
5485 | mov edx, [Screen_Max_Y] |
5485 | mov edx, [Screen_Max_Y] |
5486 | call calculatescreen |
5486 | call calculatescreen |
5487 | pop edi |
5487 | pop edi |
5488 | pop esi |
5488 | pop esi |
5489 | pop ebx |
5489 | pop ebx |
5490 | 5490 | ||
5491 | popfd |
5491 | popfd |
5492 | ret |
5492 | ret |
5493 | 5493 | ||
5494 | .epic_fail: |
5494 | .epic_fail: |
5495 | hlt ; Houston, we've had a problem |
5495 | hlt ; Houston, we've had a problem |
5496 | 5496 | ||
5497 | ; --------------- APM --------------------- |
5497 | ; --------------- APM --------------------- |
5498 | uglobal |
5498 | uglobal |
5499 | apm_entry dp 0 |
5499 | apm_entry dp 0 |
5500 | apm_vf dd 0 |
5500 | apm_vf dd 0 |
5501 | endg |
5501 | endg |
5502 | 5502 | ||
5503 | align 4 |
5503 | align 4 |
5504 | sys_apm: |
5504 | sys_apm: |
5505 | xor eax, eax |
5505 | xor eax, eax |
5506 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5506 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5507 | jne @f |
5507 | jne @f |
5508 | inc eax |
5508 | inc eax |
5509 | or dword [esp + 44], eax ; error |
5509 | or dword [esp + 44], eax ; error |
5510 | add eax, 7 |
5510 | add eax, 7 |
5511 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5511 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5512 | ret |
5512 | ret |
5513 | 5513 | ||
5514 | @@: |
5514 | @@: |
5515 | ; xchg eax, ecx |
5515 | ; xchg eax, ecx |
5516 | ; xchg ebx, ecx |
5516 | ; xchg ebx, ecx |
5517 | 5517 | ||
5518 | cmp dx, 3 |
5518 | cmp dx, 3 |
5519 | ja @f |
5519 | ja @f |
5520 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5520 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5521 | mov eax, [apm_vf] |
5521 | mov eax, [apm_vf] |
5522 | mov [esp + 32], eax |
5522 | mov [esp + 32], eax |
5523 | shr eax, 16 |
5523 | shr eax, 16 |
5524 | mov [esp + 28], eax |
5524 | mov [esp + 28], eax |
5525 | ret |
5525 | ret |
5526 | 5526 | ||
5527 | @@: |
5527 | @@: |
5528 | 5528 | ||
5529 | mov esi, [master_tab+(OS_BASE shr 20)] |
5529 | mov esi, [master_tab+(OS_BASE shr 20)] |
5530 | xchg [master_tab], esi |
5530 | xchg [master_tab], esi |
5531 | push esi |
5531 | push esi |
5532 | mov edi, cr3 |
5532 | mov edi, cr3 |
5533 | mov cr3, edi ;flush TLB |
5533 | mov cr3, edi ;flush TLB |
5534 | 5534 | ||
5535 | call pword [apm_entry] ;call APM BIOS |
5535 | call pword [apm_entry] ;call APM BIOS |
5536 | 5536 | ||
5537 | xchg eax, [esp] |
5537 | xchg eax, [esp] |
5538 | mov [master_tab], eax |
5538 | mov [master_tab], eax |
5539 | mov eax, cr3 |
5539 | mov eax, cr3 |
5540 | mov cr3, eax |
5540 | mov cr3, eax |
5541 | pop eax |
5541 | pop eax |
5542 | 5542 | ||
5543 | mov [esp + 4 ], edi |
5543 | mov [esp + 4 ], edi |
5544 | mov [esp + 8], esi |
5544 | mov [esp + 8], esi |
5545 | mov [esp + 20], ebx |
5545 | mov [esp + 20], ebx |
5546 | mov [esp + 24], edx |
5546 | mov [esp + 24], edx |
5547 | mov [esp + 28], ecx |
5547 | mov [esp + 28], ecx |
5548 | mov [esp + 32], eax |
5548 | mov [esp + 32], eax |
5549 | setc al |
5549 | setc al |
5550 | and [esp + 44], byte 0xfe |
5550 | and [esp + 44], byte 0xfe |
5551 | or [esp + 44], al |
5551 | or [esp + 44], al |
5552 | ret |
5552 | ret |
5553 | ; ----------------------------------------- |
5553 | ; ----------------------------------------- |
5554 | 5554 | ||
5555 | align 4 |
5555 | align 4 |
5556 | 5556 | ||
5557 | undefined_syscall: ; Undefined system call |
5557 | undefined_syscall: ; Undefined system call |
5558 | mov [esp + 32], dword -1 |
5558 | mov [esp + 32], dword -1 |
5559 | ret |
5559 | ret |
5560 | 5560 | ||
5561 | align 4 |
5561 | align 4 |
5562 | system_shutdown: ; shut down the system |
5562 | system_shutdown: ; shut down the system |
5563 | 5563 | ||
5564 | cmp byte [BOOT_VAR+0x9030], 1 |
5564 | cmp byte [BOOT_VAR+0x9030], 1 |
5565 | jne @F |
5565 | jne @F |
5566 | ret |
5566 | ret |
5567 | @@: |
5567 | @@: |
5568 | call stop_all_services |
5568 | call stop_all_services |
5569 | movi eax, 3 |
5569 | movi eax, 3 |
5570 | call sys_cd_audio |
5570 | call sys_cd_audio |
5571 | 5571 | ||
5572 | yes_shutdown_param: |
5572 | yes_shutdown_param: |
5573 | cli |
5573 | cli |
5574 | 5574 | ||
5575 | if ~ defined extended_primary_loader |
5575 | if ~ defined extended_primary_loader |
5576 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5576 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5577 | movi esi, 12 |
5577 | movi esi, 12 |
5578 | xor ebx, ebx |
5578 | xor ebx, ebx |
5579 | or ecx, -1 |
5579 | or ecx, -1 |
5580 | mov edx, OS_BASE+0x70000 |
5580 | mov edx, OS_BASE+0x70000 |
5581 | call fileread |
5581 | call fileread |
5582 | 5582 | ||
5583 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5583 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5584 | mov edi, OS_BASE+0x40000 |
5584 | mov edi, OS_BASE+0x40000 |
5585 | mov ecx, 1000 |
5585 | mov ecx, 1000 |
5586 | rep movsb |
5586 | rep movsb |
5587 | end if |
5587 | end if |
5588 | 5588 | ||
5589 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5589 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5590 | mov edi, OS_BASE |
5590 | mov edi, OS_BASE |
5591 | mov ecx, 0x10000/4 |
5591 | mov ecx, 0x10000/4 |
5592 | cld |
5592 | cld |
5593 | rep movsd |
5593 | rep movsd |
5594 | 5594 | ||
5595 | call restorefatchain |
5595 | call restorefatchain |
5596 | 5596 | ||
5597 | call IRQ_mask_all |
5597 | call IRQ_mask_all |
5598 | 5598 | ||
5599 | if 0 |
5599 | if 0 |
5600 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5600 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5601 | mov word [OS_BASE+0x467+2], 0x1000 |
5601 | mov word [OS_BASE+0x467+2], 0x1000 |
5602 | 5602 | ||
5603 | mov al, 0x0F |
5603 | mov al, 0x0F |
5604 | out 0x70, al |
5604 | out 0x70, al |
5605 | mov al, 0x05 |
5605 | mov al, 0x05 |
5606 | out 0x71, al |
5606 | out 0x71, al |
5607 | 5607 | ||
5608 | mov al, 0xFE |
5608 | mov al, 0xFE |
5609 | out 0x64, al |
5609 | out 0x64, al |
5610 | 5610 | ||
5611 | hlt |
5611 | hlt |
5612 | jmp $-1 |
5612 | jmp $-1 |
5613 | 5613 | ||
5614 | else |
5614 | else |
5615 | cmp byte [OS_BASE + 0x9030], 2 |
5615 | cmp byte [OS_BASE + 0x9030], 2 |
5616 | jnz no_acpi_power_off |
5616 | jnz no_acpi_power_off |
5617 | 5617 | ||
5618 | ; scan for RSDP |
5618 | ; scan for RSDP |
5619 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5619 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5620 | movzx eax, word [OS_BASE + 0x40E] |
5620 | movzx eax, word [OS_BASE + 0x40E] |
5621 | shl eax, 4 |
5621 | shl eax, 4 |
5622 | jz @f |
5622 | jz @f |
5623 | mov ecx, 1024/16 |
5623 | mov ecx, 1024/16 |
5624 | call scan_rsdp |
5624 | call scan_rsdp |
5625 | jnc .rsdp_found |
5625 | jnc .rsdp_found |
5626 | @@: |
5626 | @@: |
5627 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5627 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5628 | mov eax, 0xE0000 |
5628 | mov eax, 0xE0000 |
5629 | mov ecx, 0x2000 |
5629 | mov ecx, 0x2000 |
5630 | call scan_rsdp |
5630 | call scan_rsdp |
5631 | jc no_acpi_power_off |
5631 | jc no_acpi_power_off |
5632 | .rsdp_found: |
5632 | .rsdp_found: |
5633 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5633 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5634 | mov ebp, [ipc_tmp] |
5634 | mov ebp, [ipc_tmp] |
5635 | stdcall map_page, ebp, esi, PG_MAP |
5635 | stdcall map_page, ebp, esi, PG_MAP |
5636 | lea eax, [esi+1000h] |
5636 | lea eax, [esi+1000h] |
5637 | lea edx, [ebp+1000h] |
5637 | lea edx, [ebp+1000h] |
5638 | stdcall map_page, edx, eax, PG_MAP |
5638 | stdcall map_page, edx, eax, PG_MAP |
5639 | and esi, 0xFFF |
5639 | and esi, 0xFFF |
5640 | add esi, ebp |
5640 | add esi, ebp |
5641 | cmp dword [esi], 'RSDT' |
5641 | cmp dword [esi], 'RSDT' |
5642 | jnz no_acpi_power_off |
5642 | jnz no_acpi_power_off |
5643 | mov ecx, [esi+4] |
5643 | mov ecx, [esi+4] |
5644 | sub ecx, 24h |
5644 | sub ecx, 24h |
5645 | jbe no_acpi_power_off |
5645 | jbe no_acpi_power_off |
5646 | shr ecx, 2 |
5646 | shr ecx, 2 |
5647 | add esi, 24h |
5647 | add esi, 24h |
5648 | .scan_fadt: |
5648 | .scan_fadt: |
5649 | lodsd |
5649 | lodsd |
5650 | mov ebx, eax |
5650 | mov ebx, eax |
5651 | lea eax, [ebp+2000h] |
5651 | lea eax, [ebp+2000h] |
5652 | stdcall map_page, eax, ebx, PG_MAP |
5652 | stdcall map_page, eax, ebx, PG_MAP |
5653 | lea eax, [ebp+3000h] |
5653 | lea eax, [ebp+3000h] |
5654 | add ebx, 0x1000 |
5654 | add ebx, 0x1000 |
5655 | stdcall map_page, eax, ebx, PG_MAP |
5655 | stdcall map_page, eax, ebx, PG_MAP |
5656 | and ebx, 0xFFF |
5656 | and ebx, 0xFFF |
5657 | lea ebx, [ebx+ebp+2000h] |
5657 | lea ebx, [ebx+ebp+2000h] |
5658 | cmp dword [ebx], 'FACP' |
5658 | cmp dword [ebx], 'FACP' |
5659 | jz .fadt_found |
5659 | jz .fadt_found |
5660 | loop .scan_fadt |
5660 | loop .scan_fadt |
5661 | jmp no_acpi_power_off |
5661 | jmp no_acpi_power_off |
5662 | .fadt_found: |
5662 | .fadt_found: |
5663 | ; ebx is linear address of FADT |
5663 | ; ebx is linear address of FADT |
5664 | mov edi, [ebx+40] ; physical address of the DSDT |
5664 | mov edi, [ebx+40] ; physical address of the DSDT |
5665 | lea eax, [ebp+4000h] |
5665 | lea eax, [ebp+4000h] |
5666 | stdcall map_page, eax, edi, PG_MAP |
5666 | stdcall map_page, eax, edi, PG_MAP |
5667 | lea eax, [ebp+5000h] |
5667 | lea eax, [ebp+5000h] |
5668 | lea esi, [edi+0x1000] |
5668 | lea esi, [edi+0x1000] |
5669 | stdcall map_page, eax, esi, PG_MAP |
5669 | stdcall map_page, eax, esi, PG_MAP |
5670 | and esi, 0xFFF |
5670 | and esi, 0xFFF |
5671 | sub edi, esi |
5671 | sub edi, esi |
5672 | cmp dword [esi+ebp+4000h], 'DSDT' |
5672 | cmp dword [esi+ebp+4000h], 'DSDT' |
5673 | jnz no_acpi_power_off |
5673 | jnz no_acpi_power_off |
5674 | mov eax, [esi+ebp+4004h] ; DSDT length |
5674 | mov eax, [esi+ebp+4004h] ; DSDT length |
5675 | sub eax, 36+4 |
5675 | sub eax, 36+4 |
5676 | jbe no_acpi_power_off |
5676 | jbe no_acpi_power_off |
5677 | add esi, 36 |
5677 | add esi, 36 |
5678 | .scan_dsdt: |
5678 | .scan_dsdt: |
5679 | cmp dword [esi+ebp+4000h], '_S5_' |
5679 | cmp dword [esi+ebp+4000h], '_S5_' |
5680 | jnz .scan_dsdt_cont |
5680 | jnz .scan_dsdt_cont |
5681 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5681 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5682 | jnz .scan_dsdt_cont |
5682 | jnz .scan_dsdt_cont |
5683 | mov dl, [esi+ebp+4000h+6] |
5683 | mov dl, [esi+ebp+4000h+6] |
5684 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5684 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5685 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5685 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5686 | ja .scan_dsdt_cont |
5686 | ja .scan_dsdt_cont |
5687 | cmp dl, 1 |
5687 | cmp dl, 1 |
5688 | jb .scan_dsdt_cont |
5688 | jb .scan_dsdt_cont |
5689 | lea esi, [esi+ebp+4000h+7] |
5689 | lea esi, [esi+ebp+4000h+7] |
5690 | xor ecx, ecx |
5690 | xor ecx, ecx |
5691 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5691 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5692 | jz @f |
5692 | jz @f |
5693 | cmp byte [esi], 0xA |
5693 | cmp byte [esi], 0xA |
5694 | jnz no_acpi_power_off |
5694 | jnz no_acpi_power_off |
5695 | inc esi |
5695 | inc esi |
5696 | mov cl, [esi] |
5696 | mov cl, [esi] |
5697 | @@: |
5697 | @@: |
5698 | inc esi |
5698 | inc esi |
5699 | cmp dl, 2 |
5699 | cmp dl, 2 |
5700 | jb @f |
5700 | jb @f |
5701 | cmp byte [esi], 0 |
5701 | cmp byte [esi], 0 |
5702 | jz @f |
5702 | jz @f |
5703 | cmp byte [esi], 0xA |
5703 | cmp byte [esi], 0xA |
5704 | jnz no_acpi_power_off |
5704 | jnz no_acpi_power_off |
5705 | inc esi |
5705 | inc esi |
5706 | mov ch, [esi] |
5706 | mov ch, [esi] |
5707 | @@: |
5707 | @@: |
5708 | jmp do_acpi_power_off |
5708 | jmp do_acpi_power_off |
5709 | .scan_dsdt_cont: |
5709 | .scan_dsdt_cont: |
5710 | inc esi |
5710 | inc esi |
5711 | cmp esi, 0x1000 |
5711 | cmp esi, 0x1000 |
5712 | jb @f |
5712 | jb @f |
5713 | sub esi, 0x1000 |
5713 | sub esi, 0x1000 |
5714 | add edi, 0x1000 |
5714 | add edi, 0x1000 |
5715 | push eax |
5715 | push eax |
5716 | lea eax, [ebp+4000h] |
5716 | lea eax, [ebp+4000h] |
5717 | stdcall map_page, eax, edi, PG_MAP |
5717 | stdcall map_page, eax, edi, PG_MAP |
5718 | push PG_MAP |
5718 | push PG_MAP |
5719 | lea eax, [edi+1000h] |
5719 | lea eax, [edi+1000h] |
5720 | push eax |
5720 | push eax |
5721 | lea eax, [ebp+5000h] |
5721 | lea eax, [ebp+5000h] |
5722 | push eax |
5722 | push eax |
5723 | stdcall map_page |
5723 | stdcall map_page |
5724 | pop eax |
5724 | pop eax |
5725 | @@: |
5725 | @@: |
5726 | dec eax |
5726 | dec eax |
5727 | jnz .scan_dsdt |
5727 | jnz .scan_dsdt |
5728 | jmp no_acpi_power_off |
5728 | jmp no_acpi_power_off |
5729 | do_acpi_power_off: |
5729 | do_acpi_power_off: |
5730 | mov edx, [ebx+48] |
5730 | mov edx, [ebx+48] |
5731 | test edx, edx |
5731 | test edx, edx |
5732 | jz .nosmi |
5732 | jz .nosmi |
5733 | mov al, [ebx+52] |
5733 | mov al, [ebx+52] |
5734 | out dx, al |
5734 | out dx, al |
5735 | mov edx, [ebx+64] |
5735 | mov edx, [ebx+64] |
5736 | @@: |
5736 | @@: |
5737 | in ax, dx |
5737 | in ax, dx |
5738 | test al, 1 |
5738 | test al, 1 |
5739 | jz @b |
5739 | jz @b |
5740 | .nosmi: |
5740 | .nosmi: |
5741 | and cx, 0x0707 |
5741 | and cx, 0x0707 |
5742 | shl cx, 2 |
5742 | shl cx, 2 |
5743 | or cx, 0x2020 |
5743 | or cx, 0x2020 |
5744 | mov edx, [ebx+64] |
5744 | mov edx, [ebx+64] |
5745 | in ax, dx |
5745 | in ax, dx |
5746 | and ax, 203h |
5746 | and ax, 203h |
5747 | or ah, cl |
5747 | or ah, cl |
5748 | out dx, ax |
5748 | out dx, ax |
5749 | mov edx, [ebx+68] |
5749 | mov edx, [ebx+68] |
5750 | test edx, edx |
5750 | test edx, edx |
5751 | jz @f |
5751 | jz @f |
5752 | in ax, dx |
5752 | in ax, dx |
5753 | and ax, 203h |
5753 | and ax, 203h |
5754 | or ah, ch |
5754 | or ah, ch |
5755 | out dx, ax |
5755 | out dx, ax |
5756 | @@: |
5756 | @@: |
5757 | jmp $ |
5757 | jmp $ |
5758 | 5758 | ||
5759 | 5759 | ||
5760 | no_acpi_power_off: |
5760 | no_acpi_power_off: |
5761 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5761 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5762 | mov word [OS_BASE+0x467+2], 0x1000 |
5762 | mov word [OS_BASE+0x467+2], 0x1000 |
5763 | 5763 | ||
5764 | mov al, 0x0F |
5764 | mov al, 0x0F |
5765 | out 0x70, al |
5765 | out 0x70, al |
5766 | mov al, 0x05 |
5766 | mov al, 0x05 |
5767 | out 0x71, al |
5767 | out 0x71, al |
5768 | 5768 | ||
5769 | mov al, 0xFE |
5769 | mov al, 0xFE |
5770 | out 0x64, al |
5770 | out 0x64, al |
5771 | 5771 | ||
5772 | hlt |
5772 | hlt |
5773 | jmp $-1 |
5773 | jmp $-1 |
5774 | 5774 | ||
5775 | scan_rsdp: |
5775 | scan_rsdp: |
5776 | add eax, OS_BASE |
5776 | add eax, OS_BASE |
5777 | .s: |
5777 | .s: |
5778 | cmp dword [eax], 'RSD ' |
5778 | cmp dword [eax], 'RSD ' |
5779 | jnz .n |
5779 | jnz .n |
5780 | cmp dword [eax+4], 'PTR ' |
5780 | cmp dword [eax+4], 'PTR ' |
5781 | jnz .n |
5781 | jnz .n |
5782 | xor edx, edx |
5782 | xor edx, edx |
5783 | xor esi, esi |
5783 | xor esi, esi |
5784 | @@: |
5784 | @@: |
5785 | add dl, [eax+esi] |
5785 | add dl, [eax+esi] |
5786 | inc esi |
5786 | inc esi |
5787 | cmp esi, 20 |
5787 | cmp esi, 20 |
5788 | jnz @b |
5788 | jnz @b |
5789 | test dl, dl |
5789 | test dl, dl |
5790 | jz .ok |
5790 | jz .ok |
5791 | .n: |
5791 | .n: |
5792 | add eax, 10h |
5792 | add eax, 10h |
5793 | loop .s |
5793 | loop .s |
5794 | stc |
5794 | stc |
5795 | .ok: |
5795 | .ok: |
5796 | ret |
5796 | ret |
5797 | end if |
5797 | end if |
5798 | 5798 | ||
5799 | include "data32.inc" |
5799 | include "data32.inc" |
5800 | 5800 | ||
5801 | __REV__ = __REV |
5801 | __REV__ = __REV |
5802 | 5802 | ||
5803 | uglobals_size = $ - endofcode |
5803 | uglobals_size = $ - endofcode |
5804 | if ~ lang eq sp |
5804 | if ~ lang eq sp |
5805 | diff16 "end of kernel code",0,$ |
5805 | diff16 "end of kernel code",0,$ |
5806 | end if=> |
5806 | end if=> |