Rev 2642 | Rev 2648 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2642 | Rev 2643 | ||
---|---|---|---|
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 | include 'macros.inc' |
69 | include 'macros.inc' |
70 | include 'struct.inc' |
70 | include 'struct.inc' |
71 | 71 | ||
72 | $Revision: 2642 $ |
72 | $Revision: 2643 $ |
73 | 73 | ||
74 | 74 | ||
75 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
75 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
76 | 76 | ||
77 | ; Enabling the next line will enable serial output console |
77 | ; Enabling the next line will enable serial output console |
78 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
78 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
79 | 79 | ||
80 | include "proc32.inc" |
80 | include "proc32.inc" |
81 | include "kglobals.inc" |
81 | include "kglobals.inc" |
82 | include "lang.inc" |
82 | include "lang.inc" |
83 | 83 | ||
84 | include "const.inc" |
84 | include "const.inc" |
85 | max_processes equ 255 |
85 | max_processes equ 255 |
86 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
86 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
87 | 87 | ||
88 | 88 | ||
89 | os_stack equ (os_data_l-gdts) ; GDTs |
89 | os_stack equ (os_data_l-gdts) ; GDTs |
90 | os_code equ (os_code_l-gdts) |
90 | os_code equ (os_code_l-gdts) |
91 | graph_data equ (3+graph_data_l-gdts) |
91 | graph_data equ (3+graph_data_l-gdts) |
92 | tss0 equ (tss0_l-gdts) |
92 | tss0 equ (tss0_l-gdts) |
93 | app_code equ (3+app_code_l-gdts) |
93 | app_code equ (3+app_code_l-gdts) |
94 | app_data equ (3+app_data_l-gdts) |
94 | app_data equ (3+app_data_l-gdts) |
95 | app_tls equ (3+tls_data_l-gdts) |
95 | app_tls equ (3+tls_data_l-gdts) |
96 | pci_code_sel equ (pci_code_32-gdts) |
96 | pci_code_sel equ (pci_code_32-gdts) |
97 | pci_data_sel equ (pci_data_32-gdts) |
97 | pci_data_sel equ (pci_data_32-gdts) |
98 | 98 | ||
99 | 99 | ||
100 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
100 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
101 | ;; |
101 | ;; |
102 | ;; Included files: |
102 | ;; Included files: |
103 | ;; |
103 | ;; |
104 | ;; Kernel16.inc |
104 | ;; Kernel16.inc |
105 | ;; - Booteng.inc English text for bootup |
105 | ;; - Booteng.inc English text for bootup |
106 | ;; - Bootcode.inc Hardware setup |
106 | ;; - Bootcode.inc Hardware setup |
107 | ;; - Pci16.inc PCI functions |
107 | ;; - Pci16.inc PCI functions |
108 | ;; |
108 | ;; |
109 | ;; Kernel32.inc |
109 | ;; Kernel32.inc |
110 | ;; - Sys32.inc Process management |
110 | ;; - Sys32.inc Process management |
111 | ;; - Shutdown.inc Shutdown and restart |
111 | ;; - Shutdown.inc Shutdown and restart |
112 | ;; - Fat32.inc Read / write hd |
112 | ;; - Fat32.inc Read / write hd |
113 | ;; - Vesa12.inc Vesa 1.2 driver |
113 | ;; - Vesa12.inc Vesa 1.2 driver |
114 | ;; - Vesa20.inc Vesa 2.0 driver |
114 | ;; - Vesa20.inc Vesa 2.0 driver |
115 | ;; - Vga.inc VGA driver |
115 | ;; - Vga.inc VGA driver |
116 | ;; - Stack.inc Network interface |
116 | ;; - Stack.inc Network interface |
117 | ;; - Mouse.inc Mouse pointer |
117 | ;; - Mouse.inc Mouse pointer |
118 | ;; - Scincode.inc Window skinning |
118 | ;; - Scincode.inc Window skinning |
119 | ;; - Pci32.inc PCI functions |
119 | ;; - Pci32.inc PCI functions |
120 | ;; |
120 | ;; |
121 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
121 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
122 | 122 | ||
123 | 123 | ||
124 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
124 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
125 | ;; ;; |
125 | ;; ;; |
126 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
126 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
127 | ;; ;; |
127 | ;; ;; |
128 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
128 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
129 | 129 | ||
130 | use16 |
130 | use16 |
131 | org 0x0 |
131 | org 0x0 |
132 | jmp start_of_code |
132 | jmp start_of_code |
133 | 133 | ||
134 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
134 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
135 | 135 | ||
136 | include "boot/bootstr.inc" ; language-independent boot messages |
136 | include "boot/bootstr.inc" ; language-independent boot messages |
137 | include "boot/preboot.inc" |
137 | include "boot/preboot.inc" |
138 | 138 | ||
139 | if lang eq en |
139 | if lang eq en |
140 | include "boot/booteng.inc" ; english system boot messages |
140 | include "boot/booteng.inc" ; english system boot messages |
141 | else if lang eq ru |
141 | else if lang eq ru |
142 | include "boot/bootru.inc" ; russian system boot messages |
142 | include "boot/bootru.inc" ; russian system boot messages |
143 | include "boot/ru.inc" ; Russian font |
143 | include "boot/ru.inc" ; Russian font |
144 | else if lang eq et |
144 | else if lang eq et |
145 | include "boot/bootet.inc" ; estonian system boot messages |
145 | include "boot/bootet.inc" ; estonian system boot messages |
146 | include "boot/et.inc" ; Estonian font |
146 | include "boot/et.inc" ; Estonian font |
147 | else |
147 | else |
148 | include "boot/bootge.inc" ; german system boot messages |
148 | include "boot/bootge.inc" ; german system boot messages |
149 | end if |
149 | end if |
150 | 150 | ||
151 | include "boot/bootcode.inc" ; 16 bit system boot code |
151 | include "boot/bootcode.inc" ; 16 bit system boot code |
152 | include "bus/pci/pci16.inc" |
152 | include "bus/pci/pci16.inc" |
153 | include "detect/biosdisk.inc" |
153 | include "detect/biosdisk.inc" |
154 | 154 | ||
155 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
155 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
156 | ;; ;; |
156 | ;; ;; |
157 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
157 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
158 | ;; ;; |
158 | ;; ;; |
159 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
159 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
160 | 160 | ||
161 | 161 | ||
162 | ; CR0 Flags - Protected mode and Paging |
162 | ; CR0 Flags - Protected mode and Paging |
163 | 163 | ||
164 | mov ecx, CR0_PE |
164 | mov ecx, CR0_PE |
165 | 165 | ||
166 | ; Enabling 32 bit protected mode |
166 | ; Enabling 32 bit protected mode |
167 | 167 | ||
168 | sidt [cs:old_ints_h] |
168 | sidt [cs:old_ints_h] |
169 | 169 | ||
170 | cli ; disable all irqs |
170 | cli ; disable all irqs |
171 | cld |
171 | cld |
172 | mov al, 255 ; mask all irqs |
172 | mov al, 255 ; mask all irqs |
173 | out 0xa1, al |
173 | out 0xa1, al |
174 | out 0x21, al |
174 | out 0x21, al |
175 | l.5: |
175 | l.5: |
176 | in al, 0x64 ; Enable A20 |
176 | in al, 0x64 ; Enable A20 |
177 | test al, 2 |
177 | test al, 2 |
178 | jnz l.5 |
178 | jnz l.5 |
179 | mov al, 0xD1 |
179 | mov al, 0xD1 |
180 | out 0x64, al |
180 | out 0x64, al |
181 | l.6: |
181 | l.6: |
182 | in al, 0x64 |
182 | in al, 0x64 |
183 | test al, 2 |
183 | test al, 2 |
184 | jnz l.6 |
184 | jnz l.6 |
185 | mov al, 0xDF |
185 | mov al, 0xDF |
186 | out 0x60, al |
186 | out 0x60, al |
187 | l.7: |
187 | l.7: |
188 | in al, 0x64 |
188 | in al, 0x64 |
189 | test al, 2 |
189 | test al, 2 |
190 | jnz l.7 |
190 | jnz l.7 |
191 | mov al, 0xFF |
191 | mov al, 0xFF |
192 | out 0x64, al |
192 | out 0x64, al |
193 | 193 | ||
194 | lgdt [cs:tmp_gdt] ; Load GDT |
194 | lgdt [cs:tmp_gdt] ; Load GDT |
195 | mov eax, cr0 ; protected mode |
195 | mov eax, cr0 ; protected mode |
196 | or eax, ecx |
196 | or eax, ecx |
197 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
197 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
198 | mov cr0, eax |
198 | mov cr0, eax |
199 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
199 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
200 | 200 | ||
201 | align 8 |
201 | align 8 |
202 | tmp_gdt: |
202 | tmp_gdt: |
203 | 203 | ||
204 | dw 23 |
204 | dw 23 |
205 | dd tmp_gdt+0x10000 |
205 | dd tmp_gdt+0x10000 |
206 | dw 0 |
206 | dw 0 |
207 | 207 | ||
208 | dw 0xffff |
208 | dw 0xffff |
209 | dw 0x0000 |
209 | dw 0x0000 |
210 | db 0x00 |
210 | db 0x00 |
211 | dw 11011111b *256 +10011010b |
211 | dw 11011111b *256 +10011010b |
212 | db 0x00 |
212 | db 0x00 |
213 | 213 | ||
214 | dw 0xffff |
214 | dw 0xffff |
215 | dw 0x0000 |
215 | dw 0x0000 |
216 | db 0x00 |
216 | db 0x00 |
217 | dw 11011111b *256 +10010010b |
217 | dw 11011111b *256 +10010010b |
218 | db 0x00 |
218 | db 0x00 |
219 | 219 | ||
220 | include "data16.inc" |
220 | include "data16.inc" |
221 | 221 | ||
222 | use32 |
222 | use32 |
223 | org $+0x10000 |
223 | org $+0x10000 |
224 | 224 | ||
225 | align 4 |
225 | align 4 |
226 | B32: |
226 | B32: |
227 | mov ax, os_stack ; Selector for os |
227 | mov ax, os_stack ; Selector for os |
228 | mov ds, ax |
228 | mov ds, ax |
229 | mov es, ax |
229 | mov es, ax |
230 | mov fs, ax |
230 | mov fs, ax |
231 | mov gs, ax |
231 | mov gs, ax |
232 | mov ss, ax |
232 | mov ss, ax |
233 | mov esp, 0x006CC00 ; Set stack |
233 | mov esp, 0x006CC00 ; Set stack |
234 | 234 | ||
235 | ; CLEAR 0x280000 - HEAP_BASE |
235 | ; CLEAR 0x280000 - HEAP_BASE |
236 | 236 | ||
237 | xor eax, eax |
237 | xor eax, eax |
238 | mov edi, CLEAN_ZONE |
238 | mov edi, CLEAN_ZONE |
239 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
239 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
240 | cld |
240 | cld |
241 | rep stosd |
241 | rep stosd |
242 | 242 | ||
243 | ; CLEAR KERNEL UNDEFINED GLOBALS |
243 | ; CLEAR KERNEL UNDEFINED GLOBALS |
244 | mov edi, endofcode-OS_BASE |
244 | mov edi, endofcode-OS_BASE |
245 | mov ecx, 0x90000 |
245 | mov ecx, 0x90000 |
246 | sub ecx, edi |
246 | sub ecx, edi |
247 | shr ecx, 2 |
247 | shr ecx, 2 |
248 | rep stosd |
248 | rep stosd |
249 | 249 | ||
250 | ; SAVE & CLEAR 0-0xffff |
250 | ; SAVE & CLEAR 0-0xffff |
251 | 251 | ||
252 | xor esi, esi |
252 | xor esi, esi |
253 | mov edi, (BOOT_VAR-OS_BASE) |
253 | mov edi, (BOOT_VAR-OS_BASE) |
254 | mov ecx, 0x10000 / 4 |
254 | mov ecx, 0x10000 / 4 |
255 | rep movsd |
255 | rep movsd |
256 | mov edi, 0x1000 |
256 | mov edi, 0x1000 |
257 | mov ecx, 0xf000 / 4 |
257 | mov ecx, 0xf000 / 4 |
258 | rep stosd |
258 | rep stosd |
259 | 259 | ||
260 | call test_cpu |
260 | call test_cpu |
261 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
261 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
262 | 262 | ||
263 | call check_acpi |
263 | call check_acpi |
264 | call init_BIOS32 |
264 | call init_BIOS32 |
265 | ; MEMORY MODEL |
265 | ; MEMORY MODEL |
266 | call mem_test |
266 | call mem_test |
267 | call init_mem |
267 | call init_mem |
268 | call init_page_map |
268 | call init_page_map |
269 | 269 | ||
270 | ; ENABLE PAGING |
270 | ; ENABLE PAGING |
271 | 271 | ||
272 | mov eax, sys_pgdir-OS_BASE |
272 | mov eax, sys_pgdir-OS_BASE |
273 | mov cr3, eax |
273 | mov cr3, eax |
274 | 274 | ||
275 | mov eax, cr0 |
275 | mov eax, cr0 |
276 | or eax, CR0_PG+CR0_WP |
276 | or eax, CR0_PG+CR0_WP |
277 | mov cr0, eax |
277 | mov cr0, eax |
278 | 278 | ||
279 | lgdt [gdts] |
279 | lgdt [gdts] |
280 | jmp pword os_code:high_code |
280 | jmp pword os_code:high_code |
281 | 281 | ||
282 | align 4 |
282 | align 4 |
283 | bios32_entry dd ? |
283 | bios32_entry dd ? |
284 | tmp_page_tabs dd ? |
284 | tmp_page_tabs dd ? |
285 | 285 | ||
286 | use16 |
286 | use16 |
287 | org $-0x10000 |
287 | org $-0x10000 |
288 | include "boot/shutdown.inc" ; shutdown or restart |
288 | include "boot/shutdown.inc" ; shutdown or restart |
289 | org $+0x10000 |
289 | org $+0x10000 |
290 | use32 |
290 | use32 |
291 | 291 | ||
292 | __DEBUG__ fix 1 |
292 | __DEBUG__ fix 1 |
293 | __DEBUG_LEVEL__ fix 1 |
293 | __DEBUG_LEVEL__ fix 1 |
294 | include 'init.inc' |
294 | include 'init.inc' |
295 | 295 | ||
296 | org OS_BASE+$ |
296 | org OS_BASE+$ |
297 | 297 | ||
298 | include 'fdo.inc' |
298 | include 'fdo.inc' |
299 | 299 | ||
300 | align 4 |
300 | align 4 |
301 | high_code: |
301 | high_code: |
302 | mov ax, os_stack |
302 | mov ax, os_stack |
303 | mov bx, app_data |
303 | mov bx, app_data |
304 | mov cx, app_tls |
304 | mov cx, app_tls |
305 | mov ss, ax |
305 | mov ss, ax |
306 | add esp, OS_BASE |
306 | add esp, OS_BASE |
307 | 307 | ||
308 | mov ds, bx |
308 | mov ds, bx |
309 | mov es, bx |
309 | mov es, bx |
310 | mov fs, cx |
310 | mov fs, cx |
311 | mov gs, bx |
311 | mov gs, bx |
312 | 312 | ||
313 | bt [cpu_caps], CAPS_PGE |
313 | bt [cpu_caps], CAPS_PGE |
314 | jnc @F |
314 | jnc @F |
315 | 315 | ||
316 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
316 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
317 | 317 | ||
318 | mov ebx, cr4 |
318 | mov ebx, cr4 |
319 | or ebx, CR4_PGE |
319 | or ebx, CR4_PGE |
320 | mov cr4, ebx |
320 | mov cr4, ebx |
321 | @@: |
321 | @@: |
322 | xor eax, eax |
322 | xor eax, eax |
323 | mov dword [sys_pgdir], eax |
323 | mov dword [sys_pgdir], eax |
324 | mov dword [sys_pgdir+4], eax |
324 | mov dword [sys_pgdir+4], eax |
325 | 325 | ||
326 | mov eax, cr3 |
326 | mov eax, cr3 |
327 | mov cr3, eax ; flush TLB |
327 | mov cr3, eax ; flush TLB |
328 | 328 | ||
329 | mov ecx, pg_data.mutex |
329 | mov ecx, pg_data.mutex |
330 | call mutex_init |
330 | call mutex_init |
331 | 331 | ||
332 | mov ecx, disk_list_mutex |
332 | mov ecx, disk_list_mutex |
333 | call mutex_init |
333 | call mutex_init |
334 | 334 | ||
335 | mov ecx, keyboard_list_mutex |
335 | mov ecx, keyboard_list_mutex |
336 | call mutex_init |
336 | call mutex_init |
337 | 337 | ||
338 | mov ecx, unpack_mutex |
338 | mov ecx, unpack_mutex |
339 | call mutex_init |
339 | call mutex_init |
340 | 340 | ||
341 | ; SAVE REAL MODE VARIABLES |
341 | ; SAVE REAL MODE VARIABLES |
342 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
342 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
343 | mov [IDEContrRegsBaseAddr], ax |
343 | mov [IDEContrRegsBaseAddr], ax |
344 | ; --------------- APM --------------------- |
344 | ; --------------- APM --------------------- |
345 | 345 | ||
346 | ; init selectors |
346 | ; init selectors |
347 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
347 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
348 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
348 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
349 | ; protected-mode 32-bit code segment |
349 | ; protected-mode 32-bit code segment |
350 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
350 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
351 | ; protected-mode 16-bit code segment |
351 | ; protected-mode 16-bit code segment |
352 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
352 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
353 | ; protected-mode 16-bit data segment |
353 | ; protected-mode 16-bit data segment |
354 | 354 | ||
355 | shl eax, 4 |
355 | shl eax, 4 |
356 | mov [dword apm_code_32 + 2], ax |
356 | mov [dword apm_code_32 + 2], ax |
357 | shr eax, 16 |
357 | shr eax, 16 |
358 | mov [dword apm_code_32 + 4], al |
358 | mov [dword apm_code_32 + 4], al |
359 | 359 | ||
360 | shl ecx, 4 |
360 | shl ecx, 4 |
361 | mov [dword apm_code_16 + 2], cx |
361 | mov [dword apm_code_16 + 2], cx |
362 | shr ecx, 16 |
362 | shr ecx, 16 |
363 | mov [dword apm_code_16 + 4], cl |
363 | mov [dword apm_code_16 + 4], cl |
364 | 364 | ||
365 | shl edx, 4 |
365 | shl edx, 4 |
366 | mov [dword apm_data_16 + 2], dx |
366 | mov [dword apm_data_16 + 2], dx |
367 | shr edx, 16 |
367 | shr edx, 16 |
368 | mov [dword apm_data_16 + 4], dl |
368 | mov [dword apm_data_16 + 4], dl |
369 | 369 | ||
370 | mov dword[apm_entry], ebx |
370 | mov dword[apm_entry], ebx |
371 | mov word [apm_entry + 4], apm_code_32 - gdts |
371 | mov word [apm_entry + 4], apm_code_32 - gdts |
372 | 372 | ||
373 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
373 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
374 | mov [apm_vf], eax |
374 | mov [apm_vf], eax |
375 | ; ----------------------------------------- |
375 | ; ----------------------------------------- |
376 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
376 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
377 | mov [allow_dma_access], al |
377 | mov [allow_dma_access], al |
378 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
378 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
379 | mov [ScreenBPP], al |
379 | mov [ScreenBPP], al |
380 | 380 | ||
381 | mov [_display.bpp], eax |
381 | mov [_display.bpp], eax |
382 | mov [_display.vrefresh], 60 |
382 | mov [_display.vrefresh], 60 |
383 | 383 | ||
384 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
384 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
385 | mov [_display.width], eax |
385 | mov [_display.width], eax |
386 | dec eax |
386 | dec eax |
387 | mov [Screen_Max_X], eax |
387 | mov [Screen_Max_X], eax |
388 | mov [screen_workarea.right], eax |
388 | mov [screen_workarea.right], eax |
389 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
389 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
390 | mov [_display.height], eax |
390 | mov [_display.height], eax |
391 | dec eax |
391 | dec eax |
392 | mov [Screen_Max_Y], eax |
392 | mov [Screen_Max_Y], eax |
393 | mov [screen_workarea.bottom], eax |
393 | mov [screen_workarea.bottom], eax |
394 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE]; screen mode |
394 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE]; screen mode |
395 | mov [SCR_MODE], eax |
395 | mov [SCR_MODE], eax |
396 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
396 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
397 | ; mov [BANK_SWITCH], eax |
397 | ; mov [BANK_SWITCH], eax |
398 | mov [BytesPerScanLine], word 640*4 ; Bytes PerScanLine |
398 | mov [BytesPerScanLine], word 640*4 ; Bytes PerScanLine |
399 | cmp [SCR_MODE], word 0x13 ; 320x200 |
399 | cmp [SCR_MODE], word 0x13 ; 320x200 |
400 | je @f |
400 | je @f |
401 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
401 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
402 | je @f |
402 | je @f |
403 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
403 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
404 | mov [BytesPerScanLine], ax |
404 | mov [BytesPerScanLine], ax |
405 | mov [_display.pitch], eax |
405 | mov [_display.pitch], eax |
406 | @@: |
406 | @@: |
407 | mov eax, [_display.width] |
407 | mov eax, [_display.width] |
408 | mul [_display.height] |
408 | mul [_display.height] |
409 | mov [_WinMapSize], eax |
409 | mov [_WinMapSize], eax |
410 | 410 | ||
411 | call calculate_fast_getting_offset_for_WinMapAddress |
411 | call calculate_fast_getting_offset_for_WinMapAddress |
412 | ; for Qemu or non standart video cards |
412 | ; for Qemu or non standart video cards |
413 | ; Unfortunately [BytesPerScanLine] does not always |
413 | ; Unfortunately [BytesPerScanLine] does not always |
414 | ; equal to [_display.width] * [ScreenBPP] / 8 |
414 | ; equal to [_display.width] * [ScreenBPP] / 8 |
415 | call calculate_fast_getting_offset_for_LFB |
415 | call calculate_fast_getting_offset_for_LFB |
416 | 416 | ||
417 | mov esi, BOOT_VAR+0x9080 |
417 | mov esi, BOOT_VAR+0x9080 |
418 | movzx ecx, byte [esi-1] |
418 | movzx ecx, byte [esi-1] |
419 | mov [NumBiosDisks], ecx |
419 | mov [NumBiosDisks], ecx |
420 | mov edi, BiosDisksData |
420 | mov edi, BiosDisksData |
421 | rep movsd |
421 | rep movsd |
422 | 422 | ||
423 | ; GRAPHICS ADDRESSES |
423 | ; GRAPHICS ADDRESSES |
424 | 424 | ||
425 | mov eax, [BOOT_VAR+BOOT_LFB] |
425 | mov eax, [BOOT_VAR+BOOT_LFB] |
426 | mov [LFBAddress], eax |
426 | mov [LFBAddress], eax |
427 | 427 | ||
428 | cmp [SCR_MODE], word 0100000000000000b |
428 | cmp [SCR_MODE], word 0100000000000000b |
429 | jge setvesa20 |
429 | jge setvesa20 |
430 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
430 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
431 | je v20ga32 |
431 | je v20ga32 |
432 | jmp v20ga24 |
432 | jmp v20ga24 |
433 | 433 | ||
434 | setvesa20: |
434 | setvesa20: |
435 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
435 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
436 | mov [GETPIXEL], dword Vesa20_getpixel24 |
436 | mov [GETPIXEL], dword Vesa20_getpixel24 |
437 | cmp [ScreenBPP], byte 24 |
437 | cmp [ScreenBPP], byte 24 |
438 | jz v20ga24 |
438 | jz v20ga24 |
439 | v20ga32: |
439 | v20ga32: |
440 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
440 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
441 | mov [GETPIXEL], dword Vesa20_getpixel32 |
441 | mov [GETPIXEL], dword Vesa20_getpixel32 |
442 | jmp no_mode_0x12 |
442 | jmp no_mode_0x12 |
443 | v20ga24: |
443 | v20ga24: |
444 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
444 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
445 | jne no_mode_0x12 |
445 | jne no_mode_0x12 |
446 | mov [PUTPIXEL], dword VGA_putpixel |
446 | mov [PUTPIXEL], dword VGA_putpixel |
447 | mov [GETPIXEL], dword Vesa20_getpixel32 |
447 | mov [GETPIXEL], dword Vesa20_getpixel32 |
448 | no_mode_0x12: |
448 | no_mode_0x12: |
449 | 449 | ||
450 | mov [MOUSE_PICTURE], dword mousepointer |
450 | mov [MOUSE_PICTURE], dword mousepointer |
451 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
451 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
452 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
452 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
453 | 453 | ||
454 | ; -------- Fast System Call init ---------- |
454 | ; -------- Fast System Call init ---------- |
455 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
455 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
456 | bt [cpu_caps], CAPS_SEP |
456 | bt [cpu_caps], CAPS_SEP |
457 | jnc .SEnP ; SysEnter not Present |
457 | jnc .SEnP ; SysEnter not Present |
458 | xor edx, edx |
458 | xor edx, edx |
459 | mov ecx, MSR_SYSENTER_CS |
459 | mov ecx, MSR_SYSENTER_CS |
460 | mov eax, os_code |
460 | mov eax, os_code |
461 | wrmsr |
461 | wrmsr |
462 | mov ecx, MSR_SYSENTER_ESP |
462 | mov ecx, MSR_SYSENTER_ESP |
463 | ; mov eax, sysenter_stack ; Check it |
463 | ; mov eax, sysenter_stack ; Check it |
464 | xor eax, eax |
464 | xor eax, eax |
465 | wrmsr |
465 | wrmsr |
466 | mov ecx, MSR_SYSENTER_EIP |
466 | mov ecx, MSR_SYSENTER_EIP |
467 | mov eax, sysenter_entry |
467 | mov eax, sysenter_entry |
468 | wrmsr |
468 | wrmsr |
469 | .SEnP: |
469 | .SEnP: |
470 | ; AMD SYSCALL/SYSRET |
470 | ; AMD SYSCALL/SYSRET |
471 | cmp byte[cpu_vendor], 'A' |
471 | cmp byte[cpu_vendor], 'A' |
472 | jne .noSYSCALL |
472 | jne .noSYSCALL |
473 | mov eax, 0x80000001 |
473 | mov eax, 0x80000001 |
474 | cpuid |
474 | cpuid |
475 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
475 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
476 | jz .noSYSCALL |
476 | jz .noSYSCALL |
477 | mov ecx, MSR_AMD_EFER |
477 | mov ecx, MSR_AMD_EFER |
478 | rdmsr |
478 | rdmsr |
479 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
479 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
480 | wrmsr |
480 | wrmsr |
481 | 481 | ||
482 | ; !!!! It`s dirty hack, fix it !!! |
482 | ; !!!! It`s dirty hack, fix it !!! |
483 | ; Bits of EDX : |
483 | ; Bits of EDX : |
484 | ; Bit 3116 During the SYSRET instruction, this field is copied into the CS register |
484 | ; Bit 3116 During the SYSRET instruction, this field is copied into the CS register |
485 | ; and the contents of this field, plus 8, are copied into the SS register. |
485 | ; and the contents of this field, plus 8, are copied into the SS register. |
486 | ; Bit 150 During the SYSCALL instruction, this field is copied into the CS register |
486 | ; Bit 150 During the SYSCALL instruction, this field is copied into the CS register |
487 | ; and the contents of this field, plus 8, are copied into the SS register. |
487 | ; and the contents of this field, plus 8, are copied into the SS register. |
488 | 488 | ||
489 | ; mov edx, (os_code + 16) * 65536 + os_code |
489 | ; mov edx, (os_code + 16) * 65536 + os_code |
490 | mov edx, 0x1B0008 |
490 | mov edx, 0x1B0008 |
491 | 491 | ||
492 | mov eax, syscall_entry |
492 | mov eax, syscall_entry |
493 | mov ecx, MSR_AMD_STAR |
493 | mov ecx, MSR_AMD_STAR |
494 | wrmsr |
494 | wrmsr |
495 | .noSYSCALL: |
495 | .noSYSCALL: |
496 | ; ----------------------------------------- |
496 | ; ----------------------------------------- |
497 | stdcall alloc_page |
497 | stdcall alloc_page |
498 | stdcall map_page, tss-0xF80, eax, PG_SW |
498 | stdcall map_page, tss-0xF80, eax, PG_SW |
499 | stdcall alloc_page |
499 | stdcall alloc_page |
500 | inc eax |
500 | inc eax |
501 | mov [SLOT_BASE+256+APPDATA.io_map], eax |
501 | mov [SLOT_BASE+256+APPDATA.io_map], eax |
502 | stdcall map_page, tss+0x80, eax, PG_SW |
502 | stdcall map_page, tss+0x80, eax, PG_SW |
503 | stdcall alloc_page |
503 | stdcall alloc_page |
504 | inc eax |
504 | inc eax |
505 | mov dword [SLOT_BASE+256+APPDATA.io_map+4], eax |
505 | mov dword [SLOT_BASE+256+APPDATA.io_map+4], eax |
506 | stdcall map_page, tss+0x1080, eax, PG_SW |
506 | stdcall map_page, tss+0x1080, eax, PG_SW |
507 | 507 | ||
508 | ; LOAD IDT |
508 | ; LOAD IDT |
509 | 509 | ||
510 | call build_interrupt_table ;lidt is executed |
510 | call build_interrupt_table ;lidt is executed |
511 | ;lidt [idtreg] |
511 | ;lidt [idtreg] |
512 | 512 | ||
513 | call init_kernel_heap |
513 | call init_kernel_heap |
514 | stdcall kernel_alloc, RING0_STACK_SIZE+512 |
514 | stdcall kernel_alloc, RING0_STACK_SIZE+512 |
515 | mov [os_stack_seg], eax |
515 | mov [os_stack_seg], eax |
516 | 516 | ||
517 | lea esp, [eax+RING0_STACK_SIZE] |
517 | lea esp, [eax+RING0_STACK_SIZE] |
518 | 518 | ||
519 | mov [tss._ss0], os_stack |
519 | mov [tss._ss0], os_stack |
520 | mov [tss._esp0], esp |
520 | mov [tss._esp0], esp |
521 | mov [tss._esp], esp |
521 | mov [tss._esp], esp |
522 | mov [tss._cs], os_code |
522 | mov [tss._cs], os_code |
523 | mov [tss._ss], os_stack |
523 | mov [tss._ss], os_stack |
524 | mov [tss._ds], app_data |
524 | mov [tss._ds], app_data |
525 | mov [tss._es], app_data |
525 | mov [tss._es], app_data |
526 | mov [tss._fs], app_data |
526 | mov [tss._fs], app_data |
527 | mov [tss._gs], app_data |
527 | mov [tss._gs], app_data |
528 | mov [tss._io], 128 |
528 | mov [tss._io], 128 |
529 | ;Add IO access table - bit array of permitted ports |
529 | ;Add IO access table - bit array of permitted ports |
530 | mov edi, tss._io_map_0 |
530 | mov edi, tss._io_map_0 |
531 | xor eax, eax |
531 | xor eax, eax |
532 | not eax |
532 | not eax |
533 | mov ecx, 8192/4 |
533 | mov ecx, 8192/4 |
534 | rep stosd ; access to 4096*8=65536 ports |
534 | rep stosd ; access to 4096*8=65536 ports |
535 | 535 | ||
536 | mov ax, tss0 |
536 | mov ax, tss0 |
537 | ltr ax |
537 | ltr ax |
538 | 538 | ||
539 | mov [LFBSize], 0x800000 |
539 | mov [LFBSize], 0x800000 |
540 | call init_LFB |
540 | call init_LFB |
541 | call init_fpu |
541 | call init_fpu |
542 | call init_malloc |
542 | call init_malloc |
543 | 543 | ||
544 | stdcall alloc_kernel_space, 0x51000 |
544 | stdcall alloc_kernel_space, 0x51000 |
545 | mov [default_io_map], eax |
545 | mov [default_io_map], eax |
546 | 546 | ||
547 | add eax, 0x2000 |
547 | add eax, 0x2000 |
548 | mov [ipc_tmp], eax |
548 | mov [ipc_tmp], eax |
549 | mov ebx, 0x1000 |
549 | mov ebx, 0x1000 |
550 | 550 | ||
551 | add eax, 0x40000 |
551 | add eax, 0x40000 |
552 | mov [proc_mem_map], eax |
552 | mov [proc_mem_map], eax |
553 | 553 | ||
554 | add eax, 0x8000 |
554 | add eax, 0x8000 |
555 | mov [proc_mem_pdir], eax |
555 | mov [proc_mem_pdir], eax |
556 | 556 | ||
557 | add eax, ebx |
557 | add eax, ebx |
558 | mov [proc_mem_tab], eax |
558 | mov [proc_mem_tab], eax |
559 | 559 | ||
560 | add eax, ebx |
560 | add eax, ebx |
561 | mov [tmp_task_pdir], eax |
561 | mov [tmp_task_pdir], eax |
562 | 562 | ||
563 | add eax, ebx |
563 | add eax, ebx |
564 | mov [tmp_task_ptab], eax |
564 | mov [tmp_task_ptab], eax |
565 | 565 | ||
566 | add eax, ebx |
566 | add eax, ebx |
567 | mov [ipc_pdir], eax |
567 | mov [ipc_pdir], eax |
568 | 568 | ||
569 | add eax, ebx |
569 | add eax, ebx |
570 | mov [ipc_ptab], eax |
570 | mov [ipc_ptab], eax |
571 | 571 | ||
572 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
572 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
573 | (unpack.lc+unpack.lp)))*4 |
573 | (unpack.lc+unpack.lp)))*4 |
574 | 574 | ||
575 | mov [unpack.p], eax |
575 | mov [unpack.p], eax |
576 | 576 | ||
577 | call init_events |
577 | call init_events |
578 | mov eax, srv.fd-SRV.fd |
578 | mov eax, srv.fd-SRV.fd |
579 | mov [srv.fd], eax |
579 | mov [srv.fd], eax |
580 | mov [srv.bk], eax |
580 | mov [srv.bk], eax |
581 | 581 | ||
582 | ;Set base of graphic segment to linear address of LFB |
582 | ;Set base of graphic segment to linear address of LFB |
583 | mov eax, [LFBAddress] ; set for gs |
583 | mov eax, [LFBAddress] ; set for gs |
584 | mov [graph_data_l+2], ax |
584 | mov [graph_data_l+2], ax |
585 | shr eax, 16 |
585 | shr eax, 16 |
586 | mov [graph_data_l+4], al |
586 | mov [graph_data_l+4], al |
587 | mov [graph_data_l+7], ah |
587 | mov [graph_data_l+7], ah |
588 | 588 | ||
589 | stdcall kernel_alloc, [_WinMapSize] |
589 | stdcall kernel_alloc, [_WinMapSize] |
590 | mov [_WinMapAddress], eax |
590 | mov [_WinMapAddress], eax |
591 | 591 | ||
592 | xor eax, eax |
592 | xor eax, eax |
593 | inc eax |
593 | inc eax |
594 | mov [CURRENT_TASK], eax ;dword 1 |
594 | mov [CURRENT_TASK], eax ;dword 1 |
595 | mov [TASK_COUNT], eax ;dword 1 |
595 | mov [TASK_COUNT], eax ;dword 1 |
596 | mov [TASK_BASE], dword TASK_DATA |
596 | mov [TASK_BASE], dword TASK_DATA |
597 | mov [current_slot], SLOT_BASE+256 |
597 | mov [current_slot], SLOT_BASE+256 |
598 | 598 | ||
599 | ; set background |
599 | ; set background |
600 | 600 | ||
601 | mov [BgrDrawMode], eax |
601 | mov [BgrDrawMode], eax |
602 | mov [BgrDataWidth], eax |
602 | mov [BgrDataWidth], eax |
603 | mov [BgrDataHeight], eax |
603 | mov [BgrDataHeight], eax |
604 | mov [mem_BACKGROUND], 4 |
604 | mov [mem_BACKGROUND], 4 |
605 | mov [img_background], static_background_data |
605 | mov [img_background], static_background_data |
606 | 606 | ||
607 | mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE |
607 | mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE |
608 | 608 | ||
609 | stdcall kernel_alloc, 0x10000/8 |
609 | stdcall kernel_alloc, 0x10000/8 |
610 | mov edi, eax |
610 | mov edi, eax |
611 | mov [network_free_ports], eax |
611 | mov [network_free_ports], eax |
612 | or eax, -1 |
612 | or eax, -1 |
613 | mov ecx, 0x10000/32 |
613 | mov ecx, 0x10000/32 |
614 | rep stosd |
614 | rep stosd |
615 | 615 | ||
616 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
616 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
617 | mov esi, boot_initirq |
617 | mov esi, boot_initirq |
618 | call boot_log |
618 | call boot_log |
619 | call init_irqs |
619 | call init_irqs |
620 | 620 | ||
621 | mov esi, boot_picinit |
621 | mov esi, boot_picinit |
622 | call boot_log |
622 | call boot_log |
623 | call PIC_init |
623 | call PIC_init |
624 | 624 | ||
625 | mov esi, boot_v86machine |
625 | mov esi, boot_v86machine |
626 | call boot_log |
626 | call boot_log |
627 | ; Initialize system V86 machine |
627 | ; Initialize system V86 machine |
628 | call init_sys_v86 |
628 | call init_sys_v86 |
629 | 629 | ||
630 | mov esi, boot_inittimer |
630 | mov esi, boot_inittimer |
631 | call boot_log |
631 | call boot_log |
632 | ; Initialize system timer (IRQ0) |
632 | ; Initialize system timer (IRQ0) |
633 | call PIT_init |
633 | call PIT_init |
634 | 634 | ||
635 | mov esi, boot_initapic |
635 | mov esi, boot_initapic |
636 | call boot_log |
636 | call boot_log |
637 | ; Try to Initialize APIC |
637 | ; Try to Initialize APIC |
638 | call APIC_init |
638 | call APIC_init |
639 | 639 | ||
640 | mov esi, boot_enableirq |
640 | mov esi, boot_enableirq |
641 | call boot_log |
641 | call boot_log |
642 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
642 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
643 | ; they are used: when partitions are scanned, hd_read relies on timer |
643 | ; they are used: when partitions are scanned, hd_read relies on timer |
644 | call unmask_timer |
644 | call unmask_timer |
645 | stdcall enable_irq, 2 ; @#$%! PIC |
645 | stdcall enable_irq, 2 ; @#$%! PIC |
646 | stdcall enable_irq, 6 ; FDD |
646 | stdcall enable_irq, 6 ; FDD |
647 | stdcall enable_irq, 13 ; co-processor |
647 | stdcall enable_irq, 13 ; co-processor |
648 | stdcall enable_irq, 14 |
648 | stdcall enable_irq, 14 |
649 | stdcall enable_irq, 15 |
649 | stdcall enable_irq, 15 |
650 | 650 | ||
651 | mov esi, boot_enablint_ide |
651 | mov esi, boot_enablint_ide |
652 | call boot_log |
652 | call boot_log |
653 | ; Enable interrupts in IDE controller |
653 | ; Enable interrupts in IDE controller |
654 | mov al, 0 |
654 | mov al, 0 |
655 | mov dx, 0x3F6 |
655 | mov dx, 0x3F6 |
656 | out dx, al |
656 | out dx, al |
657 | mov dl, 0x76 |
657 | mov dl, 0x76 |
658 | out dx, al |
658 | out dx, al |
659 | 659 | ||
660 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
660 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
661 | ; mov esi, boot_detectdisks |
661 | ; mov esi, boot_detectdisks |
662 | ; call boot_log |
662 | ; call boot_log |
663 | ;include 'detect/disks.inc' |
663 | ;include 'detect/disks.inc' |
664 | mov esi, boot_detectfloppy |
664 | mov esi, boot_detectfloppy |
665 | call boot_log |
665 | call boot_log |
666 | include 'detect/dev_fd.inc' |
666 | include 'detect/dev_fd.inc' |
667 | mov esi, boot_detecthdcd |
667 | mov esi, boot_detecthdcd |
668 | call boot_log |
668 | call boot_log |
669 | include 'detect/dev_hdcd.inc' |
669 | include 'detect/dev_hdcd.inc' |
670 | mov esi, boot_getcache |
670 | mov esi, boot_getcache |
671 | call boot_log |
671 | call boot_log |
672 | include 'detect/getcache.inc' |
672 | include 'detect/getcache.inc' |
673 | mov esi, boot_detectpart |
673 | mov esi, boot_detectpart |
674 | call boot_log |
674 | call boot_log |
675 | include 'detect/sear_par.inc' |
675 | include 'detect/sear_par.inc' |
676 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
676 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
677 | 677 | ||
678 | mov esi, boot_init_sys |
678 | mov esi, boot_init_sys |
679 | call boot_log |
679 | call boot_log |
680 | call Parser_params |
680 | call Parser_params |
681 | 681 | ||
682 | if ~ defined extended_primary_loader |
682 | if ~ defined extended_primary_loader |
683 | ; ramdisk image should be loaded by extended primary loader if it exists |
683 | ; ramdisk image should be loaded by extended primary loader if it exists |
684 | ; READ RAMDISK IMAGE FROM HD |
684 | ; READ RAMDISK IMAGE FROM HD |
685 | 685 | ||
686 | ;!!!!!!!!!!!!!!!!!!!!!!! |
686 | ;!!!!!!!!!!!!!!!!!!!!!!! |
687 | include 'boot/rdload.inc' |
687 | include 'boot/rdload.inc' |
688 | ;!!!!!!!!!!!!!!!!!!!!!!! |
688 | ;!!!!!!!!!!!!!!!!!!!!!!! |
689 | end if |
689 | end if |
690 | ; mov [dma_hdd],1 |
690 | ; mov [dma_hdd],1 |
691 | ; CALCULATE FAT CHAIN FOR RAMDISK |
691 | ; CALCULATE FAT CHAIN FOR RAMDISK |
692 | 692 | ||
693 | call calculatefatchain |
693 | call calculatefatchain |
694 | 694 | ||
695 | if 0 |
695 | if 0 |
696 | mov ax, [OS_BASE+0x10000+bx_from_load] |
696 | mov ax, [OS_BASE+0x10000+bx_from_load] |
697 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
697 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
698 | je no_lib_load |
698 | je no_lib_load |
699 | 699 | ||
700 | mov esi, boot_loadlibs |
700 | mov esi, boot_loadlibs |
701 | call boot_log |
701 | call boot_log |
702 | ; LOADING LIBRARES |
702 | ; LOADING LIBRARES |
703 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
703 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
704 | call load_file_parse_table ; prepare file parse table |
704 | call load_file_parse_table ; prepare file parse table |
705 | call set_kernel_conf ; configure devices and gui |
705 | call set_kernel_conf ; configure devices and gui |
706 | no_lib_load: |
706 | no_lib_load: |
707 | end if |
707 | end if |
708 | 708 | ||
709 | ; Display APIC status |
709 | ; Display APIC status |
710 | mov esi, boot_APIC_found |
710 | mov esi, boot_APIC_found |
711 | cmp [irq_mode], IRQ_APIC |
711 | cmp [irq_mode], IRQ_APIC |
712 | je @f |
712 | je @f |
713 | mov esi, boot_APIC_nfound |
713 | mov esi, boot_APIC_nfound |
714 | @@: |
714 | @@: |
715 | call boot_log |
715 | call boot_log |
716 | 716 | ||
717 | ; PRINT AMOUNT OF MEMORY |
717 | ; PRINT AMOUNT OF MEMORY |
718 | mov esi, boot_memdetect |
718 | mov esi, boot_memdetect |
719 | call boot_log |
719 | call boot_log |
720 | 720 | ||
721 | movzx ecx, word [boot_y] |
721 | movzx ecx, word [boot_y] |
722 | if lang eq ru |
722 | if lang eq ru |
723 | or ecx, (10+30*6) shl 16 |
723 | or ecx, (10+30*6) shl 16 |
724 | else |
724 | else |
725 | or ecx, (10+29*6) shl 16 |
725 | or ecx, (10+29*6) shl 16 |
726 | end if |
726 | end if |
727 | sub ecx, 10 |
727 | sub ecx, 10 |
728 | mov edx, 0xFFFFFF |
728 | mov edx, 0xFFFFFF |
729 | mov ebx, [MEM_AMOUNT] |
729 | mov ebx, [MEM_AMOUNT] |
730 | shr ebx, 20 |
730 | shr ebx, 20 |
731 | xor edi, edi |
731 | xor edi, edi |
732 | mov eax, 0x00040000 |
732 | mov eax, 0x00040000 |
733 | inc edi |
733 | inc edi |
734 | call display_number_force |
734 | call display_number_force |
735 | 735 | ||
736 | ; BUILD SCHEDULER |
736 | ; BUILD SCHEDULER |
737 | 737 | ||
738 | ; call build_scheduler; sys32.inc |
738 | ; call build_scheduler; sys32.inc |
739 | 739 | ||
740 | ; mov esi, boot_devices |
740 | ; mov esi, boot_devices |
741 | ; call boot_log |
741 | ; call boot_log |
742 | 742 | ||
743 | mov [pci_access_enabled], 1 |
743 | mov [pci_access_enabled], 1 |
744 | 744 | ||
745 | 745 | ||
746 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
746 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
747 | 747 | ||
748 | mov esi, boot_windefs |
748 | mov esi, boot_windefs |
749 | call boot_log |
749 | call boot_log |
750 | call set_window_defaults |
750 | call set_window_defaults |
751 | 751 | ||
752 | ; SET BACKGROUND DEFAULTS |
752 | ; SET BACKGROUND DEFAULTS |
753 | 753 | ||
754 | mov esi, boot_bgr |
754 | mov esi, boot_bgr |
755 | call boot_log |
755 | call boot_log |
756 | call init_background |
756 | call init_background |
757 | call calculatebackground |
757 | call calculatebackground |
758 | 758 | ||
759 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
759 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
760 | 760 | ||
761 | mov esi, boot_resirqports |
761 | mov esi, boot_resirqports |
762 | call boot_log |
762 | call boot_log |
763 | call reserve_irqs_ports |
763 | call reserve_irqs_ports |
764 | 764 | ||
765 | ; SET UP OS TASK |
765 | ; SET UP OS TASK |
766 | 766 | ||
767 | mov esi, boot_setostask |
767 | mov esi, boot_setostask |
768 | call boot_log |
768 | call boot_log |
769 | 769 | ||
770 | xor eax, eax |
770 | xor eax, eax |
771 | mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data |
771 | mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data |
772 | mov dword [SLOT_BASE+APPDATA.exc_handler], eax |
772 | mov dword [SLOT_BASE+APPDATA.exc_handler], eax |
773 | mov dword [SLOT_BASE+APPDATA.except_mask], eax |
773 | mov dword [SLOT_BASE+APPDATA.except_mask], eax |
774 | 774 | ||
775 | ; name for OS/IDLE process |
775 | ; name for OS/IDLE process |
776 | 776 | ||
777 | mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' |
777 | mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' |
778 | mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' |
778 | mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' |
779 | mov edi, [os_stack_seg] |
779 | mov edi, [os_stack_seg] |
780 | mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi |
780 | mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi |
781 | add edi, 0x2000-512 |
781 | add edi, 0x2000-512 |
782 | mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi |
782 | mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi |
783 | mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi; just for case |
783 | mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi; just for case |
784 | ; [SLOT_BASE+256+APPDATA.io_map] was set earlier |
784 | ; [SLOT_BASE+256+APPDATA.io_map] was set earlier |
785 | 785 | ||
786 | mov esi, fpu_data |
786 | mov esi, fpu_data |
787 | mov ecx, 512/4 |
787 | mov ecx, 512/4 |
788 | cld |
788 | cld |
789 | rep movsd |
789 | rep movsd |
790 | 790 | ||
791 | mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax |
791 | mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax |
792 | mov dword [SLOT_BASE+256+APPDATA.except_mask], eax |
792 | mov dword [SLOT_BASE+256+APPDATA.except_mask], eax |
793 | 793 | ||
794 | mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET |
794 | mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET |
795 | mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx |
795 | mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx |
796 | mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx |
796 | mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx |
797 | 797 | ||
798 | mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path |
798 | mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path |
799 | mov dword [SLOT_BASE+256+APPDATA.tls_base], eax |
799 | mov dword [SLOT_BASE+256+APPDATA.tls_base], eax |
800 | 800 | ||
801 | ; task list |
801 | ; task list |
802 | mov dword [TASK_DATA+TASKDATA.mem_start], eax; process base address |
802 | mov dword [TASK_DATA+TASKDATA.mem_start], eax; process base address |
803 | inc eax |
803 | inc eax |
804 | mov dword [CURRENT_TASK], eax |
804 | mov dword [CURRENT_TASK], eax |
805 | mov dword [TASK_COUNT], eax |
805 | mov dword [TASK_COUNT], eax |
806 | mov [current_slot], SLOT_BASE+256 |
806 | mov [current_slot], SLOT_BASE+256 |
807 | mov [TASK_BASE], dword TASK_DATA |
807 | mov [TASK_BASE], dword TASK_DATA |
808 | mov byte[TASK_DATA+TASKDATA.wnd_number], al ; on screen number |
808 | mov byte[TASK_DATA+TASKDATA.wnd_number], al ; on screen number |
809 | mov dword [TASK_DATA+TASKDATA.pid], eax ; process id number |
809 | mov dword [TASK_DATA+TASKDATA.pid], eax ; process id number |
810 | 810 | ||
811 | call init_display |
811 | call init_display |
812 | mov eax, [def_cursor] |
812 | mov eax, [def_cursor] |
813 | mov [SLOT_BASE+APPDATA.cursor], eax |
813 | mov [SLOT_BASE+APPDATA.cursor], eax |
814 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
814 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
815 | 815 | ||
816 | ; READ TSC / SECOND |
816 | ; READ TSC / SECOND |
817 | 817 | ||
818 | mov esi, boot_tsc |
818 | mov esi, boot_tsc |
819 | call boot_log |
819 | call boot_log |
820 | cli |
820 | cli |
821 | rdtsc ;call _rdtsc |
821 | rdtsc ;call _rdtsc |
822 | mov ecx, eax |
822 | mov ecx, eax |
823 | mov esi, 250 ; wait 1/4 a second |
823 | mov esi, 250 ; wait 1/4 a second |
824 | call delay_ms |
824 | call delay_ms |
825 | rdtsc ;call _rdtsc |
825 | rdtsc ;call _rdtsc |
826 | sti |
826 | sti |
827 | sub eax, ecx |
827 | sub eax, ecx |
828 | shl eax, 2 |
828 | shl eax, 2 |
829 | mov [CPU_FREQ], eax ; save tsc / sec |
829 | mov [CPU_FREQ], eax ; save tsc / sec |
830 | ; mov ebx, 1000000 |
830 | ; mov ebx, 1000000 |
831 | ; div ebx |
831 | ; div ebx |
832 | ; ¢®®¡é¥-â® ¯à®¨§¢®¤¨â¥«ì®áâì ¢ ¤ ®¬ ª®ªà¥â®¬ ¬¥á⥠|
832 | ; ¢®®¡é¥-â® ¯à®¨§¢®¤¨â¥«ì®áâì ¢ ¤ ®¬ ª®ªà¥â®¬ ¬¥á⥠|
833 | ; ᮢ¥à襮 ¥ªà¨â¨ç , ® çâ®¡ë § âªãâì «î¡¨â¥«¥© |
833 | ; ᮢ¥à襮 ¥ªà¨â¨ç , ® çâ®¡ë § âªãâì «î¡¨â¥«¥© |
834 | ; ®¯â¨¬¨§¨àãîé¨å ª®¬¯¨«ïâ®à®¢ ... |
834 | ; ®¯â¨¬¨§¨àãîé¨å ª®¬¯¨«ïâ®à®¢ ... |
835 | mov edx, 2251799814 |
835 | mov edx, 2251799814 |
836 | mul edx |
836 | mul edx |
837 | shr edx, 19 |
837 | shr edx, 19 |
838 | mov [stall_mcs], edx |
838 | mov [stall_mcs], edx |
839 | ; PRINT CPU FREQUENCY |
839 | ; PRINT CPU FREQUENCY |
840 | mov esi, boot_cpufreq |
840 | mov esi, boot_cpufreq |
841 | call boot_log |
841 | call boot_log |
842 | 842 | ||
843 | mov ebx, edx |
843 | mov ebx, edx |
844 | movzx ecx, word [boot_y] |
844 | movzx ecx, word [boot_y] |
845 | if lang eq ru |
845 | if lang eq ru |
846 | add ecx, (10+19*6) shl 16 - 10 ; 'Determining amount of memory' |
846 | add ecx, (10+19*6) shl 16 - 10 ; 'Determining amount of memory' |
847 | else |
847 | else |
848 | add ecx, (10+17*6) shl 16 - 10 ; 'Determining amount of memory' |
848 | add ecx, (10+17*6) shl 16 - 10 ; 'Determining amount of memory' |
849 | end if |
849 | end if |
850 | mov edx, 0xFFFFFF |
850 | mov edx, 0xFFFFFF |
851 | xor edi, edi |
851 | xor edi, edi |
852 | mov eax, 0x00040000 |
852 | mov eax, 0x00040000 |
853 | inc edi |
853 | inc edi |
854 | call display_number_force |
854 | call display_number_force |
855 | 855 | ||
856 | ; SET VARIABLES |
856 | ; SET VARIABLES |
857 | 857 | ||
858 | call set_variables |
858 | call set_variables |
859 | 859 | ||
860 | ; STACK AND FDC |
860 | ; STACK AND FDC |
861 | 861 | ||
862 | call stack_init |
862 | call stack_init |
863 | call fdc_init |
863 | call fdc_init |
864 | 864 | ||
865 | ; PALETTE FOR 320x200 and 640x480 16 col |
865 | ; PALETTE FOR 320x200 and 640x480 16 col |
866 | 866 | ||
867 | cmp [SCR_MODE], word 0x12 |
867 | cmp [SCR_MODE], word 0x12 |
868 | jne no_pal_vga |
868 | jne no_pal_vga |
869 | mov esi, boot_pal_vga |
869 | mov esi, boot_pal_vga |
870 | call boot_log |
870 | call boot_log |
871 | call paletteVGA |
871 | call paletteVGA |
872 | no_pal_vga: |
872 | no_pal_vga: |
873 | 873 | ||
874 | cmp [SCR_MODE], word 0x13 |
874 | cmp [SCR_MODE], word 0x13 |
875 | jne no_pal_ega |
875 | jne no_pal_ega |
876 | mov esi, boot_pal_ega |
876 | mov esi, boot_pal_ega |
877 | call boot_log |
877 | call boot_log |
878 | call palette320x200 |
878 | call palette320x200 |
879 | no_pal_ega: |
879 | no_pal_ega: |
880 | 880 | ||
881 | ; LOAD DEFAULT SKIN |
881 | ; LOAD DEFAULT SKIN |
882 | 882 | ||
883 | call load_default_skin |
883 | call load_default_skin |
884 | 884 | ||
885 | ;protect io permission map |
885 | ;protect io permission map |
886 | 886 | ||
887 | mov esi, [default_io_map] |
887 | mov esi, [default_io_map] |
888 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
888 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
889 | add esi, 0x1000 |
889 | add esi, 0x1000 |
890 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
890 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
891 | 891 | ||
892 | stdcall map_page, tss._io_map_0, \ |
892 | stdcall map_page, tss._io_map_0, \ |
893 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
893 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
894 | stdcall map_page, tss._io_map_1, \ |
894 | stdcall map_page, tss._io_map_1, \ |
895 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
895 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
896 | 896 | ||
897 | mov ax, [OS_BASE+0x10000+bx_from_load] |
897 | mov ax, [OS_BASE+0x10000+bx_from_load] |
898 | cmp ax, 'r1'; if not rused ram disk - load network configuration from files {SPraid.simba} |
898 | cmp ax, 'r1'; if not rused ram disk - load network configuration from files {SPraid.simba} |
899 | je no_st_network |
899 | je no_st_network |
900 | call set_network_conf |
900 | call set_network_conf |
901 | no_st_network: |
901 | no_st_network: |
902 | 902 | ||
903 | ; LOAD FIRST APPLICATION |
903 | ; LOAD FIRST APPLICATION |
904 | cli |
904 | cli |
905 | 905 | ||
906 | ; cmp byte [BOOT_VAR+0x9030],1 |
906 | ; cmp byte [BOOT_VAR+0x9030],1 |
907 | ; jne no_load_vrr_m |
907 | ; jne no_load_vrr_m |
908 | 908 | ||
909 | ; mov ebp, vrr_m |
909 | ; mov ebp, vrr_m |
910 | ; call fs_execute_from_sysdir |
910 | ; call fs_execute_from_sysdir |
911 | ; |
911 | ; |
912 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
912 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
913 | ; sub eax,2 |
913 | ; sub eax,2 |
914 | ; jz first_app_found |
914 | ; jz first_app_found |
915 | ; |
915 | ; |
916 | ;no_load_vrr_m: |
916 | ;no_load_vrr_m: |
917 | 917 | ||
918 | mov ebp, firstapp |
918 | mov ebp, firstapp |
919 | call fs_execute_from_sysdir |
919 | call fs_execute_from_sysdir |
920 | 920 | ||
921 | ; cmp eax,2 ; continue if a process has been loaded |
921 | ; cmp eax,2 ; continue if a process has been loaded |
922 | sub eax, 2 |
922 | sub eax, 2 |
923 | jz first_app_found |
923 | jz first_app_found |
924 | 924 | ||
925 | mov esi, boot_failed |
925 | mov esi, boot_failed |
926 | call boot_log |
926 | call boot_log |
927 | 927 | ||
928 | mov eax, 0xDEADBEEF ; otherwise halt |
928 | mov eax, 0xDEADBEEF ; otherwise halt |
929 | hlt |
929 | hlt |
930 | 930 | ||
931 | first_app_found: |
931 | first_app_found: |
932 | 932 | ||
933 | cli |
933 | cli |
934 | 934 | ||
935 | ;mov [TASK_COUNT],dword 2 |
935 | ;mov [TASK_COUNT],dword 2 |
936 | push 1 |
936 | push 1 |
937 | pop dword [CURRENT_TASK] ; set OS task fisrt |
937 | pop dword [CURRENT_TASK] ; set OS task fisrt |
938 | 938 | ||
939 | ; SET KEYBOARD PARAMETERS |
939 | ; SET KEYBOARD PARAMETERS |
940 | mov al, 0xf6 ; reset keyboard, scan enabled |
940 | mov al, 0xf6 ; reset keyboard, scan enabled |
941 | call kb_write |
941 | call kb_write |
942 | test ah, ah |
942 | test ah, ah |
943 | jnz .no_keyboard |
943 | jnz .no_keyboard |
944 | 944 | ||
945 | ; wait until 8042 is ready |
945 | ; wait until 8042 is ready |
946 | xor ecx, ecx |
946 | xor ecx, ecx |
947 | @@: |
947 | @@: |
948 | in al, 64h |
948 | in al, 64h |
949 | and al, 00000010b |
949 | and al, 00000010b |
950 | loopnz @b |
950 | loopnz @b |
951 | 951 | ||
952 | iglobal |
952 | iglobal |
953 | align 4 |
953 | align 4 |
954 | ps2_keyboard_functions: |
954 | ps2_keyboard_functions: |
955 | dd .end - $ |
955 | dd .end - $ |
956 | dd 0 ; no close |
956 | dd 0 ; no close |
957 | dd ps2_set_lights |
957 | dd ps2_set_lights |
958 | .end: |
958 | .end: |
959 | endg |
959 | endg |
960 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
960 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
961 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
961 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
962 | ; call kb_write |
962 | ; call kb_write |
963 | ; call kb_read |
963 | ; call kb_read |
964 | ; mov al, 111b |
964 | ; mov al, 111b |
965 | ; call kb_write |
965 | ; call kb_write |
966 | ; call kb_read |
966 | ; call kb_read |
967 | 967 | ||
968 | mov al, 0xF3 ; set repeat rate & delay |
968 | mov al, 0xF3 ; set repeat rate & delay |
969 | call kb_write |
969 | call kb_write |
970 | ; call kb_read |
970 | ; call kb_read |
971 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
971 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
972 | call kb_write |
972 | call kb_write |
973 | ; call kb_read |
973 | ; call kb_read |
974 | ;// mike.dld [ |
974 | ;// mike.dld [ |
975 | call set_lights |
975 | call set_lights |
976 | ;// mike.dld ] |
976 | ;// mike.dld ] |
977 | stdcall attach_int_handler, 1, irq1, 0 |
977 | stdcall attach_int_handler, 1, irq1, 0 |
978 | .no_keyboard: |
978 | .no_keyboard: |
979 | 979 | ||
980 | ; SET MOUSE |
980 | ; SET MOUSE |
981 | 981 | ||
982 | stdcall load_driver, szPS2MDriver |
982 | stdcall load_driver, szPS2MDriver |
983 | ; stdcall load_driver, szCOM_MDriver |
983 | ; stdcall load_driver, szCOM_MDriver |
984 | 984 | ||
985 | mov esi, boot_setmouse |
985 | mov esi, boot_setmouse |
986 | call boot_log |
986 | call boot_log |
987 | call setmouse |
987 | call setmouse |
988 | 988 | ||
989 | ; Setup serial output console (if enabled) |
989 | ; Setup serial output console (if enabled) |
990 | 990 | ||
991 | if defined debug_com_base |
991 | if defined debug_com_base |
992 | 992 | ||
993 | ; enable Divisor latch |
993 | ; enable Divisor latch |
994 | 994 | ||
995 | mov dx, debug_com_base+3 |
995 | mov dx, debug_com_base+3 |
996 | mov al, 1 shl 7 |
996 | mov al, 1 shl 7 |
997 | out dx, al |
997 | out dx, al |
998 | 998 | ||
999 | ; Set speed to 115200 baud (max speed) |
999 | ; Set speed to 115200 baud (max speed) |
1000 | 1000 | ||
1001 | mov dx, debug_com_base |
1001 | mov dx, debug_com_base |
1002 | mov al, 0x01 |
1002 | mov al, 0x01 |
1003 | out dx, al |
1003 | out dx, al |
1004 | 1004 | ||
1005 | mov dx, debug_com_base+1 |
1005 | mov dx, debug_com_base+1 |
1006 | mov al, 0x00 |
1006 | mov al, 0x00 |
1007 | out dx, al |
1007 | out dx, al |
1008 | 1008 | ||
1009 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1009 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1010 | 1010 | ||
1011 | mov dx, debug_com_base+3 |
1011 | mov dx, debug_com_base+3 |
1012 | mov al, 3 |
1012 | mov al, 3 |
1013 | out dx, al |
1013 | out dx, al |
1014 | 1014 | ||
1015 | ; disable interrupts |
1015 | ; disable interrupts |
1016 | 1016 | ||
1017 | mov dx, debug_com_base+1 |
1017 | mov dx, debug_com_base+1 |
1018 | mov al, 0 |
1018 | mov al, 0 |
1019 | out dx, al |
1019 | out dx, al |
1020 | 1020 | ||
1021 | ; clear + enable fifo (64 bits) |
1021 | ; clear + enable fifo (64 bits) |
1022 | 1022 | ||
1023 | mov dx, debug_com_base+2 |
1023 | mov dx, debug_com_base+2 |
1024 | mov al, 0x7 + 1 shl 5 |
1024 | mov al, 0x7 + 1 shl 5 |
1025 | out dx, al |
1025 | out dx, al |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | end if |
1028 | end if |
1029 | 1029 | ||
1030 | mov eax, [cpu_count] |
1030 | mov eax, [cpu_count] |
1031 | test eax, eax |
1031 | test eax, eax |
1032 | jnz @F |
1032 | jnz @F |
1033 | mov al, 1 ; at least one CPU |
1033 | mov al, 1 ; at least one CPU |
1034 | @@: |
1034 | @@: |
1035 | DEBUGF 1, "K : %d CPU detected\n", eax |
1035 | DEBUGF 1, "K : %d CPU detected\n", eax |
1036 | 1036 | ||
1037 | ; START MULTITASKING |
1037 | ; START MULTITASKING |
1038 | 1038 | ||
1039 | ; A 'All set - press ESC to start' messages if need |
1039 | ; A 'All set - press ESC to start' messages if need |
1040 | if preboot_blogesc |
1040 | if preboot_blogesc |
1041 | mov esi, boot_tasking |
1041 | mov esi, boot_tasking |
1042 | call boot_log |
1042 | call boot_log |
1043 | .bll1: |
1043 | .bll1: |
1044 | in al, 0x60 ; wait for ESC key press |
1044 | in al, 0x60 ; wait for ESC key press |
1045 | cmp al, 129 |
1045 | cmp al, 129 |
1046 | jne .bll1 |
1046 | jne .bll1 |
1047 | end if |
1047 | end if |
1048 | 1048 | ||
1049 | cmp [IDEContrRegsBaseAddr], 0 |
1049 | cmp [IDEContrRegsBaseAddr], 0 |
1050 | setnz [dma_hdd] |
1050 | setnz [dma_hdd] |
1051 | mov [timer_ticks_enable], 1 ; for cd driver |
1051 | mov [timer_ticks_enable], 1 ; for cd driver |
1052 | 1052 | ||
1053 | sti |
1053 | sti |
1054 | call change_task |
1054 | call change_task |
1055 | 1055 | ||
1056 | jmp osloop |
1056 | jmp osloop |
1057 | 1057 | ||
1058 | 1058 | ||
1059 | ; Fly :) |
1059 | ; Fly :) |
1060 | 1060 | ||
1061 | include 'unpacker.inc' |
1061 | include 'unpacker.inc' |
1062 | 1062 | ||
1063 | align 4 |
1063 | align 4 |
1064 | boot_log: |
1064 | boot_log: |
1065 | pushad |
1065 | pushad |
1066 | 1066 | ||
1067 | mov ebx, 10*65536 |
1067 | mov ebx, 10*65536 |
1068 | mov bx, word [boot_y] |
1068 | mov bx, word [boot_y] |
1069 | add [boot_y], dword 10 |
1069 | add [boot_y], dword 10 |
1070 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1070 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1071 | xor edi, edi |
1071 | xor edi, edi |
1072 | mov edx, esi |
1072 | mov edx, esi |
1073 | inc edi |
1073 | inc edi |
1074 | call dtext |
1074 | call dtext |
1075 | 1075 | ||
1076 | mov [novesachecksum], 1000 |
1076 | mov [novesachecksum], 1000 |
1077 | call checkVga_N13 |
1077 | call checkVga_N13 |
1078 | 1078 | ||
1079 | popad |
1079 | popad |
1080 | 1080 | ||
1081 | ret |
1081 | ret |
1082 | 1082 | ||
1083 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1083 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1084 | ; ; |
1084 | ; ; |
1085 | ; MAIN OS LOOP START ; |
1085 | ; MAIN OS LOOP START ; |
1086 | ; ; |
1086 | ; ; |
1087 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1087 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1088 | align 32 |
1088 | align 32 |
1089 | osloop: |
1089 | osloop: |
1090 | ; call [draw_pointer] |
1090 | ; call [draw_pointer] |
1091 | call __sys_draw_pointer |
1091 | call __sys_draw_pointer |
1092 | call window_check_events |
1092 | call window_check_events |
1093 | call mouse_check_events |
1093 | call mouse_check_events |
1094 | call checkmisc |
1094 | call checkmisc |
1095 | call checkVga_N13 |
1095 | call checkVga_N13 |
1096 | call stack_handler |
1096 | call stack_handler |
1097 | call checkidle |
1097 | call checkidle |
1098 | call check_fdd_motor_status |
1098 | call check_fdd_motor_status |
1099 | call check_ATAPI_device_event |
1099 | call check_ATAPI_device_event |
1100 | call check_lights_state |
1100 | call check_lights_state |
1101 | call check_timers |
1101 | call check_timers |
1102 | jmp osloop |
1102 | jmp osloop |
1103 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1103 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1104 | ; ; |
1104 | ; ; |
1105 | ; MAIN OS LOOP END ; |
1105 | ; MAIN OS LOOP END ; |
1106 | ; ; |
1106 | ; ; |
1107 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1107 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1108 | align 4 |
1108 | align 4 |
1109 | checkidle: |
1109 | checkidle: |
1110 | pushad |
1110 | pushad |
1111 | call change_task |
1111 | call change_task |
1112 | jmp idle_loop_entry |
1112 | jmp idle_loop_entry |
1113 | idle_loop: |
1113 | idle_loop: |
1114 | cmp eax, [idlemem] ; eax == [timer_ticks] |
1114 | cmp eax, [idlemem] ; eax == [timer_ticks] |
1115 | jne idle_exit |
1115 | jne idle_exit |
1116 | rdtsc ;call _rdtsc |
1116 | rdtsc ;call _rdtsc |
1117 | mov ecx, eax |
1117 | mov ecx, eax |
1118 | hlt |
1118 | hlt |
1119 | rdtsc ;call _rdtsc |
1119 | rdtsc ;call _rdtsc |
1120 | sub eax, ecx |
1120 | sub eax, ecx |
1121 | add [idleuse], eax |
1121 | add [idleuse], eax |
1122 | idle_loop_entry: |
1122 | idle_loop_entry: |
1123 | mov eax, [timer_ticks]; eax = [timer_ticks] |
1123 | mov eax, [timer_ticks]; eax = [timer_ticks] |
1124 | cmp [check_idle_semaphore], 0 |
1124 | cmp [check_idle_semaphore], 0 |
1125 | je idle_loop |
1125 | je idle_loop |
1126 | dec [check_idle_semaphore] |
1126 | dec [check_idle_semaphore] |
1127 | idle_exit: |
1127 | idle_exit: |
1128 | mov [idlemem], eax ; eax == [timer_ticks] |
1128 | mov [idlemem], eax ; eax == [timer_ticks] |
1129 | popad |
1129 | popad |
1130 | ret |
1130 | ret |
1131 | 1131 | ||
1132 | uglobal |
1132 | uglobal |
1133 | idlemem dd 0x0 |
1133 | idlemem dd 0x0 |
1134 | idleuse dd 0x0 |
1134 | idleuse dd 0x0 |
1135 | idleusesec dd 0x0 |
1135 | idleusesec dd 0x0 |
1136 | check_idle_semaphore dd 0x0 |
1136 | check_idle_semaphore dd 0x0 |
1137 | endg |
1137 | endg |
1138 | 1138 | ||
1139 | 1139 | ||
1140 | 1140 | ||
1141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1142 | ; ; |
1142 | ; ; |
1143 | ; INCLUDED SYSTEM FILES ; |
1143 | ; INCLUDED SYSTEM FILES ; |
1144 | ; ; |
1144 | ; ; |
1145 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1145 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1146 | 1146 | ||
1147 | 1147 | ||
1148 | include "kernel32.inc" |
1148 | include "kernel32.inc" |
1149 | 1149 | ||
1150 | 1150 | ||
1151 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1151 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1152 | ; ; |
1152 | ; ; |
1153 | ; KERNEL FUNCTIONS ; |
1153 | ; KERNEL FUNCTIONS ; |
1154 | ; ; |
1154 | ; ; |
1155 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1155 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1156 | 1156 | ||
1157 | reserve_irqs_ports: |
1157 | reserve_irqs_ports: |
1158 | 1158 | ||
1159 | 1159 | ||
1160 | ; RESERVE PORTS |
1160 | ; RESERVE PORTS |
1161 | mov eax, RESERVED_PORTS |
1161 | mov eax, RESERVED_PORTS |
1162 | mov ecx, 1 |
1162 | mov ecx, 1 |
1163 | 1163 | ||
1164 | mov [eax], dword 4 |
1164 | mov [eax], dword 4 |
1165 | 1165 | ||
1166 | mov [eax+16], ecx |
1166 | mov [eax+16], ecx |
1167 | mov [eax+16+4], dword 0 |
1167 | mov [eax+16+4], dword 0 |
1168 | mov [eax+16+4], dword 0x2D |
1168 | mov [eax+16+4], dword 0x2D |
1169 | 1169 | ||
1170 | mov [eax+32], ecx |
1170 | mov [eax+32], ecx |
1171 | mov [eax+32+4], dword 0x30 |
1171 | mov [eax+32+4], dword 0x30 |
1172 | mov [eax+32+8], dword 0x4D |
1172 | mov [eax+32+8], dword 0x4D |
1173 | 1173 | ||
1174 | mov [eax+48], ecx |
1174 | mov [eax+48], ecx |
1175 | mov [eax+48+4], dword 0x50 |
1175 | mov [eax+48+4], dword 0x50 |
1176 | mov [eax+28+8], dword 0xDF |
1176 | mov [eax+28+8], dword 0xDF |
1177 | 1177 | ||
1178 | mov [eax+64], ecx |
1178 | mov [eax+64], ecx |
1179 | mov [eax+64+4], dword 0xE5 |
1179 | mov [eax+64+4], dword 0xE5 |
1180 | mov [eax+64+8], dword 0xFF |
1180 | mov [eax+64+8], dword 0xFF |
1181 | 1181 | ||
1182 | ret |
1182 | ret |
1183 | 1183 | ||
1184 | 1184 | ||
1185 | iglobal |
1185 | iglobal |
1186 | process_number dd 0x1 |
1186 | process_number dd 0x1 |
1187 | endg |
1187 | endg |
1188 | 1188 | ||
1189 | set_variables: |
1189 | set_variables: |
1190 | 1190 | ||
1191 | mov ecx, 0x16 ; flush port 0x60 |
1191 | mov ecx, 0x16 ; flush port 0x60 |
1192 | .fl60: |
1192 | .fl60: |
1193 | in al, 0x60 |
1193 | in al, 0x60 |
1194 | loop .fl60 |
1194 | loop .fl60 |
1195 | push eax |
1195 | push eax |
1196 | 1196 | ||
1197 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1197 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1198 | shr ax, 1 |
1198 | shr ax, 1 |
1199 | shl eax, 16 |
1199 | shl eax, 16 |
1200 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1200 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1201 | shr ax, 1 |
1201 | shr ax, 1 |
1202 | mov [MOUSE_X], eax |
1202 | mov [MOUSE_X], eax |
1203 | 1203 | ||
1204 | xor eax, eax |
1204 | xor eax, eax |
1205 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1205 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1206 | 1206 | ||
1207 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1207 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1208 | mov byte [KEY_COUNT], al ; keyboard buffer |
1208 | mov byte [KEY_COUNT], al ; keyboard buffer |
1209 | mov byte [BTN_COUNT], al ; button buffer |
1209 | mov byte [BTN_COUNT], al ; button buffer |
1210 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1210 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1211 | 1211 | ||
1212 | ;!! IP 04.02.2005: |
1212 | ;!! IP 04.02.2005: |
1213 | mov byte [DONT_SWITCH], al; change task if possible |
1213 | mov byte [DONT_SWITCH], al; change task if possible |
1214 | pop eax |
1214 | pop eax |
1215 | ret |
1215 | ret |
1216 | 1216 | ||
1217 | align 4 |
1217 | align 4 |
1218 | ;input eax=43,bl-byte of output, ecx - number of port |
1218 | ;input eax=43,bl-byte of output, ecx - number of port |
1219 | sys_outport: |
1219 | sys_outport: |
1220 | 1220 | ||
1221 | mov edi, ecx ; separate flag for read / write |
1221 | mov edi, ecx ; separate flag for read / write |
1222 | and ecx, 65535 |
1222 | and ecx, 65535 |
1223 | 1223 | ||
1224 | mov eax, [RESERVED_PORTS] |
1224 | mov eax, [RESERVED_PORTS] |
1225 | test eax, eax |
1225 | test eax, eax |
1226 | jnz .sopl8 |
1226 | jnz .sopl8 |
1227 | inc eax |
1227 | inc eax |
1228 | mov [esp+32], eax |
1228 | mov [esp+32], eax |
1229 | ret |
1229 | ret |
1230 | 1230 | ||
1231 | .sopl8: |
1231 | .sopl8: |
1232 | mov edx, [TASK_BASE] |
1232 | mov edx, [TASK_BASE] |
1233 | mov edx, [edx+0x4] |
1233 | mov edx, [edx+0x4] |
1234 | ;and ecx,65535 |
1234 | ;and ecx,65535 |
1235 | ;cld - set on interrupt 0x40 |
1235 | ;cld - set on interrupt 0x40 |
1236 | .sopl1: |
1236 | .sopl1: |
1237 | 1237 | ||
1238 | mov esi, eax |
1238 | mov esi, eax |
1239 | shl esi, 4 |
1239 | shl esi, 4 |
1240 | add esi, RESERVED_PORTS |
1240 | add esi, RESERVED_PORTS |
1241 | cmp edx, [esi+0] |
1241 | cmp edx, [esi+0] |
1242 | jne .sopl2 |
1242 | jne .sopl2 |
1243 | cmp ecx, [esi+4] |
1243 | cmp ecx, [esi+4] |
1244 | jb .sopl2 |
1244 | jb .sopl2 |
1245 | cmp ecx, [esi+8] |
1245 | cmp ecx, [esi+8] |
1246 | jg .sopl2 |
1246 | jg .sopl2 |
1247 | .sopl3: |
1247 | .sopl3: |
1248 | 1248 | ||
1249 | test edi, 0x80000000; read ? |
1249 | test edi, 0x80000000; read ? |
1250 | jnz .sopl4 |
1250 | jnz .sopl4 |
1251 | 1251 | ||
1252 | mov eax, ebx |
1252 | mov eax, ebx |
1253 | mov dx, cx ; write |
1253 | mov dx, cx ; write |
1254 | out dx, al |
1254 | out dx, al |
1255 | and [esp+32], dword 0 |
1255 | and [esp+32], dword 0 |
1256 | ret |
1256 | ret |
1257 | 1257 | ||
1258 | .sopl2: |
1258 | .sopl2: |
1259 | 1259 | ||
1260 | dec eax |
1260 | dec eax |
1261 | jnz .sopl1 |
1261 | jnz .sopl1 |
1262 | inc eax |
1262 | inc eax |
1263 | mov [esp+32], eax |
1263 | mov [esp+32], eax |
1264 | ret |
1264 | ret |
1265 | 1265 | ||
1266 | 1266 | ||
1267 | .sopl4: |
1267 | .sopl4: |
1268 | 1268 | ||
1269 | mov dx, cx ; read |
1269 | mov dx, cx ; read |
1270 | in al, dx |
1270 | in al, dx |
1271 | and eax, 0xff |
1271 | and eax, 0xff |
1272 | and [esp+32], dword 0 |
1272 | and [esp+32], dword 0 |
1273 | mov [esp+20], eax |
1273 | mov [esp+20], eax |
1274 | ret |
1274 | ret |
1275 | 1275 | ||
1276 | display_number: |
1276 | display_number: |
1277 | ;It is not optimization |
1277 | ;It is not optimization |
1278 | mov eax, ebx |
1278 | mov eax, ebx |
1279 | mov ebx, ecx |
1279 | mov ebx, ecx |
1280 | mov ecx, edx |
1280 | mov ecx, edx |
1281 | mov edx, esi |
1281 | mov edx, esi |
1282 | mov esi, edi |
1282 | mov esi, edi |
1283 | ; eax = print type, al=0 -> ebx is number |
1283 | ; eax = print type, al=0 -> ebx is number |
1284 | ; al=1 -> ebx is pointer |
1284 | ; al=1 -> ebx is pointer |
1285 | ; ah=0 -> display decimal |
1285 | ; ah=0 -> display decimal |
1286 | ; ah=1 -> display hexadecimal |
1286 | ; ah=1 -> display hexadecimal |
1287 | ; ah=2 -> display binary |
1287 | ; ah=2 -> display binary |
1288 | ; eax bits 16-21 = number of digits to display (0-32) |
1288 | ; eax bits 16-21 = number of digits to display (0-32) |
1289 | ; eax bits 22-31 = reserved |
1289 | ; eax bits 22-31 = reserved |
1290 | ; |
1290 | ; |
1291 | ; ebx = number or pointer |
1291 | ; ebx = number or pointer |
1292 | ; ecx = x shl 16 + y |
1292 | ; ecx = x shl 16 + y |
1293 | ; edx = color |
1293 | ; edx = color |
1294 | xor edi, edi |
1294 | xor edi, edi |
1295 | display_number_force: |
1295 | display_number_force: |
1296 | push eax |
1296 | push eax |
1297 | and eax, 0x3fffffff |
1297 | and eax, 0x3fffffff |
1298 | cmp eax, 0xffff ; length > 0 ? |
1298 | cmp eax, 0xffff ; length > 0 ? |
1299 | pop eax |
1299 | pop eax |
1300 | jge cont_displ |
1300 | jge cont_displ |
1301 | ret |
1301 | ret |
1302 | cont_displ: |
1302 | cont_displ: |
1303 | push eax |
1303 | push eax |
1304 | and eax, 0x3fffffff |
1304 | and eax, 0x3fffffff |
1305 | cmp eax, 61*0x10000 ; length <= 60 ? |
1305 | cmp eax, 61*0x10000 ; length <= 60 ? |
1306 | pop eax |
1306 | pop eax |
1307 | jb cont_displ2 |
1307 | jb cont_displ2 |
1308 | ret |
1308 | ret |
1309 | cont_displ2: |
1309 | cont_displ2: |
1310 | 1310 | ||
1311 | pushad |
1311 | pushad |
1312 | 1312 | ||
1313 | cmp al, 1 ; ecx is a pointer ? |
1313 | cmp al, 1 ; ecx is a pointer ? |
1314 | jne displnl1 |
1314 | jne displnl1 |
1315 | mov ebp, ebx |
1315 | mov ebp, ebx |
1316 | add ebp, 4 |
1316 | add ebp, 4 |
1317 | mov ebp, [ebp+std_application_base_address] |
1317 | mov ebp, [ebp+std_application_base_address] |
1318 | mov ebx, [ebx+std_application_base_address] |
1318 | mov ebx, [ebx+std_application_base_address] |
1319 | displnl1: |
1319 | displnl1: |
1320 | sub esp, 64 |
1320 | sub esp, 64 |
1321 | 1321 | ||
1322 | test ah, ah ; DECIMAL |
1322 | test ah, ah ; DECIMAL |
1323 | jnz no_display_desnum |
1323 | jnz no_display_desnum |
1324 | shr eax, 16 |
1324 | shr eax, 16 |
1325 | and eax, 0xC03f |
1325 | and eax, 0xC03f |
1326 | ; and eax,0x3f |
1326 | ; and eax,0x3f |
1327 | push eax |
1327 | push eax |
1328 | and eax, 0x3f |
1328 | and eax, 0x3f |
1329 | mov edi, esp |
1329 | mov edi, esp |
1330 | add edi, 4+64-1 |
1330 | add edi, 4+64-1 |
1331 | mov ecx, eax |
1331 | mov ecx, eax |
1332 | mov eax, ebx |
1332 | mov eax, ebx |
1333 | mov ebx, 10 |
1333 | mov ebx, 10 |
1334 | d_desnum: |
1334 | d_desnum: |
1335 | xor edx, edx |
1335 | xor edx, edx |
1336 | call division_64_bits |
1336 | call division_64_bits |
1337 | div ebx |
1337 | div ebx |
1338 | add dl, 48 |
1338 | add dl, 48 |
1339 | mov [edi], dl |
1339 | mov [edi], dl |
1340 | dec edi |
1340 | dec edi |
1341 | loop d_desnum |
1341 | loop d_desnum |
1342 | pop eax |
1342 | pop eax |
1343 | call normalize_number |
1343 | call normalize_number |
1344 | call draw_num_text |
1344 | call draw_num_text |
1345 | add esp, 64 |
1345 | add esp, 64 |
1346 | popad |
1346 | popad |
1347 | ret |
1347 | ret |
1348 | no_display_desnum: |
1348 | no_display_desnum: |
1349 | 1349 | ||
1350 | cmp ah, 0x01 ; HEXADECIMAL |
1350 | cmp ah, 0x01 ; HEXADECIMAL |
1351 | jne no_display_hexnum |
1351 | jne no_display_hexnum |
1352 | shr eax, 16 |
1352 | shr eax, 16 |
1353 | and eax, 0xC03f |
1353 | and eax, 0xC03f |
1354 | ; and eax,0x3f |
1354 | ; and eax,0x3f |
1355 | push eax |
1355 | push eax |
1356 | and eax, 0x3f |
1356 | and eax, 0x3f |
1357 | mov edi, esp |
1357 | mov edi, esp |
1358 | add edi, 4+64-1 |
1358 | add edi, 4+64-1 |
1359 | mov ecx, eax |
1359 | mov ecx, eax |
1360 | mov eax, ebx |
1360 | mov eax, ebx |
1361 | mov ebx, 16 |
1361 | mov ebx, 16 |
1362 | d_hexnum: |
1362 | d_hexnum: |
1363 | xor edx, edx |
1363 | xor edx, edx |
1364 | call division_64_bits |
1364 | call division_64_bits |
1365 | div ebx |
1365 | div ebx |
1366 | hexletters = __fdo_hexdigits |
1366 | hexletters = __fdo_hexdigits |
1367 | add edx, hexletters |
1367 | add edx, hexletters |
1368 | mov dl, [edx] |
1368 | mov dl, [edx] |
1369 | mov [edi], dl |
1369 | mov [edi], dl |
1370 | dec edi |
1370 | dec edi |
1371 | loop d_hexnum |
1371 | loop d_hexnum |
1372 | pop eax |
1372 | pop eax |
1373 | call normalize_number |
1373 | call normalize_number |
1374 | call draw_num_text |
1374 | call draw_num_text |
1375 | add esp, 64 |
1375 | add esp, 64 |
1376 | popad |
1376 | popad |
1377 | ret |
1377 | ret |
1378 | no_display_hexnum: |
1378 | no_display_hexnum: |
1379 | 1379 | ||
1380 | cmp ah, 0x02 ; BINARY |
1380 | cmp ah, 0x02 ; BINARY |
1381 | jne no_display_binnum |
1381 | jne no_display_binnum |
1382 | shr eax, 16 |
1382 | shr eax, 16 |
1383 | and eax, 0xC03f |
1383 | and eax, 0xC03f |
1384 | ; and eax,0x3f |
1384 | ; and eax,0x3f |
1385 | push eax |
1385 | push eax |
1386 | and eax, 0x3f |
1386 | and eax, 0x3f |
1387 | mov edi, esp |
1387 | mov edi, esp |
1388 | add edi, 4+64-1 |
1388 | add edi, 4+64-1 |
1389 | mov ecx, eax |
1389 | mov ecx, eax |
1390 | mov eax, ebx |
1390 | mov eax, ebx |
1391 | mov ebx, 2 |
1391 | mov ebx, 2 |
1392 | d_binnum: |
1392 | d_binnum: |
1393 | xor edx, edx |
1393 | xor edx, edx |
1394 | call division_64_bits |
1394 | call division_64_bits |
1395 | div ebx |
1395 | div ebx |
1396 | add dl, 48 |
1396 | add dl, 48 |
1397 | mov [edi], dl |
1397 | mov [edi], dl |
1398 | dec edi |
1398 | dec edi |
1399 | loop d_binnum |
1399 | loop d_binnum |
1400 | pop eax |
1400 | pop eax |
1401 | call normalize_number |
1401 | call normalize_number |
1402 | call draw_num_text |
1402 | call draw_num_text |
1403 | add esp, 64 |
1403 | add esp, 64 |
1404 | popad |
1404 | popad |
1405 | ret |
1405 | ret |
1406 | no_display_binnum: |
1406 | no_display_binnum: |
1407 | 1407 | ||
1408 | add esp, 64 |
1408 | add esp, 64 |
1409 | popad |
1409 | popad |
1410 | ret |
1410 | ret |
1411 | 1411 | ||
1412 | normalize_number: |
1412 | normalize_number: |
1413 | test ah, 0x80 |
1413 | test ah, 0x80 |
1414 | jz .continue |
1414 | jz .continue |
1415 | mov ecx, 48 |
1415 | mov ecx, 48 |
1416 | and eax, 0x3f |
1416 | and eax, 0x3f |
1417 | @@: |
1417 | @@: |
1418 | inc edi |
1418 | inc edi |
1419 | cmp [edi], cl |
1419 | cmp [edi], cl |
1420 | jne .continue |
1420 | jne .continue |
1421 | dec eax |
1421 | dec eax |
1422 | cmp eax, 1 |
1422 | cmp eax, 1 |
1423 | ja @r |
1423 | ja @r |
1424 | mov al, 1 |
1424 | mov al, 1 |
1425 | .continue: |
1425 | .continue: |
1426 | and eax, 0x3f |
1426 | and eax, 0x3f |
1427 | ret |
1427 | ret |
1428 | 1428 | ||
1429 | division_64_bits: |
1429 | division_64_bits: |
1430 | test [esp+1+4], byte 0x40 |
1430 | test [esp+1+4], byte 0x40 |
1431 | jz .continue |
1431 | jz .continue |
1432 | push eax |
1432 | push eax |
1433 | mov eax, ebp |
1433 | mov eax, ebp |
1434 | div ebx |
1434 | div ebx |
1435 | mov ebp, eax |
1435 | mov ebp, eax |
1436 | pop eax |
1436 | pop eax |
1437 | .continue: |
1437 | .continue: |
1438 | ret |
1438 | ret |
1439 | 1439 | ||
1440 | draw_num_text: |
1440 | draw_num_text: |
1441 | mov esi, eax |
1441 | mov esi, eax |
1442 | mov edx, 64+4 |
1442 | mov edx, 64+4 |
1443 | sub edx, eax |
1443 | sub edx, eax |
1444 | add edx, esp |
1444 | add edx, esp |
1445 | mov ebx, [esp+64+32-8+4] |
1445 | mov ebx, [esp+64+32-8+4] |
1446 | ; add window start x & y |
1446 | ; add window start x & y |
1447 | mov ecx, [TASK_BASE] |
1447 | mov ecx, [TASK_BASE] |
1448 | 1448 | ||
1449 | mov edi, [CURRENT_TASK] |
1449 | mov edi, [CURRENT_TASK] |
1450 | shl edi, 8 |
1450 | shl edi, 8 |
1451 | 1451 | ||
1452 | mov eax, [ecx-twdw+WDATA.box.left] |
1452 | mov eax, [ecx-twdw+WDATA.box.left] |
1453 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1453 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1454 | shl eax, 16 |
1454 | shl eax, 16 |
1455 | add eax, [ecx-twdw+WDATA.box.top] |
1455 | add eax, [ecx-twdw+WDATA.box.top] |
1456 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1456 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1457 | add ebx, eax |
1457 | add ebx, eax |
1458 | mov ecx, [esp+64+32-12+4] |
1458 | mov ecx, [esp+64+32-12+4] |
1459 | and ecx, not 0x80000000 ; force counted string |
1459 | and ecx, not 0x80000000 ; force counted string |
1460 | mov eax, [esp+64+8] ; background color (if given) |
1460 | mov eax, [esp+64+8] ; background color (if given) |
1461 | mov edi, [esp+64+4] |
1461 | mov edi, [esp+64+4] |
1462 | jmp dtext |
1462 | jmp dtext |
1463 | 1463 | ||
1464 | align 4 |
1464 | align 4 |
1465 | 1465 | ||
1466 | sys_setup: |
1466 | sys_setup: |
1467 | 1467 | ||
1468 | ; 1=roland mpu midi base , base io address |
1468 | ; 1=roland mpu midi base , base io address |
1469 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1469 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1470 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1470 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1471 | ; 5=system language, 1eng 2fi 3ger 4rus |
1471 | ; 5=system language, 1eng 2fi 3ger 4rus |
1472 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1472 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1473 | ; 8=fat32 partition in hd |
1473 | ; 8=fat32 partition in hd |
1474 | ; 9 |
1474 | ; 9 |
1475 | ; 10 = sound dma channel |
1475 | ; 10 = sound dma channel |
1476 | ; 11 = enable lba read |
1476 | ; 11 = enable lba read |
1477 | ; 12 = enable pci access |
1477 | ; 12 = enable pci access |
1478 | 1478 | ||
1479 | 1479 | ||
1480 | and [esp+32], dword 0 |
1480 | and [esp+32], dword 0 |
1481 | dec ebx ; MIDI |
1481 | dec ebx ; MIDI |
1482 | jnz nsyse1 |
1482 | jnz nsyse1 |
1483 | cmp ecx, 0x100 |
1483 | cmp ecx, 0x100 |
1484 | 1484 | ||
1485 | jb nsyse1 |
1485 | jb nsyse1 |
1486 | mov esi, 65535 |
1486 | mov esi, 65535 |
1487 | cmp esi, ecx |
1487 | cmp esi, ecx |
1488 | 1488 | ||
1489 | jb nsyse1 |
1489 | jb nsyse1 |
1490 | mov [midi_base], cx ;bx |
1490 | mov [midi_base], cx ;bx |
1491 | mov word [mididp], cx;bx |
1491 | mov word [mididp], cx;bx |
1492 | inc cx ;bx |
1492 | inc cx ;bx |
1493 | mov word [midisp], cx;bx |
1493 | mov word [midisp], cx;bx |
1494 | ret |
1494 | ret |
1495 | 1495 | ||
1496 | iglobal |
1496 | iglobal |
1497 | midi_base dw 0 |
1497 | midi_base dw 0 |
1498 | endg |
1498 | endg |
1499 | 1499 | ||
1500 | nsyse1: |
1500 | nsyse1: |
1501 | dec ebx ; KEYBOARD |
1501 | dec ebx ; KEYBOARD |
1502 | jnz nsyse2 |
1502 | jnz nsyse2 |
1503 | mov edi, [TASK_BASE] |
1503 | mov edi, [TASK_BASE] |
1504 | mov eax, [edi+TASKDATA.mem_start] |
1504 | mov eax, [edi+TASKDATA.mem_start] |
1505 | add eax, edx |
1505 | add eax, edx |
1506 | 1506 | ||
1507 | dec ecx |
1507 | dec ecx |
1508 | jnz kbnobase |
1508 | jnz kbnobase |
1509 | mov ebx, keymap |
1509 | mov ebx, keymap |
1510 | mov ecx, 128 |
1510 | mov ecx, 128 |
1511 | call memmove |
1511 | call memmove |
1512 | ret |
1512 | ret |
1513 | kbnobase: |
1513 | kbnobase: |
1514 | dec ecx |
1514 | dec ecx |
1515 | jnz kbnoshift |
1515 | jnz kbnoshift |
1516 | 1516 | ||
1517 | mov ebx, keymap_shift |
1517 | mov ebx, keymap_shift |
1518 | mov ecx, 128 |
1518 | mov ecx, 128 |
1519 | call memmove |
1519 | call memmove |
1520 | ret |
1520 | ret |
1521 | kbnoshift: |
1521 | kbnoshift: |
1522 | dec ecx |
1522 | dec ecx |
1523 | jnz kbnoalt |
1523 | jnz kbnoalt |
1524 | mov ebx, keymap_alt |
1524 | mov ebx, keymap_alt |
1525 | mov ecx, 128 |
1525 | mov ecx, 128 |
1526 | call memmove |
1526 | call memmove |
1527 | ret |
1527 | ret |
1528 | kbnoalt: |
1528 | kbnoalt: |
1529 | sub ecx, 6 |
1529 | sub ecx, 6 |
1530 | jnz kbnocountry |
1530 | jnz kbnocountry |
1531 | mov word [keyboard], dx |
1531 | mov word [keyboard], dx |
1532 | ret |
1532 | ret |
1533 | kbnocountry: |
1533 | kbnocountry: |
1534 | mov [esp+32], dword 1 |
1534 | mov [esp+32], dword 1 |
1535 | ret |
1535 | ret |
1536 | nsyse2: |
1536 | nsyse2: |
1537 | dec ebx ; CD |
1537 | dec ebx ; CD |
1538 | jnz nsyse4 |
1538 | jnz nsyse4 |
1539 | 1539 | ||
1540 | test ecx, ecx |
1540 | test ecx, ecx |
1541 | jz nosesl |
1541 | jz nosesl |
1542 | 1542 | ||
1543 | cmp ecx, 4 |
1543 | cmp ecx, 4 |
1544 | ja nosesl |
1544 | ja nosesl |
1545 | mov [cd_base], cl |
1545 | mov [cd_base], cl |
1546 | 1546 | ||
1547 | dec ecx |
1547 | dec ecx |
1548 | jnz noprma |
1548 | jnz noprma |
1549 | mov [cdbase], 0x1f0 |
1549 | mov [cdbase], 0x1f0 |
1550 | mov [cdid], 0xa0 |
1550 | mov [cdid], 0xa0 |
1551 | noprma: |
1551 | noprma: |
1552 | 1552 | ||
1553 | dec ecx |
1553 | dec ecx |
1554 | jnz noprsl |
1554 | jnz noprsl |
1555 | mov [cdbase], 0x1f0 |
1555 | mov [cdbase], 0x1f0 |
1556 | mov [cdid], 0xb0 |
1556 | mov [cdid], 0xb0 |
1557 | noprsl: |
1557 | noprsl: |
1558 | dec ecx |
1558 | dec ecx |
1559 | jnz nosema |
1559 | jnz nosema |
1560 | mov [cdbase], 0x170 |
1560 | mov [cdbase], 0x170 |
1561 | mov [cdid], 0xa0 |
1561 | mov [cdid], 0xa0 |
1562 | nosema: |
1562 | nosema: |
1563 | dec ecx |
1563 | dec ecx |
1564 | jnz nosesl |
1564 | jnz nosesl |
1565 | mov [cdbase], 0x170 |
1565 | mov [cdbase], 0x170 |
1566 | mov [cdid], 0xb0 |
1566 | mov [cdid], 0xb0 |
1567 | nosesl: |
1567 | nosesl: |
1568 | ret |
1568 | ret |
1569 | 1569 | ||
1570 | iglobal |
1570 | iglobal |
1571 | cd_base db 0 |
1571 | cd_base db 0 |
1572 | 1572 | ||
1573 | endg |
1573 | endg |
1574 | nsyse4: |
1574 | nsyse4: |
1575 | 1575 | ||
1576 | sub ebx, 2 ; SYSTEM LANGUAGE |
1576 | sub ebx, 2 ; SYSTEM LANGUAGE |
1577 | jnz nsyse5 |
1577 | jnz nsyse5 |
1578 | mov [syslang], ecx |
1578 | mov [syslang], ecx |
1579 | ret |
1579 | ret |
1580 | nsyse5: |
1580 | nsyse5: |
1581 | 1581 | ||
1582 | sub ebx, 2 ; HD BASE |
1582 | sub ebx, 2 ; HD BASE |
1583 | jnz nsyse7 |
1583 | jnz nsyse7 |
1584 | 1584 | ||
1585 | test ecx, ecx |
1585 | test ecx, ecx |
1586 | jz nosethd |
1586 | jz nosethd |
1587 | 1587 | ||
1588 | cmp ecx, 4 |
1588 | cmp ecx, 4 |
1589 | ja nosethd |
1589 | ja nosethd |
1590 | mov [hd_base], cl |
1590 | mov [hd_base], cl |
1591 | 1591 | ||
1592 | cmp ecx, 1 |
1592 | cmp ecx, 1 |
1593 | jnz noprmahd |
1593 | jnz noprmahd |
1594 | mov [hdbase], 0x1f0 |
1594 | mov [hdbase], 0x1f0 |
1595 | and dword [hdid], 0x0 |
1595 | and dword [hdid], 0x0 |
1596 | mov dword [hdpos], ecx |
1596 | mov dword [hdpos], ecx |
1597 | ; call set_FAT32_variables |
1597 | ; call set_FAT32_variables |
1598 | noprmahd: |
1598 | noprmahd: |
1599 | 1599 | ||
1600 | cmp ecx, 2 |
1600 | cmp ecx, 2 |
1601 | jnz noprslhd |
1601 | jnz noprslhd |
1602 | mov [hdbase], 0x1f0 |
1602 | mov [hdbase], 0x1f0 |
1603 | mov [hdid], 0x10 |
1603 | mov [hdid], 0x10 |
1604 | mov dword [hdpos], ecx |
1604 | mov dword [hdpos], ecx |
1605 | ; call set_FAT32_variables |
1605 | ; call set_FAT32_variables |
1606 | noprslhd: |
1606 | noprslhd: |
1607 | 1607 | ||
1608 | cmp ecx, 3 |
1608 | cmp ecx, 3 |
1609 | jnz nosemahd |
1609 | jnz nosemahd |
1610 | mov [hdbase], 0x170 |
1610 | mov [hdbase], 0x170 |
1611 | and dword [hdid], 0x0 |
1611 | and dword [hdid], 0x0 |
1612 | mov dword [hdpos], ecx |
1612 | mov dword [hdpos], ecx |
1613 | ; call set_FAT32_variables |
1613 | ; call set_FAT32_variables |
1614 | nosemahd: |
1614 | nosemahd: |
1615 | 1615 | ||
1616 | cmp ecx, 4 |
1616 | cmp ecx, 4 |
1617 | jnz noseslhd |
1617 | jnz noseslhd |
1618 | mov [hdbase], 0x170 |
1618 | mov [hdbase], 0x170 |
1619 | mov [hdid], 0x10 |
1619 | mov [hdid], 0x10 |
1620 | mov dword [hdpos], ecx |
1620 | mov dword [hdpos], ecx |
1621 | ; call set_FAT32_variables |
1621 | ; call set_FAT32_variables |
1622 | noseslhd: |
1622 | noseslhd: |
1623 | call reserve_hd1 |
1623 | call reserve_hd1 |
1624 | call reserve_hd_channel |
1624 | call reserve_hd_channel |
1625 | call free_hd_channel |
1625 | call free_hd_channel |
1626 | and dword [hd1_status], 0 ; free |
1626 | and dword [hd1_status], 0 ; free |
1627 | nosethd: |
1627 | nosethd: |
1628 | ret |
1628 | ret |
1629 | 1629 | ||
1630 | iglobal |
1630 | iglobal |
1631 | hd_base db 0 |
1631 | hd_base db 0 |
1632 | endg |
1632 | endg |
1633 | 1633 | ||
1634 | nsyse7: |
1634 | nsyse7: |
1635 | 1635 | ||
1636 | ; cmp eax,8 ; HD PARTITION |
1636 | ; cmp eax,8 ; HD PARTITION |
1637 | dec ebx |
1637 | dec ebx |
1638 | jnz nsyse8 |
1638 | jnz nsyse8 |
1639 | mov [fat32part], ecx |
1639 | mov [fat32part], ecx |
1640 | ; call set_FAT32_variables |
1640 | ; call set_FAT32_variables |
1641 | call reserve_hd1 |
1641 | call reserve_hd1 |
1642 | call reserve_hd_channel |
1642 | call reserve_hd_channel |
1643 | call free_hd_channel |
1643 | call free_hd_channel |
1644 | ; pusha |
1644 | ; pusha |
1645 | call choice_necessity_partition_1 |
1645 | call choice_necessity_partition_1 |
1646 | ; popa |
1646 | ; popa |
1647 | and dword [hd1_status], 0 ; free |
1647 | and dword [hd1_status], 0 ; free |
1648 | ret |
1648 | ret |
1649 | 1649 | ||
1650 | nsyse8: |
1650 | nsyse8: |
1651 | ; cmp eax,11 ; ENABLE LBA READ |
1651 | ; cmp eax,11 ; ENABLE LBA READ |
1652 | and ecx, 1 |
1652 | and ecx, 1 |
1653 | sub ebx, 3 |
1653 | sub ebx, 3 |
1654 | jnz no_set_lba_read |
1654 | jnz no_set_lba_read |
1655 | mov [lba_read_enabled], ecx |
1655 | mov [lba_read_enabled], ecx |
1656 | ret |
1656 | ret |
1657 | 1657 | ||
1658 | no_set_lba_read: |
1658 | no_set_lba_read: |
1659 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1659 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1660 | dec ebx |
1660 | dec ebx |
1661 | jnz sys_setup_err |
1661 | jnz sys_setup_err |
1662 | mov [pci_access_enabled], ecx |
1662 | mov [pci_access_enabled], ecx |
1663 | ret |
1663 | ret |
1664 | 1664 | ||
1665 | sys_setup_err: |
1665 | sys_setup_err: |
1666 | or [esp+32], dword -1 |
1666 | or [esp+32], dword -1 |
1667 | ret |
1667 | ret |
1668 | 1668 | ||
1669 | align 4 |
1669 | align 4 |
1670 | 1670 | ||
1671 | sys_getsetup: |
1671 | sys_getsetup: |
1672 | 1672 | ||
1673 | ; 1=roland mpu midi base , base io address |
1673 | ; 1=roland mpu midi base , base io address |
1674 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1674 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1675 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1675 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1676 | ; 5=system language, 1eng 2fi 3ger 4rus |
1676 | ; 5=system language, 1eng 2fi 3ger 4rus |
1677 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1677 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1678 | ; 8=fat32 partition in hd |
1678 | ; 8=fat32 partition in hd |
1679 | ; 9=get hs timer tic |
1679 | ; 9=get hs timer tic |
1680 | 1680 | ||
1681 | ; cmp eax,1 |
1681 | ; cmp eax,1 |
1682 | dec ebx |
1682 | dec ebx |
1683 | jnz ngsyse1 |
1683 | jnz ngsyse1 |
1684 | movzx eax, [midi_base] |
1684 | movzx eax, [midi_base] |
1685 | mov [esp+32], eax |
1685 | mov [esp+32], eax |
1686 | ret |
1686 | ret |
1687 | ngsyse1: |
1687 | ngsyse1: |
1688 | ; cmp eax,2 |
1688 | ; cmp eax,2 |
1689 | dec ebx |
1689 | dec ebx |
1690 | jnz ngsyse2 |
1690 | jnz ngsyse2 |
1691 | 1691 | ||
1692 | mov edi, [TASK_BASE] |
1692 | mov edi, [TASK_BASE] |
1693 | mov ebx, [edi+TASKDATA.mem_start] |
1693 | mov ebx, [edi+TASKDATA.mem_start] |
1694 | add ebx, edx |
1694 | add ebx, edx |
1695 | 1695 | ||
1696 | ; cmp ebx,1 |
1696 | ; cmp ebx,1 |
1697 | dec ecx |
1697 | dec ecx |
1698 | jnz kbnobaseret |
1698 | jnz kbnobaseret |
1699 | mov eax, keymap |
1699 | mov eax, keymap |
1700 | mov ecx, 128 |
1700 | mov ecx, 128 |
1701 | call memmove |
1701 | call memmove |
1702 | ret |
1702 | ret |
1703 | kbnobaseret: |
1703 | kbnobaseret: |
1704 | ; cmp ebx,2 |
1704 | ; cmp ebx,2 |
1705 | dec ecx |
1705 | dec ecx |
1706 | jnz kbnoshiftret |
1706 | jnz kbnoshiftret |
1707 | 1707 | ||
1708 | mov eax, keymap_shift |
1708 | mov eax, keymap_shift |
1709 | mov ecx, 128 |
1709 | mov ecx, 128 |
1710 | call memmove |
1710 | call memmove |
1711 | ret |
1711 | ret |
1712 | kbnoshiftret: |
1712 | kbnoshiftret: |
1713 | ; cmp ebx,3 |
1713 | ; cmp ebx,3 |
1714 | dec ecx |
1714 | dec ecx |
1715 | jne kbnoaltret |
1715 | jne kbnoaltret |
1716 | 1716 | ||
1717 | mov eax, keymap_alt |
1717 | mov eax, keymap_alt |
1718 | mov ecx, 128 |
1718 | mov ecx, 128 |
1719 | call memmove |
1719 | call memmove |
1720 | ret |
1720 | ret |
1721 | kbnoaltret: |
1721 | kbnoaltret: |
1722 | ; cmp ebx,9 |
1722 | ; cmp ebx,9 |
1723 | sub ecx, 6 |
1723 | sub ecx, 6 |
1724 | jnz ngsyse2 |
1724 | jnz ngsyse2 |
1725 | movzx eax, word [keyboard] |
1725 | movzx eax, word [keyboard] |
1726 | mov [esp+32], eax |
1726 | mov [esp+32], eax |
1727 | ret |
1727 | ret |
1728 | 1728 | ||
1729 | 1729 | ||
1730 | ngsyse2: |
1730 | ngsyse2: |
1731 | ; cmp eax,3 |
1731 | ; cmp eax,3 |
1732 | dec ebx |
1732 | dec ebx |
1733 | jnz ngsyse3 |
1733 | jnz ngsyse3 |
1734 | movzx eax, [cd_base] |
1734 | movzx eax, [cd_base] |
1735 | mov [esp+32], eax |
1735 | mov [esp+32], eax |
1736 | ret |
1736 | ret |
1737 | ngsyse3: |
1737 | ngsyse3: |
1738 | ; cmp eax,5 |
1738 | ; cmp eax,5 |
1739 | sub ebx, 2 |
1739 | sub ebx, 2 |
1740 | jnz ngsyse5 |
1740 | jnz ngsyse5 |
1741 | mov eax, [syslang] |
1741 | mov eax, [syslang] |
1742 | mov [esp+32], eax |
1742 | mov [esp+32], eax |
1743 | ret |
1743 | ret |
1744 | ngsyse5: |
1744 | ngsyse5: |
1745 | ; cmp eax,7 |
1745 | ; cmp eax,7 |
1746 | sub ebx, 2 |
1746 | sub ebx, 2 |
1747 | jnz ngsyse7 |
1747 | jnz ngsyse7 |
1748 | movzx eax, [hd_base] |
1748 | movzx eax, [hd_base] |
1749 | mov [esp+32], eax |
1749 | mov [esp+32], eax |
1750 | ret |
1750 | ret |
1751 | ngsyse7: |
1751 | ngsyse7: |
1752 | ; cmp eax,8 |
1752 | ; cmp eax,8 |
1753 | dec ebx |
1753 | dec ebx |
1754 | jnz ngsyse8 |
1754 | jnz ngsyse8 |
1755 | mov eax, [fat32part] |
1755 | mov eax, [fat32part] |
1756 | mov [esp+32], eax |
1756 | mov [esp+32], eax |
1757 | ret |
1757 | ret |
1758 | ngsyse8: |
1758 | ngsyse8: |
1759 | ; cmp eax,9 |
1759 | ; cmp eax,9 |
1760 | dec ebx |
1760 | dec ebx |
1761 | jnz ngsyse9 |
1761 | jnz ngsyse9 |
1762 | mov eax, [timer_ticks];[0xfdf0] |
1762 | mov eax, [timer_ticks];[0xfdf0] |
1763 | mov [esp+32], eax |
1763 | mov [esp+32], eax |
1764 | ret |
1764 | ret |
1765 | ngsyse9: |
1765 | ngsyse9: |
1766 | ; cmp eax,11 |
1766 | ; cmp eax,11 |
1767 | sub ebx, 2 |
1767 | sub ebx, 2 |
1768 | jnz ngsyse11 |
1768 | jnz ngsyse11 |
1769 | mov eax, [lba_read_enabled] |
1769 | mov eax, [lba_read_enabled] |
1770 | mov [esp+32], eax |
1770 | mov [esp+32], eax |
1771 | ret |
1771 | ret |
1772 | ngsyse11: |
1772 | ngsyse11: |
1773 | ; cmp eax,12 |
1773 | ; cmp eax,12 |
1774 | dec ebx |
1774 | dec ebx |
1775 | jnz ngsyse12 |
1775 | jnz ngsyse12 |
1776 | mov eax, [pci_access_enabled] |
1776 | mov eax, [pci_access_enabled] |
1777 | mov [esp+32], eax |
1777 | mov [esp+32], eax |
1778 | ret |
1778 | ret |
1779 | ngsyse12: |
1779 | ngsyse12: |
1780 | mov [esp+32], dword 1 |
1780 | mov [esp+32], dword 1 |
1781 | ret |
1781 | ret |
1782 | 1782 | ||
1783 | 1783 | ||
1784 | get_timer_ticks: |
1784 | get_timer_ticks: |
1785 | mov eax, [timer_ticks] |
1785 | mov eax, [timer_ticks] |
1786 | ret |
1786 | ret |
1787 | 1787 | ||
1788 | iglobal |
1788 | iglobal |
1789 | align 4 |
1789 | align 4 |
1790 | mousefn dd msscreen, mswin, msbutton, msset |
1790 | mousefn dd msscreen, mswin, msbutton, msset |
1791 | dd app_load_cursor |
1791 | dd app_load_cursor |
1792 | dd app_set_cursor |
1792 | dd app_set_cursor |
1793 | dd app_delete_cursor |
1793 | dd app_delete_cursor |
1794 | dd msz |
1794 | dd msz |
1795 | endg |
1795 | endg |
1796 | 1796 | ||
1797 | readmousepos: |
1797 | readmousepos: |
1798 | 1798 | ||
1799 | ; eax=0 screen relative |
1799 | ; eax=0 screen relative |
1800 | ; eax=1 window relative |
1800 | ; eax=1 window relative |
1801 | ; eax=2 buttons pressed |
1801 | ; eax=2 buttons pressed |
1802 | ; eax=3 set mouse pos ; reserved |
1802 | ; eax=3 set mouse pos ; reserved |
1803 | ; eax=4 load cursor |
1803 | ; eax=4 load cursor |
1804 | ; eax=5 set cursor |
1804 | ; eax=5 set cursor |
1805 | ; eax=6 delete cursor ; reserved |
1805 | ; eax=6 delete cursor ; reserved |
1806 | ; eax=7 get mouse_z |
1806 | ; eax=7 get mouse_z |
1807 | 1807 | ||
1808 | cmp ebx, 7 |
1808 | cmp ebx, 7 |
1809 | ja msset |
1809 | ja msset |
1810 | jmp [mousefn+ebx*4] |
1810 | jmp [mousefn+ebx*4] |
1811 | msscreen: |
1811 | msscreen: |
1812 | mov eax, [MOUSE_X] |
1812 | mov eax, [MOUSE_X] |
1813 | shl eax, 16 |
1813 | shl eax, 16 |
1814 | mov ax, [MOUSE_Y] |
1814 | mov ax, [MOUSE_Y] |
1815 | mov [esp+36-4], eax |
1815 | mov [esp+36-4], eax |
1816 | ret |
1816 | ret |
1817 | mswin: |
1817 | mswin: |
1818 | mov eax, [MOUSE_X] |
1818 | mov eax, [MOUSE_X] |
1819 | shl eax, 16 |
1819 | shl eax, 16 |
1820 | mov ax, [MOUSE_Y] |
1820 | mov ax, [MOUSE_Y] |
1821 | mov esi, [TASK_BASE] |
1821 | mov esi, [TASK_BASE] |
1822 | mov bx, word [esi-twdw+WDATA.box.left] |
1822 | mov bx, word [esi-twdw+WDATA.box.left] |
1823 | shl ebx, 16 |
1823 | shl ebx, 16 |
1824 | mov bx, word [esi-twdw+WDATA.box.top] |
1824 | mov bx, word [esi-twdw+WDATA.box.top] |
1825 | sub eax, ebx |
1825 | sub eax, ebx |
1826 | 1826 | ||
1827 | mov edi, [CURRENT_TASK] |
1827 | mov edi, [CURRENT_TASK] |
1828 | shl edi, 8 |
1828 | shl edi, 8 |
1829 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1829 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1830 | rol eax, 16 |
1830 | rol eax, 16 |
1831 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1831 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1832 | rol eax, 16 |
1832 | rol eax, 16 |
1833 | mov [esp+36-4], eax |
1833 | mov [esp+36-4], eax |
1834 | ret |
1834 | ret |
1835 | msbutton: |
1835 | msbutton: |
1836 | movzx eax, byte [BTN_DOWN] |
1836 | movzx eax, byte [BTN_DOWN] |
1837 | mov [esp+36-4], eax |
1837 | mov [esp+36-4], eax |
1838 | ret |
1838 | ret |
1839 | msz: |
1839 | msz: |
1840 | mov edi, [TASK_COUNT] |
1840 | mov edi, [TASK_COUNT] |
1841 | movzx edi, word [WIN_POS + edi*2] |
1841 | movzx edi, word [WIN_POS + edi*2] |
1842 | cmp edi, [CURRENT_TASK] |
1842 | cmp edi, [CURRENT_TASK] |
1843 | jne @f |
1843 | jne @f |
1844 | mov ax, [MOUSE_SCROLL_H] |
1844 | mov ax, [MOUSE_SCROLL_H] |
1845 | shl eax, 16 |
1845 | shl eax, 16 |
1846 | mov ax, [MOUSE_SCROLL_V] |
1846 | mov ax, [MOUSE_SCROLL_V] |
1847 | mov [esp+36-4], eax |
1847 | mov [esp+36-4], eax |
1848 | and [MOUSE_SCROLL_H], word 0 |
1848 | and [MOUSE_SCROLL_H], word 0 |
1849 | and [MOUSE_SCROLL_V], word 0 |
1849 | and [MOUSE_SCROLL_V], word 0 |
1850 | ret |
1850 | ret |
1851 | @@: |
1851 | @@: |
1852 | and [esp+36-4], dword 0 |
1852 | and [esp+36-4], dword 0 |
1853 | ; ret |
1853 | ; ret |
1854 | msset: |
1854 | msset: |
1855 | ret |
1855 | ret |
1856 | 1856 | ||
1857 | app_load_cursor: |
1857 | app_load_cursor: |
1858 | cmp ecx, OS_BASE |
1858 | cmp ecx, OS_BASE |
1859 | jae msset |
1859 | jae msset |
1860 | stdcall load_cursor, ecx, edx |
1860 | stdcall load_cursor, ecx, edx |
1861 | mov [esp+36-4], eax |
1861 | mov [esp+36-4], eax |
1862 | ret |
1862 | ret |
1863 | 1863 | ||
1864 | app_set_cursor: |
1864 | app_set_cursor: |
1865 | stdcall set_cursor, ecx |
1865 | stdcall set_cursor, ecx |
1866 | mov [esp+36-4], eax |
1866 | mov [esp+36-4], eax |
1867 | ret |
1867 | ret |
1868 | 1868 | ||
1869 | app_delete_cursor: |
1869 | app_delete_cursor: |
1870 | stdcall delete_cursor, ecx |
1870 | stdcall delete_cursor, ecx |
1871 | mov [esp+36-4], eax |
1871 | mov [esp+36-4], eax |
1872 | ret |
1872 | ret |
1873 | 1873 | ||
1874 | is_input: |
1874 | is_input: |
1875 | 1875 | ||
1876 | push edx |
1876 | push edx |
1877 | mov dx, word [midisp] |
1877 | mov dx, word [midisp] |
1878 | in al, dx |
1878 | in al, dx |
1879 | and al, 0x80 |
1879 | and al, 0x80 |
1880 | pop edx |
1880 | pop edx |
1881 | ret |
1881 | ret |
1882 | 1882 | ||
1883 | is_output: |
1883 | is_output: |
1884 | 1884 | ||
1885 | push edx |
1885 | push edx |
1886 | mov dx, word [midisp] |
1886 | mov dx, word [midisp] |
1887 | in al, dx |
1887 | in al, dx |
1888 | and al, 0x40 |
1888 | and al, 0x40 |
1889 | pop edx |
1889 | pop edx |
1890 | ret |
1890 | ret |
1891 | 1891 | ||
1892 | 1892 | ||
1893 | get_mpu_in: |
1893 | get_mpu_in: |
1894 | 1894 | ||
1895 | push edx |
1895 | push edx |
1896 | mov dx, word [mididp] |
1896 | mov dx, word [mididp] |
1897 | in al, dx |
1897 | in al, dx |
1898 | pop edx |
1898 | pop edx |
1899 | ret |
1899 | ret |
1900 | 1900 | ||
1901 | 1901 | ||
1902 | put_mpu_out: |
1902 | put_mpu_out: |
1903 | 1903 | ||
1904 | push edx |
1904 | push edx |
1905 | mov dx, word [mididp] |
1905 | mov dx, word [mididp] |
1906 | out dx, al |
1906 | out dx, al |
1907 | pop edx |
1907 | pop edx |
1908 | ret |
1908 | ret |
1909 | 1909 | ||
1910 | 1910 | ||
1911 | 1911 | ||
1912 | align 4 |
1912 | align 4 |
1913 | 1913 | ||
1914 | sys_midi: |
1914 | sys_midi: |
1915 | cmp [mididp], 0 |
1915 | cmp [mididp], 0 |
1916 | jnz sm0 |
1916 | jnz sm0 |
1917 | mov [esp+36], dword 1 |
1917 | mov [esp+36], dword 1 |
1918 | ret |
1918 | ret |
1919 | sm0: |
1919 | sm0: |
1920 | and [esp+36], dword 0 |
1920 | and [esp+36], dword 0 |
1921 | dec ebx |
1921 | dec ebx |
1922 | jnz smn1 |
1922 | jnz smn1 |
1923 | ; call setuart |
1923 | ; call setuart |
1924 | su1: |
1924 | su1: |
1925 | call is_output |
1925 | call is_output |
1926 | test al, al |
1926 | test al, al |
1927 | jnz su1 |
1927 | jnz su1 |
1928 | mov dx, word [midisp] |
1928 | mov dx, word [midisp] |
1929 | mov al, 0xff |
1929 | mov al, 0xff |
1930 | out dx, al |
1930 | out dx, al |
1931 | su2: |
1931 | su2: |
1932 | mov dx, word [midisp] |
1932 | mov dx, word [midisp] |
1933 | mov al, 0xff |
1933 | mov al, 0xff |
1934 | out dx, al |
1934 | out dx, al |
1935 | call is_input |
1935 | call is_input |
1936 | test al, al |
1936 | test al, al |
1937 | jnz su2 |
1937 | jnz su2 |
1938 | call get_mpu_in |
1938 | call get_mpu_in |
1939 | cmp al, 0xfe |
1939 | cmp al, 0xfe |
1940 | jnz su2 |
1940 | jnz su2 |
1941 | su3: |
1941 | su3: |
1942 | call is_output |
1942 | call is_output |
1943 | test al, al |
1943 | test al, al |
1944 | jnz su3 |
1944 | jnz su3 |
1945 | mov dx, word [midisp] |
1945 | mov dx, word [midisp] |
1946 | mov al, 0x3f |
1946 | mov al, 0x3f |
1947 | out dx, al |
1947 | out dx, al |
1948 | ret |
1948 | ret |
1949 | smn1: |
1949 | smn1: |
1950 | dec ebx |
1950 | dec ebx |
1951 | jnz smn2 |
1951 | jnz smn2 |
1952 | sm10: |
1952 | sm10: |
1953 | call get_mpu_in |
1953 | call get_mpu_in |
1954 | call is_output |
1954 | call is_output |
1955 | test al, al |
1955 | test al, al |
1956 | jnz sm10 |
1956 | jnz sm10 |
1957 | mov al, bl |
1957 | mov al, bl |
1958 | call put_mpu_out |
1958 | call put_mpu_out |
1959 | smn2: |
1959 | smn2: |
1960 | ret |
1960 | ret |
1961 | 1961 | ||
1962 | detect_devices: |
1962 | detect_devices: |
1963 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1963 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1964 | ;include 'detect/commouse.inc' |
1964 | ;include 'detect/commouse.inc' |
1965 | ;include 'detect/ps2mouse.inc' |
1965 | ;include 'detect/ps2mouse.inc' |
1966 | ;include 'detect/dev_fd.inc' |
1966 | ;include 'detect/dev_fd.inc' |
1967 | ;include 'detect/dev_hdcd.inc' |
1967 | ;include 'detect/dev_hdcd.inc' |
1968 | ;include 'detect/sear_par.inc' |
1968 | ;include 'detect/sear_par.inc' |
1969 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1969 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1970 | ret |
1970 | ret |
1971 | 1971 | ||
1972 | sys_end: |
1972 | sys_end: |
1973 | ;-------------------------------------- |
1973 | ;-------------------------------------- |
1974 | cmp [_display.select_cursor], 0 |
1974 | cmp [_display.select_cursor], 0 |
1975 | je @f |
1975 | je @f |
1976 | ; restore default cursor before killing |
1976 | ; restore default cursor before killing |
1977 | pusha |
1977 | pusha |
1978 | mov ecx, [current_slot] |
1978 | mov ecx, [current_slot] |
1979 | call restore_default_cursor_before_killing |
1979 | call restore_default_cursor_before_killing |
1980 | popa |
1980 | popa |
1981 | @@: |
1981 | @@: |
1982 | ;-------------------------------------- |
1982 | ;-------------------------------------- |
1983 | mov ecx, [current_slot] |
1983 | mov ecx, [current_slot] |
1984 | mov eax, [ecx+APPDATA.tls_base] |
1984 | mov eax, [ecx+APPDATA.tls_base] |
1985 | test eax, eax |
1985 | test eax, eax |
1986 | jz @F |
1986 | jz @F |
1987 | 1987 | ||
1988 | stdcall user_free, eax |
1988 | stdcall user_free, eax |
1989 | @@: |
1989 | @@: |
1990 | 1990 | ||
1991 | mov eax, [TASK_BASE] |
1991 | mov eax, [TASK_BASE] |
1992 | mov [eax+TASKDATA.state], 3; terminate this program |
1992 | mov [eax+TASKDATA.state], 3; terminate this program |
1993 | 1993 | ||
1994 | waitterm: ; wait here for termination |
1994 | waitterm: ; wait here for termination |
1995 | mov ebx, 100 |
1995 | mov ebx, 100 |
1996 | call delay_hs |
1996 | call delay_hs |
1997 | jmp waitterm |
1997 | jmp waitterm |
1998 | ;------------------------------------------------------------------------------ |
1998 | ;------------------------------------------------------------------------------ |
1999 | align 4 |
1999 | align 4 |
2000 | restore_default_cursor_before_killing: |
2000 | restore_default_cursor_before_killing: |
2001 | pushfd |
2001 | pushfd |
2002 | cli |
2002 | cli |
2003 | mov eax, [def_cursor] |
2003 | mov eax, [def_cursor] |
2004 | mov [ecx+APPDATA.cursor], eax |
2004 | mov [ecx+APPDATA.cursor], eax |
2005 | 2005 | ||
2006 | movzx eax, word [MOUSE_Y] |
2006 | movzx eax, word [MOUSE_Y] |
2007 | movzx ebx, word [MOUSE_X] |
2007 | movzx ebx, word [MOUSE_X] |
2008 | ; mov ecx, [Screen_Max_X] |
2008 | ; mov ecx, [Screen_Max_X] |
2009 | ; inc ecx |
2009 | ; inc ecx |
2010 | ; mul ecx |
2010 | ; mul ecx |
2011 | mov eax, [d_width_calc_area + eax*4] |
2011 | mov eax, [d_width_calc_area + eax*4] |
2012 | 2012 | ||
2013 | add eax, [_WinMapAddress] |
2013 | add eax, [_WinMapAddress] |
2014 | movzx edx, byte [ebx+eax] |
2014 | movzx edx, byte [ebx+eax] |
2015 | shl edx, 8 |
2015 | shl edx, 8 |
2016 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2016 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2017 | 2017 | ||
2018 | cmp esi, [current_cursor] |
2018 | cmp esi, [current_cursor] |
2019 | je @f |
2019 | je @f |
2020 | 2020 | ||
2021 | push esi |
2021 | push esi |
2022 | call [_display.select_cursor] |
2022 | call [_display.select_cursor] |
2023 | mov [current_cursor], esi |
2023 | mov [current_cursor], esi |
2024 | @@: |
2024 | @@: |
2025 | mov [redrawmouse_unconditional], 1 |
2025 | mov [redrawmouse_unconditional], 1 |
2026 | popfd |
2026 | popfd |
2027 | ; call [draw_pointer] |
2027 | ; call [draw_pointer] |
2028 | call __sys_draw_pointer |
2028 | call __sys_draw_pointer |
2029 | ret |
2029 | ret |
2030 | ;------------------------------------------------------------------------------ |
2030 | ;------------------------------------------------------------------------------ |
2031 | iglobal |
2031 | iglobal |
2032 | align 4 |
2032 | align 4 |
2033 | sys_system_table: |
2033 | sys_system_table: |
2034 | dd sysfn_deactivate ; 1 = deactivate window |
2034 | dd sysfn_deactivate ; 1 = deactivate window |
2035 | dd sysfn_terminate ; 2 = terminate thread |
2035 | dd sysfn_terminate ; 2 = terminate thread |
2036 | dd sysfn_activate ; 3 = activate window |
2036 | dd sysfn_activate ; 3 = activate window |
2037 | dd sysfn_getidletime ; 4 = get idle time |
2037 | dd sysfn_getidletime ; 4 = get idle time |
2038 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2038 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2039 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2039 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2040 | dd sysfn_getactive ; 7 = get active window |
2040 | dd sysfn_getactive ; 7 = get active window |
2041 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2041 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2042 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2042 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2043 | dd sysfn_minimize ; 10 = minimize window |
2043 | dd sysfn_minimize ; 10 = minimize window |
2044 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2044 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2045 | dd sysfn_lastkey ; 12 = get last pressed key |
2045 | dd sysfn_lastkey ; 12 = get last pressed key |
2046 | dd sysfn_getversion ; 13 = get kernel version |
2046 | dd sysfn_getversion ; 13 = get kernel version |
2047 | dd sysfn_waitretrace ; 14 = wait retrace |
2047 | dd sysfn_waitretrace ; 14 = wait retrace |
2048 | dd sysfn_centermouse ; 15 = center mouse cursor |
2048 | dd sysfn_centermouse ; 15 = center mouse cursor |
2049 | dd sysfn_getfreemem ; 16 = get free memory size |
2049 | dd sysfn_getfreemem ; 16 = get free memory size |
2050 | dd sysfn_getallmem ; 17 = get total memory size |
2050 | dd sysfn_getallmem ; 17 = get total memory size |
2051 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2051 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2052 | ; instead of slot |
2052 | ; instead of slot |
2053 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2053 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2054 | dd sysfn_meminfo ; 20 = get extended memory info |
2054 | dd sysfn_meminfo ; 20 = get extended memory info |
2055 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2055 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2056 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2056 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2057 | sysfn_num = ($ - sys_system_table)/4 |
2057 | sysfn_num = ($ - sys_system_table)/4 |
2058 | endg |
2058 | endg |
2059 | ;------------------------------------------------------------------------------ |
2059 | ;------------------------------------------------------------------------------ |
2060 | sys_system: |
2060 | sys_system: |
2061 | dec ebx |
2061 | dec ebx |
2062 | cmp ebx, sysfn_num |
2062 | cmp ebx, sysfn_num |
2063 | jae @f |
2063 | jae @f |
2064 | jmp dword [sys_system_table + ebx*4] |
2064 | jmp dword [sys_system_table + ebx*4] |
2065 | @@: |
2065 | @@: |
2066 | ret |
2066 | ret |
2067 | ;------------------------------------------------------------------------------ |
2067 | ;------------------------------------------------------------------------------ |
2068 | sysfn_shutdown: ; 18.9 = system shutdown |
2068 | sysfn_shutdown: ; 18.9 = system shutdown |
2069 | cmp ecx, 1 |
2069 | cmp ecx, 1 |
2070 | jl exit_for_anyone |
2070 | jl exit_for_anyone |
2071 | cmp ecx, 4 |
2071 | cmp ecx, 4 |
2072 | jg exit_for_anyone |
2072 | jg exit_for_anyone |
2073 | mov [BOOT_VAR+0x9030], cl |
2073 | mov [BOOT_VAR+0x9030], cl |
2074 | 2074 | ||
2075 | mov eax, [TASK_COUNT] |
2075 | mov eax, [TASK_COUNT] |
2076 | mov [SYS_SHUTDOWN], al |
2076 | mov [SYS_SHUTDOWN], al |
2077 | mov [shutdown_processes], eax |
2077 | mov [shutdown_processes], eax |
2078 | and dword [esp+32], 0 |
2078 | and dword [esp+32], 0 |
2079 | exit_for_anyone: |
2079 | exit_for_anyone: |
2080 | ret |
2080 | ret |
2081 | uglobal |
2081 | uglobal |
2082 | shutdown_processes: |
2082 | shutdown_processes: |
2083 | dd 0x0 |
2083 | dd 0x0 |
2084 | endg |
2084 | endg |
2085 | ;------------------------------------------------------------------------------ |
2085 | ;------------------------------------------------------------------------------ |
2086 | sysfn_terminate: ; 18.2 = TERMINATE |
2086 | sysfn_terminate: ; 18.2 = TERMINATE |
2087 | push ecx |
2087 | push ecx |
2088 | cmp ecx, 2 |
2088 | cmp ecx, 2 |
2089 | jb noprocessterminate |
2089 | jb noprocessterminate |
2090 | mov edx, [TASK_COUNT] |
2090 | mov edx, [TASK_COUNT] |
2091 | cmp ecx, edx |
2091 | cmp ecx, edx |
2092 | ja noprocessterminate |
2092 | ja noprocessterminate |
2093 | mov eax, [TASK_COUNT] |
2093 | mov eax, [TASK_COUNT] |
2094 | shl ecx, 5 |
2094 | shl ecx, 5 |
2095 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2095 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2096 | add ecx, CURRENT_TASK+TASKDATA.state |
2096 | add ecx, CURRENT_TASK+TASKDATA.state |
2097 | cmp byte [ecx], 9 |
2097 | cmp byte [ecx], 9 |
2098 | jz noprocessterminate |
2098 | jz noprocessterminate |
2099 | ;-------------------------------------- |
2099 | ;-------------------------------------- |
2100 | cmp [_display.select_cursor], 0 |
2100 | cmp [_display.select_cursor], 0 |
2101 | je .restore_end |
2101 | je .restore_end |
2102 | ; restore default cursor before killing |
2102 | ; restore default cursor before killing |
2103 | pusha |
2103 | pusha |
2104 | mov ecx, [esp+32] |
2104 | mov ecx, [esp+32] |
2105 | shl ecx, 8 |
2105 | shl ecx, 8 |
2106 | add ecx, SLOT_BASE |
2106 | add ecx, SLOT_BASE |
2107 | mov eax, [def_cursor] |
2107 | mov eax, [def_cursor] |
2108 | cmp [ecx+APPDATA.cursor], eax |
2108 | cmp [ecx+APPDATA.cursor], eax |
2109 | je @f |
2109 | je @f |
2110 | call restore_default_cursor_before_killing |
2110 | call restore_default_cursor_before_killing |
2111 | @@: |
2111 | @@: |
2112 | popa |
2112 | popa |
2113 | .restore_end: |
2113 | .restore_end: |
2114 | ;-------------------------------------- |
2114 | ;-------------------------------------- |
2115 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2115 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2116 | mov [ecx], byte 3; clear possible i40's |
2116 | mov [ecx], byte 3; clear possible i40's |
2117 | ;call MEM_Heap_UnLock |
2117 | ;call MEM_Heap_UnLock |
2118 | 2118 | ||
2119 | cmp edx, [application_table_status]; clear app table stat |
2119 | cmp edx, [application_table_status]; clear app table stat |
2120 | jne noatsc |
2120 | jne noatsc |
2121 | and [application_table_status], 0 |
2121 | and [application_table_status], 0 |
2122 | noatsc: |
2122 | noatsc: |
2123 | noprocessterminate: |
2123 | noprocessterminate: |
2124 | add esp, 4 |
2124 | add esp, 4 |
2125 | ret |
2125 | ret |
2126 | ;------------------------------------------------------------------------------ |
2126 | ;------------------------------------------------------------------------------ |
2127 | sysfn_terminate2: |
2127 | sysfn_terminate2: |
2128 | ;lock application_table_status mutex |
2128 | ;lock application_table_status mutex |
2129 | .table_status: |
2129 | .table_status: |
2130 | cli |
2130 | cli |
2131 | cmp [application_table_status], 0 |
2131 | cmp [application_table_status], 0 |
2132 | je .stf |
2132 | je .stf |
2133 | sti |
2133 | sti |
2134 | call change_task |
2134 | call change_task |
2135 | jmp .table_status |
2135 | jmp .table_status |
2136 | .stf: |
2136 | .stf: |
2137 | call set_application_table_status |
2137 | call set_application_table_status |
2138 | mov eax, ecx |
2138 | mov eax, ecx |
2139 | call pid_to_slot |
2139 | call pid_to_slot |
2140 | test eax, eax |
2140 | test eax, eax |
2141 | jz .not_found |
2141 | jz .not_found |
2142 | mov ecx, eax |
2142 | mov ecx, eax |
2143 | cli |
2143 | cli |
2144 | call sysfn_terminate |
2144 | call sysfn_terminate |
2145 | and [application_table_status], 0 |
2145 | and [application_table_status], 0 |
2146 | sti |
2146 | sti |
2147 | and dword [esp+32], 0 |
2147 | and dword [esp+32], 0 |
2148 | ret |
2148 | ret |
2149 | .not_found: |
2149 | .not_found: |
2150 | mov [application_table_status], 0 |
2150 | mov [application_table_status], 0 |
2151 | or dword [esp+32], -1 |
2151 | or dword [esp+32], -1 |
2152 | ret |
2152 | ret |
2153 | ;------------------------------------------------------------------------------ |
2153 | ;------------------------------------------------------------------------------ |
2154 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2154 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2155 | cmp ecx, 2 |
2155 | cmp ecx, 2 |
2156 | jb .nowindowdeactivate |
2156 | jb .nowindowdeactivate |
2157 | cmp ecx, [TASK_COUNT] |
2157 | cmp ecx, [TASK_COUNT] |
2158 | ja .nowindowdeactivate |
2158 | ja .nowindowdeactivate |
2159 | 2159 | ||
2160 | movzx esi, word [WIN_STACK + ecx*2] |
2160 | movzx esi, word [WIN_STACK + ecx*2] |
2161 | cmp esi, 1 |
2161 | cmp esi, 1 |
2162 | je .nowindowdeactivate ; already deactive |
2162 | je .nowindowdeactivate ; already deactive |
2163 | 2163 | ||
2164 | mov edi, ecx |
2164 | mov edi, ecx |
2165 | shl edi, 5 |
2165 | shl edi, 5 |
2166 | add edi, window_data |
2166 | add edi, window_data |
2167 | movzx esi, word [WIN_STACK + ecx * 2] |
2167 | movzx esi, word [WIN_STACK + ecx * 2] |
2168 | lea esi, [WIN_POS + esi * 2] |
2168 | lea esi, [WIN_POS + esi * 2] |
2169 | call window._.window_deactivate |
2169 | call window._.window_deactivate |
2170 | 2170 | ||
2171 | xor eax, eax |
2171 | xor eax, eax |
2172 | mov byte[MOUSE_BACKGROUND], al |
2172 | mov byte[MOUSE_BACKGROUND], al |
2173 | mov byte[DONT_DRAW_MOUSE], al |
2173 | mov byte[DONT_DRAW_MOUSE], al |
2174 | mov byte[MOUSE_DOWN], 0 |
2174 | mov byte[MOUSE_DOWN], 0 |
2175 | 2175 | ||
2176 | call syscall_display_settings._.calculate_whole_screen |
2176 | call syscall_display_settings._.calculate_whole_screen |
2177 | call syscall_display_settings._.redraw_whole_screen |
2177 | call syscall_display_settings._.redraw_whole_screen |
2178 | .nowindowdeactivate: |
2178 | .nowindowdeactivate: |
2179 | ret |
2179 | ret |
2180 | ;------------------------------------------------------------------------------ |
2180 | ;------------------------------------------------------------------------------ |
2181 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2181 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2182 | cmp ecx, 2 |
2182 | cmp ecx, 2 |
2183 | jb .nowindowactivate |
2183 | jb .nowindowactivate |
2184 | cmp ecx, [TASK_COUNT] |
2184 | cmp ecx, [TASK_COUNT] |
2185 | ja .nowindowactivate |
2185 | ja .nowindowactivate |
2186 | 2186 | ||
2187 | mov [window_minimize], 2; restore window if minimized |
2187 | mov [window_minimize], 2; restore window if minimized |
2188 | 2188 | ||
2189 | movzx esi, word [WIN_STACK + ecx*2] |
2189 | movzx esi, word [WIN_STACK + ecx*2] |
2190 | cmp esi, [TASK_COUNT] |
2190 | cmp esi, [TASK_COUNT] |
2191 | je .nowindowactivate; already active |
2191 | je .nowindowactivate; already active |
2192 | 2192 | ||
2193 | mov edi, ecx |
2193 | mov edi, ecx |
2194 | shl edi, 5 |
2194 | shl edi, 5 |
2195 | add edi, window_data |
2195 | add edi, window_data |
2196 | movzx esi, word [WIN_STACK + ecx * 2] |
2196 | movzx esi, word [WIN_STACK + ecx * 2] |
2197 | lea esi, [WIN_POS + esi * 2] |
2197 | lea esi, [WIN_POS + esi * 2] |
2198 | call waredraw |
2198 | call waredraw |
2199 | .nowindowactivate: |
2199 | .nowindowactivate: |
2200 | ret |
2200 | ret |
2201 | ;------------------------------------------------------------------------------ |
2201 | ;------------------------------------------------------------------------------ |
2202 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2202 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2203 | mov eax, [idleusesec] |
2203 | mov eax, [idleusesec] |
2204 | mov [esp+32], eax |
2204 | mov [esp+32], eax |
2205 | ret |
2205 | ret |
2206 | ;------------------------------------------------------------------------------ |
2206 | ;------------------------------------------------------------------------------ |
2207 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2207 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2208 | mov eax, [CPU_FREQ] |
2208 | mov eax, [CPU_FREQ] |
2209 | mov [esp+32], eax |
2209 | mov [esp+32], eax |
2210 | ret |
2210 | ret |
2211 | ;------------------------------------------------------------------------------ |
2211 | ;------------------------------------------------------------------------------ |
2212 | ; SAVE ramdisk to /hd/1/menuet.img |
2212 | ; SAVE ramdisk to /hd/1/menuet.img |
2213 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2213 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2214 | include 'blkdev/rdsave.inc' |
2214 | include 'blkdev/rdsave.inc' |
2215 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2215 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2216 | ;------------------------------------------------------------------------------ |
2216 | ;------------------------------------------------------------------------------ |
2217 | align 4 |
2217 | align 4 |
2218 | sysfn_getactive: ; 18.7 = get active window |
2218 | sysfn_getactive: ; 18.7 = get active window |
2219 | mov eax, [TASK_COUNT] |
2219 | mov eax, [TASK_COUNT] |
2220 | movzx eax, word [WIN_POS + eax*2] |
2220 | movzx eax, word [WIN_POS + eax*2] |
2221 | mov [esp+32], eax |
2221 | mov [esp+32], eax |
2222 | ret |
2222 | ret |
2223 | ;------------------------------------------------------------------------------ |
2223 | ;------------------------------------------------------------------------------ |
2224 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2224 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2225 | ; cmp ecx,1 |
2225 | ; cmp ecx,1 |
2226 | dec ecx |
2226 | dec ecx |
2227 | jnz nogetsoundflag |
2227 | jnz nogetsoundflag |
2228 | movzx eax, byte [sound_flag]; get sound_flag |
2228 | movzx eax, byte [sound_flag]; get sound_flag |
2229 | mov [esp+32], eax |
2229 | mov [esp+32], eax |
2230 | ret |
2230 | ret |
2231 | nogetsoundflag: |
2231 | nogetsoundflag: |
2232 | ; cmp ecx,2 |
2232 | ; cmp ecx,2 |
2233 | dec ecx |
2233 | dec ecx |
2234 | jnz nosoundflag |
2234 | jnz nosoundflag |
2235 | xor byte [sound_flag], 1 |
2235 | xor byte [sound_flag], 1 |
2236 | nosoundflag: |
2236 | nosoundflag: |
2237 | ret |
2237 | ret |
2238 | ;------------------------------------------------------------------------------ |
2238 | ;------------------------------------------------------------------------------ |
2239 | sysfn_minimize: ; 18.10 = minimize window |
2239 | sysfn_minimize: ; 18.10 = minimize window |
2240 | mov [window_minimize], 1 |
2240 | mov [window_minimize], 1 |
2241 | ret |
2241 | ret |
2242 | ;------------------------------------------------------------------------------ |
2242 | ;------------------------------------------------------------------------------ |
2243 | align 4 |
2243 | align 4 |
2244 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2244 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2245 | ; cmp ecx,1 |
2245 | ; cmp ecx,1 |
2246 | dec ecx |
2246 | dec ecx |
2247 | jnz full_table |
2247 | jnz full_table |
2248 | small_table: |
2248 | small_table: |
2249 | call for_all_tables |
2249 | call for_all_tables |
2250 | mov ecx, 10 |
2250 | mov ecx, 10 |
2251 | cld |
2251 | cld |
2252 | rep movsb |
2252 | rep movsb |
2253 | ret |
2253 | ret |
2254 | for_all_tables: |
2254 | for_all_tables: |
2255 | mov edi, edx |
2255 | mov edi, edx |
2256 | mov esi, DRIVE_DATA |
2256 | mov esi, DRIVE_DATA |
2257 | ret |
2257 | ret |
2258 | full_table: |
2258 | full_table: |
2259 | ; cmp ecx,2 |
2259 | ; cmp ecx,2 |
2260 | dec ecx |
2260 | dec ecx |
2261 | jnz exit_for_anyone |
2261 | jnz exit_for_anyone |
2262 | call for_all_tables |
2262 | call for_all_tables |
2263 | mov ecx, 16384 |
2263 | mov ecx, 16384 |
2264 | cld |
2264 | cld |
2265 | rep movsd |
2265 | rep movsd |
2266 | ret |
2266 | ret |
2267 | ;------------------------------------------------------------------------------ |
2267 | ;------------------------------------------------------------------------------ |
2268 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2268 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2269 | and dword [esp+32], 0 |
2269 | and dword [esp+32], 0 |
2270 | ret |
2270 | ret |
2271 | ;------------------------------------------------------------------------------ |
2271 | ;------------------------------------------------------------------------------ |
2272 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2272 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2273 | mov edi, ecx |
2273 | mov edi, ecx |
2274 | mov esi, version_inf |
2274 | mov esi, version_inf |
2275 | mov ecx, version_end-version_inf |
2275 | mov ecx, version_end-version_inf |
2276 | rep movsb |
2276 | rep movsb |
2277 | ret |
2277 | ret |
2278 | ;------------------------------------------------------------------------------ |
2278 | ;------------------------------------------------------------------------------ |
2279 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2279 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2280 | ;wait retrace functions |
2280 | ;wait retrace functions |
2281 | sys_wait_retrace: |
2281 | sys_wait_retrace: |
2282 | mov edx, 0x3da |
2282 | mov edx, 0x3da |
2283 | WaitRetrace_loop: |
2283 | WaitRetrace_loop: |
2284 | in al, dx |
2284 | in al, dx |
2285 | test al, 1000b |
2285 | test al, 1000b |
2286 | jz WaitRetrace_loop |
2286 | jz WaitRetrace_loop |
2287 | and [esp+32], dword 0 |
2287 | and [esp+32], dword 0 |
2288 | ret |
2288 | ret |
2289 | ;------------------------------------------------------------------------------ |
2289 | ;------------------------------------------------------------------------------ |
2290 | align 4 |
2290 | align 4 |
2291 | sysfn_centermouse: ; 18.15 = mouse centered |
2291 | sysfn_centermouse: ; 18.15 = mouse centered |
2292 | ; removed here by |
2292 | ; removed here by |
2293 | ; call mouse_centered |
2293 | ; call mouse_centered |
2294 | ;* mouse centered - start code- Mario79 |
2294 | ;* mouse centered - start code- Mario79 |
2295 | ;mouse_centered: |
2295 | ;mouse_centered: |
2296 | ; push eax |
2296 | ; push eax |
2297 | mov eax, [Screen_Max_X] |
2297 | mov eax, [Screen_Max_X] |
2298 | shr eax, 1 |
2298 | shr eax, 1 |
2299 | mov [MOUSE_X], ax |
2299 | mov [MOUSE_X], ax |
2300 | mov eax, [Screen_Max_Y] |
2300 | mov eax, [Screen_Max_Y] |
2301 | shr eax, 1 |
2301 | shr eax, 1 |
2302 | mov [MOUSE_Y], ax |
2302 | mov [MOUSE_Y], ax |
2303 | ; ret |
2303 | ; ret |
2304 | ;* mouse centered - end code- Mario79 |
2304 | ;* mouse centered - end code- Mario79 |
2305 | xor eax, eax |
2305 | xor eax, eax |
2306 | and [esp+32], eax |
2306 | and [esp+32], eax |
2307 | ; pop eax |
2307 | ; pop eax |
2308 | ret |
2308 | ret |
2309 | ;------------------------------------------------------------------------------ |
2309 | ;------------------------------------------------------------------------------ |
2310 | align 4 |
2310 | align 4 |
2311 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2311 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2312 | test ecx, ecx; get mouse speed factor |
2312 | test ecx, ecx; get mouse speed factor |
2313 | jnz .set_mouse_acceleration |
2313 | jnz .set_mouse_acceleration |
2314 | xor eax, eax |
2314 | xor eax, eax |
2315 | mov ax, [mouse_speed_factor] |
2315 | mov ax, [mouse_speed_factor] |
2316 | mov [esp+32], eax |
2316 | mov [esp+32], eax |
2317 | ret |
2317 | ret |
2318 | .set_mouse_acceleration: |
2318 | .set_mouse_acceleration: |
2319 | ; cmp ecx,1 ; set mouse speed factor |
2319 | ; cmp ecx,1 ; set mouse speed factor |
2320 | dec ecx |
2320 | dec ecx |
2321 | jnz .get_mouse_delay |
2321 | jnz .get_mouse_delay |
2322 | mov [mouse_speed_factor], dx |
2322 | mov [mouse_speed_factor], dx |
2323 | ret |
2323 | ret |
2324 | .get_mouse_delay: |
2324 | .get_mouse_delay: |
2325 | ; cmp ecx,2 ; get mouse delay |
2325 | ; cmp ecx,2 ; get mouse delay |
2326 | dec ecx |
2326 | dec ecx |
2327 | jnz .set_mouse_delay |
2327 | jnz .set_mouse_delay |
2328 | mov eax, [mouse_delay] |
2328 | mov eax, [mouse_delay] |
2329 | mov [esp+32], eax |
2329 | mov [esp+32], eax |
2330 | ret |
2330 | ret |
2331 | .set_mouse_delay: |
2331 | .set_mouse_delay: |
2332 | ; cmp ecx,3 ; set mouse delay |
2332 | ; cmp ecx,3 ; set mouse delay |
2333 | dec ecx |
2333 | dec ecx |
2334 | jnz .set_pointer_position |
2334 | jnz .set_pointer_position |
2335 | mov [mouse_delay], edx |
2335 | mov [mouse_delay], edx |
2336 | ret |
2336 | ret |
2337 | .set_pointer_position: |
2337 | .set_pointer_position: |
2338 | ; cmp ecx,4 ; set mouse pointer position |
2338 | ; cmp ecx,4 ; set mouse pointer position |
2339 | dec ecx |
2339 | dec ecx |
2340 | jnz .set_mouse_button |
2340 | jnz .set_mouse_button |
2341 | cmp dx, word[Screen_Max_Y] |
2341 | cmp dx, word[Screen_Max_Y] |
2342 | ja .end |
2342 | ja .end |
2343 | rol edx, 16 |
2343 | rol edx, 16 |
2344 | cmp dx, word[Screen_Max_X] |
2344 | cmp dx, word[Screen_Max_X] |
2345 | ja .end |
2345 | ja .end |
2346 | mov [MOUSE_X], edx |
2346 | mov [MOUSE_X], edx |
2347 | ret |
2347 | ret |
2348 | .set_mouse_button: |
2348 | .set_mouse_button: |
2349 | ; cmp ecx,5 ; set mouse button features |
2349 | ; cmp ecx,5 ; set mouse button features |
2350 | dec ecx |
2350 | dec ecx |
2351 | jnz .end |
2351 | jnz .end |
2352 | mov [BTN_DOWN], dl |
2352 | mov [BTN_DOWN], dl |
2353 | mov [mouse_active], 1 |
2353 | mov [mouse_active], 1 |
2354 | .end: |
2354 | .end: |
2355 | ret |
2355 | ret |
2356 | ;------------------------------------------------------------------------------ |
2356 | ;------------------------------------------------------------------------------ |
2357 | sysfn_getfreemem: |
2357 | sysfn_getfreemem: |
2358 | mov eax, [pg_data.pages_free] |
2358 | mov eax, [pg_data.pages_free] |
2359 | shl eax, 2 |
2359 | shl eax, 2 |
2360 | mov [esp+32], eax |
2360 | mov [esp+32], eax |
2361 | ret |
2361 | ret |
2362 | 2362 | ||
2363 | sysfn_getallmem: |
2363 | sysfn_getallmem: |
2364 | mov eax, [MEM_AMOUNT] |
2364 | mov eax, [MEM_AMOUNT] |
2365 | shr eax, 10 |
2365 | shr eax, 10 |
2366 | mov [esp+32], eax |
2366 | mov [esp+32], eax |
2367 | ret |
2367 | ret |
2368 | 2368 | ||
2369 | ; // Alver, 2007-22-08 // { |
2369 | ; // Alver, 2007-22-08 // { |
2370 | sysfn_pid_to_slot: |
2370 | sysfn_pid_to_slot: |
2371 | mov eax, ecx |
2371 | mov eax, ecx |
2372 | call pid_to_slot |
2372 | call pid_to_slot |
2373 | mov [esp+32], eax |
2373 | mov [esp+32], eax |
2374 | ret |
2374 | ret |
2375 | 2375 | ||
2376 | sysfn_min_rest_window: |
2376 | sysfn_min_rest_window: |
2377 | pushad |
2377 | pushad |
2378 | mov eax, edx ; ebx - operating |
2378 | mov eax, edx ; ebx - operating |
2379 | shr ecx, 1 |
2379 | shr ecx, 1 |
2380 | jnc @f |
2380 | jnc @f |
2381 | call pid_to_slot |
2381 | call pid_to_slot |
2382 | @@: |
2382 | @@: |
2383 | or eax, eax ; eax - number of slot |
2383 | or eax, eax ; eax - number of slot |
2384 | jz .error |
2384 | jz .error |
2385 | cmp eax, 255 ; varify maximal slot number |
2385 | cmp eax, 255 ; varify maximal slot number |
2386 | ja .error |
2386 | ja .error |
2387 | movzx eax, word [WIN_STACK + eax*2] |
2387 | movzx eax, word [WIN_STACK + eax*2] |
2388 | shr ecx, 1 |
2388 | shr ecx, 1 |
2389 | jc .restore |
2389 | jc .restore |
2390 | ; .minimize: |
2390 | ; .minimize: |
2391 | call minimize_window |
2391 | call minimize_window |
2392 | jmp .exit |
2392 | jmp .exit |
2393 | .restore: |
2393 | .restore: |
2394 | call restore_minimized_window |
2394 | call restore_minimized_window |
2395 | .exit: |
2395 | .exit: |
2396 | popad |
2396 | popad |
2397 | xor eax, eax |
2397 | xor eax, eax |
2398 | mov [esp+32], eax |
2398 | mov [esp+32], eax |
2399 | ret |
2399 | ret |
2400 | .error: |
2400 | .error: |
2401 | popad |
2401 | popad |
2402 | xor eax, eax |
2402 | xor eax, eax |
2403 | dec eax |
2403 | dec eax |
2404 | mov [esp+32], eax |
2404 | mov [esp+32], eax |
2405 | ret |
2405 | ret |
2406 | ; } \\ Alver, 2007-22-08 \\ |
2406 | ; } \\ Alver, 2007-22-08 \\ |
2407 | 2407 | ||
2408 | uglobal |
2408 | uglobal |
2409 | ;// mike.dld, 2006-29-01 [ |
2409 | ;// mike.dld, 2006-29-01 [ |
2410 | screen_workarea RECT |
2410 | screen_workarea RECT |
2411 | ;// mike.dld, 2006-29-01 ] |
2411 | ;// mike.dld, 2006-29-01 ] |
2412 | window_minimize db 0 |
2412 | window_minimize db 0 |
2413 | sound_flag db 0 |
2413 | sound_flag db 0 |
2414 | endg |
2414 | endg |
2415 | 2415 | ||
2416 | UID_NONE=0 |
2416 | UID_NONE=0 |
2417 | UID_MENUETOS=1 ;official |
2417 | UID_MENUETOS=1 ;official |
2418 | UID_KOLIBRI=2 ;russian |
2418 | UID_KOLIBRI=2 ;russian |
2419 | 2419 | ||
2420 | iglobal |
2420 | iglobal |
2421 | version_inf: |
2421 | version_inf: |
2422 | db 0,7,7,0 ; version 0.7.7.0 |
2422 | db 0,7,7,0 ; version 0.7.7.0 |
2423 | db 0 |
2423 | db 0 |
2424 | dd __REV__ |
2424 | dd __REV__ |
2425 | version_end: |
2425 | version_end: |
2426 | endg |
2426 | endg |
2427 | ;------------------------------------------------------------------------------ |
2427 | ;------------------------------------------------------------------------------ |
2428 | align 4 |
2428 | align 4 |
2429 | sys_cachetodiskette: |
2429 | sys_cachetodiskette: |
2430 | cmp ebx, 1 |
2430 | cmp ebx, 1 |
2431 | jne .no_floppy_a_save |
2431 | jne .no_floppy_a_save |
2432 | mov [flp_number], 1 |
2432 | mov [flp_number], 1 |
2433 | jmp .save_image_on_floppy |
2433 | jmp .save_image_on_floppy |
2434 | ;-------------------------------------- |
2434 | ;-------------------------------------- |
2435 | align 4 |
2435 | align 4 |
2436 | .no_floppy_a_save: |
2436 | .no_floppy_a_save: |
2437 | cmp ebx, 2 |
2437 | cmp ebx, 2 |
2438 | jne .no_floppy_b_save |
2438 | jne .no_floppy_b_save |
2439 | mov [flp_number], 2 |
2439 | mov [flp_number], 2 |
2440 | ;-------------------------------------- |
2440 | ;-------------------------------------- |
2441 | align 4 |
2441 | align 4 |
2442 | .save_image_on_floppy: |
2442 | .save_image_on_floppy: |
2443 | call save_image |
2443 | call save_image |
2444 | mov [esp + 32], dword 0 |
2444 | mov [esp + 32], dword 0 |
2445 | cmp [FDC_Status], 0 |
2445 | cmp [FDC_Status], 0 |
2446 | je .yes_floppy_save |
2446 | je .yes_floppy_save |
2447 | ;-------------------------------------- |
2447 | ;-------------------------------------- |
2448 | align 4 |
2448 | align 4 |
2449 | .no_floppy_b_save: |
2449 | .no_floppy_b_save: |
2450 | mov [esp + 32], dword 1 |
2450 | mov [esp + 32], dword 1 |
2451 | ;-------------------------------------- |
2451 | ;-------------------------------------- |
2452 | align 4 |
2452 | align 4 |
2453 | .yes_floppy_save: |
2453 | .yes_floppy_save: |
2454 | ret |
2454 | ret |
2455 | ;------------------------------------------------------------------------------ |
2455 | ;------------------------------------------------------------------------------ |
2456 | uglobal |
2456 | uglobal |
2457 | ; bgrchanged dd 0x0 |
2457 | ; bgrchanged dd 0x0 |
2458 | align 4 |
2458 | align 4 |
2459 | bgrlockpid dd 0 |
2459 | bgrlockpid dd 0 |
2460 | bgrlock db 0 |
2460 | bgrlock db 0 |
2461 | endg |
2461 | endg |
2462 | ;------------------------------------------------------------------------------ |
2462 | ;------------------------------------------------------------------------------ |
2463 | align 4 |
2463 | align 4 |
2464 | sys_background: |
2464 | sys_background: |
2465 | cmp ebx, 1 ; BACKGROUND SIZE |
2465 | cmp ebx, 1 ; BACKGROUND SIZE |
2466 | jnz nosb1 |
2466 | jnz nosb1 |
2467 | test ecx, ecx |
2467 | test ecx, ecx |
2468 | jz sbgrr |
2468 | jz sbgrr |
2469 | 2469 | ||
2470 | test edx, edx |
2470 | test edx, edx |
2471 | jz sbgrr |
2471 | jz sbgrr |
2472 | ;-------------------------------------- |
2472 | ;-------------------------------------- |
2473 | align 4 |
2473 | align 4 |
2474 | @@: |
2474 | @@: |
2475 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2475 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2476 | bts dword [bgrlock], 0 |
2476 | bts dword [bgrlock], 0 |
2477 | jnc @f |
2477 | jnc @f |
2478 | call change_task |
2478 | call change_task |
2479 | jmp @b |
2479 | jmp @b |
2480 | ;-------------------------------------- |
2480 | ;-------------------------------------- |
2481 | align 4 |
2481 | align 4 |
2482 | @@: |
2482 | @@: |
2483 | mov [BgrDataWidth], ecx |
2483 | mov [BgrDataWidth], ecx |
2484 | mov [BgrDataHeight], edx |
2484 | mov [BgrDataHeight], edx |
2485 | ; mov [bgrchanged],1 |
2485 | ; mov [bgrchanged],1 |
2486 | 2486 | ||
2487 | pushad |
2487 | pushad |
2488 | ; return memory for old background |
2488 | ; return memory for old background |
2489 | mov eax, [img_background] |
2489 | mov eax, [img_background] |
2490 | cmp eax, static_background_data |
2490 | cmp eax, static_background_data |
2491 | jz @f |
2491 | jz @f |
2492 | stdcall kernel_free, eax |
2492 | stdcall kernel_free, eax |
2493 | ;-------------------------------------- |
2493 | ;-------------------------------------- |
2494 | align 4 |
2494 | align 4 |
2495 | @@: |
2495 | @@: |
2496 | ; calculate RAW size |
2496 | ; calculate RAW size |
2497 | xor eax, eax |
2497 | xor eax, eax |
2498 | inc eax |
2498 | inc eax |
2499 | cmp [BgrDataWidth], eax |
2499 | cmp [BgrDataWidth], eax |
2500 | jae @f |
2500 | jae @f |
2501 | mov [BgrDataWidth], eax |
2501 | mov [BgrDataWidth], eax |
2502 | ;-------------------------------------- |
2502 | ;-------------------------------------- |
2503 | align 4 |
2503 | align 4 |
2504 | @@: |
2504 | @@: |
2505 | cmp [BgrDataHeight], eax |
2505 | cmp [BgrDataHeight], eax |
2506 | jae @f |
2506 | jae @f |
2507 | mov [BgrDataHeight], eax |
2507 | mov [BgrDataHeight], eax |
2508 | ;-------------------------------------- |
2508 | ;-------------------------------------- |
2509 | align 4 |
2509 | align 4 |
2510 | @@: |
2510 | @@: |
2511 | mov eax, [BgrDataWidth] |
2511 | mov eax, [BgrDataWidth] |
2512 | imul eax, [BgrDataHeight] |
2512 | imul eax, [BgrDataHeight] |
2513 | lea eax, [eax*3] |
2513 | lea eax, [eax*3] |
2514 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2514 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2515 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2515 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2516 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2516 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2517 | shr eax, 12 |
2517 | shr eax, 12 |
2518 | inc eax |
2518 | inc eax |
2519 | shl eax, 12 |
2519 | shl eax, 12 |
2520 | mov [mem_BACKGROUND], eax |
2520 | mov [mem_BACKGROUND], eax |
2521 | ; get memory for new background |
2521 | ; get memory for new background |
2522 | stdcall kernel_alloc, eax |
2522 | stdcall kernel_alloc, eax |
2523 | test eax, eax |
2523 | test eax, eax |
2524 | jz .memfailed |
2524 | jz .memfailed |
2525 | mov [img_background], eax |
2525 | mov [img_background], eax |
2526 | jmp .exit |
2526 | jmp .exit |
2527 | ;-------------------------------------- |
2527 | ;-------------------------------------- |
2528 | align 4 |
2528 | align 4 |
2529 | .memfailed: |
2529 | .memfailed: |
2530 | ; revert to static monotone data |
2530 | ; revert to static monotone data |
2531 | mov [img_background], static_background_data |
2531 | mov [img_background], static_background_data |
2532 | xor eax, eax |
2532 | xor eax, eax |
2533 | inc eax |
2533 | inc eax |
2534 | mov [BgrDataWidth], eax |
2534 | mov [BgrDataWidth], eax |
2535 | mov [BgrDataHeight], eax |
2535 | mov [BgrDataHeight], eax |
2536 | mov [mem_BACKGROUND], 4 |
2536 | mov [mem_BACKGROUND], 4 |
2537 | ;-------------------------------------- |
2537 | ;-------------------------------------- |
2538 | align 4 |
2538 | align 4 |
2539 | .exit: |
2539 | .exit: |
2540 | popad |
2540 | popad |
2541 | mov [bgrlock], 0 |
2541 | mov [bgrlock], 0 |
2542 | ;-------------------------------------- |
2542 | ;-------------------------------------- |
2543 | align 4 |
2543 | align 4 |
2544 | sbgrr: |
2544 | sbgrr: |
2545 | ret |
2545 | ret |
2546 | ;------------------------------------------------------------------------------ |
2546 | ;------------------------------------------------------------------------------ |
2547 | align 4 |
2547 | align 4 |
2548 | nosb1: |
2548 | nosb1: |
2549 | cmp ebx, 2 ; SET PIXEL |
2549 | cmp ebx, 2 ; SET PIXEL |
2550 | jnz nosb2 |
2550 | jnz nosb2 |
2551 | 2551 | ||
2552 | mov eax, [img_background] |
2552 | mov eax, [img_background] |
2553 | test ecx, ecx |
2553 | test ecx, ecx |
2554 | jz @f |
2554 | jz @f |
2555 | cmp eax, static_background_data |
2555 | cmp eax, static_background_data |
2556 | jz .ret |
2556 | jz .ret |
2557 | ;-------------------------------------- |
2557 | ;-------------------------------------- |
2558 | align 4 |
2558 | align 4 |
2559 | @@: |
2559 | @@: |
2560 | mov ebx, [mem_BACKGROUND] |
2560 | mov ebx, [mem_BACKGROUND] |
2561 | add ebx, 4095 |
2561 | add ebx, 4095 |
2562 | and ebx, -4096 |
2562 | and ebx, -4096 |
2563 | sub ebx, 4 |
2563 | sub ebx, 4 |
2564 | cmp ecx, ebx |
2564 | cmp ecx, ebx |
2565 | ja .ret |
2565 | ja .ret |
2566 | 2566 | ||
2567 | mov ebx, [eax+ecx] |
2567 | mov ebx, [eax+ecx] |
2568 | and ebx, 0xFF000000;255*256*256*256 |
2568 | and ebx, 0xFF000000;255*256*256*256 |
2569 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2569 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2570 | add edx, ebx |
2570 | add edx, ebx |
2571 | mov [eax+ecx], edx |
2571 | mov [eax+ecx], edx |
2572 | ;-------------------------------------- |
2572 | ;-------------------------------------- |
2573 | align 4 |
2573 | align 4 |
2574 | .ret: |
2574 | .ret: |
2575 | ret |
2575 | ret |
2576 | ;------------------------------------------------------------------------------ |
2576 | ;------------------------------------------------------------------------------ |
2577 | align 4 |
2577 | align 4 |
2578 | nosb2: |
2578 | nosb2: |
2579 | cmp ebx, 3 ; DRAW BACKGROUND |
2579 | cmp ebx, 3 ; DRAW BACKGROUND |
2580 | jnz nosb3 |
2580 | jnz nosb3 |
2581 | ;-------------------------------------- |
2581 | ;-------------------------------------- |
2582 | align 4 |
2582 | align 4 |
2583 | draw_background_temp: |
2583 | draw_background_temp: |
2584 | mov [background_defined], 1 |
2584 | mov [background_defined], 1 |
2585 | call force_redraw_background |
2585 | call force_redraw_background |
2586 | ;-------------------------------------- |
2586 | ;-------------------------------------- |
2587 | align 4 |
2587 | align 4 |
2588 | nosb31: |
2588 | nosb31: |
2589 | ret |
2589 | ret |
2590 | ;------------------------------------------------------------------------------ |
2590 | ;------------------------------------------------------------------------------ |
2591 | align 4 |
2591 | align 4 |
2592 | nosb3: |
2592 | nosb3: |
2593 | cmp ebx, 4 ; TILED / STRETCHED |
2593 | cmp ebx, 4 ; TILED / STRETCHED |
2594 | jnz nosb4 |
2594 | jnz nosb4 |
2595 | cmp ecx, [BgrDrawMode] |
2595 | cmp ecx, [BgrDrawMode] |
2596 | je nosb41 |
2596 | je nosb41 |
2597 | mov [BgrDrawMode], ecx |
2597 | mov [BgrDrawMode], ecx |
2598 | ;-------------------------------------- |
2598 | ;-------------------------------------- |
2599 | align 4 |
2599 | align 4 |
2600 | nosb41: |
2600 | nosb41: |
2601 | ret |
2601 | ret |
2602 | ;------------------------------------------------------------------------------ |
2602 | ;------------------------------------------------------------------------------ |
2603 | align 4 |
2603 | align 4 |
2604 | nosb4: |
2604 | nosb4: |
2605 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2605 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2606 | jnz nosb5 |
2606 | jnz nosb5 |
2607 | cmp [img_background], static_background_data |
2607 | cmp [img_background], static_background_data |
2608 | jnz @f |
2608 | jnz @f |
2609 | test edx, edx |
2609 | test edx, edx |
2610 | jnz .fin |
2610 | jnz .fin |
2611 | cmp esi, 4 |
2611 | cmp esi, 4 |
2612 | ja .fin |
2612 | ja .fin |
2613 | ;-------------------------------------- |
2613 | ;-------------------------------------- |
2614 | align 4 |
2614 | align 4 |
2615 | @@: |
2615 | @@: |
2616 | ; bughere |
2616 | ; bughere |
2617 | mov eax, ecx |
2617 | mov eax, ecx |
2618 | mov ebx, edx |
2618 | mov ebx, edx |
2619 | add ebx, [img_background];IMG_BACKGROUND |
2619 | add ebx, [img_background];IMG_BACKGROUND |
2620 | mov ecx, esi |
2620 | mov ecx, esi |
2621 | call memmove |
2621 | call memmove |
2622 | ;-------------------------------------- |
2622 | ;-------------------------------------- |
2623 | align 4 |
2623 | align 4 |
2624 | .fin: |
2624 | .fin: |
2625 | ret |
2625 | ret |
2626 | ;------------------------------------------------------------------------------ |
2626 | ;------------------------------------------------------------------------------ |
2627 | align 4 |
2627 | align 4 |
2628 | nosb5: |
2628 | nosb5: |
2629 | cmp ebx, 6 |
2629 | cmp ebx, 6 |
2630 | jnz nosb6 |
2630 | jnz nosb6 |
2631 | ;-------------------------------------- |
2631 | ;-------------------------------------- |
2632 | align 4 |
2632 | align 4 |
2633 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2633 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2634 | @@: |
2634 | @@: |
2635 | bts dword [bgrlock], 0 |
2635 | bts dword [bgrlock], 0 |
2636 | jnc @f |
2636 | jnc @f |
2637 | call change_task |
2637 | call change_task |
2638 | jmp @b |
2638 | jmp @b |
2639 | ;-------------------------------------- |
2639 | ;-------------------------------------- |
2640 | align 4 |
2640 | align 4 |
2641 | @@: |
2641 | @@: |
2642 | mov eax, [CURRENT_TASK] |
2642 | mov eax, [CURRENT_TASK] |
2643 | mov [bgrlockpid], eax |
2643 | mov [bgrlockpid], eax |
2644 | cmp [img_background], static_background_data |
2644 | cmp [img_background], static_background_data |
2645 | jz .nomem |
2645 | jz .nomem |
2646 | stdcall user_alloc, [mem_BACKGROUND] |
2646 | stdcall user_alloc, [mem_BACKGROUND] |
2647 | mov [esp+32], eax |
2647 | mov [esp+32], eax |
2648 | test eax, eax |
2648 | test eax, eax |
2649 | jz .nomem |
2649 | jz .nomem |
2650 | mov ebx, eax |
2650 | mov ebx, eax |
2651 | shr ebx, 12 |
2651 | shr ebx, 12 |
2652 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2652 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2653 | mov esi, [img_background] |
2653 | mov esi, [img_background] |
2654 | shr esi, 12 |
2654 | shr esi, 12 |
2655 | mov ecx, [mem_BACKGROUND] |
2655 | mov ecx, [mem_BACKGROUND] |
2656 | add ecx, 0xFFF |
2656 | add ecx, 0xFFF |
2657 | shr ecx, 12 |
2657 | shr ecx, 12 |
2658 | ;-------------------------------------- |
2658 | ;-------------------------------------- |
2659 | align 4 |
2659 | align 4 |
2660 | .z: |
2660 | .z: |
2661 | mov eax, [page_tabs+ebx*4] |
2661 | mov eax, [page_tabs+ebx*4] |
2662 | test al, 1 |
2662 | test al, 1 |
2663 | jz @f |
2663 | jz @f |
2664 | call free_page |
2664 | call free_page |
2665 | ;-------------------------------------- |
2665 | ;-------------------------------------- |
2666 | align 4 |
2666 | align 4 |
2667 | @@: |
2667 | @@: |
2668 | mov eax, [page_tabs+esi*4] |
2668 | mov eax, [page_tabs+esi*4] |
2669 | or al, PG_UW |
2669 | or al, PG_UW |
2670 | mov [page_tabs+ebx*4], eax |
2670 | mov [page_tabs+ebx*4], eax |
2671 | mov eax, ebx |
2671 | mov eax, ebx |
2672 | shl eax, 12 |
2672 | shl eax, 12 |
2673 | invlpg [eax] |
2673 | invlpg [eax] |
2674 | inc ebx |
2674 | inc ebx |
2675 | inc esi |
2675 | inc esi |
2676 | loop .z |
2676 | loop .z |
2677 | ret |
2677 | ret |
2678 | ;-------------------------------------- |
2678 | ;-------------------------------------- |
2679 | align 4 |
2679 | align 4 |
2680 | .nomem: |
2680 | .nomem: |
2681 | and [bgrlockpid], 0 |
2681 | and [bgrlockpid], 0 |
2682 | mov [bgrlock], 0 |
2682 | mov [bgrlock], 0 |
2683 | ;------------------------------------------------------------------------------ |
2683 | ;------------------------------------------------------------------------------ |
2684 | align 4 |
2684 | align 4 |
2685 | nosb6: |
2685 | nosb6: |
2686 | cmp ebx, 7 |
2686 | cmp ebx, 7 |
2687 | jnz nosb7 |
2687 | jnz nosb7 |
2688 | cmp [bgrlock], 0 |
2688 | cmp [bgrlock], 0 |
2689 | jz .err |
2689 | jz .err |
2690 | mov eax, [CURRENT_TASK] |
2690 | mov eax, [CURRENT_TASK] |
2691 | cmp [bgrlockpid], eax |
2691 | cmp [bgrlockpid], eax |
2692 | jnz .err |
2692 | jnz .err |
2693 | mov eax, ecx |
2693 | mov eax, ecx |
2694 | mov ebx, ecx |
2694 | mov ebx, ecx |
2695 | shr eax, 12 |
2695 | shr eax, 12 |
2696 | mov ecx, [page_tabs+(eax-1)*4] |
2696 | mov ecx, [page_tabs+(eax-1)*4] |
2697 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2697 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2698 | jz .err |
2698 | jz .err |
2699 | jnp .err |
2699 | jnp .err |
2700 | push eax |
2700 | push eax |
2701 | shr ecx, 12 |
2701 | shr ecx, 12 |
2702 | dec ecx |
2702 | dec ecx |
2703 | ;-------------------------------------- |
2703 | ;-------------------------------------- |
2704 | align 4 |
2704 | align 4 |
2705 | @@: |
2705 | @@: |
2706 | and dword [page_tabs+eax*4], 0 |
2706 | and dword [page_tabs+eax*4], 0 |
2707 | mov edx, eax |
2707 | mov edx, eax |
2708 | shl edx, 12 |
2708 | shl edx, 12 |
2709 | push eax |
2709 | push eax |
2710 | invlpg [edx] |
2710 | invlpg [edx] |
2711 | pop eax |
2711 | pop eax |
2712 | inc eax |
2712 | inc eax |
2713 | loop @b |
2713 | loop @b |
2714 | pop eax |
2714 | pop eax |
2715 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2715 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2716 | stdcall user_free, ebx |
2716 | stdcall user_free, ebx |
2717 | mov [esp+32], eax |
2717 | mov [esp+32], eax |
2718 | and [bgrlockpid], 0 |
2718 | and [bgrlockpid], 0 |
2719 | mov [bgrlock], 0 |
2719 | mov [bgrlock], 0 |
2720 | ret |
2720 | ret |
2721 | ;-------------------------------------- |
2721 | ;-------------------------------------- |
2722 | align 4 |
2722 | align 4 |
2723 | .err: |
2723 | .err: |
2724 | and dword [esp+32], 0 |
2724 | and dword [esp+32], 0 |
2725 | ret |
2725 | ret |
2726 | ;------------------------------------------------------------------------------ |
2726 | ;------------------------------------------------------------------------------ |
2727 | align 4 |
2727 | align 4 |
2728 | nosb7: |
2728 | nosb7: |
2729 | cmp ebx, 8 |
2729 | cmp ebx, 8 |
2730 | jnz nosb8 |
2730 | jnz nosb8 |
2731 | 2731 | ||
2732 | mov eax, [BG_Rect_X_left_right] |
2732 | mov eax, [BG_Rect_X_left_right] |
2733 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2733 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2734 | mov eax, [BG_Rect_Y_top_bottom] |
2734 | mov eax, [BG_Rect_Y_top_bottom] |
2735 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2735 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2736 | ret |
2736 | ret |
2737 | ;------------------------------------------------------------------------------ |
2737 | ;------------------------------------------------------------------------------ |
2738 | align 4 |
2738 | align 4 |
2739 | nosb8: |
2739 | nosb8: |
2740 | cmp ebx, 9 |
2740 | cmp ebx, 9 |
2741 | jnz nosb9 |
2741 | jnz nosb9 |
2742 | ; ecx = [left]*65536 + [right] |
2742 | ; ecx = [left]*65536 + [right] |
2743 | ; edx = [top]*65536 + [bottom] |
2743 | ; edx = [top]*65536 + [bottom] |
2744 | mov eax, [Screen_Max_X] |
2744 | mov eax, [Screen_Max_X] |
2745 | mov ebx, [Screen_Max_Y] |
2745 | mov ebx, [Screen_Max_Y] |
2746 | ; check [right] |
2746 | ; check [right] |
2747 | cmp cx, ax |
2747 | cmp cx, ax |
2748 | ja .exit |
2748 | ja .exit |
2749 | ; check [left] |
2749 | ; check [left] |
2750 | ror ecx, 16 |
2750 | ror ecx, 16 |
2751 | cmp cx, ax |
2751 | cmp cx, ax |
2752 | ja .exit |
2752 | ja .exit |
2753 | ; check [bottom] |
2753 | ; check [bottom] |
2754 | cmp dx, bx |
2754 | cmp dx, bx |
2755 | ja .exit |
2755 | ja .exit |
2756 | ; check [top] |
2756 | ; check [top] |
2757 | ror edx, 16 |
2757 | ror edx, 16 |
2758 | cmp dx, bx |
2758 | cmp dx, bx |
2759 | ja .exit |
2759 | ja .exit |
2760 | 2760 | ||
2761 | movzx eax, cx ; [left] |
2761 | movzx eax, cx ; [left] |
2762 | movzx ebx, dx ; [top] |
2762 | movzx ebx, dx ; [top] |
2763 | 2763 | ||
2764 | shr ecx, 16 ; [right] |
2764 | shr ecx, 16 ; [right] |
2765 | shr edx, 16 ; [bottom] |
2765 | shr edx, 16 ; [bottom] |
2766 | 2766 | ||
2767 | mov [background_defined], 1 |
2767 | mov [background_defined], 1 |
2768 | 2768 | ||
2769 | mov [draw_data+32 + RECT.left], eax |
2769 | mov [draw_data+32 + RECT.left], eax |
2770 | mov [draw_data+32 + RECT.top], ebx |
2770 | mov [draw_data+32 + RECT.top], ebx |
2771 | 2771 | ||
2772 | mov [draw_data+32 + RECT.right], ecx |
2772 | mov [draw_data+32 + RECT.right], ecx |
2773 | mov [draw_data+32 + RECT.bottom], edx |
2773 | mov [draw_data+32 + RECT.bottom], edx |
2774 | 2774 | ||
2775 | inc byte[REDRAW_BACKGROUND] |
2775 | inc byte[REDRAW_BACKGROUND] |
2776 | ;-------------------------------------- |
2776 | ;-------------------------------------- |
2777 | align 4 |
2777 | align 4 |
2778 | .exit: |
2778 | .exit: |
2779 | ret |
2779 | ret |
2780 | ;------------------------------------------------------------------------------ |
2780 | ;------------------------------------------------------------------------------ |
2781 | align 4 |
2781 | align 4 |
2782 | nosb9: |
2782 | nosb9: |
2783 | ret |
2783 | ret |
2784 | ;------------------------------------------------------------------------------ |
2784 | ;------------------------------------------------------------------------------ |
2785 | align 4 |
2785 | align 4 |
2786 | uglobal |
2786 | uglobal |
2787 | BG_Rect_X_left_right dd 0x0 |
2787 | BG_Rect_X_left_right dd 0x0 |
2788 | BG_Rect_Y_top_bottom dd 0x0 |
2788 | BG_Rect_Y_top_bottom dd 0x0 |
2789 | endg |
2789 | endg |
2790 | ;------------------------------------------------------------------------------ |
2790 | ;------------------------------------------------------------------------------ |
2791 | align 4 |
2791 | align 4 |
2792 | force_redraw_background: |
2792 | force_redraw_background: |
2793 | and [draw_data+32 + RECT.left], 0 |
2793 | and [draw_data+32 + RECT.left], 0 |
2794 | and [draw_data+32 + RECT.top], 0 |
2794 | and [draw_data+32 + RECT.top], 0 |
2795 | push eax ebx |
2795 | push eax ebx |
2796 | mov eax, [Screen_Max_X] |
2796 | mov eax, [Screen_Max_X] |
2797 | mov ebx, [Screen_Max_Y] |
2797 | mov ebx, [Screen_Max_Y] |
2798 | mov [draw_data+32 + RECT.right], eax |
2798 | mov [draw_data+32 + RECT.right], eax |
2799 | mov [draw_data+32 + RECT.bottom], ebx |
2799 | mov [draw_data+32 + RECT.bottom], ebx |
2800 | pop ebx eax |
2800 | pop ebx eax |
2801 | inc byte[REDRAW_BACKGROUND] |
2801 | inc byte[REDRAW_BACKGROUND] |
2802 | ret |
2802 | ret |
2803 | ;------------------------------------------------------------------------------ |
2803 | ;------------------------------------------------------------------------------ |
2804 | align 4 |
2804 | align 4 |
2805 | sys_getbackground: |
2805 | sys_getbackground: |
2806 | ; cmp eax,1 ; SIZE |
2806 | ; cmp eax,1 ; SIZE |
2807 | dec ebx |
2807 | dec ebx |
2808 | jnz nogb1 |
2808 | jnz nogb1 |
2809 | mov eax, [BgrDataWidth] |
2809 | mov eax, [BgrDataWidth] |
2810 | shl eax, 16 |
2810 | shl eax, 16 |
2811 | mov ax, [BgrDataHeight] |
2811 | mov ax, [BgrDataHeight] |
2812 | mov [esp+32], eax |
2812 | mov [esp+32], eax |
2813 | ret |
2813 | ret |
2814 | ;------------------------------------------------------------------------------ |
2814 | ;------------------------------------------------------------------------------ |
2815 | align 4 |
2815 | align 4 |
2816 | nogb1: |
2816 | nogb1: |
2817 | ; cmp eax,2 ; PIXEL |
2817 | ; cmp eax,2 ; PIXEL |
2818 | dec ebx |
2818 | dec ebx |
2819 | jnz nogb2 |
2819 | jnz nogb2 |
2820 | 2820 | ||
2821 | mov eax, [img_background] |
2821 | mov eax, [img_background] |
2822 | test ecx, ecx |
2822 | test ecx, ecx |
2823 | jz @f |
2823 | jz @f |
2824 | cmp eax, static_background_data |
2824 | cmp eax, static_background_data |
2825 | jz .ret |
2825 | jz .ret |
2826 | ;-------------------------------------- |
2826 | ;-------------------------------------- |
2827 | align 4 |
2827 | align 4 |
2828 | @@: |
2828 | @@: |
2829 | mov ebx, [mem_BACKGROUND] |
2829 | mov ebx, [mem_BACKGROUND] |
2830 | add ebx, 4095 |
2830 | add ebx, 4095 |
2831 | and ebx, -4096 |
2831 | and ebx, -4096 |
2832 | sub ebx, 4 |
2832 | sub ebx, 4 |
2833 | cmp ecx, ebx |
2833 | cmp ecx, ebx |
2834 | ja .ret |
2834 | ja .ret |
2835 | 2835 | ||
2836 | mov eax, [ecx+eax] |
2836 | mov eax, [ecx+eax] |
2837 | 2837 | ||
2838 | and eax, 0xFFFFFF |
2838 | and eax, 0xFFFFFF |
2839 | mov [esp+32], eax |
2839 | mov [esp+32], eax |
2840 | ;-------------------------------------- |
2840 | ;-------------------------------------- |
2841 | align 4 |
2841 | align 4 |
2842 | .ret: |
2842 | .ret: |
2843 | ret |
2843 | ret |
2844 | ;------------------------------------------------------------------------------ |
2844 | ;------------------------------------------------------------------------------ |
2845 | align 4 |
2845 | align 4 |
2846 | nogb2: |
2846 | nogb2: |
2847 | 2847 | ||
2848 | ; cmp eax,4 ; TILED / STRETCHED |
2848 | ; cmp eax,4 ; TILED / STRETCHED |
2849 | dec ebx |
2849 | dec ebx |
2850 | dec ebx |
2850 | dec ebx |
2851 | jnz nogb4 |
2851 | jnz nogb4 |
2852 | mov eax, [BgrDrawMode] |
2852 | mov eax, [BgrDrawMode] |
2853 | ;-------------------------------------- |
2853 | ;-------------------------------------- |
2854 | align 4 |
2854 | align 4 |
2855 | nogb4: |
2855 | nogb4: |
2856 | mov [esp+32], eax |
2856 | mov [esp+32], eax |
2857 | ret |
2857 | ret |
2858 | ;------------------------------------------------------------------------------ |
2858 | ;------------------------------------------------------------------------------ |
2859 | align 4 |
2859 | align 4 |
2860 | sys_getkey: |
2860 | sys_getkey: |
2861 | mov [esp + 32], dword 1 |
2861 | mov [esp + 32], dword 1 |
2862 | ; test main buffer |
2862 | ; test main buffer |
2863 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2863 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2864 | movzx ecx, word [WIN_STACK + ebx * 2] |
2864 | movzx ecx, word [WIN_STACK + ebx * 2] |
2865 | mov edx, [TASK_COUNT] |
2865 | mov edx, [TASK_COUNT] |
2866 | cmp ecx, edx |
2866 | cmp ecx, edx |
2867 | jne .finish |
2867 | jne .finish |
2868 | cmp [KEY_COUNT], byte 0 |
2868 | cmp [KEY_COUNT], byte 0 |
2869 | je .finish |
2869 | je .finish |
2870 | movzx eax, byte [KEY_BUFF] |
2870 | movzx eax, byte [KEY_BUFF] |
2871 | shl eax, 8 |
2871 | shl eax, 8 |
2872 | push eax |
2872 | push eax |
2873 | dec byte [KEY_COUNT] |
2873 | dec byte [KEY_COUNT] |
2874 | and byte [KEY_COUNT], 127 |
2874 | and byte [KEY_COUNT], 127 |
2875 | movzx ecx, byte [KEY_COUNT] |
2875 | movzx ecx, byte [KEY_COUNT] |
2876 | add ecx, 2 |
2876 | add ecx, 2 |
2877 | mov eax, KEY_BUFF + 1 |
2877 | mov eax, KEY_BUFF + 1 |
2878 | mov ebx, KEY_BUFF |
2878 | mov ebx, KEY_BUFF |
2879 | call memmove |
2879 | call memmove |
2880 | pop eax |
2880 | pop eax |
2881 | ;-------------------------------------- |
2881 | ;-------------------------------------- |
2882 | align 4 |
2882 | align 4 |
2883 | .ret_eax: |
2883 | .ret_eax: |
2884 | mov [esp + 32], eax |
2884 | mov [esp + 32], eax |
2885 | ret |
2885 | ret |
2886 | ;-------------------------------------- |
2886 | ;-------------------------------------- |
2887 | align 4 |
2887 | align 4 |
2888 | .finish: |
2888 | .finish: |
2889 | ; test hotkeys buffer |
2889 | ; test hotkeys buffer |
2890 | mov ecx, hotkey_buffer |
2890 | mov ecx, hotkey_buffer |
2891 | ;-------------------------------------- |
2891 | ;-------------------------------------- |
2892 | align 4 |
2892 | align 4 |
2893 | @@: |
2893 | @@: |
2894 | cmp [ecx], ebx |
2894 | cmp [ecx], ebx |
2895 | jz .found |
2895 | jz .found |
2896 | add ecx, 8 |
2896 | add ecx, 8 |
2897 | cmp ecx, hotkey_buffer + 120 * 8 |
2897 | cmp ecx, hotkey_buffer + 120 * 8 |
2898 | jb @b |
2898 | jb @b |
2899 | ret |
2899 | ret |
2900 | ;-------------------------------------- |
2900 | ;-------------------------------------- |
2901 | align 4 |
2901 | align 4 |
2902 | .found: |
2902 | .found: |
2903 | mov ax, [ecx + 6] |
2903 | mov ax, [ecx + 6] |
2904 | shl eax, 16 |
2904 | shl eax, 16 |
2905 | mov ah, [ecx + 4] |
2905 | mov ah, [ecx + 4] |
2906 | mov al, 2 |
2906 | mov al, 2 |
2907 | and dword [ecx + 4], 0 |
2907 | and dword [ecx + 4], 0 |
2908 | and dword [ecx], 0 |
2908 | and dword [ecx], 0 |
2909 | jmp .ret_eax |
2909 | jmp .ret_eax |
2910 | ;------------------------------------------------------------------------------ |
2910 | ;------------------------------------------------------------------------------ |
2911 | align 4 |
2911 | align 4 |
2912 | sys_getbutton: |
2912 | sys_getbutton: |
2913 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2913 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2914 | mov [esp + 32], dword 1 |
2914 | mov [esp + 32], dword 1 |
2915 | movzx ecx, word [WIN_STACK + ebx * 2] |
2915 | movzx ecx, word [WIN_STACK + ebx * 2] |
2916 | mov edx, [TASK_COUNT] ; less than 256 processes |
2916 | mov edx, [TASK_COUNT] ; less than 256 processes |
2917 | cmp ecx, edx |
2917 | cmp ecx, edx |
2918 | jne .exit |
2918 | jne .exit |
2919 | movzx eax, byte [BTN_COUNT] |
2919 | movzx eax, byte [BTN_COUNT] |
2920 | test eax, eax |
2920 | test eax, eax |
2921 | jz .exit |
2921 | jz .exit |
2922 | mov eax, [BTN_BUFF] |
2922 | mov eax, [BTN_BUFF] |
2923 | and al, 0xFE ; delete left button bit |
2923 | and al, 0xFE ; delete left button bit |
2924 | mov [BTN_COUNT], byte 0 |
2924 | mov [BTN_COUNT], byte 0 |
2925 | mov [esp + 32], eax |
2925 | mov [esp + 32], eax |
2926 | ;-------------------------------------- |
2926 | ;-------------------------------------- |
2927 | align 4 |
2927 | align 4 |
2928 | .exit: |
2928 | .exit: |
2929 | ret |
2929 | ret |
2930 | ;------------------------------------------------------------------------------ |
2930 | ;------------------------------------------------------------------------------ |
2931 | align 4 |
2931 | align 4 |
2932 | sys_cpuusage: |
2932 | sys_cpuusage: |
2933 | 2933 | ||
2934 | ; RETURN: |
2934 | ; RETURN: |
2935 | ; |
2935 | ; |
2936 | ; +00 dword process cpu usage |
2936 | ; +00 dword process cpu usage |
2937 | ; +04 word position in windowing stack |
2937 | ; +04 word position in windowing stack |
2938 | ; +06 word windowing stack value at current position (cpu nro) |
2938 | ; +06 word windowing stack value at current position (cpu nro) |
2939 | ; +10 12 bytes name |
2939 | ; +10 12 bytes name |
2940 | ; +22 dword start in mem |
2940 | ; +22 dword start in mem |
2941 | ; +26 dword used mem |
2941 | ; +26 dword used mem |
2942 | ; +30 dword PID , process idenfification number |
2942 | ; +30 dword PID , process idenfification number |
2943 | ; |
2943 | ; |
2944 | 2944 | ||
2945 | cmp ecx, -1 ; who am I ? |
2945 | cmp ecx, -1 ; who am I ? |
2946 | jne .no_who_am_i |
2946 | jne .no_who_am_i |
2947 | mov ecx, [CURRENT_TASK] |
2947 | mov ecx, [CURRENT_TASK] |
2948 | .no_who_am_i: |
2948 | .no_who_am_i: |
2949 | cmp ecx, max_processes |
2949 | cmp ecx, max_processes |
2950 | ja .nofillbuf |
2950 | ja .nofillbuf |
2951 | 2951 | ||
2952 | ; +4: word: position of the window of thread in the window stack |
2952 | ; +4: word: position of the window of thread in the window stack |
2953 | mov ax, [WIN_STACK + ecx * 2] |
2953 | mov ax, [WIN_STACK + ecx * 2] |
2954 | mov [ebx+4], ax |
2954 | mov [ebx+4], ax |
2955 | ; +6: word: number of the thread slot, which window has in the window stack |
2955 | ; +6: word: number of the thread slot, which window has in the window stack |
2956 | ; position ecx (has no relation to the specific thread) |
2956 | ; position ecx (has no relation to the specific thread) |
2957 | mov ax, [WIN_POS + ecx * 2] |
2957 | mov ax, [WIN_POS + ecx * 2] |
2958 | mov [ebx+6], ax |
2958 | mov [ebx+6], ax |
2959 | 2959 | ||
2960 | shl ecx, 5 |
2960 | shl ecx, 5 |
2961 | 2961 | ||
2962 | ; +0: dword: memory usage |
2962 | ; +0: dword: memory usage |
2963 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2963 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2964 | mov [ebx], eax |
2964 | mov [ebx], eax |
2965 | ; +10: 11 bytes: name of the process |
2965 | ; +10: 11 bytes: name of the process |
2966 | push ecx |
2966 | push ecx |
2967 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
2967 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
2968 | add ebx, 10 |
2968 | add ebx, 10 |
2969 | mov ecx, 11 |
2969 | mov ecx, 11 |
2970 | call memmove |
2970 | call memmove |
2971 | pop ecx |
2971 | pop ecx |
2972 | 2972 | ||
2973 | ; +22: address of the process in memory |
2973 | ; +22: address of the process in memory |
2974 | ; +26: size of used memory - 1 |
2974 | ; +26: size of used memory - 1 |
2975 | push edi |
2975 | push edi |
2976 | lea edi, [ebx+12] |
2976 | lea edi, [ebx+12] |
2977 | xor eax, eax |
2977 | xor eax, eax |
2978 | mov edx, 0x100000*16 |
2978 | mov edx, 0x100000*16 |
2979 | cmp ecx, 1 shl 5 |
2979 | cmp ecx, 1 shl 5 |
2980 | je .os_mem |
2980 | je .os_mem |
2981 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
2981 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
2982 | mov eax, std_application_base_address |
2982 | mov eax, std_application_base_address |
2983 | .os_mem: |
2983 | .os_mem: |
2984 | stosd |
2984 | stosd |
2985 | lea eax, [edx-1] |
2985 | lea eax, [edx-1] |
2986 | stosd |
2986 | stosd |
2987 | 2987 | ||
2988 | ; +30: PID/TID |
2988 | ; +30: PID/TID |
2989 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2989 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2990 | stosd |
2990 | stosd |
2991 | 2991 | ||
2992 | ; window position and size |
2992 | ; window position and size |
2993 | push esi |
2993 | push esi |
2994 | lea esi, [ecx + window_data + WDATA.box] |
2994 | lea esi, [ecx + window_data + WDATA.box] |
2995 | movsd |
2995 | movsd |
2996 | movsd |
2996 | movsd |
2997 | movsd |
2997 | movsd |
2998 | movsd |
2998 | movsd |
2999 | 2999 | ||
3000 | ; Process state (+50) |
3000 | ; Process state (+50) |
3001 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3001 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3002 | stosd |
3002 | stosd |
3003 | 3003 | ||
3004 | ; Window client area box |
3004 | ; Window client area box |
3005 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3005 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3006 | movsd |
3006 | movsd |
3007 | movsd |
3007 | movsd |
3008 | movsd |
3008 | movsd |
3009 | movsd |
3009 | movsd |
3010 | 3010 | ||
3011 | ; Window state |
3011 | ; Window state |
3012 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3012 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3013 | stosb |
3013 | stosb |
3014 | 3014 | ||
3015 | ; Event mask (+71) |
3015 | ; Event mask (+71) |
3016 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3016 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3017 | stosd |
3017 | stosd |
3018 | 3018 | ||
3019 | pop esi |
3019 | pop esi |
3020 | pop edi |
3020 | pop edi |
3021 | 3021 | ||
3022 | .nofillbuf: |
3022 | .nofillbuf: |
3023 | ; return number of processes |
3023 | ; return number of processes |
3024 | 3024 | ||
3025 | mov eax, [TASK_COUNT] |
3025 | mov eax, [TASK_COUNT] |
3026 | mov [esp+32], eax |
3026 | mov [esp+32], eax |
3027 | ret |
3027 | ret |
3028 | 3028 | ||
3029 | align 4 |
3029 | align 4 |
3030 | sys_clock: |
3030 | sys_clock: |
3031 | cli |
3031 | cli |
3032 | ; Mikhail Lisovin xx Jan 2005 |
3032 | ; Mikhail Lisovin xx Jan 2005 |
3033 | @@: |
3033 | @@: |
3034 | mov al, 10 |
3034 | mov al, 10 |
3035 | out 0x70, al |
3035 | out 0x70, al |
3036 | in al, 0x71 |
3036 | in al, 0x71 |
3037 | test al, al |
3037 | test al, al |
3038 | jns @f |
3038 | jns @f |
3039 | mov esi, 1 |
3039 | mov esi, 1 |
3040 | call delay_ms |
3040 | call delay_ms |
3041 | jmp @b |
3041 | jmp @b |
3042 | @@: |
3042 | @@: |
3043 | ; end Lisovin's fix |
3043 | ; end Lisovin's fix |
3044 | 3044 | ||
3045 | xor al, al ; seconds |
3045 | xor al, al ; seconds |
3046 | out 0x70, al |
3046 | out 0x70, al |
3047 | in al, 0x71 |
3047 | in al, 0x71 |
3048 | movzx ecx, al |
3048 | movzx ecx, al |
3049 | mov al, 02 ; minutes |
3049 | mov al, 02 ; minutes |
3050 | shl ecx, 16 |
3050 | shl ecx, 16 |
3051 | out 0x70, al |
3051 | out 0x70, al |
3052 | in al, 0x71 |
3052 | in al, 0x71 |
3053 | movzx edx, al |
3053 | movzx edx, al |
3054 | mov al, 04 ; hours |
3054 | mov al, 04 ; hours |
3055 | shl edx, 8 |
3055 | shl edx, 8 |
3056 | out 0x70, al |
3056 | out 0x70, al |
3057 | in al, 0x71 |
3057 | in al, 0x71 |
3058 | add ecx, edx |
3058 | add ecx, edx |
3059 | movzx edx, al |
3059 | movzx edx, al |
3060 | add ecx, edx |
3060 | add ecx, edx |
3061 | sti |
3061 | sti |
3062 | mov [esp + 32], ecx |
3062 | mov [esp + 32], ecx |
3063 | ret |
3063 | ret |
3064 | 3064 | ||
3065 | 3065 | ||
3066 | align 4 |
3066 | align 4 |
3067 | 3067 | ||
3068 | sys_date: |
3068 | sys_date: |
3069 | 3069 | ||
3070 | cli |
3070 | cli |
3071 | @@: |
3071 | @@: |
3072 | mov al, 10 |
3072 | mov al, 10 |
3073 | out 0x70, al |
3073 | out 0x70, al |
3074 | in al, 0x71 |
3074 | in al, 0x71 |
3075 | test al, al |
3075 | test al, al |
3076 | jns @f |
3076 | jns @f |
3077 | mov esi, 1 |
3077 | mov esi, 1 |
3078 | call delay_ms |
3078 | call delay_ms |
3079 | jmp @b |
3079 | jmp @b |
3080 | @@: |
3080 | @@: |
3081 | 3081 | ||
3082 | mov ch, 0 |
3082 | mov ch, 0 |
3083 | mov al, 7 ; date |
3083 | mov al, 7 ; date |
3084 | out 0x70, al |
3084 | out 0x70, al |
3085 | in al, 0x71 |
3085 | in al, 0x71 |
3086 | mov cl, al |
3086 | mov cl, al |
3087 | mov al, 8 ; month |
3087 | mov al, 8 ; month |
3088 | shl ecx, 16 |
3088 | shl ecx, 16 |
3089 | out 0x70, al |
3089 | out 0x70, al |
3090 | in al, 0x71 |
3090 | in al, 0x71 |
3091 | mov ch, al |
3091 | mov ch, al |
3092 | mov al, 9 ; year |
3092 | mov al, 9 ; year |
3093 | out 0x70, al |
3093 | out 0x70, al |
3094 | in al, 0x71 |
3094 | in al, 0x71 |
3095 | mov cl, al |
3095 | mov cl, al |
3096 | sti |
3096 | sti |
3097 | mov [esp+32], ecx |
3097 | mov [esp+32], ecx |
3098 | ret |
3098 | ret |
3099 | 3099 | ||
3100 | 3100 | ||
3101 | ; redraw status |
3101 | ; redraw status |
3102 | 3102 | ||
3103 | sys_redrawstat: |
3103 | sys_redrawstat: |
3104 | cmp ebx, 1 |
3104 | cmp ebx, 1 |
3105 | jne no_widgets_away |
3105 | jne no_widgets_away |
3106 | ; buttons away |
3106 | ; buttons away |
3107 | mov ecx, [CURRENT_TASK] |
3107 | mov ecx, [CURRENT_TASK] |
3108 | sys_newba2: |
3108 | sys_newba2: |
3109 | mov edi, [BTN_ADDR] |
3109 | mov edi, [BTN_ADDR] |
3110 | cmp [edi], dword 0 ; empty button list ? |
3110 | cmp [edi], dword 0 ; empty button list ? |
3111 | je end_of_buttons_away |
3111 | je end_of_buttons_away |
3112 | movzx ebx, word [edi] |
3112 | movzx ebx, word [edi] |
3113 | inc ebx |
3113 | inc ebx |
3114 | mov eax, edi |
3114 | mov eax, edi |
3115 | sys_newba: |
3115 | sys_newba: |
3116 | dec ebx |
3116 | dec ebx |
3117 | jz end_of_buttons_away |
3117 | jz end_of_buttons_away |
3118 | 3118 | ||
3119 | add eax, 0x10 |
3119 | add eax, 0x10 |
3120 | cmp cx, [eax] |
3120 | cmp cx, [eax] |
3121 | jnz sys_newba |
3121 | jnz sys_newba |
3122 | 3122 | ||
3123 | push eax ebx ecx |
3123 | push eax ebx ecx |
3124 | mov ecx, ebx |
3124 | mov ecx, ebx |
3125 | inc ecx |
3125 | inc ecx |
3126 | shl ecx, 4 |
3126 | shl ecx, 4 |
3127 | mov ebx, eax |
3127 | mov ebx, eax |
3128 | add eax, 0x10 |
3128 | add eax, 0x10 |
3129 | call memmove |
3129 | call memmove |
3130 | dec dword [edi] |
3130 | dec dword [edi] |
3131 | pop ecx ebx eax |
3131 | pop ecx ebx eax |
3132 | 3132 | ||
3133 | jmp sys_newba2 |
3133 | jmp sys_newba2 |
3134 | 3134 | ||
3135 | end_of_buttons_away: |
3135 | end_of_buttons_away: |
3136 | 3136 | ||
3137 | ret |
3137 | ret |
3138 | 3138 | ||
3139 | no_widgets_away: |
3139 | no_widgets_away: |
3140 | 3140 | ||
3141 | cmp ebx, 2 |
3141 | cmp ebx, 2 |
3142 | jnz srl1 |
3142 | jnz srl1 |
3143 | 3143 | ||
3144 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3144 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3145 | add edx, draw_data - CURRENT_TASK |
3145 | add edx, draw_data - CURRENT_TASK |
3146 | mov [edx + RECT.left], 0 |
3146 | mov [edx + RECT.left], 0 |
3147 | mov [edx + RECT.top], 0 |
3147 | mov [edx + RECT.top], 0 |
3148 | mov eax, [Screen_Max_X] |
3148 | mov eax, [Screen_Max_X] |
3149 | mov [edx + RECT.right], eax |
3149 | mov [edx + RECT.right], eax |
3150 | mov eax, [Screen_Max_Y] |
3150 | mov eax, [Screen_Max_Y] |
3151 | mov [edx + RECT.bottom], eax |
3151 | mov [edx + RECT.bottom], eax |
3152 | 3152 | ||
3153 | srl1: |
3153 | srl1: |
3154 | ret |
3154 | ret |
3155 | 3155 | ||
3156 | ;ok - 100% work |
3156 | ;ok - 100% work |
3157 | ;nt - not tested |
3157 | ;nt - not tested |
3158 | ;--------------------------------------------------------------------------------------------- |
3158 | ;--------------------------------------------------------------------------------------------- |
3159 | ;eax |
3159 | ;eax |
3160 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3160 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3161 | ;1 - change task. Ret nothing. Block. ok. |
3161 | ;1 - change task. Ret nothing. Block. ok. |
3162 | ;2 - performance control |
3162 | ;2 - performance control |
3163 | ; ebx |
3163 | ; ebx |
3164 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3164 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3165 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3165 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3166 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3166 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3167 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3167 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3168 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3168 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3169 | ;eax |
3169 | ;eax |
3170 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3170 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3171 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3171 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3172 | ;--------------------------------------------------------------------------------------------- |
3172 | ;--------------------------------------------------------------------------------------------- |
3173 | iglobal |
3173 | iglobal |
3174 | align 4 |
3174 | align 4 |
3175 | sheduler: |
3175 | sheduler: |
3176 | dd sys_sheduler.00 |
3176 | dd sys_sheduler.00 |
3177 | dd change_task |
3177 | dd change_task |
3178 | dd sys_sheduler.02 |
3178 | dd sys_sheduler.02 |
3179 | dd sys_sheduler.03 |
3179 | dd sys_sheduler.03 |
3180 | dd sys_sheduler.04 |
3180 | dd sys_sheduler.04 |
3181 | endg |
3181 | endg |
3182 | sys_sheduler: |
3182 | sys_sheduler: |
3183 | ;rewritten by |
3183 | ;rewritten by |
3184 | jmp dword [sheduler+ebx*4] |
3184 | jmp dword [sheduler+ebx*4] |
3185 | ;.shed_counter: |
3185 | ;.shed_counter: |
3186 | .00: |
3186 | .00: |
3187 | mov eax, [context_counter] |
3187 | mov eax, [context_counter] |
3188 | mov [esp+32], eax |
3188 | mov [esp+32], eax |
3189 | ret |
3189 | ret |
3190 | 3190 | ||
3191 | .02: |
3191 | .02: |
3192 | ;.perf_control: |
3192 | ;.perf_control: |
3193 | inc ebx ;before ebx=2, ebx=3 |
3193 | inc ebx ;before ebx=2, ebx=3 |
3194 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3194 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3195 | jz cache_disable |
3195 | jz cache_disable |
3196 | 3196 | ||
3197 | dec ebx ;ebx=2 |
3197 | dec ebx ;ebx=2 |
3198 | cmp ebx, ecx ; |
3198 | cmp ebx, ecx ; |
3199 | jz cache_enable ;if ecx=2 and ebx=2 |
3199 | jz cache_enable ;if ecx=2 and ebx=2 |
3200 | 3200 | ||
3201 | dec ebx ;ebx=1 |
3201 | dec ebx ;ebx=1 |
3202 | cmp ebx, ecx |
3202 | cmp ebx, ecx |
3203 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3203 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3204 | 3204 | ||
3205 | dec ebx |
3205 | dec ebx |
3206 | test ebx, ecx ;ebx=0 and ecx=0 |
3206 | test ebx, ecx ;ebx=0 and ecx=0 |
3207 | jz modify_pce ;if ecx=0 |
3207 | jz modify_pce ;if ecx=0 |
3208 | 3208 | ||
3209 | ret |
3209 | ret |
3210 | 3210 | ||
3211 | .03: |
3211 | .03: |
3212 | ;.rdmsr_instr: |
3212 | ;.rdmsr_instr: |
3213 | ;now counter in ecx |
3213 | ;now counter in ecx |
3214 | ;(edx:eax) esi:edi => edx:esi |
3214 | ;(edx:eax) esi:edi => edx:esi |
3215 | mov eax, esi |
3215 | mov eax, esi |
3216 | mov ecx, edx |
3216 | mov ecx, edx |
3217 | rdmsr |
3217 | rdmsr |
3218 | mov [esp+32], eax |
3218 | mov [esp+32], eax |
3219 | mov [esp+20], edx ;ret in ebx? |
3219 | mov [esp+20], edx ;ret in ebx? |
3220 | ret |
3220 | ret |
3221 | 3221 | ||
3222 | .04: |
3222 | .04: |
3223 | ;.wrmsr_instr: |
3223 | ;.wrmsr_instr: |
3224 | ;now counter in ecx |
3224 | ;now counter in ecx |
3225 | ;(edx:eax) esi:edi => edx:esi |
3225 | ;(edx:eax) esi:edi => edx:esi |
3226 | ; Fast Call MSR can't be destroy |
3226 | ; Fast Call MSR can't be destroy |
3227 | ; ® MSR_AMD_EFER ¬®¦® ¨§¬¥ïâì, â.ª. ¢ í⮬ ॣ¨áâॠ«¨è |
3227 | ; ® MSR_AMD_EFER ¬®¦® ¨§¬¥ïâì, â.ª. ¢ í⮬ ॣ¨áâॠ«¨è |
3228 | ; ¢ª«îç îâáï/¢ëª«îç îâáï à áè¨à¥ë¥ ¢®§¬®¦®á⨠|
3228 | ; ¢ª«îç îâáï/¢ëª«îç îâáï à áè¨à¥ë¥ ¢®§¬®¦®á⨠|
3229 | cmp edx, MSR_SYSENTER_CS |
3229 | cmp edx, MSR_SYSENTER_CS |
3230 | je @f |
3230 | je @f |
3231 | cmp edx, MSR_SYSENTER_ESP |
3231 | cmp edx, MSR_SYSENTER_ESP |
3232 | je @f |
3232 | je @f |
3233 | cmp edx, MSR_SYSENTER_EIP |
3233 | cmp edx, MSR_SYSENTER_EIP |
3234 | je @f |
3234 | je @f |
3235 | cmp edx, MSR_AMD_STAR |
3235 | cmp edx, MSR_AMD_STAR |
3236 | je @f |
3236 | je @f |
3237 | 3237 | ||
3238 | mov eax, esi |
3238 | mov eax, esi |
3239 | mov ecx, edx |
3239 | mov ecx, edx |
3240 | wrmsr |
3240 | wrmsr |
3241 | ; mov [esp + 32], eax |
3241 | ; mov [esp + 32], eax |
3242 | ; mov [esp + 20], edx ;ret in ebx? |
3242 | ; mov [esp + 20], edx ;ret in ebx? |
3243 | @@: |
3243 | @@: |
3244 | ret |
3244 | ret |
3245 | 3245 | ||
3246 | cache_disable: |
3246 | cache_disable: |
3247 | mov eax, cr0 |
3247 | mov eax, cr0 |
3248 | or eax, 01100000000000000000000000000000b |
3248 | or eax, 01100000000000000000000000000000b |
3249 | mov cr0, eax |
3249 | mov cr0, eax |
3250 | wbinvd ;set MESI |
3250 | wbinvd ;set MESI |
3251 | ret |
3251 | ret |
3252 | 3252 | ||
3253 | cache_enable: |
3253 | cache_enable: |
3254 | mov eax, cr0 |
3254 | mov eax, cr0 |
3255 | and eax, 10011111111111111111111111111111b |
3255 | and eax, 10011111111111111111111111111111b |
3256 | mov cr0, eax |
3256 | mov cr0, eax |
3257 | ret |
3257 | ret |
3258 | 3258 | ||
3259 | is_cache_enabled: |
3259 | is_cache_enabled: |
3260 | mov eax, cr0 |
3260 | mov eax, cr0 |
3261 | mov ebx, eax |
3261 | mov ebx, eax |
3262 | and eax, 01100000000000000000000000000000b |
3262 | and eax, 01100000000000000000000000000000b |
3263 | jz cache_disabled |
3263 | jz cache_disabled |
3264 | mov [esp+32], ebx |
3264 | mov [esp+32], ebx |
3265 | cache_disabled: |
3265 | cache_disabled: |
3266 | mov dword [esp+32], eax;0 |
3266 | mov dword [esp+32], eax;0 |
3267 | ret |
3267 | ret |
3268 | 3268 | ||
3269 | modify_pce: |
3269 | modify_pce: |
3270 | mov eax, cr4 |
3270 | mov eax, cr4 |
3271 | ; mov ebx,0 |
3271 | ; mov ebx,0 |
3272 | ; or bx,100000000b ;pce |
3272 | ; or bx,100000000b ;pce |
3273 | ; xor eax,ebx ;invert pce |
3273 | ; xor eax,ebx ;invert pce |
3274 | bts eax, 8;pce=cr4[8] |
3274 | bts eax, 8;pce=cr4[8] |
3275 | mov cr4, eax |
3275 | mov cr4, eax |
3276 | mov [esp+32], eax |
3276 | mov [esp+32], eax |
3277 | ret |
3277 | ret |
3278 | ;--------------------------------------------------------------------------------------------- |
3278 | ;--------------------------------------------------------------------------------------------- |
3279 | 3279 | ||
3280 | 3280 | ||
3281 | ; check if pixel is allowed to be drawn |
3281 | ; check if pixel is allowed to be drawn |
3282 | 3282 | ||
3283 | ;checkpixel: |
3283 | ;checkpixel: |
3284 | ; push eax edx |
3284 | ; push eax edx |
3285 | 3285 | ||
3286 | ;; mov edx, [Screen_Max_X] ; screen x size |
3286 | ;; mov edx, [Screen_Max_X] ; screen x size |
3287 | ;; inc edx |
3287 | ;; inc edx |
3288 | ;; imul edx, ebx |
3288 | ;; imul edx, ebx |
3289 | ; mov edx, [d_width_calc_area + ebx*4] |
3289 | ; mov edx, [d_width_calc_area + ebx*4] |
3290 | ; add eax, [_WinMapAddress] |
3290 | ; add eax, [_WinMapAddress] |
3291 | ; mov dl, [eax+edx]; lea eax, [...] |
3291 | ; mov dl, [eax+edx]; lea eax, [...] |
3292 | 3292 | ||
3293 | ; xor ecx, ecx |
3293 | ; xor ecx, ecx |
3294 | ; mov eax, [CURRENT_TASK] |
3294 | ; mov eax, [CURRENT_TASK] |
3295 | ; cmp al, dl |
3295 | ; cmp al, dl |
3296 | ; setne cl |
3296 | ; setne cl |
3297 | 3297 | ||
3298 | ; pop edx eax |
3298 | ; pop edx eax |
3299 | ; ret |
3299 | ; ret |
3300 | 3300 | ||
3301 | iglobal |
3301 | iglobal |
3302 | cpustring db 'CPU',0 |
3302 | cpustring db 'CPU',0 |
3303 | endg |
3303 | endg |
3304 | 3304 | ||
3305 | uglobal |
3305 | uglobal |
3306 | background_defined db 0 ; diamond, 11.04.2006 |
3306 | background_defined db 0 ; diamond, 11.04.2006 |
3307 | endg |
3307 | endg |
3308 | ;----------------------------------------------------------------------------- |
3308 | ;----------------------------------------------------------------------------- |
3309 | align 4 |
3309 | align 4 |
3310 | checkmisc: |
3310 | checkmisc: |
3311 | cmp [ctrl_alt_del], 1 |
3311 | cmp [ctrl_alt_del], 1 |
3312 | jne nocpustart |
3312 | jne nocpustart |
3313 | 3313 | ||
3314 | mov ebp, cpustring |
3314 | mov ebp, cpustring |
3315 | call fs_execute_from_sysdir |
3315 | call fs_execute_from_sysdir |
3316 | 3316 | ||
3317 | mov [ctrl_alt_del], 0 |
3317 | mov [ctrl_alt_del], 0 |
3318 | ;-------------------------------------- |
3318 | ;-------------------------------------- |
3319 | align 4 |
3319 | align 4 |
3320 | nocpustart: |
3320 | nocpustart: |
3321 | cmp [mouse_active], 1 |
3321 | cmp [mouse_active], 1 |
3322 | jne mouse_not_active |
3322 | jne mouse_not_active |
3323 | mov [mouse_active], 0 |
3323 | mov [mouse_active], 0 |
3324 | 3324 | ||
3325 | xor edi, edi |
3325 | xor edi, edi |
3326 | mov ebx, CURRENT_TASK |
3326 | mov ebx, CURRENT_TASK |
3327 | 3327 | ||
3328 | mov ecx, [TASK_COUNT] |
3328 | mov ecx, [TASK_COUNT] |
3329 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3329 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3330 | shl eax, 8 |
3330 | shl eax, 8 |
3331 | push eax |
3331 | push eax |
3332 | 3332 | ||
3333 | movzx eax, word [MOUSE_X] |
3333 | movzx eax, word [MOUSE_X] |
3334 | movzx edx, word [MOUSE_Y] |
3334 | movzx edx, word [MOUSE_Y] |
3335 | ;-------------------------------------- |
3335 | ;-------------------------------------- |
3336 | align 4 |
3336 | align 4 |
3337 | .set_mouse_event: |
3337 | .set_mouse_event: |
3338 | add edi, 256 |
3338 | add edi, 256 |
3339 | add ebx, 32 |
3339 | add ebx, 32 |
3340 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3340 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3341 | jz .pos_filter |
3341 | jz .pos_filter |
3342 | 3342 | ||
3343 | cmp edi, [esp] ; skip if filtration active |
3343 | cmp edi, [esp] ; skip if filtration active |
3344 | jne .skip |
3344 | jne .skip |
3345 | ;-------------------------------------- |
3345 | ;-------------------------------------- |
3346 | align 4 |
3346 | align 4 |
3347 | .pos_filter: |
3347 | .pos_filter: |
3348 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3348 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3349 | jz .set |
3349 | jz .set |
3350 | 3350 | ||
3351 | mov esi, [ebx-twdw+WDATA.box.left] |
3351 | mov esi, [ebx-twdw+WDATA.box.left] |
3352 | cmp eax, esi |
3352 | cmp eax, esi |
3353 | jb .skip |
3353 | jb .skip |
3354 | add esi, [ebx-twdw+WDATA.box.width] |
3354 | add esi, [ebx-twdw+WDATA.box.width] |
3355 | cmp eax, esi |
3355 | cmp eax, esi |
3356 | ja .skip |
3356 | ja .skip |
3357 | 3357 | ||
3358 | mov esi, [ebx-twdw+WDATA.box.top] |
3358 | mov esi, [ebx-twdw+WDATA.box.top] |
3359 | cmp edx, esi |
3359 | cmp edx, esi |
3360 | jb .skip |
3360 | jb .skip |
3361 | add esi, [ebx-twdw+WDATA.box.height] |
3361 | add esi, [ebx-twdw+WDATA.box.height] |
3362 | cmp edx, esi |
3362 | cmp edx, esi |
3363 | ja .skip |
3363 | ja .skip |
3364 | ;-------------------------------------- |
3364 | ;-------------------------------------- |
3365 | align 4 |
3365 | align 4 |
3366 | .set: |
3366 | .set: |
3367 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3367 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3368 | ;-------------------------------------- |
3368 | ;-------------------------------------- |
3369 | align 4 |
3369 | align 4 |
3370 | .skip: |
3370 | .skip: |
3371 | loop .set_mouse_event |
3371 | loop .set_mouse_event |
3372 | 3372 | ||
3373 | pop eax |
3373 | pop eax |
3374 | ;-------------------------------------- |
3374 | ;-------------------------------------- |
3375 | align 4 |
3375 | align 4 |
3376 | mouse_not_active: |
3376 | mouse_not_active: |
3377 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3377 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3378 | jz nobackgr |
3378 | jz nobackgr |
3379 | 3379 | ||
3380 | cmp [background_defined], 0 |
3380 | cmp [background_defined], 0 |
3381 | jz nobackgr |
3381 | jz nobackgr |
3382 | ;-------------------------------------- |
3382 | ;-------------------------------------- |
3383 | align 4 |
3383 | align 4 |
3384 | @@: |
3384 | @@: |
3385 | push eax |
3385 | push eax |
3386 | mov eax, [draw_data+32 + RECT.left] |
3386 | mov eax, [draw_data+32 + RECT.left] |
3387 | shl eax, 16 |
3387 | shl eax, 16 |
3388 | add eax, [draw_data+32 + RECT.right] |
3388 | add eax, [draw_data+32 + RECT.right] |
3389 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3389 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3390 | 3390 | ||
3391 | mov eax, [draw_data+32 + RECT.top] |
3391 | mov eax, [draw_data+32 + RECT.top] |
3392 | shl eax, 16 |
3392 | shl eax, 16 |
3393 | add eax, [draw_data+32 + RECT.bottom] |
3393 | add eax, [draw_data+32 + RECT.bottom] |
3394 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3394 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3395 | pop eax |
3395 | pop eax |
3396 | 3396 | ||
3397 | call drawbackground |
3397 | call drawbackground |
3398 | ; DEBUGF 1, "K : drawbackground\n" |
3398 | ; DEBUGF 1, "K : drawbackground\n" |
3399 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3399 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3400 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3400 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3401 | ;--------- set event 5 start ---------- |
3401 | ;--------- set event 5 start ---------- |
3402 | push ecx edi |
3402 | push ecx edi |
3403 | xor edi, edi |
3403 | xor edi, edi |
3404 | mov ecx, [TASK_COUNT] |
3404 | mov ecx, [TASK_COUNT] |
3405 | ;-------------------------------------- |
3405 | ;-------------------------------------- |
3406 | align 4 |
3406 | align 4 |
3407 | set_bgr_event: |
3407 | set_bgr_event: |
3408 | add edi, 256 |
3408 | add edi, 256 |
3409 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3409 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3410 | loop set_bgr_event |
3410 | loop set_bgr_event |
3411 | pop edi ecx |
3411 | pop edi ecx |
3412 | ; call change_task - because the application must have time to call f.15.8 |
3412 | ; call change_task - because the application must have time to call f.15.8 |
3413 | call change_task |
3413 | call change_task |
3414 | ;--------- set event 5 stop ----------- |
3414 | ;--------- set event 5 stop ----------- |
3415 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3415 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3416 | jnz @b |
3416 | jnz @b |
3417 | 3417 | ||
3418 | mov [draw_data+32 + RECT.left], eax |
3418 | mov [draw_data+32 + RECT.left], eax |
3419 | mov [draw_data+32 + RECT.top], eax |
3419 | mov [draw_data+32 + RECT.top], eax |
3420 | mov [draw_data+32 + RECT.right], eax |
3420 | mov [draw_data+32 + RECT.right], eax |
3421 | mov [draw_data+32 + RECT.bottom], eax |
3421 | mov [draw_data+32 + RECT.bottom], eax |
3422 | mov [MOUSE_BACKGROUND], byte 0 |
3422 | mov [MOUSE_BACKGROUND], byte 0 |
3423 | ;-------------------------------------- |
3423 | ;-------------------------------------- |
3424 | align 4 |
3424 | align 4 |
3425 | nobackgr: |
3425 | nobackgr: |
3426 | ; system shutdown request |
3426 | ; system shutdown request |
3427 | cmp [SYS_SHUTDOWN], byte 0 |
3427 | cmp [SYS_SHUTDOWN], byte 0 |
3428 | je noshutdown |
3428 | je noshutdown |
3429 | 3429 | ||
3430 | mov edx, [shutdown_processes] |
3430 | mov edx, [shutdown_processes] |
3431 | 3431 | ||
3432 | cmp [SYS_SHUTDOWN], dl |
3432 | cmp [SYS_SHUTDOWN], dl |
3433 | jne no_mark_system_shutdown |
3433 | jne no_mark_system_shutdown |
3434 | 3434 | ||
3435 | lea ecx, [edx-1] |
3435 | lea ecx, [edx-1] |
3436 | mov edx, OS_BASE+0x3040 |
3436 | mov edx, OS_BASE+0x3040 |
3437 | jecxz @f |
3437 | jecxz @f |
3438 | ;-------------------------------------- |
3438 | ;-------------------------------------- |
3439 | align 4 |
3439 | align 4 |
3440 | markz: |
3440 | markz: |
3441 | mov [edx+TASKDATA.state], byte 3 |
3441 | mov [edx+TASKDATA.state], byte 3 |
3442 | add edx, 0x20 |
3442 | add edx, 0x20 |
3443 | loop markz |
3443 | loop markz |
3444 | ;-------------------------------------- |
3444 | ;-------------------------------------- |
3445 | align 4 |
3445 | align 4 |
3446 | @@: |
3446 | @@: |
3447 | no_mark_system_shutdown: |
3447 | no_mark_system_shutdown: |
3448 | dec byte [SYS_SHUTDOWN] |
3448 | dec byte [SYS_SHUTDOWN] |
3449 | je system_shutdown |
3449 | je system_shutdown |
3450 | ;-------------------------------------- |
3450 | ;-------------------------------------- |
3451 | align 4 |
3451 | align 4 |
3452 | noshutdown: |
3452 | noshutdown: |
3453 | mov eax, [TASK_COUNT] ; termination |
3453 | mov eax, [TASK_COUNT] ; termination |
3454 | mov ebx, TASK_DATA+TASKDATA.state |
3454 | mov ebx, TASK_DATA+TASKDATA.state |
3455 | mov esi, 1 |
3455 | mov esi, 1 |
3456 | ;-------------------------------------- |
3456 | ;-------------------------------------- |
3457 | align 4 |
3457 | align 4 |
3458 | newct: |
3458 | newct: |
3459 | mov cl, [ebx] |
3459 | mov cl, [ebx] |
3460 | cmp cl, byte 3 |
3460 | cmp cl, byte 3 |
3461 | jz terminate |
3461 | jz terminate |
3462 | 3462 | ||
3463 | cmp cl, byte 4 |
3463 | cmp cl, byte 4 |
3464 | jz terminate |
3464 | jz terminate |
3465 | 3465 | ||
3466 | add ebx, 0x20 |
3466 | add ebx, 0x20 |
3467 | inc esi |
3467 | inc esi |
3468 | dec eax |
3468 | dec eax |
3469 | jnz newct |
3469 | jnz newct |
3470 | ret |
3470 | ret |
3471 | ;----------------------------------------------------------------------------- |
3471 | ;----------------------------------------------------------------------------- |
3472 | align 4 |
3472 | align 4 |
3473 | redrawscreen: |
3473 | redrawscreen: |
3474 | ; eax , if process window_data base is eax, do not set flag/limits |
3474 | ; eax , if process window_data base is eax, do not set flag/limits |
3475 | 3475 | ||
3476 | pushad |
3476 | pushad |
3477 | push eax |
3477 | push eax |
3478 | 3478 | ||
3479 | ;;; mov ebx,2 |
3479 | ;;; mov ebx,2 |
3480 | ;;; call delay_hs |
3480 | ;;; call delay_hs |
3481 | 3481 | ||
3482 | ;mov ecx,0 ; redraw flags for apps |
3482 | ;mov ecx,0 ; redraw flags for apps |
3483 | xor ecx, ecx |
3483 | xor ecx, ecx |
3484 | ;-------------------------------------- |
3484 | ;-------------------------------------- |
3485 | align 4 |
3485 | align 4 |
3486 | newdw2: |
3486 | newdw2: |
3487 | inc ecx |
3487 | inc ecx |
3488 | push ecx |
3488 | push ecx |
3489 | 3489 | ||
3490 | mov eax, ecx |
3490 | mov eax, ecx |
3491 | shl eax, 5 |
3491 | shl eax, 5 |
3492 | add eax, window_data |
3492 | add eax, window_data |
3493 | 3493 | ||
3494 | cmp eax, [esp+4] |
3494 | cmp eax, [esp+4] |
3495 | je not_this_task |
3495 | je not_this_task |
3496 | ; check if window in redraw area |
3496 | ; check if window in redraw area |
3497 | mov edi, eax |
3497 | mov edi, eax |
3498 | 3498 | ||
3499 | cmp ecx, 1 ; limit for background |
3499 | cmp ecx, 1 ; limit for background |
3500 | jz bgli |
3500 | jz bgli |
3501 | 3501 | ||
3502 | mov eax, [edi + WDATA.box.left] |
3502 | mov eax, [edi + WDATA.box.left] |
3503 | mov ebx, [edi + WDATA.box.top] |
3503 | mov ebx, [edi + WDATA.box.top] |
3504 | mov ecx, [edi + WDATA.box.width] |
3504 | mov ecx, [edi + WDATA.box.width] |
3505 | mov edx, [edi + WDATA.box.height] |
3505 | mov edx, [edi + WDATA.box.height] |
3506 | add ecx, eax |
3506 | add ecx, eax |
3507 | add edx, ebx |
3507 | add edx, ebx |
3508 | 3508 | ||
3509 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3509 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3510 | cmp ecx, ebx |
3510 | cmp ecx, ebx |
3511 | jb ricino |
3511 | jb ricino |
3512 | 3512 | ||
3513 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3513 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3514 | cmp ecx, eax |
3514 | cmp ecx, eax |
3515 | jb ricino |
3515 | jb ricino |
3516 | 3516 | ||
3517 | mov eax, [edi + WDATA.box.left] |
3517 | mov eax, [edi + WDATA.box.left] |
3518 | mov ebx, [edi + WDATA.box.top] |
3518 | mov ebx, [edi + WDATA.box.top] |
3519 | mov ecx, [edi + WDATA.box.width] |
3519 | mov ecx, [edi + WDATA.box.width] |
3520 | mov edx, [edi + WDATA.box.height] |
3520 | mov edx, [edi + WDATA.box.height] |
3521 | add ecx, eax |
3521 | add ecx, eax |
3522 | add edx, ebx |
3522 | add edx, ebx |
3523 | 3523 | ||
3524 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3524 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3525 | cmp edx, eax |
3525 | cmp edx, eax |
3526 | jb ricino |
3526 | jb ricino |
3527 | 3527 | ||
3528 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3528 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3529 | cmp ecx, eax |
3529 | cmp ecx, eax |
3530 | jb ricino |
3530 | jb ricino |
3531 | ;-------------------------------------- |
3531 | ;-------------------------------------- |
3532 | align 4 |
3532 | align 4 |
3533 | bgli: |
3533 | bgli: |
3534 | cmp dword[esp], 1 |
3534 | cmp dword[esp], 1 |
3535 | jnz .az |
3535 | jnz .az |
3536 | 3536 | ||
3537 | cmp byte[REDRAW_BACKGROUND], 0 |
3537 | cmp byte[REDRAW_BACKGROUND], 0 |
3538 | jz .az |
3538 | jz .az |
3539 | 3539 | ||
3540 | mov dl, 0 |
3540 | mov dl, 0 |
3541 | lea eax, [edi+draw_data-window_data] |
3541 | lea eax, [edi+draw_data-window_data] |
3542 | mov ebx, [draw_limits.left] |
3542 | mov ebx, [draw_limits.left] |
3543 | cmp ebx, [eax+RECT.left] |
3543 | cmp ebx, [eax+RECT.left] |
3544 | jae @f |
3544 | jae @f |
3545 | 3545 | ||
3546 | mov [eax+RECT.left], ebx |
3546 | mov [eax+RECT.left], ebx |
3547 | mov dl, 1 |
3547 | mov dl, 1 |
3548 | ;-------------------------------------- |
3548 | ;-------------------------------------- |
3549 | align 4 |
3549 | align 4 |
3550 | @@: |
3550 | @@: |
3551 | mov ebx, [draw_limits.top] |
3551 | mov ebx, [draw_limits.top] |
3552 | cmp ebx, [eax+RECT.top] |
3552 | cmp ebx, [eax+RECT.top] |
3553 | jae @f |
3553 | jae @f |
3554 | 3554 | ||
3555 | mov [eax+RECT.top], ebx |
3555 | mov [eax+RECT.top], ebx |
3556 | mov dl, 1 |
3556 | mov dl, 1 |
3557 | ;-------------------------------------- |
3557 | ;-------------------------------------- |
3558 | align 4 |
3558 | align 4 |
3559 | @@: |
3559 | @@: |
3560 | mov ebx, [draw_limits.right] |
3560 | mov ebx, [draw_limits.right] |
3561 | cmp ebx, [eax+RECT.right] |
3561 | cmp ebx, [eax+RECT.right] |
3562 | jbe @f |
3562 | jbe @f |
3563 | 3563 | ||
3564 | mov [eax+RECT.right], ebx |
3564 | mov [eax+RECT.right], ebx |
3565 | mov dl, 1 |
3565 | mov dl, 1 |
3566 | ;-------------------------------------- |
3566 | ;-------------------------------------- |
3567 | align 4 |
3567 | align 4 |
3568 | @@: |
3568 | @@: |
3569 | mov ebx, [draw_limits.bottom] |
3569 | mov ebx, [draw_limits.bottom] |
3570 | cmp ebx, [eax+RECT.bottom] |
3570 | cmp ebx, [eax+RECT.bottom] |
3571 | jbe @f |
3571 | jbe @f |
3572 | 3572 | ||
3573 | mov [eax+RECT.bottom], ebx |
3573 | mov [eax+RECT.bottom], ebx |
3574 | mov dl, 1 |
3574 | mov dl, 1 |
3575 | ;-------------------------------------- |
3575 | ;-------------------------------------- |
3576 | align 4 |
3576 | align 4 |
3577 | @@: |
3577 | @@: |
3578 | add byte[REDRAW_BACKGROUND], dl |
3578 | add byte[REDRAW_BACKGROUND], dl |
3579 | jmp newdw8 |
3579 | jmp newdw8 |
3580 | ;-------------------------------------- |
3580 | ;-------------------------------------- |
3581 | align 4 |
3581 | align 4 |
3582 | .az: |
3582 | .az: |
3583 | mov eax, edi |
3583 | mov eax, edi |
3584 | add eax, draw_data-window_data |
3584 | add eax, draw_data-window_data |
3585 | 3585 | ||
3586 | mov ebx, [draw_limits.left] ; set limits |
3586 | mov ebx, [draw_limits.left] ; set limits |
3587 | mov [eax + RECT.left], ebx |
3587 | mov [eax + RECT.left], ebx |
3588 | mov ebx, [draw_limits.top] |
3588 | mov ebx, [draw_limits.top] |
3589 | mov [eax + RECT.top], ebx |
3589 | mov [eax + RECT.top], ebx |
3590 | mov ebx, [draw_limits.right] |
3590 | mov ebx, [draw_limits.right] |
3591 | mov [eax + RECT.right], ebx |
3591 | mov [eax + RECT.right], ebx |
3592 | mov ebx, [draw_limits.bottom] |
3592 | mov ebx, [draw_limits.bottom] |
3593 | mov [eax + RECT.bottom], ebx |
3593 | mov [eax + RECT.bottom], ebx |
3594 | 3594 | ||
3595 | sub eax, draw_data-window_data |
3595 | sub eax, draw_data-window_data |
3596 | 3596 | ||
3597 | cmp dword [esp], 1 |
3597 | cmp dword [esp], 1 |
3598 | jne nobgrd |
3598 | jne nobgrd |
3599 | inc byte[REDRAW_BACKGROUND] |
3599 | inc byte[REDRAW_BACKGROUND] |
3600 | ;-------------------------------------- |
3600 | ;-------------------------------------- |
3601 | align 4 |
3601 | align 4 |
3602 | newdw8: |
3602 | newdw8: |
3603 | nobgrd: |
3603 | nobgrd: |
3604 | 3604 | ||
3605 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3605 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3606 | ;-------------------------------------- |
3606 | ;-------------------------------------- |
3607 | align 4 |
3607 | align 4 |
3608 | ricino: |
3608 | ricino: |
3609 | not_this_task: |
3609 | not_this_task: |
3610 | pop ecx |
3610 | pop ecx |
3611 | 3611 | ||
3612 | cmp ecx, [TASK_COUNT] |
3612 | cmp ecx, [TASK_COUNT] |
3613 | jle newdw2 |
3613 | jle newdw2 |
3614 | 3614 | ||
3615 | pop eax |
3615 | pop eax |
3616 | popad |
3616 | popad |
3617 | ret |
3617 | ret |
3618 | ;----------------------------------------------------------------------------- |
3618 | ;----------------------------------------------------------------------------- |
3619 | align 4 |
3619 | align 4 |
3620 | calculatebackground: ; background |
3620 | calculatebackground: ; background |
3621 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3621 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3622 | mov eax, 0x01010101 |
3622 | mov eax, 0x01010101 |
3623 | mov ecx, [_WinMapSize] |
3623 | mov ecx, [_WinMapSize] |
3624 | shr ecx, 2 |
3624 | shr ecx, 2 |
3625 | rep stosd |
3625 | rep stosd |
3626 | 3626 | ||
3627 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3627 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3628 | ret |
3628 | ret |
3629 | ;----------------------------------------------------------------------------- |
3629 | ;----------------------------------------------------------------------------- |
3630 | uglobal |
3630 | uglobal |
3631 | imax dd 0x0 |
3631 | imax dd 0x0 |
3632 | endg |
3632 | endg |
3633 | ;----------------------------------------------------------------------------- |
3633 | ;----------------------------------------------------------------------------- |
3634 | align 4 |
3634 | align 4 |
3635 | delay_ms: ; delay in 1/1000 sec |
3635 | delay_ms: ; delay in 1/1000 sec |
3636 | push eax |
3636 | push eax |
3637 | push ecx |
3637 | push ecx |
3638 | 3638 | ||
3639 | mov ecx, esi |
3639 | mov ecx, esi |
3640 | ; |
3640 | ; |
3641 | imul ecx, 33941 |
3641 | imul ecx, 33941 |
3642 | shr ecx, 9 |
3642 | shr ecx, 9 |
3643 | ; |
3643 | ; |
3644 | 3644 | ||
3645 | in al, 0x61 |
3645 | in al, 0x61 |
3646 | and al, 0x10 |
3646 | and al, 0x10 |
3647 | mov ah, al |
3647 | mov ah, al |
3648 | cld |
3648 | cld |
3649 | ;-------------------------------------- |
3649 | ;-------------------------------------- |
3650 | align 4 |
3650 | align 4 |
3651 | cnt1: |
3651 | cnt1: |
3652 | in al, 0x61 |
3652 | in al, 0x61 |
3653 | and al, 0x10 |
3653 | and al, 0x10 |
3654 | cmp al, ah |
3654 | cmp al, ah |
3655 | jz cnt1 |
3655 | jz cnt1 |
3656 | 3656 | ||
3657 | mov ah, al |
3657 | mov ah, al |
3658 | loop cnt1 |
3658 | loop cnt1 |
3659 | 3659 | ||
3660 | pop ecx |
3660 | pop ecx |
3661 | pop eax |
3661 | pop eax |
3662 | ret |
3662 | ret |
3663 | ;----------------------------------------------------------------------------- |
3663 | ;----------------------------------------------------------------------------- |
3664 | align 4 |
3664 | align 4 |
3665 | set_app_param: |
3665 | set_app_param: |
3666 | mov edi, [TASK_BASE] |
3666 | mov edi, [TASK_BASE] |
3667 | mov eax, ebx |
3667 | mov eax, ebx |
3668 | btr eax, 3 ; move MOUSE_FILTRATION |
3668 | btr eax, 3 ; move MOUSE_FILTRATION |
3669 | mov ebx, [current_slot] ; bit into event_filter |
3669 | mov ebx, [current_slot] ; bit into event_filter |
3670 | setc byte [ebx+APPDATA.event_filter] |
3670 | setc byte [ebx+APPDATA.event_filter] |
3671 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3671 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3672 | mov [esp+32], eax ; return old mask value |
3672 | mov [esp+32], eax ; return old mask value |
3673 | ret |
3673 | ret |
3674 | ;----------------------------------------------------------------------------- |
3674 | ;----------------------------------------------------------------------------- |
3675 | align 4 |
3675 | align 4 |
3676 | delay_hs: ; delay in 1/100 secs |
3676 | delay_hs: ; delay in 1/100 secs |
3677 | ; ebx = delay time |
3677 | ; ebx = delay time |
3678 | push ecx |
3678 | push ecx |
3679 | push edx |
3679 | push edx |
3680 | 3680 | ||
3681 | mov edx, [timer_ticks] |
3681 | mov edx, [timer_ticks] |
3682 | ;-------------------------------------- |
3682 | ;-------------------------------------- |
3683 | align 4 |
3683 | align 4 |
3684 | newtic: |
3684 | newtic: |
3685 | mov ecx, [timer_ticks] |
3685 | mov ecx, [timer_ticks] |
3686 | sub ecx, edx |
3686 | sub ecx, edx |
3687 | cmp ecx, ebx |
3687 | cmp ecx, ebx |
3688 | jae zerodelay |
3688 | jae zerodelay |
3689 | 3689 | ||
3690 | call change_task |
3690 | call change_task |
3691 | 3691 | ||
3692 | jmp newtic |
3692 | jmp newtic |
3693 | ;-------------------------------------- |
3693 | ;-------------------------------------- |
3694 | align 4 |
3694 | align 4 |
3695 | zerodelay: |
3695 | zerodelay: |
3696 | pop edx |
3696 | pop edx |
3697 | pop ecx |
3697 | pop ecx |
3698 | ret |
3698 | ret |
3699 | ;----------------------------------------------------------------------------- |
3699 | ;----------------------------------------------------------------------------- |
3700 | align 16 ;very often call this subrutine |
3700 | align 16 ;very often call this subrutine |
3701 | memmove: ; memory move in bytes |
3701 | memmove: ; memory move in bytes |
3702 | ; eax = from |
3702 | ; eax = from |
3703 | ; ebx = to |
3703 | ; ebx = to |
3704 | ; ecx = no of bytes |
3704 | ; ecx = no of bytes |
3705 | test ecx, ecx |
3705 | test ecx, ecx |
3706 | jle .ret |
3706 | jle .ret |
3707 | 3707 | ||
3708 | push esi edi ecx |
3708 | push esi edi ecx |
3709 | 3709 | ||
3710 | mov edi, ebx |
3710 | mov edi, ebx |
3711 | mov esi, eax |
3711 | mov esi, eax |
3712 | 3712 | ||
3713 | test ecx, not 11b |
3713 | test ecx, not 11b |
3714 | jz @f |
3714 | jz @f |
3715 | 3715 | ||
3716 | push ecx |
3716 | push ecx |
3717 | shr ecx, 2 |
3717 | shr ecx, 2 |
3718 | rep movsd |
3718 | rep movsd |
3719 | pop ecx |
3719 | pop ecx |
3720 | and ecx, 11b |
3720 | and ecx, 11b |
3721 | jz .finish |
3721 | jz .finish |
3722 | ;-------------------------------------- |
3722 | ;-------------------------------------- |
3723 | align 4 |
3723 | align 4 |
3724 | @@: |
3724 | @@: |
3725 | rep movsb |
3725 | rep movsb |
3726 | ;-------------------------------------- |
3726 | ;-------------------------------------- |
3727 | align 4 |
3727 | align 4 |
3728 | .finish: |
3728 | .finish: |
3729 | pop ecx edi esi |
3729 | pop ecx edi esi |
3730 | ;-------------------------------------- |
3730 | ;-------------------------------------- |
3731 | align 4 |
3731 | align 4 |
3732 | .ret: |
3732 | .ret: |
3733 | ret |
3733 | ret |
3734 | ;----------------------------------------------------------------------------- |
3734 | ;----------------------------------------------------------------------------- |
3735 | ; |
3735 | ; |
3736 | ;align 4 |
3736 | ;align 4 |
3737 | ; |
3737 | ; |
3738 | ;read_floppy_file: |
3738 | ;read_floppy_file: |
3739 | ; |
3739 | ; |
3740 | ;; as input |
3740 | ;; as input |
3741 | ;; |
3741 | ;; |
3742 | ;; eax pointer to file |
3742 | ;; eax pointer to file |
3743 | ;; ebx file lenght |
3743 | ;; ebx file lenght |
3744 | ;; ecx start 512 byte block number |
3744 | ;; ecx start 512 byte block number |
3745 | ;; edx number of blocks to read |
3745 | ;; edx number of blocks to read |
3746 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3746 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3747 | ;; |
3747 | ;; |
3748 | ;; |
3748 | ;; |
3749 | ;; on return |
3749 | ;; on return |
3750 | ;; |
3750 | ;; |
3751 | ;; eax = 0 command succesful |
3751 | ;; eax = 0 command succesful |
3752 | ;; 1 no fd base and/or partition defined |
3752 | ;; 1 no fd base and/or partition defined |
3753 | ;; 2 yet unsupported FS |
3753 | ;; 2 yet unsupported FS |
3754 | ;; 3 unknown FS |
3754 | ;; 3 unknown FS |
3755 | ;; 4 partition not defined at hd |
3755 | ;; 4 partition not defined at hd |
3756 | ;; 5 file not found |
3756 | ;; 5 file not found |
3757 | ;; ebx = size of file |
3757 | ;; ebx = size of file |
3758 | ; |
3758 | ; |
3759 | ; mov edi,[TASK_BASE] |
3759 | ; mov edi,[TASK_BASE] |
3760 | ; add edi,0x10 |
3760 | ; add edi,0x10 |
3761 | ; add esi,[edi] |
3761 | ; add esi,[edi] |
3762 | ; add eax,[edi] |
3762 | ; add eax,[edi] |
3763 | ; |
3763 | ; |
3764 | ; pushad |
3764 | ; pushad |
3765 | ; mov edi,esi |
3765 | ; mov edi,esi |
3766 | ; add edi,1024 |
3766 | ; add edi,1024 |
3767 | ; mov esi,0x100000+19*512 |
3767 | ; mov esi,0x100000+19*512 |
3768 | ; sub ecx,1 |
3768 | ; sub ecx,1 |
3769 | ; shl ecx,9 |
3769 | ; shl ecx,9 |
3770 | ; add esi,ecx |
3770 | ; add esi,ecx |
3771 | ; shl edx,9 |
3771 | ; shl edx,9 |
3772 | ; mov ecx,edx |
3772 | ; mov ecx,edx |
3773 | ; cld |
3773 | ; cld |
3774 | ; rep movsb |
3774 | ; rep movsb |
3775 | ; popad |
3775 | ; popad |
3776 | ; |
3776 | ; |
3777 | ; mov [esp+36],eax |
3777 | ; mov [esp+36],eax |
3778 | ; mov [esp+24],ebx |
3778 | ; mov [esp+24],ebx |
3779 | ; ret |
3779 | ; ret |
3780 | 3780 | ||
3781 | 3781 | ||
3782 | 3782 | ||
3783 | align 4 |
3783 | align 4 |
3784 | set_io_access_rights: |
3784 | set_io_access_rights: |
3785 | push edi eax |
3785 | push edi eax |
3786 | mov edi, tss._io_map_0 |
3786 | mov edi, tss._io_map_0 |
3787 | ; mov ecx,eax |
3787 | ; mov ecx,eax |
3788 | ; and ecx,7 ; offset in byte |
3788 | ; and ecx,7 ; offset in byte |
3789 | ; shr eax,3 ; number of byte |
3789 | ; shr eax,3 ; number of byte |
3790 | ; add edi,eax |
3790 | ; add edi,eax |
3791 | ; mov ebx,1 |
3791 | ; mov ebx,1 |
3792 | ; shl ebx,cl |
3792 | ; shl ebx,cl |
3793 | test ebp, ebp |
3793 | test ebp, ebp |
3794 | ; cmp ebp,0 ; enable access - ebp = 0 |
3794 | ; cmp ebp,0 ; enable access - ebp = 0 |
3795 | jnz .siar1 |
3795 | jnz .siar1 |
3796 | ; not ebx |
3796 | ; not ebx |
3797 | ; and [edi],byte bl |
3797 | ; and [edi],byte bl |
3798 | btr [edi], eax |
3798 | btr [edi], eax |
3799 | pop eax edi |
3799 | pop eax edi |
3800 | ret |
3800 | ret |
3801 | .siar1: |
3801 | .siar1: |
3802 | bts [edi], eax |
3802 | bts [edi], eax |
3803 | ; or [edi],byte bl ; disable access - ebp = 1 |
3803 | ; or [edi],byte bl ; disable access - ebp = 1 |
3804 | pop eax edi |
3804 | pop eax edi |
3805 | ret |
3805 | ret |
3806 | ;reserve/free group of ports |
3806 | ;reserve/free group of ports |
3807 | ; * eax = 46 - number function |
3807 | ; * eax = 46 - number function |
3808 | ; * ebx = 0 - reserve, 1 - free |
3808 | ; * ebx = 0 - reserve, 1 - free |
3809 | ; * ecx = number start arrea of ports |
3809 | ; * ecx = number start arrea of ports |
3810 | ; * edx = number end arrea of ports (include last number of port) |
3810 | ; * edx = number end arrea of ports (include last number of port) |
3811 | ;Return value: |
3811 | ;Return value: |
3812 | ; * eax = 0 - succesful |
3812 | ; * eax = 0 - succesful |
3813 | ; * eax = 1 - error |
3813 | ; * eax = 1 - error |
3814 | ; * The system has reserve this ports: |
3814 | ; * The system has reserve this ports: |
3815 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3815 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3816 | ;destroys eax,ebx, ebp |
3816 | ;destroys eax,ebx, ebp |
3817 | r_f_port_area: |
3817 | r_f_port_area: |
3818 | 3818 | ||
3819 | test ebx, ebx |
3819 | test ebx, ebx |
3820 | jnz free_port_area |
3820 | jnz free_port_area |
3821 | ; je r_port_area |
3821 | ; je r_port_area |
3822 | ; jmp free_port_area |
3822 | ; jmp free_port_area |
3823 | 3823 | ||
3824 | ; r_port_area: |
3824 | ; r_port_area: |
3825 | 3825 | ||
3826 | ; pushad |
3826 | ; pushad |
3827 | 3827 | ||
3828 | cmp ecx, edx ; beginning > end ? |
3828 | cmp ecx, edx ; beginning > end ? |
3829 | ja rpal1 |
3829 | ja rpal1 |
3830 | cmp edx, 65536 |
3830 | cmp edx, 65536 |
3831 | jae rpal1 |
3831 | jae rpal1 |
3832 | mov eax, [RESERVED_PORTS] |
3832 | mov eax, [RESERVED_PORTS] |
3833 | test eax, eax ; no reserved areas ? |
3833 | test eax, eax ; no reserved areas ? |
3834 | je rpal2 |
3834 | je rpal2 |
3835 | cmp eax, 255 ; max reserved |
3835 | cmp eax, 255 ; max reserved |
3836 | jae rpal1 |
3836 | jae rpal1 |
3837 | rpal3: |
3837 | rpal3: |
3838 | mov ebx, eax |
3838 | mov ebx, eax |
3839 | shl ebx, 4 |
3839 | shl ebx, 4 |
3840 | add ebx, RESERVED_PORTS |
3840 | add ebx, RESERVED_PORTS |
3841 | cmp ecx, [ebx+8] |
3841 | cmp ecx, [ebx+8] |
3842 | ja rpal4 |
3842 | ja rpal4 |
3843 | cmp edx, [ebx+4] |
3843 | cmp edx, [ebx+4] |
3844 | jae rpal1 |
3844 | jae rpal1 |
3845 | ; jb rpal4 |
3845 | ; jb rpal4 |
3846 | ; jmp rpal1 |
3846 | ; jmp rpal1 |
3847 | rpal4: |
3847 | rpal4: |
3848 | dec eax |
3848 | dec eax |
3849 | jnz rpal3 |
3849 | jnz rpal3 |
3850 | jmp rpal2 |
3850 | jmp rpal2 |
3851 | rpal1: |
3851 | rpal1: |
3852 | ; popad |
3852 | ; popad |
3853 | ; mov eax,1 |
3853 | ; mov eax,1 |
3854 | xor eax, eax |
3854 | xor eax, eax |
3855 | inc eax |
3855 | inc eax |
3856 | ret |
3856 | ret |
3857 | rpal2: |
3857 | rpal2: |
3858 | ; popad |
3858 | ; popad |
3859 | ; enable port access at port IO map |
3859 | ; enable port access at port IO map |
3860 | cli |
3860 | cli |
3861 | pushad ; start enable io map |
3861 | pushad ; start enable io map |
3862 | 3862 | ||
3863 | cmp edx, 65536;16384 |
3863 | cmp edx, 65536;16384 |
3864 | jae no_unmask_io; jge |
3864 | jae no_unmask_io; jge |
3865 | mov eax, ecx |
3865 | mov eax, ecx |
3866 | ; push ebp |
3866 | ; push ebp |
3867 | xor ebp, ebp ; enable - eax = port |
3867 | xor ebp, ebp ; enable - eax = port |
3868 | new_port_access: |
3868 | new_port_access: |
3869 | ; pushad |
3869 | ; pushad |
3870 | call set_io_access_rights |
3870 | call set_io_access_rights |
3871 | ; popad |
3871 | ; popad |
3872 | inc eax |
3872 | inc eax |
3873 | cmp eax, edx |
3873 | cmp eax, edx |
3874 | jbe new_port_access |
3874 | jbe new_port_access |
3875 | ; pop ebp |
3875 | ; pop ebp |
3876 | no_unmask_io: |
3876 | no_unmask_io: |
3877 | popad ; end enable io map |
3877 | popad ; end enable io map |
3878 | sti |
3878 | sti |
3879 | 3879 | ||
3880 | mov eax, [RESERVED_PORTS] |
3880 | mov eax, [RESERVED_PORTS] |
3881 | add eax, 1 |
3881 | add eax, 1 |
3882 | mov [RESERVED_PORTS], eax |
3882 | mov [RESERVED_PORTS], eax |
3883 | shl eax, 4 |
3883 | shl eax, 4 |
3884 | add eax, RESERVED_PORTS |
3884 | add eax, RESERVED_PORTS |
3885 | mov ebx, [TASK_BASE] |
3885 | mov ebx, [TASK_BASE] |
3886 | mov ebx, [ebx+TASKDATA.pid] |
3886 | mov ebx, [ebx+TASKDATA.pid] |
3887 | mov [eax], ebx |
3887 | mov [eax], ebx |
3888 | mov [eax+4], ecx |
3888 | mov [eax+4], ecx |
3889 | mov [eax+8], edx |
3889 | mov [eax+8], edx |
3890 | 3890 | ||
3891 | xor eax, eax |
3891 | xor eax, eax |
3892 | ret |
3892 | ret |
3893 | 3893 | ||
3894 | free_port_area: |
3894 | free_port_area: |
3895 | 3895 | ||
3896 | ; pushad |
3896 | ; pushad |
3897 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
3897 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
3898 | test eax, eax |
3898 | test eax, eax |
3899 | jz frpal2 |
3899 | jz frpal2 |
3900 | mov ebx, [TASK_BASE] |
3900 | mov ebx, [TASK_BASE] |
3901 | mov ebx, [ebx+TASKDATA.pid] |
3901 | mov ebx, [ebx+TASKDATA.pid] |
3902 | frpal3: |
3902 | frpal3: |
3903 | mov edi, eax |
3903 | mov edi, eax |
3904 | shl edi, 4 |
3904 | shl edi, 4 |
3905 | add edi, RESERVED_PORTS |
3905 | add edi, RESERVED_PORTS |
3906 | cmp ebx, [edi] |
3906 | cmp ebx, [edi] |
3907 | jne frpal4 |
3907 | jne frpal4 |
3908 | cmp ecx, [edi+4] |
3908 | cmp ecx, [edi+4] |
3909 | jne frpal4 |
3909 | jne frpal4 |
3910 | cmp edx, [edi+8] |
3910 | cmp edx, [edi+8] |
3911 | jne frpal4 |
3911 | jne frpal4 |
3912 | jmp frpal1 |
3912 | jmp frpal1 |
3913 | frpal4: |
3913 | frpal4: |
3914 | dec eax |
3914 | dec eax |
3915 | jnz frpal3 |
3915 | jnz frpal3 |
3916 | frpal2: |
3916 | frpal2: |
3917 | ; popad |
3917 | ; popad |
3918 | inc eax |
3918 | inc eax |
3919 | ret |
3919 | ret |
3920 | frpal1: |
3920 | frpal1: |
3921 | push ecx |
3921 | push ecx |
3922 | mov ecx, 256 |
3922 | mov ecx, 256 |
3923 | sub ecx, eax |
3923 | sub ecx, eax |
3924 | shl ecx, 4 |
3924 | shl ecx, 4 |
3925 | mov esi, edi |
3925 | mov esi, edi |
3926 | add esi, 16 |
3926 | add esi, 16 |
3927 | cld |
3927 | cld |
3928 | rep movsb |
3928 | rep movsb |
3929 | 3929 | ||
3930 | dec dword [RESERVED_PORTS] |
3930 | dec dword [RESERVED_PORTS] |
3931 | ;popad |
3931 | ;popad |
3932 | ;disable port access at port IO map |
3932 | ;disable port access at port IO map |
3933 | 3933 | ||
3934 | ; pushad ; start disable io map |
3934 | ; pushad ; start disable io map |
3935 | pop eax ;start port |
3935 | pop eax ;start port |
3936 | cmp edx, 65536;16384 |
3936 | cmp edx, 65536;16384 |
3937 | jge no_mask_io |
3937 | jge no_mask_io |
3938 | 3938 | ||
3939 | ; mov eax,ecx |
3939 | ; mov eax,ecx |
3940 | xor ebp, ebp |
3940 | xor ebp, ebp |
3941 | inc ebp |
3941 | inc ebp |
3942 | new_port_access_disable: |
3942 | new_port_access_disable: |
3943 | ; pushad |
3943 | ; pushad |
3944 | ; mov ebp,1 ; disable - eax = port |
3944 | ; mov ebp,1 ; disable - eax = port |
3945 | call set_io_access_rights |
3945 | call set_io_access_rights |
3946 | ; popad |
3946 | ; popad |
3947 | inc eax |
3947 | inc eax |
3948 | cmp eax, edx |
3948 | cmp eax, edx |
3949 | jbe new_port_access_disable |
3949 | jbe new_port_access_disable |
3950 | no_mask_io: |
3950 | no_mask_io: |
3951 | ; popad ; end disable io map |
3951 | ; popad ; end disable io map |
3952 | xor eax, eax |
3952 | xor eax, eax |
3953 | ret |
3953 | ret |
3954 | ;----------------------------------------------------------------------------- |
3954 | ;----------------------------------------------------------------------------- |
3955 | align 4 |
3955 | align 4 |
3956 | drawbackground: |
3956 | drawbackground: |
3957 | dbrv20: |
3957 | dbrv20: |
3958 | cmp [BgrDrawMode], dword 1 |
3958 | cmp [BgrDrawMode], dword 1 |
3959 | jne bgrstr |
3959 | jne bgrstr |
3960 | call vesa20_drawbackground_tiled |
3960 | call vesa20_drawbackground_tiled |
3961 | ; call [draw_pointer] |
3961 | ; call [draw_pointer] |
3962 | call __sys_draw_pointer |
3962 | call __sys_draw_pointer |
3963 | ret |
3963 | ret |
3964 | ;-------------------------------------- |
3964 | ;-------------------------------------- |
3965 | align 4 |
3965 | align 4 |
3966 | bgrstr: |
3966 | bgrstr: |
3967 | call vesa20_drawbackground_stretch |
3967 | call vesa20_drawbackground_stretch |
3968 | ; call [draw_pointer] |
3968 | ; call [draw_pointer] |
3969 | call __sys_draw_pointer |
3969 | call __sys_draw_pointer |
3970 | ret |
3970 | ret |
3971 | ;----------------------------------------------------------------------------- |
3971 | ;----------------------------------------------------------------------------- |
3972 | align 4 |
3972 | align 4 |
3973 | syscall_putimage: ; PutImage |
3973 | syscall_putimage: ; PutImage |
3974 | sys_putimage: |
3974 | sys_putimage: |
3975 | test ecx, 0x80008000 |
3975 | test ecx, 0x80008000 |
3976 | jnz .exit |
3976 | jnz .exit |
3977 | test ecx, 0x0000FFFF |
3977 | test ecx, 0x0000FFFF |
3978 | jz .exit |
3978 | jz .exit |
3979 | test ecx, 0xFFFF0000 |
3979 | test ecx, 0xFFFF0000 |
3980 | jnz @f |
3980 | jnz @f |
3981 | ;-------------------------------------- |
3981 | ;-------------------------------------- |
3982 | align 4 |
3982 | align 4 |
3983 | .exit: |
3983 | .exit: |
3984 | ret |
3984 | ret |
3985 | ;-------------------------------------- |
3985 | ;-------------------------------------- |
3986 | align 4 |
3986 | align 4 |
3987 | @@: |
3987 | @@: |
3988 | mov edi, [current_slot] |
3988 | mov edi, [current_slot] |
3989 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
3989 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
3990 | rol edx, 16 |
3990 | rol edx, 16 |
3991 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
3991 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
3992 | rol edx, 16 |
3992 | rol edx, 16 |
3993 | ;-------------------------------------- |
3993 | ;-------------------------------------- |
3994 | align 4 |
3994 | align 4 |
3995 | .forced: |
3995 | .forced: |
3996 | push ebp esi 0 |
3996 | push ebp esi 0 |
3997 | mov ebp, putimage_get24bpp |
3997 | mov ebp, putimage_get24bpp |
3998 | mov esi, putimage_init24bpp |
3998 | mov esi, putimage_init24bpp |
3999 | ;-------------------------------------- |
3999 | ;-------------------------------------- |
4000 | align 4 |
4000 | align 4 |
4001 | sys_putimage_bpp: |
4001 | sys_putimage_bpp: |
4002 | call vesa20_putimage |
4002 | call vesa20_putimage |
4003 | pop ebp esi ebp |
4003 | pop ebp esi ebp |
4004 | ret |
4004 | ret |
4005 | ; jmp [draw_pointer] |
4005 | ; jmp [draw_pointer] |
4006 | ;----------------------------------------------------------------------------- |
4006 | ;----------------------------------------------------------------------------- |
4007 | align 4 |
4007 | align 4 |
4008 | sys_putimage_palette: |
4008 | sys_putimage_palette: |
4009 | ; ebx = pointer to image |
4009 | ; ebx = pointer to image |
4010 | ; ecx = [xsize]*65536 + [ysize] |
4010 | ; ecx = [xsize]*65536 + [ysize] |
4011 | ; edx = [xstart]*65536 + [ystart] |
4011 | ; edx = [xstart]*65536 + [ystart] |
4012 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4012 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4013 | ; edi = pointer to palette |
4013 | ; edi = pointer to palette |
4014 | ; ebp = row delta |
4014 | ; ebp = row delta |
4015 | mov eax, [CURRENT_TASK] |
4015 | mov eax, [CURRENT_TASK] |
4016 | shl eax, 8 |
4016 | shl eax, 8 |
4017 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4017 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4018 | rol edx, 16 |
4018 | rol edx, 16 |
4019 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4019 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4020 | rol edx, 16 |
4020 | rol edx, 16 |
4021 | ;-------------------------------------- |
4021 | ;-------------------------------------- |
4022 | align 4 |
4022 | align 4 |
4023 | .forced: |
4023 | .forced: |
4024 | cmp esi, 1 |
4024 | cmp esi, 1 |
4025 | jnz @f |
4025 | jnz @f |
4026 | push edi |
4026 | push edi |
4027 | mov eax, [edi+4] |
4027 | mov eax, [edi+4] |
4028 | sub eax, [edi] |
4028 | sub eax, [edi] |
4029 | push eax |
4029 | push eax |
4030 | push dword [edi] |
4030 | push dword [edi] |
4031 | push 0ffffff80h |
4031 | push 0ffffff80h |
4032 | mov edi, esp |
4032 | mov edi, esp |
4033 | call put_mono_image |
4033 | call put_mono_image |
4034 | add esp, 12 |
4034 | add esp, 12 |
4035 | pop edi |
4035 | pop edi |
4036 | ret |
4036 | ret |
4037 | ;-------------------------------------- |
4037 | ;-------------------------------------- |
4038 | align 4 |
4038 | align 4 |
4039 | @@: |
4039 | @@: |
4040 | cmp esi, 2 |
4040 | cmp esi, 2 |
4041 | jnz @f |
4041 | jnz @f |
4042 | push edi |
4042 | push edi |
4043 | push 0ffffff80h |
4043 | push 0ffffff80h |
4044 | mov edi, esp |
4044 | mov edi, esp |
4045 | call put_2bit_image |
4045 | call put_2bit_image |
4046 | pop eax |
4046 | pop eax |
4047 | pop edi |
4047 | pop edi |
4048 | ret |
4048 | ret |
4049 | ;-------------------------------------- |
4049 | ;-------------------------------------- |
4050 | align 4 |
4050 | align 4 |
4051 | @@: |
4051 | @@: |
4052 | cmp esi, 4 |
4052 | cmp esi, 4 |
4053 | jnz @f |
4053 | jnz @f |
4054 | push edi |
4054 | push edi |
4055 | push 0ffffff80h |
4055 | push 0ffffff80h |
4056 | mov edi, esp |
4056 | mov edi, esp |
4057 | call put_4bit_image |
4057 | call put_4bit_image |
4058 | pop eax |
4058 | pop eax |
4059 | pop edi |
4059 | pop edi |
4060 | ret |
4060 | ret |
4061 | ;-------------------------------------- |
4061 | ;-------------------------------------- |
4062 | align 4 |
4062 | align 4 |
4063 | @@: |
4063 | @@: |
4064 | push ebp esi ebp |
4064 | push ebp esi ebp |
4065 | cmp esi, 8 |
4065 | cmp esi, 8 |
4066 | jnz @f |
4066 | jnz @f |
4067 | mov ebp, putimage_get8bpp |
4067 | mov ebp, putimage_get8bpp |
4068 | mov esi, putimage_init8bpp |
4068 | mov esi, putimage_init8bpp |
4069 | jmp sys_putimage_bpp |
4069 | jmp sys_putimage_bpp |
4070 | ;-------------------------------------- |
4070 | ;-------------------------------------- |
4071 | align 4 |
4071 | align 4 |
4072 | @@: |
4072 | @@: |
4073 | cmp esi, 15 |
4073 | cmp esi, 15 |
4074 | jnz @f |
4074 | jnz @f |
4075 | mov ebp, putimage_get15bpp |
4075 | mov ebp, putimage_get15bpp |
4076 | mov esi, putimage_init15bpp |
4076 | mov esi, putimage_init15bpp |
4077 | jmp sys_putimage_bpp |
4077 | jmp sys_putimage_bpp |
4078 | ;-------------------------------------- |
4078 | ;-------------------------------------- |
4079 | align 4 |
4079 | align 4 |
4080 | @@: |
4080 | @@: |
4081 | cmp esi, 16 |
4081 | cmp esi, 16 |
4082 | jnz @f |
4082 | jnz @f |
4083 | mov ebp, putimage_get16bpp |
4083 | mov ebp, putimage_get16bpp |
4084 | mov esi, putimage_init16bpp |
4084 | mov esi, putimage_init16bpp |
4085 | jmp sys_putimage_bpp |
4085 | jmp sys_putimage_bpp |
4086 | ;-------------------------------------- |
4086 | ;-------------------------------------- |
4087 | align 4 |
4087 | align 4 |
4088 | @@: |
4088 | @@: |
4089 | cmp esi, 24 |
4089 | cmp esi, 24 |
4090 | jnz @f |
4090 | jnz @f |
4091 | mov ebp, putimage_get24bpp |
4091 | mov ebp, putimage_get24bpp |
4092 | mov esi, putimage_init24bpp |
4092 | mov esi, putimage_init24bpp |
4093 | jmp sys_putimage_bpp |
4093 | jmp sys_putimage_bpp |
4094 | ;-------------------------------------- |
4094 | ;-------------------------------------- |
4095 | align 4 |
4095 | align 4 |
4096 | @@: |
4096 | @@: |
4097 | cmp esi, 32 |
4097 | cmp esi, 32 |
4098 | jnz @f |
4098 | jnz @f |
4099 | mov ebp, putimage_get32bpp |
4099 | mov ebp, putimage_get32bpp |
4100 | mov esi, putimage_init32bpp |
4100 | mov esi, putimage_init32bpp |
4101 | jmp sys_putimage_bpp |
4101 | jmp sys_putimage_bpp |
4102 | ;-------------------------------------- |
4102 | ;-------------------------------------- |
4103 | align 4 |
4103 | align 4 |
4104 | @@: |
4104 | @@: |
4105 | pop ebp esi ebp |
4105 | pop ebp esi ebp |
4106 | ret |
4106 | ret |
4107 | ;----------------------------------------------------------------------------- |
4107 | ;----------------------------------------------------------------------------- |
4108 | align 4 |
4108 | align 4 |
4109 | put_mono_image: |
4109 | put_mono_image: |
4110 | push ebp esi ebp |
4110 | push ebp esi ebp |
4111 | mov ebp, putimage_get1bpp |
4111 | mov ebp, putimage_get1bpp |
4112 | mov esi, putimage_init1bpp |
4112 | mov esi, putimage_init1bpp |
4113 | jmp sys_putimage_bpp |
4113 | jmp sys_putimage_bpp |
4114 | ;----------------------------------------------------------------------------- |
4114 | ;----------------------------------------------------------------------------- |
4115 | align 4 |
4115 | align 4 |
4116 | put_2bit_image: |
4116 | put_2bit_image: |
4117 | push ebp esi ebp |
4117 | push ebp esi ebp |
4118 | mov ebp, putimage_get2bpp |
4118 | mov ebp, putimage_get2bpp |
4119 | mov esi, putimage_init2bpp |
4119 | mov esi, putimage_init2bpp |
4120 | jmp sys_putimage_bpp |
4120 | jmp sys_putimage_bpp |
4121 | ;----------------------------------------------------------------------------- |
4121 | ;----------------------------------------------------------------------------- |
4122 | align 4 |
4122 | align 4 |
4123 | put_4bit_image: |
4123 | put_4bit_image: |
4124 | push ebp esi ebp |
4124 | push ebp esi ebp |
4125 | mov ebp, putimage_get4bpp |
4125 | mov ebp, putimage_get4bpp |
4126 | mov esi, putimage_init4bpp |
4126 | mov esi, putimage_init4bpp |
4127 | jmp sys_putimage_bpp |
4127 | jmp sys_putimage_bpp |
4128 | ;----------------------------------------------------------------------------- |
4128 | ;----------------------------------------------------------------------------- |
4129 | align 4 |
4129 | align 4 |
4130 | putimage_init24bpp: |
4130 | putimage_init24bpp: |
4131 | lea eax, [eax*3] |
4131 | lea eax, [eax*3] |
4132 | putimage_init8bpp: |
4132 | putimage_init8bpp: |
4133 | ret |
4133 | ret |
4134 | ;----------------------------------------------------------------------------- |
4134 | ;----------------------------------------------------------------------------- |
4135 | align 16 |
4135 | align 16 |
4136 | putimage_get24bpp: |
4136 | putimage_get24bpp: |
4137 | movzx eax, byte [esi+2] |
4137 | movzx eax, byte [esi+2] |
4138 | shl eax, 16 |
4138 | shl eax, 16 |
4139 | mov ax, [esi] |
4139 | mov ax, [esi] |
4140 | add esi, 3 |
4140 | add esi, 3 |
4141 | ret 4 |
4141 | ret 4 |
4142 | ;----------------------------------------------------------------------------- |
4142 | ;----------------------------------------------------------------------------- |
4143 | align 16 |
4143 | align 16 |
4144 | putimage_get8bpp: |
4144 | putimage_get8bpp: |
4145 | movzx eax, byte [esi] |
4145 | movzx eax, byte [esi] |
4146 | push edx |
4146 | push edx |
4147 | mov edx, [esp+8] |
4147 | mov edx, [esp+8] |
4148 | mov eax, [edx+eax*4] |
4148 | mov eax, [edx+eax*4] |
4149 | pop edx |
4149 | pop edx |
4150 | inc esi |
4150 | inc esi |
4151 | ret 4 |
4151 | ret 4 |
4152 | ;----------------------------------------------------------------------------- |
4152 | ;----------------------------------------------------------------------------- |
4153 | align 4 |
4153 | align 4 |
4154 | putimage_init1bpp: |
4154 | putimage_init1bpp: |
4155 | add eax, ecx |
4155 | add eax, ecx |
4156 | push ecx |
4156 | push ecx |
4157 | add eax, 7 |
4157 | add eax, 7 |
4158 | add ecx, 7 |
4158 | add ecx, 7 |
4159 | shr eax, 3 |
4159 | shr eax, 3 |
4160 | shr ecx, 3 |
4160 | shr ecx, 3 |
4161 | sub eax, ecx |
4161 | sub eax, ecx |
4162 | pop ecx |
4162 | pop ecx |
4163 | ret |
4163 | ret |
4164 | ;----------------------------------------------------------------------------- |
4164 | ;----------------------------------------------------------------------------- |
4165 | align 16 |
4165 | align 16 |
4166 | putimage_get1bpp: |
4166 | putimage_get1bpp: |
4167 | push edx |
4167 | push edx |
4168 | mov edx, [esp+8] |
4168 | mov edx, [esp+8] |
4169 | mov al, [edx] |
4169 | mov al, [edx] |
4170 | add al, al |
4170 | add al, al |
4171 | jnz @f |
4171 | jnz @f |
4172 | lodsb |
4172 | lodsb |
4173 | adc al, al |
4173 | adc al, al |
4174 | @@: |
4174 | @@: |
4175 | mov [edx], al |
4175 | mov [edx], al |
4176 | sbb eax, eax |
4176 | sbb eax, eax |
4177 | and eax, [edx+8] |
4177 | and eax, [edx+8] |
4178 | add eax, [edx+4] |
4178 | add eax, [edx+4] |
4179 | pop edx |
4179 | pop edx |
4180 | ret 4 |
4180 | ret 4 |
4181 | ;----------------------------------------------------------------------------- |
4181 | ;----------------------------------------------------------------------------- |
4182 | align 4 |
4182 | align 4 |
4183 | putimage_init2bpp: |
4183 | putimage_init2bpp: |
4184 | add eax, ecx |
4184 | add eax, ecx |
4185 | push ecx |
4185 | push ecx |
4186 | add ecx, 3 |
4186 | add ecx, 3 |
4187 | add eax, 3 |
4187 | add eax, 3 |
4188 | shr ecx, 2 |
4188 | shr ecx, 2 |
4189 | shr eax, 2 |
4189 | shr eax, 2 |
4190 | sub eax, ecx |
4190 | sub eax, ecx |
4191 | pop ecx |
4191 | pop ecx |
4192 | ret |
4192 | ret |
4193 | ;----------------------------------------------------------------------------- |
4193 | ;----------------------------------------------------------------------------- |
4194 | align 16 |
4194 | align 16 |
4195 | putimage_get2bpp: |
4195 | putimage_get2bpp: |
4196 | push edx |
4196 | push edx |
4197 | mov edx, [esp+8] |
4197 | mov edx, [esp+8] |
4198 | mov al, [edx] |
4198 | mov al, [edx] |
4199 | mov ah, al |
4199 | mov ah, al |
4200 | shr al, 6 |
4200 | shr al, 6 |
4201 | shl ah, 2 |
4201 | shl ah, 2 |
4202 | jnz .nonewbyte |
4202 | jnz .nonewbyte |
4203 | lodsb |
4203 | lodsb |
4204 | mov ah, al |
4204 | mov ah, al |
4205 | shr al, 6 |
4205 | shr al, 6 |
4206 | shl ah, 2 |
4206 | shl ah, 2 |
4207 | add ah, 1 |
4207 | add ah, 1 |
4208 | .nonewbyte: |
4208 | .nonewbyte: |
4209 | mov [edx], ah |
4209 | mov [edx], ah |
4210 | mov edx, [edx+4] |
4210 | mov edx, [edx+4] |
4211 | movzx eax, al |
4211 | movzx eax, al |
4212 | mov eax, [edx+eax*4] |
4212 | mov eax, [edx+eax*4] |
4213 | pop edx |
4213 | pop edx |
4214 | ret 4 |
4214 | ret 4 |
4215 | ;----------------------------------------------------------------------------- |
4215 | ;----------------------------------------------------------------------------- |
4216 | align 4 |
4216 | align 4 |
4217 | putimage_init4bpp: |
4217 | putimage_init4bpp: |
4218 | add eax, ecx |
4218 | add eax, ecx |
4219 | push ecx |
4219 | push ecx |
4220 | add ecx, 1 |
4220 | add ecx, 1 |
4221 | add eax, 1 |
4221 | add eax, 1 |
4222 | shr ecx, 1 |
4222 | shr ecx, 1 |
4223 | shr eax, 1 |
4223 | shr eax, 1 |
4224 | sub eax, ecx |
4224 | sub eax, ecx |
4225 | pop ecx |
4225 | pop ecx |
4226 | ret |
4226 | ret |
4227 | ;----------------------------------------------------------------------------- |
4227 | ;----------------------------------------------------------------------------- |
4228 | align 16 |
4228 | align 16 |
4229 | putimage_get4bpp: |
4229 | putimage_get4bpp: |
4230 | push edx |
4230 | push edx |
4231 | mov edx, [esp+8] |
4231 | mov edx, [esp+8] |
4232 | add byte [edx], 80h |
4232 | add byte [edx], 80h |
4233 | jc @f |
4233 | jc @f |
4234 | movzx eax, byte [edx+1] |
4234 | movzx eax, byte [edx+1] |
4235 | mov edx, [edx+4] |
4235 | mov edx, [edx+4] |
4236 | and eax, 0x0F |
4236 | and eax, 0x0F |
4237 | mov eax, [edx+eax*4] |
4237 | mov eax, [edx+eax*4] |
4238 | pop edx |
4238 | pop edx |
4239 | ret 4 |
4239 | ret 4 |
4240 | @@: |
4240 | @@: |
4241 | movzx eax, byte [esi] |
4241 | movzx eax, byte [esi] |
4242 | add esi, 1 |
4242 | add esi, 1 |
4243 | mov [edx+1], al |
4243 | mov [edx+1], al |
4244 | shr eax, 4 |
4244 | shr eax, 4 |
4245 | mov edx, [edx+4] |
4245 | mov edx, [edx+4] |
4246 | mov eax, [edx+eax*4] |
4246 | mov eax, [edx+eax*4] |
4247 | pop edx |
4247 | pop edx |
4248 | ret 4 |
4248 | ret 4 |
4249 | ;----------------------------------------------------------------------------- |
4249 | ;----------------------------------------------------------------------------- |
4250 | align 4 |
4250 | align 4 |
4251 | putimage_init32bpp: |
4251 | putimage_init32bpp: |
4252 | shl eax, 2 |
4252 | shl eax, 2 |
4253 | ret |
4253 | ret |
4254 | ;----------------------------------------------------------------------------- |
4254 | ;----------------------------------------------------------------------------- |
4255 | align 16 |
4255 | align 16 |
4256 | putimage_get32bpp: |
4256 | putimage_get32bpp: |
4257 | lodsd |
4257 | lodsd |
4258 | ret 4 |
4258 | ret 4 |
4259 | ;----------------------------------------------------------------------------- |
4259 | ;----------------------------------------------------------------------------- |
4260 | align 4 |
4260 | align 4 |
4261 | putimage_init15bpp: |
4261 | putimage_init15bpp: |
4262 | putimage_init16bpp: |
4262 | putimage_init16bpp: |
4263 | add eax, eax |
4263 | add eax, eax |
4264 | ret |
4264 | ret |
4265 | ;----------------------------------------------------------------------------- |
4265 | ;----------------------------------------------------------------------------- |
4266 | align 16 |
4266 | align 16 |
4267 | putimage_get15bpp: |
4267 | putimage_get15bpp: |
4268 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4268 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4269 | push ecx edx |
4269 | push ecx edx |
4270 | movzx eax, word [esi] |
4270 | movzx eax, word [esi] |
4271 | add esi, 2 |
4271 | add esi, 2 |
4272 | mov ecx, eax |
4272 | mov ecx, eax |
4273 | mov edx, eax |
4273 | mov edx, eax |
4274 | and eax, 0x1F |
4274 | and eax, 0x1F |
4275 | and ecx, 0x1F shl 5 |
4275 | and ecx, 0x1F shl 5 |
4276 | and edx, 0x1F shl 10 |
4276 | and edx, 0x1F shl 10 |
4277 | shl eax, 3 |
4277 | shl eax, 3 |
4278 | shl ecx, 6 |
4278 | shl ecx, 6 |
4279 | shl edx, 9 |
4279 | shl edx, 9 |
4280 | or eax, ecx |
4280 | or eax, ecx |
4281 | or eax, edx |
4281 | or eax, edx |
4282 | pop edx ecx |
4282 | pop edx ecx |
4283 | ret 4 |
4283 | ret 4 |
4284 | ;----------------------------------------------------------------------------- |
4284 | ;----------------------------------------------------------------------------- |
4285 | align 16 |
4285 | align 16 |
4286 | putimage_get16bpp: |
4286 | putimage_get16bpp: |
4287 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4287 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4288 | push ecx edx |
4288 | push ecx edx |
4289 | movzx eax, word [esi] |
4289 | movzx eax, word [esi] |
4290 | add esi, 2 |
4290 | add esi, 2 |
4291 | mov ecx, eax |
4291 | mov ecx, eax |
4292 | mov edx, eax |
4292 | mov edx, eax |
4293 | and eax, 0x1F |
4293 | and eax, 0x1F |
4294 | and ecx, 0x3F shl 5 |
4294 | and ecx, 0x3F shl 5 |
4295 | and edx, 0x1F shl 11 |
4295 | and edx, 0x1F shl 11 |
4296 | shl eax, 3 |
4296 | shl eax, 3 |
4297 | shl ecx, 5 |
4297 | shl ecx, 5 |
4298 | shl edx, 8 |
4298 | shl edx, 8 |
4299 | or eax, ecx |
4299 | or eax, ecx |
4300 | or eax, edx |
4300 | or eax, edx |
4301 | pop edx ecx |
4301 | pop edx ecx |
4302 | ret 4 |
4302 | ret 4 |
4303 | ;----------------------------------------------------------------------------- |
4303 | ;----------------------------------------------------------------------------- |
4304 | ;align 4 |
4304 | ;align 4 |
4305 | ; eax x beginning |
4305 | ; eax x beginning |
4306 | ; ebx y beginning |
4306 | ; ebx y beginning |
4307 | ; ecx x end |
4307 | ; ecx x end |
4308 | ; edx y end |
4308 | ; edx y end |
4309 | ; edi color |
4309 | ; edi color |
4310 | ;__sys_drawbar: |
4310 | ;__sys_drawbar: |
4311 | ; mov esi, [current_slot] |
4311 | ; mov esi, [current_slot] |
4312 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4312 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4313 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4313 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4314 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4314 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4315 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4315 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4316 | ;-------------------------------------- |
4316 | ;-------------------------------------- |
4317 | ;align 4 |
4317 | ;align 4 |
4318 | ;.forced: |
4318 | ;.forced: |
4319 | ; call vesa20_drawbar |
4319 | ; call vesa20_drawbar |
4320 | ; call [draw_pointer] |
4320 | ; call [draw_pointer] |
4321 | ; ret |
4321 | ; ret |
4322 | ;----------------------------------------------------------------------------- |
4322 | ;----------------------------------------------------------------------------- |
4323 | align 4 |
4323 | align 4 |
4324 | kb_read: |
4324 | kb_read: |
4325 | 4325 | ||
4326 | push ecx edx |
4326 | push ecx edx |
4327 | 4327 | ||
4328 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4328 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4329 | kr_loop: |
4329 | kr_loop: |
4330 | in al, 0x64 |
4330 | in al, 0x64 |
4331 | test al, 1 |
4331 | test al, 1 |
4332 | jnz kr_ready |
4332 | jnz kr_ready |
4333 | loop kr_loop |
4333 | loop kr_loop |
4334 | mov ah, 1 |
4334 | mov ah, 1 |
4335 | jmp kr_exit |
4335 | jmp kr_exit |
4336 | kr_ready: |
4336 | kr_ready: |
4337 | push ecx |
4337 | push ecx |
4338 | mov ecx, 32 |
4338 | mov ecx, 32 |
4339 | kr_delay: |
4339 | kr_delay: |
4340 | loop kr_delay |
4340 | loop kr_delay |
4341 | pop ecx |
4341 | pop ecx |
4342 | in al, 0x60 |
4342 | in al, 0x60 |
4343 | xor ah, ah |
4343 | xor ah, ah |
4344 | kr_exit: |
4344 | kr_exit: |
4345 | 4345 | ||
4346 | pop edx ecx |
4346 | pop edx ecx |
4347 | 4347 | ||
4348 | ret |
4348 | ret |
4349 | ;----------------------------------------------------------------------------- |
4349 | ;----------------------------------------------------------------------------- |
4350 | align 4 |
4350 | align 4 |
4351 | kb_write: |
4351 | kb_write: |
4352 | 4352 | ||
4353 | push ecx edx |
4353 | push ecx edx |
4354 | 4354 | ||
4355 | mov dl, al |
4355 | mov dl, al |
4356 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4356 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4357 | ; kw_loop1: |
4357 | ; kw_loop1: |
4358 | ; in al,0x64 |
4358 | ; in al,0x64 |
4359 | ; test al,0x20 |
4359 | ; test al,0x20 |
4360 | ; jz kw_ok1 |
4360 | ; jz kw_ok1 |
4361 | ; loop kw_loop1 |
4361 | ; loop kw_loop1 |
4362 | ; mov ah,1 |
4362 | ; mov ah,1 |
4363 | ; jmp kw_exit |
4363 | ; jmp kw_exit |
4364 | ; kw_ok1: |
4364 | ; kw_ok1: |
4365 | in al, 0x60 |
4365 | in al, 0x60 |
4366 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4366 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4367 | kw_loop: |
4367 | kw_loop: |
4368 | in al, 0x64 |
4368 | in al, 0x64 |
4369 | test al, 2 |
4369 | test al, 2 |
4370 | jz kw_ok |
4370 | jz kw_ok |
4371 | loop kw_loop |
4371 | loop kw_loop |
4372 | mov ah, 1 |
4372 | mov ah, 1 |
4373 | jmp kw_exit |
4373 | jmp kw_exit |
4374 | kw_ok: |
4374 | kw_ok: |
4375 | mov al, dl |
4375 | mov al, dl |
4376 | out 0x60, al |
4376 | out 0x60, al |
4377 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4377 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4378 | kw_loop3: |
4378 | kw_loop3: |
4379 | in al, 0x64 |
4379 | in al, 0x64 |
4380 | test al, 2 |
4380 | test al, 2 |
4381 | jz kw_ok3 |
4381 | jz kw_ok3 |
4382 | loop kw_loop3 |
4382 | loop kw_loop3 |
4383 | mov ah, 1 |
4383 | mov ah, 1 |
4384 | jmp kw_exit |
4384 | jmp kw_exit |
4385 | kw_ok3: |
4385 | kw_ok3: |
4386 | mov ah, 8 |
4386 | mov ah, 8 |
4387 | kw_loop4: |
4387 | kw_loop4: |
4388 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4388 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4389 | kw_loop5: |
4389 | kw_loop5: |
4390 | in al, 0x64 |
4390 | in al, 0x64 |
4391 | test al, 1 |
4391 | test al, 1 |
4392 | jnz kw_ok4 |
4392 | jnz kw_ok4 |
4393 | loop kw_loop5 |
4393 | loop kw_loop5 |
4394 | dec ah |
4394 | dec ah |
4395 | jnz kw_loop4 |
4395 | jnz kw_loop4 |
4396 | kw_ok4: |
4396 | kw_ok4: |
4397 | xor ah, ah |
4397 | xor ah, ah |
4398 | kw_exit: |
4398 | kw_exit: |
4399 | 4399 | ||
4400 | pop edx ecx |
4400 | pop edx ecx |
4401 | 4401 | ||
4402 | ret |
4402 | ret |
4403 | ;----------------------------------------------------------------------------- |
4403 | ;----------------------------------------------------------------------------- |
4404 | align 4 |
4404 | align 4 |
4405 | kb_cmd: |
4405 | kb_cmd: |
4406 | 4406 | ||
4407 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4407 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4408 | c_wait: |
4408 | c_wait: |
4409 | in al, 0x64 |
4409 | in al, 0x64 |
4410 | test al, 2 |
4410 | test al, 2 |
4411 | jz c_send |
4411 | jz c_send |
4412 | loop c_wait |
4412 | loop c_wait |
4413 | jmp c_error |
4413 | jmp c_error |
4414 | c_send: |
4414 | c_send: |
4415 | mov al, bl |
4415 | mov al, bl |
4416 | out 0x64, al |
4416 | out 0x64, al |
4417 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4417 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4418 | c_accept: |
4418 | c_accept: |
4419 | in al, 0x64 |
4419 | in al, 0x64 |
4420 | test al, 2 |
4420 | test al, 2 |
4421 | jz c_ok |
4421 | jz c_ok |
4422 | loop c_accept |
4422 | loop c_accept |
4423 | c_error: |
4423 | c_error: |
4424 | mov ah, 1 |
4424 | mov ah, 1 |
4425 | jmp c_exit |
4425 | jmp c_exit |
4426 | c_ok: |
4426 | c_ok: |
4427 | xor ah, ah |
4427 | xor ah, ah |
4428 | c_exit: |
4428 | c_exit: |
4429 | ret |
4429 | ret |
4430 | 4430 | ||
4431 | 4431 | ||
4432 | setmouse: ; set mousepicture -pointer |
4432 | setmouse: ; set mousepicture -pointer |
4433 | ; ps2 mouse enable |
4433 | ; ps2 mouse enable |
4434 | 4434 | ||
4435 | ; mov [MOUSE_PICTURE], dword mousepointer |
4435 | ; mov [MOUSE_PICTURE], dword mousepointer |
4436 | 4436 | ||
4437 | cli |
4437 | cli |
4438 | 4438 | ||
4439 | ret |
4439 | ret |
4440 | 4440 | ||
4441 | if used _rdtsc |
4441 | if used _rdtsc |
4442 | _rdtsc: |
4442 | _rdtsc: |
4443 | bt [cpu_caps], CAPS_TSC |
4443 | bt [cpu_caps], CAPS_TSC |
4444 | jnc ret_rdtsc |
4444 | jnc ret_rdtsc |
4445 | rdtsc |
4445 | rdtsc |
4446 | ret |
4446 | ret |
4447 | ret_rdtsc: |
4447 | ret_rdtsc: |
4448 | mov edx, 0xffffffff |
4448 | mov edx, 0xffffffff |
4449 | mov eax, 0xffffffff |
4449 | mov eax, 0xffffffff |
4450 | ret |
4450 | ret |
4451 | end if |
4451 | end if |
4452 | 4452 | ||
4453 | sys_msg_board_str: |
4453 | sys_msg_board_str: |
4454 | 4454 | ||
4455 | pushad |
4455 | pushad |
4456 | @@: |
4456 | @@: |
4457 | cmp [esi], byte 0 |
4457 | cmp [esi], byte 0 |
4458 | je @f |
4458 | je @f |
4459 | mov eax, 1 |
4459 | mov eax, 1 |
4460 | movzx ebx, byte [esi] |
4460 | movzx ebx, byte [esi] |
4461 | call sys_msg_board |
4461 | call sys_msg_board |
4462 | inc esi |
4462 | inc esi |
4463 | jmp @b |
4463 | jmp @b |
4464 | @@: |
4464 | @@: |
4465 | popad |
4465 | popad |
4466 | ret |
4466 | ret |
4467 | 4467 | ||
4468 | sys_msg_board_byte: |
4468 | sys_msg_board_byte: |
4469 | ; in: al = byte to display |
4469 | ; in: al = byte to display |
4470 | ; out: nothing |
4470 | ; out: nothing |
4471 | ; destroys: nothing |
4471 | ; destroys: nothing |
4472 | pushad |
4472 | pushad |
4473 | mov ecx, 2 |
4473 | mov ecx, 2 |
4474 | shl eax, 24 |
4474 | shl eax, 24 |
4475 | jmp @f |
4475 | jmp @f |
4476 | 4476 | ||
4477 | sys_msg_board_word: |
4477 | sys_msg_board_word: |
4478 | ; in: ax = word to display |
4478 | ; in: ax = word to display |
4479 | ; out: nothing |
4479 | ; out: nothing |
4480 | ; destroys: nothing |
4480 | ; destroys: nothing |
4481 | pushad |
4481 | pushad |
4482 | mov ecx, 4 |
4482 | mov ecx, 4 |
4483 | shl eax, 16 |
4483 | shl eax, 16 |
4484 | jmp @f |
4484 | jmp @f |
4485 | 4485 | ||
4486 | sys_msg_board_dword: |
4486 | sys_msg_board_dword: |
4487 | ; in: eax = dword to display |
4487 | ; in: eax = dword to display |
4488 | ; out: nothing |
4488 | ; out: nothing |
4489 | ; destroys: nothing |
4489 | ; destroys: nothing |
4490 | pushad |
4490 | pushad |
4491 | mov ecx, 8 |
4491 | mov ecx, 8 |
4492 | @@: |
4492 | @@: |
4493 | push ecx |
4493 | push ecx |
4494 | rol eax, 4 |
4494 | rol eax, 4 |
4495 | push eax |
4495 | push eax |
4496 | and al, 0xF |
4496 | and al, 0xF |
4497 | cmp al, 10 |
4497 | cmp al, 10 |
4498 | sbb al, 69h |
4498 | sbb al, 69h |
4499 | das |
4499 | das |
4500 | mov bl, al |
4500 | mov bl, al |
4501 | xor eax, eax |
4501 | xor eax, eax |
4502 | inc eax |
4502 | inc eax |
4503 | call sys_msg_board |
4503 | call sys_msg_board |
4504 | pop eax |
4504 | pop eax |
4505 | pop ecx |
4505 | pop ecx |
4506 | loop @b |
4506 | loop @b |
4507 | popad |
4507 | popad |
4508 | ret |
4508 | ret |
4509 | 4509 | ||
4510 | uglobal |
4510 | uglobal |
4511 | msg_board_data: |
4511 | msg_board_data: |
4512 | times 4096 db 0 |
4512 | times 4096 db 0 |
4513 | msg_board_count dd 0x0 |
4513 | msg_board_count dd 0x0 |
4514 | endg |
4514 | endg |
4515 | 4515 | ||
4516 | sys_msg_board: |
4516 | sys_msg_board: |
4517 | 4517 | ||
4518 | ; eax=1 : write : bl byte to write |
4518 | ; eax=1 : write : bl byte to write |
4519 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4519 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4520 | 4520 | ||
4521 | mov ecx, [msg_board_count] |
4521 | mov ecx, [msg_board_count] |
4522 | cmp eax, 1 |
4522 | cmp eax, 1 |
4523 | jne .smbl1 |
4523 | jne .smbl1 |
4524 | 4524 | ||
4525 | if defined debug_com_base |
4525 | if defined debug_com_base |
4526 | 4526 | ||
4527 | push dx ax |
4527 | push dx ax |
4528 | 4528 | ||
4529 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4529 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4530 | mov dx, debug_com_base+5 |
4530 | mov dx, debug_com_base+5 |
4531 | in al, dx |
4531 | in al, dx |
4532 | test al, 1 shl 5 |
4532 | test al, 1 shl 5 |
4533 | jz @r |
4533 | jz @r |
4534 | 4534 | ||
4535 | mov dx, debug_com_base ; Output the byte |
4535 | mov dx, debug_com_base ; Output the byte |
4536 | mov al, bl |
4536 | mov al, bl |
4537 | out dx, al |
4537 | out dx, al |
4538 | 4538 | ||
4539 | pop ax dx |
4539 | pop ax dx |
4540 | 4540 | ||
4541 | end if |
4541 | end if |
4542 | 4542 | ||
4543 | mov [msg_board_data+ecx], bl |
4543 | mov [msg_board_data+ecx], bl |
4544 | inc ecx |
4544 | inc ecx |
4545 | and ecx, 4095 |
4545 | and ecx, 4095 |
4546 | mov [msg_board_count], ecx |
4546 | mov [msg_board_count], ecx |
4547 | mov [check_idle_semaphore], 5 |
4547 | mov [check_idle_semaphore], 5 |
4548 | ret |
4548 | ret |
4549 | .smbl1: |
4549 | .smbl1: |
4550 | cmp eax, 2 |
4550 | cmp eax, 2 |
4551 | jne .smbl2 |
4551 | jne .smbl2 |
4552 | test ecx, ecx |
4552 | test ecx, ecx |
4553 | jz .smbl21 |
4553 | jz .smbl21 |
4554 | mov eax, msg_board_data+1 |
4554 | mov eax, msg_board_data+1 |
4555 | mov ebx, msg_board_data |
4555 | mov ebx, msg_board_data |
4556 | movzx edx, byte [ebx] |
4556 | movzx edx, byte [ebx] |
4557 | call memmove |
4557 | call memmove |
4558 | dec [msg_board_count] |
4558 | dec [msg_board_count] |
4559 | mov [esp + 36], edx ;eax |
4559 | mov [esp + 36], edx ;eax |
4560 | mov [esp + 24], dword 1 |
4560 | mov [esp + 24], dword 1 |
4561 | ret |
4561 | ret |
4562 | .smbl21: |
4562 | .smbl21: |
4563 | mov [esp+36], ecx |
4563 | mov [esp+36], ecx |
4564 | mov [esp+24], ecx |
4564 | mov [esp+24], ecx |
4565 | .smbl2: |
4565 | .smbl2: |
4566 | ret |
4566 | ret |
4567 | 4567 | ||
4568 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4568 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4569 | ;; 66 sys function. ;; |
4569 | ;; 66 sys function. ;; |
4570 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4570 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4571 | ;; out eax ;; |
4571 | ;; out eax ;; |
4572 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4572 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4573 | iglobal |
4573 | iglobal |
4574 | align 4 |
4574 | align 4 |
4575 | f66call: |
4575 | f66call: |
4576 | dd sys_process_def.1 ; 1 = set keyboard mode |
4576 | dd sys_process_def.1 ; 1 = set keyboard mode |
4577 | dd sys_process_def.2 ; 2 = get keyboard mode |
4577 | dd sys_process_def.2 ; 2 = get keyboard mode |
4578 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4578 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4579 | dd sys_process_def.4 |
4579 | dd sys_process_def.4 |
4580 | dd sys_process_def.5 |
4580 | dd sys_process_def.5 |
4581 | endg |
4581 | endg |
4582 | 4582 | ||
4583 | 4583 | ||
4584 | 4584 | ||
4585 | 4585 | ||
4586 | sys_process_def: |
4586 | sys_process_def: |
4587 | dec ebx |
4587 | dec ebx |
4588 | cmp ebx, 5 |
4588 | cmp ebx, 5 |
4589 | jae .not_support ;if >=6 then or eax,-1 |
4589 | jae .not_support ;if >=6 then or eax,-1 |
4590 | 4590 | ||
4591 | mov edi, [CURRENT_TASK] |
4591 | mov edi, [CURRENT_TASK] |
4592 | jmp dword [f66call+ebx*4] |
4592 | jmp dword [f66call+ebx*4] |
4593 | 4593 | ||
4594 | .not_support: |
4594 | .not_support: |
4595 | or eax, -1 |
4595 | or eax, -1 |
4596 | ret |
4596 | ret |
4597 | 4597 | ||
4598 | .1: |
4598 | .1: |
4599 | shl edi, 8 |
4599 | shl edi, 8 |
4600 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4600 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4601 | 4601 | ||
4602 | ret |
4602 | ret |
4603 | 4603 | ||
4604 | .2: ; 2 = get keyboard mode |
4604 | .2: ; 2 = get keyboard mode |
4605 | shl edi, 8 |
4605 | shl edi, 8 |
4606 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4606 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4607 | mov [esp+32], eax |
4607 | mov [esp+32], eax |
4608 | ret |
4608 | ret |
4609 | ; xor eax,eax |
4609 | ; xor eax,eax |
4610 | ; movzx eax,byte [shift] |
4610 | ; movzx eax,byte [shift] |
4611 | ; movzx ebx,byte [ctrl] |
4611 | ; movzx ebx,byte [ctrl] |
4612 | ; shl ebx,2 |
4612 | ; shl ebx,2 |
4613 | ; add eax,ebx |
4613 | ; add eax,ebx |
4614 | ; movzx ebx,byte [alt] |
4614 | ; movzx ebx,byte [alt] |
4615 | ; shl ebx,3 |
4615 | ; shl ebx,3 |
4616 | ; add eax,ebx |
4616 | ; add eax,ebx |
4617 | .3: ;3 = get keyboard ctrl, alt, shift |
4617 | .3: ;3 = get keyboard ctrl, alt, shift |
4618 | ;// mike.dld [ |
4618 | ;// mike.dld [ |
4619 | mov eax, [kb_state] |
4619 | mov eax, [kb_state] |
4620 | ;// mike.dld ] |
4620 | ;// mike.dld ] |
4621 | mov [esp+32], eax |
4621 | mov [esp+32], eax |
4622 | ret |
4622 | ret |
4623 | 4623 | ||
4624 | .4: |
4624 | .4: |
4625 | mov eax, hotkey_list |
4625 | mov eax, hotkey_list |
4626 | @@: |
4626 | @@: |
4627 | cmp dword [eax+8], 0 |
4627 | cmp dword [eax+8], 0 |
4628 | jz .found_free |
4628 | jz .found_free |
4629 | add eax, 16 |
4629 | add eax, 16 |
4630 | cmp eax, hotkey_list+16*256 |
4630 | cmp eax, hotkey_list+16*256 |
4631 | jb @b |
4631 | jb @b |
4632 | mov dword [esp+32], 1 |
4632 | mov dword [esp+32], 1 |
4633 | ret |
4633 | ret |
4634 | .found_free: |
4634 | .found_free: |
4635 | mov [eax+8], edi |
4635 | mov [eax+8], edi |
4636 | mov [eax+4], edx |
4636 | mov [eax+4], edx |
4637 | movzx ecx, cl |
4637 | movzx ecx, cl |
4638 | lea ecx, [hotkey_scancodes+ecx*4] |
4638 | lea ecx, [hotkey_scancodes+ecx*4] |
4639 | mov edx, [ecx] |
4639 | mov edx, [ecx] |
4640 | mov [eax], edx |
4640 | mov [eax], edx |
4641 | mov [ecx], eax |
4641 | mov [ecx], eax |
4642 | mov [eax+12], ecx |
4642 | mov [eax+12], ecx |
4643 | jecxz @f |
4643 | jecxz @f |
4644 | mov [edx+12], eax |
4644 | mov [edx+12], eax |
4645 | @@: |
4645 | @@: |
4646 | and dword [esp+32], 0 |
4646 | and dword [esp+32], 0 |
4647 | ret |
4647 | ret |
4648 | 4648 | ||
4649 | .5: |
4649 | .5: |
4650 | movzx ebx, cl |
4650 | movzx ebx, cl |
4651 | lea ebx, [hotkey_scancodes+ebx*4] |
4651 | lea ebx, [hotkey_scancodes+ebx*4] |
4652 | mov eax, [ebx] |
4652 | mov eax, [ebx] |
4653 | .scan: |
4653 | .scan: |
4654 | test eax, eax |
4654 | test eax, eax |
4655 | jz .notfound |
4655 | jz .notfound |
4656 | cmp [eax+8], edi |
4656 | cmp [eax+8], edi |
4657 | jnz .next |
4657 | jnz .next |
4658 | cmp [eax+4], edx |
4658 | cmp [eax+4], edx |
4659 | jz .found |
4659 | jz .found |
4660 | .next: |
4660 | .next: |
4661 | mov eax, [eax] |
4661 | mov eax, [eax] |
4662 | jmp .scan |
4662 | jmp .scan |
4663 | .notfound: |
4663 | .notfound: |
4664 | mov dword [esp+32], 1 |
4664 | mov dword [esp+32], 1 |
4665 | ret |
4665 | ret |
4666 | .found: |
4666 | .found: |
4667 | mov ecx, [eax] |
4667 | mov ecx, [eax] |
4668 | jecxz @f |
4668 | jecxz @f |
4669 | mov edx, [eax+12] |
4669 | mov edx, [eax+12] |
4670 | mov [ecx+12], edx |
4670 | mov [ecx+12], edx |
4671 | @@: |
4671 | @@: |
4672 | mov ecx, [eax+12] |
4672 | mov ecx, [eax+12] |
4673 | mov edx, [eax] |
4673 | mov edx, [eax] |
4674 | mov [ecx], edx |
4674 | mov [ecx], edx |
4675 | xor edx, edx |
4675 | xor edx, edx |
4676 | mov [eax+4], edx |
4676 | mov [eax+4], edx |
4677 | mov [eax+8], edx |
4677 | mov [eax+8], edx |
4678 | mov [eax+12], edx |
4678 | mov [eax+12], edx |
4679 | mov [eax], edx |
4679 | mov [eax], edx |
4680 | mov [esp+32], edx |
4680 | mov [esp+32], edx |
4681 | ret |
4681 | ret |
4682 | 4682 | ||
4683 | 4683 | ||
4684 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4684 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4685 | ;; 61 sys function. ;; |
4685 | ;; 61 sys function. ;; |
4686 | ;; in eax=61,ebx in [1..3] ;; |
4686 | ;; in eax=61,ebx in [1..3] ;; |
4687 | ;; out eax ;; |
4687 | ;; out eax ;; |
4688 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4688 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4689 | iglobal |
4689 | iglobal |
4690 | align 4 |
4690 | align 4 |
4691 | f61call: |
4691 | f61call: |
4692 | dd sys_gs.1 ; resolution |
4692 | dd sys_gs.1 ; resolution |
4693 | dd sys_gs.2 ; bits per pixel |
4693 | dd sys_gs.2 ; bits per pixel |
4694 | dd sys_gs.3 ; bytes per scanline |
4694 | dd sys_gs.3 ; bytes per scanline |
4695 | endg |
4695 | endg |
4696 | 4696 | ||
4697 | 4697 | ||
4698 | align 4 |
4698 | align 4 |
4699 | 4699 | ||
4700 | sys_gs: ; direct screen access |
4700 | sys_gs: ; direct screen access |
4701 | dec ebx |
4701 | dec ebx |
4702 | cmp ebx, 2 |
4702 | cmp ebx, 2 |
4703 | ja .not_support |
4703 | ja .not_support |
4704 | jmp dword [f61call+ebx*4] |
4704 | jmp dword [f61call+ebx*4] |
4705 | .not_support: |
4705 | .not_support: |
4706 | or [esp+32], dword -1 |
4706 | or [esp+32], dword -1 |
4707 | ret |
4707 | ret |
4708 | 4708 | ||
4709 | 4709 | ||
4710 | .1: ; resolution |
4710 | .1: ; resolution |
4711 | mov eax, [Screen_Max_X] |
4711 | mov eax, [Screen_Max_X] |
4712 | shl eax, 16 |
4712 | shl eax, 16 |
4713 | mov ax, [Screen_Max_Y] |
4713 | mov ax, [Screen_Max_Y] |
4714 | add eax, 0x00010001 |
4714 | add eax, 0x00010001 |
4715 | mov [esp+32], eax |
4715 | mov [esp+32], eax |
4716 | ret |
4716 | ret |
4717 | .2: ; bits per pixel |
4717 | .2: ; bits per pixel |
4718 | movzx eax, byte [ScreenBPP] |
4718 | movzx eax, byte [ScreenBPP] |
4719 | mov [esp+32], eax |
4719 | mov [esp+32], eax |
4720 | ret |
4720 | ret |
4721 | .3: ; bytes per scanline |
4721 | .3: ; bytes per scanline |
4722 | mov eax, [BytesPerScanLine] |
4722 | mov eax, [BytesPerScanLine] |
4723 | mov [esp+32], eax |
4723 | mov [esp+32], eax |
4724 | ret |
4724 | ret |
4725 | 4725 | ||
4726 | align 4 ; system functions |
4726 | align 4 ; system functions |
4727 | 4727 | ||
4728 | syscall_setpixel: ; SetPixel |
4728 | syscall_setpixel: ; SetPixel |
4729 | 4729 | ||
4730 | mov eax, ebx |
4730 | mov eax, ebx |
4731 | mov ebx, ecx |
4731 | mov ebx, ecx |
4732 | mov ecx, edx |
4732 | mov ecx, edx |
4733 | mov edx, [TASK_BASE] |
4733 | mov edx, [TASK_BASE] |
4734 | add eax, [edx-twdw+WDATA.box.left] |
4734 | add eax, [edx-twdw+WDATA.box.left] |
4735 | add ebx, [edx-twdw+WDATA.box.top] |
4735 | add ebx, [edx-twdw+WDATA.box.top] |
4736 | mov edi, [current_slot] |
4736 | mov edi, [current_slot] |
4737 | add eax, [edi+APPDATA.wnd_clientbox.left] |
4737 | add eax, [edi+APPDATA.wnd_clientbox.left] |
4738 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
4738 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
4739 | xor edi, edi ; no force |
4739 | xor edi, edi ; no force |
4740 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
4740 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
4741 | ; jmp [putpixel] |
4741 | ; jmp [putpixel] |
4742 | jmp __sys_putpixel |
4742 | jmp __sys_putpixel |
4743 | 4743 | ||
4744 | align 4 |
4744 | align 4 |
4745 | 4745 | ||
4746 | syscall_writetext: ; WriteText |
4746 | syscall_writetext: ; WriteText |
4747 | 4747 | ||
4748 | mov eax, [TASK_BASE] |
4748 | mov eax, [TASK_BASE] |
4749 | mov ebp, [eax-twdw+WDATA.box.left] |
4749 | mov ebp, [eax-twdw+WDATA.box.left] |
4750 | push esi |
4750 | push esi |
4751 | mov esi, [current_slot] |
4751 | mov esi, [current_slot] |
4752 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
4752 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
4753 | shl ebp, 16 |
4753 | shl ebp, 16 |
4754 | add ebp, [eax-twdw+WDATA.box.top] |
4754 | add ebp, [eax-twdw+WDATA.box.top] |
4755 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
4755 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
4756 | pop esi |
4756 | pop esi |
4757 | add ebx, ebp |
4757 | add ebx, ebp |
4758 | mov eax, edi |
4758 | mov eax, edi |
4759 | test ecx, 0x08000000 ; redirect the output to the user area |
4759 | test ecx, 0x08000000 ; redirect the output to the user area |
4760 | jnz dtext |
4760 | jnz dtext |
4761 | xor edi, edi |
4761 | xor edi, edi |
4762 | jmp dtext |
4762 | jmp dtext |
4763 | 4763 | ||
4764 | align 4 |
4764 | align 4 |
4765 | 4765 | ||
4766 | syscall_openramdiskfile: ; OpenRamdiskFile |
4766 | syscall_openramdiskfile: ; OpenRamdiskFile |
4767 | 4767 | ||
4768 | mov eax, ebx |
4768 | mov eax, ebx |
4769 | mov ebx, ecx |
4769 | mov ebx, ecx |
4770 | mov ecx, edx |
4770 | mov ecx, edx |
4771 | mov edx, esi |
4771 | mov edx, esi |
4772 | mov esi, 12 |
4772 | mov esi, 12 |
4773 | call fileread |
4773 | call fileread |
4774 | mov [esp+32], eax |
4774 | mov [esp+32], eax |
4775 | ret |
4775 | ret |
4776 | 4776 | ||
4777 | align 4 |
4777 | align 4 |
4778 | 4778 | ||
4779 | syscall_drawrect: ; DrawRect |
4779 | syscall_drawrect: ; DrawRect |
4780 | 4780 | ||
4781 | mov edi, edx ; color + gradient |
4781 | mov edi, edx ; color + gradient |
4782 | and edi, 0x80FFFFFF |
4782 | and edi, 0x80FFFFFF |
4783 | test bx, bx ; x.size |
4783 | test bx, bx ; x.size |
4784 | je .drectr |
4784 | je .drectr |
4785 | test cx, cx ; y.size |
4785 | test cx, cx ; y.size |
4786 | je .drectr |
4786 | je .drectr |
4787 | 4787 | ||
4788 | mov eax, ebx ; bad idea |
4788 | mov eax, ebx ; bad idea |
4789 | mov ebx, ecx |
4789 | mov ebx, ecx |
4790 | 4790 | ||
4791 | movzx ecx, ax ; ecx - x.size |
4791 | movzx ecx, ax ; ecx - x.size |
4792 | shr eax, 16 ; eax - x.coord |
4792 | shr eax, 16 ; eax - x.coord |
4793 | movzx edx, bx ; edx - y.size |
4793 | movzx edx, bx ; edx - y.size |
4794 | shr ebx, 16 ; ebx - y.coord |
4794 | shr ebx, 16 ; ebx - y.coord |
4795 | mov esi, [current_slot] |
4795 | mov esi, [current_slot] |
4796 | 4796 | ||
4797 | add eax, [esi + APPDATA.wnd_clientbox.left] |
4797 | add eax, [esi + APPDATA.wnd_clientbox.left] |
4798 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
4798 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
4799 | add ecx, eax |
4799 | add ecx, eax |
4800 | add edx, ebx |
4800 | add edx, ebx |
4801 | ; jmp [drawbar] |
4801 | ; jmp [drawbar] |
4802 | jmp vesa20_drawbar |
4802 | jmp vesa20_drawbar |
4803 | .drectr: |
4803 | .drectr: |
4804 | ret |
4804 | ret |
4805 | 4805 | ||
4806 | align 4 |
4806 | align 4 |
4807 | syscall_getscreensize: ; GetScreenSize |
4807 | syscall_getscreensize: ; GetScreenSize |
4808 | mov ax, [Screen_Max_X] |
4808 | mov ax, [Screen_Max_X] |
4809 | shl eax, 16 |
4809 | shl eax, 16 |
4810 | mov ax, [Screen_Max_Y] |
4810 | mov ax, [Screen_Max_Y] |
4811 | mov [esp + 32], eax |
4811 | mov [esp + 32], eax |
4812 | ret |
4812 | ret |
4813 | 4813 | ||
4814 | align 4 |
4814 | align 4 |
4815 | 4815 | ||
4816 | syscall_cdaudio: ; CD |
4816 | syscall_cdaudio: ; CD |
4817 | 4817 | ||
4818 | cmp ebx, 4 |
4818 | cmp ebx, 4 |
4819 | jb .audio |
4819 | jb .audio |
4820 | jz .eject |
4820 | jz .eject |
4821 | cmp ebx, 5 |
4821 | cmp ebx, 5 |
4822 | jnz .ret |
4822 | jnz .ret |
4823 | .load: |
4823 | .load: |
4824 | call .reserve |
4824 | call .reserve |
4825 | call LoadMedium |
4825 | call LoadMedium |
4826 | ;call .free |
4826 | ;call .free |
4827 | jmp .free |
4827 | jmp .free |
4828 | ; ret |
4828 | ; ret |
4829 | .eject: |
4829 | .eject: |
4830 | call .reserve |
4830 | call .reserve |
4831 | call clear_CD_cache |
4831 | call clear_CD_cache |
4832 | call allow_medium_removal |
4832 | call allow_medium_removal |
4833 | call EjectMedium |
4833 | call EjectMedium |
4834 | ; call .free |
4834 | ; call .free |
4835 | jmp .free |
4835 | jmp .free |
4836 | ; ret |
4836 | ; ret |
4837 | .audio: |
4837 | .audio: |
4838 | call sys_cd_audio |
4838 | call sys_cd_audio |
4839 | mov [esp+36-4], eax |
4839 | mov [esp+36-4], eax |
4840 | .ret: |
4840 | .ret: |
4841 | ret |
4841 | ret |
4842 | 4842 | ||
4843 | .reserve: |
4843 | .reserve: |
4844 | call reserve_cd |
4844 | call reserve_cd |
4845 | mov eax, ecx |
4845 | mov eax, ecx |
4846 | shr eax, 1 |
4846 | shr eax, 1 |
4847 | and eax, 1 |
4847 | and eax, 1 |
4848 | inc eax |
4848 | inc eax |
4849 | mov [ChannelNumber], ax |
4849 | mov [ChannelNumber], ax |
4850 | mov eax, ecx |
4850 | mov eax, ecx |
4851 | and eax, 1 |
4851 | and eax, 1 |
4852 | mov [DiskNumber], al |
4852 | mov [DiskNumber], al |
4853 | call reserve_cd_channel |
4853 | call reserve_cd_channel |
4854 | and ebx, 3 |
4854 | and ebx, 3 |
4855 | inc ebx |
4855 | inc ebx |
4856 | mov [cdpos], ebx |
4856 | mov [cdpos], ebx |
4857 | add ebx, ebx |
4857 | add ebx, ebx |
4858 | mov cl, 8 |
4858 | mov cl, 8 |
4859 | sub cl, bl |
4859 | sub cl, bl |
4860 | mov al, [DRIVE_DATA+1] |
4860 | mov al, [DRIVE_DATA+1] |
4861 | shr al, cl |
4861 | shr al, cl |
4862 | test al, 2 |
4862 | test al, 2 |
4863 | jz .free;.err |
4863 | jz .free;.err |
4864 | ret |
4864 | ret |
4865 | .free: |
4865 | .free: |
4866 | call free_cd_channel |
4866 | call free_cd_channel |
4867 | and [cd_status], 0 |
4867 | and [cd_status], 0 |
4868 | ret |
4868 | ret |
4869 | .err: |
4869 | .err: |
4870 | call .free |
4870 | call .free |
4871 | ; pop eax |
4871 | ; pop eax |
4872 | ret |
4872 | ret |
4873 | ;----------------------------------------------------------------------------- |
4873 | ;----------------------------------------------------------------------------- |
4874 | align 4 |
4874 | align 4 |
4875 | syscall_getpixel_WinMap: ; GetPixel WinMap |
4875 | syscall_getpixel_WinMap: ; GetPixel WinMap |
4876 | cmp ebx, [Screen_Max_X] |
4876 | cmp ebx, [Screen_Max_X] |
4877 | jbe @f |
4877 | jbe @f |
4878 | cmp ecx, [Screen_Max_Y] |
4878 | cmp ecx, [Screen_Max_Y] |
4879 | jbe @f |
4879 | jbe @f |
4880 | xor eax, eax |
4880 | xor eax, eax |
4881 | jmp .store |
4881 | jmp .store |
4882 | ;-------------------------------------- |
4882 | ;-------------------------------------- |
4883 | align 4 |
4883 | align 4 |
4884 | @@: |
4884 | @@: |
4885 | mov eax, [d_width_calc_area + ecx*4] |
4885 | mov eax, [d_width_calc_area + ecx*4] |
4886 | add eax, [_WinMapAddress] |
4886 | add eax, [_WinMapAddress] |
4887 | movzx eax, byte[eax+ebx] ; get value for current point |
4887 | movzx eax, byte[eax+ebx] ; get value for current point |
4888 | ;-------------------------------------- |
4888 | ;-------------------------------------- |
4889 | align 4 |
4889 | align 4 |
4890 | .store: |
4890 | .store: |
4891 | mov [esp + 32], eax |
4891 | mov [esp + 32], eax |
4892 | ret |
4892 | ret |
4893 | ;----------------------------------------------------------------------------- |
4893 | ;----------------------------------------------------------------------------- |
4894 | align 4 |
4894 | align 4 |
4895 | syscall_getpixel: ; GetPixel |
4895 | syscall_getpixel: ; GetPixel |
4896 | mov ecx, [Screen_Max_X] |
4896 | mov ecx, [Screen_Max_X] |
4897 | inc ecx |
4897 | inc ecx |
4898 | xor edx, edx |
4898 | xor edx, edx |
4899 | mov eax, ebx |
4899 | mov eax, ebx |
4900 | div ecx |
4900 | div ecx |
4901 | mov ebx, edx |
4901 | mov ebx, edx |
4902 | xchg eax, ebx |
4902 | xchg eax, ebx |
4903 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4903 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4904 | call dword [GETPIXEL]; eax - x, ebx - y |
4904 | call dword [GETPIXEL]; eax - x, ebx - y |
4905 | mov [esp + 32], ecx |
4905 | mov [esp + 32], ecx |
4906 | ret |
4906 | ret |
4907 | ;----------------------------------------------------------------------------- |
4907 | ;----------------------------------------------------------------------------- |
4908 | align 4 |
4908 | align 4 |
4909 | syscall_getarea: |
4909 | syscall_getarea: |
4910 | ;eax = 36 |
4910 | ;eax = 36 |
4911 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
4911 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
4912 | ;ecx = [size x]*65536 + [size y] |
4912 | ;ecx = [size x]*65536 + [size y] |
4913 | ;edx = [start x]*65536 + [start y] |
4913 | ;edx = [start x]*65536 + [start y] |
4914 | pushad |
4914 | pushad |
4915 | mov edi, ebx |
4915 | mov edi, ebx |
4916 | mov eax, edx |
4916 | mov eax, edx |
4917 | shr eax, 16 |
4917 | shr eax, 16 |
4918 | mov ebx, edx |
4918 | mov ebx, edx |
4919 | and ebx, 0xffff |
4919 | and ebx, 0xffff |
4920 | dec eax |
4920 | dec eax |
4921 | dec ebx |
4921 | dec ebx |
4922 | ; eax - x, ebx - y |
4922 | ; eax - x, ebx - y |
4923 | mov edx, ecx |
4923 | mov edx, ecx |
4924 | 4924 | ||
4925 | shr ecx, 16 |
4925 | shr ecx, 16 |
4926 | and edx, 0xffff |
4926 | and edx, 0xffff |
4927 | mov esi, ecx |
4927 | mov esi, ecx |
4928 | ; ecx - size x, edx - size y |
4928 | ; ecx - size x, edx - size y |
4929 | 4929 | ||
4930 | mov ebp, edx |
4930 | mov ebp, edx |
4931 | dec ebp |
4931 | dec ebp |
4932 | lea ebp, [ebp*3] |
4932 | lea ebp, [ebp*3] |
4933 | 4933 | ||
4934 | imul ebp, esi |
4934 | imul ebp, esi |
4935 | 4935 | ||
4936 | mov esi, ecx |
4936 | mov esi, ecx |
4937 | dec esi |
4937 | dec esi |
4938 | lea esi, [esi*3] |
4938 | lea esi, [esi*3] |
4939 | 4939 | ||
4940 | add ebp, esi |
4940 | add ebp, esi |
4941 | add ebp, edi |
4941 | add ebp, edi |
4942 | 4942 | ||
4943 | add ebx, edx |
4943 | add ebx, edx |
4944 | ;-------------------------------------- |
4944 | ;-------------------------------------- |
4945 | align 4 |
4945 | align 4 |
4946 | .start_y: |
4946 | .start_y: |
4947 | push ecx edx |
4947 | push ecx edx |
4948 | ;-------------------------------------- |
4948 | ;-------------------------------------- |
4949 | align 4 |
4949 | align 4 |
4950 | .start_x: |
4950 | .start_x: |
4951 | push eax ebx ecx |
4951 | push eax ebx ecx |
4952 | add eax, ecx |
4952 | add eax, ecx |
4953 | 4953 | ||
4954 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4954 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4955 | call dword [GETPIXEL]; eax - x, ebx - y |
4955 | call dword [GETPIXEL]; eax - x, ebx - y |
4956 | 4956 | ||
4957 | mov [ebp], cx |
4957 | mov [ebp], cx |
4958 | shr ecx, 16 |
4958 | shr ecx, 16 |
4959 | mov [ebp+2], cl |
4959 | mov [ebp+2], cl |
4960 | 4960 | ||
4961 | pop ecx ebx eax |
4961 | pop ecx ebx eax |
4962 | sub ebp, 3 |
4962 | sub ebp, 3 |
4963 | dec ecx |
4963 | dec ecx |
4964 | jnz .start_x |
4964 | jnz .start_x |
4965 | pop edx ecx |
4965 | pop edx ecx |
4966 | dec ebx |
4966 | dec ebx |
4967 | dec edx |
4967 | dec edx |
4968 | jnz .start_y |
4968 | jnz .start_y |
4969 | popad |
4969 | popad |
4970 | ret |
4970 | ret |
4971 | ;----------------------------------------------------------------------------- |
4971 | ;----------------------------------------------------------------------------- |
4972 | align 4 |
4972 | align 4 |
4973 | syscall_putarea_backgr: |
4973 | syscall_putarea_backgr: |
4974 | ;eax = 25 |
4974 | ;eax = 25 |
4975 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
4975 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
4976 | ;ecx = [size x]*65536 + [size y] |
4976 | ;ecx = [size x]*65536 + [size y] |
4977 | ;edx = [start x]*65536 + [start y] |
4977 | ;edx = [start x]*65536 + [start y] |
4978 | pushad |
4978 | pushad |
4979 | mov edi, ebx |
4979 | mov edi, ebx |
4980 | mov eax, edx |
4980 | mov eax, edx |
4981 | shr eax, 16 |
4981 | shr eax, 16 |
4982 | mov ebx, edx |
4982 | mov ebx, edx |
4983 | and ebx, 0xffff |
4983 | and ebx, 0xffff |
4984 | dec eax |
4984 | dec eax |
4985 | dec ebx |
4985 | dec ebx |
4986 | ; eax - x, ebx - y |
4986 | ; eax - x, ebx - y |
4987 | mov edx, ecx |
4987 | mov edx, ecx |
4988 | shr ecx, 16 |
4988 | shr ecx, 16 |
4989 | and edx, 0xffff |
4989 | and edx, 0xffff |
4990 | mov esi, ecx |
4990 | mov esi, ecx |
4991 | ; ecx - size x, edx - size y |
4991 | ; ecx - size x, edx - size y |
4992 | mov ebp, edx |
4992 | mov ebp, edx |
4993 | dec ebp |
4993 | dec ebp |
4994 | shl ebp, 2 |
4994 | shl ebp, 2 |
4995 | 4995 | ||
4996 | imul ebp, esi |
4996 | imul ebp, esi |
4997 | 4997 | ||
4998 | mov esi, ecx |
4998 | mov esi, ecx |
4999 | dec esi |
4999 | dec esi |
5000 | shl esi, 2 |
5000 | shl esi, 2 |
5001 | 5001 | ||
5002 | add ebp, esi |
5002 | add ebp, esi |
5003 | add ebp, edi |
5003 | add ebp, edi |
5004 | 5004 | ||
5005 | add ebx, edx |
5005 | add ebx, edx |
5006 | ;-------------------------------------- |
5006 | ;-------------------------------------- |
5007 | align 4 |
5007 | align 4 |
5008 | .start_y: |
5008 | .start_y: |
5009 | push ecx edx |
5009 | push ecx edx |
5010 | ;-------------------------------------- |
5010 | ;-------------------------------------- |
5011 | align 4 |
5011 | align 4 |
5012 | .start_x: |
5012 | .start_x: |
5013 | push eax ecx |
5013 | push eax ecx |
5014 | add eax, ecx |
5014 | add eax, ecx |
5015 | 5015 | ||
5016 | mov ecx, [ebp] |
5016 | mov ecx, [ebp] |
5017 | rol ecx, 8 |
5017 | rol ecx, 8 |
5018 | test cl, cl ; transparensy = 0 |
5018 | test cl, cl ; transparensy = 0 |
5019 | jz .no_put |
5019 | jz .no_put |
5020 | 5020 | ||
5021 | xor cl, cl |
5021 | xor cl, cl |
5022 | ror ecx, 8 |
5022 | ror ecx, 8 |
5023 | 5023 | ||
5024 | pushad |
5024 | pushad |
5025 | mov edx, [d_width_calc_area + ebx*4] |
5025 | mov edx, [d_width_calc_area + ebx*4] |
5026 | add edx, [_WinMapAddress] |
5026 | add edx, [_WinMapAddress] |
5027 | movzx edx, byte [eax+edx] |
5027 | movzx edx, byte [eax+edx] |
5028 | cmp dl, byte 1 |
5028 | cmp dl, byte 1 |
5029 | jne @f |
5029 | jne @f |
5030 | 5030 | ||
5031 | call dword [PUTPIXEL]; eax - x, ebx - y |
5031 | call dword [PUTPIXEL]; eax - x, ebx - y |
5032 | ;-------------------------------------- |
5032 | ;-------------------------------------- |
5033 | align 4 |
5033 | align 4 |
5034 | @@: |
5034 | @@: |
5035 | popad |
5035 | popad |
5036 | ;-------------------------------------- |
5036 | ;-------------------------------------- |
5037 | align 4 |
5037 | align 4 |
5038 | .no_put: |
5038 | .no_put: |
5039 | pop ecx eax |
5039 | pop ecx eax |
5040 | 5040 | ||
5041 | sub ebp, 4 |
5041 | sub ebp, 4 |
5042 | dec ecx |
5042 | dec ecx |
5043 | jnz .start_x |
5043 | jnz .start_x |
5044 | 5044 | ||
5045 | pop edx ecx |
5045 | pop edx ecx |
5046 | dec ebx |
5046 | dec ebx |
5047 | dec edx |
5047 | dec edx |
5048 | jnz .start_y |
5048 | jnz .start_y |
5049 | 5049 | ||
5050 | popad |
5050 | popad |
5051 | ret |
5051 | ret |
5052 | ;----------------------------------------------------------------------------- |
5052 | ;----------------------------------------------------------------------------- |
5053 | align 4 |
5053 | align 4 |
5054 | syscall_drawline: ; DrawLine |
5054 | syscall_drawline: ; DrawLine |
5055 | 5055 | ||
5056 | mov edi, [TASK_BASE] |
5056 | mov edi, [TASK_BASE] |
5057 | movzx eax, word[edi-twdw+WDATA.box.left] |
5057 | movzx eax, word[edi-twdw+WDATA.box.left] |
5058 | mov ebp, eax |
5058 | mov ebp, eax |
5059 | mov esi, [current_slot] |
5059 | mov esi, [current_slot] |
5060 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5060 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5061 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5061 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5062 | add ebp, ebx |
5062 | add ebp, ebx |
5063 | shl eax, 16 |
5063 | shl eax, 16 |
5064 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5064 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5065 | add eax, ebp |
5065 | add eax, ebp |
5066 | mov ebp, ebx |
5066 | mov ebp, ebx |
5067 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5067 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5068 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5068 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5069 | add ebp, ecx |
5069 | add ebp, ecx |
5070 | shl ebx, 16 |
5070 | shl ebx, 16 |
5071 | xor edi, edi |
5071 | xor edi, edi |
5072 | add ebx, ebp |
5072 | add ebx, ebp |
5073 | mov ecx, edx |
5073 | mov ecx, edx |
5074 | ; jmp [draw_line] |
5074 | ; jmp [draw_line] |
5075 | jmp __sys_draw_line |
5075 | jmp __sys_draw_line |
5076 | 5076 | ||
5077 | 5077 | ||
5078 | align 4 |
5078 | align 4 |
5079 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5079 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5080 | 5080 | ||
5081 | call r_f_port_area |
5081 | call r_f_port_area |
5082 | mov [esp+32], eax |
5082 | mov [esp+32], eax |
5083 | ret |
5083 | ret |
5084 | 5084 | ||
5085 | align 4 |
5085 | align 4 |
5086 | syscall_threads: ; CreateThreads |
5086 | syscall_threads: ; CreateThreads |
5087 | ; eax=1 create thread |
5087 | ; eax=1 create thread |
5088 | ; |
5088 | ; |
5089 | ; ebx=thread start |
5089 | ; ebx=thread start |
5090 | ; ecx=thread stack value |
5090 | ; ecx=thread stack value |
5091 | ; |
5091 | ; |
5092 | ; on return : eax = pid |
5092 | ; on return : eax = pid |
5093 | 5093 | ||
5094 | call new_sys_threads |
5094 | call new_sys_threads |
5095 | 5095 | ||
5096 | mov [esp+32], eax |
5096 | mov [esp+32], eax |
5097 | ret |
5097 | ret |
5098 | 5098 | ||
5099 | align 4 |
5099 | align 4 |
5100 | 5100 | ||
5101 | stack_driver_stat: |
5101 | stack_driver_stat: |
5102 | 5102 | ||
5103 | call app_stack_handler ; Stack status |
5103 | call app_stack_handler ; Stack status |
5104 | 5104 | ||
5105 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5105 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5106 | ; call change_task ; between sent packet |
5106 | ; call change_task ; between sent packet |
5107 | 5107 | ||
5108 | mov [esp+32], eax |
5108 | mov [esp+32], eax |
5109 | ret |
5109 | ret |
5110 | 5110 | ||
5111 | align 4 |
5111 | align 4 |
5112 | 5112 | ||
5113 | socket: ; Socket interface |
5113 | socket: ; Socket interface |
5114 | call app_socket_handler |
5114 | call app_socket_handler |
5115 | 5115 | ||
5116 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5116 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5117 | ; call change_task ; between sent packet |
5117 | ; call change_task ; between sent packet |
5118 | 5118 | ||
5119 | mov [esp+36], eax |
5119 | mov [esp+36], eax |
5120 | mov [esp+24], ebx |
5120 | mov [esp+24], ebx |
5121 | ret |
5121 | ret |
5122 | - | ||
5123 | align 4 |
- | |
5124 | - | ||
5125 | read_from_hd: ; Read from hd - fn not in use |
- | |
5126 | - | ||
5127 | mov edi, [TASK_BASE] |
- | |
5128 | add edi, TASKDATA.mem_start |
- | |
5129 | add eax, [edi] |
- | |
5130 | add ecx, [edi] |
- | |
5131 | add edx, [edi] |
- | |
5132 | call file_read |
- | |
5133 | - | ||
5134 | mov [esp+36], eax |
- | |
5135 | mov [esp+24], ebx |
- | |
5136 | - | ||
5137 | ret |
- | |
5138 | 5122 | ||
5139 | paleholder: |
5123 | paleholder: |
5140 | ret |
5124 | ret |
5141 | ;------------------------------------------------------------------------------ |
5125 | ;------------------------------------------------------------------------------ |
5142 | align 4 |
5126 | align 4 |
5143 | calculate_fast_getting_offset_for_WinMapAddress: |
5127 | calculate_fast_getting_offset_for_WinMapAddress: |
5144 | ; calculate data area for fast getting offset to _WinMapAddress |
5128 | ; calculate data area for fast getting offset to _WinMapAddress |
5145 | xor eax, eax |
5129 | xor eax, eax |
5146 | mov ecx, [_display.height] |
5130 | mov ecx, [_display.height] |
5147 | inc ecx |
5131 | inc ecx |
5148 | mov edi, d_width_calc_area |
5132 | mov edi, d_width_calc_area |
5149 | cld |
5133 | cld |
5150 | @@: |
5134 | @@: |
5151 | stosd |
5135 | stosd |
5152 | add eax, [_display.width] |
5136 | add eax, [_display.width] |
5153 | dec ecx |
5137 | dec ecx |
5154 | jnz @r |
5138 | jnz @r |
5155 | ret |
5139 | ret |
5156 | ;------------------------------------------------------------------------------ |
5140 | ;------------------------------------------------------------------------------ |
5157 | align 4 |
5141 | align 4 |
5158 | calculate_fast_getting_offset_for_LFB: |
5142 | calculate_fast_getting_offset_for_LFB: |
5159 | ; calculate data area for fast getting offset to LFB |
5143 | ; calculate data area for fast getting offset to LFB |
5160 | xor eax, eax |
5144 | xor eax, eax |
5161 | mov ecx, [_display.height] |
5145 | mov ecx, [_display.height] |
5162 | inc ecx |
5146 | inc ecx |
5163 | mov edi, BPSLine_calc_area |
5147 | mov edi, BPSLine_calc_area |
5164 | cld |
5148 | cld |
5165 | @@: |
5149 | @@: |
5166 | stosd |
5150 | stosd |
5167 | add eax, [BytesPerScanLine] |
5151 | add eax, [BytesPerScanLine] |
5168 | dec ecx |
5152 | dec ecx |
5169 | jnz @r |
5153 | jnz @r |
5170 | ret |
5154 | ret |
5171 | ;------------------------------------------------------------------------------ |
5155 | ;------------------------------------------------------------------------------ |
5172 | align 4 |
5156 | align 4 |
5173 | set_screen: |
5157 | set_screen: |
5174 | cmp eax, [Screen_Max_X] |
5158 | cmp eax, [Screen_Max_X] |
5175 | jne .set |
5159 | jne .set |
5176 | 5160 | ||
5177 | cmp edx, [Screen_Max_Y] |
5161 | cmp edx, [Screen_Max_Y] |
5178 | jne .set |
5162 | jne .set |
5179 | ret |
5163 | ret |
5180 | .set: |
5164 | .set: |
5181 | pushfd |
5165 | pushfd |
5182 | cli |
5166 | cli |
5183 | 5167 | ||
5184 | mov [Screen_Max_X], eax |
5168 | mov [Screen_Max_X], eax |
5185 | mov [Screen_Max_Y], edx |
5169 | mov [Screen_Max_Y], edx |
5186 | mov [BytesPerScanLine], ecx |
5170 | mov [BytesPerScanLine], ecx |
5187 | 5171 | ||
5188 | mov [screen_workarea.right], eax |
5172 | mov [screen_workarea.right], eax |
5189 | mov [screen_workarea.bottom], edx |
5173 | mov [screen_workarea.bottom], edx |
5190 | 5174 | ||
5191 | push ebx |
5175 | push ebx |
5192 | push esi |
5176 | push esi |
5193 | push edi |
5177 | push edi |
5194 | 5178 | ||
5195 | pushad |
5179 | pushad |
5196 | 5180 | ||
5197 | stdcall kernel_free, [_WinMapAddress] |
5181 | stdcall kernel_free, [_WinMapAddress] |
5198 | 5182 | ||
5199 | mov eax, [_display.width] |
5183 | mov eax, [_display.width] |
5200 | mul [_display.height] |
5184 | mul [_display.height] |
5201 | mov [_WinMapSize], eax |
5185 | mov [_WinMapSize], eax |
5202 | 5186 | ||
5203 | stdcall kernel_alloc, eax |
5187 | stdcall kernel_alloc, eax |
5204 | mov [_WinMapAddress], eax |
5188 | mov [_WinMapAddress], eax |
5205 | test eax, eax |
5189 | test eax, eax |
5206 | jz .epic_fail |
5190 | jz .epic_fail |
5207 | 5191 | ||
5208 | call calculate_fast_getting_offset_for_WinMapAddress |
5192 | call calculate_fast_getting_offset_for_WinMapAddress |
5209 | ; for Qemu or non standart video cards |
5193 | ; for Qemu or non standart video cards |
5210 | ; Unfortunately [BytesPerScanLine] does not always |
5194 | ; Unfortunately [BytesPerScanLine] does not always |
5211 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5195 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5212 | call calculate_fast_getting_offset_for_LFB |
5196 | call calculate_fast_getting_offset_for_LFB |
5213 | popad |
5197 | popad |
5214 | 5198 | ||
5215 | call repos_windows |
5199 | call repos_windows |
5216 | xor eax, eax |
5200 | xor eax, eax |
5217 | xor ebx, ebx |
5201 | xor ebx, ebx |
5218 | mov ecx, [Screen_Max_X] |
5202 | mov ecx, [Screen_Max_X] |
5219 | mov edx, [Screen_Max_Y] |
5203 | mov edx, [Screen_Max_Y] |
5220 | call calculatescreen |
5204 | call calculatescreen |
5221 | pop edi |
5205 | pop edi |
5222 | pop esi |
5206 | pop esi |
5223 | pop ebx |
5207 | pop ebx |
5224 | 5208 | ||
5225 | popfd |
5209 | popfd |
5226 | ret |
5210 | ret |
5227 | 5211 | ||
5228 | .epic_fail: |
5212 | .epic_fail: |
5229 | hlt ; Houston, we've had a problem |
5213 | hlt ; Houston, we've had a problem |
5230 | 5214 | ||
5231 | ; --------------- APM --------------------- |
5215 | ; --------------- APM --------------------- |
5232 | uglobal |
5216 | uglobal |
5233 | apm_entry dp 0 |
5217 | apm_entry dp 0 |
5234 | apm_vf dd 0 |
5218 | apm_vf dd 0 |
5235 | endg |
5219 | endg |
5236 | 5220 | ||
5237 | align 4 |
5221 | align 4 |
5238 | sys_apm: |
5222 | sys_apm: |
5239 | xor eax, eax |
5223 | xor eax, eax |
5240 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5224 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5241 | jne @f |
5225 | jne @f |
5242 | inc eax |
5226 | inc eax |
5243 | or dword [esp + 44], eax ; error |
5227 | or dword [esp + 44], eax ; error |
5244 | add eax, 7 |
5228 | add eax, 7 |
5245 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5229 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5246 | ret |
5230 | ret |
5247 | 5231 | ||
5248 | @@: |
5232 | @@: |
5249 | ; xchg eax, ecx |
5233 | ; xchg eax, ecx |
5250 | ; xchg ebx, ecx |
5234 | ; xchg ebx, ecx |
5251 | 5235 | ||
5252 | cmp dx, 3 |
5236 | cmp dx, 3 |
5253 | ja @f |
5237 | ja @f |
5254 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5238 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5255 | mov eax, [apm_vf] |
5239 | mov eax, [apm_vf] |
5256 | mov [esp + 32], eax |
5240 | mov [esp + 32], eax |
5257 | shr eax, 16 |
5241 | shr eax, 16 |
5258 | mov [esp + 28], eax |
5242 | mov [esp + 28], eax |
5259 | ret |
5243 | ret |
5260 | 5244 | ||
5261 | @@: |
5245 | @@: |
5262 | 5246 | ||
5263 | mov esi, [master_tab+(OS_BASE shr 20)] |
5247 | mov esi, [master_tab+(OS_BASE shr 20)] |
5264 | xchg [master_tab], esi |
5248 | xchg [master_tab], esi |
5265 | push esi |
5249 | push esi |
5266 | mov edi, cr3 |
5250 | mov edi, cr3 |
5267 | mov cr3, edi ;flush TLB |
5251 | mov cr3, edi ;flush TLB |
5268 | 5252 | ||
5269 | call pword [apm_entry] ;call APM BIOS |
5253 | call pword [apm_entry] ;call APM BIOS |
5270 | 5254 | ||
5271 | xchg eax, [esp] |
5255 | xchg eax, [esp] |
5272 | mov [master_tab], eax |
5256 | mov [master_tab], eax |
5273 | mov eax, cr3 |
5257 | mov eax, cr3 |
5274 | mov cr3, eax |
5258 | mov cr3, eax |
5275 | pop eax |
5259 | pop eax |
5276 | 5260 | ||
5277 | mov [esp + 4 ], edi |
5261 | mov [esp + 4 ], edi |
5278 | mov [esp + 8], esi |
5262 | mov [esp + 8], esi |
5279 | mov [esp + 20], ebx |
5263 | mov [esp + 20], ebx |
5280 | mov [esp + 24], edx |
5264 | mov [esp + 24], edx |
5281 | mov [esp + 28], ecx |
5265 | mov [esp + 28], ecx |
5282 | mov [esp + 32], eax |
5266 | mov [esp + 32], eax |
5283 | setc al |
5267 | setc al |
5284 | and [esp + 44], byte 0xfe |
5268 | and [esp + 44], byte 0xfe |
5285 | or [esp + 44], al |
5269 | or [esp + 44], al |
5286 | ret |
5270 | ret |
5287 | ; ----------------------------------------- |
5271 | ; ----------------------------------------- |
5288 | 5272 | ||
5289 | align 4 |
5273 | align 4 |
5290 | 5274 | ||
5291 | undefined_syscall: ; Undefined system call |
5275 | undefined_syscall: ; Undefined system call |
5292 | mov [esp + 32], dword -1 |
5276 | mov [esp + 32], dword -1 |
5293 | ret |
5277 | ret |
5294 | 5278 | ||
5295 | align 4 |
5279 | align 4 |
5296 | system_shutdown: ; shut down the system |
5280 | system_shutdown: ; shut down the system |
5297 | 5281 | ||
5298 | cmp byte [BOOT_VAR+0x9030], 1 |
5282 | cmp byte [BOOT_VAR+0x9030], 1 |
5299 | jne @F |
5283 | jne @F |
5300 | ret |
5284 | ret |
5301 | @@: |
5285 | @@: |
5302 | call stop_all_services |
5286 | call stop_all_services |
5303 | push 3 ; stop playing cd |
5287 | push 3 ; stop playing cd |
5304 | pop eax |
5288 | pop eax |
5305 | call sys_cd_audio |
5289 | call sys_cd_audio |
5306 | 5290 | ||
5307 | yes_shutdown_param: |
5291 | yes_shutdown_param: |
5308 | cli |
5292 | cli |
5309 | 5293 | ||
5310 | if ~ defined extended_primary_loader |
5294 | if ~ defined extended_primary_loader |
5311 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5295 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5312 | push 12 |
5296 | push 12 |
5313 | pop esi |
5297 | pop esi |
5314 | xor ebx, ebx |
5298 | xor ebx, ebx |
5315 | or ecx, -1 |
5299 | or ecx, -1 |
5316 | mov edx, OS_BASE+0x70000 |
5300 | mov edx, OS_BASE+0x70000 |
5317 | call fileread |
5301 | call fileread |
5318 | 5302 | ||
5319 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5303 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5320 | mov edi, OS_BASE+0x40000 |
5304 | mov edi, OS_BASE+0x40000 |
5321 | mov ecx, 1000 |
5305 | mov ecx, 1000 |
5322 | rep movsb |
5306 | rep movsb |
5323 | end if |
5307 | end if |
5324 | 5308 | ||
5325 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5309 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5326 | mov edi, OS_BASE |
5310 | mov edi, OS_BASE |
5327 | mov ecx, 0x10000/4 |
5311 | mov ecx, 0x10000/4 |
5328 | cld |
5312 | cld |
5329 | rep movsd |
5313 | rep movsd |
5330 | 5314 | ||
5331 | call restorefatchain |
5315 | call restorefatchain |
5332 | 5316 | ||
5333 | call IRQ_mask_all |
5317 | call IRQ_mask_all |
5334 | 5318 | ||
5335 | if 0 |
5319 | if 0 |
5336 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5320 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5337 | mov word [OS_BASE+0x467+2], 0x1000 |
5321 | mov word [OS_BASE+0x467+2], 0x1000 |
5338 | 5322 | ||
5339 | mov al, 0x0F |
5323 | mov al, 0x0F |
5340 | out 0x70, al |
5324 | out 0x70, al |
5341 | mov al, 0x05 |
5325 | mov al, 0x05 |
5342 | out 0x71, al |
5326 | out 0x71, al |
5343 | 5327 | ||
5344 | mov al, 0xFE |
5328 | mov al, 0xFE |
5345 | out 0x64, al |
5329 | out 0x64, al |
5346 | 5330 | ||
5347 | hlt |
5331 | hlt |
5348 | jmp $-1 |
5332 | jmp $-1 |
5349 | 5333 | ||
5350 | else |
5334 | else |
5351 | cmp byte [OS_BASE + 0x9030], 2 |
5335 | cmp byte [OS_BASE + 0x9030], 2 |
5352 | jnz no_acpi_power_off |
5336 | jnz no_acpi_power_off |
5353 | 5337 | ||
5354 | ; scan for RSDP |
5338 | ; scan for RSDP |
5355 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5339 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5356 | movzx eax, word [OS_BASE + 0x40E] |
5340 | movzx eax, word [OS_BASE + 0x40E] |
5357 | shl eax, 4 |
5341 | shl eax, 4 |
5358 | jz @f |
5342 | jz @f |
5359 | mov ecx, 1024/16 |
5343 | mov ecx, 1024/16 |
5360 | call scan_rsdp |
5344 | call scan_rsdp |
5361 | jnc .rsdp_found |
5345 | jnc .rsdp_found |
5362 | @@: |
5346 | @@: |
5363 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5347 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5364 | mov eax, 0xE0000 |
5348 | mov eax, 0xE0000 |
5365 | mov ecx, 0x2000 |
5349 | mov ecx, 0x2000 |
5366 | call scan_rsdp |
5350 | call scan_rsdp |
5367 | jc no_acpi_power_off |
5351 | jc no_acpi_power_off |
5368 | .rsdp_found: |
5352 | .rsdp_found: |
5369 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5353 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5370 | mov ebp, [ipc_tmp] |
5354 | mov ebp, [ipc_tmp] |
5371 | stdcall map_page, ebp, esi, PG_MAP |
5355 | stdcall map_page, ebp, esi, PG_MAP |
5372 | lea eax, [esi+1000h] |
5356 | lea eax, [esi+1000h] |
5373 | lea edx, [ebp+1000h] |
5357 | lea edx, [ebp+1000h] |
5374 | stdcall map_page, edx, eax, PG_MAP |
5358 | stdcall map_page, edx, eax, PG_MAP |
5375 | and esi, 0xFFF |
5359 | and esi, 0xFFF |
5376 | add esi, ebp |
5360 | add esi, ebp |
5377 | cmp dword [esi], 'RSDT' |
5361 | cmp dword [esi], 'RSDT' |
5378 | jnz no_acpi_power_off |
5362 | jnz no_acpi_power_off |
5379 | mov ecx, [esi+4] |
5363 | mov ecx, [esi+4] |
5380 | sub ecx, 24h |
5364 | sub ecx, 24h |
5381 | jbe no_acpi_power_off |
5365 | jbe no_acpi_power_off |
5382 | shr ecx, 2 |
5366 | shr ecx, 2 |
5383 | add esi, 24h |
5367 | add esi, 24h |
5384 | .scan_fadt: |
5368 | .scan_fadt: |
5385 | lodsd |
5369 | lodsd |
5386 | mov ebx, eax |
5370 | mov ebx, eax |
5387 | lea eax, [ebp+2000h] |
5371 | lea eax, [ebp+2000h] |
5388 | stdcall map_page, eax, ebx, PG_MAP |
5372 | stdcall map_page, eax, ebx, PG_MAP |
5389 | lea eax, [ebp+3000h] |
5373 | lea eax, [ebp+3000h] |
5390 | add ebx, 0x1000 |
5374 | add ebx, 0x1000 |
5391 | stdcall map_page, eax, ebx, PG_MAP |
5375 | stdcall map_page, eax, ebx, PG_MAP |
5392 | and ebx, 0xFFF |
5376 | and ebx, 0xFFF |
5393 | lea ebx, [ebx+ebp+2000h] |
5377 | lea ebx, [ebx+ebp+2000h] |
5394 | cmp dword [ebx], 'FACP' |
5378 | cmp dword [ebx], 'FACP' |
5395 | jz .fadt_found |
5379 | jz .fadt_found |
5396 | loop .scan_fadt |
5380 | loop .scan_fadt |
5397 | jmp no_acpi_power_off |
5381 | jmp no_acpi_power_off |
5398 | .fadt_found: |
5382 | .fadt_found: |
5399 | ; ebx is linear address of FADT |
5383 | ; ebx is linear address of FADT |
5400 | mov edi, [ebx+40] ; physical address of the DSDT |
5384 | mov edi, [ebx+40] ; physical address of the DSDT |
5401 | lea eax, [ebp+4000h] |
5385 | lea eax, [ebp+4000h] |
5402 | stdcall map_page, eax, edi, PG_MAP |
5386 | stdcall map_page, eax, edi, PG_MAP |
5403 | lea eax, [ebp+5000h] |
5387 | lea eax, [ebp+5000h] |
5404 | lea esi, [edi+0x1000] |
5388 | lea esi, [edi+0x1000] |
5405 | stdcall map_page, eax, esi, PG_MAP |
5389 | stdcall map_page, eax, esi, PG_MAP |
5406 | and esi, 0xFFF |
5390 | and esi, 0xFFF |
5407 | sub edi, esi |
5391 | sub edi, esi |
5408 | cmp dword [esi+ebp+4000h], 'DSDT' |
5392 | cmp dword [esi+ebp+4000h], 'DSDT' |
5409 | jnz no_acpi_power_off |
5393 | jnz no_acpi_power_off |
5410 | mov eax, [esi+ebp+4004h] ; DSDT length |
5394 | mov eax, [esi+ebp+4004h] ; DSDT length |
5411 | sub eax, 36+4 |
5395 | sub eax, 36+4 |
5412 | jbe no_acpi_power_off |
5396 | jbe no_acpi_power_off |
5413 | add esi, 36 |
5397 | add esi, 36 |
5414 | .scan_dsdt: |
5398 | .scan_dsdt: |
5415 | cmp dword [esi+ebp+4000h], '_S5_' |
5399 | cmp dword [esi+ebp+4000h], '_S5_' |
5416 | jnz .scan_dsdt_cont |
5400 | jnz .scan_dsdt_cont |
5417 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5401 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5418 | jnz .scan_dsdt_cont |
5402 | jnz .scan_dsdt_cont |
5419 | mov dl, [esi+ebp+4000h+6] |
5403 | mov dl, [esi+ebp+4000h+6] |
5420 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5404 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5421 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5405 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5422 | ja .scan_dsdt_cont |
5406 | ja .scan_dsdt_cont |
5423 | cmp dl, 1 |
5407 | cmp dl, 1 |
5424 | jb .scan_dsdt_cont |
5408 | jb .scan_dsdt_cont |
5425 | lea esi, [esi+ebp+4000h+7] |
5409 | lea esi, [esi+ebp+4000h+7] |
5426 | xor ecx, ecx |
5410 | xor ecx, ecx |
5427 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5411 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5428 | jz @f |
5412 | jz @f |
5429 | cmp byte [esi], 0xA |
5413 | cmp byte [esi], 0xA |
5430 | jnz no_acpi_power_off |
5414 | jnz no_acpi_power_off |
5431 | inc esi |
5415 | inc esi |
5432 | mov cl, [esi] |
5416 | mov cl, [esi] |
5433 | @@: |
5417 | @@: |
5434 | inc esi |
5418 | inc esi |
5435 | cmp dl, 2 |
5419 | cmp dl, 2 |
5436 | jb @f |
5420 | jb @f |
5437 | cmp byte [esi], 0 |
5421 | cmp byte [esi], 0 |
5438 | jz @f |
5422 | jz @f |
5439 | cmp byte [esi], 0xA |
5423 | cmp byte [esi], 0xA |
5440 | jnz no_acpi_power_off |
5424 | jnz no_acpi_power_off |
5441 | inc esi |
5425 | inc esi |
5442 | mov ch, [esi] |
5426 | mov ch, [esi] |
5443 | @@: |
5427 | @@: |
5444 | jmp do_acpi_power_off |
5428 | jmp do_acpi_power_off |
5445 | .scan_dsdt_cont: |
5429 | .scan_dsdt_cont: |
5446 | inc esi |
5430 | inc esi |
5447 | cmp esi, 0x1000 |
5431 | cmp esi, 0x1000 |
5448 | jb @f |
5432 | jb @f |
5449 | sub esi, 0x1000 |
5433 | sub esi, 0x1000 |
5450 | add edi, 0x1000 |
5434 | add edi, 0x1000 |
5451 | push eax |
5435 | push eax |
5452 | lea eax, [ebp+4000h] |
5436 | lea eax, [ebp+4000h] |
5453 | stdcall map_page, eax, edi, PG_MAP |
5437 | stdcall map_page, eax, edi, PG_MAP |
5454 | push PG_MAP |
5438 | push PG_MAP |
5455 | lea eax, [edi+1000h] |
5439 | lea eax, [edi+1000h] |
5456 | push eax |
5440 | push eax |
5457 | lea eax, [ebp+5000h] |
5441 | lea eax, [ebp+5000h] |
5458 | push eax |
5442 | push eax |
5459 | stdcall map_page |
5443 | stdcall map_page |
5460 | pop eax |
5444 | pop eax |
5461 | @@: |
5445 | @@: |
5462 | dec eax |
5446 | dec eax |
5463 | jnz .scan_dsdt |
5447 | jnz .scan_dsdt |
5464 | jmp no_acpi_power_off |
5448 | jmp no_acpi_power_off |
5465 | do_acpi_power_off: |
5449 | do_acpi_power_off: |
5466 | mov edx, [ebx+48] |
5450 | mov edx, [ebx+48] |
5467 | test edx, edx |
5451 | test edx, edx |
5468 | jz .nosmi |
5452 | jz .nosmi |
5469 | mov al, [ebx+52] |
5453 | mov al, [ebx+52] |
5470 | out dx, al |
5454 | out dx, al |
5471 | mov edx, [ebx+64] |
5455 | mov edx, [ebx+64] |
5472 | @@: |
5456 | @@: |
5473 | in ax, dx |
5457 | in ax, dx |
5474 | test al, 1 |
5458 | test al, 1 |
5475 | jz @b |
5459 | jz @b |
5476 | .nosmi: |
5460 | .nosmi: |
5477 | and cx, 0x0707 |
5461 | and cx, 0x0707 |
5478 | shl cx, 2 |
5462 | shl cx, 2 |
5479 | or cx, 0x2020 |
5463 | or cx, 0x2020 |
5480 | mov edx, [ebx+64] |
5464 | mov edx, [ebx+64] |
5481 | in ax, dx |
5465 | in ax, dx |
5482 | and ax, 203h |
5466 | and ax, 203h |
5483 | or ah, cl |
5467 | or ah, cl |
5484 | out dx, ax |
5468 | out dx, ax |
5485 | mov edx, [ebx+68] |
5469 | mov edx, [ebx+68] |
5486 | test edx, edx |
5470 | test edx, edx |
5487 | jz @f |
5471 | jz @f |
5488 | in ax, dx |
5472 | in ax, dx |
5489 | and ax, 203h |
5473 | and ax, 203h |
5490 | or ah, ch |
5474 | or ah, ch |
5491 | out dx, ax |
5475 | out dx, ax |
5492 | @@: |
5476 | @@: |
5493 | jmp $ |
5477 | jmp $ |
5494 | 5478 | ||
5495 | 5479 | ||
5496 | no_acpi_power_off: |
5480 | no_acpi_power_off: |
5497 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5481 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5498 | mov word [OS_BASE+0x467+2], 0x1000 |
5482 | mov word [OS_BASE+0x467+2], 0x1000 |
5499 | 5483 | ||
5500 | mov al, 0x0F |
5484 | mov al, 0x0F |
5501 | out 0x70, al |
5485 | out 0x70, al |
5502 | mov al, 0x05 |
5486 | mov al, 0x05 |
5503 | out 0x71, al |
5487 | out 0x71, al |
5504 | 5488 | ||
5505 | mov al, 0xFE |
5489 | mov al, 0xFE |
5506 | out 0x64, al |
5490 | out 0x64, al |
5507 | 5491 | ||
5508 | hlt |
5492 | hlt |
5509 | jmp $-1 |
5493 | jmp $-1 |
5510 | 5494 | ||
5511 | scan_rsdp: |
5495 | scan_rsdp: |
5512 | add eax, OS_BASE |
5496 | add eax, OS_BASE |
5513 | .s: |
5497 | .s: |
5514 | cmp dword [eax], 'RSD ' |
5498 | cmp dword [eax], 'RSD ' |
5515 | jnz .n |
5499 | jnz .n |
5516 | cmp dword [eax+4], 'PTR ' |
5500 | cmp dword [eax+4], 'PTR ' |
5517 | jnz .n |
5501 | jnz .n |
5518 | xor edx, edx |
5502 | xor edx, edx |
5519 | xor esi, esi |
5503 | xor esi, esi |
5520 | @@: |
5504 | @@: |
5521 | add dl, [eax+esi] |
5505 | add dl, [eax+esi] |
5522 | inc esi |
5506 | inc esi |
5523 | cmp esi, 20 |
5507 | cmp esi, 20 |
5524 | jnz @b |
5508 | jnz @b |
5525 | test dl, dl |
5509 | test dl, dl |
5526 | jz .ok |
5510 | jz .ok |
5527 | .n: |
5511 | .n: |
5528 | add eax, 10h |
5512 | add eax, 10h |
5529 | loop .s |
5513 | loop .s |
5530 | stc |
5514 | stc |
5531 | .ok: |
5515 | .ok: |
5532 | ret |
5516 | ret |
5533 | end if |
5517 | end if |
5534 | 5518 | ||
5535 | include "data32.inc" |
5519 | include "data32.inc" |
5536 | 5520 | ||
5537 | __REV__ = __REV |
5521 | __REV__ = __REV |
5538 | 5522 | ||
5539 | uglobals_size = $ - endofcode |
5523 | uglobals_size = $ - endofcode |
5540 | diff16 "end of kernel code",0,$=> |
5524 | diff16 "end of kernel code",0,$=> |