Rev 3611 | Rev 3614 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3611 | Rev 3613 | ||
---|---|---|---|
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: 3611 $ |
74 | $Revision: 3613 $ |
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 | ||
- | 660 | ; CALCULATE FAT CHAIN FOR RAMDISK |
|
- | 661 | ||
- | 662 | call calculatefatchain |
|
659 | 663 | ||
660 | mov esi, boot_initapic |
664 | mov esi, boot_initapic |
661 | call boot_log |
665 | call boot_log |
662 | ; Try to Initialize APIC |
666 | ; Try to Initialize APIC |
663 | call APIC_init |
667 | call APIC_init |
664 | 668 | ||
665 | mov esi, boot_enableirq |
669 | mov esi, boot_enableirq |
666 | call boot_log |
670 | call boot_log |
667 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
671 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
668 | ; they are used: when partitions are scanned, hd_read relies on timer |
672 | ; they are used: when partitions are scanned, hd_read relies on timer |
669 | call unmask_timer |
673 | call unmask_timer |
670 | stdcall enable_irq, 2 ; @#$%! PIC |
674 | stdcall enable_irq, 2 ; @#$%! PIC |
671 | stdcall enable_irq, 6 ; FDD |
675 | stdcall enable_irq, 6 ; FDD |
672 | stdcall enable_irq, 13 ; co-processor |
676 | stdcall enable_irq, 13 ; co-processor |
673 | stdcall enable_irq, 14 |
677 | stdcall enable_irq, 14 |
674 | stdcall enable_irq, 15 |
678 | stdcall enable_irq, 15 |
675 | 679 | ||
676 | mov esi, boot_enablint_ide |
680 | mov esi, boot_enablint_ide |
677 | call boot_log |
681 | call boot_log |
678 | ; Enable interrupts in IDE controller |
682 | ; Enable interrupts in IDE controller |
679 | mov al, 0 |
683 | mov al, 0 |
680 | mov dx, 0x3F6 |
684 | mov dx, 0x3F6 |
681 | out dx, al |
685 | out dx, al |
682 | mov dl, 0x76 |
686 | mov dl, 0x76 |
683 | out dx, al |
687 | out dx, al |
684 | 688 | ||
685 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
689 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
686 | ; mov esi, boot_detectdisks |
690 | ; mov esi, boot_detectdisks |
687 | ; call boot_log |
691 | ; call boot_log |
688 | ;include 'detect/disks.inc' |
692 | ;include 'detect/disks.inc' |
689 | mov esi, boot_detectfloppy |
693 | mov esi, boot_detectfloppy |
690 | call boot_log |
694 | call boot_log |
691 | include 'detect/dev_fd.inc' |
695 | include 'detect/dev_fd.inc' |
692 | mov esi, boot_detecthdcd |
696 | mov esi, boot_detecthdcd |
693 | call boot_log |
697 | call boot_log |
694 | include 'detect/dev_hdcd.inc' |
698 | include 'detect/dev_hdcd.inc' |
695 | mov esi, boot_getcache |
699 | mov esi, boot_getcache |
696 | call boot_log |
700 | call boot_log |
697 | include 'detect/getcache.inc' |
701 | include 'detect/getcache.inc' |
698 | mov esi, boot_detectpart |
702 | mov esi, boot_detectpart |
699 | call boot_log |
703 | call boot_log |
700 | include 'detect/sear_par.inc' |
704 | include 'detect/sear_par.inc' |
701 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
705 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
702 | 706 | ||
703 | mov esi, boot_init_sys |
707 | mov esi, boot_init_sys |
704 | call boot_log |
708 | call boot_log |
705 | call Parser_params |
709 | call Parser_params |
706 | 710 | ||
707 | if ~ defined extended_primary_loader |
711 | if ~ defined extended_primary_loader |
708 | ; ramdisk image should be loaded by extended primary loader if it exists |
712 | ; ramdisk image should be loaded by extended primary loader if it exists |
709 | ; READ RAMDISK IMAGE FROM HD |
713 | ; READ RAMDISK IMAGE FROM HD |
710 | 714 | ||
711 | ;!!!!!!!!!!!!!!!!!!!!!!! |
715 | ;!!!!!!!!!!!!!!!!!!!!!!! |
712 | include 'boot/rdload.inc' |
716 | include 'boot/rdload.inc' |
713 | ;!!!!!!!!!!!!!!!!!!!!!!! |
717 | ;!!!!!!!!!!!!!!!!!!!!!!! |
714 | end if |
718 | end if |
715 | ; mov [dma_hdd],1 |
719 | ; mov [dma_hdd],1 |
716 | ; CALCULATE FAT CHAIN FOR RAMDISK |
- | |
717 | - | ||
718 | call calculatefatchain |
- | |
719 | 720 | ||
720 | if 0 |
721 | if 0 |
721 | mov ax, [OS_BASE+0x10000+bx_from_load] |
722 | mov ax, [OS_BASE+0x10000+bx_from_load] |
722 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
723 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
723 | je no_lib_load |
724 | je no_lib_load |
724 | 725 | ||
725 | mov esi, boot_loadlibs |
726 | mov esi, boot_loadlibs |
726 | call boot_log |
727 | call boot_log |
727 | ; LOADING LIBRARES |
728 | ; LOADING LIBRARES |
728 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
729 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
729 | call load_file_parse_table ; prepare file parse table |
730 | call load_file_parse_table ; prepare file parse table |
730 | call set_kernel_conf ; configure devices and gui |
731 | call set_kernel_conf ; configure devices and gui |
731 | no_lib_load: |
732 | no_lib_load: |
732 | end if |
733 | end if |
733 | 734 | ||
734 | ; Display APIC status |
735 | ; Display APIC status |
735 | mov esi, boot_APIC_found |
736 | mov esi, boot_APIC_found |
736 | cmp [irq_mode], IRQ_APIC |
737 | cmp [irq_mode], IRQ_APIC |
737 | je @f |
738 | je @f |
738 | mov esi, boot_APIC_nfound |
739 | mov esi, boot_APIC_nfound |
739 | @@: |
740 | @@: |
740 | call boot_log |
741 | call boot_log |
741 | 742 | ||
742 | ; PRINT AMOUNT OF MEMORY |
743 | ; PRINT AMOUNT OF MEMORY |
743 | mov esi, boot_memdetect |
744 | mov esi, boot_memdetect |
744 | call boot_log |
745 | call boot_log |
745 | 746 | ||
746 | movzx ecx, word [boot_y] |
747 | movzx ecx, word [boot_y] |
747 | if lang eq ru |
748 | if lang eq ru |
748 | or ecx, (10+30*6) shl 16 |
749 | or ecx, (10+30*6) shl 16 |
749 | else if lang eq sp |
750 | else if lang eq sp |
750 | or ecx, (10+33*6) shl 16 |
751 | or ecx, (10+33*6) shl 16 |
751 | else |
752 | else |
752 | or ecx, (10+29*6) shl 16 |
753 | or ecx, (10+29*6) shl 16 |
753 | end if |
754 | end if |
754 | sub ecx, 10 |
755 | sub ecx, 10 |
755 | mov edx, 0xFFFFFF |
756 | mov edx, 0xFFFFFF |
756 | mov ebx, [MEM_AMOUNT] |
757 | mov ebx, [MEM_AMOUNT] |
757 | shr ebx, 20 |
758 | shr ebx, 20 |
758 | xor edi, edi |
759 | xor edi, edi |
759 | mov eax, 0x00040000 |
760 | mov eax, 0x00040000 |
760 | inc edi |
761 | inc edi |
761 | call display_number_force |
762 | call display_number_force |
762 | 763 | ||
763 | ; BUILD SCHEDULER |
764 | ; BUILD SCHEDULER |
764 | 765 | ||
765 | ; call build_scheduler; sys32.inc |
766 | ; call build_scheduler; sys32.inc |
766 | 767 | ||
767 | ; mov esi, boot_devices |
768 | ; mov esi, boot_devices |
768 | ; call boot_log |
769 | ; call boot_log |
769 | 770 | ||
770 | mov [pci_access_enabled], 1 |
771 | mov [pci_access_enabled], 1 |
771 | call pci_enum |
772 | call pci_enum |
772 | 773 | ||
773 | stdcall load_driver, szVidintel |
774 | stdcall load_driver, szVidintel |
774 | 775 | ||
775 | call usb_init |
776 | call usb_init |
776 | 777 | ||
777 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
778 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
778 | 779 | ||
779 | mov esi, boot_windefs |
780 | mov esi, boot_windefs |
780 | call boot_log |
781 | call boot_log |
781 | call set_window_defaults |
782 | call set_window_defaults |
782 | 783 | ||
783 | ; SET BACKGROUND DEFAULTS |
784 | ; SET BACKGROUND DEFAULTS |
784 | 785 | ||
785 | mov esi, boot_bgr |
786 | mov esi, boot_bgr |
786 | call boot_log |
787 | call boot_log |
787 | call init_background |
788 | call init_background |
788 | call calculatebackground |
789 | call calculatebackground |
789 | 790 | ||
790 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
791 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
791 | 792 | ||
792 | mov esi, boot_resirqports |
793 | mov esi, boot_resirqports |
793 | call boot_log |
794 | call boot_log |
794 | call reserve_irqs_ports |
795 | call reserve_irqs_ports |
795 | 796 | ||
796 | call init_display |
797 | call init_display |
797 | mov eax, [def_cursor] |
798 | mov eax, [def_cursor] |
798 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
799 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
799 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
800 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
800 | 801 | ||
801 | ; PRINT CPU FREQUENCY |
802 | ; PRINT CPU FREQUENCY |
802 | 803 | ||
803 | mov esi, boot_cpufreq |
804 | mov esi, boot_cpufreq |
804 | call boot_log |
805 | call boot_log |
805 | 806 | ||
806 | cli ;FIXME check IF |
807 | cli ;FIXME check IF |
807 | rdtsc |
808 | rdtsc |
808 | mov ecx, eax |
809 | mov ecx, eax |
809 | mov esi, 250 ; wait 1/4 a second |
810 | mov esi, 250 ; wait 1/4 a second |
810 | call delay_ms |
811 | call delay_ms |
811 | rdtsc |
812 | rdtsc |
812 | 813 | ||
813 | sub eax, ecx |
814 | sub eax, ecx |
814 | xor edx, edx |
815 | xor edx, edx |
815 | shld edx, eax, 2 |
816 | shld edx, eax, 2 |
816 | shl eax, 2 |
817 | shl eax, 2 |
817 | mov dword [cpu_freq], eax |
818 | mov dword [cpu_freq], eax |
818 | mov dword [cpu_freq+4], edx |
819 | mov dword [cpu_freq+4], edx |
819 | mov ebx, 1000000 |
820 | mov ebx, 1000000 |
820 | div ebx |
821 | div ebx |
821 | mov ebx, eax |
822 | mov ebx, eax |
822 | 823 | ||
823 | movzx ecx, word [boot_y] |
824 | movzx ecx, word [boot_y] |
824 | if lang eq ru |
825 | if lang eq ru |
825 | add ecx, (10+19*6) shl 16 - 10 |
826 | add ecx, (10+19*6) shl 16 - 10 |
826 | else if lang eq sp |
827 | else if lang eq sp |
827 | add ecx, (10+25*6) shl 16 - 10 |
828 | add ecx, (10+25*6) shl 16 - 10 |
828 | else |
829 | else |
829 | add ecx, (10+17*6) shl 16 - 10 |
830 | add ecx, (10+17*6) shl 16 - 10 |
830 | end if |
831 | end if |
831 | 832 | ||
832 | mov edx, 0xFFFFFF |
833 | mov edx, 0xFFFFFF |
833 | xor edi, edi |
834 | xor edi, edi |
834 | mov eax, 0x00040000 |
835 | mov eax, 0x00040000 |
835 | inc edi |
836 | inc edi |
836 | call display_number_force |
837 | call display_number_force |
837 | 838 | ||
838 | ; SET VARIABLES |
839 | ; SET VARIABLES |
839 | 840 | ||
840 | call set_variables |
841 | call set_variables |
841 | 842 | ||
842 | ; STACK AND FDC |
843 | ; STACK AND FDC |
843 | 844 | ||
844 | call stack_init |
845 | call stack_init |
845 | call fdc_init |
846 | call fdc_init |
846 | 847 | ||
847 | ; PALETTE FOR 320x200 and 640x480 16 col |
848 | ; PALETTE FOR 320x200 and 640x480 16 col |
848 | 849 | ||
849 | cmp [SCR_MODE], word 0x12 |
850 | cmp [SCR_MODE], word 0x12 |
850 | jne no_pal_vga |
851 | jne no_pal_vga |
851 | mov esi, boot_pal_vga |
852 | mov esi, boot_pal_vga |
852 | call boot_log |
853 | call boot_log |
853 | call paletteVGA |
854 | call paletteVGA |
854 | no_pal_vga: |
855 | no_pal_vga: |
855 | 856 | ||
856 | cmp [SCR_MODE], word 0x13 |
857 | cmp [SCR_MODE], word 0x13 |
857 | jne no_pal_ega |
858 | jne no_pal_ega |
858 | mov esi, boot_pal_ega |
859 | mov esi, boot_pal_ega |
859 | call boot_log |
860 | call boot_log |
860 | call palette320x200 |
861 | call palette320x200 |
861 | no_pal_ega: |
862 | no_pal_ega: |
862 | 863 | ||
863 | ; LOAD DEFAULT SKIN |
864 | ; LOAD DEFAULT SKIN |
864 | 865 | ||
865 | call load_default_skin |
866 | call load_default_skin |
866 | 867 | ||
867 | ;protect io permission map |
868 | ;protect io permission map |
868 | 869 | ||
869 | mov esi, [default_io_map] |
870 | mov esi, [default_io_map] |
870 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
871 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
871 | add esi, 0x1000 |
872 | add esi, 0x1000 |
872 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
873 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
873 | 874 | ||
874 | stdcall map_page, tss._io_map_0, \ |
875 | stdcall map_page, tss._io_map_0, \ |
875 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
876 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
876 | stdcall map_page, tss._io_map_1, \ |
877 | stdcall map_page, tss._io_map_1, \ |
877 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
878 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
878 | 879 | ||
879 | ; LOAD FIRST APPLICATION |
880 | ; LOAD FIRST APPLICATION |
880 | cli |
881 | cli |
881 | 882 | ||
882 | ; cmp byte [BOOT_VAR+0x9030],1 |
883 | ; cmp byte [BOOT_VAR+0x9030],1 |
883 | ; jne no_load_vrr_m |
884 | ; jne no_load_vrr_m |
884 | 885 | ||
885 | ; mov ebp, vrr_m |
886 | ; mov ebp, vrr_m |
886 | ; call fs_execute_from_sysdir |
887 | ; call fs_execute_from_sysdir |
887 | ; |
888 | ; |
888 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
889 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
889 | ; sub eax,2 |
890 | ; sub eax,2 |
890 | ; jz first_app_found |
891 | ; jz first_app_found |
891 | ; |
892 | ; |
892 | ;no_load_vrr_m: |
893 | ;no_load_vrr_m: |
893 | 894 | ||
894 | mov ebp, firstapp |
895 | mov ebp, firstapp |
895 | call fs_execute_from_sysdir |
896 | call fs_execute_from_sysdir |
896 | 897 | ||
897 | ; cmp eax,2 ; continue if a process has been loaded |
898 | ; cmp eax,2 ; continue if a process has been loaded |
898 | test eax, eax |
899 | test eax, eax |
899 | jns first_app_found |
900 | jns first_app_found |
900 | 901 | ||
901 | mov esi, boot_failed |
902 | mov esi, boot_failed |
902 | call boot_log |
903 | call boot_log |
903 | 904 | ||
904 | mov eax, 0xDEADBEEF ; otherwise halt |
905 | mov eax, 0xDEADBEEF ; otherwise halt |
905 | hlt |
906 | hlt |
906 | 907 | ||
907 | first_app_found: |
908 | first_app_found: |
908 | 909 | ||
909 | cli |
910 | cli |
910 | 911 | ||
911 | ; SET KEYBOARD PARAMETERS |
912 | ; SET KEYBOARD PARAMETERS |
912 | mov al, 0xf6 ; reset keyboard, scan enabled |
913 | mov al, 0xf6 ; reset keyboard, scan enabled |
913 | call kb_write |
914 | call kb_write |
914 | test ah, ah |
915 | test ah, ah |
915 | jnz .no_keyboard |
916 | jnz .no_keyboard |
916 | 917 | ||
917 | ; wait until 8042 is ready |
918 | ; wait until 8042 is ready |
918 | xor ecx, ecx |
919 | xor ecx, ecx |
919 | @@: |
920 | @@: |
920 | in al, 64h |
921 | in al, 64h |
921 | and al, 00000010b |
922 | and al, 00000010b |
922 | loopnz @b |
923 | loopnz @b |
923 | 924 | ||
924 | iglobal |
925 | iglobal |
925 | align 4 |
926 | align 4 |
926 | ps2_keyboard_functions: |
927 | ps2_keyboard_functions: |
927 | dd .end - $ |
928 | dd .end - $ |
928 | dd 0 ; no close |
929 | dd 0 ; no close |
929 | dd ps2_set_lights |
930 | dd ps2_set_lights |
930 | .end: |
931 | .end: |
931 | endg |
932 | endg |
932 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
933 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
933 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
934 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
934 | ; call kb_write |
935 | ; call kb_write |
935 | ; call kb_read |
936 | ; call kb_read |
936 | ; mov al, 111b |
937 | ; mov al, 111b |
937 | ; call kb_write |
938 | ; call kb_write |
938 | ; call kb_read |
939 | ; call kb_read |
939 | 940 | ||
940 | mov al, 0xF3 ; set repeat rate & delay |
941 | mov al, 0xF3 ; set repeat rate & delay |
941 | call kb_write |
942 | call kb_write |
942 | ; call kb_read |
943 | ; call kb_read |
943 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
944 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
944 | call kb_write |
945 | call kb_write |
945 | ; call kb_read |
946 | ; call kb_read |
946 | ;// mike.dld [ |
947 | ;// mike.dld [ |
947 | call set_lights |
948 | call set_lights |
948 | ;// mike.dld ] |
949 | ;// mike.dld ] |
949 | stdcall attach_int_handler, 1, irq1, 0 |
950 | stdcall attach_int_handler, 1, irq1, 0 |
950 | .no_keyboard: |
951 | .no_keyboard: |
951 | 952 | ||
952 | ; SET MOUSE |
953 | ; SET MOUSE |
953 | 954 | ||
954 | stdcall load_driver, szPS2MDriver |
955 | stdcall load_driver, szPS2MDriver |
955 | ; stdcall load_driver, szCOM_MDriver |
956 | ; stdcall load_driver, szCOM_MDriver |
956 | 957 | ||
957 | mov esi, boot_setmouse |
958 | mov esi, boot_setmouse |
958 | call boot_log |
959 | call boot_log |
959 | call setmouse |
960 | call setmouse |
960 | 961 | ||
961 | ; Setup serial output console (if enabled) |
962 | ; Setup serial output console (if enabled) |
962 | 963 | ||
963 | if defined debug_com_base |
964 | if defined debug_com_base |
964 | 965 | ||
965 | ; enable Divisor latch |
966 | ; enable Divisor latch |
966 | 967 | ||
967 | mov dx, debug_com_base+3 |
968 | mov dx, debug_com_base+3 |
968 | mov al, 1 shl 7 |
969 | mov al, 1 shl 7 |
969 | out dx, al |
970 | out dx, al |
970 | 971 | ||
971 | ; Set speed to 115200 baud (max speed) |
972 | ; Set speed to 115200 baud (max speed) |
972 | 973 | ||
973 | mov dx, debug_com_base |
974 | mov dx, debug_com_base |
974 | mov al, 0x01 |
975 | mov al, 0x01 |
975 | out dx, al |
976 | out dx, al |
976 | 977 | ||
977 | mov dx, debug_com_base+1 |
978 | mov dx, debug_com_base+1 |
978 | mov al, 0x00 |
979 | mov al, 0x00 |
979 | out dx, al |
980 | out dx, al |
980 | 981 | ||
981 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
982 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
982 | 983 | ||
983 | mov dx, debug_com_base+3 |
984 | mov dx, debug_com_base+3 |
984 | mov al, 3 |
985 | mov al, 3 |
985 | out dx, al |
986 | out dx, al |
986 | 987 | ||
987 | ; disable interrupts |
988 | ; disable interrupts |
988 | 989 | ||
989 | mov dx, debug_com_base+1 |
990 | mov dx, debug_com_base+1 |
990 | mov al, 0 |
991 | mov al, 0 |
991 | out dx, al |
992 | out dx, al |
992 | 993 | ||
993 | ; clear + enable fifo (64 bits) |
994 | ; clear + enable fifo (64 bits) |
994 | 995 | ||
995 | mov dx, debug_com_base+2 |
996 | mov dx, debug_com_base+2 |
996 | mov al, 0x7 + 1 shl 5 |
997 | mov al, 0x7 + 1 shl 5 |
997 | out dx, al |
998 | out dx, al |
998 | 999 | ||
999 | 1000 | ||
1000 | end if |
1001 | end if |
1001 | mov eax, [version_inf.rev] |
1002 | mov eax, [version_inf.rev] |
1002 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1003 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1003 | 1004 | ||
1004 | mov eax, [cpu_count] |
1005 | mov eax, [cpu_count] |
1005 | test eax, eax |
1006 | test eax, eax |
1006 | jnz @F |
1007 | jnz @F |
1007 | mov al, 1 ; at least one CPU |
1008 | mov al, 1 ; at least one CPU |
1008 | @@: |
1009 | @@: |
1009 | DEBUGF 1, "K : %d CPU detected\n", eax |
1010 | DEBUGF 1, "K : %d CPU detected\n", eax |
1010 | 1011 | ||
1011 | ; START MULTITASKING |
1012 | ; START MULTITASKING |
1012 | 1013 | ||
1013 | ; A 'All set - press ESC to start' messages if need |
1014 | ; A 'All set - press ESC to start' messages if need |
1014 | if preboot_blogesc |
1015 | if preboot_blogesc |
1015 | mov esi, boot_tasking |
1016 | mov esi, boot_tasking |
1016 | call boot_log |
1017 | call boot_log |
1017 | .bll1: |
1018 | .bll1: |
1018 | in al, 0x60 ; wait for ESC key press |
1019 | in al, 0x60 ; wait for ESC key press |
1019 | cmp al, 129 |
1020 | cmp al, 129 |
1020 | jne .bll1 |
1021 | jne .bll1 |
1021 | end if |
1022 | end if |
1022 | 1023 | ||
1023 | cmp [IDEContrRegsBaseAddr], 0 |
1024 | cmp [IDEContrRegsBaseAddr], 0 |
1024 | setnz [dma_hdd] |
1025 | setnz [dma_hdd] |
1025 | mov [timer_ticks_enable], 1 ; for cd driver |
1026 | mov [timer_ticks_enable], 1 ; for cd driver |
1026 | 1027 | ||
1027 | sti |
1028 | sti |
1028 | ; call change_task |
1029 | ; call change_task |
1029 | 1030 | ||
1030 | jmp osloop |
1031 | jmp osloop |
1031 | 1032 | ||
1032 | 1033 | ||
1033 | ; Fly :) |
1034 | ; Fly :) |
1034 | 1035 | ||
1035 | include 'unpacker.inc' |
1036 | include 'unpacker.inc' |
1036 | 1037 | ||
1037 | align 4 |
1038 | align 4 |
1038 | boot_log: |
1039 | boot_log: |
1039 | pushad |
1040 | pushad |
1040 | 1041 | ||
1041 | mov ebx, 10*65536 |
1042 | mov ebx, 10*65536 |
1042 | mov bx, word [boot_y] |
1043 | mov bx, word [boot_y] |
1043 | add [boot_y], dword 10 |
1044 | add [boot_y], dword 10 |
1044 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1045 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1045 | xor edi, edi |
1046 | xor edi, edi |
1046 | mov edx, esi |
1047 | mov edx, esi |
1047 | inc edi |
1048 | inc edi |
1048 | call dtext |
1049 | call dtext |
1049 | 1050 | ||
1050 | mov [novesachecksum], 1000 |
1051 | mov [novesachecksum], 1000 |
1051 | call checkVga_N13 |
1052 | call checkVga_N13 |
1052 | 1053 | ||
1053 | popad |
1054 | popad |
1054 | 1055 | ||
1055 | ret |
1056 | ret |
1056 | 1057 | ||
1057 | ; in: edx -> APPDATA for OS/IDLE slot |
1058 | ; in: edx -> APPDATA for OS/IDLE slot |
1058 | ; in: ebx = stack base |
1059 | ; in: ebx = stack base |
1059 | proc setup_os_slot |
1060 | proc setup_os_slot |
1060 | xor eax, eax |
1061 | xor eax, eax |
1061 | mov ecx, 256/4 |
1062 | mov ecx, 256/4 |
1062 | mov edi, edx |
1063 | mov edi, edx |
1063 | rep stosd |
1064 | rep stosd |
1064 | 1065 | ||
1065 | mov eax, tss+0x80 |
1066 | mov eax, tss+0x80 |
1066 | call get_pg_addr |
1067 | call get_pg_addr |
1067 | inc eax |
1068 | inc eax |
1068 | mov [edx+APPDATA.io_map], eax |
1069 | mov [edx+APPDATA.io_map], eax |
1069 | mov eax, tss+0x1080 |
1070 | mov eax, tss+0x1080 |
1070 | call get_pg_addr |
1071 | call get_pg_addr |
1071 | inc eax |
1072 | inc eax |
1072 | mov [edx+APPDATA.io_map+4], eax |
1073 | mov [edx+APPDATA.io_map+4], eax |
1073 | 1074 | ||
1074 | mov dword [edx+APPDATA.pl0_stack], ebx |
1075 | mov dword [edx+APPDATA.pl0_stack], ebx |
1075 | lea edi, [ebx+0x2000-512] |
1076 | lea edi, [ebx+0x2000-512] |
1076 | mov dword [edx+APPDATA.fpu_state], edi |
1077 | mov dword [edx+APPDATA.fpu_state], edi |
1077 | mov dword [edx+APPDATA.saved_esp0], edi |
1078 | mov dword [edx+APPDATA.saved_esp0], edi |
1078 | mov dword [edx+APPDATA.saved_esp], edi |
1079 | mov dword [edx+APPDATA.saved_esp], edi |
1079 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1080 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1080 | 1081 | ||
1081 | mov esi, fpu_data |
1082 | mov esi, fpu_data |
1082 | mov ecx, 512/4 |
1083 | mov ecx, 512/4 |
1083 | cld |
1084 | cld |
1084 | rep movsd |
1085 | rep movsd |
1085 | 1086 | ||
1086 | lea eax, [edx+APP_OBJ_OFFSET] |
1087 | lea eax, [edx+APP_OBJ_OFFSET] |
1087 | mov dword [edx+APPDATA.fd_obj], eax |
1088 | mov dword [edx+APPDATA.fd_obj], eax |
1088 | mov dword [edx+APPDATA.bk_obj], eax |
1089 | mov dword [edx+APPDATA.bk_obj], eax |
1089 | 1090 | ||
1090 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1091 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1091 | 1092 | ||
1092 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1093 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1093 | 1094 | ||
1094 | mov eax, edx |
1095 | mov eax, edx |
1095 | shr eax, 3 |
1096 | shr eax, 3 |
1096 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1097 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1097 | mov [eax+TASKDATA.wnd_number], dh |
1098 | mov [eax+TASKDATA.wnd_number], dh |
1098 | mov byte [eax+TASKDATA.pid], dh |
1099 | mov byte [eax+TASKDATA.pid], dh |
1099 | 1100 | ||
1100 | ret |
1101 | ret |
1101 | endp |
1102 | endp |
1102 | 1103 | ||
1103 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1104 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1104 | ; ; |
1105 | ; ; |
1105 | ; MAIN OS LOOP START ; |
1106 | ; MAIN OS LOOP START ; |
1106 | ; ; |
1107 | ; ; |
1107 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1108 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1108 | align 32 |
1109 | align 32 |
1109 | osloop: |
1110 | osloop: |
1110 | mov edx, osloop_has_work? |
1111 | mov edx, osloop_has_work? |
1111 | xor ecx, ecx |
1112 | xor ecx, ecx |
1112 | call Wait_events |
1113 | call Wait_events |
1113 | xor eax, eax |
1114 | xor eax, eax |
1114 | xchg eax, [osloop_nonperiodic_work] |
1115 | xchg eax, [osloop_nonperiodic_work] |
1115 | test eax, eax |
1116 | test eax, eax |
1116 | jz .no_periodic |
1117 | jz .no_periodic |
1117 | ; call [draw_pointer] |
1118 | ; call [draw_pointer] |
1118 | call __sys_draw_pointer |
1119 | call __sys_draw_pointer |
1119 | call window_check_events |
1120 | call window_check_events |
1120 | call mouse_check_events |
1121 | call mouse_check_events |
1121 | call checkmisc |
1122 | call checkmisc |
1122 | call checkVga_N13 |
1123 | call checkVga_N13 |
1123 | .no_periodic: |
1124 | .no_periodic: |
1124 | call stack_handler |
1125 | call stack_handler |
1125 | call check_fdd_motor_status |
1126 | call check_fdd_motor_status |
1126 | call check_ATAPI_device_event |
1127 | call check_ATAPI_device_event |
1127 | call check_lights_state |
1128 | call check_lights_state |
1128 | call check_timers |
1129 | call check_timers |
1129 | jmp osloop |
1130 | jmp osloop |
1130 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1131 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1131 | ; ; |
1132 | ; ; |
1132 | ; MAIN OS LOOP END ; |
1133 | ; MAIN OS LOOP END ; |
1133 | ; ; |
1134 | ; ; |
1134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1135 | proc osloop_has_work? |
1136 | proc osloop_has_work? |
1136 | cmp [osloop_nonperiodic_work], 0 |
1137 | cmp [osloop_nonperiodic_work], 0 |
1137 | jnz .yes |
1138 | jnz .yes |
1138 | call stack_handler_has_work? |
1139 | call stack_handler_has_work? |
1139 | jnz .yes |
1140 | jnz .yes |
1140 | call check_fdd_motor_status_has_work? |
1141 | call check_fdd_motor_status_has_work? |
1141 | jnz .yes |
1142 | jnz .yes |
1142 | call check_ATAPI_device_event_has_work? |
1143 | call check_ATAPI_device_event_has_work? |
1143 | jnz .yes |
1144 | jnz .yes |
1144 | call check_lights_state_has_work? |
1145 | call check_lights_state_has_work? |
1145 | jnz .yes |
1146 | jnz .yes |
1146 | call check_timers_has_work? |
1147 | call check_timers_has_work? |
1147 | jnz .yes |
1148 | jnz .yes |
1148 | .no: |
1149 | .no: |
1149 | xor eax, eax |
1150 | xor eax, eax |
1150 | ret |
1151 | ret |
1151 | .yes: |
1152 | .yes: |
1152 | xor eax, eax |
1153 | xor eax, eax |
1153 | inc eax |
1154 | inc eax |
1154 | ret |
1155 | ret |
1155 | endp |
1156 | endp |
1156 | 1157 | ||
1157 | proc wakeup_osloop |
1158 | proc wakeup_osloop |
1158 | mov [osloop_nonperiodic_work], 1 |
1159 | mov [osloop_nonperiodic_work], 1 |
1159 | ret |
1160 | ret |
1160 | endp |
1161 | endp |
1161 | 1162 | ||
1162 | uglobal |
1163 | uglobal |
1163 | align 4 |
1164 | align 4 |
1164 | osloop_nonperiodic_work dd ? |
1165 | osloop_nonperiodic_work dd ? |
1165 | endg |
1166 | endg |
1166 | 1167 | ||
1167 | align 4 |
1168 | align 4 |
1168 | idle_thread: |
1169 | idle_thread: |
1169 | sti |
1170 | sti |
1170 | idle_loop: |
1171 | idle_loop: |
1171 | hlt |
1172 | hlt |
1172 | jmp idle_loop |
1173 | jmp idle_loop |
1173 | 1174 | ||
1174 | 1175 | ||
1175 | 1176 | ||
1176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1177 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1177 | ; ; |
1178 | ; ; |
1178 | ; INCLUDED SYSTEM FILES ; |
1179 | ; INCLUDED SYSTEM FILES ; |
1179 | ; ; |
1180 | ; ; |
1180 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1181 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1181 | 1182 | ||
1182 | 1183 | ||
1183 | include "kernel32.inc" |
1184 | include "kernel32.inc" |
1184 | 1185 | ||
1185 | 1186 | ||
1186 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1187 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1187 | ; ; |
1188 | ; ; |
1188 | ; KERNEL FUNCTIONS ; |
1189 | ; KERNEL FUNCTIONS ; |
1189 | ; ; |
1190 | ; ; |
1190 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1191 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1191 | 1192 | ||
1192 | reserve_irqs_ports: |
1193 | reserve_irqs_ports: |
1193 | 1194 | ||
1194 | 1195 | ||
1195 | ; RESERVE PORTS |
1196 | ; RESERVE PORTS |
1196 | mov eax, RESERVED_PORTS |
1197 | mov eax, RESERVED_PORTS |
1197 | mov ecx, 1 |
1198 | mov ecx, 1 |
1198 | 1199 | ||
1199 | mov [eax], dword 4 |
1200 | mov [eax], dword 4 |
1200 | 1201 | ||
1201 | mov [eax+16], ecx |
1202 | mov [eax+16], ecx |
1202 | mov [eax+16+4], dword 0 |
1203 | mov [eax+16+4], dword 0 |
1203 | mov [eax+16+8], dword 0x2D |
1204 | mov [eax+16+8], dword 0x2D |
1204 | 1205 | ||
1205 | mov [eax+32], ecx |
1206 | mov [eax+32], ecx |
1206 | mov [eax+32+4], dword 0x30 |
1207 | mov [eax+32+4], dword 0x30 |
1207 | mov [eax+32+8], dword 0x4D |
1208 | mov [eax+32+8], dword 0x4D |
1208 | 1209 | ||
1209 | mov [eax+48], ecx |
1210 | mov [eax+48], ecx |
1210 | mov [eax+48+4], dword 0x50 |
1211 | mov [eax+48+4], dword 0x50 |
1211 | mov [eax+48+8], dword 0xDF |
1212 | mov [eax+48+8], dword 0xDF |
1212 | 1213 | ||
1213 | mov [eax+64], ecx |
1214 | mov [eax+64], ecx |
1214 | mov [eax+64+4], dword 0xE5 |
1215 | mov [eax+64+4], dword 0xE5 |
1215 | mov [eax+64+8], dword 0xFF |
1216 | mov [eax+64+8], dword 0xFF |
1216 | 1217 | ||
1217 | ret |
1218 | ret |
1218 | 1219 | ||
1219 | 1220 | ||
1220 | iglobal |
1221 | iglobal |
1221 | process_number dd 0x2 |
1222 | process_number dd 0x2 |
1222 | endg |
1223 | endg |
1223 | 1224 | ||
1224 | set_variables: |
1225 | set_variables: |
1225 | 1226 | ||
1226 | mov ecx, 0x16 ; flush port 0x60 |
1227 | mov ecx, 0x16 ; flush port 0x60 |
1227 | .fl60: |
1228 | .fl60: |
1228 | in al, 0x60 |
1229 | in al, 0x60 |
1229 | loop .fl60 |
1230 | loop .fl60 |
1230 | push eax |
1231 | push eax |
1231 | 1232 | ||
1232 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1233 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1233 | shr ax, 1 |
1234 | shr ax, 1 |
1234 | shl eax, 16 |
1235 | shl eax, 16 |
1235 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1236 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1236 | shr ax, 1 |
1237 | shr ax, 1 |
1237 | mov [MOUSE_X], eax |
1238 | mov [MOUSE_X], eax |
1238 | call wakeup_osloop |
1239 | call wakeup_osloop |
1239 | 1240 | ||
1240 | xor eax, eax |
1241 | xor eax, eax |
1241 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1242 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1242 | 1243 | ||
1243 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1244 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1244 | mov byte [KEY_COUNT], al ; keyboard buffer |
1245 | mov byte [KEY_COUNT], al ; keyboard buffer |
1245 | mov byte [BTN_COUNT], al ; button buffer |
1246 | mov byte [BTN_COUNT], al ; button buffer |
1246 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1247 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1247 | 1248 | ||
1248 | ;!! IP 04.02.2005: |
1249 | ;!! IP 04.02.2005: |
1249 | ; mov byte [DONT_SWITCH], al; change task if possible |
1250 | ; mov byte [DONT_SWITCH], al; change task if possible |
1250 | pop eax |
1251 | pop eax |
1251 | ret |
1252 | ret |
1252 | 1253 | ||
1253 | align 4 |
1254 | align 4 |
1254 | ;input eax=43,bl-byte of output, ecx - number of port |
1255 | ;input eax=43,bl-byte of output, ecx - number of port |
1255 | sys_outport: |
1256 | sys_outport: |
1256 | 1257 | ||
1257 | mov edi, ecx ; separate flag for read / write |
1258 | mov edi, ecx ; separate flag for read / write |
1258 | and ecx, 65535 |
1259 | and ecx, 65535 |
1259 | 1260 | ||
1260 | mov eax, [RESERVED_PORTS] |
1261 | mov eax, [RESERVED_PORTS] |
1261 | test eax, eax |
1262 | test eax, eax |
1262 | jnz .sopl8 |
1263 | jnz .sopl8 |
1263 | inc eax |
1264 | inc eax |
1264 | mov [esp+32], eax |
1265 | mov [esp+32], eax |
1265 | ret |
1266 | ret |
1266 | 1267 | ||
1267 | .sopl8: |
1268 | .sopl8: |
1268 | mov edx, [TASK_BASE] |
1269 | mov edx, [TASK_BASE] |
1269 | mov edx, [edx+0x4] |
1270 | mov edx, [edx+0x4] |
1270 | ;and ecx,65535 |
1271 | ;and ecx,65535 |
1271 | ;cld - set on interrupt 0x40 |
1272 | ;cld - set on interrupt 0x40 |
1272 | .sopl1: |
1273 | .sopl1: |
1273 | 1274 | ||
1274 | mov esi, eax |
1275 | mov esi, eax |
1275 | shl esi, 4 |
1276 | shl esi, 4 |
1276 | add esi, RESERVED_PORTS |
1277 | add esi, RESERVED_PORTS |
1277 | cmp edx, [esi+0] |
1278 | cmp edx, [esi+0] |
1278 | jne .sopl2 |
1279 | jne .sopl2 |
1279 | cmp ecx, [esi+4] |
1280 | cmp ecx, [esi+4] |
1280 | jb .sopl2 |
1281 | jb .sopl2 |
1281 | cmp ecx, [esi+8] |
1282 | cmp ecx, [esi+8] |
1282 | jg .sopl2 |
1283 | jg .sopl2 |
1283 | .sopl3: |
1284 | .sopl3: |
1284 | 1285 | ||
1285 | test edi, 0x80000000; read ? |
1286 | test edi, 0x80000000; read ? |
1286 | jnz .sopl4 |
1287 | jnz .sopl4 |
1287 | 1288 | ||
1288 | mov eax, ebx |
1289 | mov eax, ebx |
1289 | mov dx, cx ; write |
1290 | mov dx, cx ; write |
1290 | out dx, al |
1291 | out dx, al |
1291 | and [esp+32], dword 0 |
1292 | and [esp+32], dword 0 |
1292 | ret |
1293 | ret |
1293 | 1294 | ||
1294 | .sopl2: |
1295 | .sopl2: |
1295 | 1296 | ||
1296 | dec eax |
1297 | dec eax |
1297 | jnz .sopl1 |
1298 | jnz .sopl1 |
1298 | inc eax |
1299 | inc eax |
1299 | mov [esp+32], eax |
1300 | mov [esp+32], eax |
1300 | ret |
1301 | ret |
1301 | 1302 | ||
1302 | 1303 | ||
1303 | .sopl4: |
1304 | .sopl4: |
1304 | 1305 | ||
1305 | mov dx, cx ; read |
1306 | mov dx, cx ; read |
1306 | in al, dx |
1307 | in al, dx |
1307 | and eax, 0xff |
1308 | and eax, 0xff |
1308 | and [esp+32], dword 0 |
1309 | and [esp+32], dword 0 |
1309 | mov [esp+20], eax |
1310 | mov [esp+20], eax |
1310 | ret |
1311 | ret |
1311 | 1312 | ||
1312 | display_number: |
1313 | display_number: |
1313 | ;It is not optimization |
1314 | ;It is not optimization |
1314 | mov eax, ebx |
1315 | mov eax, ebx |
1315 | mov ebx, ecx |
1316 | mov ebx, ecx |
1316 | mov ecx, edx |
1317 | mov ecx, edx |
1317 | mov edx, esi |
1318 | mov edx, esi |
1318 | mov esi, edi |
1319 | mov esi, edi |
1319 | ; eax = print type, al=0 -> ebx is number |
1320 | ; eax = print type, al=0 -> ebx is number |
1320 | ; al=1 -> ebx is pointer |
1321 | ; al=1 -> ebx is pointer |
1321 | ; ah=0 -> display decimal |
1322 | ; ah=0 -> display decimal |
1322 | ; ah=1 -> display hexadecimal |
1323 | ; ah=1 -> display hexadecimal |
1323 | ; ah=2 -> display binary |
1324 | ; ah=2 -> display binary |
1324 | ; eax bits 16-21 = number of digits to display (0-32) |
1325 | ; eax bits 16-21 = number of digits to display (0-32) |
1325 | ; eax bits 22-31 = reserved |
1326 | ; eax bits 22-31 = reserved |
1326 | ; |
1327 | ; |
1327 | ; ebx = number or pointer |
1328 | ; ebx = number or pointer |
1328 | ; ecx = x shl 16 + y |
1329 | ; ecx = x shl 16 + y |
1329 | ; edx = color |
1330 | ; edx = color |
1330 | xor edi, edi |
1331 | xor edi, edi |
1331 | display_number_force: |
1332 | display_number_force: |
1332 | push eax |
1333 | push eax |
1333 | and eax, 0x3fffffff |
1334 | and eax, 0x3fffffff |
1334 | cmp eax, 0xffff ; length > 0 ? |
1335 | cmp eax, 0xffff ; length > 0 ? |
1335 | pop eax |
1336 | pop eax |
1336 | jge cont_displ |
1337 | jge cont_displ |
1337 | ret |
1338 | ret |
1338 | cont_displ: |
1339 | cont_displ: |
1339 | push eax |
1340 | push eax |
1340 | and eax, 0x3fffffff |
1341 | and eax, 0x3fffffff |
1341 | cmp eax, 61*0x10000 ; length <= 60 ? |
1342 | cmp eax, 61*0x10000 ; length <= 60 ? |
1342 | pop eax |
1343 | pop eax |
1343 | jb cont_displ2 |
1344 | jb cont_displ2 |
1344 | ret |
1345 | ret |
1345 | cont_displ2: |
1346 | cont_displ2: |
1346 | 1347 | ||
1347 | pushad |
1348 | pushad |
1348 | 1349 | ||
1349 | cmp al, 1 ; ecx is a pointer ? |
1350 | cmp al, 1 ; ecx is a pointer ? |
1350 | jne displnl1 |
1351 | jne displnl1 |
1351 | mov ebp, ebx |
1352 | mov ebp, ebx |
1352 | add ebp, 4 |
1353 | add ebp, 4 |
1353 | mov ebp, [ebp+std_application_base_address] |
1354 | mov ebp, [ebp+std_application_base_address] |
1354 | mov ebx, [ebx+std_application_base_address] |
1355 | mov ebx, [ebx+std_application_base_address] |
1355 | displnl1: |
1356 | displnl1: |
1356 | sub esp, 64 |
1357 | sub esp, 64 |
1357 | 1358 | ||
1358 | test ah, ah ; DECIMAL |
1359 | test ah, ah ; DECIMAL |
1359 | jnz no_display_desnum |
1360 | jnz no_display_desnum |
1360 | shr eax, 16 |
1361 | shr eax, 16 |
1361 | and eax, 0xC03f |
1362 | and eax, 0xC03f |
1362 | ; and eax,0x3f |
1363 | ; and eax,0x3f |
1363 | push eax |
1364 | push eax |
1364 | and eax, 0x3f |
1365 | and eax, 0x3f |
1365 | mov edi, esp |
1366 | mov edi, esp |
1366 | add edi, 4+64-1 |
1367 | add edi, 4+64-1 |
1367 | mov ecx, eax |
1368 | mov ecx, eax |
1368 | mov eax, ebx |
1369 | mov eax, ebx |
1369 | mov ebx, 10 |
1370 | mov ebx, 10 |
1370 | d_desnum: |
1371 | d_desnum: |
1371 | xor edx, edx |
1372 | xor edx, edx |
1372 | call division_64_bits |
1373 | call division_64_bits |
1373 | div ebx |
1374 | div ebx |
1374 | add dl, 48 |
1375 | add dl, 48 |
1375 | mov [edi], dl |
1376 | mov [edi], dl |
1376 | dec edi |
1377 | dec edi |
1377 | loop d_desnum |
1378 | loop d_desnum |
1378 | pop eax |
1379 | pop eax |
1379 | call normalize_number |
1380 | call normalize_number |
1380 | call draw_num_text |
1381 | call draw_num_text |
1381 | add esp, 64 |
1382 | add esp, 64 |
1382 | popad |
1383 | popad |
1383 | ret |
1384 | ret |
1384 | no_display_desnum: |
1385 | no_display_desnum: |
1385 | 1386 | ||
1386 | cmp ah, 0x01 ; HEXADECIMAL |
1387 | cmp ah, 0x01 ; HEXADECIMAL |
1387 | jne no_display_hexnum |
1388 | jne no_display_hexnum |
1388 | shr eax, 16 |
1389 | shr eax, 16 |
1389 | and eax, 0xC03f |
1390 | and eax, 0xC03f |
1390 | ; and eax,0x3f |
1391 | ; and eax,0x3f |
1391 | push eax |
1392 | push eax |
1392 | and eax, 0x3f |
1393 | and eax, 0x3f |
1393 | mov edi, esp |
1394 | mov edi, esp |
1394 | add edi, 4+64-1 |
1395 | add edi, 4+64-1 |
1395 | mov ecx, eax |
1396 | mov ecx, eax |
1396 | mov eax, ebx |
1397 | mov eax, ebx |
1397 | mov ebx, 16 |
1398 | mov ebx, 16 |
1398 | d_hexnum: |
1399 | d_hexnum: |
1399 | xor edx, edx |
1400 | xor edx, edx |
1400 | call division_64_bits |
1401 | call division_64_bits |
1401 | div ebx |
1402 | div ebx |
1402 | hexletters = __fdo_hexdigits |
1403 | hexletters = __fdo_hexdigits |
1403 | add edx, hexletters |
1404 | add edx, hexletters |
1404 | mov dl, [edx] |
1405 | mov dl, [edx] |
1405 | mov [edi], dl |
1406 | mov [edi], dl |
1406 | dec edi |
1407 | dec edi |
1407 | loop d_hexnum |
1408 | loop d_hexnum |
1408 | pop eax |
1409 | pop eax |
1409 | call normalize_number |
1410 | call normalize_number |
1410 | call draw_num_text |
1411 | call draw_num_text |
1411 | add esp, 64 |
1412 | add esp, 64 |
1412 | popad |
1413 | popad |
1413 | ret |
1414 | ret |
1414 | no_display_hexnum: |
1415 | no_display_hexnum: |
1415 | 1416 | ||
1416 | cmp ah, 0x02 ; BINARY |
1417 | cmp ah, 0x02 ; BINARY |
1417 | jne no_display_binnum |
1418 | jne no_display_binnum |
1418 | shr eax, 16 |
1419 | shr eax, 16 |
1419 | and eax, 0xC03f |
1420 | and eax, 0xC03f |
1420 | ; and eax,0x3f |
1421 | ; and eax,0x3f |
1421 | push eax |
1422 | push eax |
1422 | and eax, 0x3f |
1423 | and eax, 0x3f |
1423 | mov edi, esp |
1424 | mov edi, esp |
1424 | add edi, 4+64-1 |
1425 | add edi, 4+64-1 |
1425 | mov ecx, eax |
1426 | mov ecx, eax |
1426 | mov eax, ebx |
1427 | mov eax, ebx |
1427 | mov ebx, 2 |
1428 | mov ebx, 2 |
1428 | d_binnum: |
1429 | d_binnum: |
1429 | xor edx, edx |
1430 | xor edx, edx |
1430 | call division_64_bits |
1431 | call division_64_bits |
1431 | div ebx |
1432 | div ebx |
1432 | add dl, 48 |
1433 | add dl, 48 |
1433 | mov [edi], dl |
1434 | mov [edi], dl |
1434 | dec edi |
1435 | dec edi |
1435 | loop d_binnum |
1436 | loop d_binnum |
1436 | pop eax |
1437 | pop eax |
1437 | call normalize_number |
1438 | call normalize_number |
1438 | call draw_num_text |
1439 | call draw_num_text |
1439 | add esp, 64 |
1440 | add esp, 64 |
1440 | popad |
1441 | popad |
1441 | ret |
1442 | ret |
1442 | no_display_binnum: |
1443 | no_display_binnum: |
1443 | 1444 | ||
1444 | add esp, 64 |
1445 | add esp, 64 |
1445 | popad |
1446 | popad |
1446 | ret |
1447 | ret |
1447 | 1448 | ||
1448 | normalize_number: |
1449 | normalize_number: |
1449 | test ah, 0x80 |
1450 | test ah, 0x80 |
1450 | jz .continue |
1451 | jz .continue |
1451 | mov ecx, 48 |
1452 | mov ecx, 48 |
1452 | and eax, 0x3f |
1453 | and eax, 0x3f |
1453 | @@: |
1454 | @@: |
1454 | inc edi |
1455 | inc edi |
1455 | cmp [edi], cl |
1456 | cmp [edi], cl |
1456 | jne .continue |
1457 | jne .continue |
1457 | dec eax |
1458 | dec eax |
1458 | cmp eax, 1 |
1459 | cmp eax, 1 |
1459 | ja @r |
1460 | ja @r |
1460 | mov al, 1 |
1461 | mov al, 1 |
1461 | .continue: |
1462 | .continue: |
1462 | and eax, 0x3f |
1463 | and eax, 0x3f |
1463 | ret |
1464 | ret |
1464 | 1465 | ||
1465 | division_64_bits: |
1466 | division_64_bits: |
1466 | test [esp+1+4], byte 0x40 |
1467 | test [esp+1+4], byte 0x40 |
1467 | jz .continue |
1468 | jz .continue |
1468 | push eax |
1469 | push eax |
1469 | mov eax, ebp |
1470 | mov eax, ebp |
1470 | div ebx |
1471 | div ebx |
1471 | mov ebp, eax |
1472 | mov ebp, eax |
1472 | pop eax |
1473 | pop eax |
1473 | .continue: |
1474 | .continue: |
1474 | ret |
1475 | ret |
1475 | 1476 | ||
1476 | draw_num_text: |
1477 | draw_num_text: |
1477 | mov esi, eax |
1478 | mov esi, eax |
1478 | mov edx, 64+4 |
1479 | mov edx, 64+4 |
1479 | sub edx, eax |
1480 | sub edx, eax |
1480 | add edx, esp |
1481 | add edx, esp |
1481 | mov ebx, [esp+64+32-8+4] |
1482 | mov ebx, [esp+64+32-8+4] |
1482 | ; add window start x & y |
1483 | ; add window start x & y |
1483 | mov ecx, [TASK_BASE] |
1484 | mov ecx, [TASK_BASE] |
1484 | 1485 | ||
1485 | mov edi, [CURRENT_TASK] |
1486 | mov edi, [CURRENT_TASK] |
1486 | shl edi, 8 |
1487 | shl edi, 8 |
1487 | 1488 | ||
1488 | mov eax, [ecx-twdw+WDATA.box.left] |
1489 | mov eax, [ecx-twdw+WDATA.box.left] |
1489 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1490 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1490 | shl eax, 16 |
1491 | shl eax, 16 |
1491 | add eax, [ecx-twdw+WDATA.box.top] |
1492 | add eax, [ecx-twdw+WDATA.box.top] |
1492 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1493 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1493 | add ebx, eax |
1494 | add ebx, eax |
1494 | mov ecx, [esp+64+32-12+4] |
1495 | mov ecx, [esp+64+32-12+4] |
1495 | and ecx, not 0x80000000 ; force counted string |
1496 | and ecx, not 0x80000000 ; force counted string |
1496 | mov eax, [esp+64+8] ; background color (if given) |
1497 | mov eax, [esp+64+8] ; background color (if given) |
1497 | mov edi, [esp+64+4] |
1498 | mov edi, [esp+64+4] |
1498 | jmp dtext |
1499 | jmp dtext |
1499 | 1500 | ||
1500 | align 4 |
1501 | align 4 |
1501 | 1502 | ||
1502 | sys_setup: |
1503 | sys_setup: |
1503 | 1504 | ||
1504 | ; 1=roland mpu midi base , base io address |
1505 | ; 1=roland mpu midi base , base io address |
1505 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1506 | ; 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 |
1507 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1507 | ; 5=system language, 1eng 2fi 3ger 4rus |
1508 | ; 5=system language, 1eng 2fi 3ger 4rus |
1508 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1509 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1509 | ; 8=fat32 partition in hd |
1510 | ; 8=fat32 partition in hd |
1510 | ; 9 |
1511 | ; 9 |
1511 | ; 10 = sound dma channel |
1512 | ; 10 = sound dma channel |
1512 | ; 11 = enable lba read |
1513 | ; 11 = enable lba read |
1513 | ; 12 = enable pci access |
1514 | ; 12 = enable pci access |
1514 | 1515 | ||
1515 | 1516 | ||
1516 | and [esp+32], dword 0 |
1517 | and [esp+32], dword 0 |
1517 | dec ebx ; MIDI |
1518 | dec ebx ; MIDI |
1518 | jnz nsyse1 |
1519 | jnz nsyse1 |
1519 | cmp ecx, 0x100 |
1520 | cmp ecx, 0x100 |
1520 | 1521 | ||
1521 | jb nsyse1 |
1522 | jb nsyse1 |
1522 | mov esi, 65535 |
1523 | mov esi, 65535 |
1523 | cmp esi, ecx |
1524 | cmp esi, ecx |
1524 | 1525 | ||
1525 | jb nsyse1 |
1526 | jb nsyse1 |
1526 | mov [midi_base], cx ;bx |
1527 | mov [midi_base], cx ;bx |
1527 | mov word [mididp], cx;bx |
1528 | mov word [mididp], cx;bx |
1528 | inc cx ;bx |
1529 | inc cx ;bx |
1529 | mov word [midisp], cx;bx |
1530 | mov word [midisp], cx;bx |
1530 | ret |
1531 | ret |
1531 | 1532 | ||
1532 | iglobal |
1533 | iglobal |
1533 | midi_base dw 0 |
1534 | midi_base dw 0 |
1534 | endg |
1535 | endg |
1535 | 1536 | ||
1536 | nsyse1: |
1537 | nsyse1: |
1537 | dec ebx ; KEYBOARD |
1538 | dec ebx ; KEYBOARD |
1538 | jnz nsyse2 |
1539 | jnz nsyse2 |
1539 | mov edi, [TASK_BASE] |
1540 | mov edi, [TASK_BASE] |
1540 | mov eax, [edi+TASKDATA.mem_start] |
1541 | mov eax, [edi+TASKDATA.mem_start] |
1541 | add eax, edx |
1542 | add eax, edx |
1542 | 1543 | ||
1543 | dec ecx |
1544 | dec ecx |
1544 | jnz kbnobase |
1545 | jnz kbnobase |
1545 | mov ebx, keymap |
1546 | mov ebx, keymap |
1546 | mov ecx, 128 |
1547 | mov ecx, 128 |
1547 | call memmove |
1548 | call memmove |
1548 | ret |
1549 | ret |
1549 | kbnobase: |
1550 | kbnobase: |
1550 | dec ecx |
1551 | dec ecx |
1551 | jnz kbnoshift |
1552 | jnz kbnoshift |
1552 | 1553 | ||
1553 | mov ebx, keymap_shift |
1554 | mov ebx, keymap_shift |
1554 | mov ecx, 128 |
1555 | mov ecx, 128 |
1555 | call memmove |
1556 | call memmove |
1556 | ret |
1557 | ret |
1557 | kbnoshift: |
1558 | kbnoshift: |
1558 | dec ecx |
1559 | dec ecx |
1559 | jnz kbnoalt |
1560 | jnz kbnoalt |
1560 | mov ebx, keymap_alt |
1561 | mov ebx, keymap_alt |
1561 | mov ecx, 128 |
1562 | mov ecx, 128 |
1562 | call memmove |
1563 | call memmove |
1563 | ret |
1564 | ret |
1564 | kbnoalt: |
1565 | kbnoalt: |
1565 | sub ecx, 6 |
1566 | sub ecx, 6 |
1566 | jnz kbnocountry |
1567 | jnz kbnocountry |
1567 | mov word [keyboard], dx |
1568 | mov word [keyboard], dx |
1568 | ret |
1569 | ret |
1569 | kbnocountry: |
1570 | kbnocountry: |
1570 | mov [esp+32], dword 1 |
1571 | mov [esp+32], dword 1 |
1571 | ret |
1572 | ret |
1572 | nsyse2: |
1573 | nsyse2: |
1573 | dec ebx ; CD |
1574 | dec ebx ; CD |
1574 | jnz nsyse4 |
1575 | jnz nsyse4 |
1575 | 1576 | ||
1576 | test ecx, ecx |
1577 | test ecx, ecx |
1577 | jz nosesl |
1578 | jz nosesl |
1578 | 1579 | ||
1579 | cmp ecx, 4 |
1580 | cmp ecx, 4 |
1580 | ja nosesl |
1581 | ja nosesl |
1581 | mov [cd_base], cl |
1582 | mov [cd_base], cl |
1582 | 1583 | ||
1583 | dec ecx |
1584 | dec ecx |
1584 | jnz noprma |
1585 | jnz noprma |
1585 | mov [cdbase], 0x1f0 |
1586 | mov [cdbase], 0x1f0 |
1586 | mov [cdid], 0xa0 |
1587 | mov [cdid], 0xa0 |
1587 | noprma: |
1588 | noprma: |
1588 | 1589 | ||
1589 | dec ecx |
1590 | dec ecx |
1590 | jnz noprsl |
1591 | jnz noprsl |
1591 | mov [cdbase], 0x1f0 |
1592 | mov [cdbase], 0x1f0 |
1592 | mov [cdid], 0xb0 |
1593 | mov [cdid], 0xb0 |
1593 | noprsl: |
1594 | noprsl: |
1594 | dec ecx |
1595 | dec ecx |
1595 | jnz nosema |
1596 | jnz nosema |
1596 | mov [cdbase], 0x170 |
1597 | mov [cdbase], 0x170 |
1597 | mov [cdid], 0xa0 |
1598 | mov [cdid], 0xa0 |
1598 | nosema: |
1599 | nosema: |
1599 | dec ecx |
1600 | dec ecx |
1600 | jnz nosesl |
1601 | jnz nosesl |
1601 | mov [cdbase], 0x170 |
1602 | mov [cdbase], 0x170 |
1602 | mov [cdid], 0xb0 |
1603 | mov [cdid], 0xb0 |
1603 | nosesl: |
1604 | nosesl: |
1604 | ret |
1605 | ret |
1605 | 1606 | ||
1606 | iglobal |
1607 | iglobal |
1607 | cd_base db 0 |
1608 | cd_base db 0 |
1608 | 1609 | ||
1609 | endg |
1610 | endg |
1610 | nsyse4: |
1611 | nsyse4: |
1611 | 1612 | ||
1612 | sub ebx, 2 ; SYSTEM LANGUAGE |
1613 | sub ebx, 2 ; SYSTEM LANGUAGE |
1613 | jnz nsyse5 |
1614 | jnz nsyse5 |
1614 | mov [syslang], ecx |
1615 | mov [syslang], ecx |
1615 | ret |
1616 | ret |
1616 | nsyse5: |
1617 | nsyse5: |
1617 | 1618 | ||
1618 | sub ebx, 2 ; HD BASE |
1619 | sub ebx, 2 ; HD BASE |
1619 | jnz nsyse7 |
1620 | jnz nsyse7 |
1620 | 1621 | ||
1621 | test ecx, ecx |
1622 | test ecx, ecx |
1622 | jz nosethd |
1623 | jz nosethd |
1623 | 1624 | ||
1624 | cmp ecx, 4 |
1625 | cmp ecx, 4 |
1625 | ja nosethd |
1626 | ja nosethd |
1626 | mov [hd_base], cl |
1627 | mov [hd_base], cl |
1627 | 1628 | ||
1628 | cmp ecx, 1 |
1629 | cmp ecx, 1 |
1629 | jnz noprmahd |
1630 | jnz noprmahd |
1630 | mov [hdbase], 0x1f0 |
1631 | mov [hdbase], 0x1f0 |
1631 | and dword [hdid], 0x0 |
1632 | and dword [hdid], 0x0 |
1632 | mov dword [hdpos], ecx |
1633 | mov dword [hdpos], ecx |
1633 | ; call set_FAT32_variables |
1634 | ; call set_FAT32_variables |
1634 | noprmahd: |
1635 | noprmahd: |
1635 | 1636 | ||
1636 | cmp ecx, 2 |
1637 | cmp ecx, 2 |
1637 | jnz noprslhd |
1638 | jnz noprslhd |
1638 | mov [hdbase], 0x1f0 |
1639 | mov [hdbase], 0x1f0 |
1639 | mov [hdid], 0x10 |
1640 | mov [hdid], 0x10 |
1640 | mov dword [hdpos], ecx |
1641 | mov dword [hdpos], ecx |
1641 | ; call set_FAT32_variables |
1642 | ; call set_FAT32_variables |
1642 | noprslhd: |
1643 | noprslhd: |
1643 | 1644 | ||
1644 | cmp ecx, 3 |
1645 | cmp ecx, 3 |
1645 | jnz nosemahd |
1646 | jnz nosemahd |
1646 | mov [hdbase], 0x170 |
1647 | mov [hdbase], 0x170 |
1647 | and dword [hdid], 0x0 |
1648 | and dword [hdid], 0x0 |
1648 | mov dword [hdpos], ecx |
1649 | mov dword [hdpos], ecx |
1649 | ; call set_FAT32_variables |
1650 | ; call set_FAT32_variables |
1650 | nosemahd: |
1651 | nosemahd: |
1651 | 1652 | ||
1652 | cmp ecx, 4 |
1653 | cmp ecx, 4 |
1653 | jnz noseslhd |
1654 | jnz noseslhd |
1654 | mov [hdbase], 0x170 |
1655 | mov [hdbase], 0x170 |
1655 | mov [hdid], 0x10 |
1656 | mov [hdid], 0x10 |
1656 | mov dword [hdpos], ecx |
1657 | mov dword [hdpos], ecx |
1657 | ; call set_FAT32_variables |
1658 | ; call set_FAT32_variables |
1658 | noseslhd: |
1659 | noseslhd: |
1659 | call reserve_hd1 |
1660 | call reserve_hd1 |
1660 | call reserve_hd_channel |
1661 | call reserve_hd_channel |
1661 | call free_hd_channel |
1662 | call free_hd_channel |
1662 | and dword [hd1_status], 0 ; free |
1663 | and dword [hd1_status], 0 ; free |
1663 | nosethd: |
1664 | nosethd: |
1664 | ret |
1665 | ret |
1665 | 1666 | ||
1666 | iglobal |
1667 | iglobal |
1667 | hd_base db 0 |
1668 | hd_base db 0 |
1668 | endg |
1669 | endg |
1669 | 1670 | ||
1670 | nsyse7: |
1671 | nsyse7: |
1671 | 1672 | ||
1672 | ; cmp eax,8 ; HD PARTITION |
1673 | ; cmp eax,8 ; HD PARTITION |
1673 | dec ebx |
1674 | dec ebx |
1674 | jnz nsyse8 |
1675 | jnz nsyse8 |
1675 | mov [fat32part], ecx |
1676 | mov [fat32part], ecx |
1676 | ; call set_FAT32_variables |
1677 | ; call set_FAT32_variables |
1677 | call reserve_hd1 |
1678 | call reserve_hd1 |
1678 | call reserve_hd_channel |
1679 | call reserve_hd_channel |
1679 | call free_hd_channel |
1680 | call free_hd_channel |
1680 | ; pusha |
1681 | ; pusha |
1681 | call choice_necessity_partition_1 |
1682 | call choice_necessity_partition_1 |
1682 | ; popa |
1683 | ; popa |
1683 | and dword [hd1_status], 0 ; free |
1684 | and dword [hd1_status], 0 ; free |
1684 | ret |
1685 | ret |
1685 | 1686 | ||
1686 | nsyse8: |
1687 | nsyse8: |
1687 | ; cmp eax,11 ; ENABLE LBA READ |
1688 | ; cmp eax,11 ; ENABLE LBA READ |
1688 | and ecx, 1 |
1689 | and ecx, 1 |
1689 | sub ebx, 3 |
1690 | sub ebx, 3 |
1690 | jnz no_set_lba_read |
1691 | jnz no_set_lba_read |
1691 | mov [lba_read_enabled], ecx |
1692 | mov [lba_read_enabled], ecx |
1692 | ret |
1693 | ret |
1693 | 1694 | ||
1694 | no_set_lba_read: |
1695 | no_set_lba_read: |
1695 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1696 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1696 | dec ebx |
1697 | dec ebx |
1697 | jnz sys_setup_err |
1698 | jnz sys_setup_err |
1698 | mov [pci_access_enabled], ecx |
1699 | mov [pci_access_enabled], ecx |
1699 | ret |
1700 | ret |
1700 | 1701 | ||
1701 | sys_setup_err: |
1702 | sys_setup_err: |
1702 | or [esp+32], dword -1 |
1703 | or [esp+32], dword -1 |
1703 | ret |
1704 | ret |
1704 | 1705 | ||
1705 | align 4 |
1706 | align 4 |
1706 | 1707 | ||
1707 | sys_getsetup: |
1708 | sys_getsetup: |
1708 | 1709 | ||
1709 | ; 1=roland mpu midi base , base io address |
1710 | ; 1=roland mpu midi base , base io address |
1710 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1711 | ; 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 |
1712 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1712 | ; 5=system language, 1eng 2fi 3ger 4rus |
1713 | ; 5=system language, 1eng 2fi 3ger 4rus |
1713 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1714 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1714 | ; 8=fat32 partition in hd |
1715 | ; 8=fat32 partition in hd |
1715 | ; 9=get hs timer tic |
1716 | ; 9=get hs timer tic |
1716 | 1717 | ||
1717 | ; cmp eax,1 |
1718 | ; cmp eax,1 |
1718 | dec ebx |
1719 | dec ebx |
1719 | jnz ngsyse1 |
1720 | jnz ngsyse1 |
1720 | movzx eax, [midi_base] |
1721 | movzx eax, [midi_base] |
1721 | mov [esp+32], eax |
1722 | mov [esp+32], eax |
1722 | ret |
1723 | ret |
1723 | ngsyse1: |
1724 | ngsyse1: |
1724 | ; cmp eax,2 |
1725 | ; cmp eax,2 |
1725 | dec ebx |
1726 | dec ebx |
1726 | jnz ngsyse2 |
1727 | jnz ngsyse2 |
1727 | 1728 | ||
1728 | mov edi, [TASK_BASE] |
1729 | mov edi, [TASK_BASE] |
1729 | mov ebx, [edi+TASKDATA.mem_start] |
1730 | mov ebx, [edi+TASKDATA.mem_start] |
1730 | add ebx, edx |
1731 | add ebx, edx |
1731 | 1732 | ||
1732 | ; cmp ebx,1 |
1733 | ; cmp ebx,1 |
1733 | dec ecx |
1734 | dec ecx |
1734 | jnz kbnobaseret |
1735 | jnz kbnobaseret |
1735 | mov eax, keymap |
1736 | mov eax, keymap |
1736 | mov ecx, 128 |
1737 | mov ecx, 128 |
1737 | call memmove |
1738 | call memmove |
1738 | ret |
1739 | ret |
1739 | kbnobaseret: |
1740 | kbnobaseret: |
1740 | ; cmp ebx,2 |
1741 | ; cmp ebx,2 |
1741 | dec ecx |
1742 | dec ecx |
1742 | jnz kbnoshiftret |
1743 | jnz kbnoshiftret |
1743 | 1744 | ||
1744 | mov eax, keymap_shift |
1745 | mov eax, keymap_shift |
1745 | mov ecx, 128 |
1746 | mov ecx, 128 |
1746 | call memmove |
1747 | call memmove |
1747 | ret |
1748 | ret |
1748 | kbnoshiftret: |
1749 | kbnoshiftret: |
1749 | ; cmp ebx,3 |
1750 | ; cmp ebx,3 |
1750 | dec ecx |
1751 | dec ecx |
1751 | jne kbnoaltret |
1752 | jne kbnoaltret |
1752 | 1753 | ||
1753 | mov eax, keymap_alt |
1754 | mov eax, keymap_alt |
1754 | mov ecx, 128 |
1755 | mov ecx, 128 |
1755 | call memmove |
1756 | call memmove |
1756 | ret |
1757 | ret |
1757 | kbnoaltret: |
1758 | kbnoaltret: |
1758 | ; cmp ebx,9 |
1759 | ; cmp ebx,9 |
1759 | sub ecx, 6 |
1760 | sub ecx, 6 |
1760 | jnz ngsyse2 |
1761 | jnz ngsyse2 |
1761 | movzx eax, word [keyboard] |
1762 | movzx eax, word [keyboard] |
1762 | mov [esp+32], eax |
1763 | mov [esp+32], eax |
1763 | ret |
1764 | ret |
1764 | 1765 | ||
1765 | 1766 | ||
1766 | ngsyse2: |
1767 | ngsyse2: |
1767 | ; cmp eax,3 |
1768 | ; cmp eax,3 |
1768 | dec ebx |
1769 | dec ebx |
1769 | jnz ngsyse3 |
1770 | jnz ngsyse3 |
1770 | movzx eax, [cd_base] |
1771 | movzx eax, [cd_base] |
1771 | mov [esp+32], eax |
1772 | mov [esp+32], eax |
1772 | ret |
1773 | ret |
1773 | ngsyse3: |
1774 | ngsyse3: |
1774 | ; cmp eax,5 |
1775 | ; cmp eax,5 |
1775 | sub ebx, 2 |
1776 | sub ebx, 2 |
1776 | jnz ngsyse5 |
1777 | jnz ngsyse5 |
1777 | mov eax, [syslang] |
1778 | mov eax, [syslang] |
1778 | mov [esp+32], eax |
1779 | mov [esp+32], eax |
1779 | ret |
1780 | ret |
1780 | ngsyse5: |
1781 | ngsyse5: |
1781 | ; cmp eax,7 |
1782 | ; cmp eax,7 |
1782 | sub ebx, 2 |
1783 | sub ebx, 2 |
1783 | jnz ngsyse7 |
1784 | jnz ngsyse7 |
1784 | movzx eax, [hd_base] |
1785 | movzx eax, [hd_base] |
1785 | mov [esp+32], eax |
1786 | mov [esp+32], eax |
1786 | ret |
1787 | ret |
1787 | ngsyse7: |
1788 | ngsyse7: |
1788 | ; cmp eax,8 |
1789 | ; cmp eax,8 |
1789 | dec ebx |
1790 | dec ebx |
1790 | jnz ngsyse8 |
1791 | jnz ngsyse8 |
1791 | mov eax, [fat32part] |
1792 | mov eax, [fat32part] |
1792 | mov [esp+32], eax |
1793 | mov [esp+32], eax |
1793 | ret |
1794 | ret |
1794 | ngsyse8: |
1795 | ngsyse8: |
1795 | ; cmp eax,9 |
1796 | ; cmp eax,9 |
1796 | dec ebx |
1797 | dec ebx |
1797 | jnz ngsyse9 |
1798 | jnz ngsyse9 |
1798 | mov eax, [timer_ticks];[0xfdf0] |
1799 | mov eax, [timer_ticks];[0xfdf0] |
1799 | mov [esp+32], eax |
1800 | mov [esp+32], eax |
1800 | ret |
1801 | ret |
1801 | ngsyse9: |
1802 | ngsyse9: |
1802 | ; cmp eax,11 |
1803 | ; cmp eax,11 |
1803 | sub ebx, 2 |
1804 | sub ebx, 2 |
1804 | jnz ngsyse11 |
1805 | jnz ngsyse11 |
1805 | mov eax, [lba_read_enabled] |
1806 | mov eax, [lba_read_enabled] |
1806 | mov [esp+32], eax |
1807 | mov [esp+32], eax |
1807 | ret |
1808 | ret |
1808 | ngsyse11: |
1809 | ngsyse11: |
1809 | ; cmp eax,12 |
1810 | ; cmp eax,12 |
1810 | dec ebx |
1811 | dec ebx |
1811 | jnz ngsyse12 |
1812 | jnz ngsyse12 |
1812 | mov eax, [pci_access_enabled] |
1813 | mov eax, [pci_access_enabled] |
1813 | mov [esp+32], eax |
1814 | mov [esp+32], eax |
1814 | ret |
1815 | ret |
1815 | ngsyse12: |
1816 | ngsyse12: |
1816 | mov [esp+32], dword 1 |
1817 | mov [esp+32], dword 1 |
1817 | ret |
1818 | ret |
1818 | 1819 | ||
1819 | 1820 | ||
1820 | get_timer_ticks: |
1821 | get_timer_ticks: |
1821 | mov eax, [timer_ticks] |
1822 | mov eax, [timer_ticks] |
1822 | ret |
1823 | ret |
1823 | 1824 | ||
1824 | iglobal |
1825 | iglobal |
1825 | align 4 |
1826 | align 4 |
1826 | mousefn dd msscreen, mswin, msbutton, msset |
1827 | mousefn dd msscreen, mswin, msbutton, msset |
1827 | dd app_load_cursor |
1828 | dd app_load_cursor |
1828 | dd app_set_cursor |
1829 | dd app_set_cursor |
1829 | dd app_delete_cursor |
1830 | dd app_delete_cursor |
1830 | dd msz |
1831 | dd msz |
1831 | endg |
1832 | endg |
1832 | 1833 | ||
1833 | readmousepos: |
1834 | readmousepos: |
1834 | 1835 | ||
1835 | ; eax=0 screen relative |
1836 | ; eax=0 screen relative |
1836 | ; eax=1 window relative |
1837 | ; eax=1 window relative |
1837 | ; eax=2 buttons pressed |
1838 | ; eax=2 buttons pressed |
1838 | ; eax=3 set mouse pos ; reserved |
1839 | ; eax=3 set mouse pos ; reserved |
1839 | ; eax=4 load cursor |
1840 | ; eax=4 load cursor |
1840 | ; eax=5 set cursor |
1841 | ; eax=5 set cursor |
1841 | ; eax=6 delete cursor ; reserved |
1842 | ; eax=6 delete cursor ; reserved |
1842 | ; eax=7 get mouse_z |
1843 | ; eax=7 get mouse_z |
1843 | 1844 | ||
1844 | cmp ebx, 7 |
1845 | cmp ebx, 7 |
1845 | ja msset |
1846 | ja msset |
1846 | jmp [mousefn+ebx*4] |
1847 | jmp [mousefn+ebx*4] |
1847 | msscreen: |
1848 | msscreen: |
1848 | mov eax, [MOUSE_X] |
1849 | mov eax, [MOUSE_X] |
1849 | shl eax, 16 |
1850 | shl eax, 16 |
1850 | mov ax, [MOUSE_Y] |
1851 | mov ax, [MOUSE_Y] |
1851 | mov [esp+36-4], eax |
1852 | mov [esp+36-4], eax |
1852 | ret |
1853 | ret |
1853 | mswin: |
1854 | mswin: |
1854 | mov eax, [MOUSE_X] |
1855 | mov eax, [MOUSE_X] |
1855 | shl eax, 16 |
1856 | shl eax, 16 |
1856 | mov ax, [MOUSE_Y] |
1857 | mov ax, [MOUSE_Y] |
1857 | mov esi, [TASK_BASE] |
1858 | mov esi, [TASK_BASE] |
1858 | mov bx, word [esi-twdw+WDATA.box.left] |
1859 | mov bx, word [esi-twdw+WDATA.box.left] |
1859 | shl ebx, 16 |
1860 | shl ebx, 16 |
1860 | mov bx, word [esi-twdw+WDATA.box.top] |
1861 | mov bx, word [esi-twdw+WDATA.box.top] |
1861 | sub eax, ebx |
1862 | sub eax, ebx |
1862 | 1863 | ||
1863 | mov edi, [CURRENT_TASK] |
1864 | mov edi, [CURRENT_TASK] |
1864 | shl edi, 8 |
1865 | shl edi, 8 |
1865 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1866 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1866 | rol eax, 16 |
1867 | rol eax, 16 |
1867 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1868 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1868 | rol eax, 16 |
1869 | rol eax, 16 |
1869 | mov [esp+36-4], eax |
1870 | mov [esp+36-4], eax |
1870 | ret |
1871 | ret |
1871 | msbutton: |
1872 | msbutton: |
1872 | movzx eax, byte [BTN_DOWN] |
1873 | movzx eax, byte [BTN_DOWN] |
1873 | mov [esp+36-4], eax |
1874 | mov [esp+36-4], eax |
1874 | ret |
1875 | ret |
1875 | msz: |
1876 | msz: |
1876 | mov edi, [TASK_COUNT] |
1877 | mov edi, [TASK_COUNT] |
1877 | movzx edi, word [WIN_POS + edi*2] |
1878 | movzx edi, word [WIN_POS + edi*2] |
1878 | cmp edi, [CURRENT_TASK] |
1879 | cmp edi, [CURRENT_TASK] |
1879 | jne @f |
1880 | jne @f |
1880 | mov ax, [MOUSE_SCROLL_H] |
1881 | mov ax, [MOUSE_SCROLL_H] |
1881 | shl eax, 16 |
1882 | shl eax, 16 |
1882 | mov ax, [MOUSE_SCROLL_V] |
1883 | mov ax, [MOUSE_SCROLL_V] |
1883 | mov [esp+36-4], eax |
1884 | mov [esp+36-4], eax |
1884 | and [MOUSE_SCROLL_H], word 0 |
1885 | and [MOUSE_SCROLL_H], word 0 |
1885 | and [MOUSE_SCROLL_V], word 0 |
1886 | and [MOUSE_SCROLL_V], word 0 |
1886 | ret |
1887 | ret |
1887 | @@: |
1888 | @@: |
1888 | and [esp+36-4], dword 0 |
1889 | and [esp+36-4], dword 0 |
1889 | ; ret |
1890 | ; ret |
1890 | msset: |
1891 | msset: |
1891 | ret |
1892 | ret |
1892 | 1893 | ||
1893 | app_load_cursor: |
1894 | app_load_cursor: |
1894 | cmp ecx, OS_BASE |
1895 | cmp ecx, OS_BASE |
1895 | jae msset |
1896 | jae msset |
1896 | stdcall load_cursor, ecx, edx |
1897 | stdcall load_cursor, ecx, edx |
1897 | mov [esp+36-4], eax |
1898 | mov [esp+36-4], eax |
1898 | ret |
1899 | ret |
1899 | 1900 | ||
1900 | app_set_cursor: |
1901 | app_set_cursor: |
1901 | stdcall set_cursor, ecx |
1902 | stdcall set_cursor, ecx |
1902 | mov [esp+36-4], eax |
1903 | mov [esp+36-4], eax |
1903 | ret |
1904 | ret |
1904 | 1905 | ||
1905 | app_delete_cursor: |
1906 | app_delete_cursor: |
1906 | stdcall delete_cursor, ecx |
1907 | stdcall delete_cursor, ecx |
1907 | mov [esp+36-4], eax |
1908 | mov [esp+36-4], eax |
1908 | ret |
1909 | ret |
1909 | 1910 | ||
1910 | is_input: |
1911 | is_input: |
1911 | 1912 | ||
1912 | push edx |
1913 | push edx |
1913 | mov dx, word [midisp] |
1914 | mov dx, word [midisp] |
1914 | in al, dx |
1915 | in al, dx |
1915 | and al, 0x80 |
1916 | and al, 0x80 |
1916 | pop edx |
1917 | pop edx |
1917 | ret |
1918 | ret |
1918 | 1919 | ||
1919 | is_output: |
1920 | is_output: |
1920 | 1921 | ||
1921 | push edx |
1922 | push edx |
1922 | mov dx, word [midisp] |
1923 | mov dx, word [midisp] |
1923 | in al, dx |
1924 | in al, dx |
1924 | and al, 0x40 |
1925 | and al, 0x40 |
1925 | pop edx |
1926 | pop edx |
1926 | ret |
1927 | ret |
1927 | 1928 | ||
1928 | 1929 | ||
1929 | get_mpu_in: |
1930 | get_mpu_in: |
1930 | 1931 | ||
1931 | push edx |
1932 | push edx |
1932 | mov dx, word [mididp] |
1933 | mov dx, word [mididp] |
1933 | in al, dx |
1934 | in al, dx |
1934 | pop edx |
1935 | pop edx |
1935 | ret |
1936 | ret |
1936 | 1937 | ||
1937 | 1938 | ||
1938 | put_mpu_out: |
1939 | put_mpu_out: |
1939 | 1940 | ||
1940 | push edx |
1941 | push edx |
1941 | mov dx, word [mididp] |
1942 | mov dx, word [mididp] |
1942 | out dx, al |
1943 | out dx, al |
1943 | pop edx |
1944 | pop edx |
1944 | ret |
1945 | ret |
1945 | 1946 | ||
1946 | 1947 | ||
1947 | 1948 | ||
1948 | align 4 |
1949 | align 4 |
1949 | 1950 | ||
1950 | sys_midi: |
1951 | sys_midi: |
1951 | cmp [mididp], 0 |
1952 | cmp [mididp], 0 |
1952 | jnz sm0 |
1953 | jnz sm0 |
1953 | mov [esp+36], dword 1 |
1954 | mov [esp+36], dword 1 |
1954 | ret |
1955 | ret |
1955 | sm0: |
1956 | sm0: |
1956 | and [esp+36], dword 0 |
1957 | and [esp+36], dword 0 |
1957 | dec ebx |
1958 | dec ebx |
1958 | jnz smn1 |
1959 | jnz smn1 |
1959 | ; call setuart |
1960 | ; call setuart |
1960 | su1: |
1961 | su1: |
1961 | call is_output |
1962 | call is_output |
1962 | test al, al |
1963 | test al, al |
1963 | jnz su1 |
1964 | jnz su1 |
1964 | mov dx, word [midisp] |
1965 | mov dx, word [midisp] |
1965 | mov al, 0xff |
1966 | mov al, 0xff |
1966 | out dx, al |
1967 | out dx, al |
1967 | su2: |
1968 | su2: |
1968 | mov dx, word [midisp] |
1969 | mov dx, word [midisp] |
1969 | mov al, 0xff |
1970 | mov al, 0xff |
1970 | out dx, al |
1971 | out dx, al |
1971 | call is_input |
1972 | call is_input |
1972 | test al, al |
1973 | test al, al |
1973 | jnz su2 |
1974 | jnz su2 |
1974 | call get_mpu_in |
1975 | call get_mpu_in |
1975 | cmp al, 0xfe |
1976 | cmp al, 0xfe |
1976 | jnz su2 |
1977 | jnz su2 |
1977 | su3: |
1978 | su3: |
1978 | call is_output |
1979 | call is_output |
1979 | test al, al |
1980 | test al, al |
1980 | jnz su3 |
1981 | jnz su3 |
1981 | mov dx, word [midisp] |
1982 | mov dx, word [midisp] |
1982 | mov al, 0x3f |
1983 | mov al, 0x3f |
1983 | out dx, al |
1984 | out dx, al |
1984 | ret |
1985 | ret |
1985 | smn1: |
1986 | smn1: |
1986 | dec ebx |
1987 | dec ebx |
1987 | jnz smn2 |
1988 | jnz smn2 |
1988 | sm10: |
1989 | sm10: |
1989 | call get_mpu_in |
1990 | call get_mpu_in |
1990 | call is_output |
1991 | call is_output |
1991 | test al, al |
1992 | test al, al |
1992 | jnz sm10 |
1993 | jnz sm10 |
1993 | mov al, bl |
1994 | mov al, bl |
1994 | call put_mpu_out |
1995 | call put_mpu_out |
1995 | smn2: |
1996 | smn2: |
1996 | ret |
1997 | ret |
1997 | 1998 | ||
1998 | detect_devices: |
1999 | detect_devices: |
1999 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2000 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2000 | ;include 'detect/commouse.inc' |
2001 | ;include 'detect/commouse.inc' |
2001 | ;include 'detect/ps2mouse.inc' |
2002 | ;include 'detect/ps2mouse.inc' |
2002 | ;include 'detect/dev_fd.inc' |
2003 | ;include 'detect/dev_fd.inc' |
2003 | ;include 'detect/dev_hdcd.inc' |
2004 | ;include 'detect/dev_hdcd.inc' |
2004 | ;include 'detect/sear_par.inc' |
2005 | ;include 'detect/sear_par.inc' |
2005 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2006 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2006 | ret |
2007 | ret |
2007 | 2008 | ||
2008 | sys_end: |
2009 | sys_end: |
2009 | ;-------------------------------------- |
2010 | ;-------------------------------------- |
2010 | cmp [_display.select_cursor], 0 |
2011 | cmp [_display.select_cursor], 0 |
2011 | je @f |
2012 | je @f |
2012 | ; restore default cursor before killing |
2013 | ; restore default cursor before killing |
2013 | pusha |
2014 | pusha |
2014 | mov ecx, [current_slot] |
2015 | mov ecx, [current_slot] |
2015 | call restore_default_cursor_before_killing |
2016 | call restore_default_cursor_before_killing |
2016 | popa |
2017 | popa |
2017 | @@: |
2018 | @@: |
2018 | ;-------------------------------------- |
2019 | ;-------------------------------------- |
2019 | ; kill all sockets this process owns |
2020 | ; kill all sockets this process owns |
2020 | pusha |
2021 | pusha |
2021 | mov edx, [TASK_BASE] |
2022 | mov edx, [TASK_BASE] |
2022 | mov edx, [edx+TASKDATA.pid] |
2023 | mov edx, [edx+TASKDATA.pid] |
2023 | call SOCKET_process_end |
2024 | call SOCKET_process_end |
2024 | popa |
2025 | popa |
2025 | ;-------------------------------------- |
2026 | ;-------------------------------------- |
2026 | mov ecx, [current_slot] |
2027 | mov ecx, [current_slot] |
2027 | mov eax, [ecx+APPDATA.tls_base] |
2028 | mov eax, [ecx+APPDATA.tls_base] |
2028 | test eax, eax |
2029 | test eax, eax |
2029 | jz @F |
2030 | jz @F |
2030 | 2031 | ||
2031 | stdcall user_free, eax |
2032 | stdcall user_free, eax |
2032 | @@: |
2033 | @@: |
2033 | 2034 | ||
2034 | mov eax, [TASK_BASE] |
2035 | mov eax, [TASK_BASE] |
2035 | mov [eax+TASKDATA.state], 3; terminate this program |
2036 | mov [eax+TASKDATA.state], 3; terminate this program |
2036 | call wakeup_osloop |
2037 | call wakeup_osloop |
2037 | 2038 | ||
2038 | .waitterm: ; wait here for termination |
2039 | .waitterm: ; wait here for termination |
2039 | call change_task |
2040 | call change_task |
2040 | jmp .waitterm |
2041 | jmp .waitterm |
2041 | ;------------------------------------------------------------------------------ |
2042 | ;------------------------------------------------------------------------------ |
2042 | align 4 |
2043 | align 4 |
2043 | restore_default_cursor_before_killing: |
2044 | restore_default_cursor_before_killing: |
2044 | pushfd |
2045 | pushfd |
2045 | cli |
2046 | cli |
2046 | mov eax, [def_cursor] |
2047 | mov eax, [def_cursor] |
2047 | mov [ecx+APPDATA.cursor], eax |
2048 | mov [ecx+APPDATA.cursor], eax |
2048 | 2049 | ||
2049 | movzx eax, word [MOUSE_Y] |
2050 | movzx eax, word [MOUSE_Y] |
2050 | movzx ebx, word [MOUSE_X] |
2051 | movzx ebx, word [MOUSE_X] |
2051 | ; mov ecx, [Screen_Max_X] |
2052 | ; mov ecx, [Screen_Max_X] |
2052 | ; inc ecx |
2053 | ; inc ecx |
2053 | ; mul ecx |
2054 | ; mul ecx |
2054 | mov eax, [d_width_calc_area + eax*4] |
2055 | mov eax, [d_width_calc_area + eax*4] |
2055 | 2056 | ||
2056 | add eax, [_WinMapAddress] |
2057 | add eax, [_WinMapAddress] |
2057 | movzx edx, byte [ebx+eax] |
2058 | movzx edx, byte [ebx+eax] |
2058 | shl edx, 8 |
2059 | shl edx, 8 |
2059 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2060 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2060 | 2061 | ||
2061 | cmp esi, [current_cursor] |
2062 | cmp esi, [current_cursor] |
2062 | je @f |
2063 | je @f |
2063 | 2064 | ||
2064 | push esi |
2065 | push esi |
2065 | call [_display.select_cursor] |
2066 | call [_display.select_cursor] |
2066 | mov [current_cursor], esi |
2067 | mov [current_cursor], esi |
2067 | @@: |
2068 | @@: |
2068 | mov [redrawmouse_unconditional], 1 |
2069 | mov [redrawmouse_unconditional], 1 |
2069 | call wakeup_osloop |
2070 | call wakeup_osloop |
2070 | popfd |
2071 | popfd |
2071 | ret |
2072 | ret |
2072 | ;------------------------------------------------------------------------------ |
2073 | ;------------------------------------------------------------------------------ |
2073 | iglobal |
2074 | iglobal |
2074 | align 4 |
2075 | align 4 |
2075 | sys_system_table: |
2076 | sys_system_table: |
2076 | dd sysfn_deactivate ; 1 = deactivate window |
2077 | dd sysfn_deactivate ; 1 = deactivate window |
2077 | dd sysfn_terminate ; 2 = terminate thread |
2078 | dd sysfn_terminate ; 2 = terminate thread |
2078 | dd sysfn_activate ; 3 = activate window |
2079 | dd sysfn_activate ; 3 = activate window |
2079 | dd sysfn_getidletime ; 4 = get idle time |
2080 | dd sysfn_getidletime ; 4 = get idle time |
2080 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2081 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2081 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2082 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2082 | dd sysfn_getactive ; 7 = get active window |
2083 | dd sysfn_getactive ; 7 = get active window |
2083 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2084 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2084 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2085 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2085 | dd sysfn_minimize ; 10 = minimize window |
2086 | dd sysfn_minimize ; 10 = minimize window |
2086 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2087 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2087 | dd sysfn_lastkey ; 12 = get last pressed key |
2088 | dd sysfn_lastkey ; 12 = get last pressed key |
2088 | dd sysfn_getversion ; 13 = get kernel version |
2089 | dd sysfn_getversion ; 13 = get kernel version |
2089 | dd sysfn_waitretrace ; 14 = wait retrace |
2090 | dd sysfn_waitretrace ; 14 = wait retrace |
2090 | dd sysfn_centermouse ; 15 = center mouse cursor |
2091 | dd sysfn_centermouse ; 15 = center mouse cursor |
2091 | dd sysfn_getfreemem ; 16 = get free memory size |
2092 | dd sysfn_getfreemem ; 16 = get free memory size |
2092 | dd sysfn_getallmem ; 17 = get total memory size |
2093 | dd sysfn_getallmem ; 17 = get total memory size |
2093 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2094 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2094 | ; instead of slot |
2095 | ; instead of slot |
2095 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2096 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2096 | dd sysfn_meminfo ; 20 = get extended memory info |
2097 | dd sysfn_meminfo ; 20 = get extended memory info |
2097 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2098 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2098 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2099 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2099 | dd sysfn_min_windows ; 23 = minimize all windows |
2100 | dd sysfn_min_windows ; 23 = minimize all windows |
2100 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2101 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2101 | sysfn_num = ($ - sys_system_table)/4 |
2102 | sysfn_num = ($ - sys_system_table)/4 |
2102 | endg |
2103 | endg |
2103 | ;------------------------------------------------------------------------------ |
2104 | ;------------------------------------------------------------------------------ |
2104 | sys_system: |
2105 | sys_system: |
2105 | dec ebx |
2106 | dec ebx |
2106 | cmp ebx, sysfn_num |
2107 | cmp ebx, sysfn_num |
2107 | jae @f |
2108 | jae @f |
2108 | jmp dword [sys_system_table + ebx*4] |
2109 | jmp dword [sys_system_table + ebx*4] |
2109 | @@: |
2110 | @@: |
2110 | ret |
2111 | ret |
2111 | ;------------------------------------------------------------------------------ |
2112 | ;------------------------------------------------------------------------------ |
2112 | sysfn_shutdown: ; 18.9 = system shutdown |
2113 | sysfn_shutdown: ; 18.9 = system shutdown |
2113 | cmp ecx, 1 |
2114 | cmp ecx, 1 |
2114 | jl exit_for_anyone |
2115 | jl exit_for_anyone |
2115 | cmp ecx, 4 |
2116 | cmp ecx, 4 |
2116 | jg exit_for_anyone |
2117 | jg exit_for_anyone |
2117 | mov [BOOT_VAR+0x9030], cl |
2118 | mov [BOOT_VAR+0x9030], cl |
2118 | 2119 | ||
2119 | mov eax, [TASK_COUNT] |
2120 | mov eax, [TASK_COUNT] |
2120 | mov [SYS_SHUTDOWN], al |
2121 | mov [SYS_SHUTDOWN], al |
2121 | mov [shutdown_processes], eax |
2122 | mov [shutdown_processes], eax |
2122 | call wakeup_osloop |
2123 | call wakeup_osloop |
2123 | and dword [esp+32], 0 |
2124 | and dword [esp+32], 0 |
2124 | exit_for_anyone: |
2125 | exit_for_anyone: |
2125 | ret |
2126 | ret |
2126 | uglobal |
2127 | uglobal |
2127 | shutdown_processes: |
2128 | shutdown_processes: |
2128 | dd 0x0 |
2129 | dd 0x0 |
2129 | endg |
2130 | endg |
2130 | ;------------------------------------------------------------------------------ |
2131 | ;------------------------------------------------------------------------------ |
2131 | sysfn_terminate: ; 18.2 = TERMINATE |
2132 | sysfn_terminate: ; 18.2 = TERMINATE |
2132 | push ecx |
2133 | push ecx |
2133 | cmp ecx, 2 |
2134 | cmp ecx, 2 |
2134 | jb noprocessterminate |
2135 | jb noprocessterminate |
2135 | mov edx, [TASK_COUNT] |
2136 | mov edx, [TASK_COUNT] |
2136 | cmp ecx, edx |
2137 | cmp ecx, edx |
2137 | ja noprocessterminate |
2138 | ja noprocessterminate |
2138 | mov eax, [TASK_COUNT] |
2139 | mov eax, [TASK_COUNT] |
2139 | shl ecx, 5 |
2140 | shl ecx, 5 |
2140 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2141 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2141 | add ecx, CURRENT_TASK+TASKDATA.state |
2142 | add ecx, CURRENT_TASK+TASKDATA.state |
2142 | cmp byte [ecx], 9 |
2143 | cmp byte [ecx], 9 |
2143 | jz noprocessterminate |
2144 | jz noprocessterminate |
2144 | push ecx edx |
2145 | push ecx edx |
2145 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2146 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2146 | call request_terminate |
2147 | call request_terminate |
2147 | pop edx ecx |
2148 | pop edx ecx |
2148 | test eax, eax |
2149 | test eax, eax |
2149 | jz noprocessterminate |
2150 | jz noprocessterminate |
2150 | ;-------------------------------------- |
2151 | ;-------------------------------------- |
2151 | ; terminate all network sockets it used |
2152 | ; terminate all network sockets it used |
2152 | pusha |
2153 | pusha |
2153 | mov eax, edx |
2154 | mov eax, edx |
2154 | call SOCKET_process_end |
2155 | call SOCKET_process_end |
2155 | popa |
2156 | popa |
2156 | ;-------------------------------------- |
2157 | ;-------------------------------------- |
2157 | cmp [_display.select_cursor], 0 |
2158 | cmp [_display.select_cursor], 0 |
2158 | je .restore_end |
2159 | je .restore_end |
2159 | ; restore default cursor before killing |
2160 | ; restore default cursor before killing |
2160 | pusha |
2161 | pusha |
2161 | mov ecx, [esp+32] |
2162 | mov ecx, [esp+32] |
2162 | shl ecx, 8 |
2163 | shl ecx, 8 |
2163 | add ecx, SLOT_BASE |
2164 | add ecx, SLOT_BASE |
2164 | mov eax, [def_cursor] |
2165 | mov eax, [def_cursor] |
2165 | cmp [ecx+APPDATA.cursor], eax |
2166 | cmp [ecx+APPDATA.cursor], eax |
2166 | je @f |
2167 | je @f |
2167 | call restore_default_cursor_before_killing |
2168 | call restore_default_cursor_before_killing |
2168 | @@: |
2169 | @@: |
2169 | popa |
2170 | popa |
2170 | .restore_end: |
2171 | .restore_end: |
2171 | ;-------------------------------------- |
2172 | ;-------------------------------------- |
2172 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2173 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2173 | mov [ecx], byte 3; clear possible i40's |
2174 | mov [ecx], byte 3; clear possible i40's |
2174 | call wakeup_osloop |
2175 | call wakeup_osloop |
2175 | ;call MEM_Heap_UnLock |
2176 | ;call MEM_Heap_UnLock |
2176 | 2177 | ||
2177 | cmp edx, [application_table_owner]; clear app table stat |
2178 | cmp edx, [application_table_owner]; clear app table stat |
2178 | jne noatsc |
2179 | jne noatsc |
2179 | call unlock_application_table |
2180 | call unlock_application_table |
2180 | noatsc: |
2181 | noatsc: |
2181 | noprocessterminate: |
2182 | noprocessterminate: |
2182 | add esp, 4 |
2183 | add esp, 4 |
2183 | ret |
2184 | ret |
2184 | ;------------------------------------------------------------------------------ |
2185 | ;------------------------------------------------------------------------------ |
2185 | sysfn_terminate2: |
2186 | sysfn_terminate2: |
2186 | ;lock application_table_status mutex |
2187 | ;lock application_table_status mutex |
2187 | .table_status: |
2188 | .table_status: |
2188 | call lock_application_table |
2189 | call lock_application_table |
2189 | mov eax, ecx |
2190 | mov eax, ecx |
2190 | call pid_to_slot |
2191 | call pid_to_slot |
2191 | test eax, eax |
2192 | test eax, eax |
2192 | jz .not_found |
2193 | jz .not_found |
2193 | mov ecx, eax |
2194 | mov ecx, eax |
2194 | cli |
2195 | cli |
2195 | call sysfn_terminate |
2196 | call sysfn_terminate |
2196 | call unlock_application_table |
2197 | call unlock_application_table |
2197 | sti |
2198 | sti |
2198 | and dword [esp+32], 0 |
2199 | and dword [esp+32], 0 |
2199 | ret |
2200 | ret |
2200 | .not_found: |
2201 | .not_found: |
2201 | call unlock_application_table |
2202 | call unlock_application_table |
2202 | or dword [esp+32], -1 |
2203 | or dword [esp+32], -1 |
2203 | ret |
2204 | ret |
2204 | ;------------------------------------------------------------------------------ |
2205 | ;------------------------------------------------------------------------------ |
2205 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2206 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2206 | cmp ecx, 2 |
2207 | cmp ecx, 2 |
2207 | jb .nowindowdeactivate |
2208 | jb .nowindowdeactivate |
2208 | cmp ecx, [TASK_COUNT] |
2209 | cmp ecx, [TASK_COUNT] |
2209 | ja .nowindowdeactivate |
2210 | ja .nowindowdeactivate |
2210 | 2211 | ||
2211 | movzx esi, word [WIN_STACK + ecx*2] |
2212 | movzx esi, word [WIN_STACK + ecx*2] |
2212 | cmp esi, 1 |
2213 | cmp esi, 1 |
2213 | je .nowindowdeactivate ; already deactive |
2214 | je .nowindowdeactivate ; already deactive |
2214 | 2215 | ||
2215 | mov edi, ecx |
2216 | mov edi, ecx |
2216 | shl edi, 5 |
2217 | shl edi, 5 |
2217 | add edi, window_data |
2218 | add edi, window_data |
2218 | movzx esi, word [WIN_STACK + ecx * 2] |
2219 | movzx esi, word [WIN_STACK + ecx * 2] |
2219 | lea esi, [WIN_POS + esi * 2] |
2220 | lea esi, [WIN_POS + esi * 2] |
2220 | call window._.window_deactivate |
2221 | call window._.window_deactivate |
2221 | 2222 | ||
2222 | call syscall_display_settings._.calculate_whole_screen |
2223 | call syscall_display_settings._.calculate_whole_screen |
2223 | call syscall_display_settings._.redraw_whole_screen |
2224 | call syscall_display_settings._.redraw_whole_screen |
2224 | .nowindowdeactivate: |
2225 | .nowindowdeactivate: |
2225 | ret |
2226 | ret |
2226 | ;------------------------------------------------------------------------------ |
2227 | ;------------------------------------------------------------------------------ |
2227 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2228 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2228 | cmp ecx, 2 |
2229 | cmp ecx, 2 |
2229 | jb .nowindowactivate |
2230 | jb .nowindowactivate |
2230 | cmp ecx, [TASK_COUNT] |
2231 | cmp ecx, [TASK_COUNT] |
2231 | ja .nowindowactivate |
2232 | ja .nowindowactivate |
2232 | ;------------------------------------- |
2233 | ;------------------------------------- |
2233 | @@: |
2234 | @@: |
2234 | ; If the window is captured and moved by the user, |
2235 | ; If the window is captured and moved by the user, |
2235 | ; then you can't change the position in window stack!!! |
2236 | ; then you can't change the position in window stack!!! |
2236 | mov al, [mouse.active_sys_window.action] |
2237 | mov al, [mouse.active_sys_window.action] |
2237 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2238 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2238 | test al, al |
2239 | test al, al |
2239 | jz @f |
2240 | jz @f |
2240 | call change_task |
2241 | call change_task |
2241 | jmp @b |
2242 | jmp @b |
2242 | @@: |
2243 | @@: |
2243 | ;------------------------------------- |
2244 | ;------------------------------------- |
2244 | mov [window_minimize], 2; restore window if minimized |
2245 | mov [window_minimize], 2; restore window if minimized |
2245 | call wakeup_osloop |
2246 | call wakeup_osloop |
2246 | 2247 | ||
2247 | movzx esi, word [WIN_STACK + ecx*2] |
2248 | movzx esi, word [WIN_STACK + ecx*2] |
2248 | cmp esi, [TASK_COUNT] |
2249 | cmp esi, [TASK_COUNT] |
2249 | je .nowindowactivate; already active |
2250 | je .nowindowactivate; already active |
2250 | 2251 | ||
2251 | mov edi, ecx |
2252 | mov edi, ecx |
2252 | shl edi, 5 |
2253 | shl edi, 5 |
2253 | add edi, window_data |
2254 | add edi, window_data |
2254 | movzx esi, word [WIN_STACK + ecx * 2] |
2255 | movzx esi, word [WIN_STACK + ecx * 2] |
2255 | lea esi, [WIN_POS + esi * 2] |
2256 | lea esi, [WIN_POS + esi * 2] |
2256 | call waredraw |
2257 | call waredraw |
2257 | .nowindowactivate: |
2258 | .nowindowactivate: |
2258 | ret |
2259 | ret |
2259 | ;------------------------------------------------------------------------------ |
2260 | ;------------------------------------------------------------------------------ |
2260 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2261 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2261 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2262 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2262 | mov [esp+32], eax |
2263 | mov [esp+32], eax |
2263 | ret |
2264 | ret |
2264 | ;------------------------------------------------------------------------------ |
2265 | ;------------------------------------------------------------------------------ |
2265 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2266 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2266 | mov eax, dword [cpu_freq] |
2267 | mov eax, dword [cpu_freq] |
2267 | mov [esp+32], eax |
2268 | mov [esp+32], eax |
2268 | ret |
2269 | ret |
2269 | ;------------------------------------------------------------------------------ |
2270 | ;------------------------------------------------------------------------------ |
2270 | get_cpu_freq: |
2271 | get_cpu_freq: |
2271 | mov eax, dword [cpu_freq] |
2272 | mov eax, dword [cpu_freq] |
2272 | mov edx, dword [cpu_freq+4] |
2273 | mov edx, dword [cpu_freq+4] |
2273 | ret |
2274 | ret |
2274 | ; SAVE ramdisk to /hd/1/menuet.img |
2275 | ; SAVE ramdisk to /hd/1/menuet.img |
2275 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2276 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2276 | include 'blkdev/rdsave.inc' |
2277 | include 'blkdev/rdsave.inc' |
2277 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2278 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2278 | ;------------------------------------------------------------------------------ |
2279 | ;------------------------------------------------------------------------------ |
2279 | align 4 |
2280 | align 4 |
2280 | sysfn_getactive: ; 18.7 = get active window |
2281 | sysfn_getactive: ; 18.7 = get active window |
2281 | mov eax, [TASK_COUNT] |
2282 | mov eax, [TASK_COUNT] |
2282 | movzx eax, word [WIN_POS + eax*2] |
2283 | movzx eax, word [WIN_POS + eax*2] |
2283 | mov [esp+32], eax |
2284 | mov [esp+32], eax |
2284 | ret |
2285 | ret |
2285 | ;------------------------------------------------------------------------------ |
2286 | ;------------------------------------------------------------------------------ |
2286 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2287 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2287 | ; cmp ecx,1 |
2288 | ; cmp ecx,1 |
2288 | dec ecx |
2289 | dec ecx |
2289 | jnz nogetsoundflag |
2290 | jnz nogetsoundflag |
2290 | movzx eax, byte [sound_flag]; get sound_flag |
2291 | movzx eax, byte [sound_flag]; get sound_flag |
2291 | mov [esp+32], eax |
2292 | mov [esp+32], eax |
2292 | ret |
2293 | ret |
2293 | nogetsoundflag: |
2294 | nogetsoundflag: |
2294 | ; cmp ecx,2 |
2295 | ; cmp ecx,2 |
2295 | dec ecx |
2296 | dec ecx |
2296 | jnz nosoundflag |
2297 | jnz nosoundflag |
2297 | xor byte [sound_flag], 1 |
2298 | xor byte [sound_flag], 1 |
2298 | nosoundflag: |
2299 | nosoundflag: |
2299 | ret |
2300 | ret |
2300 | ;------------------------------------------------------------------------------ |
2301 | ;------------------------------------------------------------------------------ |
2301 | sysfn_minimize: ; 18.10 = minimize window |
2302 | sysfn_minimize: ; 18.10 = minimize window |
2302 | mov [window_minimize], 1 |
2303 | mov [window_minimize], 1 |
2303 | call wakeup_osloop |
2304 | call wakeup_osloop |
2304 | ret |
2305 | ret |
2305 | ;------------------------------------------------------------------------------ |
2306 | ;------------------------------------------------------------------------------ |
2306 | align 4 |
2307 | align 4 |
2307 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2308 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2308 | ; cmp ecx,1 |
2309 | ; cmp ecx,1 |
2309 | dec ecx |
2310 | dec ecx |
2310 | jnz full_table |
2311 | jnz full_table |
2311 | small_table: |
2312 | small_table: |
2312 | call for_all_tables |
2313 | call for_all_tables |
2313 | mov ecx, 10 |
2314 | mov ecx, 10 |
2314 | cld |
2315 | cld |
2315 | rep movsb |
2316 | rep movsb |
2316 | ret |
2317 | ret |
2317 | for_all_tables: |
2318 | for_all_tables: |
2318 | mov edi, edx |
2319 | mov edi, edx |
2319 | mov esi, DRIVE_DATA |
2320 | mov esi, DRIVE_DATA |
2320 | ret |
2321 | ret |
2321 | full_table: |
2322 | full_table: |
2322 | ; cmp ecx,2 |
2323 | ; cmp ecx,2 |
2323 | dec ecx |
2324 | dec ecx |
2324 | jnz exit_for_anyone |
2325 | jnz exit_for_anyone |
2325 | call for_all_tables |
2326 | call for_all_tables |
2326 | mov ecx, 16384 |
2327 | mov ecx, 16384 |
2327 | cld |
2328 | cld |
2328 | rep movsd |
2329 | rep movsd |
2329 | ret |
2330 | ret |
2330 | ;------------------------------------------------------------------------------ |
2331 | ;------------------------------------------------------------------------------ |
2331 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2332 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2332 | and dword [esp+32], 0 |
2333 | and dword [esp+32], 0 |
2333 | ret |
2334 | ret |
2334 | ;------------------------------------------------------------------------------ |
2335 | ;------------------------------------------------------------------------------ |
2335 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2336 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2336 | mov edi, ecx |
2337 | mov edi, ecx |
2337 | mov esi, version_inf |
2338 | mov esi, version_inf |
2338 | mov ecx, version_end-version_inf |
2339 | mov ecx, version_end-version_inf |
2339 | rep movsb |
2340 | rep movsb |
2340 | ret |
2341 | ret |
2341 | ;------------------------------------------------------------------------------ |
2342 | ;------------------------------------------------------------------------------ |
2342 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2343 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2343 | ;wait retrace functions |
2344 | ;wait retrace functions |
2344 | sys_wait_retrace: |
2345 | sys_wait_retrace: |
2345 | mov edx, 0x3da |
2346 | mov edx, 0x3da |
2346 | WaitRetrace_loop: |
2347 | WaitRetrace_loop: |
2347 | in al, dx |
2348 | in al, dx |
2348 | test al, 1000b |
2349 | test al, 1000b |
2349 | jz WaitRetrace_loop |
2350 | jz WaitRetrace_loop |
2350 | and [esp+32], dword 0 |
2351 | and [esp+32], dword 0 |
2351 | ret |
2352 | ret |
2352 | ;------------------------------------------------------------------------------ |
2353 | ;------------------------------------------------------------------------------ |
2353 | align 4 |
2354 | align 4 |
2354 | sysfn_centermouse: ; 18.15 = mouse centered |
2355 | sysfn_centermouse: ; 18.15 = mouse centered |
2355 | ; removed here by |
2356 | ; removed here by |
2356 | ; call mouse_centered |
2357 | ; call mouse_centered |
2357 | ;* mouse centered - start code- Mario79 |
2358 | ;* mouse centered - start code- Mario79 |
2358 | ;mouse_centered: |
2359 | ;mouse_centered: |
2359 | ; push eax |
2360 | ; push eax |
2360 | mov eax, [Screen_Max_X] |
2361 | mov eax, [Screen_Max_X] |
2361 | shr eax, 1 |
2362 | shr eax, 1 |
2362 | mov [MOUSE_X], ax |
2363 | mov [MOUSE_X], ax |
2363 | mov eax, [Screen_Max_Y] |
2364 | mov eax, [Screen_Max_Y] |
2364 | shr eax, 1 |
2365 | shr eax, 1 |
2365 | mov [MOUSE_Y], ax |
2366 | mov [MOUSE_Y], ax |
2366 | call wakeup_osloop |
2367 | call wakeup_osloop |
2367 | ; ret |
2368 | ; ret |
2368 | ;* mouse centered - end code- Mario79 |
2369 | ;* mouse centered - end code- Mario79 |
2369 | xor eax, eax |
2370 | xor eax, eax |
2370 | and [esp+32], eax |
2371 | and [esp+32], eax |
2371 | ; pop eax |
2372 | ; pop eax |
2372 | ret |
2373 | ret |
2373 | ;------------------------------------------------------------------------------ |
2374 | ;------------------------------------------------------------------------------ |
2374 | align 4 |
2375 | align 4 |
2375 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2376 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2376 | test ecx, ecx; get mouse speed factor |
2377 | test ecx, ecx; get mouse speed factor |
2377 | jnz .set_mouse_acceleration |
2378 | jnz .set_mouse_acceleration |
2378 | xor eax, eax |
2379 | xor eax, eax |
2379 | mov ax, [mouse_speed_factor] |
2380 | mov ax, [mouse_speed_factor] |
2380 | mov [esp+32], eax |
2381 | mov [esp+32], eax |
2381 | ret |
2382 | ret |
2382 | .set_mouse_acceleration: |
2383 | .set_mouse_acceleration: |
2383 | ; cmp ecx,1 ; set mouse speed factor |
2384 | ; cmp ecx,1 ; set mouse speed factor |
2384 | dec ecx |
2385 | dec ecx |
2385 | jnz .get_mouse_delay |
2386 | jnz .get_mouse_delay |
2386 | mov [mouse_speed_factor], dx |
2387 | mov [mouse_speed_factor], dx |
2387 | ret |
2388 | ret |
2388 | .get_mouse_delay: |
2389 | .get_mouse_delay: |
2389 | ; cmp ecx,2 ; get mouse delay |
2390 | ; cmp ecx,2 ; get mouse delay |
2390 | dec ecx |
2391 | dec ecx |
2391 | jnz .set_mouse_delay |
2392 | jnz .set_mouse_delay |
2392 | mov eax, [mouse_delay] |
2393 | mov eax, [mouse_delay] |
2393 | mov [esp+32], eax |
2394 | mov [esp+32], eax |
2394 | ret |
2395 | ret |
2395 | .set_mouse_delay: |
2396 | .set_mouse_delay: |
2396 | ; cmp ecx,3 ; set mouse delay |
2397 | ; cmp ecx,3 ; set mouse delay |
2397 | dec ecx |
2398 | dec ecx |
2398 | jnz .set_pointer_position |
2399 | jnz .set_pointer_position |
2399 | mov [mouse_delay], edx |
2400 | mov [mouse_delay], edx |
2400 | ret |
2401 | ret |
2401 | .set_pointer_position: |
2402 | .set_pointer_position: |
2402 | ; cmp ecx,4 ; set mouse pointer position |
2403 | ; cmp ecx,4 ; set mouse pointer position |
2403 | dec ecx |
2404 | dec ecx |
2404 | jnz .set_mouse_button |
2405 | jnz .set_mouse_button |
2405 | cmp dx, word[Screen_Max_Y] |
2406 | cmp dx, word[Screen_Max_Y] |
2406 | ja .end |
2407 | ja .end |
2407 | rol edx, 16 |
2408 | rol edx, 16 |
2408 | cmp dx, word[Screen_Max_X] |
2409 | cmp dx, word[Screen_Max_X] |
2409 | ja .end |
2410 | ja .end |
2410 | mov [MOUSE_X], edx |
2411 | mov [MOUSE_X], edx |
2411 | call wakeup_osloop |
2412 | call wakeup_osloop |
2412 | ret |
2413 | ret |
2413 | .set_mouse_button: |
2414 | .set_mouse_button: |
2414 | ; cmp ecx,5 ; set mouse button features |
2415 | ; cmp ecx,5 ; set mouse button features |
2415 | dec ecx |
2416 | dec ecx |
2416 | jnz .end |
2417 | jnz .end |
2417 | mov [BTN_DOWN], dl |
2418 | mov [BTN_DOWN], dl |
2418 | mov [mouse_active], 1 |
2419 | mov [mouse_active], 1 |
2419 | call wakeup_osloop |
2420 | call wakeup_osloop |
2420 | .end: |
2421 | .end: |
2421 | ret |
2422 | ret |
2422 | ;------------------------------------------------------------------------------ |
2423 | ;------------------------------------------------------------------------------ |
2423 | sysfn_getfreemem: |
2424 | sysfn_getfreemem: |
2424 | mov eax, [pg_data.pages_free] |
2425 | mov eax, [pg_data.pages_free] |
2425 | shl eax, 2 |
2426 | shl eax, 2 |
2426 | mov [esp+32], eax |
2427 | mov [esp+32], eax |
2427 | ret |
2428 | ret |
2428 | ;------------------------------------------------------------------------------ |
2429 | ;------------------------------------------------------------------------------ |
2429 | sysfn_getallmem: |
2430 | sysfn_getallmem: |
2430 | mov eax, [MEM_AMOUNT] |
2431 | mov eax, [MEM_AMOUNT] |
2431 | shr eax, 10 |
2432 | shr eax, 10 |
2432 | mov [esp+32], eax |
2433 | mov [esp+32], eax |
2433 | ret |
2434 | ret |
2434 | ;------------------------------------------------------------------------------ |
2435 | ;------------------------------------------------------------------------------ |
2435 | sysfn_pid_to_slot: |
2436 | sysfn_pid_to_slot: |
2436 | mov eax, ecx |
2437 | mov eax, ecx |
2437 | call pid_to_slot |
2438 | call pid_to_slot |
2438 | mov [esp+32], eax |
2439 | mov [esp+32], eax |
2439 | ret |
2440 | ret |
2440 | ;------------------------------------------------------------------------------ |
2441 | ;------------------------------------------------------------------------------ |
2441 | sysfn_min_rest_window: |
2442 | sysfn_min_rest_window: |
2442 | pushad |
2443 | pushad |
2443 | mov eax, edx ; ebx - operating |
2444 | mov eax, edx ; ebx - operating |
2444 | shr ecx, 1 |
2445 | shr ecx, 1 |
2445 | jnc @f |
2446 | jnc @f |
2446 | call pid_to_slot |
2447 | call pid_to_slot |
2447 | @@: |
2448 | @@: |
2448 | or eax, eax ; eax - number of slot |
2449 | or eax, eax ; eax - number of slot |
2449 | jz .error |
2450 | jz .error |
2450 | cmp eax, 255 ; varify maximal slot number |
2451 | cmp eax, 255 ; varify maximal slot number |
2451 | ja .error |
2452 | ja .error |
2452 | movzx eax, word [WIN_STACK + eax*2] |
2453 | movzx eax, word [WIN_STACK + eax*2] |
2453 | shr ecx, 1 |
2454 | shr ecx, 1 |
2454 | jc .restore |
2455 | jc .restore |
2455 | ; .minimize: |
2456 | ; .minimize: |
2456 | call minimize_window |
2457 | call minimize_window |
2457 | jmp .exit |
2458 | jmp .exit |
2458 | .restore: |
2459 | .restore: |
2459 | call restore_minimized_window |
2460 | call restore_minimized_window |
2460 | .exit: |
2461 | .exit: |
2461 | popad |
2462 | popad |
2462 | xor eax, eax |
2463 | xor eax, eax |
2463 | mov [esp+32], eax |
2464 | mov [esp+32], eax |
2464 | ret |
2465 | ret |
2465 | .error: |
2466 | .error: |
2466 | popad |
2467 | popad |
2467 | xor eax, eax |
2468 | xor eax, eax |
2468 | dec eax |
2469 | dec eax |
2469 | mov [esp+32], eax |
2470 | mov [esp+32], eax |
2470 | ret |
2471 | ret |
2471 | ;------------------------------------------------------------------------------ |
2472 | ;------------------------------------------------------------------------------ |
2472 | sysfn_min_windows: |
2473 | sysfn_min_windows: |
2473 | call minimize_all_window |
2474 | call minimize_all_window |
2474 | mov [esp+32], eax |
2475 | mov [esp+32], eax |
2475 | call change_task |
2476 | call change_task |
2476 | ret |
2477 | ret |
2477 | ;------------------------------------------------------------------------------ |
2478 | ;------------------------------------------------------------------------------ |
2478 | sysfn_set_screen_sizes: |
2479 | sysfn_set_screen_sizes: |
2479 | cmp [SCR_MODE], word 0x13 |
2480 | cmp [SCR_MODE], word 0x13 |
2480 | jbe .exit |
2481 | jbe .exit |
2481 | 2482 | ||
2482 | cmp [_display.select_cursor], select_cursor |
2483 | cmp [_display.select_cursor], select_cursor |
2483 | jne .exit |
2484 | jne .exit |
2484 | 2485 | ||
2485 | cmp ecx, [display_width_standard] |
2486 | cmp ecx, [display_width_standard] |
2486 | ja .exit |
2487 | ja .exit |
2487 | 2488 | ||
2488 | cmp edx, [display_height_standard] |
2489 | cmp edx, [display_height_standard] |
2489 | ja .exit |
2490 | ja .exit |
2490 | 2491 | ||
2491 | pushfd |
2492 | pushfd |
2492 | cli |
2493 | cli |
2493 | mov eax, ecx |
2494 | mov eax, ecx |
2494 | mov ecx, [_display.pitch] |
2495 | mov ecx, [_display.pitch] |
2495 | mov [_display.width], eax |
2496 | mov [_display.width], eax |
2496 | dec eax |
2497 | dec eax |
2497 | mov [_display.height], edx |
2498 | mov [_display.height], edx |
2498 | dec edx |
2499 | dec edx |
2499 | ; eax - new Screen_Max_X |
2500 | ; eax - new Screen_Max_X |
2500 | ; edx - new Screen_Max_Y |
2501 | ; edx - new Screen_Max_Y |
2501 | mov [do_not_touch_winmap], 1 |
2502 | mov [do_not_touch_winmap], 1 |
2502 | call set_screen |
2503 | call set_screen |
2503 | mov [do_not_touch_winmap], 0 |
2504 | mov [do_not_touch_winmap], 0 |
2504 | popfd |
2505 | popfd |
2505 | call change_task |
2506 | call change_task |
2506 | .exit: |
2507 | .exit: |
2507 | ret |
2508 | ret |
2508 | ;------------------------------------------------------------------------------ |
2509 | ;------------------------------------------------------------------------------ |
2509 | uglobal |
2510 | uglobal |
2510 | screen_workarea RECT |
2511 | screen_workarea RECT |
2511 | display_width_standard dd 0 |
2512 | display_width_standard dd 0 |
2512 | display_height_standard dd 0 |
2513 | display_height_standard dd 0 |
2513 | do_not_touch_winmap db 0 |
2514 | do_not_touch_winmap db 0 |
2514 | window_minimize db 0 |
2515 | window_minimize db 0 |
2515 | sound_flag db 0 |
2516 | sound_flag db 0 |
2516 | 2517 | ||
2517 | endg |
2518 | endg |
2518 | 2519 | ||
2519 | UID_NONE=0 |
2520 | UID_NONE=0 |
2520 | UID_MENUETOS=1 ;official |
2521 | UID_MENUETOS=1 ;official |
2521 | UID_KOLIBRI=2 ;russian |
2522 | UID_KOLIBRI=2 ;russian |
2522 | 2523 | ||
2523 | iglobal |
2524 | iglobal |
2524 | version_inf: |
2525 | version_inf: |
2525 | db 0,7,7,0 ; version 0.7.7.0 |
2526 | db 0,7,7,0 ; version 0.7.7.0 |
2526 | db 0 |
2527 | db 0 |
2527 | .rev dd __REV__ |
2528 | .rev dd __REV__ |
2528 | version_end: |
2529 | version_end: |
2529 | endg |
2530 | endg |
2530 | ;------------------------------------------------------------------------------ |
2531 | ;------------------------------------------------------------------------------ |
2531 | align 4 |
2532 | align 4 |
2532 | sys_cachetodiskette: |
2533 | sys_cachetodiskette: |
2533 | cmp ebx, 1 |
2534 | cmp ebx, 1 |
2534 | jne .no_floppy_a_save |
2535 | jne .no_floppy_a_save |
2535 | mov [flp_number], 1 |
2536 | mov [flp_number], 1 |
2536 | jmp .save_image_on_floppy |
2537 | jmp .save_image_on_floppy |
2537 | ;-------------------------------------- |
2538 | ;-------------------------------------- |
2538 | align 4 |
2539 | align 4 |
2539 | .no_floppy_a_save: |
2540 | .no_floppy_a_save: |
2540 | cmp ebx, 2 |
2541 | cmp ebx, 2 |
2541 | jne .no_floppy_b_save |
2542 | jne .no_floppy_b_save |
2542 | mov [flp_number], 2 |
2543 | mov [flp_number], 2 |
2543 | ;-------------------------------------- |
2544 | ;-------------------------------------- |
2544 | align 4 |
2545 | align 4 |
2545 | .save_image_on_floppy: |
2546 | .save_image_on_floppy: |
2546 | call save_image |
2547 | call save_image |
2547 | mov [esp + 32], dword 0 |
2548 | mov [esp + 32], dword 0 |
2548 | cmp [FDC_Status], 0 |
2549 | cmp [FDC_Status], 0 |
2549 | je .yes_floppy_save |
2550 | je .yes_floppy_save |
2550 | ;-------------------------------------- |
2551 | ;-------------------------------------- |
2551 | align 4 |
2552 | align 4 |
2552 | .no_floppy_b_save: |
2553 | .no_floppy_b_save: |
2553 | mov [esp + 32], dword 1 |
2554 | mov [esp + 32], dword 1 |
2554 | ;-------------------------------------- |
2555 | ;-------------------------------------- |
2555 | align 4 |
2556 | align 4 |
2556 | .yes_floppy_save: |
2557 | .yes_floppy_save: |
2557 | ret |
2558 | ret |
2558 | ;------------------------------------------------------------------------------ |
2559 | ;------------------------------------------------------------------------------ |
2559 | uglobal |
2560 | uglobal |
2560 | ; bgrchanged dd 0x0 |
2561 | ; bgrchanged dd 0x0 |
2561 | align 4 |
2562 | align 4 |
2562 | bgrlockpid dd 0 |
2563 | bgrlockpid dd 0 |
2563 | bgrlock db 0 |
2564 | bgrlock db 0 |
2564 | endg |
2565 | endg |
2565 | ;------------------------------------------------------------------------------ |
2566 | ;------------------------------------------------------------------------------ |
2566 | align 4 |
2567 | align 4 |
2567 | sys_background: |
2568 | sys_background: |
2568 | cmp ebx, 1 ; BACKGROUND SIZE |
2569 | cmp ebx, 1 ; BACKGROUND SIZE |
2569 | jnz nosb1 |
2570 | jnz nosb1 |
2570 | test ecx, ecx |
2571 | test ecx, ecx |
2571 | jz sbgrr |
2572 | jz sbgrr |
2572 | 2573 | ||
2573 | test edx, edx |
2574 | test edx, edx |
2574 | jz sbgrr |
2575 | jz sbgrr |
2575 | ;-------------------------------------- |
2576 | ;-------------------------------------- |
2576 | align 4 |
2577 | align 4 |
2577 | @@: |
2578 | @@: |
2578 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2579 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2579 | bts dword [bgrlock], 0 |
2580 | bts dword [bgrlock], 0 |
2580 | jnc @f |
2581 | jnc @f |
2581 | call change_task |
2582 | call change_task |
2582 | jmp @b |
2583 | jmp @b |
2583 | ;-------------------------------------- |
2584 | ;-------------------------------------- |
2584 | align 4 |
2585 | align 4 |
2585 | @@: |
2586 | @@: |
2586 | mov [BgrDataWidth], ecx |
2587 | mov [BgrDataWidth], ecx |
2587 | mov [BgrDataHeight], edx |
2588 | mov [BgrDataHeight], edx |
2588 | ; mov [bgrchanged],1 |
2589 | ; mov [bgrchanged],1 |
2589 | 2590 | ||
2590 | pushad |
2591 | pushad |
2591 | ; return memory for old background |
2592 | ; return memory for old background |
2592 | mov eax, [img_background] |
2593 | mov eax, [img_background] |
2593 | cmp eax, static_background_data |
2594 | cmp eax, static_background_data |
2594 | jz @f |
2595 | jz @f |
2595 | stdcall kernel_free, eax |
2596 | stdcall kernel_free, eax |
2596 | ;-------------------------------------- |
2597 | ;-------------------------------------- |
2597 | align 4 |
2598 | align 4 |
2598 | @@: |
2599 | @@: |
2599 | ; calculate RAW size |
2600 | ; calculate RAW size |
2600 | xor eax, eax |
2601 | xor eax, eax |
2601 | inc eax |
2602 | inc eax |
2602 | cmp [BgrDataWidth], eax |
2603 | cmp [BgrDataWidth], eax |
2603 | jae @f |
2604 | jae @f |
2604 | mov [BgrDataWidth], eax |
2605 | mov [BgrDataWidth], eax |
2605 | ;-------------------------------------- |
2606 | ;-------------------------------------- |
2606 | align 4 |
2607 | align 4 |
2607 | @@: |
2608 | @@: |
2608 | cmp [BgrDataHeight], eax |
2609 | cmp [BgrDataHeight], eax |
2609 | jae @f |
2610 | jae @f |
2610 | mov [BgrDataHeight], eax |
2611 | mov [BgrDataHeight], eax |
2611 | ;-------------------------------------- |
2612 | ;-------------------------------------- |
2612 | align 4 |
2613 | align 4 |
2613 | @@: |
2614 | @@: |
2614 | mov eax, [BgrDataWidth] |
2615 | mov eax, [BgrDataWidth] |
2615 | imul eax, [BgrDataHeight] |
2616 | imul eax, [BgrDataHeight] |
2616 | lea eax, [eax*3] |
2617 | lea eax, [eax*3] |
2617 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2618 | ; 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 |
2619 | ; 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]" |
2620 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2620 | shr eax, 12 |
2621 | shr eax, 12 |
2621 | inc eax |
2622 | inc eax |
2622 | shl eax, 12 |
2623 | shl eax, 12 |
2623 | mov [mem_BACKGROUND], eax |
2624 | mov [mem_BACKGROUND], eax |
2624 | ; get memory for new background |
2625 | ; get memory for new background |
2625 | stdcall kernel_alloc, eax |
2626 | stdcall kernel_alloc, eax |
2626 | test eax, eax |
2627 | test eax, eax |
2627 | jz .memfailed |
2628 | jz .memfailed |
2628 | mov [img_background], eax |
2629 | mov [img_background], eax |
2629 | jmp .exit |
2630 | jmp .exit |
2630 | ;-------------------------------------- |
2631 | ;-------------------------------------- |
2631 | align 4 |
2632 | align 4 |
2632 | .memfailed: |
2633 | .memfailed: |
2633 | ; revert to static monotone data |
2634 | ; revert to static monotone data |
2634 | mov [img_background], static_background_data |
2635 | mov [img_background], static_background_data |
2635 | xor eax, eax |
2636 | xor eax, eax |
2636 | inc eax |
2637 | inc eax |
2637 | mov [BgrDataWidth], eax |
2638 | mov [BgrDataWidth], eax |
2638 | mov [BgrDataHeight], eax |
2639 | mov [BgrDataHeight], eax |
2639 | mov [mem_BACKGROUND], 4 |
2640 | mov [mem_BACKGROUND], 4 |
2640 | ;-------------------------------------- |
2641 | ;-------------------------------------- |
2641 | align 4 |
2642 | align 4 |
2642 | .exit: |
2643 | .exit: |
2643 | popad |
2644 | popad |
2644 | mov [bgrlock], 0 |
2645 | mov [bgrlock], 0 |
2645 | ;-------------------------------------- |
2646 | ;-------------------------------------- |
2646 | align 4 |
2647 | align 4 |
2647 | sbgrr: |
2648 | sbgrr: |
2648 | ret |
2649 | ret |
2649 | ;------------------------------------------------------------------------------ |
2650 | ;------------------------------------------------------------------------------ |
2650 | align 4 |
2651 | align 4 |
2651 | nosb1: |
2652 | nosb1: |
2652 | cmp ebx, 2 ; SET PIXEL |
2653 | cmp ebx, 2 ; SET PIXEL |
2653 | jnz nosb2 |
2654 | jnz nosb2 |
2654 | 2655 | ||
2655 | mov eax, [img_background] |
2656 | mov eax, [img_background] |
2656 | test ecx, ecx |
2657 | test ecx, ecx |
2657 | jz @f |
2658 | jz @f |
2658 | cmp eax, static_background_data |
2659 | cmp eax, static_background_data |
2659 | jz .ret |
2660 | jz .ret |
2660 | ;-------------------------------------- |
2661 | ;-------------------------------------- |
2661 | align 4 |
2662 | align 4 |
2662 | @@: |
2663 | @@: |
2663 | mov ebx, [mem_BACKGROUND] |
2664 | mov ebx, [mem_BACKGROUND] |
2664 | add ebx, 4095 |
2665 | add ebx, 4095 |
2665 | and ebx, -4096 |
2666 | and ebx, -4096 |
2666 | sub ebx, 4 |
2667 | sub ebx, 4 |
2667 | cmp ecx, ebx |
2668 | cmp ecx, ebx |
2668 | ja .ret |
2669 | ja .ret |
2669 | 2670 | ||
2670 | mov ebx, [eax+ecx] |
2671 | mov ebx, [eax+ecx] |
2671 | and ebx, 0xFF000000;255*256*256*256 |
2672 | and ebx, 0xFF000000;255*256*256*256 |
2672 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2673 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2673 | add edx, ebx |
2674 | add edx, ebx |
2674 | mov [eax+ecx], edx |
2675 | mov [eax+ecx], edx |
2675 | ;-------------------------------------- |
2676 | ;-------------------------------------- |
2676 | align 4 |
2677 | align 4 |
2677 | .ret: |
2678 | .ret: |
2678 | ret |
2679 | ret |
2679 | ;------------------------------------------------------------------------------ |
2680 | ;------------------------------------------------------------------------------ |
2680 | align 4 |
2681 | align 4 |
2681 | nosb2: |
2682 | nosb2: |
2682 | cmp ebx, 3 ; DRAW BACKGROUND |
2683 | cmp ebx, 3 ; DRAW BACKGROUND |
2683 | jnz nosb3 |
2684 | jnz nosb3 |
2684 | ;-------------------------------------- |
2685 | ;-------------------------------------- |
2685 | align 4 |
2686 | align 4 |
2686 | draw_background_temp: |
2687 | draw_background_temp: |
2687 | mov [background_defined], 1 |
2688 | mov [background_defined], 1 |
2688 | call force_redraw_background |
2689 | call force_redraw_background |
2689 | ;-------------------------------------- |
2690 | ;-------------------------------------- |
2690 | align 4 |
2691 | align 4 |
2691 | nosb31: |
2692 | nosb31: |
2692 | ret |
2693 | ret |
2693 | ;------------------------------------------------------------------------------ |
2694 | ;------------------------------------------------------------------------------ |
2694 | align 4 |
2695 | align 4 |
2695 | nosb3: |
2696 | nosb3: |
2696 | cmp ebx, 4 ; TILED / STRETCHED |
2697 | cmp ebx, 4 ; TILED / STRETCHED |
2697 | jnz nosb4 |
2698 | jnz nosb4 |
2698 | cmp ecx, [BgrDrawMode] |
2699 | cmp ecx, [BgrDrawMode] |
2699 | je nosb41 |
2700 | je nosb41 |
2700 | mov [BgrDrawMode], ecx |
2701 | mov [BgrDrawMode], ecx |
2701 | ;-------------------------------------- |
2702 | ;-------------------------------------- |
2702 | align 4 |
2703 | align 4 |
2703 | nosb41: |
2704 | nosb41: |
2704 | ret |
2705 | ret |
2705 | ;------------------------------------------------------------------------------ |
2706 | ;------------------------------------------------------------------------------ |
2706 | align 4 |
2707 | align 4 |
2707 | nosb4: |
2708 | nosb4: |
2708 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2709 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2709 | jnz nosb5 |
2710 | jnz nosb5 |
2710 | cmp [img_background], static_background_data |
2711 | cmp [img_background], static_background_data |
2711 | jnz @f |
2712 | jnz @f |
2712 | test edx, edx |
2713 | test edx, edx |
2713 | jnz .fin |
2714 | jnz .fin |
2714 | cmp esi, 4 |
2715 | cmp esi, 4 |
2715 | ja .fin |
2716 | ja .fin |
2716 | ;-------------------------------------- |
2717 | ;-------------------------------------- |
2717 | align 4 |
2718 | align 4 |
2718 | @@: |
2719 | @@: |
2719 | ; bughere |
2720 | ; bughere |
2720 | mov eax, ecx |
2721 | mov eax, ecx |
2721 | mov ebx, edx |
2722 | mov ebx, edx |
2722 | add ebx, [img_background];IMG_BACKGROUND |
2723 | add ebx, [img_background];IMG_BACKGROUND |
2723 | mov ecx, esi |
2724 | mov ecx, esi |
2724 | call memmove |
2725 | call memmove |
2725 | ;-------------------------------------- |
2726 | ;-------------------------------------- |
2726 | align 4 |
2727 | align 4 |
2727 | .fin: |
2728 | .fin: |
2728 | ret |
2729 | ret |
2729 | ;------------------------------------------------------------------------------ |
2730 | ;------------------------------------------------------------------------------ |
2730 | align 4 |
2731 | align 4 |
2731 | nosb5: |
2732 | nosb5: |
2732 | cmp ebx, 6 |
2733 | cmp ebx, 6 |
2733 | jnz nosb6 |
2734 | jnz nosb6 |
2734 | ;-------------------------------------- |
2735 | ;-------------------------------------- |
2735 | align 4 |
2736 | align 4 |
2736 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2737 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2737 | @@: |
2738 | @@: |
2738 | bts dword [bgrlock], 0 |
2739 | bts dword [bgrlock], 0 |
2739 | jnc @f |
2740 | jnc @f |
2740 | call change_task |
2741 | call change_task |
2741 | jmp @b |
2742 | jmp @b |
2742 | ;-------------------------------------- |
2743 | ;-------------------------------------- |
2743 | align 4 |
2744 | align 4 |
2744 | @@: |
2745 | @@: |
2745 | mov eax, [CURRENT_TASK] |
2746 | mov eax, [CURRENT_TASK] |
2746 | mov [bgrlockpid], eax |
2747 | mov [bgrlockpid], eax |
2747 | cmp [img_background], static_background_data |
2748 | cmp [img_background], static_background_data |
2748 | jz .nomem |
2749 | jz .nomem |
2749 | stdcall user_alloc, [mem_BACKGROUND] |
2750 | stdcall user_alloc, [mem_BACKGROUND] |
2750 | mov [esp+32], eax |
2751 | mov [esp+32], eax |
2751 | test eax, eax |
2752 | test eax, eax |
2752 | jz .nomem |
2753 | jz .nomem |
2753 | mov ebx, eax |
2754 | mov ebx, eax |
2754 | shr ebx, 12 |
2755 | shr ebx, 12 |
2755 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2756 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2756 | mov esi, [img_background] |
2757 | mov esi, [img_background] |
2757 | shr esi, 12 |
2758 | shr esi, 12 |
2758 | mov ecx, [mem_BACKGROUND] |
2759 | mov ecx, [mem_BACKGROUND] |
2759 | add ecx, 0xFFF |
2760 | add ecx, 0xFFF |
2760 | shr ecx, 12 |
2761 | shr ecx, 12 |
2761 | ;-------------------------------------- |
2762 | ;-------------------------------------- |
2762 | align 4 |
2763 | align 4 |
2763 | .z: |
2764 | .z: |
2764 | mov eax, [page_tabs+ebx*4] |
2765 | mov eax, [page_tabs+ebx*4] |
2765 | test al, 1 |
2766 | test al, 1 |
2766 | jz @f |
2767 | jz @f |
2767 | call free_page |
2768 | call free_page |
2768 | ;-------------------------------------- |
2769 | ;-------------------------------------- |
2769 | align 4 |
2770 | align 4 |
2770 | @@: |
2771 | @@: |
2771 | mov eax, [page_tabs+esi*4] |
2772 | mov eax, [page_tabs+esi*4] |
2772 | or al, PG_UW |
2773 | or al, PG_UW |
2773 | mov [page_tabs+ebx*4], eax |
2774 | mov [page_tabs+ebx*4], eax |
2774 | mov eax, ebx |
2775 | mov eax, ebx |
2775 | shl eax, 12 |
2776 | shl eax, 12 |
2776 | invlpg [eax] |
2777 | invlpg [eax] |
2777 | inc ebx |
2778 | inc ebx |
2778 | inc esi |
2779 | inc esi |
2779 | loop .z |
2780 | loop .z |
2780 | ret |
2781 | ret |
2781 | ;-------------------------------------- |
2782 | ;-------------------------------------- |
2782 | align 4 |
2783 | align 4 |
2783 | .nomem: |
2784 | .nomem: |
2784 | and [bgrlockpid], 0 |
2785 | and [bgrlockpid], 0 |
2785 | mov [bgrlock], 0 |
2786 | mov [bgrlock], 0 |
2786 | ;------------------------------------------------------------------------------ |
2787 | ;------------------------------------------------------------------------------ |
2787 | align 4 |
2788 | align 4 |
2788 | nosb6: |
2789 | nosb6: |
2789 | cmp ebx, 7 |
2790 | cmp ebx, 7 |
2790 | jnz nosb7 |
2791 | jnz nosb7 |
2791 | cmp [bgrlock], 0 |
2792 | cmp [bgrlock], 0 |
2792 | jz .err |
2793 | jz .err |
2793 | mov eax, [CURRENT_TASK] |
2794 | mov eax, [CURRENT_TASK] |
2794 | cmp [bgrlockpid], eax |
2795 | cmp [bgrlockpid], eax |
2795 | jnz .err |
2796 | jnz .err |
2796 | mov eax, ecx |
2797 | mov eax, ecx |
2797 | mov ebx, ecx |
2798 | mov ebx, ecx |
2798 | shr eax, 12 |
2799 | shr eax, 12 |
2799 | mov ecx, [page_tabs+(eax-1)*4] |
2800 | mov ecx, [page_tabs+(eax-1)*4] |
2800 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2801 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2801 | jz .err |
2802 | jz .err |
2802 | jnp .err |
2803 | jnp .err |
2803 | push eax |
2804 | push eax |
2804 | shr ecx, 12 |
2805 | shr ecx, 12 |
2805 | dec ecx |
2806 | dec ecx |
2806 | ;-------------------------------------- |
2807 | ;-------------------------------------- |
2807 | align 4 |
2808 | align 4 |
2808 | @@: |
2809 | @@: |
2809 | and dword [page_tabs+eax*4], 0 |
2810 | and dword [page_tabs+eax*4], 0 |
2810 | mov edx, eax |
2811 | mov edx, eax |
2811 | shl edx, 12 |
2812 | shl edx, 12 |
2812 | push eax |
2813 | push eax |
2813 | invlpg [edx] |
2814 | invlpg [edx] |
2814 | pop eax |
2815 | pop eax |
2815 | inc eax |
2816 | inc eax |
2816 | loop @b |
2817 | loop @b |
2817 | pop eax |
2818 | pop eax |
2818 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2819 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2819 | stdcall user_free, ebx |
2820 | stdcall user_free, ebx |
2820 | mov [esp+32], eax |
2821 | mov [esp+32], eax |
2821 | and [bgrlockpid], 0 |
2822 | and [bgrlockpid], 0 |
2822 | mov [bgrlock], 0 |
2823 | mov [bgrlock], 0 |
2823 | ret |
2824 | ret |
2824 | ;-------------------------------------- |
2825 | ;-------------------------------------- |
2825 | align 4 |
2826 | align 4 |
2826 | .err: |
2827 | .err: |
2827 | and dword [esp+32], 0 |
2828 | and dword [esp+32], 0 |
2828 | ret |
2829 | ret |
2829 | ;------------------------------------------------------------------------------ |
2830 | ;------------------------------------------------------------------------------ |
2830 | align 4 |
2831 | align 4 |
2831 | nosb7: |
2832 | nosb7: |
2832 | cmp ebx, 8 |
2833 | cmp ebx, 8 |
2833 | jnz nosb8 |
2834 | jnz nosb8 |
2834 | 2835 | ||
2835 | mov ecx, [current_slot] |
2836 | mov ecx, [current_slot] |
2836 | xor eax, eax |
2837 | xor eax, eax |
2837 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2838 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2838 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2839 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2839 | xor eax, eax |
2840 | xor eax, eax |
2840 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2841 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2841 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2842 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2842 | ret |
2843 | ret |
2843 | ;------------------------------------------------------------------------------ |
2844 | ;------------------------------------------------------------------------------ |
2844 | align 4 |
2845 | align 4 |
2845 | nosb8: |
2846 | nosb8: |
2846 | cmp ebx, 9 |
2847 | cmp ebx, 9 |
2847 | jnz nosb9 |
2848 | jnz nosb9 |
2848 | ; ecx = [left]*65536 + [right] |
2849 | ; ecx = [left]*65536 + [right] |
2849 | ; edx = [top]*65536 + [bottom] |
2850 | ; edx = [top]*65536 + [bottom] |
2850 | mov eax, [Screen_Max_X] |
2851 | mov eax, [Screen_Max_X] |
2851 | mov ebx, [Screen_Max_Y] |
2852 | mov ebx, [Screen_Max_Y] |
2852 | ; check [right] |
2853 | ; check [right] |
2853 | cmp cx, ax |
2854 | cmp cx, ax |
2854 | ja .exit |
2855 | ja .exit |
2855 | ; check [left] |
2856 | ; check [left] |
2856 | ror ecx, 16 |
2857 | ror ecx, 16 |
2857 | cmp cx, ax |
2858 | cmp cx, ax |
2858 | ja .exit |
2859 | ja .exit |
2859 | ; check [bottom] |
2860 | ; check [bottom] |
2860 | cmp dx, bx |
2861 | cmp dx, bx |
2861 | ja .exit |
2862 | ja .exit |
2862 | ; check [top] |
2863 | ; check [top] |
2863 | ror edx, 16 |
2864 | ror edx, 16 |
2864 | cmp dx, bx |
2865 | cmp dx, bx |
2865 | ja .exit |
2866 | ja .exit |
2866 | 2867 | ||
2867 | movzx eax, cx ; [left] |
2868 | movzx eax, cx ; [left] |
2868 | movzx ebx, dx ; [top] |
2869 | movzx ebx, dx ; [top] |
2869 | 2870 | ||
2870 | shr ecx, 16 ; [right] |
2871 | shr ecx, 16 ; [right] |
2871 | shr edx, 16 ; [bottom] |
2872 | shr edx, 16 ; [bottom] |
2872 | 2873 | ||
2873 | mov [background_defined], 1 |
2874 | mov [background_defined], 1 |
2874 | 2875 | ||
2875 | mov [draw_data+32 + RECT.left], eax |
2876 | mov [draw_data+32 + RECT.left], eax |
2876 | mov [draw_data+32 + RECT.top], ebx |
2877 | mov [draw_data+32 + RECT.top], ebx |
2877 | 2878 | ||
2878 | mov [draw_data+32 + RECT.right], ecx |
2879 | mov [draw_data+32 + RECT.right], ecx |
2879 | mov [draw_data+32 + RECT.bottom], edx |
2880 | mov [draw_data+32 + RECT.bottom], edx |
2880 | 2881 | ||
2881 | inc byte[REDRAW_BACKGROUND] |
2882 | inc byte[REDRAW_BACKGROUND] |
2882 | call wakeup_osloop |
2883 | call wakeup_osloop |
2883 | ;-------------------------------------- |
2884 | ;-------------------------------------- |
2884 | align 4 |
2885 | align 4 |
2885 | .exit: |
2886 | .exit: |
2886 | ret |
2887 | ret |
2887 | ;------------------------------------------------------------------------------ |
2888 | ;------------------------------------------------------------------------------ |
2888 | align 4 |
2889 | align 4 |
2889 | nosb9: |
2890 | nosb9: |
2890 | ret |
2891 | ret |
2891 | ;------------------------------------------------------------------------------ |
2892 | ;------------------------------------------------------------------------------ |
2892 | align 4 |
2893 | align 4 |
2893 | uglobal |
2894 | uglobal |
2894 | BG_Rect_X_left_right dd 0x0 |
2895 | BG_Rect_X_left_right dd 0x0 |
2895 | BG_Rect_Y_top_bottom dd 0x0 |
2896 | BG_Rect_Y_top_bottom dd 0x0 |
2896 | endg |
2897 | endg |
2897 | ;------------------------------------------------------------------------------ |
2898 | ;------------------------------------------------------------------------------ |
2898 | align 4 |
2899 | align 4 |
2899 | force_redraw_background: |
2900 | force_redraw_background: |
2900 | and [draw_data+32 + RECT.left], 0 |
2901 | and [draw_data+32 + RECT.left], 0 |
2901 | and [draw_data+32 + RECT.top], 0 |
2902 | and [draw_data+32 + RECT.top], 0 |
2902 | push eax ebx |
2903 | push eax ebx |
2903 | mov eax, [Screen_Max_X] |
2904 | mov eax, [Screen_Max_X] |
2904 | mov ebx, [Screen_Max_Y] |
2905 | mov ebx, [Screen_Max_Y] |
2905 | mov [draw_data+32 + RECT.right], eax |
2906 | mov [draw_data+32 + RECT.right], eax |
2906 | mov [draw_data+32 + RECT.bottom], ebx |
2907 | mov [draw_data+32 + RECT.bottom], ebx |
2907 | pop ebx eax |
2908 | pop ebx eax |
2908 | inc byte[REDRAW_BACKGROUND] |
2909 | inc byte[REDRAW_BACKGROUND] |
2909 | call wakeup_osloop |
2910 | call wakeup_osloop |
2910 | ret |
2911 | ret |
2911 | ;------------------------------------------------------------------------------ |
2912 | ;------------------------------------------------------------------------------ |
2912 | align 4 |
2913 | align 4 |
2913 | sys_getbackground: |
2914 | sys_getbackground: |
2914 | ; cmp eax,1 ; SIZE |
2915 | ; cmp eax,1 ; SIZE |
2915 | dec ebx |
2916 | dec ebx |
2916 | jnz nogb1 |
2917 | jnz nogb1 |
2917 | mov eax, [BgrDataWidth] |
2918 | mov eax, [BgrDataWidth] |
2918 | shl eax, 16 |
2919 | shl eax, 16 |
2919 | mov ax, word [BgrDataHeight] |
2920 | mov ax, word [BgrDataHeight] |
2920 | mov [esp+32], eax |
2921 | mov [esp+32], eax |
2921 | ret |
2922 | ret |
2922 | ;------------------------------------------------------------------------------ |
2923 | ;------------------------------------------------------------------------------ |
2923 | align 4 |
2924 | align 4 |
2924 | nogb1: |
2925 | nogb1: |
2925 | ; cmp eax,2 ; PIXEL |
2926 | ; cmp eax,2 ; PIXEL |
2926 | dec ebx |
2927 | dec ebx |
2927 | jnz nogb2 |
2928 | jnz nogb2 |
2928 | 2929 | ||
2929 | mov eax, [img_background] |
2930 | mov eax, [img_background] |
2930 | test ecx, ecx |
2931 | test ecx, ecx |
2931 | jz @f |
2932 | jz @f |
2932 | cmp eax, static_background_data |
2933 | cmp eax, static_background_data |
2933 | jz .ret |
2934 | jz .ret |
2934 | ;-------------------------------------- |
2935 | ;-------------------------------------- |
2935 | align 4 |
2936 | align 4 |
2936 | @@: |
2937 | @@: |
2937 | mov ebx, [mem_BACKGROUND] |
2938 | mov ebx, [mem_BACKGROUND] |
2938 | add ebx, 4095 |
2939 | add ebx, 4095 |
2939 | and ebx, -4096 |
2940 | and ebx, -4096 |
2940 | sub ebx, 4 |
2941 | sub ebx, 4 |
2941 | cmp ecx, ebx |
2942 | cmp ecx, ebx |
2942 | ja .ret |
2943 | ja .ret |
2943 | 2944 | ||
2944 | mov eax, [ecx+eax] |
2945 | mov eax, [ecx+eax] |
2945 | 2946 | ||
2946 | and eax, 0xFFFFFF |
2947 | and eax, 0xFFFFFF |
2947 | mov [esp+32], eax |
2948 | mov [esp+32], eax |
2948 | ;-------------------------------------- |
2949 | ;-------------------------------------- |
2949 | align 4 |
2950 | align 4 |
2950 | .ret: |
2951 | .ret: |
2951 | ret |
2952 | ret |
2952 | ;------------------------------------------------------------------------------ |
2953 | ;------------------------------------------------------------------------------ |
2953 | align 4 |
2954 | align 4 |
2954 | nogb2: |
2955 | nogb2: |
2955 | 2956 | ||
2956 | ; cmp eax,4 ; TILED / STRETCHED |
2957 | ; cmp eax,4 ; TILED / STRETCHED |
2957 | dec ebx |
2958 | dec ebx |
2958 | dec ebx |
2959 | dec ebx |
2959 | jnz nogb4 |
2960 | jnz nogb4 |
2960 | mov eax, [BgrDrawMode] |
2961 | mov eax, [BgrDrawMode] |
2961 | ;-------------------------------------- |
2962 | ;-------------------------------------- |
2962 | align 4 |
2963 | align 4 |
2963 | nogb4: |
2964 | nogb4: |
2964 | mov [esp+32], eax |
2965 | mov [esp+32], eax |
2965 | ret |
2966 | ret |
2966 | ;------------------------------------------------------------------------------ |
2967 | ;------------------------------------------------------------------------------ |
2967 | align 4 |
2968 | align 4 |
2968 | sys_getkey: |
2969 | sys_getkey: |
2969 | mov [esp + 32], dword 1 |
2970 | mov [esp + 32], dword 1 |
2970 | ; test main buffer |
2971 | ; test main buffer |
2971 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2972 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2972 | movzx ecx, word [WIN_STACK + ebx * 2] |
2973 | movzx ecx, word [WIN_STACK + ebx * 2] |
2973 | mov edx, [TASK_COUNT] |
2974 | mov edx, [TASK_COUNT] |
2974 | cmp ecx, edx |
2975 | cmp ecx, edx |
2975 | jne .finish |
2976 | jne .finish |
2976 | cmp [KEY_COUNT], byte 0 |
2977 | cmp [KEY_COUNT], byte 0 |
2977 | je .finish |
2978 | je .finish |
2978 | movzx eax, byte [KEY_BUFF] |
2979 | movzx eax, byte [KEY_BUFF] |
2979 | shl eax, 8 |
2980 | shl eax, 8 |
2980 | push eax |
2981 | push eax |
2981 | dec byte [KEY_COUNT] |
2982 | dec byte [KEY_COUNT] |
2982 | and byte [KEY_COUNT], 127 |
2983 | and byte [KEY_COUNT], 127 |
2983 | movzx ecx, byte [KEY_COUNT] |
2984 | movzx ecx, byte [KEY_COUNT] |
2984 | add ecx, 2 |
2985 | add ecx, 2 |
2985 | mov eax, KEY_BUFF + 1 |
2986 | mov eax, KEY_BUFF + 1 |
2986 | mov ebx, KEY_BUFF |
2987 | mov ebx, KEY_BUFF |
2987 | call memmove |
2988 | call memmove |
2988 | pop eax |
2989 | pop eax |
2989 | ;-------------------------------------- |
2990 | ;-------------------------------------- |
2990 | align 4 |
2991 | align 4 |
2991 | .ret_eax: |
2992 | .ret_eax: |
2992 | mov [esp + 32], eax |
2993 | mov [esp + 32], eax |
2993 | ret |
2994 | ret |
2994 | ;-------------------------------------- |
2995 | ;-------------------------------------- |
2995 | align 4 |
2996 | align 4 |
2996 | .finish: |
2997 | .finish: |
2997 | ; test hotkeys buffer |
2998 | ; test hotkeys buffer |
2998 | mov ecx, hotkey_buffer |
2999 | mov ecx, hotkey_buffer |
2999 | ;-------------------------------------- |
3000 | ;-------------------------------------- |
3000 | align 4 |
3001 | align 4 |
3001 | @@: |
3002 | @@: |
3002 | cmp [ecx], ebx |
3003 | cmp [ecx], ebx |
3003 | jz .found |
3004 | jz .found |
3004 | add ecx, 8 |
3005 | add ecx, 8 |
3005 | cmp ecx, hotkey_buffer + 120 * 8 |
3006 | cmp ecx, hotkey_buffer + 120 * 8 |
3006 | jb @b |
3007 | jb @b |
3007 | ret |
3008 | ret |
3008 | ;-------------------------------------- |
3009 | ;-------------------------------------- |
3009 | align 4 |
3010 | align 4 |
3010 | .found: |
3011 | .found: |
3011 | mov ax, [ecx + 6] |
3012 | mov ax, [ecx + 6] |
3012 | shl eax, 16 |
3013 | shl eax, 16 |
3013 | mov ah, [ecx + 4] |
3014 | mov ah, [ecx + 4] |
3014 | mov al, 2 |
3015 | mov al, 2 |
3015 | and dword [ecx + 4], 0 |
3016 | and dword [ecx + 4], 0 |
3016 | and dword [ecx], 0 |
3017 | and dword [ecx], 0 |
3017 | jmp .ret_eax |
3018 | jmp .ret_eax |
3018 | ;------------------------------------------------------------------------------ |
3019 | ;------------------------------------------------------------------------------ |
3019 | align 4 |
3020 | align 4 |
3020 | sys_getbutton: |
3021 | sys_getbutton: |
3021 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3022 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3022 | mov [esp + 32], dword 1 |
3023 | mov [esp + 32], dword 1 |
3023 | movzx ecx, word [WIN_STACK + ebx * 2] |
3024 | movzx ecx, word [WIN_STACK + ebx * 2] |
3024 | mov edx, [TASK_COUNT] ; less than 256 processes |
3025 | mov edx, [TASK_COUNT] ; less than 256 processes |
3025 | cmp ecx, edx |
3026 | cmp ecx, edx |
3026 | jne .exit |
3027 | jne .exit |
3027 | movzx eax, byte [BTN_COUNT] |
3028 | movzx eax, byte [BTN_COUNT] |
3028 | test eax, eax |
3029 | test eax, eax |
3029 | jz .exit |
3030 | jz .exit |
3030 | mov eax, [BTN_BUFF] |
3031 | mov eax, [BTN_BUFF] |
3031 | and al, 0xFE ; delete left button bit |
3032 | and al, 0xFE ; delete left button bit |
3032 | mov [BTN_COUNT], byte 0 |
3033 | mov [BTN_COUNT], byte 0 |
3033 | mov [esp + 32], eax |
3034 | mov [esp + 32], eax |
3034 | ;-------------------------------------- |
3035 | ;-------------------------------------- |
3035 | align 4 |
3036 | align 4 |
3036 | .exit: |
3037 | .exit: |
3037 | ret |
3038 | ret |
3038 | ;------------------------------------------------------------------------------ |
3039 | ;------------------------------------------------------------------------------ |
3039 | align 4 |
3040 | align 4 |
3040 | sys_cpuusage: |
3041 | sys_cpuusage: |
3041 | 3042 | ||
3042 | ; RETURN: |
3043 | ; RETURN: |
3043 | ; |
3044 | ; |
3044 | ; +00 dword process cpu usage |
3045 | ; +00 dword process cpu usage |
3045 | ; +04 word position in windowing stack |
3046 | ; +04 word position in windowing stack |
3046 | ; +06 word windowing stack value at current position (cpu nro) |
3047 | ; +06 word windowing stack value at current position (cpu nro) |
3047 | ; +10 12 bytes name |
3048 | ; +10 12 bytes name |
3048 | ; +22 dword start in mem |
3049 | ; +22 dword start in mem |
3049 | ; +26 dword used mem |
3050 | ; +26 dword used mem |
3050 | ; +30 dword PID , process idenfification number |
3051 | ; +30 dword PID , process idenfification number |
3051 | ; |
3052 | ; |
3052 | 3053 | ||
3053 | cmp ecx, -1 ; who am I ? |
3054 | cmp ecx, -1 ; who am I ? |
3054 | jne .no_who_am_i |
3055 | jne .no_who_am_i |
3055 | mov ecx, [CURRENT_TASK] |
3056 | mov ecx, [CURRENT_TASK] |
3056 | .no_who_am_i: |
3057 | .no_who_am_i: |
3057 | cmp ecx, max_processes |
3058 | cmp ecx, max_processes |
3058 | ja .nofillbuf |
3059 | ja .nofillbuf |
3059 | 3060 | ||
3060 | ; +4: word: position of the window of thread in the window stack |
3061 | ; +4: word: position of the window of thread in the window stack |
3061 | mov ax, [WIN_STACK + ecx * 2] |
3062 | mov ax, [WIN_STACK + ecx * 2] |
3062 | mov [ebx+4], ax |
3063 | mov [ebx+4], ax |
3063 | ; +6: word: number of the thread slot, which window has in the window stack |
3064 | ; +6: word: number of the thread slot, which window has in the window stack |
3064 | ; position ecx (has no relation to the specific thread) |
3065 | ; position ecx (has no relation to the specific thread) |
3065 | mov ax, [WIN_POS + ecx * 2] |
3066 | mov ax, [WIN_POS + ecx * 2] |
3066 | mov [ebx+6], ax |
3067 | mov [ebx+6], ax |
3067 | 3068 | ||
3068 | shl ecx, 5 |
3069 | shl ecx, 5 |
3069 | 3070 | ||
3070 | ; +0: dword: memory usage |
3071 | ; +0: dword: memory usage |
3071 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3072 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3072 | mov [ebx], eax |
3073 | mov [ebx], eax |
3073 | ; +10: 11 bytes: name of the process |
3074 | ; +10: 11 bytes: name of the process |
3074 | push ecx |
3075 | push ecx |
3075 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3076 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3076 | add ebx, 10 |
3077 | add ebx, 10 |
3077 | mov ecx, 11 |
3078 | mov ecx, 11 |
3078 | call memmove |
3079 | call memmove |
3079 | pop ecx |
3080 | pop ecx |
3080 | 3081 | ||
3081 | ; +22: address of the process in memory |
3082 | ; +22: address of the process in memory |
3082 | ; +26: size of used memory - 1 |
3083 | ; +26: size of used memory - 1 |
3083 | push edi |
3084 | push edi |
3084 | lea edi, [ebx+12] |
3085 | lea edi, [ebx+12] |
3085 | xor eax, eax |
3086 | xor eax, eax |
3086 | mov edx, 0x100000*16 |
3087 | mov edx, 0x100000*16 |
3087 | cmp ecx, 1 shl 5 |
3088 | cmp ecx, 1 shl 5 |
3088 | je .os_mem |
3089 | je .os_mem |
3089 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3090 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3090 | mov eax, std_application_base_address |
3091 | mov eax, std_application_base_address |
3091 | .os_mem: |
3092 | .os_mem: |
3092 | stosd |
3093 | stosd |
3093 | lea eax, [edx-1] |
3094 | lea eax, [edx-1] |
3094 | stosd |
3095 | stosd |
3095 | 3096 | ||
3096 | ; +30: PID/TID |
3097 | ; +30: PID/TID |
3097 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3098 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3098 | stosd |
3099 | stosd |
3099 | 3100 | ||
3100 | ; window position and size |
3101 | ; window position and size |
3101 | push esi |
3102 | push esi |
3102 | lea esi, [ecx + window_data + WDATA.box] |
3103 | lea esi, [ecx + window_data + WDATA.box] |
3103 | movsd |
3104 | movsd |
3104 | movsd |
3105 | movsd |
3105 | movsd |
3106 | movsd |
3106 | movsd |
3107 | movsd |
3107 | 3108 | ||
3108 | ; Process state (+50) |
3109 | ; Process state (+50) |
3109 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3110 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3110 | stosd |
3111 | stosd |
3111 | 3112 | ||
3112 | ; Window client area box |
3113 | ; Window client area box |
3113 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3114 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3114 | movsd |
3115 | movsd |
3115 | movsd |
3116 | movsd |
3116 | movsd |
3117 | movsd |
3117 | movsd |
3118 | movsd |
3118 | 3119 | ||
3119 | ; Window state |
3120 | ; Window state |
3120 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3121 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3121 | stosb |
3122 | stosb |
3122 | 3123 | ||
3123 | ; Event mask (+71) |
3124 | ; Event mask (+71) |
3124 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3125 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3125 | stosd |
3126 | stosd |
3126 | 3127 | ||
3127 | pop esi |
3128 | pop esi |
3128 | pop edi |
3129 | pop edi |
3129 | 3130 | ||
3130 | .nofillbuf: |
3131 | .nofillbuf: |
3131 | ; return number of processes |
3132 | ; return number of processes |
3132 | 3133 | ||
3133 | mov eax, [TASK_COUNT] |
3134 | mov eax, [TASK_COUNT] |
3134 | mov [esp+32], eax |
3135 | mov [esp+32], eax |
3135 | ret |
3136 | ret |
3136 | 3137 | ||
3137 | align 4 |
3138 | align 4 |
3138 | sys_clock: |
3139 | sys_clock: |
3139 | cli |
3140 | cli |
3140 | ; Mikhail Lisovin xx Jan 2005 |
3141 | ; Mikhail Lisovin xx Jan 2005 |
3141 | @@: |
3142 | @@: |
3142 | mov al, 10 |
3143 | mov al, 10 |
3143 | out 0x70, al |
3144 | out 0x70, al |
3144 | in al, 0x71 |
3145 | in al, 0x71 |
3145 | test al, al |
3146 | test al, al |
3146 | jns @f |
3147 | jns @f |
3147 | mov esi, 1 |
3148 | mov esi, 1 |
3148 | call delay_ms |
3149 | call delay_ms |
3149 | jmp @b |
3150 | jmp @b |
3150 | @@: |
3151 | @@: |
3151 | ; end Lisovin's fix |
3152 | ; end Lisovin's fix |
3152 | 3153 | ||
3153 | xor al, al ; seconds |
3154 | xor al, al ; seconds |
3154 | out 0x70, al |
3155 | out 0x70, al |
3155 | in al, 0x71 |
3156 | in al, 0x71 |
3156 | movzx ecx, al |
3157 | movzx ecx, al |
3157 | mov al, 02 ; minutes |
3158 | mov al, 02 ; minutes |
3158 | shl ecx, 16 |
3159 | shl ecx, 16 |
3159 | out 0x70, al |
3160 | out 0x70, al |
3160 | in al, 0x71 |
3161 | in al, 0x71 |
3161 | movzx edx, al |
3162 | movzx edx, al |
3162 | mov al, 04 ; hours |
3163 | mov al, 04 ; hours |
3163 | shl edx, 8 |
3164 | shl edx, 8 |
3164 | out 0x70, al |
3165 | out 0x70, al |
3165 | in al, 0x71 |
3166 | in al, 0x71 |
3166 | add ecx, edx |
3167 | add ecx, edx |
3167 | movzx edx, al |
3168 | movzx edx, al |
3168 | add ecx, edx |
3169 | add ecx, edx |
3169 | sti |
3170 | sti |
3170 | mov [esp + 32], ecx |
3171 | mov [esp + 32], ecx |
3171 | ret |
3172 | ret |
3172 | 3173 | ||
3173 | 3174 | ||
3174 | align 4 |
3175 | align 4 |
3175 | 3176 | ||
3176 | sys_date: |
3177 | sys_date: |
3177 | 3178 | ||
3178 | cli |
3179 | cli |
3179 | @@: |
3180 | @@: |
3180 | mov al, 10 |
3181 | mov al, 10 |
3181 | out 0x70, al |
3182 | out 0x70, al |
3182 | in al, 0x71 |
3183 | in al, 0x71 |
3183 | test al, al |
3184 | test al, al |
3184 | jns @f |
3185 | jns @f |
3185 | mov esi, 1 |
3186 | mov esi, 1 |
3186 | call delay_ms |
3187 | call delay_ms |
3187 | jmp @b |
3188 | jmp @b |
3188 | @@: |
3189 | @@: |
3189 | 3190 | ||
3190 | mov ch, 0 |
3191 | mov ch, 0 |
3191 | mov al, 7 ; date |
3192 | mov al, 7 ; date |
3192 | out 0x70, al |
3193 | out 0x70, al |
3193 | in al, 0x71 |
3194 | in al, 0x71 |
3194 | mov cl, al |
3195 | mov cl, al |
3195 | mov al, 8 ; month |
3196 | mov al, 8 ; month |
3196 | shl ecx, 16 |
3197 | shl ecx, 16 |
3197 | out 0x70, al |
3198 | out 0x70, al |
3198 | in al, 0x71 |
3199 | in al, 0x71 |
3199 | mov ch, al |
3200 | mov ch, al |
3200 | mov al, 9 ; year |
3201 | mov al, 9 ; year |
3201 | out 0x70, al |
3202 | out 0x70, al |
3202 | in al, 0x71 |
3203 | in al, 0x71 |
3203 | mov cl, al |
3204 | mov cl, al |
3204 | sti |
3205 | sti |
3205 | mov [esp+32], ecx |
3206 | mov [esp+32], ecx |
3206 | ret |
3207 | ret |
3207 | 3208 | ||
3208 | 3209 | ||
3209 | ; redraw status |
3210 | ; redraw status |
3210 | 3211 | ||
3211 | sys_redrawstat: |
3212 | sys_redrawstat: |
3212 | cmp ebx, 1 |
3213 | cmp ebx, 1 |
3213 | jne no_widgets_away |
3214 | jne no_widgets_away |
3214 | ; buttons away |
3215 | ; buttons away |
3215 | mov ecx, [CURRENT_TASK] |
3216 | mov ecx, [CURRENT_TASK] |
3216 | sys_newba2: |
3217 | sys_newba2: |
3217 | mov edi, [BTN_ADDR] |
3218 | mov edi, [BTN_ADDR] |
3218 | cmp [edi], dword 0 ; empty button list ? |
3219 | cmp [edi], dword 0 ; empty button list ? |
3219 | je end_of_buttons_away |
3220 | je end_of_buttons_away |
3220 | movzx ebx, word [edi] |
3221 | movzx ebx, word [edi] |
3221 | inc ebx |
3222 | inc ebx |
3222 | mov eax, edi |
3223 | mov eax, edi |
3223 | sys_newba: |
3224 | sys_newba: |
3224 | dec ebx |
3225 | dec ebx |
3225 | jz end_of_buttons_away |
3226 | jz end_of_buttons_away |
3226 | 3227 | ||
3227 | add eax, 0x10 |
3228 | add eax, 0x10 |
3228 | cmp cx, [eax] |
3229 | cmp cx, [eax] |
3229 | jnz sys_newba |
3230 | jnz sys_newba |
3230 | 3231 | ||
3231 | push eax ebx ecx |
3232 | push eax ebx ecx |
3232 | mov ecx, ebx |
3233 | mov ecx, ebx |
3233 | inc ecx |
3234 | inc ecx |
3234 | shl ecx, 4 |
3235 | shl ecx, 4 |
3235 | mov ebx, eax |
3236 | mov ebx, eax |
3236 | add eax, 0x10 |
3237 | add eax, 0x10 |
3237 | call memmove |
3238 | call memmove |
3238 | dec dword [edi] |
3239 | dec dword [edi] |
3239 | pop ecx ebx eax |
3240 | pop ecx ebx eax |
3240 | 3241 | ||
3241 | jmp sys_newba2 |
3242 | jmp sys_newba2 |
3242 | 3243 | ||
3243 | end_of_buttons_away: |
3244 | end_of_buttons_away: |
3244 | 3245 | ||
3245 | ret |
3246 | ret |
3246 | 3247 | ||
3247 | no_widgets_away: |
3248 | no_widgets_away: |
3248 | 3249 | ||
3249 | cmp ebx, 2 |
3250 | cmp ebx, 2 |
3250 | jnz srl1 |
3251 | jnz srl1 |
3251 | 3252 | ||
3252 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3253 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3253 | add edx, draw_data - CURRENT_TASK |
3254 | add edx, draw_data - CURRENT_TASK |
3254 | mov [edx + RECT.left], 0 |
3255 | mov [edx + RECT.left], 0 |
3255 | mov [edx + RECT.top], 0 |
3256 | mov [edx + RECT.top], 0 |
3256 | mov eax, [Screen_Max_X] |
3257 | mov eax, [Screen_Max_X] |
3257 | mov [edx + RECT.right], eax |
3258 | mov [edx + RECT.right], eax |
3258 | mov eax, [Screen_Max_Y] |
3259 | mov eax, [Screen_Max_Y] |
3259 | mov [edx + RECT.bottom], eax |
3260 | mov [edx + RECT.bottom], eax |
3260 | 3261 | ||
3261 | srl1: |
3262 | srl1: |
3262 | ret |
3263 | ret |
3263 | 3264 | ||
3264 | ;ok - 100% work |
3265 | ;ok - 100% work |
3265 | ;nt - not tested |
3266 | ;nt - not tested |
3266 | ;--------------------------------------------------------------------------------------------- |
3267 | ;--------------------------------------------------------------------------------------------- |
3267 | ;eax |
3268 | ;eax |
3268 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3269 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3269 | ;1 - change task. Ret nothing. Block. ok. |
3270 | ;1 - change task. Ret nothing. Block. ok. |
3270 | ;2 - performance control |
3271 | ;2 - performance control |
3271 | ; ebx |
3272 | ; ebx |
3272 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3273 | ; 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. |
3274 | ; 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. |
3275 | ; 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. |
3276 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3276 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3277 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3277 | ;eax |
3278 | ;eax |
3278 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3279 | ;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. |
3280 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3280 | ;--------------------------------------------------------------------------------------------- |
3281 | ;--------------------------------------------------------------------------------------------- |
3281 | iglobal |
3282 | iglobal |
3282 | align 4 |
3283 | align 4 |
3283 | sheduler: |
3284 | sheduler: |
3284 | dd sys_sheduler.00 |
3285 | dd sys_sheduler.00 |
3285 | dd change_task |
3286 | dd change_task |
3286 | dd sys_sheduler.02 |
3287 | dd sys_sheduler.02 |
3287 | dd sys_sheduler.03 |
3288 | dd sys_sheduler.03 |
3288 | dd sys_sheduler.04 |
3289 | dd sys_sheduler.04 |
3289 | endg |
3290 | endg |
3290 | sys_sheduler: |
3291 | sys_sheduler: |
3291 | ;rewritten by |
3292 | ;rewritten by |
3292 | jmp dword [sheduler+ebx*4] |
3293 | jmp dword [sheduler+ebx*4] |
3293 | ;.shed_counter: |
3294 | ;.shed_counter: |
3294 | .00: |
3295 | .00: |
3295 | mov eax, [context_counter] |
3296 | mov eax, [context_counter] |
3296 | mov [esp+32], eax |
3297 | mov [esp+32], eax |
3297 | ret |
3298 | ret |
3298 | 3299 | ||
3299 | .02: |
3300 | .02: |
3300 | ;.perf_control: |
3301 | ;.perf_control: |
3301 | inc ebx ;before ebx=2, ebx=3 |
3302 | inc ebx ;before ebx=2, ebx=3 |
3302 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3303 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3303 | jz cache_disable |
3304 | jz cache_disable |
3304 | 3305 | ||
3305 | dec ebx ;ebx=2 |
3306 | dec ebx ;ebx=2 |
3306 | cmp ebx, ecx ; |
3307 | cmp ebx, ecx ; |
3307 | jz cache_enable ;if ecx=2 and ebx=2 |
3308 | jz cache_enable ;if ecx=2 and ebx=2 |
3308 | 3309 | ||
3309 | dec ebx ;ebx=1 |
3310 | dec ebx ;ebx=1 |
3310 | cmp ebx, ecx |
3311 | cmp ebx, ecx |
3311 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3312 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3312 | 3313 | ||
3313 | dec ebx |
3314 | dec ebx |
3314 | test ebx, ecx ;ebx=0 and ecx=0 |
3315 | test ebx, ecx ;ebx=0 and ecx=0 |
3315 | jz modify_pce ;if ecx=0 |
3316 | jz modify_pce ;if ecx=0 |
3316 | 3317 | ||
3317 | ret |
3318 | ret |
3318 | 3319 | ||
3319 | .03: |
3320 | .03: |
3320 | ;.rdmsr_instr: |
3321 | ;.rdmsr_instr: |
3321 | ;now counter in ecx |
3322 | ;now counter in ecx |
3322 | ;(edx:eax) esi:edi => edx:esi |
3323 | ;(edx:eax) esi:edi => edx:esi |
3323 | mov eax, esi |
3324 | mov eax, esi |
3324 | mov ecx, edx |
3325 | mov ecx, edx |
3325 | rdmsr |
3326 | rdmsr |
3326 | mov [esp+32], eax |
3327 | mov [esp+32], eax |
3327 | mov [esp+20], edx ;ret in ebx? |
3328 | mov [esp+20], edx ;ret in ebx? |
3328 | ret |
3329 | ret |
3329 | 3330 | ||
3330 | .04: |
3331 | .04: |
3331 | ;.wrmsr_instr: |
3332 | ;.wrmsr_instr: |
3332 | ;now counter in ecx |
3333 | ;now counter in ecx |
3333 | ;(edx:eax) esi:edi => edx:esi |
3334 | ;(edx:eax) esi:edi => edx:esi |
3334 | ; Fast Call MSR can't be destroy |
3335 | ; Fast Call MSR can't be destroy |
3335 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3336 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3336 | ; включаются/выключаются расширенные возможности |
3337 | ; включаются/выключаются расширенные возможности |
3337 | cmp edx, MSR_SYSENTER_CS |
3338 | cmp edx, MSR_SYSENTER_CS |
3338 | je @f |
3339 | je @f |
3339 | cmp edx, MSR_SYSENTER_ESP |
3340 | cmp edx, MSR_SYSENTER_ESP |
3340 | je @f |
3341 | je @f |
3341 | cmp edx, MSR_SYSENTER_EIP |
3342 | cmp edx, MSR_SYSENTER_EIP |
3342 | je @f |
3343 | je @f |
3343 | cmp edx, MSR_AMD_STAR |
3344 | cmp edx, MSR_AMD_STAR |
3344 | je @f |
3345 | je @f |
3345 | 3346 | ||
3346 | mov eax, esi |
3347 | mov eax, esi |
3347 | mov ecx, edx |
3348 | mov ecx, edx |
3348 | wrmsr |
3349 | wrmsr |
3349 | ; mov [esp + 32], eax |
3350 | ; mov [esp + 32], eax |
3350 | ; mov [esp + 20], edx ;ret in ebx? |
3351 | ; mov [esp + 20], edx ;ret in ebx? |
3351 | @@: |
3352 | @@: |
3352 | ret |
3353 | ret |
3353 | 3354 | ||
3354 | cache_disable: |
3355 | cache_disable: |
3355 | mov eax, cr0 |
3356 | mov eax, cr0 |
3356 | or eax, 01100000000000000000000000000000b |
3357 | or eax, 01100000000000000000000000000000b |
3357 | mov cr0, eax |
3358 | mov cr0, eax |
3358 | wbinvd ;set MESI |
3359 | wbinvd ;set MESI |
3359 | ret |
3360 | ret |
3360 | 3361 | ||
3361 | cache_enable: |
3362 | cache_enable: |
3362 | mov eax, cr0 |
3363 | mov eax, cr0 |
3363 | and eax, 10011111111111111111111111111111b |
3364 | and eax, 10011111111111111111111111111111b |
3364 | mov cr0, eax |
3365 | mov cr0, eax |
3365 | ret |
3366 | ret |
3366 | 3367 | ||
3367 | is_cache_enabled: |
3368 | is_cache_enabled: |
3368 | mov eax, cr0 |
3369 | mov eax, cr0 |
3369 | mov ebx, eax |
3370 | mov ebx, eax |
3370 | and eax, 01100000000000000000000000000000b |
3371 | and eax, 01100000000000000000000000000000b |
3371 | jz cache_disabled |
3372 | jz cache_disabled |
3372 | mov [esp+32], ebx |
3373 | mov [esp+32], ebx |
3373 | cache_disabled: |
3374 | cache_disabled: |
3374 | mov dword [esp+32], eax;0 |
3375 | mov dword [esp+32], eax;0 |
3375 | ret |
3376 | ret |
3376 | 3377 | ||
3377 | modify_pce: |
3378 | modify_pce: |
3378 | mov eax, cr4 |
3379 | mov eax, cr4 |
3379 | ; mov ebx,0 |
3380 | ; mov ebx,0 |
3380 | ; or bx,100000000b ;pce |
3381 | ; or bx,100000000b ;pce |
3381 | ; xor eax,ebx ;invert pce |
3382 | ; xor eax,ebx ;invert pce |
3382 | bts eax, 8;pce=cr4[8] |
3383 | bts eax, 8;pce=cr4[8] |
3383 | mov cr4, eax |
3384 | mov cr4, eax |
3384 | mov [esp+32], eax |
3385 | mov [esp+32], eax |
3385 | ret |
3386 | ret |
3386 | ;--------------------------------------------------------------------------------------------- |
3387 | ;--------------------------------------------------------------------------------------------- |
3387 | 3388 | ||
3388 | 3389 | ||
3389 | ; check if pixel is allowed to be drawn |
3390 | ; check if pixel is allowed to be drawn |
3390 | 3391 | ||
3391 | ;checkpixel: |
3392 | ;checkpixel: |
3392 | ; push eax edx |
3393 | ; push eax edx |
3393 | 3394 | ||
3394 | ;; mov edx, [Screen_Max_X] ; screen x size |
3395 | ;; mov edx, [Screen_Max_X] ; screen x size |
3395 | ;; inc edx |
3396 | ;; inc edx |
3396 | ;; imul edx, ebx |
3397 | ;; imul edx, ebx |
3397 | ; mov edx, [d_width_calc_area + ebx*4] |
3398 | ; mov edx, [d_width_calc_area + ebx*4] |
3398 | ; add eax, [_WinMapAddress] |
3399 | ; add eax, [_WinMapAddress] |
3399 | ; mov dl, [eax+edx]; lea eax, [...] |
3400 | ; mov dl, [eax+edx]; lea eax, [...] |
3400 | 3401 | ||
3401 | ; xor ecx, ecx |
3402 | ; xor ecx, ecx |
3402 | ; mov eax, [CURRENT_TASK] |
3403 | ; mov eax, [CURRENT_TASK] |
3403 | ; cmp al, dl |
3404 | ; cmp al, dl |
3404 | ; setne cl |
3405 | ; setne cl |
3405 | 3406 | ||
3406 | ; pop edx eax |
3407 | ; pop edx eax |
3407 | ; ret |
3408 | ; ret |
3408 | 3409 | ||
3409 | iglobal |
3410 | iglobal |
3410 | cpustring db 'CPU',0 |
3411 | cpustring db 'CPU',0 |
3411 | endg |
3412 | endg |
3412 | 3413 | ||
3413 | uglobal |
3414 | uglobal |
3414 | background_defined db 0 ; diamond, 11.04.2006 |
3415 | background_defined db 0 ; diamond, 11.04.2006 |
3415 | endg |
3416 | endg |
3416 | ;----------------------------------------------------------------------------- |
3417 | ;----------------------------------------------------------------------------- |
3417 | align 4 |
3418 | align 4 |
3418 | checkmisc: |
3419 | checkmisc: |
3419 | cmp [ctrl_alt_del], 1 |
3420 | cmp [ctrl_alt_del], 1 |
3420 | jne nocpustart |
3421 | jne nocpustart |
3421 | 3422 | ||
3422 | mov ebp, cpustring |
3423 | mov ebp, cpustring |
3423 | call fs_execute_from_sysdir |
3424 | call fs_execute_from_sysdir |
3424 | 3425 | ||
3425 | mov [ctrl_alt_del], 0 |
3426 | mov [ctrl_alt_del], 0 |
3426 | ;-------------------------------------- |
3427 | ;-------------------------------------- |
3427 | align 4 |
3428 | align 4 |
3428 | nocpustart: |
3429 | nocpustart: |
3429 | cmp [mouse_active], 1 |
3430 | cmp [mouse_active], 1 |
3430 | jne mouse_not_active |
3431 | jne mouse_not_active |
3431 | mov [mouse_active], 0 |
3432 | mov [mouse_active], 0 |
3432 | 3433 | ||
3433 | xor edi, edi |
3434 | xor edi, edi |
3434 | mov ebx, CURRENT_TASK |
3435 | mov ebx, CURRENT_TASK |
3435 | 3436 | ||
3436 | mov ecx, [TASK_COUNT] |
3437 | mov ecx, [TASK_COUNT] |
3437 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3438 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3438 | shl eax, 8 |
3439 | shl eax, 8 |
3439 | push eax |
3440 | push eax |
3440 | 3441 | ||
3441 | movzx eax, word [MOUSE_X] |
3442 | movzx eax, word [MOUSE_X] |
3442 | movzx edx, word [MOUSE_Y] |
3443 | movzx edx, word [MOUSE_Y] |
3443 | ;-------------------------------------- |
3444 | ;-------------------------------------- |
3444 | align 4 |
3445 | align 4 |
3445 | .set_mouse_event: |
3446 | .set_mouse_event: |
3446 | add edi, 256 |
3447 | add edi, 256 |
3447 | add ebx, 32 |
3448 | add ebx, 32 |
3448 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3449 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3449 | jz .pos_filter |
3450 | jz .pos_filter |
3450 | 3451 | ||
3451 | cmp edi, [esp] ; skip if filtration active |
3452 | cmp edi, [esp] ; skip if filtration active |
3452 | jne .skip |
3453 | jne .skip |
3453 | ;-------------------------------------- |
3454 | ;-------------------------------------- |
3454 | align 4 |
3455 | align 4 |
3455 | .pos_filter: |
3456 | .pos_filter: |
3456 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3457 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3457 | jz .set |
3458 | jz .set |
3458 | 3459 | ||
3459 | mov esi, [ebx-twdw+WDATA.box.left] |
3460 | mov esi, [ebx-twdw+WDATA.box.left] |
3460 | cmp eax, esi |
3461 | cmp eax, esi |
3461 | jb .skip |
3462 | jb .skip |
3462 | add esi, [ebx-twdw+WDATA.box.width] |
3463 | add esi, [ebx-twdw+WDATA.box.width] |
3463 | cmp eax, esi |
3464 | cmp eax, esi |
3464 | ja .skip |
3465 | ja .skip |
3465 | 3466 | ||
3466 | mov esi, [ebx-twdw+WDATA.box.top] |
3467 | mov esi, [ebx-twdw+WDATA.box.top] |
3467 | cmp edx, esi |
3468 | cmp edx, esi |
3468 | jb .skip |
3469 | jb .skip |
3469 | add esi, [ebx-twdw+WDATA.box.height] |
3470 | add esi, [ebx-twdw+WDATA.box.height] |
3470 | cmp edx, esi |
3471 | cmp edx, esi |
3471 | ja .skip |
3472 | ja .skip |
3472 | ;-------------------------------------- |
3473 | ;-------------------------------------- |
3473 | align 4 |
3474 | align 4 |
3474 | .set: |
3475 | .set: |
3475 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3476 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3476 | ;-------------------------------------- |
3477 | ;-------------------------------------- |
3477 | align 4 |
3478 | align 4 |
3478 | .skip: |
3479 | .skip: |
3479 | loop .set_mouse_event |
3480 | loop .set_mouse_event |
3480 | 3481 | ||
3481 | pop eax |
3482 | pop eax |
3482 | ;-------------------------------------- |
3483 | ;-------------------------------------- |
3483 | align 4 |
3484 | align 4 |
3484 | mouse_not_active: |
3485 | mouse_not_active: |
3485 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3486 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3486 | jz nobackgr |
3487 | jz nobackgr |
3487 | 3488 | ||
3488 | cmp [background_defined], 0 |
3489 | cmp [background_defined], 0 |
3489 | jz nobackgr |
3490 | jz nobackgr |
3490 | ;-------------------------------------- |
3491 | ;-------------------------------------- |
3491 | align 4 |
3492 | align 4 |
3492 | backgr: |
3493 | backgr: |
3493 | mov eax, [draw_data+32 + RECT.left] |
3494 | mov eax, [draw_data+32 + RECT.left] |
3494 | shl eax, 16 |
3495 | shl eax, 16 |
3495 | add eax, [draw_data+32 + RECT.right] |
3496 | add eax, [draw_data+32 + RECT.right] |
3496 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3497 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3497 | 3498 | ||
3498 | mov eax, [draw_data+32 + RECT.top] |
3499 | mov eax, [draw_data+32 + RECT.top] |
3499 | shl eax, 16 |
3500 | shl eax, 16 |
3500 | add eax, [draw_data+32 + RECT.bottom] |
3501 | add eax, [draw_data+32 + RECT.bottom] |
3501 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3502 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3502 | 3503 | ||
3503 | call drawbackground |
3504 | call drawbackground |
3504 | ; DEBUGF 1, "K : drawbackground\n" |
3505 | ; DEBUGF 1, "K : drawbackground\n" |
3505 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3506 | ; 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] |
3507 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3507 | ;--------- set event 5 start ---------- |
3508 | ;--------- set event 5 start ---------- |
3508 | push ecx edi |
3509 | push ecx edi |
3509 | xor edi, edi |
3510 | xor edi, edi |
3510 | mov ecx, [TASK_COUNT] |
3511 | mov ecx, [TASK_COUNT] |
3511 | ;-------------------------------------- |
3512 | ;-------------------------------------- |
3512 | align 4 |
3513 | align 4 |
3513 | set_bgr_event: |
3514 | set_bgr_event: |
3514 | add edi, 256 |
3515 | add edi, 256 |
3515 | mov eax, [BG_Rect_X_left_right] |
3516 | mov eax, [BG_Rect_X_left_right] |
3516 | mov edx, [BG_Rect_Y_top_bottom] |
3517 | mov edx, [BG_Rect_Y_top_bottom] |
3517 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3518 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3518 | jz .set |
3519 | jz .set |
3519 | .join: |
3520 | .join: |
3520 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3521 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3521 | jae @f |
3522 | jae @f |
3522 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3523 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3523 | @@: |
3524 | @@: |
3524 | shr eax, 16 |
3525 | shr eax, 16 |
3525 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3526 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3526 | jbe @f |
3527 | jbe @f |
3527 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3528 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3528 | @@: |
3529 | @@: |
3529 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3530 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3530 | jae @f |
3531 | jae @f |
3531 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3532 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3532 | @@: |
3533 | @@: |
3533 | shr edx, 16 |
3534 | shr edx, 16 |
3534 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3535 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3535 | jbe @f |
3536 | jbe @f |
3536 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3537 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3537 | @@: |
3538 | @@: |
3538 | jmp .common |
3539 | jmp .common |
3539 | .set: |
3540 | .set: |
3540 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3541 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3541 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3542 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3542 | .common: |
3543 | .common: |
3543 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3544 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3544 | loop set_bgr_event |
3545 | loop set_bgr_event |
3545 | pop edi ecx |
3546 | pop edi ecx |
3546 | ;--------- set event 5 stop ----------- |
3547 | ;--------- set event 5 stop ----------- |
3547 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3548 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3548 | jnz backgr |
3549 | jnz backgr |
3549 | 3550 | ||
3550 | xor eax, eax |
3551 | xor eax, eax |
3551 | mov [draw_data+32 + RECT.left], eax |
3552 | mov [draw_data+32 + RECT.left], eax |
3552 | mov [draw_data+32 + RECT.top], eax |
3553 | mov [draw_data+32 + RECT.top], eax |
3553 | mov [draw_data+32 + RECT.right], eax |
3554 | mov [draw_data+32 + RECT.right], eax |
3554 | mov [draw_data+32 + RECT.bottom], eax |
3555 | mov [draw_data+32 + RECT.bottom], eax |
3555 | ;-------------------------------------- |
3556 | ;-------------------------------------- |
3556 | align 4 |
3557 | align 4 |
3557 | nobackgr: |
3558 | nobackgr: |
3558 | ; system shutdown request |
3559 | ; system shutdown request |
3559 | cmp [SYS_SHUTDOWN], byte 0 |
3560 | cmp [SYS_SHUTDOWN], byte 0 |
3560 | je noshutdown |
3561 | je noshutdown |
3561 | 3562 | ||
3562 | mov edx, [shutdown_processes] |
3563 | mov edx, [shutdown_processes] |
3563 | 3564 | ||
3564 | cmp [SYS_SHUTDOWN], dl |
3565 | cmp [SYS_SHUTDOWN], dl |
3565 | jne noshutdown |
3566 | jne noshutdown |
3566 | 3567 | ||
3567 | lea ecx, [edx-1] |
3568 | lea ecx, [edx-1] |
3568 | mov edx, OS_BASE+0x3040 |
3569 | mov edx, OS_BASE+0x3040 |
3569 | jecxz no_mark_system_shutdown |
3570 | jecxz no_mark_system_shutdown |
3570 | ;-------------------------------------- |
3571 | ;-------------------------------------- |
3571 | align 4 |
3572 | align 4 |
3572 | markz: |
3573 | markz: |
3573 | push ecx edx |
3574 | push ecx edx |
3574 | cmp [edx+TASKDATA.state], 9 |
3575 | cmp [edx+TASKDATA.state], 9 |
3575 | jz .nokill |
3576 | jz .nokill |
3576 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3577 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3577 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3578 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3578 | jz .nokill |
3579 | jz .nokill |
3579 | call request_terminate |
3580 | call request_terminate |
3580 | jmp .common |
3581 | jmp .common |
3581 | .nokill: |
3582 | .nokill: |
3582 | dec byte [SYS_SHUTDOWN] |
3583 | dec byte [SYS_SHUTDOWN] |
3583 | xor eax, eax |
3584 | xor eax, eax |
3584 | .common: |
3585 | .common: |
3585 | pop edx ecx |
3586 | pop edx ecx |
3586 | test eax, eax |
3587 | test eax, eax |
3587 | jz @f |
3588 | jz @f |
3588 | mov [edx+TASKDATA.state], byte 3 |
3589 | mov [edx+TASKDATA.state], byte 3 |
3589 | @@: |
3590 | @@: |
3590 | add edx, 0x20 |
3591 | add edx, 0x20 |
3591 | loop markz |
3592 | loop markz |
3592 | call wakeup_osloop |
3593 | call wakeup_osloop |
3593 | ;-------------------------------------- |
3594 | ;-------------------------------------- |
3594 | align 4 |
3595 | align 4 |
3595 | @@: |
3596 | @@: |
3596 | no_mark_system_shutdown: |
3597 | no_mark_system_shutdown: |
3597 | dec byte [SYS_SHUTDOWN] |
3598 | dec byte [SYS_SHUTDOWN] |
3598 | je system_shutdown |
3599 | je system_shutdown |
3599 | ;-------------------------------------- |
3600 | ;-------------------------------------- |
3600 | align 4 |
3601 | align 4 |
3601 | noshutdown: |
3602 | noshutdown: |
3602 | mov eax, [TASK_COUNT] ; termination |
3603 | mov eax, [TASK_COUNT] ; termination |
3603 | mov ebx, TASK_DATA+TASKDATA.state |
3604 | mov ebx, TASK_DATA+TASKDATA.state |
3604 | mov esi, 1 |
3605 | mov esi, 1 |
3605 | ;-------------------------------------- |
3606 | ;-------------------------------------- |
3606 | align 4 |
3607 | align 4 |
3607 | newct: |
3608 | newct: |
3608 | mov cl, [ebx] |
3609 | mov cl, [ebx] |
3609 | cmp cl, byte 3 |
3610 | cmp cl, byte 3 |
3610 | jz .terminate |
3611 | jz .terminate |
3611 | 3612 | ||
3612 | cmp cl, byte 4 |
3613 | cmp cl, byte 4 |
3613 | jnz .noterminate |
3614 | jnz .noterminate |
3614 | .terminate: |
3615 | .terminate: |
3615 | pushad |
3616 | pushad |
3616 | mov ecx, eax |
3617 | mov ecx, eax |
3617 | shl ecx, 8 |
3618 | shl ecx, 8 |
3618 | add ecx, SLOT_BASE |
3619 | add ecx, SLOT_BASE |
3619 | call restore_default_cursor_before_killing |
3620 | call restore_default_cursor_before_killing |
3620 | popad |
3621 | popad |
3621 | 3622 | ||
3622 | pushad |
3623 | pushad |
3623 | call terminate |
3624 | call terminate |
3624 | popad |
3625 | popad |
3625 | cmp byte [SYS_SHUTDOWN], 0 |
3626 | cmp byte [SYS_SHUTDOWN], 0 |
3626 | jz .noterminate |
3627 | jz .noterminate |
3627 | dec byte [SYS_SHUTDOWN] |
3628 | dec byte [SYS_SHUTDOWN] |
3628 | je system_shutdown |
3629 | je system_shutdown |
3629 | 3630 | ||
3630 | .noterminate: |
3631 | .noterminate: |
3631 | add ebx, 0x20 |
3632 | add ebx, 0x20 |
3632 | inc esi |
3633 | inc esi |
3633 | dec eax |
3634 | dec eax |
3634 | jnz newct |
3635 | jnz newct |
3635 | ret |
3636 | ret |
3636 | ;----------------------------------------------------------------------------- |
3637 | ;----------------------------------------------------------------------------- |
3637 | align 4 |
3638 | align 4 |
3638 | redrawscreen: |
3639 | redrawscreen: |
3639 | ; eax , if process window_data base is eax, do not set flag/limits |
3640 | ; eax , if process window_data base is eax, do not set flag/limits |
3640 | 3641 | ||
3641 | pushad |
3642 | pushad |
3642 | push eax |
3643 | push eax |
3643 | 3644 | ||
3644 | ;;; mov ebx,2 |
3645 | ;;; mov ebx,2 |
3645 | ;;; call delay_hs |
3646 | ;;; call delay_hs |
3646 | 3647 | ||
3647 | ;mov ecx,0 ; redraw flags for apps |
3648 | ;mov ecx,0 ; redraw flags for apps |
3648 | xor ecx, ecx |
3649 | xor ecx, ecx |
3649 | ;-------------------------------------- |
3650 | ;-------------------------------------- |
3650 | align 4 |
3651 | align 4 |
3651 | newdw2: |
3652 | newdw2: |
3652 | inc ecx |
3653 | inc ecx |
3653 | push ecx |
3654 | push ecx |
3654 | 3655 | ||
3655 | mov eax, ecx |
3656 | mov eax, ecx |
3656 | shl eax, 5 |
3657 | shl eax, 5 |
3657 | add eax, window_data |
3658 | add eax, window_data |
3658 | 3659 | ||
3659 | cmp eax, [esp+4] |
3660 | cmp eax, [esp+4] |
3660 | je not_this_task |
3661 | je not_this_task |
3661 | ; check if window in redraw area |
3662 | ; check if window in redraw area |
3662 | mov edi, eax |
3663 | mov edi, eax |
3663 | 3664 | ||
3664 | cmp ecx, 1 ; limit for background |
3665 | cmp ecx, 1 ; limit for background |
3665 | jz bgli |
3666 | jz bgli |
3666 | 3667 | ||
3667 | mov eax, [edi + WDATA.box.left] |
3668 | mov eax, [edi + WDATA.box.left] |
3668 | mov ebx, [edi + WDATA.box.top] |
3669 | mov ebx, [edi + WDATA.box.top] |
3669 | mov ecx, [edi + WDATA.box.width] |
3670 | mov ecx, [edi + WDATA.box.width] |
3670 | mov edx, [edi + WDATA.box.height] |
3671 | mov edx, [edi + WDATA.box.height] |
3671 | add ecx, eax |
3672 | add ecx, eax |
3672 | add edx, ebx |
3673 | add edx, ebx |
3673 | 3674 | ||
3674 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3675 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3675 | cmp ecx, ebx |
3676 | cmp ecx, ebx |
3676 | jb ricino |
3677 | jb ricino |
3677 | 3678 | ||
3678 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3679 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3679 | cmp ecx, eax |
3680 | cmp ecx, eax |
3680 | jb ricino |
3681 | jb ricino |
3681 | 3682 | ||
3682 | mov eax, [edi + WDATA.box.left] |
3683 | mov eax, [edi + WDATA.box.left] |
3683 | mov ebx, [edi + WDATA.box.top] |
3684 | mov ebx, [edi + WDATA.box.top] |
3684 | mov ecx, [edi + WDATA.box.width] |
3685 | mov ecx, [edi + WDATA.box.width] |
3685 | mov edx, [edi + WDATA.box.height] |
3686 | mov edx, [edi + WDATA.box.height] |
3686 | add ecx, eax |
3687 | add ecx, eax |
3687 | add edx, ebx |
3688 | add edx, ebx |
3688 | 3689 | ||
3689 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3690 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3690 | cmp edx, eax |
3691 | cmp edx, eax |
3691 | jb ricino |
3692 | jb ricino |
3692 | 3693 | ||
3693 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3694 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3694 | cmp ecx, eax |
3695 | cmp ecx, eax |
3695 | jb ricino |
3696 | jb ricino |
3696 | ;-------------------------------------- |
3697 | ;-------------------------------------- |
3697 | align 4 |
3698 | align 4 |
3698 | bgli: |
3699 | bgli: |
3699 | cmp dword[esp], 1 |
3700 | cmp dword[esp], 1 |
3700 | jnz .az |
3701 | jnz .az |
3701 | 3702 | ||
3702 | cmp byte[REDRAW_BACKGROUND], 0 |
3703 | cmp byte[REDRAW_BACKGROUND], 0 |
3703 | jz .az |
3704 | jz .az |
3704 | 3705 | ||
3705 | mov dl, 0 |
3706 | mov dl, 0 |
3706 | lea eax, [edi+draw_data-window_data] |
3707 | lea eax, [edi+draw_data-window_data] |
3707 | mov ebx, [draw_limits.left] |
3708 | mov ebx, [draw_limits.left] |
3708 | cmp ebx, [eax+RECT.left] |
3709 | cmp ebx, [eax+RECT.left] |
3709 | jae @f |
3710 | jae @f |
3710 | 3711 | ||
3711 | mov [eax+RECT.left], ebx |
3712 | mov [eax+RECT.left], ebx |
3712 | mov dl, 1 |
3713 | mov dl, 1 |
3713 | ;-------------------------------------- |
3714 | ;-------------------------------------- |
3714 | align 4 |
3715 | align 4 |
3715 | @@: |
3716 | @@: |
3716 | mov ebx, [draw_limits.top] |
3717 | mov ebx, [draw_limits.top] |
3717 | cmp ebx, [eax+RECT.top] |
3718 | cmp ebx, [eax+RECT.top] |
3718 | jae @f |
3719 | jae @f |
3719 | 3720 | ||
3720 | mov [eax+RECT.top], ebx |
3721 | mov [eax+RECT.top], ebx |
3721 | mov dl, 1 |
3722 | mov dl, 1 |
3722 | ;-------------------------------------- |
3723 | ;-------------------------------------- |
3723 | align 4 |
3724 | align 4 |
3724 | @@: |
3725 | @@: |
3725 | mov ebx, [draw_limits.right] |
3726 | mov ebx, [draw_limits.right] |
3726 | cmp ebx, [eax+RECT.right] |
3727 | cmp ebx, [eax+RECT.right] |
3727 | jbe @f |
3728 | jbe @f |
3728 | 3729 | ||
3729 | mov [eax+RECT.right], ebx |
3730 | mov [eax+RECT.right], ebx |
3730 | mov dl, 1 |
3731 | mov dl, 1 |
3731 | ;-------------------------------------- |
3732 | ;-------------------------------------- |
3732 | align 4 |
3733 | align 4 |
3733 | @@: |
3734 | @@: |
3734 | mov ebx, [draw_limits.bottom] |
3735 | mov ebx, [draw_limits.bottom] |
3735 | cmp ebx, [eax+RECT.bottom] |
3736 | cmp ebx, [eax+RECT.bottom] |
3736 | jbe @f |
3737 | jbe @f |
3737 | 3738 | ||
3738 | mov [eax+RECT.bottom], ebx |
3739 | mov [eax+RECT.bottom], ebx |
3739 | mov dl, 1 |
3740 | mov dl, 1 |
3740 | ;-------------------------------------- |
3741 | ;-------------------------------------- |
3741 | align 4 |
3742 | align 4 |
3742 | @@: |
3743 | @@: |
3743 | add byte[REDRAW_BACKGROUND], dl |
3744 | add byte[REDRAW_BACKGROUND], dl |
3744 | call wakeup_osloop |
3745 | call wakeup_osloop |
3745 | jmp newdw8 |
3746 | jmp newdw8 |
3746 | ;-------------------------------------- |
3747 | ;-------------------------------------- |
3747 | align 4 |
3748 | align 4 |
3748 | .az: |
3749 | .az: |
3749 | mov eax, edi |
3750 | mov eax, edi |
3750 | add eax, draw_data-window_data |
3751 | add eax, draw_data-window_data |
3751 | 3752 | ||
3752 | mov ebx, [draw_limits.left] ; set limits |
3753 | mov ebx, [draw_limits.left] ; set limits |
3753 | mov [eax + RECT.left], ebx |
3754 | mov [eax + RECT.left], ebx |
3754 | mov ebx, [draw_limits.top] |
3755 | mov ebx, [draw_limits.top] |
3755 | mov [eax + RECT.top], ebx |
3756 | mov [eax + RECT.top], ebx |
3756 | mov ebx, [draw_limits.right] |
3757 | mov ebx, [draw_limits.right] |
3757 | mov [eax + RECT.right], ebx |
3758 | mov [eax + RECT.right], ebx |
3758 | mov ebx, [draw_limits.bottom] |
3759 | mov ebx, [draw_limits.bottom] |
3759 | mov [eax + RECT.bottom], ebx |
3760 | mov [eax + RECT.bottom], ebx |
3760 | 3761 | ||
3761 | sub eax, draw_data-window_data |
3762 | sub eax, draw_data-window_data |
3762 | 3763 | ||
3763 | cmp dword [esp], 1 |
3764 | cmp dword [esp], 1 |
3764 | jne nobgrd |
3765 | jne nobgrd |
3765 | inc byte[REDRAW_BACKGROUND] |
3766 | inc byte[REDRAW_BACKGROUND] |
3766 | call wakeup_osloop |
3767 | call wakeup_osloop |
3767 | ;-------------------------------------- |
3768 | ;-------------------------------------- |
3768 | align 4 |
3769 | align 4 |
3769 | newdw8: |
3770 | newdw8: |
3770 | nobgrd: |
3771 | nobgrd: |
3771 | 3772 | ||
3772 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3773 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3773 | ;-------------------------------------- |
3774 | ;-------------------------------------- |
3774 | align 4 |
3775 | align 4 |
3775 | ricino: |
3776 | ricino: |
3776 | not_this_task: |
3777 | not_this_task: |
3777 | pop ecx |
3778 | pop ecx |
3778 | 3779 | ||
3779 | cmp ecx, [TASK_COUNT] |
3780 | cmp ecx, [TASK_COUNT] |
3780 | jle newdw2 |
3781 | jle newdw2 |
3781 | 3782 | ||
3782 | pop eax |
3783 | pop eax |
3783 | popad |
3784 | popad |
3784 | ret |
3785 | ret |
3785 | ;----------------------------------------------------------------------------- |
3786 | ;----------------------------------------------------------------------------- |
3786 | align 4 |
3787 | align 4 |
3787 | calculatebackground: ; background |
3788 | calculatebackground: ; background |
3788 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3789 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3789 | mov eax, 0x01010101 |
3790 | mov eax, 0x01010101 |
3790 | mov ecx, [_WinMapSize] |
3791 | mov ecx, [_WinMapSize] |
3791 | shr ecx, 2 |
3792 | shr ecx, 2 |
3792 | rep stosd |
3793 | rep stosd |
3793 | 3794 | ||
3794 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3795 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3795 | ret |
3796 | ret |
3796 | ;----------------------------------------------------------------------------- |
3797 | ;----------------------------------------------------------------------------- |
3797 | uglobal |
3798 | uglobal |
3798 | imax dd 0x0 |
3799 | imax dd 0x0 |
3799 | endg |
3800 | endg |
3800 | ;----------------------------------------------------------------------------- |
3801 | ;----------------------------------------------------------------------------- |
3801 | align 4 |
3802 | align 4 |
3802 | delay_ms: ; delay in 1/1000 sec |
3803 | delay_ms: ; delay in 1/1000 sec |
3803 | push eax |
3804 | push eax |
3804 | push ecx |
3805 | push ecx |
3805 | 3806 | ||
3806 | mov ecx, esi |
3807 | mov ecx, esi |
3807 | ; |
3808 | ; |
3808 | imul ecx, 33941 |
3809 | imul ecx, 33941 |
3809 | shr ecx, 9 |
3810 | shr ecx, 9 |
3810 | ; |
3811 | ; |
3811 | 3812 | ||
3812 | in al, 0x61 |
3813 | in al, 0x61 |
3813 | and al, 0x10 |
3814 | and al, 0x10 |
3814 | mov ah, al |
3815 | mov ah, al |
3815 | cld |
3816 | cld |
3816 | ;-------------------------------------- |
3817 | ;-------------------------------------- |
3817 | align 4 |
3818 | align 4 |
3818 | cnt1: |
3819 | cnt1: |
3819 | in al, 0x61 |
3820 | in al, 0x61 |
3820 | and al, 0x10 |
3821 | and al, 0x10 |
3821 | cmp al, ah |
3822 | cmp al, ah |
3822 | jz cnt1 |
3823 | jz cnt1 |
3823 | 3824 | ||
3824 | mov ah, al |
3825 | mov ah, al |
3825 | loop cnt1 |
3826 | loop cnt1 |
3826 | 3827 | ||
3827 | pop ecx |
3828 | pop ecx |
3828 | pop eax |
3829 | pop eax |
3829 | ret |
3830 | ret |
3830 | ;----------------------------------------------------------------------------- |
3831 | ;----------------------------------------------------------------------------- |
3831 | align 4 |
3832 | align 4 |
3832 | set_app_param: |
3833 | set_app_param: |
3833 | mov edi, [TASK_BASE] |
3834 | mov edi, [TASK_BASE] |
3834 | mov eax, ebx |
3835 | mov eax, ebx |
3835 | btr eax, 3 ; move MOUSE_FILTRATION |
3836 | btr eax, 3 ; move MOUSE_FILTRATION |
3836 | mov ebx, [current_slot] ; bit into event_filter |
3837 | mov ebx, [current_slot] ; bit into event_filter |
3837 | setc byte [ebx+APPDATA.event_filter] |
3838 | setc byte [ebx+APPDATA.event_filter] |
3838 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3839 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3839 | mov [esp+32], eax ; return old mask value |
3840 | mov [esp+32], eax ; return old mask value |
3840 | ret |
3841 | ret |
3841 | ;----------------------------------------------------------------------------- |
3842 | ;----------------------------------------------------------------------------- |
3842 | 3843 | ||
3843 | ; this is for syscall |
3844 | ; this is for syscall |
3844 | proc delay_hs_unprotected |
3845 | proc delay_hs_unprotected |
3845 | call unprotect_from_terminate |
3846 | call unprotect_from_terminate |
3846 | call delay_hs |
3847 | call delay_hs |
3847 | call protect_from_terminate |
3848 | call protect_from_terminate |
3848 | ret |
3849 | ret |
3849 | endp |
3850 | endp |
3850 | 3851 | ||
3851 | if 1 |
3852 | if 1 |
3852 | align 4 |
3853 | align 4 |
3853 | delay_hs: ; delay in 1/100 secs |
3854 | delay_hs: ; delay in 1/100 secs |
3854 | ; ebx = delay time |
3855 | ; ebx = delay time |
3855 | 3856 | ||
3856 | pushad |
3857 | pushad |
3857 | push ebx |
3858 | push ebx |
3858 | xor esi, esi |
3859 | xor esi, esi |
3859 | mov ecx, MANUAL_DESTROY |
3860 | mov ecx, MANUAL_DESTROY |
3860 | call create_event |
3861 | call create_event |
3861 | test eax, eax |
3862 | test eax, eax |
3862 | jz .done |
3863 | jz .done |
3863 | 3864 | ||
3864 | mov ebx, edx |
3865 | mov ebx, edx |
3865 | mov ecx, [esp] |
3866 | mov ecx, [esp] |
3866 | push edx |
3867 | push edx |
3867 | push eax |
3868 | push eax |
3868 | call wait_event_timeout |
3869 | call wait_event_timeout |
3869 | pop eax |
3870 | pop eax |
3870 | pop ebx |
3871 | pop ebx |
3871 | call destroy_event |
3872 | call destroy_event |
3872 | .done: |
3873 | .done: |
3873 | add esp, 4 |
3874 | add esp, 4 |
3874 | popad |
3875 | popad |
3875 | ret |
3876 | ret |
3876 | 3877 | ||
3877 | else |
3878 | else |
3878 | 3879 | ||
3879 | align 4 |
3880 | align 4 |
3880 | delay_hs: ; delay in 1/100 secs |
3881 | delay_hs: ; delay in 1/100 secs |
3881 | ; ebx = delay time |
3882 | ; ebx = delay time |
3882 | push ecx |
3883 | push ecx |
3883 | push edx |
3884 | push edx |
3884 | 3885 | ||
3885 | mov edx, [timer_ticks] |
3886 | mov edx, [timer_ticks] |
3886 | ;-------------------------------------- |
3887 | ;-------------------------------------- |
3887 | align 4 |
3888 | align 4 |
3888 | newtic: |
3889 | newtic: |
3889 | mov ecx, [timer_ticks] |
3890 | mov ecx, [timer_ticks] |
3890 | sub ecx, edx |
3891 | sub ecx, edx |
3891 | cmp ecx, ebx |
3892 | cmp ecx, ebx |
3892 | jae zerodelay |
3893 | jae zerodelay |
3893 | 3894 | ||
3894 | call change_task |
3895 | call change_task |
3895 | 3896 | ||
3896 | jmp newtic |
3897 | jmp newtic |
3897 | ;-------------------------------------- |
3898 | ;-------------------------------------- |
3898 | align 4 |
3899 | align 4 |
3899 | zerodelay: |
3900 | zerodelay: |
3900 | pop edx |
3901 | pop edx |
3901 | pop ecx |
3902 | pop ecx |
3902 | ret |
3903 | ret |
3903 | end if |
3904 | end if |
3904 | 3905 | ||
3905 | ;----------------------------------------------------------------------------- |
3906 | ;----------------------------------------------------------------------------- |
3906 | align 16 ;very often call this subrutine |
3907 | align 16 ;very often call this subrutine |
3907 | memmove: ; memory move in bytes |
3908 | memmove: ; memory move in bytes |
3908 | ; eax = from |
3909 | ; eax = from |
3909 | ; ebx = to |
3910 | ; ebx = to |
3910 | ; ecx = no of bytes |
3911 | ; ecx = no of bytes |
3911 | test ecx, ecx |
3912 | test ecx, ecx |
3912 | jle .ret |
3913 | jle .ret |
3913 | 3914 | ||
3914 | push esi edi ecx |
3915 | push esi edi ecx |
3915 | 3916 | ||
3916 | mov edi, ebx |
3917 | mov edi, ebx |
3917 | mov esi, eax |
3918 | mov esi, eax |
3918 | 3919 | ||
3919 | test ecx, not 11b |
3920 | test ecx, not 11b |
3920 | jz @f |
3921 | jz @f |
3921 | 3922 | ||
3922 | push ecx |
3923 | push ecx |
3923 | shr ecx, 2 |
3924 | shr ecx, 2 |
3924 | rep movsd |
3925 | rep movsd |
3925 | pop ecx |
3926 | pop ecx |
3926 | and ecx, 11b |
3927 | and ecx, 11b |
3927 | jz .finish |
3928 | jz .finish |
3928 | ;-------------------------------------- |
3929 | ;-------------------------------------- |
3929 | align 4 |
3930 | align 4 |
3930 | @@: |
3931 | @@: |
3931 | rep movsb |
3932 | rep movsb |
3932 | ;-------------------------------------- |
3933 | ;-------------------------------------- |
3933 | align 4 |
3934 | align 4 |
3934 | .finish: |
3935 | .finish: |
3935 | pop ecx edi esi |
3936 | pop ecx edi esi |
3936 | ;-------------------------------------- |
3937 | ;-------------------------------------- |
3937 | align 4 |
3938 | align 4 |
3938 | .ret: |
3939 | .ret: |
3939 | ret |
3940 | ret |
3940 | ;----------------------------------------------------------------------------- |
3941 | ;----------------------------------------------------------------------------- |
3941 | ; |
3942 | ; |
3942 | ;align 4 |
3943 | ;align 4 |
3943 | ; |
3944 | ; |
3944 | ;read_floppy_file: |
3945 | ;read_floppy_file: |
3945 | ; |
3946 | ; |
3946 | ;; as input |
3947 | ;; as input |
3947 | ;; |
3948 | ;; |
3948 | ;; eax pointer to file |
3949 | ;; eax pointer to file |
3949 | ;; ebx file lenght |
3950 | ;; ebx file lenght |
3950 | ;; ecx start 512 byte block number |
3951 | ;; ecx start 512 byte block number |
3951 | ;; edx number of blocks to read |
3952 | ;; edx number of blocks to read |
3952 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3953 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3953 | ;; |
3954 | ;; |
3954 | ;; |
3955 | ;; |
3955 | ;; on return |
3956 | ;; on return |
3956 | ;; |
3957 | ;; |
3957 | ;; eax = 0 command succesful |
3958 | ;; eax = 0 command succesful |
3958 | ;; 1 no fd base and/or partition defined |
3959 | ;; 1 no fd base and/or partition defined |
3959 | ;; 2 yet unsupported FS |
3960 | ;; 2 yet unsupported FS |
3960 | ;; 3 unknown FS |
3961 | ;; 3 unknown FS |
3961 | ;; 4 partition not defined at hd |
3962 | ;; 4 partition not defined at hd |
3962 | ;; 5 file not found |
3963 | ;; 5 file not found |
3963 | ;; ebx = size of file |
3964 | ;; ebx = size of file |
3964 | ; |
3965 | ; |
3965 | ; mov edi,[TASK_BASE] |
3966 | ; mov edi,[TASK_BASE] |
3966 | ; add edi,0x10 |
3967 | ; add edi,0x10 |
3967 | ; add esi,[edi] |
3968 | ; add esi,[edi] |
3968 | ; add eax,[edi] |
3969 | ; add eax,[edi] |
3969 | ; |
3970 | ; |
3970 | ; pushad |
3971 | ; pushad |
3971 | ; mov edi,esi |
3972 | ; mov edi,esi |
3972 | ; add edi,1024 |
3973 | ; add edi,1024 |
3973 | ; mov esi,0x100000+19*512 |
3974 | ; mov esi,0x100000+19*512 |
3974 | ; sub ecx,1 |
3975 | ; sub ecx,1 |
3975 | ; shl ecx,9 |
3976 | ; shl ecx,9 |
3976 | ; add esi,ecx |
3977 | ; add esi,ecx |
3977 | ; shl edx,9 |
3978 | ; shl edx,9 |
3978 | ; mov ecx,edx |
3979 | ; mov ecx,edx |
3979 | ; cld |
3980 | ; cld |
3980 | ; rep movsb |
3981 | ; rep movsb |
3981 | ; popad |
3982 | ; popad |
3982 | ; |
3983 | ; |
3983 | ; mov [esp+36],eax |
3984 | ; mov [esp+36],eax |
3984 | ; mov [esp+24],ebx |
3985 | ; mov [esp+24],ebx |
3985 | ; ret |
3986 | ; ret |
3986 | 3987 | ||
3987 | 3988 | ||
3988 | 3989 | ||
3989 | align 4 |
3990 | align 4 |
3990 | set_io_access_rights: |
3991 | set_io_access_rights: |
3991 | push edi eax |
3992 | push edi eax |
3992 | mov edi, tss._io_map_0 |
3993 | mov edi, tss._io_map_0 |
3993 | ; mov ecx,eax |
3994 | ; mov ecx,eax |
3994 | ; and ecx,7 ; offset in byte |
3995 | ; and ecx,7 ; offset in byte |
3995 | ; shr eax,3 ; number of byte |
3996 | ; shr eax,3 ; number of byte |
3996 | ; add edi,eax |
3997 | ; add edi,eax |
3997 | ; mov ebx,1 |
3998 | ; mov ebx,1 |
3998 | ; shl ebx,cl |
3999 | ; shl ebx,cl |
3999 | test ebp, ebp |
4000 | test ebp, ebp |
4000 | ; cmp ebp,0 ; enable access - ebp = 0 |
4001 | ; cmp ebp,0 ; enable access - ebp = 0 |
4001 | jnz .siar1 |
4002 | jnz .siar1 |
4002 | ; not ebx |
4003 | ; not ebx |
4003 | ; and [edi],byte bl |
4004 | ; and [edi],byte bl |
4004 | btr [edi], eax |
4005 | btr [edi], eax |
4005 | pop eax edi |
4006 | pop eax edi |
4006 | ret |
4007 | ret |
4007 | .siar1: |
4008 | .siar1: |
4008 | bts [edi], eax |
4009 | bts [edi], eax |
4009 | ; or [edi],byte bl ; disable access - ebp = 1 |
4010 | ; or [edi],byte bl ; disable access - ebp = 1 |
4010 | pop eax edi |
4011 | pop eax edi |
4011 | ret |
4012 | ret |
4012 | ;reserve/free group of ports |
4013 | ;reserve/free group of ports |
4013 | ; * eax = 46 - number function |
4014 | ; * eax = 46 - number function |
4014 | ; * ebx = 0 - reserve, 1 - free |
4015 | ; * ebx = 0 - reserve, 1 - free |
4015 | ; * ecx = number start arrea of ports |
4016 | ; * ecx = number start arrea of ports |
4016 | ; * edx = number end arrea of ports (include last number of port) |
4017 | ; * edx = number end arrea of ports (include last number of port) |
4017 | ;Return value: |
4018 | ;Return value: |
4018 | ; * eax = 0 - succesful |
4019 | ; * eax = 0 - succesful |
4019 | ; * eax = 1 - error |
4020 | ; * eax = 1 - error |
4020 | ; * The system has reserve this ports: |
4021 | ; * The system has reserve this ports: |
4021 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4022 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4022 | ;destroys eax,ebx, ebp |
4023 | ;destroys eax,ebx, ebp |
4023 | r_f_port_area: |
4024 | r_f_port_area: |
4024 | 4025 | ||
4025 | test ebx, ebx |
4026 | test ebx, ebx |
4026 | jnz free_port_area |
4027 | jnz free_port_area |
4027 | ; je r_port_area |
4028 | ; je r_port_area |
4028 | ; jmp free_port_area |
4029 | ; jmp free_port_area |
4029 | 4030 | ||
4030 | ; r_port_area: |
4031 | ; r_port_area: |
4031 | 4032 | ||
4032 | ; pushad |
4033 | ; pushad |
4033 | 4034 | ||
4034 | cmp ecx, edx ; beginning > end ? |
4035 | cmp ecx, edx ; beginning > end ? |
4035 | ja rpal1 |
4036 | ja rpal1 |
4036 | cmp edx, 65536 |
4037 | cmp edx, 65536 |
4037 | jae rpal1 |
4038 | jae rpal1 |
4038 | mov eax, [RESERVED_PORTS] |
4039 | mov eax, [RESERVED_PORTS] |
4039 | test eax, eax ; no reserved areas ? |
4040 | test eax, eax ; no reserved areas ? |
4040 | je rpal2 |
4041 | je rpal2 |
4041 | cmp eax, 255 ; max reserved |
4042 | cmp eax, 255 ; max reserved |
4042 | jae rpal1 |
4043 | jae rpal1 |
4043 | rpal3: |
4044 | rpal3: |
4044 | mov ebx, eax |
4045 | mov ebx, eax |
4045 | shl ebx, 4 |
4046 | shl ebx, 4 |
4046 | add ebx, RESERVED_PORTS |
4047 | add ebx, RESERVED_PORTS |
4047 | cmp ecx, [ebx+8] |
4048 | cmp ecx, [ebx+8] |
4048 | ja rpal4 |
4049 | ja rpal4 |
4049 | cmp edx, [ebx+4] |
4050 | cmp edx, [ebx+4] |
4050 | jae rpal1 |
4051 | jae rpal1 |
4051 | ; jb rpal4 |
4052 | ; jb rpal4 |
4052 | ; jmp rpal1 |
4053 | ; jmp rpal1 |
4053 | rpal4: |
4054 | rpal4: |
4054 | dec eax |
4055 | dec eax |
4055 | jnz rpal3 |
4056 | jnz rpal3 |
4056 | jmp rpal2 |
4057 | jmp rpal2 |
4057 | rpal1: |
4058 | rpal1: |
4058 | ; popad |
4059 | ; popad |
4059 | ; mov eax,1 |
4060 | ; mov eax,1 |
4060 | xor eax, eax |
4061 | xor eax, eax |
4061 | inc eax |
4062 | inc eax |
4062 | ret |
4063 | ret |
4063 | rpal2: |
4064 | rpal2: |
4064 | ; popad |
4065 | ; popad |
4065 | ; enable port access at port IO map |
4066 | ; enable port access at port IO map |
4066 | cli |
4067 | cli |
4067 | pushad ; start enable io map |
4068 | pushad ; start enable io map |
4068 | 4069 | ||
4069 | cmp edx, 65536;16384 |
4070 | cmp edx, 65536;16384 |
4070 | jae no_unmask_io; jge |
4071 | jae no_unmask_io; jge |
4071 | mov eax, ecx |
4072 | mov eax, ecx |
4072 | ; push ebp |
4073 | ; push ebp |
4073 | xor ebp, ebp ; enable - eax = port |
4074 | xor ebp, ebp ; enable - eax = port |
4074 | new_port_access: |
4075 | new_port_access: |
4075 | ; pushad |
4076 | ; pushad |
4076 | call set_io_access_rights |
4077 | call set_io_access_rights |
4077 | ; popad |
4078 | ; popad |
4078 | inc eax |
4079 | inc eax |
4079 | cmp eax, edx |
4080 | cmp eax, edx |
4080 | jbe new_port_access |
4081 | jbe new_port_access |
4081 | ; pop ebp |
4082 | ; pop ebp |
4082 | no_unmask_io: |
4083 | no_unmask_io: |
4083 | popad ; end enable io map |
4084 | popad ; end enable io map |
4084 | sti |
4085 | sti |
4085 | 4086 | ||
4086 | mov eax, [RESERVED_PORTS] |
4087 | mov eax, [RESERVED_PORTS] |
4087 | add eax, 1 |
4088 | add eax, 1 |
4088 | mov [RESERVED_PORTS], eax |
4089 | mov [RESERVED_PORTS], eax |
4089 | shl eax, 4 |
4090 | shl eax, 4 |
4090 | add eax, RESERVED_PORTS |
4091 | add eax, RESERVED_PORTS |
4091 | mov ebx, [TASK_BASE] |
4092 | mov ebx, [TASK_BASE] |
4092 | mov ebx, [ebx+TASKDATA.pid] |
4093 | mov ebx, [ebx+TASKDATA.pid] |
4093 | mov [eax], ebx |
4094 | mov [eax], ebx |
4094 | mov [eax+4], ecx |
4095 | mov [eax+4], ecx |
4095 | mov [eax+8], edx |
4096 | mov [eax+8], edx |
4096 | 4097 | ||
4097 | xor eax, eax |
4098 | xor eax, eax |
4098 | ret |
4099 | ret |
4099 | 4100 | ||
4100 | free_port_area: |
4101 | free_port_area: |
4101 | 4102 | ||
4102 | ; pushad |
4103 | ; pushad |
4103 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4104 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4104 | test eax, eax |
4105 | test eax, eax |
4105 | jz frpal2 |
4106 | jz frpal2 |
4106 | mov ebx, [TASK_BASE] |
4107 | mov ebx, [TASK_BASE] |
4107 | mov ebx, [ebx+TASKDATA.pid] |
4108 | mov ebx, [ebx+TASKDATA.pid] |
4108 | frpal3: |
4109 | frpal3: |
4109 | mov edi, eax |
4110 | mov edi, eax |
4110 | shl edi, 4 |
4111 | shl edi, 4 |
4111 | add edi, RESERVED_PORTS |
4112 | add edi, RESERVED_PORTS |
4112 | cmp ebx, [edi] |
4113 | cmp ebx, [edi] |
4113 | jne frpal4 |
4114 | jne frpal4 |
4114 | cmp ecx, [edi+4] |
4115 | cmp ecx, [edi+4] |
4115 | jne frpal4 |
4116 | jne frpal4 |
4116 | cmp edx, [edi+8] |
4117 | cmp edx, [edi+8] |
4117 | jne frpal4 |
4118 | jne frpal4 |
4118 | jmp frpal1 |
4119 | jmp frpal1 |
4119 | frpal4: |
4120 | frpal4: |
4120 | dec eax |
4121 | dec eax |
4121 | jnz frpal3 |
4122 | jnz frpal3 |
4122 | frpal2: |
4123 | frpal2: |
4123 | ; popad |
4124 | ; popad |
4124 | inc eax |
4125 | inc eax |
4125 | ret |
4126 | ret |
4126 | frpal1: |
4127 | frpal1: |
4127 | push ecx |
4128 | push ecx |
4128 | mov ecx, 256 |
4129 | mov ecx, 256 |
4129 | sub ecx, eax |
4130 | sub ecx, eax |
4130 | shl ecx, 4 |
4131 | shl ecx, 4 |
4131 | mov esi, edi |
4132 | mov esi, edi |
4132 | add esi, 16 |
4133 | add esi, 16 |
4133 | cld |
4134 | cld |
4134 | rep movsb |
4135 | rep movsb |
4135 | 4136 | ||
4136 | dec dword [RESERVED_PORTS] |
4137 | dec dword [RESERVED_PORTS] |
4137 | ;popad |
4138 | ;popad |
4138 | ;disable port access at port IO map |
4139 | ;disable port access at port IO map |
4139 | 4140 | ||
4140 | ; pushad ; start disable io map |
4141 | ; pushad ; start disable io map |
4141 | pop eax ;start port |
4142 | pop eax ;start port |
4142 | cmp edx, 65536;16384 |
4143 | cmp edx, 65536;16384 |
4143 | jge no_mask_io |
4144 | jge no_mask_io |
4144 | 4145 | ||
4145 | ; mov eax,ecx |
4146 | ; mov eax,ecx |
4146 | xor ebp, ebp |
4147 | xor ebp, ebp |
4147 | inc ebp |
4148 | inc ebp |
4148 | new_port_access_disable: |
4149 | new_port_access_disable: |
4149 | ; pushad |
4150 | ; pushad |
4150 | ; mov ebp,1 ; disable - eax = port |
4151 | ; mov ebp,1 ; disable - eax = port |
4151 | call set_io_access_rights |
4152 | call set_io_access_rights |
4152 | ; popad |
4153 | ; popad |
4153 | inc eax |
4154 | inc eax |
4154 | cmp eax, edx |
4155 | cmp eax, edx |
4155 | jbe new_port_access_disable |
4156 | jbe new_port_access_disable |
4156 | no_mask_io: |
4157 | no_mask_io: |
4157 | ; popad ; end disable io map |
4158 | ; popad ; end disable io map |
4158 | xor eax, eax |
4159 | xor eax, eax |
4159 | ret |
4160 | ret |
4160 | ;----------------------------------------------------------------------------- |
4161 | ;----------------------------------------------------------------------------- |
4161 | align 4 |
4162 | align 4 |
4162 | drawbackground: |
4163 | drawbackground: |
4163 | dbrv20: |
4164 | dbrv20: |
4164 | cmp [BgrDrawMode], dword 1 |
4165 | cmp [BgrDrawMode], dword 1 |
4165 | jne bgrstr |
4166 | jne bgrstr |
4166 | call vesa20_drawbackground_tiled |
4167 | call vesa20_drawbackground_tiled |
4167 | ; call [draw_pointer] |
4168 | ; call [draw_pointer] |
4168 | call __sys_draw_pointer |
4169 | call __sys_draw_pointer |
4169 | ret |
4170 | ret |
4170 | ;-------------------------------------- |
4171 | ;-------------------------------------- |
4171 | align 4 |
4172 | align 4 |
4172 | bgrstr: |
4173 | bgrstr: |
4173 | call vesa20_drawbackground_stretch |
4174 | call vesa20_drawbackground_stretch |
4174 | ; call [draw_pointer] |
4175 | ; call [draw_pointer] |
4175 | call __sys_draw_pointer |
4176 | call __sys_draw_pointer |
4176 | ret |
4177 | ret |
4177 | ;----------------------------------------------------------------------------- |
4178 | ;----------------------------------------------------------------------------- |
4178 | align 4 |
4179 | align 4 |
4179 | syscall_putimage: ; PutImage |
4180 | syscall_putimage: ; PutImage |
4180 | sys_putimage: |
4181 | sys_putimage: |
4181 | test ecx, 0x80008000 |
4182 | test ecx, 0x80008000 |
4182 | jnz .exit |
4183 | jnz .exit |
4183 | test ecx, 0x0000FFFF |
4184 | test ecx, 0x0000FFFF |
4184 | jz .exit |
4185 | jz .exit |
4185 | test ecx, 0xFFFF0000 |
4186 | test ecx, 0xFFFF0000 |
4186 | jnz @f |
4187 | jnz @f |
4187 | ;-------------------------------------- |
4188 | ;-------------------------------------- |
4188 | align 4 |
4189 | align 4 |
4189 | .exit: |
4190 | .exit: |
4190 | ret |
4191 | ret |
4191 | ;-------------------------------------- |
4192 | ;-------------------------------------- |
4192 | align 4 |
4193 | align 4 |
4193 | @@: |
4194 | @@: |
4194 | mov edi, [current_slot] |
4195 | mov edi, [current_slot] |
4195 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4196 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4196 | rol edx, 16 |
4197 | rol edx, 16 |
4197 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4198 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4198 | rol edx, 16 |
4199 | rol edx, 16 |
4199 | ;-------------------------------------- |
4200 | ;-------------------------------------- |
4200 | align 4 |
4201 | align 4 |
4201 | .forced: |
4202 | .forced: |
4202 | push ebp esi 0 |
4203 | push ebp esi 0 |
4203 | mov ebp, putimage_get24bpp |
4204 | mov ebp, putimage_get24bpp |
4204 | mov esi, putimage_init24bpp |
4205 | mov esi, putimage_init24bpp |
4205 | ;-------------------------------------- |
4206 | ;-------------------------------------- |
4206 | align 4 |
4207 | align 4 |
4207 | sys_putimage_bpp: |
4208 | sys_putimage_bpp: |
4208 | call vesa20_putimage |
4209 | call vesa20_putimage |
4209 | pop ebp esi ebp |
4210 | pop ebp esi ebp |
4210 | ret |
4211 | ret |
4211 | ; jmp [draw_pointer] |
4212 | ; jmp [draw_pointer] |
4212 | ;----------------------------------------------------------------------------- |
4213 | ;----------------------------------------------------------------------------- |
4213 | align 4 |
4214 | align 4 |
4214 | sys_putimage_palette: |
4215 | sys_putimage_palette: |
4215 | ; ebx = pointer to image |
4216 | ; ebx = pointer to image |
4216 | ; ecx = [xsize]*65536 + [ysize] |
4217 | ; ecx = [xsize]*65536 + [ysize] |
4217 | ; edx = [xstart]*65536 + [ystart] |
4218 | ; edx = [xstart]*65536 + [ystart] |
4218 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4219 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4219 | ; edi = pointer to palette |
4220 | ; edi = pointer to palette |
4220 | ; ebp = row delta |
4221 | ; ebp = row delta |
4221 | mov eax, [CURRENT_TASK] |
4222 | mov eax, [CURRENT_TASK] |
4222 | shl eax, 8 |
4223 | shl eax, 8 |
4223 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4224 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4224 | rol edx, 16 |
4225 | rol edx, 16 |
4225 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4226 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4226 | rol edx, 16 |
4227 | rol edx, 16 |
4227 | ;-------------------------------------- |
4228 | ;-------------------------------------- |
4228 | align 4 |
4229 | align 4 |
4229 | .forced: |
4230 | .forced: |
4230 | cmp esi, 1 |
4231 | cmp esi, 1 |
4231 | jnz @f |
4232 | jnz @f |
4232 | push edi |
4233 | push edi |
4233 | mov eax, [edi+4] |
4234 | mov eax, [edi+4] |
4234 | sub eax, [edi] |
4235 | sub eax, [edi] |
4235 | push eax |
4236 | push eax |
4236 | push dword [edi] |
4237 | push dword [edi] |
4237 | push 0ffffff80h |
4238 | push 0ffffff80h |
4238 | mov edi, esp |
4239 | mov edi, esp |
4239 | call put_mono_image |
4240 | call put_mono_image |
4240 | add esp, 12 |
4241 | add esp, 12 |
4241 | pop edi |
4242 | pop edi |
4242 | ret |
4243 | ret |
4243 | ;-------------------------------------- |
4244 | ;-------------------------------------- |
4244 | align 4 |
4245 | align 4 |
4245 | @@: |
4246 | @@: |
4246 | cmp esi, 2 |
4247 | cmp esi, 2 |
4247 | jnz @f |
4248 | jnz @f |
4248 | push edi |
4249 | push edi |
4249 | push 0ffffff80h |
4250 | push 0ffffff80h |
4250 | mov edi, esp |
4251 | mov edi, esp |
4251 | call put_2bit_image |
4252 | call put_2bit_image |
4252 | pop eax |
4253 | pop eax |
4253 | pop edi |
4254 | pop edi |
4254 | ret |
4255 | ret |
4255 | ;-------------------------------------- |
4256 | ;-------------------------------------- |
4256 | align 4 |
4257 | align 4 |
4257 | @@: |
4258 | @@: |
4258 | cmp esi, 4 |
4259 | cmp esi, 4 |
4259 | jnz @f |
4260 | jnz @f |
4260 | push edi |
4261 | push edi |
4261 | push 0ffffff80h |
4262 | push 0ffffff80h |
4262 | mov edi, esp |
4263 | mov edi, esp |
4263 | call put_4bit_image |
4264 | call put_4bit_image |
4264 | pop eax |
4265 | pop eax |
4265 | pop edi |
4266 | pop edi |
4266 | ret |
4267 | ret |
4267 | ;-------------------------------------- |
4268 | ;-------------------------------------- |
4268 | align 4 |
4269 | align 4 |
4269 | @@: |
4270 | @@: |
4270 | push ebp esi ebp |
4271 | push ebp esi ebp |
4271 | cmp esi, 8 |
4272 | cmp esi, 8 |
4272 | jnz @f |
4273 | jnz @f |
4273 | mov ebp, putimage_get8bpp |
4274 | mov ebp, putimage_get8bpp |
4274 | mov esi, putimage_init8bpp |
4275 | mov esi, putimage_init8bpp |
4275 | jmp sys_putimage_bpp |
4276 | jmp sys_putimage_bpp |
4276 | ;-------------------------------------- |
4277 | ;-------------------------------------- |
4277 | align 4 |
4278 | align 4 |
4278 | @@: |
4279 | @@: |
4279 | cmp esi, 9 |
4280 | cmp esi, 9 |
4280 | jnz @f |
4281 | jnz @f |
4281 | mov ebp, putimage_get9bpp |
4282 | mov ebp, putimage_get9bpp |
4282 | mov esi, putimage_init9bpp |
4283 | mov esi, putimage_init9bpp |
4283 | jmp sys_putimage_bpp |
4284 | jmp sys_putimage_bpp |
4284 | ;-------------------------------------- |
4285 | ;-------------------------------------- |
4285 | align 4 |
4286 | align 4 |
4286 | @@: |
4287 | @@: |
4287 | cmp esi, 15 |
4288 | cmp esi, 15 |
4288 | jnz @f |
4289 | jnz @f |
4289 | mov ebp, putimage_get15bpp |
4290 | mov ebp, putimage_get15bpp |
4290 | mov esi, putimage_init15bpp |
4291 | mov esi, putimage_init15bpp |
4291 | jmp sys_putimage_bpp |
4292 | jmp sys_putimage_bpp |
4292 | ;-------------------------------------- |
4293 | ;-------------------------------------- |
4293 | align 4 |
4294 | align 4 |
4294 | @@: |
4295 | @@: |
4295 | cmp esi, 16 |
4296 | cmp esi, 16 |
4296 | jnz @f |
4297 | jnz @f |
4297 | mov ebp, putimage_get16bpp |
4298 | mov ebp, putimage_get16bpp |
4298 | mov esi, putimage_init16bpp |
4299 | mov esi, putimage_init16bpp |
4299 | jmp sys_putimage_bpp |
4300 | jmp sys_putimage_bpp |
4300 | ;-------------------------------------- |
4301 | ;-------------------------------------- |
4301 | align 4 |
4302 | align 4 |
4302 | @@: |
4303 | @@: |
4303 | cmp esi, 24 |
4304 | cmp esi, 24 |
4304 | jnz @f |
4305 | jnz @f |
4305 | mov ebp, putimage_get24bpp |
4306 | mov ebp, putimage_get24bpp |
4306 | mov esi, putimage_init24bpp |
4307 | mov esi, putimage_init24bpp |
4307 | jmp sys_putimage_bpp |
4308 | jmp sys_putimage_bpp |
4308 | ;-------------------------------------- |
4309 | ;-------------------------------------- |
4309 | align 4 |
4310 | align 4 |
4310 | @@: |
4311 | @@: |
4311 | cmp esi, 32 |
4312 | cmp esi, 32 |
4312 | jnz @f |
4313 | jnz @f |
4313 | mov ebp, putimage_get32bpp |
4314 | mov ebp, putimage_get32bpp |
4314 | mov esi, putimage_init32bpp |
4315 | mov esi, putimage_init32bpp |
4315 | jmp sys_putimage_bpp |
4316 | jmp sys_putimage_bpp |
4316 | ;-------------------------------------- |
4317 | ;-------------------------------------- |
4317 | align 4 |
4318 | align 4 |
4318 | @@: |
4319 | @@: |
4319 | pop ebp esi ebp |
4320 | pop ebp esi ebp |
4320 | ret |
4321 | ret |
4321 | ;----------------------------------------------------------------------------- |
4322 | ;----------------------------------------------------------------------------- |
4322 | align 4 |
4323 | align 4 |
4323 | put_mono_image: |
4324 | put_mono_image: |
4324 | push ebp esi ebp |
4325 | push ebp esi ebp |
4325 | mov ebp, putimage_get1bpp |
4326 | mov ebp, putimage_get1bpp |
4326 | mov esi, putimage_init1bpp |
4327 | mov esi, putimage_init1bpp |
4327 | jmp sys_putimage_bpp |
4328 | jmp sys_putimage_bpp |
4328 | ;----------------------------------------------------------------------------- |
4329 | ;----------------------------------------------------------------------------- |
4329 | align 4 |
4330 | align 4 |
4330 | put_2bit_image: |
4331 | put_2bit_image: |
4331 | push ebp esi ebp |
4332 | push ebp esi ebp |
4332 | mov ebp, putimage_get2bpp |
4333 | mov ebp, putimage_get2bpp |
4333 | mov esi, putimage_init2bpp |
4334 | mov esi, putimage_init2bpp |
4334 | jmp sys_putimage_bpp |
4335 | jmp sys_putimage_bpp |
4335 | ;----------------------------------------------------------------------------- |
4336 | ;----------------------------------------------------------------------------- |
4336 | align 4 |
4337 | align 4 |
4337 | put_4bit_image: |
4338 | put_4bit_image: |
4338 | push ebp esi ebp |
4339 | push ebp esi ebp |
4339 | mov ebp, putimage_get4bpp |
4340 | mov ebp, putimage_get4bpp |
4340 | mov esi, putimage_init4bpp |
4341 | mov esi, putimage_init4bpp |
4341 | jmp sys_putimage_bpp |
4342 | jmp sys_putimage_bpp |
4342 | ;----------------------------------------------------------------------------- |
4343 | ;----------------------------------------------------------------------------- |
4343 | align 4 |
4344 | align 4 |
4344 | putimage_init24bpp: |
4345 | putimage_init24bpp: |
4345 | lea eax, [eax*3] |
4346 | lea eax, [eax*3] |
4346 | putimage_init8bpp: |
4347 | putimage_init8bpp: |
4347 | putimage_init9bpp: |
4348 | putimage_init9bpp: |
4348 | ret |
4349 | ret |
4349 | ;----------------------------------------------------------------------------- |
4350 | ;----------------------------------------------------------------------------- |
4350 | align 16 |
4351 | align 16 |
4351 | putimage_get24bpp: |
4352 | putimage_get24bpp: |
4352 | movzx eax, byte [esi+2] |
4353 | movzx eax, byte [esi+2] |
4353 | shl eax, 16 |
4354 | shl eax, 16 |
4354 | mov ax, [esi] |
4355 | mov ax, [esi] |
4355 | add esi, 3 |
4356 | add esi, 3 |
4356 | ret 4 |
4357 | ret 4 |
4357 | ;----------------------------------------------------------------------------- |
4358 | ;----------------------------------------------------------------------------- |
4358 | align 16 |
4359 | align 16 |
4359 | putimage_get8bpp: |
4360 | putimage_get8bpp: |
4360 | movzx eax, byte [esi] |
4361 | movzx eax, byte [esi] |
4361 | push edx |
4362 | push edx |
4362 | mov edx, [esp+8] |
4363 | mov edx, [esp+8] |
4363 | mov eax, [edx+eax*4] |
4364 | mov eax, [edx+eax*4] |
4364 | pop edx |
4365 | pop edx |
4365 | inc esi |
4366 | inc esi |
4366 | ret 4 |
4367 | ret 4 |
4367 | ;----------------------------------------------------------------------------- |
4368 | ;----------------------------------------------------------------------------- |
4368 | align 16 |
4369 | align 16 |
4369 | putimage_get9bpp: |
4370 | putimage_get9bpp: |
4370 | lodsb |
4371 | lodsb |
4371 | mov ah, al |
4372 | mov ah, al |
4372 | shl eax, 8 |
4373 | shl eax, 8 |
4373 | mov al, ah |
4374 | mov al, ah |
4374 | ret 4 |
4375 | ret 4 |
4375 | ;----------------------------------------------------------------------------- |
4376 | ;----------------------------------------------------------------------------- |
4376 | align 4 |
4377 | align 4 |
4377 | putimage_init1bpp: |
4378 | putimage_init1bpp: |
4378 | add eax, ecx |
4379 | add eax, ecx |
4379 | push ecx |
4380 | push ecx |
4380 | add eax, 7 |
4381 | add eax, 7 |
4381 | add ecx, 7 |
4382 | add ecx, 7 |
4382 | shr eax, 3 |
4383 | shr eax, 3 |
4383 | shr ecx, 3 |
4384 | shr ecx, 3 |
4384 | sub eax, ecx |
4385 | sub eax, ecx |
4385 | pop ecx |
4386 | pop ecx |
4386 | ret |
4387 | ret |
4387 | ;----------------------------------------------------------------------------- |
4388 | ;----------------------------------------------------------------------------- |
4388 | align 16 |
4389 | align 16 |
4389 | putimage_get1bpp: |
4390 | putimage_get1bpp: |
4390 | push edx |
4391 | push edx |
4391 | mov edx, [esp+8] |
4392 | mov edx, [esp+8] |
4392 | mov al, [edx] |
4393 | mov al, [edx] |
4393 | add al, al |
4394 | add al, al |
4394 | jnz @f |
4395 | jnz @f |
4395 | lodsb |
4396 | lodsb |
4396 | adc al, al |
4397 | adc al, al |
4397 | @@: |
4398 | @@: |
4398 | mov [edx], al |
4399 | mov [edx], al |
4399 | sbb eax, eax |
4400 | sbb eax, eax |
4400 | and eax, [edx+8] |
4401 | and eax, [edx+8] |
4401 | add eax, [edx+4] |
4402 | add eax, [edx+4] |
4402 | pop edx |
4403 | pop edx |
4403 | ret 4 |
4404 | ret 4 |
4404 | ;----------------------------------------------------------------------------- |
4405 | ;----------------------------------------------------------------------------- |
4405 | align 4 |
4406 | align 4 |
4406 | putimage_init2bpp: |
4407 | putimage_init2bpp: |
4407 | add eax, ecx |
4408 | add eax, ecx |
4408 | push ecx |
4409 | push ecx |
4409 | add ecx, 3 |
4410 | add ecx, 3 |
4410 | add eax, 3 |
4411 | add eax, 3 |
4411 | shr ecx, 2 |
4412 | shr ecx, 2 |
4412 | shr eax, 2 |
4413 | shr eax, 2 |
4413 | sub eax, ecx |
4414 | sub eax, ecx |
4414 | pop ecx |
4415 | pop ecx |
4415 | ret |
4416 | ret |
4416 | ;----------------------------------------------------------------------------- |
4417 | ;----------------------------------------------------------------------------- |
4417 | align 16 |
4418 | align 16 |
4418 | putimage_get2bpp: |
4419 | putimage_get2bpp: |
4419 | push edx |
4420 | push edx |
4420 | mov edx, [esp+8] |
4421 | mov edx, [esp+8] |
4421 | mov al, [edx] |
4422 | mov al, [edx] |
4422 | mov ah, al |
4423 | mov ah, al |
4423 | shr al, 6 |
4424 | shr al, 6 |
4424 | shl ah, 2 |
4425 | shl ah, 2 |
4425 | jnz .nonewbyte |
4426 | jnz .nonewbyte |
4426 | lodsb |
4427 | lodsb |
4427 | mov ah, al |
4428 | mov ah, al |
4428 | shr al, 6 |
4429 | shr al, 6 |
4429 | shl ah, 2 |
4430 | shl ah, 2 |
4430 | add ah, 1 |
4431 | add ah, 1 |
4431 | .nonewbyte: |
4432 | .nonewbyte: |
4432 | mov [edx], ah |
4433 | mov [edx], ah |
4433 | mov edx, [edx+4] |
4434 | mov edx, [edx+4] |
4434 | movzx eax, al |
4435 | movzx eax, al |
4435 | mov eax, [edx+eax*4] |
4436 | mov eax, [edx+eax*4] |
4436 | pop edx |
4437 | pop edx |
4437 | ret 4 |
4438 | ret 4 |
4438 | ;----------------------------------------------------------------------------- |
4439 | ;----------------------------------------------------------------------------- |
4439 | align 4 |
4440 | align 4 |
4440 | putimage_init4bpp: |
4441 | putimage_init4bpp: |
4441 | add eax, ecx |
4442 | add eax, ecx |
4442 | push ecx |
4443 | push ecx |
4443 | add ecx, 1 |
4444 | add ecx, 1 |
4444 | add eax, 1 |
4445 | add eax, 1 |
4445 | shr ecx, 1 |
4446 | shr ecx, 1 |
4446 | shr eax, 1 |
4447 | shr eax, 1 |
4447 | sub eax, ecx |
4448 | sub eax, ecx |
4448 | pop ecx |
4449 | pop ecx |
4449 | ret |
4450 | ret |
4450 | ;----------------------------------------------------------------------------- |
4451 | ;----------------------------------------------------------------------------- |
4451 | align 16 |
4452 | align 16 |
4452 | putimage_get4bpp: |
4453 | putimage_get4bpp: |
4453 | push edx |
4454 | push edx |
4454 | mov edx, [esp+8] |
4455 | mov edx, [esp+8] |
4455 | add byte [edx], 80h |
4456 | add byte [edx], 80h |
4456 | jc @f |
4457 | jc @f |
4457 | movzx eax, byte [edx+1] |
4458 | movzx eax, byte [edx+1] |
4458 | mov edx, [edx+4] |
4459 | mov edx, [edx+4] |
4459 | and eax, 0x0F |
4460 | and eax, 0x0F |
4460 | mov eax, [edx+eax*4] |
4461 | mov eax, [edx+eax*4] |
4461 | pop edx |
4462 | pop edx |
4462 | ret 4 |
4463 | ret 4 |
4463 | @@: |
4464 | @@: |
4464 | movzx eax, byte [esi] |
4465 | movzx eax, byte [esi] |
4465 | add esi, 1 |
4466 | add esi, 1 |
4466 | mov [edx+1], al |
4467 | mov [edx+1], al |
4467 | shr eax, 4 |
4468 | shr eax, 4 |
4468 | mov edx, [edx+4] |
4469 | mov edx, [edx+4] |
4469 | mov eax, [edx+eax*4] |
4470 | mov eax, [edx+eax*4] |
4470 | pop edx |
4471 | pop edx |
4471 | ret 4 |
4472 | ret 4 |
4472 | ;----------------------------------------------------------------------------- |
4473 | ;----------------------------------------------------------------------------- |
4473 | align 4 |
4474 | align 4 |
4474 | putimage_init32bpp: |
4475 | putimage_init32bpp: |
4475 | shl eax, 2 |
4476 | shl eax, 2 |
4476 | ret |
4477 | ret |
4477 | ;----------------------------------------------------------------------------- |
4478 | ;----------------------------------------------------------------------------- |
4478 | align 16 |
4479 | align 16 |
4479 | putimage_get32bpp: |
4480 | putimage_get32bpp: |
4480 | lodsd |
4481 | lodsd |
4481 | ret 4 |
4482 | ret 4 |
4482 | ;----------------------------------------------------------------------------- |
4483 | ;----------------------------------------------------------------------------- |
4483 | align 4 |
4484 | align 4 |
4484 | putimage_init15bpp: |
4485 | putimage_init15bpp: |
4485 | putimage_init16bpp: |
4486 | putimage_init16bpp: |
4486 | add eax, eax |
4487 | add eax, eax |
4487 | ret |
4488 | ret |
4488 | ;----------------------------------------------------------------------------- |
4489 | ;----------------------------------------------------------------------------- |
4489 | align 16 |
4490 | align 16 |
4490 | putimage_get15bpp: |
4491 | putimage_get15bpp: |
4491 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4492 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4492 | push ecx edx |
4493 | push ecx edx |
4493 | movzx eax, word [esi] |
4494 | movzx eax, word [esi] |
4494 | add esi, 2 |
4495 | add esi, 2 |
4495 | mov ecx, eax |
4496 | mov ecx, eax |
4496 | mov edx, eax |
4497 | mov edx, eax |
4497 | and eax, 0x1F |
4498 | and eax, 0x1F |
4498 | and ecx, 0x1F shl 5 |
4499 | and ecx, 0x1F shl 5 |
4499 | and edx, 0x1F shl 10 |
4500 | and edx, 0x1F shl 10 |
4500 | shl eax, 3 |
4501 | shl eax, 3 |
4501 | shl ecx, 6 |
4502 | shl ecx, 6 |
4502 | shl edx, 9 |
4503 | shl edx, 9 |
4503 | or eax, ecx |
4504 | or eax, ecx |
4504 | or eax, edx |
4505 | or eax, edx |
4505 | pop edx ecx |
4506 | pop edx ecx |
4506 | ret 4 |
4507 | ret 4 |
4507 | ;----------------------------------------------------------------------------- |
4508 | ;----------------------------------------------------------------------------- |
4508 | align 16 |
4509 | align 16 |
4509 | putimage_get16bpp: |
4510 | putimage_get16bpp: |
4510 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4511 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4511 | push ecx edx |
4512 | push ecx edx |
4512 | movzx eax, word [esi] |
4513 | movzx eax, word [esi] |
4513 | add esi, 2 |
4514 | add esi, 2 |
4514 | mov ecx, eax |
4515 | mov ecx, eax |
4515 | mov edx, eax |
4516 | mov edx, eax |
4516 | and eax, 0x1F |
4517 | and eax, 0x1F |
4517 | and ecx, 0x3F shl 5 |
4518 | and ecx, 0x3F shl 5 |
4518 | and edx, 0x1F shl 11 |
4519 | and edx, 0x1F shl 11 |
4519 | shl eax, 3 |
4520 | shl eax, 3 |
4520 | shl ecx, 5 |
4521 | shl ecx, 5 |
4521 | shl edx, 8 |
4522 | shl edx, 8 |
4522 | or eax, ecx |
4523 | or eax, ecx |
4523 | or eax, edx |
4524 | or eax, edx |
4524 | pop edx ecx |
4525 | pop edx ecx |
4525 | ret 4 |
4526 | ret 4 |
4526 | ;----------------------------------------------------------------------------- |
4527 | ;----------------------------------------------------------------------------- |
4527 | ;align 4 |
4528 | ;align 4 |
4528 | ; eax x beginning |
4529 | ; eax x beginning |
4529 | ; ebx y beginning |
4530 | ; ebx y beginning |
4530 | ; ecx x end |
4531 | ; ecx x end |
4531 | ; edx y end |
4532 | ; edx y end |
4532 | ; edi color |
4533 | ; edi color |
4533 | ;__sys_drawbar: |
4534 | ;__sys_drawbar: |
4534 | ; mov esi, [current_slot] |
4535 | ; mov esi, [current_slot] |
4535 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4536 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4536 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4537 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4537 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4538 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4538 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4539 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4539 | ;-------------------------------------- |
4540 | ;-------------------------------------- |
4540 | ;align 4 |
4541 | ;align 4 |
4541 | ;.forced: |
4542 | ;.forced: |
4542 | ; call vesa20_drawbar |
4543 | ; call vesa20_drawbar |
4543 | ; call [draw_pointer] |
4544 | ; call [draw_pointer] |
4544 | ; ret |
4545 | ; ret |
4545 | ;----------------------------------------------------------------------------- |
4546 | ;----------------------------------------------------------------------------- |
4546 | align 4 |
4547 | align 4 |
4547 | kb_read: |
4548 | kb_read: |
4548 | 4549 | ||
4549 | push ecx edx |
4550 | push ecx edx |
4550 | 4551 | ||
4551 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4552 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4552 | kr_loop: |
4553 | kr_loop: |
4553 | in al, 0x64 |
4554 | in al, 0x64 |
4554 | test al, 1 |
4555 | test al, 1 |
4555 | jnz kr_ready |
4556 | jnz kr_ready |
4556 | loop kr_loop |
4557 | loop kr_loop |
4557 | mov ah, 1 |
4558 | mov ah, 1 |
4558 | jmp kr_exit |
4559 | jmp kr_exit |
4559 | kr_ready: |
4560 | kr_ready: |
4560 | push ecx |
4561 | push ecx |
4561 | mov ecx, 32 |
4562 | mov ecx, 32 |
4562 | kr_delay: |
4563 | kr_delay: |
4563 | loop kr_delay |
4564 | loop kr_delay |
4564 | pop ecx |
4565 | pop ecx |
4565 | in al, 0x60 |
4566 | in al, 0x60 |
4566 | xor ah, ah |
4567 | xor ah, ah |
4567 | kr_exit: |
4568 | kr_exit: |
4568 | 4569 | ||
4569 | pop edx ecx |
4570 | pop edx ecx |
4570 | 4571 | ||
4571 | ret |
4572 | ret |
4572 | ;----------------------------------------------------------------------------- |
4573 | ;----------------------------------------------------------------------------- |
4573 | align 4 |
4574 | align 4 |
4574 | kb_write: |
4575 | kb_write: |
4575 | 4576 | ||
4576 | push ecx edx |
4577 | push ecx edx |
4577 | 4578 | ||
4578 | mov dl, al |
4579 | mov dl, al |
4579 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4580 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4580 | ; kw_loop1: |
4581 | ; kw_loop1: |
4581 | ; in al,0x64 |
4582 | ; in al,0x64 |
4582 | ; test al,0x20 |
4583 | ; test al,0x20 |
4583 | ; jz kw_ok1 |
4584 | ; jz kw_ok1 |
4584 | ; loop kw_loop1 |
4585 | ; loop kw_loop1 |
4585 | ; mov ah,1 |
4586 | ; mov ah,1 |
4586 | ; jmp kw_exit |
4587 | ; jmp kw_exit |
4587 | ; kw_ok1: |
4588 | ; kw_ok1: |
4588 | in al, 0x60 |
4589 | in al, 0x60 |
4589 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4590 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4590 | kw_loop: |
4591 | kw_loop: |
4591 | in al, 0x64 |
4592 | in al, 0x64 |
4592 | test al, 2 |
4593 | test al, 2 |
4593 | jz kw_ok |
4594 | jz kw_ok |
4594 | loop kw_loop |
4595 | loop kw_loop |
4595 | mov ah, 1 |
4596 | mov ah, 1 |
4596 | jmp kw_exit |
4597 | jmp kw_exit |
4597 | kw_ok: |
4598 | kw_ok: |
4598 | mov al, dl |
4599 | mov al, dl |
4599 | out 0x60, al |
4600 | out 0x60, al |
4600 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4601 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4601 | kw_loop3: |
4602 | kw_loop3: |
4602 | in al, 0x64 |
4603 | in al, 0x64 |
4603 | test al, 2 |
4604 | test al, 2 |
4604 | jz kw_ok3 |
4605 | jz kw_ok3 |
4605 | loop kw_loop3 |
4606 | loop kw_loop3 |
4606 | mov ah, 1 |
4607 | mov ah, 1 |
4607 | jmp kw_exit |
4608 | jmp kw_exit |
4608 | kw_ok3: |
4609 | kw_ok3: |
4609 | mov ah, 8 |
4610 | mov ah, 8 |
4610 | kw_loop4: |
4611 | kw_loop4: |
4611 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4612 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4612 | kw_loop5: |
4613 | kw_loop5: |
4613 | in al, 0x64 |
4614 | in al, 0x64 |
4614 | test al, 1 |
4615 | test al, 1 |
4615 | jnz kw_ok4 |
4616 | jnz kw_ok4 |
4616 | loop kw_loop5 |
4617 | loop kw_loop5 |
4617 | dec ah |
4618 | dec ah |
4618 | jnz kw_loop4 |
4619 | jnz kw_loop4 |
4619 | kw_ok4: |
4620 | kw_ok4: |
4620 | xor ah, ah |
4621 | xor ah, ah |
4621 | kw_exit: |
4622 | kw_exit: |
4622 | 4623 | ||
4623 | pop edx ecx |
4624 | pop edx ecx |
4624 | 4625 | ||
4625 | ret |
4626 | ret |
4626 | ;----------------------------------------------------------------------------- |
4627 | ;----------------------------------------------------------------------------- |
4627 | align 4 |
4628 | align 4 |
4628 | kb_cmd: |
4629 | kb_cmd: |
4629 | 4630 | ||
4630 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4631 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4631 | c_wait: |
4632 | c_wait: |
4632 | in al, 0x64 |
4633 | in al, 0x64 |
4633 | test al, 2 |
4634 | test al, 2 |
4634 | jz c_send |
4635 | jz c_send |
4635 | loop c_wait |
4636 | loop c_wait |
4636 | jmp c_error |
4637 | jmp c_error |
4637 | c_send: |
4638 | c_send: |
4638 | mov al, bl |
4639 | mov al, bl |
4639 | out 0x64, al |
4640 | out 0x64, al |
4640 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4641 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4641 | c_accept: |
4642 | c_accept: |
4642 | in al, 0x64 |
4643 | in al, 0x64 |
4643 | test al, 2 |
4644 | test al, 2 |
4644 | jz c_ok |
4645 | jz c_ok |
4645 | loop c_accept |
4646 | loop c_accept |
4646 | c_error: |
4647 | c_error: |
4647 | mov ah, 1 |
4648 | mov ah, 1 |
4648 | jmp c_exit |
4649 | jmp c_exit |
4649 | c_ok: |
4650 | c_ok: |
4650 | xor ah, ah |
4651 | xor ah, ah |
4651 | c_exit: |
4652 | c_exit: |
4652 | ret |
4653 | ret |
4653 | 4654 | ||
4654 | 4655 | ||
4655 | setmouse: ; set mousepicture -pointer |
4656 | setmouse: ; set mousepicture -pointer |
4656 | ; ps2 mouse enable |
4657 | ; ps2 mouse enable |
4657 | 4658 | ||
4658 | ; mov [MOUSE_PICTURE], dword mousepointer |
4659 | ; mov [MOUSE_PICTURE], dword mousepointer |
4659 | 4660 | ||
4660 | cli |
4661 | cli |
4661 | 4662 | ||
4662 | ret |
4663 | ret |
4663 | 4664 | ||
4664 | if used _rdtsc |
4665 | if used _rdtsc |
4665 | _rdtsc: |
4666 | _rdtsc: |
4666 | bt [cpu_caps], CAPS_TSC |
4667 | bt [cpu_caps], CAPS_TSC |
4667 | jnc ret_rdtsc |
4668 | jnc ret_rdtsc |
4668 | rdtsc |
4669 | rdtsc |
4669 | ret |
4670 | ret |
4670 | ret_rdtsc: |
4671 | ret_rdtsc: |
4671 | mov edx, 0xffffffff |
4672 | mov edx, 0xffffffff |
4672 | mov eax, 0xffffffff |
4673 | mov eax, 0xffffffff |
4673 | ret |
4674 | ret |
4674 | end if |
4675 | end if |
4675 | 4676 | ||
4676 | sys_msg_board_str: |
4677 | sys_msg_board_str: |
4677 | 4678 | ||
4678 | pushad |
4679 | pushad |
4679 | @@: |
4680 | @@: |
4680 | cmp [esi], byte 0 |
4681 | cmp [esi], byte 0 |
4681 | je @f |
4682 | je @f |
4682 | mov eax, 1 |
4683 | mov eax, 1 |
4683 | movzx ebx, byte [esi] |
4684 | movzx ebx, byte [esi] |
4684 | call sys_msg_board |
4685 | call sys_msg_board |
4685 | inc esi |
4686 | inc esi |
4686 | jmp @b |
4687 | jmp @b |
4687 | @@: |
4688 | @@: |
4688 | popad |
4689 | popad |
4689 | ret |
4690 | ret |
4690 | 4691 | ||
4691 | sys_msg_board_byte: |
4692 | sys_msg_board_byte: |
4692 | ; in: al = byte to display |
4693 | ; in: al = byte to display |
4693 | ; out: nothing |
4694 | ; out: nothing |
4694 | ; destroys: nothing |
4695 | ; destroys: nothing |
4695 | pushad |
4696 | pushad |
4696 | mov ecx, 2 |
4697 | mov ecx, 2 |
4697 | shl eax, 24 |
4698 | shl eax, 24 |
4698 | jmp @f |
4699 | jmp @f |
4699 | 4700 | ||
4700 | sys_msg_board_word: |
4701 | sys_msg_board_word: |
4701 | ; in: ax = word to display |
4702 | ; in: ax = word to display |
4702 | ; out: nothing |
4703 | ; out: nothing |
4703 | ; destroys: nothing |
4704 | ; destroys: nothing |
4704 | pushad |
4705 | pushad |
4705 | mov ecx, 4 |
4706 | mov ecx, 4 |
4706 | shl eax, 16 |
4707 | shl eax, 16 |
4707 | jmp @f |
4708 | jmp @f |
4708 | 4709 | ||
4709 | sys_msg_board_dword: |
4710 | sys_msg_board_dword: |
4710 | ; in: eax = dword to display |
4711 | ; in: eax = dword to display |
4711 | ; out: nothing |
4712 | ; out: nothing |
4712 | ; destroys: nothing |
4713 | ; destroys: nothing |
4713 | pushad |
4714 | pushad |
4714 | mov ecx, 8 |
4715 | mov ecx, 8 |
4715 | @@: |
4716 | @@: |
4716 | push ecx |
4717 | push ecx |
4717 | rol eax, 4 |
4718 | rol eax, 4 |
4718 | push eax |
4719 | push eax |
4719 | and al, 0xF |
4720 | and al, 0xF |
4720 | cmp al, 10 |
4721 | cmp al, 10 |
4721 | sbb al, 69h |
4722 | sbb al, 69h |
4722 | das |
4723 | das |
4723 | mov bl, al |
4724 | mov bl, al |
4724 | xor eax, eax |
4725 | xor eax, eax |
4725 | inc eax |
4726 | inc eax |
4726 | call sys_msg_board |
4727 | call sys_msg_board |
4727 | pop eax |
4728 | pop eax |
4728 | pop ecx |
4729 | pop ecx |
4729 | loop @b |
4730 | loop @b |
4730 | popad |
4731 | popad |
4731 | ret |
4732 | ret |
4732 | 4733 | ||
4733 | msg_board_data_size = 65536 ; Must be power of two |
4734 | msg_board_data_size = 65536 ; Must be power of two |
4734 | 4735 | ||
4735 | uglobal |
4736 | uglobal |
4736 | msg_board_data rb msg_board_data_size |
4737 | msg_board_data rb msg_board_data_size |
4737 | msg_board_count dd 0x0 |
4738 | msg_board_count dd 0x0 |
4738 | endg |
4739 | endg |
4739 | 4740 | ||
4740 | sys_msg_board: |
4741 | sys_msg_board: |
4741 | 4742 | ||
4742 | ; eax=1 : write : bl byte to write |
4743 | ; eax=1 : write : bl byte to write |
4743 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4744 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4744 | 4745 | ||
4745 | mov ecx, [msg_board_count] |
4746 | mov ecx, [msg_board_count] |
4746 | cmp eax, 1 |
4747 | cmp eax, 1 |
4747 | jne .smbl1 |
4748 | jne .smbl1 |
4748 | 4749 | ||
4749 | if defined debug_com_base |
4750 | if defined debug_com_base |
4750 | 4751 | ||
4751 | push dx ax |
4752 | push dx ax |
4752 | 4753 | ||
4753 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4754 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4754 | mov dx, debug_com_base+5 |
4755 | mov dx, debug_com_base+5 |
4755 | in al, dx |
4756 | in al, dx |
4756 | test al, 1 shl 5 |
4757 | test al, 1 shl 5 |
4757 | jz @r |
4758 | jz @r |
4758 | 4759 | ||
4759 | mov dx, debug_com_base ; Output the byte |
4760 | mov dx, debug_com_base ; Output the byte |
4760 | mov al, bl |
4761 | mov al, bl |
4761 | out dx, al |
4762 | out dx, al |
4762 | 4763 | ||
4763 | pop ax dx |
4764 | pop ax dx |
4764 | 4765 | ||
4765 | end if |
4766 | end if |
4766 | 4767 | ||
4767 | mov [msg_board_data+ecx], bl |
4768 | mov [msg_board_data+ecx], bl |
4768 | if debug_direct_print |
4769 | if debug_direct_print |
4769 | pusha |
4770 | pusha |
4770 | iglobal |
4771 | iglobal |
4771 | msg_board_pos dd 234*65536+10 |
4772 | msg_board_pos dd 234*65536+10 |
4772 | endg |
4773 | endg |
4773 | lea edx, [msg_board_data+ecx] |
4774 | lea edx, [msg_board_data+ecx] |
4774 | mov ecx, 0x40FFFFFF |
4775 | mov ecx, 0x40FFFFFF |
4775 | mov ebx, [msg_board_pos] |
4776 | mov ebx, [msg_board_pos] |
4776 | mov edi, 1 |
4777 | mov edi, 1 |
4777 | mov esi, 1 |
4778 | mov esi, 1 |
4778 | call dtext |
4779 | call dtext |
4779 | popa |
4780 | popa |
4780 | add word [msg_board_pos+2], 6 |
4781 | add word [msg_board_pos+2], 6 |
4781 | cmp bl, 10 |
4782 | cmp bl, 10 |
4782 | jnz @f |
4783 | jnz @f |
4783 | mov word [msg_board_pos+2], 234 |
4784 | mov word [msg_board_pos+2], 234 |
4784 | add word [msg_board_pos], 10 |
4785 | add word [msg_board_pos], 10 |
4785 | mov ax, [Screen_Max_Y] |
4786 | mov ax, word [Screen_Max_Y] |
4786 | cmp word [msg_board_pos], ax |
4787 | cmp word [msg_board_pos], ax |
4787 | jbe @f |
4788 | jbe @f |
4788 | mov word [msg_board_pos], 10 |
4789 | mov word [msg_board_pos], 10 |
4789 | @@: |
4790 | @@: |
4790 | end if |
4791 | end if |
4791 | if 0 |
4792 | if 0 |
4792 | pusha |
4793 | pusha |
4793 | mov al, bl |
4794 | mov al, bl |
4794 | mov edx, 402h |
4795 | mov edx, 402h |
4795 | out dx, al |
4796 | out dx, al |
4796 | popa |
4797 | popa |
4797 | end if |
4798 | end if |
4798 | inc ecx |
4799 | inc ecx |
4799 | and ecx, msg_board_data_size - 1 |
4800 | and ecx, msg_board_data_size - 1 |
4800 | mov [msg_board_count], ecx |
4801 | mov [msg_board_count], ecx |
4801 | ret |
4802 | ret |
4802 | .smbl1: |
4803 | .smbl1: |
4803 | cmp eax, 2 |
4804 | cmp eax, 2 |
4804 | jne .smbl2 |
4805 | jne .smbl2 |
4805 | test ecx, ecx |
4806 | test ecx, ecx |
4806 | jz .smbl21 |
4807 | jz .smbl21 |
4807 | mov eax, msg_board_data+1 |
4808 | mov eax, msg_board_data+1 |
4808 | mov ebx, msg_board_data |
4809 | mov ebx, msg_board_data |
4809 | movzx edx, byte [ebx] |
4810 | movzx edx, byte [ebx] |
4810 | call memmove |
4811 | call memmove |
4811 | dec [msg_board_count] |
4812 | dec [msg_board_count] |
4812 | mov [esp + 36], edx ;eax |
4813 | mov [esp + 36], edx ;eax |
4813 | mov [esp + 24], dword 1 |
4814 | mov [esp + 24], dword 1 |
4814 | ret |
4815 | ret |
4815 | .smbl21: |
4816 | .smbl21: |
4816 | mov [esp+36], ecx |
4817 | mov [esp+36], ecx |
4817 | mov [esp+24], ecx |
4818 | mov [esp+24], ecx |
4818 | .smbl2: |
4819 | .smbl2: |
4819 | ret |
4820 | ret |
4820 | 4821 | ||
4821 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4822 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4822 | ;; 66 sys function. ;; |
4823 | ;; 66 sys function. ;; |
4823 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4824 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4824 | ;; out eax ;; |
4825 | ;; out eax ;; |
4825 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4826 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4826 | iglobal |
4827 | iglobal |
4827 | align 4 |
4828 | align 4 |
4828 | f66call: |
4829 | f66call: |
4829 | dd sys_process_def.1 ; 1 = set keyboard mode |
4830 | dd sys_process_def.1 ; 1 = set keyboard mode |
4830 | dd sys_process_def.2 ; 2 = get keyboard mode |
4831 | dd sys_process_def.2 ; 2 = get keyboard mode |
4831 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4832 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4832 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4833 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4833 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4834 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4834 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4835 | 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 |
4836 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4836 | endg |
4837 | endg |
4837 | ;----------------------------------------------------------------------------- |
4838 | ;----------------------------------------------------------------------------- |
4838 | align 4 |
4839 | align 4 |
4839 | sys_process_def: |
4840 | sys_process_def: |
4840 | dec ebx |
4841 | dec ebx |
4841 | cmp ebx, 7 |
4842 | cmp ebx, 7 |
4842 | jae .not_support ;if >=8 then or eax,-1 |
4843 | jae .not_support ;if >=8 then or eax,-1 |
4843 | 4844 | ||
4844 | mov edi, [CURRENT_TASK] |
4845 | mov edi, [CURRENT_TASK] |
4845 | jmp dword [f66call+ebx*4] |
4846 | jmp dword [f66call+ebx*4] |
4846 | 4847 | ||
4847 | .not_support: |
4848 | .not_support: |
4848 | or eax, -1 |
4849 | or eax, -1 |
4849 | ret |
4850 | ret |
4850 | ;----------------------------------------------------------------------------- |
4851 | ;----------------------------------------------------------------------------- |
4851 | align 4 |
4852 | align 4 |
4852 | .1: |
4853 | .1: |
4853 | shl edi, 8 |
4854 | shl edi, 8 |
4854 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4855 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4855 | 4856 | ||
4856 | ret |
4857 | ret |
4857 | ;----------------------------------------------------------------------------- |
4858 | ;----------------------------------------------------------------------------- |
4858 | align 4 |
4859 | align 4 |
4859 | .2: ; 2 = get keyboard mode |
4860 | .2: ; 2 = get keyboard mode |
4860 | shl edi, 8 |
4861 | shl edi, 8 |
4861 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4862 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4862 | mov [esp+32], eax |
4863 | mov [esp+32], eax |
4863 | ret |
4864 | ret |
4864 | ;----------------------------------------------------------------------------- |
4865 | ;----------------------------------------------------------------------------- |
4865 | align 4 |
4866 | align 4 |
4866 | .3: ;3 = get keyboard ctrl, alt, shift |
4867 | .3: ;3 = get keyboard ctrl, alt, shift |
4867 | mov eax, [kb_state] |
4868 | mov eax, [kb_state] |
4868 | mov [esp+32], eax |
4869 | mov [esp+32], eax |
4869 | ret |
4870 | ret |
4870 | ;----------------------------------------------------------------------------- |
4871 | ;----------------------------------------------------------------------------- |
4871 | align 4 |
4872 | align 4 |
4872 | .4: |
4873 | .4: |
4873 | mov eax, hotkey_list |
4874 | mov eax, hotkey_list |
4874 | @@: |
4875 | @@: |
4875 | cmp dword [eax+8], 0 |
4876 | cmp dword [eax+8], 0 |
4876 | jz .found_free |
4877 | jz .found_free |
4877 | add eax, 16 |
4878 | add eax, 16 |
4878 | cmp eax, hotkey_list+16*256 |
4879 | cmp eax, hotkey_list+16*256 |
4879 | jb @b |
4880 | jb @b |
4880 | mov dword [esp+32], 1 |
4881 | mov dword [esp+32], 1 |
4881 | ret |
4882 | ret |
4882 | .found_free: |
4883 | .found_free: |
4883 | mov [eax+8], edi |
4884 | mov [eax+8], edi |
4884 | mov [eax+4], edx |
4885 | mov [eax+4], edx |
4885 | movzx ecx, cl |
4886 | movzx ecx, cl |
4886 | lea ecx, [hotkey_scancodes+ecx*4] |
4887 | lea ecx, [hotkey_scancodes+ecx*4] |
4887 | mov edx, [ecx] |
4888 | mov edx, [ecx] |
4888 | mov [eax], edx |
4889 | mov [eax], edx |
4889 | mov [ecx], eax |
4890 | mov [ecx], eax |
4890 | mov [eax+12], ecx |
4891 | mov [eax+12], ecx |
4891 | test edx, edx |
4892 | test edx, edx |
4892 | jz @f |
4893 | jz @f |
4893 | mov [edx+12], eax |
4894 | mov [edx+12], eax |
4894 | @@: |
4895 | @@: |
4895 | and dword [esp+32], 0 |
4896 | and dword [esp+32], 0 |
4896 | ret |
4897 | ret |
4897 | ;----------------------------------------------------------------------------- |
4898 | ;----------------------------------------------------------------------------- |
4898 | align 4 |
4899 | align 4 |
4899 | .5: |
4900 | .5: |
4900 | movzx ebx, cl |
4901 | movzx ebx, cl |
4901 | lea ebx, [hotkey_scancodes+ebx*4] |
4902 | lea ebx, [hotkey_scancodes+ebx*4] |
4902 | mov eax, [ebx] |
4903 | mov eax, [ebx] |
4903 | .scan: |
4904 | .scan: |
4904 | test eax, eax |
4905 | test eax, eax |
4905 | jz .notfound |
4906 | jz .notfound |
4906 | cmp [eax+8], edi |
4907 | cmp [eax+8], edi |
4907 | jnz .next |
4908 | jnz .next |
4908 | cmp [eax+4], edx |
4909 | cmp [eax+4], edx |
4909 | jz .found |
4910 | jz .found |
4910 | .next: |
4911 | .next: |
4911 | mov eax, [eax] |
4912 | mov eax, [eax] |
4912 | jmp .scan |
4913 | jmp .scan |
4913 | .notfound: |
4914 | .notfound: |
4914 | mov dword [esp+32], 1 |
4915 | mov dword [esp+32], 1 |
4915 | ret |
4916 | ret |
4916 | .found: |
4917 | .found: |
4917 | mov ecx, [eax] |
4918 | mov ecx, [eax] |
4918 | jecxz @f |
4919 | jecxz @f |
4919 | mov edx, [eax+12] |
4920 | mov edx, [eax+12] |
4920 | mov [ecx+12], edx |
4921 | mov [ecx+12], edx |
4921 | @@: |
4922 | @@: |
4922 | mov ecx, [eax+12] |
4923 | mov ecx, [eax+12] |
4923 | mov edx, [eax] |
4924 | mov edx, [eax] |
4924 | mov [ecx], edx |
4925 | mov [ecx], edx |
4925 | xor edx, edx |
4926 | xor edx, edx |
4926 | mov [eax+4], edx |
4927 | mov [eax+4], edx |
4927 | mov [eax+8], edx |
4928 | mov [eax+8], edx |
4928 | mov [eax+12], edx |
4929 | mov [eax+12], edx |
4929 | mov [eax], edx |
4930 | mov [eax], edx |
4930 | mov [esp+32], edx |
4931 | mov [esp+32], edx |
4931 | ret |
4932 | ret |
4932 | ;----------------------------------------------------------------------------- |
4933 | ;----------------------------------------------------------------------------- |
4933 | align 4 |
4934 | align 4 |
4934 | .6: |
4935 | .6: |
4935 | pushfd |
4936 | pushfd |
4936 | cli |
4937 | cli |
4937 | mov eax, [PID_lock_input] |
4938 | mov eax, [PID_lock_input] |
4938 | test eax, eax |
4939 | test eax, eax |
4939 | jnz @f |
4940 | jnz @f |
4940 | ; get current PID |
4941 | ; get current PID |
4941 | mov eax, [CURRENT_TASK] |
4942 | mov eax, [CURRENT_TASK] |
4942 | shl eax, 5 |
4943 | shl eax, 5 |
4943 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4944 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4944 | ; set current PID for lock input |
4945 | ; set current PID for lock input |
4945 | mov [PID_lock_input], eax |
4946 | mov [PID_lock_input], eax |
4946 | @@: |
4947 | @@: |
4947 | popfd |
4948 | popfd |
4948 | ret |
4949 | ret |
4949 | ;----------------------------------------------------------------------------- |
4950 | ;----------------------------------------------------------------------------- |
4950 | align 4 |
4951 | align 4 |
4951 | .7: |
4952 | .7: |
4952 | mov eax, [PID_lock_input] |
4953 | mov eax, [PID_lock_input] |
4953 | test eax, eax |
4954 | test eax, eax |
4954 | jz @f |
4955 | jz @f |
4955 | ; get current PID |
4956 | ; get current PID |
4956 | mov ebx, [CURRENT_TASK] |
4957 | mov ebx, [CURRENT_TASK] |
4957 | shl ebx, 5 |
4958 | shl ebx, 5 |
4958 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4959 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4959 | ; compare current lock input with current PID |
4960 | ; compare current lock input with current PID |
4960 | cmp ebx, eax |
4961 | cmp ebx, eax |
4961 | jne @f |
4962 | jne @f |
4962 | 4963 | ||
4963 | xor eax, eax |
4964 | xor eax, eax |
4964 | mov [PID_lock_input], eax |
4965 | mov [PID_lock_input], eax |
4965 | @@: |
4966 | @@: |
4966 | ret |
4967 | ret |
4967 | ;----------------------------------------------------------------------------- |
4968 | ;----------------------------------------------------------------------------- |
4968 | uglobal |
4969 | uglobal |
4969 | PID_lock_input dd 0x0 |
4970 | PID_lock_input dd 0x0 |
4970 | endg |
4971 | endg |
4971 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4972 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4972 | ;; 61 sys function. ;; |
4973 | ;; 61 sys function. ;; |
4973 | ;; in eax=61,ebx in [1..3] ;; |
4974 | ;; in eax=61,ebx in [1..3] ;; |
4974 | ;; out eax ;; |
4975 | ;; out eax ;; |
4975 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4976 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4976 | iglobal |
4977 | iglobal |
4977 | align 4 |
4978 | align 4 |
4978 | f61call: |
4979 | f61call: |
4979 | dd sys_gs.1 ; resolution |
4980 | dd sys_gs.1 ; resolution |
4980 | dd sys_gs.2 ; bits per pixel |
4981 | dd sys_gs.2 ; bits per pixel |
4981 | dd sys_gs.3 ; bytes per scanline |
4982 | dd sys_gs.3 ; bytes per scanline |
4982 | endg |
4983 | endg |
4983 | 4984 | ||
4984 | 4985 | ||
4985 | align 4 |
4986 | align 4 |
4986 | 4987 | ||
4987 | sys_gs: ; direct screen access |
4988 | sys_gs: ; direct screen access |
4988 | dec ebx |
4989 | dec ebx |
4989 | cmp ebx, 2 |
4990 | cmp ebx, 2 |
4990 | ja .not_support |
4991 | ja .not_support |
4991 | jmp dword [f61call+ebx*4] |
4992 | jmp dword [f61call+ebx*4] |
4992 | .not_support: |
4993 | .not_support: |
4993 | or [esp+32], dword -1 |
4994 | or [esp+32], dword -1 |
4994 | ret |
4995 | ret |
4995 | 4996 | ||
4996 | 4997 | ||
4997 | .1: ; resolution |
4998 | .1: ; resolution |
4998 | mov eax, [Screen_Max_X] |
4999 | mov eax, [Screen_Max_X] |
4999 | shl eax, 16 |
5000 | shl eax, 16 |
5000 | mov ax, word [Screen_Max_Y] |
5001 | mov ax, word [Screen_Max_Y] |
5001 | add eax, 0x00010001 |
5002 | add eax, 0x00010001 |
5002 | mov [esp+32], eax |
5003 | mov [esp+32], eax |
5003 | ret |
5004 | ret |
5004 | .2: ; bits per pixel |
5005 | .2: ; bits per pixel |
5005 | mov eax, [_display.bpp] |
5006 | mov eax, [_display.bpp] |
5006 | mov [esp+32], eax |
5007 | mov [esp+32], eax |
5007 | ret |
5008 | ret |
5008 | .3: ; bytes per scanline |
5009 | .3: ; bytes per scanline |
5009 | mov eax, [_display.pitch] |
5010 | mov eax, [_display.pitch] |
5010 | mov [esp+32], eax |
5011 | mov [esp+32], eax |
5011 | ret |
5012 | ret |
5012 | 5013 | ||
5013 | align 4 ; system functions |
5014 | align 4 ; system functions |
5014 | 5015 | ||
5015 | syscall_setpixel: ; SetPixel |
5016 | syscall_setpixel: ; SetPixel |
5016 | 5017 | ||
5017 | mov eax, ebx |
5018 | mov eax, ebx |
5018 | mov ebx, ecx |
5019 | mov ebx, ecx |
5019 | mov ecx, edx |
5020 | mov ecx, edx |
5020 | mov edx, [TASK_BASE] |
5021 | mov edx, [TASK_BASE] |
5021 | add eax, [edx-twdw+WDATA.box.left] |
5022 | add eax, [edx-twdw+WDATA.box.left] |
5022 | add ebx, [edx-twdw+WDATA.box.top] |
5023 | add ebx, [edx-twdw+WDATA.box.top] |
5023 | mov edi, [current_slot] |
5024 | mov edi, [current_slot] |
5024 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5025 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5025 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5026 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5026 | xor edi, edi ; no force |
5027 | xor edi, edi ; no force |
5027 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5028 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5028 | ; jmp [putpixel] |
5029 | ; jmp [putpixel] |
5029 | jmp __sys_putpixel |
5030 | jmp __sys_putpixel |
5030 | 5031 | ||
5031 | align 4 |
5032 | align 4 |
5032 | 5033 | ||
5033 | syscall_writetext: ; WriteText |
5034 | syscall_writetext: ; WriteText |
5034 | 5035 | ||
5035 | mov eax, [TASK_BASE] |
5036 | mov eax, [TASK_BASE] |
5036 | mov ebp, [eax-twdw+WDATA.box.left] |
5037 | mov ebp, [eax-twdw+WDATA.box.left] |
5037 | push esi |
5038 | push esi |
5038 | mov esi, [current_slot] |
5039 | mov esi, [current_slot] |
5039 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5040 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5040 | shl ebp, 16 |
5041 | shl ebp, 16 |
5041 | add ebp, [eax-twdw+WDATA.box.top] |
5042 | add ebp, [eax-twdw+WDATA.box.top] |
5042 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5043 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5043 | pop esi |
5044 | pop esi |
5044 | test ecx, 0x08000000 ; redirect the output to the user area |
5045 | test ecx, 0x08000000 ; redirect the output to the user area |
5045 | jnz @f |
5046 | jnz @f |
5046 | add ebx, ebp |
5047 | add ebx, ebp |
5047 | align 4 |
5048 | align 4 |
5048 | @@: |
5049 | @@: |
5049 | mov eax, edi |
5050 | mov eax, edi |
5050 | test ecx, 0x08000000 ; redirect the output to the user area |
5051 | test ecx, 0x08000000 ; redirect the output to the user area |
5051 | jnz dtext |
5052 | jnz dtext |
5052 | xor edi, edi |
5053 | xor edi, edi |
5053 | jmp dtext |
5054 | jmp dtext |
5054 | 5055 | ||
5055 | align 4 |
5056 | align 4 |
5056 | 5057 | ||
5057 | syscall_openramdiskfile: ; OpenRamdiskFile |
5058 | syscall_openramdiskfile: ; OpenRamdiskFile |
5058 | 5059 | ||
5059 | mov eax, ebx |
5060 | mov eax, ebx |
5060 | mov ebx, ecx |
5061 | mov ebx, ecx |
5061 | mov ecx, edx |
5062 | mov ecx, edx |
5062 | mov edx, esi |
5063 | mov edx, esi |
5063 | mov esi, 12 |
5064 | mov esi, 12 |
5064 | call fileread |
5065 | call fileread |
5065 | mov [esp+32], eax |
5066 | mov [esp+32], eax |
5066 | ret |
5067 | ret |
5067 | 5068 | ||
5068 | align 4 |
5069 | align 4 |
5069 | 5070 | ||
5070 | syscall_drawrect: ; DrawRect |
5071 | syscall_drawrect: ; DrawRect |
5071 | 5072 | ||
5072 | mov edi, edx ; color + gradient |
5073 | mov edi, edx ; color + gradient |
5073 | and edi, 0x80FFFFFF |
5074 | and edi, 0x80FFFFFF |
5074 | test bx, bx ; x.size |
5075 | test bx, bx ; x.size |
5075 | je .drectr |
5076 | je .drectr |
5076 | test cx, cx ; y.size |
5077 | test cx, cx ; y.size |
5077 | je .drectr |
5078 | je .drectr |
5078 | 5079 | ||
5079 | mov eax, ebx ; bad idea |
5080 | mov eax, ebx ; bad idea |
5080 | mov ebx, ecx |
5081 | mov ebx, ecx |
5081 | 5082 | ||
5082 | movzx ecx, ax ; ecx - x.size |
5083 | movzx ecx, ax ; ecx - x.size |
5083 | shr eax, 16 ; eax - x.coord |
5084 | shr eax, 16 ; eax - x.coord |
5084 | movzx edx, bx ; edx - y.size |
5085 | movzx edx, bx ; edx - y.size |
5085 | shr ebx, 16 ; ebx - y.coord |
5086 | shr ebx, 16 ; ebx - y.coord |
5086 | mov esi, [current_slot] |
5087 | mov esi, [current_slot] |
5087 | 5088 | ||
5088 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5089 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5089 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5090 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5090 | add ecx, eax |
5091 | add ecx, eax |
5091 | add edx, ebx |
5092 | add edx, ebx |
5092 | ; jmp [drawbar] |
5093 | ; jmp [drawbar] |
5093 | jmp vesa20_drawbar |
5094 | jmp vesa20_drawbar |
5094 | .drectr: |
5095 | .drectr: |
5095 | ret |
5096 | ret |
5096 | 5097 | ||
5097 | align 4 |
5098 | align 4 |
5098 | syscall_getscreensize: ; GetScreenSize |
5099 | syscall_getscreensize: ; GetScreenSize |
5099 | mov ax, word [Screen_Max_X] |
5100 | mov ax, word [Screen_Max_X] |
5100 | shl eax, 16 |
5101 | shl eax, 16 |
5101 | mov ax, word [Screen_Max_Y] |
5102 | mov ax, word [Screen_Max_Y] |
5102 | mov [esp + 32], eax |
5103 | mov [esp + 32], eax |
5103 | ret |
5104 | ret |
5104 | 5105 | ||
5105 | align 4 |
5106 | align 4 |
5106 | 5107 | ||
5107 | syscall_cdaudio: ; CD |
5108 | syscall_cdaudio: ; CD |
5108 | 5109 | ||
5109 | cmp ebx, 4 |
5110 | cmp ebx, 4 |
5110 | jb .audio |
5111 | jb .audio |
5111 | jz .eject |
5112 | jz .eject |
5112 | cmp ebx, 5 |
5113 | cmp ebx, 5 |
5113 | jnz .ret |
5114 | jnz .ret |
5114 | .load: |
5115 | .load: |
5115 | call .reserve |
5116 | call .reserve |
5116 | call LoadMedium |
5117 | call LoadMedium |
5117 | ;call .free |
5118 | ;call .free |
5118 | jmp .free |
5119 | jmp .free |
5119 | ; ret |
5120 | ; ret |
5120 | .eject: |
5121 | .eject: |
5121 | call .reserve |
5122 | call .reserve |
5122 | call clear_CD_cache |
5123 | call clear_CD_cache |
5123 | call allow_medium_removal |
5124 | call allow_medium_removal |
5124 | call EjectMedium |
5125 | call EjectMedium |
5125 | ; call .free |
5126 | ; call .free |
5126 | jmp .free |
5127 | jmp .free |
5127 | ; ret |
5128 | ; ret |
5128 | .audio: |
5129 | .audio: |
5129 | call sys_cd_audio |
5130 | call sys_cd_audio |
5130 | mov [esp+36-4], eax |
5131 | mov [esp+36-4], eax |
5131 | .ret: |
5132 | .ret: |
5132 | ret |
5133 | ret |
5133 | 5134 | ||
5134 | .reserve: |
5135 | .reserve: |
5135 | call reserve_cd |
5136 | call reserve_cd |
5136 | mov eax, ecx |
5137 | mov eax, ecx |
5137 | shr eax, 1 |
5138 | shr eax, 1 |
5138 | and eax, 1 |
5139 | and eax, 1 |
5139 | inc eax |
5140 | inc eax |
5140 | mov [ChannelNumber], ax |
5141 | mov [ChannelNumber], ax |
5141 | mov eax, ecx |
5142 | mov eax, ecx |
5142 | and eax, 1 |
5143 | and eax, 1 |
5143 | mov [DiskNumber], al |
5144 | mov [DiskNumber], al |
5144 | call reserve_cd_channel |
5145 | call reserve_cd_channel |
5145 | and ebx, 3 |
5146 | and ebx, 3 |
5146 | inc ebx |
5147 | inc ebx |
5147 | mov [cdpos], ebx |
5148 | mov [cdpos], ebx |
5148 | add ebx, ebx |
5149 | add ebx, ebx |
5149 | mov cl, 8 |
5150 | mov cl, 8 |
5150 | sub cl, bl |
5151 | sub cl, bl |
5151 | mov al, [DRIVE_DATA+1] |
5152 | mov al, [DRIVE_DATA+1] |
5152 | shr al, cl |
5153 | shr al, cl |
5153 | test al, 2 |
5154 | test al, 2 |
5154 | jz .free;.err |
5155 | jz .free;.err |
5155 | ret |
5156 | ret |
5156 | .free: |
5157 | .free: |
5157 | call free_cd_channel |
5158 | call free_cd_channel |
5158 | and [cd_status], 0 |
5159 | and [cd_status], 0 |
5159 | ret |
5160 | ret |
5160 | .err: |
5161 | .err: |
5161 | call .free |
5162 | call .free |
5162 | ; pop eax |
5163 | ; pop eax |
5163 | ret |
5164 | ret |
5164 | ;----------------------------------------------------------------------------- |
5165 | ;----------------------------------------------------------------------------- |
5165 | align 4 |
5166 | align 4 |
5166 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5167 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5167 | cmp ebx, [Screen_Max_X] |
5168 | cmp ebx, [Screen_Max_X] |
5168 | jbe @f |
5169 | jbe @f |
5169 | cmp ecx, [Screen_Max_Y] |
5170 | cmp ecx, [Screen_Max_Y] |
5170 | jbe @f |
5171 | jbe @f |
5171 | xor eax, eax |
5172 | xor eax, eax |
5172 | jmp .store |
5173 | jmp .store |
5173 | ;-------------------------------------- |
5174 | ;-------------------------------------- |
5174 | align 4 |
5175 | align 4 |
5175 | @@: |
5176 | @@: |
5176 | mov eax, [d_width_calc_area + ecx*4] |
5177 | mov eax, [d_width_calc_area + ecx*4] |
5177 | add eax, [_WinMapAddress] |
5178 | add eax, [_WinMapAddress] |
5178 | movzx eax, byte[eax+ebx] ; get value for current point |
5179 | movzx eax, byte[eax+ebx] ; get value for current point |
5179 | ;-------------------------------------- |
5180 | ;-------------------------------------- |
5180 | align 4 |
5181 | align 4 |
5181 | .store: |
5182 | .store: |
5182 | mov [esp + 32], eax |
5183 | mov [esp + 32], eax |
5183 | ret |
5184 | ret |
5184 | ;----------------------------------------------------------------------------- |
5185 | ;----------------------------------------------------------------------------- |
5185 | align 4 |
5186 | align 4 |
5186 | syscall_getpixel: ; GetPixel |
5187 | syscall_getpixel: ; GetPixel |
5187 | mov ecx, [Screen_Max_X] |
5188 | mov ecx, [Screen_Max_X] |
5188 | inc ecx |
5189 | inc ecx |
5189 | xor edx, edx |
5190 | xor edx, edx |
5190 | mov eax, ebx |
5191 | mov eax, ebx |
5191 | div ecx |
5192 | div ecx |
5192 | mov ebx, edx |
5193 | mov ebx, edx |
5193 | xchg eax, ebx |
5194 | xchg eax, ebx |
5194 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5195 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5195 | call dword [GETPIXEL]; eax - x, ebx - y |
5196 | call dword [GETPIXEL]; eax - x, ebx - y |
5196 | mov [esp + 32], ecx |
5197 | mov [esp + 32], ecx |
5197 | ret |
5198 | ret |
5198 | ;----------------------------------------------------------------------------- |
5199 | ;----------------------------------------------------------------------------- |
5199 | align 4 |
5200 | align 4 |
5200 | syscall_getarea: |
5201 | syscall_getarea: |
5201 | ;eax = 36 |
5202 | ;eax = 36 |
5202 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5203 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5203 | ;ecx = [size x]*65536 + [size y] |
5204 | ;ecx = [size x]*65536 + [size y] |
5204 | ;edx = [start x]*65536 + [start y] |
5205 | ;edx = [start x]*65536 + [start y] |
5205 | pushad |
5206 | pushad |
5206 | mov edi, ebx |
5207 | mov edi, ebx |
5207 | mov eax, edx |
5208 | mov eax, edx |
5208 | shr eax, 16 |
5209 | shr eax, 16 |
5209 | mov ebx, edx |
5210 | mov ebx, edx |
5210 | and ebx, 0xffff |
5211 | and ebx, 0xffff |
5211 | dec eax |
5212 | dec eax |
5212 | dec ebx |
5213 | dec ebx |
5213 | ; eax - x, ebx - y |
5214 | ; eax - x, ebx - y |
5214 | mov edx, ecx |
5215 | mov edx, ecx |
5215 | 5216 | ||
5216 | shr ecx, 16 |
5217 | shr ecx, 16 |
5217 | and edx, 0xffff |
5218 | and edx, 0xffff |
5218 | mov esi, ecx |
5219 | mov esi, ecx |
5219 | ; ecx - size x, edx - size y |
5220 | ; ecx - size x, edx - size y |
5220 | 5221 | ||
5221 | mov ebp, edx |
5222 | mov ebp, edx |
5222 | dec ebp |
5223 | dec ebp |
5223 | lea ebp, [ebp*3] |
5224 | lea ebp, [ebp*3] |
5224 | 5225 | ||
5225 | imul ebp, esi |
5226 | imul ebp, esi |
5226 | 5227 | ||
5227 | mov esi, ecx |
5228 | mov esi, ecx |
5228 | dec esi |
5229 | dec esi |
5229 | lea esi, [esi*3] |
5230 | lea esi, [esi*3] |
5230 | 5231 | ||
5231 | add ebp, esi |
5232 | add ebp, esi |
5232 | add ebp, edi |
5233 | add ebp, edi |
5233 | 5234 | ||
5234 | add ebx, edx |
5235 | add ebx, edx |
5235 | ;-------------------------------------- |
5236 | ;-------------------------------------- |
5236 | align 4 |
5237 | align 4 |
5237 | .start_y: |
5238 | .start_y: |
5238 | push ecx edx |
5239 | push ecx edx |
5239 | ;-------------------------------------- |
5240 | ;-------------------------------------- |
5240 | align 4 |
5241 | align 4 |
5241 | .start_x: |
5242 | .start_x: |
5242 | push eax ebx ecx |
5243 | push eax ebx ecx |
5243 | add eax, ecx |
5244 | add eax, ecx |
5244 | 5245 | ||
5245 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5246 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5246 | call dword [GETPIXEL]; eax - x, ebx - y |
5247 | call dword [GETPIXEL]; eax - x, ebx - y |
5247 | 5248 | ||
5248 | mov [ebp], cx |
5249 | mov [ebp], cx |
5249 | shr ecx, 16 |
5250 | shr ecx, 16 |
5250 | mov [ebp+2], cl |
5251 | mov [ebp+2], cl |
5251 | 5252 | ||
5252 | pop ecx ebx eax |
5253 | pop ecx ebx eax |
5253 | sub ebp, 3 |
5254 | sub ebp, 3 |
5254 | dec ecx |
5255 | dec ecx |
5255 | jnz .start_x |
5256 | jnz .start_x |
5256 | pop edx ecx |
5257 | pop edx ecx |
5257 | dec ebx |
5258 | dec ebx |
5258 | dec edx |
5259 | dec edx |
5259 | jnz .start_y |
5260 | jnz .start_y |
5260 | popad |
5261 | popad |
5261 | ret |
5262 | ret |
5262 | ;----------------------------------------------------------------------------- |
5263 | ;----------------------------------------------------------------------------- |
5263 | align 4 |
5264 | align 4 |
5264 | syscall_putarea_backgr: |
5265 | syscall_putarea_backgr: |
5265 | ;eax = 25 |
5266 | ;eax = 25 |
5266 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5267 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5267 | ;ecx = [size x]*65536 + [size y] |
5268 | ;ecx = [size x]*65536 + [size y] |
5268 | ;edx = [start x]*65536 + [start y] |
5269 | ;edx = [start x]*65536 + [start y] |
5269 | pushad |
5270 | pushad |
5270 | mov edi, ebx |
5271 | mov edi, ebx |
5271 | mov eax, edx |
5272 | mov eax, edx |
5272 | shr eax, 16 |
5273 | shr eax, 16 |
5273 | mov ebx, edx |
5274 | mov ebx, edx |
5274 | and ebx, 0xffff |
5275 | and ebx, 0xffff |
5275 | dec eax |
5276 | dec eax |
5276 | dec ebx |
5277 | dec ebx |
5277 | ; eax - x, ebx - y |
5278 | ; eax - x, ebx - y |
5278 | mov edx, ecx |
5279 | mov edx, ecx |
5279 | shr ecx, 16 |
5280 | shr ecx, 16 |
5280 | and edx, 0xffff |
5281 | and edx, 0xffff |
5281 | mov esi, ecx |
5282 | mov esi, ecx |
5282 | ; ecx - size x, edx - size y |
5283 | ; ecx - size x, edx - size y |
5283 | mov ebp, edx |
5284 | mov ebp, edx |
5284 | dec ebp |
5285 | dec ebp |
5285 | shl ebp, 2 |
5286 | shl ebp, 2 |
5286 | 5287 | ||
5287 | imul ebp, esi |
5288 | imul ebp, esi |
5288 | 5289 | ||
5289 | mov esi, ecx |
5290 | mov esi, ecx |
5290 | dec esi |
5291 | dec esi |
5291 | shl esi, 2 |
5292 | shl esi, 2 |
5292 | 5293 | ||
5293 | add ebp, esi |
5294 | add ebp, esi |
5294 | add ebp, edi |
5295 | add ebp, edi |
5295 | 5296 | ||
5296 | add ebx, edx |
5297 | add ebx, edx |
5297 | ;-------------------------------------- |
5298 | ;-------------------------------------- |
5298 | align 4 |
5299 | align 4 |
5299 | .start_y: |
5300 | .start_y: |
5300 | push ecx edx |
5301 | push ecx edx |
5301 | ;-------------------------------------- |
5302 | ;-------------------------------------- |
5302 | align 4 |
5303 | align 4 |
5303 | .start_x: |
5304 | .start_x: |
5304 | push eax ecx |
5305 | push eax ecx |
5305 | add eax, ecx |
5306 | add eax, ecx |
5306 | 5307 | ||
5307 | mov ecx, [ebp] |
5308 | mov ecx, [ebp] |
5308 | rol ecx, 8 |
5309 | rol ecx, 8 |
5309 | test cl, cl ; transparensy = 0 |
5310 | test cl, cl ; transparensy = 0 |
5310 | jz .no_put |
5311 | jz .no_put |
5311 | 5312 | ||
5312 | xor cl, cl |
5313 | xor cl, cl |
5313 | ror ecx, 8 |
5314 | ror ecx, 8 |
5314 | 5315 | ||
5315 | pushad |
5316 | pushad |
5316 | mov edx, [d_width_calc_area + ebx*4] |
5317 | mov edx, [d_width_calc_area + ebx*4] |
5317 | add edx, [_WinMapAddress] |
5318 | add edx, [_WinMapAddress] |
5318 | movzx edx, byte [eax+edx] |
5319 | movzx edx, byte [eax+edx] |
5319 | cmp dl, byte 1 |
5320 | cmp dl, byte 1 |
5320 | jne @f |
5321 | jne @f |
5321 | 5322 | ||
5322 | call dword [PUTPIXEL]; eax - x, ebx - y |
5323 | call dword [PUTPIXEL]; eax - x, ebx - y |
5323 | ;-------------------------------------- |
5324 | ;-------------------------------------- |
5324 | align 4 |
5325 | align 4 |
5325 | @@: |
5326 | @@: |
5326 | popad |
5327 | popad |
5327 | ;-------------------------------------- |
5328 | ;-------------------------------------- |
5328 | align 4 |
5329 | align 4 |
5329 | .no_put: |
5330 | .no_put: |
5330 | pop ecx eax |
5331 | pop ecx eax |
5331 | 5332 | ||
5332 | sub ebp, 4 |
5333 | sub ebp, 4 |
5333 | dec ecx |
5334 | dec ecx |
5334 | jnz .start_x |
5335 | jnz .start_x |
5335 | 5336 | ||
5336 | pop edx ecx |
5337 | pop edx ecx |
5337 | dec ebx |
5338 | dec ebx |
5338 | dec edx |
5339 | dec edx |
5339 | jnz .start_y |
5340 | jnz .start_y |
5340 | 5341 | ||
5341 | popad |
5342 | popad |
5342 | ret |
5343 | ret |
5343 | ;----------------------------------------------------------------------------- |
5344 | ;----------------------------------------------------------------------------- |
5344 | align 4 |
5345 | align 4 |
5345 | syscall_drawline: ; DrawLine |
5346 | syscall_drawline: ; DrawLine |
5346 | 5347 | ||
5347 | mov edi, [TASK_BASE] |
5348 | mov edi, [TASK_BASE] |
5348 | movzx eax, word[edi-twdw+WDATA.box.left] |
5349 | movzx eax, word[edi-twdw+WDATA.box.left] |
5349 | mov ebp, eax |
5350 | mov ebp, eax |
5350 | mov esi, [current_slot] |
5351 | mov esi, [current_slot] |
5351 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5352 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5352 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5353 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5353 | add ebp, ebx |
5354 | add ebp, ebx |
5354 | shl eax, 16 |
5355 | shl eax, 16 |
5355 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5356 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5356 | add eax, ebp |
5357 | add eax, ebp |
5357 | mov ebp, ebx |
5358 | mov ebp, ebx |
5358 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5359 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5359 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5360 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5360 | add ebp, ecx |
5361 | add ebp, ecx |
5361 | shl ebx, 16 |
5362 | shl ebx, 16 |
5362 | xor edi, edi |
5363 | xor edi, edi |
5363 | add ebx, ebp |
5364 | add ebx, ebp |
5364 | mov ecx, edx |
5365 | mov ecx, edx |
5365 | ; jmp [draw_line] |
5366 | ; jmp [draw_line] |
5366 | jmp __sys_draw_line |
5367 | jmp __sys_draw_line |
5367 | 5368 | ||
5368 | 5369 | ||
5369 | align 4 |
5370 | align 4 |
5370 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5371 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5371 | 5372 | ||
5372 | call r_f_port_area |
5373 | call r_f_port_area |
5373 | mov [esp+32], eax |
5374 | mov [esp+32], eax |
5374 | ret |
5375 | ret |
5375 | 5376 | ||
5376 | align 4 |
5377 | align 4 |
5377 | syscall_threads: ; CreateThreads |
5378 | syscall_threads: ; CreateThreads |
5378 | ; eax=1 create thread |
5379 | ; eax=1 create thread |
5379 | ; |
5380 | ; |
5380 | ; ebx=thread start |
5381 | ; ebx=thread start |
5381 | ; ecx=thread stack value |
5382 | ; ecx=thread stack value |
5382 | ; |
5383 | ; |
5383 | ; on return : eax = pid |
5384 | ; on return : eax = pid |
5384 | 5385 | ||
5385 | call new_sys_threads |
5386 | call new_sys_threads |
5386 | 5387 | ||
5387 | mov [esp+32], eax |
5388 | mov [esp+32], eax |
5388 | ret |
5389 | ret |
5389 | 5390 | ||
5390 | align 4 |
5391 | align 4 |
5391 | 5392 | ||
5392 | paleholder: |
5393 | paleholder: |
5393 | ret |
5394 | ret |
5394 | ;------------------------------------------------------------------------------ |
5395 | ;------------------------------------------------------------------------------ |
5395 | align 4 |
5396 | align 4 |
5396 | calculate_fast_getting_offset_for_WinMapAddress: |
5397 | calculate_fast_getting_offset_for_WinMapAddress: |
5397 | ; calculate data area for fast getting offset to _WinMapAddress |
5398 | ; calculate data area for fast getting offset to _WinMapAddress |
5398 | xor eax, eax |
5399 | xor eax, eax |
5399 | mov ecx, [_display.height] |
5400 | mov ecx, [_display.height] |
5400 | inc ecx |
5401 | inc ecx |
5401 | mov edi, d_width_calc_area |
5402 | mov edi, d_width_calc_area |
5402 | cld |
5403 | cld |
5403 | @@: |
5404 | @@: |
5404 | stosd |
5405 | stosd |
5405 | add eax, [_display.width] |
5406 | add eax, [_display.width] |
5406 | dec ecx |
5407 | dec ecx |
5407 | jnz @r |
5408 | jnz @r |
5408 | ret |
5409 | ret |
5409 | ;------------------------------------------------------------------------------ |
5410 | ;------------------------------------------------------------------------------ |
5410 | align 4 |
5411 | align 4 |
5411 | calculate_fast_getting_offset_for_LFB: |
5412 | calculate_fast_getting_offset_for_LFB: |
5412 | ; calculate data area for fast getting offset to LFB |
5413 | ; calculate data area for fast getting offset to LFB |
5413 | xor eax, eax |
5414 | xor eax, eax |
5414 | mov ecx, [_display.height] |
5415 | mov ecx, [_display.height] |
5415 | inc ecx |
5416 | inc ecx |
5416 | mov edi, BPSLine_calc_area |
5417 | mov edi, BPSLine_calc_area |
5417 | cld |
5418 | cld |
5418 | @@: |
5419 | @@: |
5419 | stosd |
5420 | stosd |
5420 | add eax, [_display.pitch] |
5421 | add eax, [_display.pitch] |
5421 | dec ecx |
5422 | dec ecx |
5422 | jnz @r |
5423 | jnz @r |
5423 | ret |
5424 | ret |
5424 | ;------------------------------------------------------------------------------ |
5425 | ;------------------------------------------------------------------------------ |
5425 | align 4 |
5426 | align 4 |
5426 | set_screen: |
5427 | set_screen: |
5427 | ; in: |
5428 | ; in: |
5428 | ; eax - new Screen_Max_X |
5429 | ; eax - new Screen_Max_X |
5429 | ; ecx - new BytesPerScanLine |
5430 | ; ecx - new BytesPerScanLine |
5430 | ; edx - new Screen_Max_Y |
5431 | ; edx - new Screen_Max_Y |
5431 | cmp eax, [Screen_Max_X] |
5432 | cmp eax, [Screen_Max_X] |
5432 | jne .set |
5433 | jne .set |
5433 | 5434 | ||
5434 | cmp edx, [Screen_Max_Y] |
5435 | cmp edx, [Screen_Max_Y] |
5435 | jne .set |
5436 | jne .set |
5436 | ret |
5437 | ret |
5437 | .set: |
5438 | .set: |
5438 | pushfd |
5439 | pushfd |
5439 | cli |
5440 | cli |
5440 | 5441 | ||
5441 | mov [Screen_Max_X], eax |
5442 | mov [Screen_Max_X], eax |
5442 | mov [Screen_Max_Y], edx |
5443 | mov [Screen_Max_Y], edx |
5443 | mov [_display.pitch], ecx |
5444 | mov [_display.pitch], ecx |
5444 | 5445 | ||
5445 | mov [screen_workarea.right], eax |
5446 | mov [screen_workarea.right], eax |
5446 | mov [screen_workarea.bottom], edx |
5447 | mov [screen_workarea.bottom], edx |
5447 | 5448 | ||
5448 | push ebx |
5449 | push ebx |
5449 | push esi |
5450 | push esi |
5450 | push edi |
5451 | push edi |
5451 | 5452 | ||
5452 | pushad |
5453 | pushad |
5453 | 5454 | ||
5454 | cmp [do_not_touch_winmap], 1 |
5455 | cmp [do_not_touch_winmap], 1 |
5455 | je @f |
5456 | je @f |
5456 | 5457 | ||
5457 | stdcall kernel_free, [_WinMapAddress] |
5458 | stdcall kernel_free, [_WinMapAddress] |
5458 | 5459 | ||
5459 | mov eax, [_display.width] |
5460 | mov eax, [_display.width] |
5460 | mul [_display.height] |
5461 | mul [_display.height] |
5461 | mov [_WinMapSize], eax |
5462 | mov [_WinMapSize], eax |
5462 | 5463 | ||
5463 | stdcall kernel_alloc, eax |
5464 | stdcall kernel_alloc, eax |
5464 | mov [_WinMapAddress], eax |
5465 | mov [_WinMapAddress], eax |
5465 | test eax, eax |
5466 | test eax, eax |
5466 | jz .epic_fail |
5467 | jz .epic_fail |
5467 | ; store for f.18.24 |
5468 | ; store for f.18.24 |
5468 | mov eax, [_display.width] |
5469 | mov eax, [_display.width] |
5469 | mov [display_width_standard], eax |
5470 | mov [display_width_standard], eax |
5470 | 5471 | ||
5471 | mov eax, [_display.height] |
5472 | mov eax, [_display.height] |
5472 | mov [display_height_standard], eax |
5473 | mov [display_height_standard], eax |
5473 | @@: |
5474 | @@: |
5474 | call calculate_fast_getting_offset_for_WinMapAddress |
5475 | call calculate_fast_getting_offset_for_WinMapAddress |
5475 | ; for Qemu or non standart video cards |
5476 | ; for Qemu or non standart video cards |
5476 | ; Unfortunately [BytesPerScanLine] does not always |
5477 | ; Unfortunately [BytesPerScanLine] does not always |
5477 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5478 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5478 | call calculate_fast_getting_offset_for_LFB |
5479 | call calculate_fast_getting_offset_for_LFB |
5479 | popad |
5480 | popad |
5480 | 5481 | ||
5481 | call repos_windows |
5482 | call repos_windows |
5482 | xor eax, eax |
5483 | xor eax, eax |
5483 | xor ebx, ebx |
5484 | xor ebx, ebx |
5484 | mov ecx, [Screen_Max_X] |
5485 | mov ecx, [Screen_Max_X] |
5485 | mov edx, [Screen_Max_Y] |
5486 | mov edx, [Screen_Max_Y] |
5486 | call calculatescreen |
5487 | call calculatescreen |
5487 | pop edi |
5488 | pop edi |
5488 | pop esi |
5489 | pop esi |
5489 | pop ebx |
5490 | pop ebx |
5490 | 5491 | ||
5491 | popfd |
5492 | popfd |
5492 | ret |
5493 | ret |
5493 | 5494 | ||
5494 | .epic_fail: |
5495 | .epic_fail: |
5495 | hlt ; Houston, we've had a problem |
5496 | hlt ; Houston, we've had a problem |
5496 | 5497 | ||
5497 | ; --------------- APM --------------------- |
5498 | ; --------------- APM --------------------- |
5498 | uglobal |
5499 | uglobal |
5499 | apm_entry dp 0 |
5500 | apm_entry dp 0 |
5500 | apm_vf dd 0 |
5501 | apm_vf dd 0 |
5501 | endg |
5502 | endg |
5502 | 5503 | ||
5503 | align 4 |
5504 | align 4 |
5504 | sys_apm: |
5505 | sys_apm: |
5505 | xor eax, eax |
5506 | xor eax, eax |
5506 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5507 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5507 | jne @f |
5508 | jne @f |
5508 | inc eax |
5509 | inc eax |
5509 | or dword [esp + 44], eax ; error |
5510 | or dword [esp + 44], eax ; error |
5510 | add eax, 7 |
5511 | add eax, 7 |
5511 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5512 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5512 | ret |
5513 | ret |
5513 | 5514 | ||
5514 | @@: |
5515 | @@: |
5515 | ; xchg eax, ecx |
5516 | ; xchg eax, ecx |
5516 | ; xchg ebx, ecx |
5517 | ; xchg ebx, ecx |
5517 | 5518 | ||
5518 | cmp dx, 3 |
5519 | cmp dx, 3 |
5519 | ja @f |
5520 | ja @f |
5520 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5521 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5521 | mov eax, [apm_vf] |
5522 | mov eax, [apm_vf] |
5522 | mov [esp + 32], eax |
5523 | mov [esp + 32], eax |
5523 | shr eax, 16 |
5524 | shr eax, 16 |
5524 | mov [esp + 28], eax |
5525 | mov [esp + 28], eax |
5525 | ret |
5526 | ret |
5526 | 5527 | ||
5527 | @@: |
5528 | @@: |
5528 | 5529 | ||
5529 | mov esi, [master_tab+(OS_BASE shr 20)] |
5530 | mov esi, [master_tab+(OS_BASE shr 20)] |
5530 | xchg [master_tab], esi |
5531 | xchg [master_tab], esi |
5531 | push esi |
5532 | push esi |
5532 | mov edi, cr3 |
5533 | mov edi, cr3 |
5533 | mov cr3, edi ;flush TLB |
5534 | mov cr3, edi ;flush TLB |
5534 | 5535 | ||
5535 | call pword [apm_entry] ;call APM BIOS |
5536 | call pword [apm_entry] ;call APM BIOS |
5536 | 5537 | ||
5537 | xchg eax, [esp] |
5538 | xchg eax, [esp] |
5538 | mov [master_tab], eax |
5539 | mov [master_tab], eax |
5539 | mov eax, cr3 |
5540 | mov eax, cr3 |
5540 | mov cr3, eax |
5541 | mov cr3, eax |
5541 | pop eax |
5542 | pop eax |
5542 | 5543 | ||
5543 | mov [esp + 4 ], edi |
5544 | mov [esp + 4 ], edi |
5544 | mov [esp + 8], esi |
5545 | mov [esp + 8], esi |
5545 | mov [esp + 20], ebx |
5546 | mov [esp + 20], ebx |
5546 | mov [esp + 24], edx |
5547 | mov [esp + 24], edx |
5547 | mov [esp + 28], ecx |
5548 | mov [esp + 28], ecx |
5548 | mov [esp + 32], eax |
5549 | mov [esp + 32], eax |
5549 | setc al |
5550 | setc al |
5550 | and [esp + 44], byte 0xfe |
5551 | and [esp + 44], byte 0xfe |
5551 | or [esp + 44], al |
5552 | or [esp + 44], al |
5552 | ret |
5553 | ret |
5553 | ; ----------------------------------------- |
5554 | ; ----------------------------------------- |
5554 | 5555 | ||
5555 | align 4 |
5556 | align 4 |
5556 | 5557 | ||
5557 | undefined_syscall: ; Undefined system call |
5558 | undefined_syscall: ; Undefined system call |
5558 | mov [esp + 32], dword -1 |
5559 | mov [esp + 32], dword -1 |
5559 | ret |
5560 | ret |
5560 | 5561 | ||
5561 | align 4 |
5562 | align 4 |
5562 | system_shutdown: ; shut down the system |
5563 | system_shutdown: ; shut down the system |
5563 | 5564 | ||
5564 | cmp byte [BOOT_VAR+0x9030], 1 |
5565 | cmp byte [BOOT_VAR+0x9030], 1 |
5565 | jne @F |
5566 | jne @F |
5566 | ret |
5567 | ret |
5567 | @@: |
5568 | @@: |
5568 | call stop_all_services |
5569 | call stop_all_services |
5569 | movi eax, 3 |
5570 | movi eax, 3 |
5570 | call sys_cd_audio |
5571 | call sys_cd_audio |
5571 | 5572 | ||
5572 | yes_shutdown_param: |
5573 | yes_shutdown_param: |
5573 | cli |
5574 | cli |
5574 | 5575 | ||
5575 | if ~ defined extended_primary_loader |
5576 | if ~ defined extended_primary_loader |
5576 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5577 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5577 | movi esi, 12 |
5578 | movi esi, 12 |
5578 | xor ebx, ebx |
5579 | xor ebx, ebx |
5579 | or ecx, -1 |
5580 | or ecx, -1 |
5580 | mov edx, OS_BASE+0x70000 |
5581 | mov edx, OS_BASE+0x70000 |
5581 | call fileread |
5582 | call fileread |
5582 | 5583 | ||
5583 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5584 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5584 | mov edi, OS_BASE+0x40000 |
5585 | mov edi, OS_BASE+0x40000 |
5585 | mov ecx, 1000 |
5586 | mov ecx, 1000 |
5586 | rep movsb |
5587 | rep movsb |
5587 | end if |
5588 | end if |
5588 | 5589 | ||
5589 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5590 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5590 | mov edi, OS_BASE |
5591 | mov edi, OS_BASE |
5591 | mov ecx, 0x10000/4 |
5592 | mov ecx, 0x10000/4 |
5592 | cld |
5593 | cld |
5593 | rep movsd |
5594 | rep movsd |
5594 | 5595 | ||
5595 | call restorefatchain |
5596 | call restorefatchain |
5596 | 5597 | ||
5597 | call IRQ_mask_all |
5598 | call IRQ_mask_all |
5598 | 5599 | ||
5599 | if 0 |
5600 | if 0 |
5600 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5601 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5601 | mov word [OS_BASE+0x467+2], 0x1000 |
5602 | mov word [OS_BASE+0x467+2], 0x1000 |
5602 | 5603 | ||
5603 | mov al, 0x0F |
5604 | mov al, 0x0F |
5604 | out 0x70, al |
5605 | out 0x70, al |
5605 | mov al, 0x05 |
5606 | mov al, 0x05 |
5606 | out 0x71, al |
5607 | out 0x71, al |
5607 | 5608 | ||
5608 | mov al, 0xFE |
5609 | mov al, 0xFE |
5609 | out 0x64, al |
5610 | out 0x64, al |
5610 | 5611 | ||
5611 | hlt |
5612 | hlt |
5612 | jmp $-1 |
5613 | jmp $-1 |
5613 | 5614 | ||
5614 | else |
5615 | else |
5615 | cmp byte [OS_BASE + 0x9030], 2 |
5616 | cmp byte [OS_BASE + 0x9030], 2 |
5616 | jnz no_acpi_power_off |
5617 | jnz no_acpi_power_off |
5617 | 5618 | ||
5618 | ; scan for RSDP |
5619 | ; scan for RSDP |
5619 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5620 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5620 | movzx eax, word [OS_BASE + 0x40E] |
5621 | movzx eax, word [OS_BASE + 0x40E] |
5621 | shl eax, 4 |
5622 | shl eax, 4 |
5622 | jz @f |
5623 | jz @f |
5623 | mov ecx, 1024/16 |
5624 | mov ecx, 1024/16 |
5624 | call scan_rsdp |
5625 | call scan_rsdp |
5625 | jnc .rsdp_found |
5626 | jnc .rsdp_found |
5626 | @@: |
5627 | @@: |
5627 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5628 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5628 | mov eax, 0xE0000 |
5629 | mov eax, 0xE0000 |
5629 | mov ecx, 0x2000 |
5630 | mov ecx, 0x2000 |
5630 | call scan_rsdp |
5631 | call scan_rsdp |
5631 | jc no_acpi_power_off |
5632 | jc no_acpi_power_off |
5632 | .rsdp_found: |
5633 | .rsdp_found: |
5633 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5634 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5634 | mov ebp, [ipc_tmp] |
5635 | mov ebp, [ipc_tmp] |
5635 | stdcall map_page, ebp, esi, PG_MAP |
5636 | stdcall map_page, ebp, esi, PG_MAP |
5636 | lea eax, [esi+1000h] |
5637 | lea eax, [esi+1000h] |
5637 | lea edx, [ebp+1000h] |
5638 | lea edx, [ebp+1000h] |
5638 | stdcall map_page, edx, eax, PG_MAP |
5639 | stdcall map_page, edx, eax, PG_MAP |
5639 | and esi, 0xFFF |
5640 | and esi, 0xFFF |
5640 | add esi, ebp |
5641 | add esi, ebp |
5641 | cmp dword [esi], 'RSDT' |
5642 | cmp dword [esi], 'RSDT' |
5642 | jnz no_acpi_power_off |
5643 | jnz no_acpi_power_off |
5643 | mov ecx, [esi+4] |
5644 | mov ecx, [esi+4] |
5644 | sub ecx, 24h |
5645 | sub ecx, 24h |
5645 | jbe no_acpi_power_off |
5646 | jbe no_acpi_power_off |
5646 | shr ecx, 2 |
5647 | shr ecx, 2 |
5647 | add esi, 24h |
5648 | add esi, 24h |
5648 | .scan_fadt: |
5649 | .scan_fadt: |
5649 | lodsd |
5650 | lodsd |
5650 | mov ebx, eax |
5651 | mov ebx, eax |
5651 | lea eax, [ebp+2000h] |
5652 | lea eax, [ebp+2000h] |
5652 | stdcall map_page, eax, ebx, PG_MAP |
5653 | stdcall map_page, eax, ebx, PG_MAP |
5653 | lea eax, [ebp+3000h] |
5654 | lea eax, [ebp+3000h] |
5654 | add ebx, 0x1000 |
5655 | add ebx, 0x1000 |
5655 | stdcall map_page, eax, ebx, PG_MAP |
5656 | stdcall map_page, eax, ebx, PG_MAP |
5656 | and ebx, 0xFFF |
5657 | and ebx, 0xFFF |
5657 | lea ebx, [ebx+ebp+2000h] |
5658 | lea ebx, [ebx+ebp+2000h] |
5658 | cmp dword [ebx], 'FACP' |
5659 | cmp dword [ebx], 'FACP' |
5659 | jz .fadt_found |
5660 | jz .fadt_found |
5660 | loop .scan_fadt |
5661 | loop .scan_fadt |
5661 | jmp no_acpi_power_off |
5662 | jmp no_acpi_power_off |
5662 | .fadt_found: |
5663 | .fadt_found: |
5663 | ; ebx is linear address of FADT |
5664 | ; ebx is linear address of FADT |
5664 | mov edi, [ebx+40] ; physical address of the DSDT |
5665 | mov edi, [ebx+40] ; physical address of the DSDT |
5665 | lea eax, [ebp+4000h] |
5666 | lea eax, [ebp+4000h] |
5666 | stdcall map_page, eax, edi, PG_MAP |
5667 | stdcall map_page, eax, edi, PG_MAP |
5667 | lea eax, [ebp+5000h] |
5668 | lea eax, [ebp+5000h] |
5668 | lea esi, [edi+0x1000] |
5669 | lea esi, [edi+0x1000] |
5669 | stdcall map_page, eax, esi, PG_MAP |
5670 | stdcall map_page, eax, esi, PG_MAP |
5670 | and esi, 0xFFF |
5671 | and esi, 0xFFF |
5671 | sub edi, esi |
5672 | sub edi, esi |
5672 | cmp dword [esi+ebp+4000h], 'DSDT' |
5673 | cmp dword [esi+ebp+4000h], 'DSDT' |
5673 | jnz no_acpi_power_off |
5674 | jnz no_acpi_power_off |
5674 | mov eax, [esi+ebp+4004h] ; DSDT length |
5675 | mov eax, [esi+ebp+4004h] ; DSDT length |
5675 | sub eax, 36+4 |
5676 | sub eax, 36+4 |
5676 | jbe no_acpi_power_off |
5677 | jbe no_acpi_power_off |
5677 | add esi, 36 |
5678 | add esi, 36 |
5678 | .scan_dsdt: |
5679 | .scan_dsdt: |
5679 | cmp dword [esi+ebp+4000h], '_S5_' |
5680 | cmp dword [esi+ebp+4000h], '_S5_' |
5680 | jnz .scan_dsdt_cont |
5681 | jnz .scan_dsdt_cont |
5681 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5682 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5682 | jnz .scan_dsdt_cont |
5683 | jnz .scan_dsdt_cont |
5683 | mov dl, [esi+ebp+4000h+6] |
5684 | mov dl, [esi+ebp+4000h+6] |
5684 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5685 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5685 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5686 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5686 | ja .scan_dsdt_cont |
5687 | ja .scan_dsdt_cont |
5687 | cmp dl, 1 |
5688 | cmp dl, 1 |
5688 | jb .scan_dsdt_cont |
5689 | jb .scan_dsdt_cont |
5689 | lea esi, [esi+ebp+4000h+7] |
5690 | lea esi, [esi+ebp+4000h+7] |
5690 | xor ecx, ecx |
5691 | xor ecx, ecx |
5691 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5692 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5692 | jz @f |
5693 | jz @f |
5693 | cmp byte [esi], 0xA |
5694 | cmp byte [esi], 0xA |
5694 | jnz no_acpi_power_off |
5695 | jnz no_acpi_power_off |
5695 | inc esi |
5696 | inc esi |
5696 | mov cl, [esi] |
5697 | mov cl, [esi] |
5697 | @@: |
5698 | @@: |
5698 | inc esi |
5699 | inc esi |
5699 | cmp dl, 2 |
5700 | cmp dl, 2 |
5700 | jb @f |
5701 | jb @f |
5701 | cmp byte [esi], 0 |
5702 | cmp byte [esi], 0 |
5702 | jz @f |
5703 | jz @f |
5703 | cmp byte [esi], 0xA |
5704 | cmp byte [esi], 0xA |
5704 | jnz no_acpi_power_off |
5705 | jnz no_acpi_power_off |
5705 | inc esi |
5706 | inc esi |
5706 | mov ch, [esi] |
5707 | mov ch, [esi] |
5707 | @@: |
5708 | @@: |
5708 | jmp do_acpi_power_off |
5709 | jmp do_acpi_power_off |
5709 | .scan_dsdt_cont: |
5710 | .scan_dsdt_cont: |
5710 | inc esi |
5711 | inc esi |
5711 | cmp esi, 0x1000 |
5712 | cmp esi, 0x1000 |
5712 | jb @f |
5713 | jb @f |
5713 | sub esi, 0x1000 |
5714 | sub esi, 0x1000 |
5714 | add edi, 0x1000 |
5715 | add edi, 0x1000 |
5715 | push eax |
5716 | push eax |
5716 | lea eax, [ebp+4000h] |
5717 | lea eax, [ebp+4000h] |
5717 | stdcall map_page, eax, edi, PG_MAP |
5718 | stdcall map_page, eax, edi, PG_MAP |
5718 | push PG_MAP |
5719 | push PG_MAP |
5719 | lea eax, [edi+1000h] |
5720 | lea eax, [edi+1000h] |
5720 | push eax |
5721 | push eax |
5721 | lea eax, [ebp+5000h] |
5722 | lea eax, [ebp+5000h] |
5722 | push eax |
5723 | push eax |
5723 | stdcall map_page |
5724 | stdcall map_page |
5724 | pop eax |
5725 | pop eax |
5725 | @@: |
5726 | @@: |
5726 | dec eax |
5727 | dec eax |
5727 | jnz .scan_dsdt |
5728 | jnz .scan_dsdt |
5728 | jmp no_acpi_power_off |
5729 | jmp no_acpi_power_off |
5729 | do_acpi_power_off: |
5730 | do_acpi_power_off: |
5730 | mov edx, [ebx+48] |
5731 | mov edx, [ebx+48] |
5731 | test edx, edx |
5732 | test edx, edx |
5732 | jz .nosmi |
5733 | jz .nosmi |
5733 | mov al, [ebx+52] |
5734 | mov al, [ebx+52] |
5734 | out dx, al |
5735 | out dx, al |
5735 | mov edx, [ebx+64] |
5736 | mov edx, [ebx+64] |
5736 | @@: |
5737 | @@: |
5737 | in ax, dx |
5738 | in ax, dx |
5738 | test al, 1 |
5739 | test al, 1 |
5739 | jz @b |
5740 | jz @b |
5740 | .nosmi: |
5741 | .nosmi: |
5741 | and cx, 0x0707 |
5742 | and cx, 0x0707 |
5742 | shl cx, 2 |
5743 | shl cx, 2 |
5743 | or cx, 0x2020 |
5744 | or cx, 0x2020 |
5744 | mov edx, [ebx+64] |
5745 | mov edx, [ebx+64] |
5745 | in ax, dx |
5746 | in ax, dx |
5746 | and ax, 203h |
5747 | and ax, 203h |
5747 | or ah, cl |
5748 | or ah, cl |
5748 | out dx, ax |
5749 | out dx, ax |
5749 | mov edx, [ebx+68] |
5750 | mov edx, [ebx+68] |
5750 | test edx, edx |
5751 | test edx, edx |
5751 | jz @f |
5752 | jz @f |
5752 | in ax, dx |
5753 | in ax, dx |
5753 | and ax, 203h |
5754 | and ax, 203h |
5754 | or ah, ch |
5755 | or ah, ch |
5755 | out dx, ax |
5756 | out dx, ax |
5756 | @@: |
5757 | @@: |
5757 | jmp $ |
5758 | jmp $ |
5758 | 5759 | ||
5759 | 5760 | ||
5760 | no_acpi_power_off: |
5761 | no_acpi_power_off: |
5761 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5762 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5762 | mov word [OS_BASE+0x467+2], 0x1000 |
5763 | mov word [OS_BASE+0x467+2], 0x1000 |
5763 | 5764 | ||
5764 | mov al, 0x0F |
5765 | mov al, 0x0F |
5765 | out 0x70, al |
5766 | out 0x70, al |
5766 | mov al, 0x05 |
5767 | mov al, 0x05 |
5767 | out 0x71, al |
5768 | out 0x71, al |
5768 | 5769 | ||
5769 | mov al, 0xFE |
5770 | mov al, 0xFE |
5770 | out 0x64, al |
5771 | out 0x64, al |
5771 | 5772 | ||
5772 | hlt |
5773 | hlt |
5773 | jmp $-1 |
5774 | jmp $-1 |
5774 | 5775 | ||
5775 | scan_rsdp: |
5776 | scan_rsdp: |
5776 | add eax, OS_BASE |
5777 | add eax, OS_BASE |
5777 | .s: |
5778 | .s: |
5778 | cmp dword [eax], 'RSD ' |
5779 | cmp dword [eax], 'RSD ' |
5779 | jnz .n |
5780 | jnz .n |
5780 | cmp dword [eax+4], 'PTR ' |
5781 | cmp dword [eax+4], 'PTR ' |
5781 | jnz .n |
5782 | jnz .n |
5782 | xor edx, edx |
5783 | xor edx, edx |
5783 | xor esi, esi |
5784 | xor esi, esi |
5784 | @@: |
5785 | @@: |
5785 | add dl, [eax+esi] |
5786 | add dl, [eax+esi] |
5786 | inc esi |
5787 | inc esi |
5787 | cmp esi, 20 |
5788 | cmp esi, 20 |
5788 | jnz @b |
5789 | jnz @b |
5789 | test dl, dl |
5790 | test dl, dl |
5790 | jz .ok |
5791 | jz .ok |
5791 | .n: |
5792 | .n: |
5792 | add eax, 10h |
5793 | add eax, 10h |
5793 | loop .s |
5794 | loop .s |
5794 | stc |
5795 | stc |
5795 | .ok: |
5796 | .ok: |
5796 | ret |
5797 | ret |
5797 | end if |
5798 | end if |
5798 | 5799 | ||
5799 | include "data32.inc" |
5800 | include "data32.inc" |
5800 | 5801 | ||
5801 | __REV__ = __REV |
5802 | __REV__ = __REV |
5802 | 5803 | ||
5803 | uglobals_size = $ - endofcode |
5804 | uglobals_size = $ - endofcode |
5804 | if ~ lang eq sp |
5805 | if ~ lang eq sp |
5805 | diff16 "end of kernel code",0,$ |
5806 | diff16 "end of kernel code",0,$ |
5806 | end if=> |
5807 | end if=> |