Rev 3536 | Rev 3539 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3536 | Rev 3537 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. |
4 | ;; PROGRAMMING: |
4 | ;; PROGRAMMING: |
5 | ;; Ivan Poddubny |
5 | ;; Ivan Poddubny |
6 | ;; Marat Zakiyanov (Mario79) |
6 | ;; Marat Zakiyanov (Mario79) |
7 | ;; VaStaNi |
7 | ;; VaStaNi |
8 | ;; Trans |
8 | ;; Trans |
9 | ;; Mihail Semenyako (mike.dld) |
9 | ;; Mihail Semenyako (mike.dld) |
10 | ;; Sergey Kuzmin (Wildwest) |
10 | ;; Sergey Kuzmin (Wildwest) |
11 | ;; Andrey Halyavin (halyavin) |
11 | ;; Andrey Halyavin (halyavin) |
12 | ;; Mihail Lisovin (Mihasik) |
12 | ;; Mihail Lisovin (Mihasik) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
14 | ;; NoName |
14 | ;; NoName |
15 | ;; Evgeny Grechnikov (Diamond) |
15 | ;; Evgeny Grechnikov (Diamond) |
16 | ;; Iliya Mihailov (Ghost) |
16 | ;; Iliya Mihailov (Ghost) |
17 | ;; Sergey Semyonov (Serge) |
17 | ;; Sergey Semyonov (Serge) |
18 | ;; Johnny_B |
18 | ;; Johnny_B |
19 | ;; SPraid (simba) |
19 | ;; SPraid (simba) |
20 | ;; Hidnplayr |
20 | ;; Hidnplayr |
21 | ;; Alexey Teplov ( |
21 | ;; Alexey Teplov ( |
22 | ;; Rus |
22 | ;; Rus |
23 | ;; Nable |
23 | ;; Nable |
24 | ;; shurf |
24 | ;; shurf |
25 | ;; Alver |
25 | ;; Alver |
26 | ;; Maxis |
26 | ;; Maxis |
27 | ;; Galkov |
27 | ;; Galkov |
28 | ;; CleverMouse |
28 | ;; CleverMouse |
29 | ;; tsdima |
29 | ;; tsdima |
30 | ;; turbanoff |
30 | ;; turbanoff |
31 | ;; Asper |
31 | ;; Asper |
32 | ;; art_zh |
32 | ;; art_zh |
33 | ;; |
33 | ;; |
34 | ;; Data in this file was originally part of MenuetOS project which is |
34 | ;; Data in this file was originally part of MenuetOS project which is |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
37 | ;; |
37 | ;; |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
39 | ;; PROGRAMMING: |
39 | ;; PROGRAMMING: |
40 | ;; |
40 | ;; |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
42 | ;; - main os coding/design |
42 | ;; - main os coding/design |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
46 | ;; quickcode@mail.ru |
46 | ;; quickcode@mail.ru |
47 | ;; Alexey, kgaz@crosswinds.net |
47 | ;; Alexey, kgaz@crosswinds.net |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
49 | ;; kristol@nic.fi |
49 | ;; kristol@nic.fi |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
53 | ;; |
53 | ;; |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
58 | ;; License (the "GPL") for full details. |
58 | ;; License (the "GPL") for full details. |
59 | ; |
59 | ; |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
65 | ;; on all copies. |
65 | ;; on all copies. |
66 | ;; |
66 | ;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
68 | 68 | ||
69 | format binary as "mnt" |
69 | format binary as "mnt" |
70 | 70 | ||
71 | include 'macros.inc' |
71 | include 'macros.inc' |
72 | include 'struct.inc' |
72 | include 'struct.inc' |
73 | 73 | ||
74 | $Revision: 3536 $ |
74 | $Revision: 3537 $ |
75 | 75 | ||
76 | 76 | ||
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
78 | 78 | ||
79 | ; Enabling the next line will enable serial output console |
79 | ; Enabling the next line will enable serial output console |
80 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
80 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
81 | ; The following constant, if nonzero, duplicates debug output to the screen. |
81 | ; The following constant, if nonzero, duplicates debug output to the screen. |
82 | debug_direct_print equ 0 |
82 | debug_direct_print equ 0 |
83 | 83 | ||
84 | include "proc32.inc" |
84 | include "proc32.inc" |
85 | include "kglobals.inc" |
85 | include "kglobals.inc" |
86 | include "lang.inc" |
86 | include "lang.inc" |
87 | 87 | ||
88 | include "const.inc" |
88 | include "const.inc" |
89 | max_processes equ 255 |
89 | max_processes equ 255 |
90 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
90 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
91 | 91 | ||
92 | 92 | ||
93 | os_stack equ (os_data_l-gdts) ; GDTs |
93 | os_stack equ (os_data_l-gdts) ; GDTs |
94 | os_code equ (os_code_l-gdts) |
94 | os_code equ (os_code_l-gdts) |
95 | graph_data equ (3+graph_data_l-gdts) |
95 | graph_data equ (3+graph_data_l-gdts) |
96 | tss0 equ (tss0_l-gdts) |
96 | tss0 equ (tss0_l-gdts) |
97 | app_code equ (3+app_code_l-gdts) |
97 | app_code equ (3+app_code_l-gdts) |
98 | app_data equ (3+app_data_l-gdts) |
98 | app_data equ (3+app_data_l-gdts) |
99 | app_tls equ (3+tls_data_l-gdts) |
99 | app_tls equ (3+tls_data_l-gdts) |
100 | pci_code_sel equ (pci_code_32-gdts) |
100 | pci_code_sel equ (pci_code_32-gdts) |
101 | pci_data_sel equ (pci_data_32-gdts) |
101 | pci_data_sel equ (pci_data_32-gdts) |
102 | 102 | ||
103 | 103 | ||
104 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
104 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
105 | ;; |
105 | ;; |
106 | ;; Included files: |
106 | ;; Included files: |
107 | ;; |
107 | ;; |
108 | ;; Kernel16.inc |
108 | ;; Kernel16.inc |
109 | ;; - Booteng.inc English text for bootup |
109 | ;; - Booteng.inc English text for bootup |
110 | ;; - Bootcode.inc Hardware setup |
110 | ;; - Bootcode.inc Hardware setup |
111 | ;; - Pci16.inc PCI functions |
111 | ;; - Pci16.inc PCI functions |
112 | ;; |
112 | ;; |
113 | ;; Kernel32.inc |
113 | ;; Kernel32.inc |
114 | ;; - Sys32.inc Process management |
114 | ;; - Sys32.inc Process management |
115 | ;; - Shutdown.inc Shutdown and restart |
115 | ;; - Shutdown.inc Shutdown and restart |
116 | ;; - Fat32.inc Read / write hd |
116 | ;; - Fat32.inc Read / write hd |
117 | ;; - Vesa12.inc Vesa 1.2 driver |
117 | ;; - Vesa12.inc Vesa 1.2 driver |
118 | ;; - Vesa20.inc Vesa 2.0 driver |
118 | ;; - Vesa20.inc Vesa 2.0 driver |
119 | ;; - Vga.inc VGA driver |
119 | ;; - Vga.inc VGA driver |
120 | ;; - Stack.inc Network interface |
120 | ;; - Stack.inc Network interface |
121 | ;; - Mouse.inc Mouse pointer |
121 | ;; - Mouse.inc Mouse pointer |
122 | ;; - Scincode.inc Window skinning |
122 | ;; - Scincode.inc Window skinning |
123 | ;; - Pci32.inc PCI functions |
123 | ;; - Pci32.inc PCI functions |
124 | ;; |
124 | ;; |
125 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
125 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
126 | 126 | ||
127 | 127 | ||
128 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
128 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
129 | ;; ;; |
129 | ;; ;; |
130 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
130 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
131 | ;; ;; |
131 | ;; ;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
133 | 133 | ||
134 | use16 |
134 | use16 |
135 | org 0x0 |
135 | org 0x0 |
136 | jmp start_of_code |
136 | jmp start_of_code |
137 | 137 | ||
138 | if lang eq sp |
138 | if lang eq sp |
139 | include "kernelsp.inc" ; spanish kernel messages |
139 | include "kernelsp.inc" ; spanish kernel messages |
140 | else |
140 | else |
141 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
141 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
142 | end if |
142 | end if |
143 | 143 | ||
144 | include "boot/bootstr.inc" ; language-independent boot messages |
144 | include "boot/bootstr.inc" ; language-independent boot messages |
145 | include "boot/preboot.inc" |
145 | include "boot/preboot.inc" |
146 | 146 | ||
147 | if lang eq ge |
147 | if lang eq ge |
148 | include "boot/bootge.inc" ; german system boot messages |
148 | include "boot/bootge.inc" ; german system boot messages |
149 | else if lang eq sp |
149 | else if lang eq sp |
150 | include "boot/bootsp.inc" ; spanish system boot messages |
150 | include "boot/bootsp.inc" ; spanish system boot messages |
151 | else if lang eq ru |
151 | else if lang eq ru |
152 | include "boot/bootru.inc" ; russian system boot messages |
152 | include "boot/bootru.inc" ; russian system boot messages |
153 | include "boot/ru.inc" ; Russian font |
153 | include "boot/ru.inc" ; Russian font |
154 | else if lang eq et |
154 | else if lang eq et |
155 | include "boot/bootet.inc" ; estonian system boot messages |
155 | include "boot/bootet.inc" ; estonian system boot messages |
156 | include "boot/et.inc" ; Estonian font |
156 | include "boot/et.inc" ; Estonian font |
157 | else |
157 | else |
158 | include "boot/booten.inc" ; english system boot messages |
158 | include "boot/booten.inc" ; english system boot messages |
159 | end if |
159 | end if |
160 | 160 | ||
161 | include "boot/bootcode.inc" ; 16 bit system boot code |
161 | include "boot/bootcode.inc" ; 16 bit system boot code |
162 | include "bus/pci/pci16.inc" |
162 | include "bus/pci/pci16.inc" |
163 | include "detect/biosdisk.inc" |
163 | include "detect/biosdisk.inc" |
164 | 164 | ||
165 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
165 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
166 | ;; ;; |
166 | ;; ;; |
167 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
167 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
168 | ;; ;; |
168 | ;; ;; |
169 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
169 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
170 | 170 | ||
171 | 171 | ||
172 | ; CR0 Flags - Protected mode and Paging |
172 | ; CR0 Flags - Protected mode and Paging |
173 | 173 | ||
174 | mov ecx, CR0_PE |
174 | mov ecx, CR0_PE |
175 | 175 | ||
176 | ; Enabling 32 bit protected mode |
176 | ; Enabling 32 bit protected mode |
177 | 177 | ||
178 | sidt [cs:old_ints_h] |
178 | sidt [cs:old_ints_h] |
179 | 179 | ||
180 | cli ; disable all irqs |
180 | cli ; disable all irqs |
181 | cld |
181 | cld |
182 | mov al, 255 ; mask all irqs |
182 | mov al, 255 ; mask all irqs |
183 | out 0xa1, al |
183 | out 0xa1, al |
184 | out 0x21, al |
184 | out 0x21, al |
185 | l.5: |
185 | l.5: |
186 | in al, 0x64 ; Enable A20 |
186 | in al, 0x64 ; Enable A20 |
187 | test al, 2 |
187 | test al, 2 |
188 | jnz l.5 |
188 | jnz l.5 |
189 | mov al, 0xD1 |
189 | mov al, 0xD1 |
190 | out 0x64, al |
190 | out 0x64, al |
191 | l.6: |
191 | l.6: |
192 | in al, 0x64 |
192 | in al, 0x64 |
193 | test al, 2 |
193 | test al, 2 |
194 | jnz l.6 |
194 | jnz l.6 |
195 | mov al, 0xDF |
195 | mov al, 0xDF |
196 | out 0x60, al |
196 | out 0x60, al |
197 | l.7: |
197 | l.7: |
198 | in al, 0x64 |
198 | in al, 0x64 |
199 | test al, 2 |
199 | test al, 2 |
200 | jnz l.7 |
200 | jnz l.7 |
201 | mov al, 0xFF |
201 | mov al, 0xFF |
202 | out 0x64, al |
202 | out 0x64, al |
203 | 203 | ||
204 | lgdt [cs:tmp_gdt] ; Load GDT |
204 | lgdt [cs:tmp_gdt] ; Load GDT |
205 | mov eax, cr0 ; protected mode |
205 | mov eax, cr0 ; protected mode |
206 | or eax, ecx |
206 | or eax, ecx |
207 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
207 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
208 | mov cr0, eax |
208 | mov cr0, eax |
209 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
209 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
210 | 210 | ||
211 | align 8 |
211 | align 8 |
212 | tmp_gdt: |
212 | tmp_gdt: |
213 | 213 | ||
214 | dw 23 |
214 | dw 23 |
215 | dd tmp_gdt+0x10000 |
215 | dd tmp_gdt+0x10000 |
216 | dw 0 |
216 | dw 0 |
217 | 217 | ||
218 | dw 0xffff |
218 | dw 0xffff |
219 | dw 0x0000 |
219 | dw 0x0000 |
220 | db 0x00 |
220 | db 0x00 |
221 | dw 11011111b *256 +10011010b |
221 | dw 11011111b *256 +10011010b |
222 | db 0x00 |
222 | db 0x00 |
223 | 223 | ||
224 | dw 0xffff |
224 | dw 0xffff |
225 | dw 0x0000 |
225 | dw 0x0000 |
226 | db 0x00 |
226 | db 0x00 |
227 | dw 11011111b *256 +10010010b |
227 | dw 11011111b *256 +10010010b |
228 | db 0x00 |
228 | db 0x00 |
229 | 229 | ||
230 | include "data16.inc" |
230 | include "data16.inc" |
231 | 231 | ||
232 | use32 |
232 | use32 |
233 | org $+0x10000 |
233 | org $+0x10000 |
234 | 234 | ||
235 | align 4 |
235 | align 4 |
236 | B32: |
236 | B32: |
237 | mov ax, os_stack ; Selector for os |
237 | mov ax, os_stack ; Selector for os |
238 | mov ds, ax |
238 | mov ds, ax |
239 | mov es, ax |
239 | mov es, ax |
240 | mov fs, ax |
240 | mov fs, ax |
241 | mov gs, ax |
241 | mov gs, ax |
242 | mov ss, ax |
242 | mov ss, ax |
243 | mov esp, 0x006CC00 ; Set stack |
243 | mov esp, 0x006CC00 ; Set stack |
244 | 244 | ||
245 | ; CLEAR 0x280000 - HEAP_BASE |
245 | ; CLEAR 0x280000 - HEAP_BASE |
246 | 246 | ||
247 | xor eax, eax |
247 | xor eax, eax |
248 | mov edi, CLEAN_ZONE |
248 | mov edi, CLEAN_ZONE |
249 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
249 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
250 | cld |
250 | cld |
251 | rep stosd |
251 | rep stosd |
252 | 252 | ||
253 | ; CLEAR KERNEL UNDEFINED GLOBALS |
253 | ; CLEAR KERNEL UNDEFINED GLOBALS |
254 | mov edi, endofcode-OS_BASE |
254 | mov edi, endofcode-OS_BASE |
255 | mov ecx, 0x90000 |
255 | mov ecx, 0x90000 |
256 | sub ecx, edi |
256 | sub ecx, edi |
257 | shr ecx, 2 |
257 | shr ecx, 2 |
258 | rep stosd |
258 | rep stosd |
259 | 259 | ||
260 | ; SAVE & CLEAR 0-0xffff |
260 | ; SAVE & CLEAR 0-0xffff |
261 | 261 | ||
262 | xor esi, esi |
262 | xor esi, esi |
263 | mov edi, (BOOT_VAR-OS_BASE) |
263 | mov edi, (BOOT_VAR-OS_BASE) |
264 | mov ecx, 0x10000 / 4 |
264 | mov ecx, 0x10000 / 4 |
265 | rep movsd |
265 | rep movsd |
266 | mov edi, 0x1000 |
266 | mov edi, 0x1000 |
267 | mov ecx, 0xf000 / 4 |
267 | mov ecx, 0xf000 / 4 |
268 | rep stosd |
268 | rep stosd |
269 | 269 | ||
270 | call test_cpu |
270 | call test_cpu |
271 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
271 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
272 | 272 | ||
273 | call check_acpi |
273 | call check_acpi |
274 | call init_BIOS32 |
274 | call init_BIOS32 |
275 | ; MEMORY MODEL |
275 | ; MEMORY MODEL |
276 | call mem_test |
276 | call mem_test |
277 | call init_mem |
277 | call init_mem |
278 | call init_page_map |
278 | call init_page_map |
279 | 279 | ||
280 | ; ENABLE PAGING |
280 | ; ENABLE PAGING |
281 | 281 | ||
282 | mov eax, sys_pgdir-OS_BASE |
282 | mov eax, sys_pgdir-OS_BASE |
283 | mov cr3, eax |
283 | mov cr3, eax |
284 | 284 | ||
285 | mov eax, cr0 |
285 | mov eax, cr0 |
286 | or eax, CR0_PG+CR0_WP |
286 | or eax, CR0_PG+CR0_WP |
287 | mov cr0, eax |
287 | mov cr0, eax |
288 | 288 | ||
289 | lgdt [gdts] |
289 | lgdt [gdts] |
290 | jmp pword os_code:high_code |
290 | jmp pword os_code:high_code |
291 | 291 | ||
292 | align 4 |
292 | align 4 |
293 | bios32_entry dd ? |
293 | bios32_entry dd ? |
294 | tmp_page_tabs dd ? |
294 | tmp_page_tabs dd ? |
295 | 295 | ||
296 | use16 |
296 | use16 |
297 | org $-0x10000 |
297 | org $-0x10000 |
298 | include "boot/shutdown.inc" ; shutdown or restart |
298 | include "boot/shutdown.inc" ; shutdown or restart |
299 | org $+0x10000 |
299 | org $+0x10000 |
300 | use32 |
300 | use32 |
301 | 301 | ||
302 | __DEBUG__ fix 1 |
302 | __DEBUG__ fix 1 |
303 | __DEBUG_LEVEL__ fix 1 |
303 | __DEBUG_LEVEL__ fix 1 |
304 | include 'init.inc' |
304 | include 'init.inc' |
305 | 305 | ||
306 | org OS_BASE+$ |
306 | org OS_BASE+$ |
307 | 307 | ||
308 | include 'fdo.inc' |
308 | include 'fdo.inc' |
309 | 309 | ||
310 | align 4 |
310 | align 4 |
311 | high_code: |
311 | high_code: |
312 | mov ax, os_stack |
312 | mov ax, os_stack |
313 | mov bx, app_data |
313 | mov bx, app_data |
314 | mov cx, app_tls |
314 | mov cx, app_tls |
315 | mov ss, ax |
315 | mov ss, ax |
316 | add esp, OS_BASE |
316 | add esp, OS_BASE |
317 | 317 | ||
318 | mov ds, bx |
318 | mov ds, bx |
319 | mov es, bx |
319 | mov es, bx |
320 | mov fs, cx |
320 | mov fs, cx |
321 | mov gs, bx |
321 | mov gs, bx |
322 | 322 | ||
323 | bt [cpu_caps], CAPS_PGE |
323 | bt [cpu_caps], CAPS_PGE |
324 | jnc @F |
324 | jnc @F |
325 | 325 | ||
326 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
326 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
327 | 327 | ||
328 | mov ebx, cr4 |
328 | mov ebx, cr4 |
329 | or ebx, CR4_PGE |
329 | or ebx, CR4_PGE |
330 | mov cr4, ebx |
330 | mov cr4, ebx |
331 | @@: |
331 | @@: |
332 | xor eax, eax |
332 | xor eax, eax |
333 | mov dword [sys_pgdir], eax |
333 | mov dword [sys_pgdir], eax |
334 | mov dword [sys_pgdir+4], eax |
334 | mov dword [sys_pgdir+4], eax |
335 | 335 | ||
336 | mov eax, cr3 |
336 | mov eax, cr3 |
337 | mov cr3, eax ; flush TLB |
337 | mov cr3, eax ; flush TLB |
338 | 338 | ||
339 | mov ecx, pg_data.mutex |
339 | mov ecx, pg_data.mutex |
340 | call mutex_init |
340 | call mutex_init |
341 | 341 | ||
342 | mov ecx, disk_list_mutex |
342 | mov ecx, disk_list_mutex |
343 | call mutex_init |
343 | call mutex_init |
344 | 344 | ||
345 | mov ecx, keyboard_list_mutex |
345 | mov ecx, keyboard_list_mutex |
346 | call mutex_init |
346 | call mutex_init |
347 | 347 | ||
348 | mov ecx, unpack_mutex |
348 | mov ecx, unpack_mutex |
349 | call mutex_init |
349 | call mutex_init |
350 | 350 | ||
351 | mov ecx, application_table_mutex |
351 | mov ecx, application_table_mutex |
352 | call mutex_init |
352 | call mutex_init |
353 | 353 | ||
354 | ; SAVE REAL MODE VARIABLES |
354 | ; SAVE REAL MODE VARIABLES |
355 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
355 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
356 | mov [IDEContrRegsBaseAddr], ax |
356 | mov [IDEContrRegsBaseAddr], ax |
357 | ; --------------- APM --------------------- |
357 | ; --------------- APM --------------------- |
358 | 358 | ||
359 | ; init selectors |
359 | ; init selectors |
360 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
360 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
361 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
361 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
362 | ; protected-mode 32-bit code segment |
362 | ; protected-mode 32-bit code segment |
363 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
363 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
364 | ; protected-mode 16-bit code segment |
364 | ; protected-mode 16-bit code segment |
365 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
365 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
366 | ; protected-mode 16-bit data segment |
366 | ; protected-mode 16-bit data segment |
367 | 367 | ||
368 | shl eax, 4 |
368 | shl eax, 4 |
369 | mov [dword apm_code_32 + 2], ax |
369 | mov [dword apm_code_32 + 2], ax |
370 | shr eax, 16 |
370 | shr eax, 16 |
371 | mov [dword apm_code_32 + 4], al |
371 | mov [dword apm_code_32 + 4], al |
372 | 372 | ||
373 | shl ecx, 4 |
373 | shl ecx, 4 |
374 | mov [dword apm_code_16 + 2], cx |
374 | mov [dword apm_code_16 + 2], cx |
375 | shr ecx, 16 |
375 | shr ecx, 16 |
376 | mov [dword apm_code_16 + 4], cl |
376 | mov [dword apm_code_16 + 4], cl |
377 | 377 | ||
378 | shl edx, 4 |
378 | shl edx, 4 |
379 | mov [dword apm_data_16 + 2], dx |
379 | mov [dword apm_data_16 + 2], dx |
380 | shr edx, 16 |
380 | shr edx, 16 |
381 | mov [dword apm_data_16 + 4], dl |
381 | mov [dword apm_data_16 + 4], dl |
382 | 382 | ||
383 | mov dword[apm_entry], ebx |
383 | mov dword[apm_entry], ebx |
384 | mov word [apm_entry + 4], apm_code_32 - gdts |
384 | mov word [apm_entry + 4], apm_code_32 - gdts |
385 | 385 | ||
386 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
386 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
387 | mov [apm_vf], eax |
387 | mov [apm_vf], eax |
388 | ; ----------------------------------------- |
388 | ; ----------------------------------------- |
389 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
389 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
390 | mov [allow_dma_access], al |
390 | mov [allow_dma_access], al |
391 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
391 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
392 | mov [ScreenBPP], al |
- | |
393 | - | ||
394 | mov [_display.bpp], eax |
392 | mov [_display.bpp], eax |
395 | mov [_display.vrefresh], 60 |
393 | mov [_display.vrefresh], 60 |
396 | 394 | ||
397 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
395 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
398 | mov [_display.width], eax |
396 | mov [_display.width], eax |
399 | mov [display_width_standard], eax |
397 | mov [display_width_standard], eax |
400 | dec eax |
398 | dec eax |
401 | mov [Screen_Max_X], eax |
399 | mov [Screen_Max_X], eax |
402 | mov [screen_workarea.right], eax |
400 | mov [screen_workarea.right], eax |
403 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
401 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
404 | mov [_display.height], eax |
402 | mov [_display.height], eax |
405 | mov [display_height_standard], eax |
403 | mov [display_height_standard], eax |
406 | dec eax |
404 | dec eax |
407 | mov [Screen_Max_Y], eax |
405 | mov [Screen_Max_Y], eax |
408 | mov [screen_workarea.bottom], eax |
406 | mov [screen_workarea.bottom], eax |
409 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE]; screen mode |
407 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE]; screen mode |
410 | mov [SCR_MODE], eax |
408 | mov [SCR_MODE], eax |
411 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
409 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
412 | ; mov [BANK_SWITCH], eax |
410 | ; mov [BANK_SWITCH], eax |
413 | mov [BytesPerScanLine], word 640*4 ; Bytes PerScanLine |
411 | mov [BytesPerScanLine], word 640*4 ; Bytes PerScanLine |
414 | cmp [SCR_MODE], word 0x13 ; 320x200 |
412 | cmp [SCR_MODE], word 0x13 ; 320x200 |
415 | je @f |
413 | je @f |
416 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
414 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
417 | je @f |
415 | je @f |
418 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
416 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
419 | mov [BytesPerScanLine], ax |
417 | mov [BytesPerScanLine], ax |
420 | mov [_display.pitch], eax |
418 | mov [_display.pitch], eax |
421 | @@: |
419 | @@: |
422 | mov eax, [_display.width] |
420 | mov eax, [_display.width] |
423 | mul [_display.height] |
421 | mul [_display.height] |
424 | mov [_WinMapSize], eax |
422 | mov [_WinMapSize], eax |
425 | 423 | ||
426 | call calculate_fast_getting_offset_for_WinMapAddress |
424 | call calculate_fast_getting_offset_for_WinMapAddress |
427 | ; for Qemu or non standart video cards |
425 | ; for Qemu or non standart video cards |
428 | ; Unfortunately [BytesPerScanLine] does not always |
426 | ; Unfortunately [BytesPerScanLine] does not always |
429 | ; equal to [_display.width] * [ScreenBPP] / 8 |
427 | ; equal to [_display.width] * [ScreenBPP] / 8 |
430 | call calculate_fast_getting_offset_for_LFB |
428 | call calculate_fast_getting_offset_for_LFB |
431 | 429 | ||
432 | mov esi, BOOT_VAR+0x9080 |
430 | mov esi, BOOT_VAR+0x9080 |
433 | movzx ecx, byte [esi-1] |
431 | movzx ecx, byte [esi-1] |
434 | mov [NumBiosDisks], ecx |
432 | mov [NumBiosDisks], ecx |
435 | mov edi, BiosDisksData |
433 | mov edi, BiosDisksData |
436 | rep movsd |
434 | rep movsd |
437 | 435 | ||
438 | ; GRAPHICS ADDRESSES |
436 | ; GRAPHICS ADDRESSES |
439 | 437 | ||
440 | mov eax, [BOOT_VAR+BOOT_LFB] |
438 | mov eax, [BOOT_VAR+BOOT_LFB] |
441 | mov [LFBAddress], eax |
439 | mov [LFBAddress], eax |
442 | 440 | ||
443 | cmp [SCR_MODE], word 0100000000000000b |
441 | cmp [SCR_MODE], word 0100000000000000b |
444 | jge setvesa20 |
442 | jge setvesa20 |
445 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
443 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
446 | je v20ga32 |
444 | je v20ga32 |
447 | jmp v20ga24 |
445 | jmp v20ga24 |
448 | 446 | ||
449 | setvesa20: |
447 | setvesa20: |
450 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
448 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
451 | mov [GETPIXEL], dword Vesa20_getpixel24 |
449 | mov [GETPIXEL], dword Vesa20_getpixel24 |
452 | cmp [ScreenBPP], byte 24 |
450 | cmp byte [_display.bpp], 24 |
453 | jz v20ga24 |
451 | jz v20ga24 |
454 | v20ga32: |
452 | v20ga32: |
455 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
453 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
456 | mov [GETPIXEL], dword Vesa20_getpixel32 |
454 | mov [GETPIXEL], dword Vesa20_getpixel32 |
457 | jmp no_mode_0x12 |
455 | jmp no_mode_0x12 |
458 | v20ga24: |
456 | v20ga24: |
459 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
457 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
460 | jne no_mode_0x12 |
458 | jne no_mode_0x12 |
461 | mov [PUTPIXEL], dword VGA_putpixel |
459 | mov [PUTPIXEL], dword VGA_putpixel |
462 | mov [GETPIXEL], dword Vesa20_getpixel32 |
460 | mov [GETPIXEL], dword Vesa20_getpixel32 |
463 | no_mode_0x12: |
461 | no_mode_0x12: |
464 | 462 | ||
465 | mov [MOUSE_PICTURE], dword mousepointer |
463 | mov [MOUSE_PICTURE], dword mousepointer |
466 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
464 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
467 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
465 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
468 | 466 | ||
469 | ; -------- Fast System Call init ---------- |
467 | ; -------- Fast System Call init ---------- |
470 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
468 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
471 | bt [cpu_caps], CAPS_SEP |
469 | bt [cpu_caps], CAPS_SEP |
472 | jnc .SEnP ; SysEnter not Present |
470 | jnc .SEnP ; SysEnter not Present |
473 | xor edx, edx |
471 | xor edx, edx |
474 | mov ecx, MSR_SYSENTER_CS |
472 | mov ecx, MSR_SYSENTER_CS |
475 | mov eax, os_code |
473 | mov eax, os_code |
476 | wrmsr |
474 | wrmsr |
477 | mov ecx, MSR_SYSENTER_ESP |
475 | mov ecx, MSR_SYSENTER_ESP |
478 | ; mov eax, sysenter_stack ; Check it |
476 | ; mov eax, sysenter_stack ; Check it |
479 | xor eax, eax |
477 | xor eax, eax |
480 | wrmsr |
478 | wrmsr |
481 | mov ecx, MSR_SYSENTER_EIP |
479 | mov ecx, MSR_SYSENTER_EIP |
482 | mov eax, sysenter_entry |
480 | mov eax, sysenter_entry |
483 | wrmsr |
481 | wrmsr |
484 | .SEnP: |
482 | .SEnP: |
485 | ; AMD SYSCALL/SYSRET |
483 | ; AMD SYSCALL/SYSRET |
486 | cmp byte[cpu_vendor], 'A' |
484 | cmp byte[cpu_vendor], 'A' |
487 | jne .noSYSCALL |
485 | jne .noSYSCALL |
488 | mov eax, 0x80000001 |
486 | mov eax, 0x80000001 |
489 | cpuid |
487 | cpuid |
490 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
488 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
491 | jz .noSYSCALL |
489 | jz .noSYSCALL |
492 | mov ecx, MSR_AMD_EFER |
490 | mov ecx, MSR_AMD_EFER |
493 | rdmsr |
491 | rdmsr |
494 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
492 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
495 | wrmsr |
493 | wrmsr |
496 | 494 | ||
497 | ; !!!! It`s dirty hack, fix it !!! |
495 | ; !!!! It`s dirty hack, fix it !!! |
498 | ; Bits of EDX : |
496 | ; Bits of EDX : |
499 | ; Bit 3116 During the SYSRET instruction, this field is copied into the CS register |
497 | ; Bit 3116 During the SYSRET instruction, this field is copied into the CS register |
500 | ; and the contents of this field, plus 8, are copied into the SS register. |
498 | ; and the contents of this field, plus 8, are copied into the SS register. |
501 | ; Bit 150 During the SYSCALL instruction, this field is copied into the CS register |
499 | ; Bit 150 During the SYSCALL instruction, this field is copied into the CS register |
502 | ; and the contents of this field, plus 8, are copied into the SS register. |
500 | ; and the contents of this field, plus 8, are copied into the SS register. |
503 | 501 | ||
504 | ; mov edx, (os_code + 16) * 65536 + os_code |
502 | ; mov edx, (os_code + 16) * 65536 + os_code |
505 | mov edx, 0x1B0008 |
503 | mov edx, 0x1B0008 |
506 | 504 | ||
507 | mov eax, syscall_entry |
505 | mov eax, syscall_entry |
508 | mov ecx, MSR_AMD_STAR |
506 | mov ecx, MSR_AMD_STAR |
509 | wrmsr |
507 | wrmsr |
510 | .noSYSCALL: |
508 | .noSYSCALL: |
511 | ; ----------------------------------------- |
509 | ; ----------------------------------------- |
512 | stdcall alloc_page |
510 | stdcall alloc_page |
513 | stdcall map_page, tss-0xF80, eax, PG_SW |
511 | stdcall map_page, tss-0xF80, eax, PG_SW |
514 | stdcall alloc_page |
512 | stdcall alloc_page |
515 | stdcall map_page, tss+0x80, eax, PG_SW |
513 | stdcall map_page, tss+0x80, eax, PG_SW |
516 | stdcall alloc_page |
514 | stdcall alloc_page |
517 | stdcall map_page, tss+0x1080, eax, PG_SW |
515 | stdcall map_page, tss+0x1080, eax, PG_SW |
518 | 516 | ||
519 | ; LOAD IDT |
517 | ; LOAD IDT |
520 | 518 | ||
521 | call build_interrupt_table ;lidt is executed |
519 | call build_interrupt_table ;lidt is executed |
522 | ;lidt [idtreg] |
520 | ;lidt [idtreg] |
523 | 521 | ||
524 | call init_kernel_heap |
522 | call init_kernel_heap |
525 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
523 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
526 | mov [os_stack_seg], eax |
524 | mov [os_stack_seg], eax |
527 | 525 | ||
528 | lea esp, [eax+RING0_STACK_SIZE] |
526 | lea esp, [eax+RING0_STACK_SIZE] |
529 | 527 | ||
530 | mov [tss._ss0], os_stack |
528 | mov [tss._ss0], os_stack |
531 | mov [tss._esp0], esp |
529 | mov [tss._esp0], esp |
532 | mov [tss._esp], esp |
530 | mov [tss._esp], esp |
533 | mov [tss._cs], os_code |
531 | mov [tss._cs], os_code |
534 | mov [tss._ss], os_stack |
532 | mov [tss._ss], os_stack |
535 | mov [tss._ds], app_data |
533 | mov [tss._ds], app_data |
536 | mov [tss._es], app_data |
534 | mov [tss._es], app_data |
537 | mov [tss._fs], app_data |
535 | mov [tss._fs], app_data |
538 | mov [tss._gs], app_data |
536 | mov [tss._gs], app_data |
539 | mov [tss._io], 128 |
537 | mov [tss._io], 128 |
540 | ;Add IO access table - bit array of permitted ports |
538 | ;Add IO access table - bit array of permitted ports |
541 | mov edi, tss._io_map_0 |
539 | mov edi, tss._io_map_0 |
542 | xor eax, eax |
540 | xor eax, eax |
543 | not eax |
541 | not eax |
544 | mov ecx, 8192/4 |
542 | mov ecx, 8192/4 |
545 | rep stosd ; access to 4096*8=65536 ports |
543 | rep stosd ; access to 4096*8=65536 ports |
546 | 544 | ||
547 | mov ax, tss0 |
545 | mov ax, tss0 |
548 | ltr ax |
546 | ltr ax |
549 | 547 | ||
550 | mov [LFBSize], 0xC00000 |
548 | mov [LFBSize], 0xC00000 |
551 | call init_LFB |
549 | call init_LFB |
552 | call init_fpu |
550 | call init_fpu |
553 | call init_malloc |
551 | call init_malloc |
554 | 552 | ||
555 | stdcall alloc_kernel_space, 0x51000 |
553 | stdcall alloc_kernel_space, 0x51000 |
556 | mov [default_io_map], eax |
554 | mov [default_io_map], eax |
557 | 555 | ||
558 | add eax, 0x2000 |
556 | add eax, 0x2000 |
559 | mov [ipc_tmp], eax |
557 | mov [ipc_tmp], eax |
560 | mov ebx, 0x1000 |
558 | mov ebx, 0x1000 |
561 | 559 | ||
562 | add eax, 0x40000 |
560 | add eax, 0x40000 |
563 | mov [proc_mem_map], eax |
561 | mov [proc_mem_map], eax |
564 | 562 | ||
565 | add eax, 0x8000 |
563 | add eax, 0x8000 |
566 | mov [proc_mem_pdir], eax |
564 | mov [proc_mem_pdir], eax |
567 | 565 | ||
568 | add eax, ebx |
566 | add eax, ebx |
569 | mov [proc_mem_tab], eax |
567 | mov [proc_mem_tab], eax |
570 | 568 | ||
571 | add eax, ebx |
569 | add eax, ebx |
572 | mov [tmp_task_pdir], eax |
570 | mov [tmp_task_pdir], eax |
573 | 571 | ||
574 | add eax, ebx |
572 | add eax, ebx |
575 | mov [tmp_task_ptab], eax |
573 | mov [tmp_task_ptab], eax |
576 | 574 | ||
577 | add eax, ebx |
575 | add eax, ebx |
578 | mov [ipc_pdir], eax |
576 | mov [ipc_pdir], eax |
579 | 577 | ||
580 | add eax, ebx |
578 | add eax, ebx |
581 | mov [ipc_ptab], eax |
579 | mov [ipc_ptab], eax |
582 | 580 | ||
583 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
581 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
584 | (unpack.lc+unpack.lp)))*4 |
582 | (unpack.lc+unpack.lp)))*4 |
585 | 583 | ||
586 | mov [unpack.p], eax |
584 | mov [unpack.p], eax |
587 | 585 | ||
588 | call init_events |
586 | call init_events |
589 | mov eax, srv.fd-SRV.fd |
587 | mov eax, srv.fd-SRV.fd |
590 | mov [srv.fd], eax |
588 | mov [srv.fd], eax |
591 | mov [srv.bk], eax |
589 | mov [srv.bk], eax |
592 | 590 | ||
593 | ;Set base of graphic segment to linear address of LFB |
591 | ;Set base of graphic segment to linear address of LFB |
594 | mov eax, [LFBAddress] ; set for gs |
592 | mov eax, [LFBAddress] ; set for gs |
595 | mov [graph_data_l+2], ax |
593 | mov [graph_data_l+2], ax |
596 | shr eax, 16 |
594 | shr eax, 16 |
597 | mov [graph_data_l+4], al |
595 | mov [graph_data_l+4], al |
598 | mov [graph_data_l+7], ah |
596 | mov [graph_data_l+7], ah |
599 | 597 | ||
600 | stdcall kernel_alloc, [_WinMapSize] |
598 | stdcall kernel_alloc, [_WinMapSize] |
601 | mov [_WinMapAddress], eax |
599 | mov [_WinMapAddress], eax |
602 | 600 | ||
603 | xor eax, eax |
601 | xor eax, eax |
604 | inc eax |
602 | inc eax |
605 | 603 | ||
606 | ; set background |
604 | ; set background |
607 | 605 | ||
608 | mov [BgrDrawMode], eax |
606 | mov [BgrDrawMode], eax |
609 | mov [BgrDataWidth], eax |
607 | mov [BgrDataWidth], eax |
610 | mov [BgrDataHeight], eax |
608 | mov [BgrDataHeight], eax |
611 | mov [mem_BACKGROUND], 4 |
609 | mov [mem_BACKGROUND], 4 |
612 | mov [img_background], static_background_data |
610 | mov [img_background], static_background_data |
613 | 611 | ||
614 | ; SET UP OS TASK |
612 | ; SET UP OS TASK |
615 | 613 | ||
616 | mov esi, boot_setostask |
614 | mov esi, boot_setostask |
617 | call boot_log |
615 | call boot_log |
618 | 616 | ||
619 | mov edx, SLOT_BASE+256 |
617 | mov edx, SLOT_BASE+256 |
620 | mov ebx, [os_stack_seg] |
618 | mov ebx, [os_stack_seg] |
621 | add ebx, 0x2000 |
619 | add ebx, 0x2000 |
622 | call setup_os_slot |
620 | call setup_os_slot |
623 | mov dword [edx], 'IDLE' |
621 | mov dword [edx], 'IDLE' |
624 | sub [edx+APPDATA.saved_esp], 4 |
622 | sub [edx+APPDATA.saved_esp], 4 |
625 | mov eax, [edx+APPDATA.saved_esp] |
623 | mov eax, [edx+APPDATA.saved_esp] |
626 | mov dword [eax], idle_thread |
624 | mov dword [eax], idle_thread |
627 | mov ecx, IDLE_PRIORITY |
625 | mov ecx, IDLE_PRIORITY |
628 | call scheduler_add_thread |
626 | call scheduler_add_thread |
629 | 627 | ||
630 | mov edx, SLOT_BASE+256*2 |
628 | mov edx, SLOT_BASE+256*2 |
631 | mov ebx, [os_stack_seg] |
629 | mov ebx, [os_stack_seg] |
632 | call setup_os_slot |
630 | call setup_os_slot |
633 | mov dword [edx], 'OS' |
631 | mov dword [edx], 'OS' |
634 | xor ecx, ecx |
632 | xor ecx, ecx |
635 | call scheduler_add_thread |
633 | call scheduler_add_thread |
636 | 634 | ||
637 | mov dword [CURRENT_TASK], 2 |
635 | mov dword [CURRENT_TASK], 2 |
638 | mov dword [TASK_COUNT], 2 |
636 | mov dword [TASK_COUNT], 2 |
639 | mov dword [current_slot], SLOT_BASE + 256*2 |
637 | mov dword [current_slot], SLOT_BASE + 256*2 |
640 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
638 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
641 | 639 | ||
642 | stdcall kernel_alloc, 0x10000/8 |
640 | stdcall kernel_alloc, 0x10000/8 |
643 | mov edi, eax |
641 | mov edi, eax |
644 | mov [network_free_ports], eax |
642 | mov [network_free_ports], eax |
645 | or eax, -1 |
643 | or eax, -1 |
646 | mov ecx, 0x10000/32 |
644 | mov ecx, 0x10000/32 |
647 | rep stosd |
645 | rep stosd |
648 | 646 | ||
649 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
647 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
650 | mov esi, boot_initirq |
648 | mov esi, boot_initirq |
651 | call boot_log |
649 | call boot_log |
652 | call init_irqs |
650 | call init_irqs |
653 | 651 | ||
654 | mov esi, boot_picinit |
652 | mov esi, boot_picinit |
655 | call boot_log |
653 | call boot_log |
656 | call PIC_init |
654 | call PIC_init |
657 | 655 | ||
658 | mov esi, boot_v86machine |
656 | mov esi, boot_v86machine |
659 | call boot_log |
657 | call boot_log |
660 | ; Initialize system V86 machine |
658 | ; Initialize system V86 machine |
661 | call init_sys_v86 |
659 | call init_sys_v86 |
662 | 660 | ||
663 | mov esi, boot_inittimer |
661 | mov esi, boot_inittimer |
664 | call boot_log |
662 | call boot_log |
665 | ; Initialize system timer (IRQ0) |
663 | ; Initialize system timer (IRQ0) |
666 | call PIT_init |
664 | call PIT_init |
667 | 665 | ||
668 | mov esi, boot_initapic |
666 | mov esi, boot_initapic |
669 | call boot_log |
667 | call boot_log |
670 | ; Try to Initialize APIC |
668 | ; Try to Initialize APIC |
671 | call APIC_init |
669 | call APIC_init |
672 | 670 | ||
673 | mov esi, boot_enableirq |
671 | mov esi, boot_enableirq |
674 | call boot_log |
672 | call boot_log |
675 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
673 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
676 | ; they are used: when partitions are scanned, hd_read relies on timer |
674 | ; they are used: when partitions are scanned, hd_read relies on timer |
677 | call unmask_timer |
675 | call unmask_timer |
678 | stdcall enable_irq, 2 ; @#$%! PIC |
676 | stdcall enable_irq, 2 ; @#$%! PIC |
679 | stdcall enable_irq, 6 ; FDD |
677 | stdcall enable_irq, 6 ; FDD |
680 | stdcall enable_irq, 13 ; co-processor |
678 | stdcall enable_irq, 13 ; co-processor |
681 | stdcall enable_irq, 14 |
679 | stdcall enable_irq, 14 |
682 | stdcall enable_irq, 15 |
680 | stdcall enable_irq, 15 |
683 | 681 | ||
684 | mov esi, boot_enablint_ide |
682 | mov esi, boot_enablint_ide |
685 | call boot_log |
683 | call boot_log |
686 | ; Enable interrupts in IDE controller |
684 | ; Enable interrupts in IDE controller |
687 | mov al, 0 |
685 | mov al, 0 |
688 | mov dx, 0x3F6 |
686 | mov dx, 0x3F6 |
689 | out dx, al |
687 | out dx, al |
690 | mov dl, 0x76 |
688 | mov dl, 0x76 |
691 | out dx, al |
689 | out dx, al |
692 | 690 | ||
693 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
691 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
694 | ; mov esi, boot_detectdisks |
692 | ; mov esi, boot_detectdisks |
695 | ; call boot_log |
693 | ; call boot_log |
696 | ;include 'detect/disks.inc' |
694 | ;include 'detect/disks.inc' |
697 | mov esi, boot_detectfloppy |
695 | mov esi, boot_detectfloppy |
698 | call boot_log |
696 | call boot_log |
699 | include 'detect/dev_fd.inc' |
697 | include 'detect/dev_fd.inc' |
700 | mov esi, boot_detecthdcd |
698 | mov esi, boot_detecthdcd |
701 | call boot_log |
699 | call boot_log |
702 | include 'detect/dev_hdcd.inc' |
700 | include 'detect/dev_hdcd.inc' |
703 | mov esi, boot_getcache |
701 | mov esi, boot_getcache |
704 | call boot_log |
702 | call boot_log |
705 | include 'detect/getcache.inc' |
703 | include 'detect/getcache.inc' |
706 | mov esi, boot_detectpart |
704 | mov esi, boot_detectpart |
707 | call boot_log |
705 | call boot_log |
708 | include 'detect/sear_par.inc' |
706 | include 'detect/sear_par.inc' |
709 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
707 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
710 | 708 | ||
711 | mov esi, boot_init_sys |
709 | mov esi, boot_init_sys |
712 | call boot_log |
710 | call boot_log |
713 | call Parser_params |
711 | call Parser_params |
714 | 712 | ||
715 | if ~ defined extended_primary_loader |
713 | if ~ defined extended_primary_loader |
716 | ; ramdisk image should be loaded by extended primary loader if it exists |
714 | ; ramdisk image should be loaded by extended primary loader if it exists |
717 | ; READ RAMDISK IMAGE FROM HD |
715 | ; READ RAMDISK IMAGE FROM HD |
718 | 716 | ||
719 | ;!!!!!!!!!!!!!!!!!!!!!!! |
717 | ;!!!!!!!!!!!!!!!!!!!!!!! |
720 | include 'boot/rdload.inc' |
718 | include 'boot/rdload.inc' |
721 | ;!!!!!!!!!!!!!!!!!!!!!!! |
719 | ;!!!!!!!!!!!!!!!!!!!!!!! |
722 | end if |
720 | end if |
723 | ; mov [dma_hdd],1 |
721 | ; mov [dma_hdd],1 |
724 | ; CALCULATE FAT CHAIN FOR RAMDISK |
722 | ; CALCULATE FAT CHAIN FOR RAMDISK |
725 | 723 | ||
726 | call calculatefatchain |
724 | call calculatefatchain |
727 | 725 | ||
728 | if 0 |
726 | if 0 |
729 | mov ax, [OS_BASE+0x10000+bx_from_load] |
727 | mov ax, [OS_BASE+0x10000+bx_from_load] |
730 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
728 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
731 | je no_lib_load |
729 | je no_lib_load |
732 | 730 | ||
733 | mov esi, boot_loadlibs |
731 | mov esi, boot_loadlibs |
734 | call boot_log |
732 | call boot_log |
735 | ; LOADING LIBRARES |
733 | ; LOADING LIBRARES |
736 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
734 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
737 | call load_file_parse_table ; prepare file parse table |
735 | call load_file_parse_table ; prepare file parse table |
738 | call set_kernel_conf ; configure devices and gui |
736 | call set_kernel_conf ; configure devices and gui |
739 | no_lib_load: |
737 | no_lib_load: |
740 | end if |
738 | end if |
741 | 739 | ||
742 | ; Display APIC status |
740 | ; Display APIC status |
743 | mov esi, boot_APIC_found |
741 | mov esi, boot_APIC_found |
744 | cmp [irq_mode], IRQ_APIC |
742 | cmp [irq_mode], IRQ_APIC |
745 | je @f |
743 | je @f |
746 | mov esi, boot_APIC_nfound |
744 | mov esi, boot_APIC_nfound |
747 | @@: |
745 | @@: |
748 | call boot_log |
746 | call boot_log |
749 | 747 | ||
750 | ; PRINT AMOUNT OF MEMORY |
748 | ; PRINT AMOUNT OF MEMORY |
751 | mov esi, boot_memdetect |
749 | mov esi, boot_memdetect |
752 | call boot_log |
750 | call boot_log |
753 | 751 | ||
754 | movzx ecx, word [boot_y] |
752 | movzx ecx, word [boot_y] |
755 | if lang eq ru |
753 | if lang eq ru |
756 | or ecx, (10+30*6) shl 16 |
754 | or ecx, (10+30*6) shl 16 |
757 | else if lang eq sp |
755 | else if lang eq sp |
758 | or ecx, (10+33*6) shl 16 |
756 | or ecx, (10+33*6) shl 16 |
759 | else |
757 | else |
760 | or ecx, (10+29*6) shl 16 |
758 | or ecx, (10+29*6) shl 16 |
761 | end if |
759 | end if |
762 | sub ecx, 10 |
760 | sub ecx, 10 |
763 | mov edx, 0xFFFFFF |
761 | mov edx, 0xFFFFFF |
764 | mov ebx, [MEM_AMOUNT] |
762 | mov ebx, [MEM_AMOUNT] |
765 | shr ebx, 20 |
763 | shr ebx, 20 |
766 | xor edi, edi |
764 | xor edi, edi |
767 | mov eax, 0x00040000 |
765 | mov eax, 0x00040000 |
768 | inc edi |
766 | inc edi |
769 | call display_number_force |
767 | call display_number_force |
770 | 768 | ||
771 | ; BUILD SCHEDULER |
769 | ; BUILD SCHEDULER |
772 | 770 | ||
773 | ; call build_scheduler; sys32.inc |
771 | ; call build_scheduler; sys32.inc |
774 | 772 | ||
775 | ; mov esi, boot_devices |
773 | ; mov esi, boot_devices |
776 | ; call boot_log |
774 | ; call boot_log |
777 | 775 | ||
778 | mov [pci_access_enabled], 1 |
776 | mov [pci_access_enabled], 1 |
779 | call pci_enum |
777 | call pci_enum |
780 | 778 | ||
781 | stdcall load_driver, szVidintel |
779 | stdcall load_driver, szVidintel |
782 | 780 | ||
783 | call usb_init |
781 | call usb_init |
784 | 782 | ||
785 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
783 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
786 | 784 | ||
787 | mov esi, boot_windefs |
785 | mov esi, boot_windefs |
788 | call boot_log |
786 | call boot_log |
789 | call set_window_defaults |
787 | call set_window_defaults |
790 | 788 | ||
791 | ; SET BACKGROUND DEFAULTS |
789 | ; SET BACKGROUND DEFAULTS |
792 | 790 | ||
793 | mov esi, boot_bgr |
791 | mov esi, boot_bgr |
794 | call boot_log |
792 | call boot_log |
795 | call init_background |
793 | call init_background |
796 | call calculatebackground |
794 | call calculatebackground |
797 | 795 | ||
798 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
796 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
799 | 797 | ||
800 | mov esi, boot_resirqports |
798 | mov esi, boot_resirqports |
801 | call boot_log |
799 | call boot_log |
802 | call reserve_irqs_ports |
800 | call reserve_irqs_ports |
803 | 801 | ||
804 | call init_display |
802 | call init_display |
805 | mov eax, [def_cursor] |
803 | mov eax, [def_cursor] |
806 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
804 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
807 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
805 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
808 | 806 | ||
809 | ; PRINT CPU FREQUENCY |
807 | ; PRINT CPU FREQUENCY |
810 | 808 | ||
811 | mov esi, boot_cpufreq |
809 | mov esi, boot_cpufreq |
812 | call boot_log |
810 | call boot_log |
813 | 811 | ||
814 | cli ;FIXME check IF |
812 | cli ;FIXME check IF |
815 | rdtsc |
813 | rdtsc |
816 | mov ecx, eax |
814 | mov ecx, eax |
817 | mov esi, 250 ; wait 1/4 a second |
815 | mov esi, 250 ; wait 1/4 a second |
818 | call delay_ms |
816 | call delay_ms |
819 | rdtsc |
817 | rdtsc |
820 | 818 | ||
821 | sub eax, ecx |
819 | sub eax, ecx |
822 | xor edx, edx |
820 | xor edx, edx |
823 | shld edx, eax, 2 |
821 | shld edx, eax, 2 |
824 | shl eax, 2 |
822 | shl eax, 2 |
825 | mov dword [cpu_freq], eax |
823 | mov dword [cpu_freq], eax |
826 | mov dword [cpu_freq+4], edx |
824 | mov dword [cpu_freq+4], edx |
827 | mov ebx, 1000000 |
825 | mov ebx, 1000000 |
828 | div ebx |
826 | div ebx |
829 | mov ebx, eax |
827 | mov ebx, eax |
830 | 828 | ||
831 | movzx ecx, word [boot_y] |
829 | movzx ecx, word [boot_y] |
832 | if lang eq ru |
830 | if lang eq ru |
833 | add ecx, (10+19*6) shl 16 - 10 |
831 | add ecx, (10+19*6) shl 16 - 10 |
834 | else if lang eq sp |
832 | else if lang eq sp |
835 | add ecx, (10+25*6) shl 16 - 10 |
833 | add ecx, (10+25*6) shl 16 - 10 |
836 | else |
834 | else |
837 | add ecx, (10+17*6) shl 16 - 10 |
835 | add ecx, (10+17*6) shl 16 - 10 |
838 | end if |
836 | end if |
839 | 837 | ||
840 | mov edx, 0xFFFFFF |
838 | mov edx, 0xFFFFFF |
841 | xor edi, edi |
839 | xor edi, edi |
842 | mov eax, 0x00040000 |
840 | mov eax, 0x00040000 |
843 | inc edi |
841 | inc edi |
844 | call display_number_force |
842 | call display_number_force |
845 | 843 | ||
846 | ; SET VARIABLES |
844 | ; SET VARIABLES |
847 | 845 | ||
848 | call set_variables |
846 | call set_variables |
849 | 847 | ||
850 | ; STACK AND FDC |
848 | ; STACK AND FDC |
851 | 849 | ||
852 | call stack_init |
850 | call stack_init |
853 | call fdc_init |
851 | call fdc_init |
854 | 852 | ||
855 | ; PALETTE FOR 320x200 and 640x480 16 col |
853 | ; PALETTE FOR 320x200 and 640x480 16 col |
856 | 854 | ||
857 | cmp [SCR_MODE], word 0x12 |
855 | cmp [SCR_MODE], word 0x12 |
858 | jne no_pal_vga |
856 | jne no_pal_vga |
859 | mov esi, boot_pal_vga |
857 | mov esi, boot_pal_vga |
860 | call boot_log |
858 | call boot_log |
861 | call paletteVGA |
859 | call paletteVGA |
862 | no_pal_vga: |
860 | no_pal_vga: |
863 | 861 | ||
864 | cmp [SCR_MODE], word 0x13 |
862 | cmp [SCR_MODE], word 0x13 |
865 | jne no_pal_ega |
863 | jne no_pal_ega |
866 | mov esi, boot_pal_ega |
864 | mov esi, boot_pal_ega |
867 | call boot_log |
865 | call boot_log |
868 | call palette320x200 |
866 | call palette320x200 |
869 | no_pal_ega: |
867 | no_pal_ega: |
870 | 868 | ||
871 | ; LOAD DEFAULT SKIN |
869 | ; LOAD DEFAULT SKIN |
872 | 870 | ||
873 | call load_default_skin |
871 | call load_default_skin |
874 | 872 | ||
875 | ;protect io permission map |
873 | ;protect io permission map |
876 | 874 | ||
877 | mov esi, [default_io_map] |
875 | mov esi, [default_io_map] |
878 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
876 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
879 | add esi, 0x1000 |
877 | add esi, 0x1000 |
880 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
878 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
881 | 879 | ||
882 | stdcall map_page, tss._io_map_0, \ |
880 | stdcall map_page, tss._io_map_0, \ |
883 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
881 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
884 | stdcall map_page, tss._io_map_1, \ |
882 | stdcall map_page, tss._io_map_1, \ |
885 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
883 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
886 | 884 | ||
887 | mov ax, [OS_BASE+0x10000+bx_from_load] |
885 | mov ax, [OS_BASE+0x10000+bx_from_load] |
888 | cmp ax, 'r1'; if not rused ram disk - load network configuration from files {SPraid.simba} |
886 | cmp ax, 'r1'; if not rused ram disk - load network configuration from files {SPraid.simba} |
889 | je no_st_network |
887 | je no_st_network |
890 | call set_network_conf |
888 | call set_network_conf |
891 | no_st_network: |
889 | no_st_network: |
892 | 890 | ||
893 | ; LOAD FIRST APPLICATION |
891 | ; LOAD FIRST APPLICATION |
894 | cli |
892 | cli |
895 | 893 | ||
896 | ; cmp byte [BOOT_VAR+0x9030],1 |
894 | ; cmp byte [BOOT_VAR+0x9030],1 |
897 | ; jne no_load_vrr_m |
895 | ; jne no_load_vrr_m |
898 | 896 | ||
899 | ; mov ebp, vrr_m |
897 | ; mov ebp, vrr_m |
900 | ; call fs_execute_from_sysdir |
898 | ; call fs_execute_from_sysdir |
901 | ; |
899 | ; |
902 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
900 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
903 | ; sub eax,2 |
901 | ; sub eax,2 |
904 | ; jz first_app_found |
902 | ; jz first_app_found |
905 | ; |
903 | ; |
906 | ;no_load_vrr_m: |
904 | ;no_load_vrr_m: |
907 | 905 | ||
908 | mov ebp, firstapp |
906 | mov ebp, firstapp |
909 | call fs_execute_from_sysdir |
907 | call fs_execute_from_sysdir |
910 | 908 | ||
911 | ; cmp eax,2 ; continue if a process has been loaded |
909 | ; cmp eax,2 ; continue if a process has been loaded |
912 | test eax, eax |
910 | test eax, eax |
913 | jns first_app_found |
911 | jns first_app_found |
914 | 912 | ||
915 | mov esi, boot_failed |
913 | mov esi, boot_failed |
916 | call boot_log |
914 | call boot_log |
917 | 915 | ||
918 | mov eax, 0xDEADBEEF ; otherwise halt |
916 | mov eax, 0xDEADBEEF ; otherwise halt |
919 | hlt |
917 | hlt |
920 | 918 | ||
921 | first_app_found: |
919 | first_app_found: |
922 | 920 | ||
923 | cli |
921 | cli |
924 | 922 | ||
925 | ; SET KEYBOARD PARAMETERS |
923 | ; SET KEYBOARD PARAMETERS |
926 | mov al, 0xf6 ; reset keyboard, scan enabled |
924 | mov al, 0xf6 ; reset keyboard, scan enabled |
927 | call kb_write |
925 | call kb_write |
928 | test ah, ah |
926 | test ah, ah |
929 | jnz .no_keyboard |
927 | jnz .no_keyboard |
930 | 928 | ||
931 | ; wait until 8042 is ready |
929 | ; wait until 8042 is ready |
932 | xor ecx, ecx |
930 | xor ecx, ecx |
933 | @@: |
931 | @@: |
934 | in al, 64h |
932 | in al, 64h |
935 | and al, 00000010b |
933 | and al, 00000010b |
936 | loopnz @b |
934 | loopnz @b |
937 | 935 | ||
938 | iglobal |
936 | iglobal |
939 | align 4 |
937 | align 4 |
940 | ps2_keyboard_functions: |
938 | ps2_keyboard_functions: |
941 | dd .end - $ |
939 | dd .end - $ |
942 | dd 0 ; no close |
940 | dd 0 ; no close |
943 | dd ps2_set_lights |
941 | dd ps2_set_lights |
944 | .end: |
942 | .end: |
945 | endg |
943 | endg |
946 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
944 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
947 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
945 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
948 | ; call kb_write |
946 | ; call kb_write |
949 | ; call kb_read |
947 | ; call kb_read |
950 | ; mov al, 111b |
948 | ; mov al, 111b |
951 | ; call kb_write |
949 | ; call kb_write |
952 | ; call kb_read |
950 | ; call kb_read |
953 | 951 | ||
954 | mov al, 0xF3 ; set repeat rate & delay |
952 | mov al, 0xF3 ; set repeat rate & delay |
955 | call kb_write |
953 | call kb_write |
956 | ; call kb_read |
954 | ; call kb_read |
957 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
955 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
958 | call kb_write |
956 | call kb_write |
959 | ; call kb_read |
957 | ; call kb_read |
960 | ;// mike.dld [ |
958 | ;// mike.dld [ |
961 | call set_lights |
959 | call set_lights |
962 | ;// mike.dld ] |
960 | ;// mike.dld ] |
963 | stdcall attach_int_handler, 1, irq1, 0 |
961 | stdcall attach_int_handler, 1, irq1, 0 |
964 | .no_keyboard: |
962 | .no_keyboard: |
965 | 963 | ||
966 | ; SET MOUSE |
964 | ; SET MOUSE |
967 | 965 | ||
968 | stdcall load_driver, szPS2MDriver |
966 | stdcall load_driver, szPS2MDriver |
969 | ; stdcall load_driver, szCOM_MDriver |
967 | ; stdcall load_driver, szCOM_MDriver |
970 | 968 | ||
971 | mov esi, boot_setmouse |
969 | mov esi, boot_setmouse |
972 | call boot_log |
970 | call boot_log |
973 | call setmouse |
971 | call setmouse |
974 | 972 | ||
975 | ; Setup serial output console (if enabled) |
973 | ; Setup serial output console (if enabled) |
976 | 974 | ||
977 | if defined debug_com_base |
975 | if defined debug_com_base |
978 | 976 | ||
979 | ; enable Divisor latch |
977 | ; enable Divisor latch |
980 | 978 | ||
981 | mov dx, debug_com_base+3 |
979 | mov dx, debug_com_base+3 |
982 | mov al, 1 shl 7 |
980 | mov al, 1 shl 7 |
983 | out dx, al |
981 | out dx, al |
984 | 982 | ||
985 | ; Set speed to 115200 baud (max speed) |
983 | ; Set speed to 115200 baud (max speed) |
986 | 984 | ||
987 | mov dx, debug_com_base |
985 | mov dx, debug_com_base |
988 | mov al, 0x01 |
986 | mov al, 0x01 |
989 | out dx, al |
987 | out dx, al |
990 | 988 | ||
991 | mov dx, debug_com_base+1 |
989 | mov dx, debug_com_base+1 |
992 | mov al, 0x00 |
990 | mov al, 0x00 |
993 | out dx, al |
991 | out dx, al |
994 | 992 | ||
995 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
993 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
996 | 994 | ||
997 | mov dx, debug_com_base+3 |
995 | mov dx, debug_com_base+3 |
998 | mov al, 3 |
996 | mov al, 3 |
999 | out dx, al |
997 | out dx, al |
1000 | 998 | ||
1001 | ; disable interrupts |
999 | ; disable interrupts |
1002 | 1000 | ||
1003 | mov dx, debug_com_base+1 |
1001 | mov dx, debug_com_base+1 |
1004 | mov al, 0 |
1002 | mov al, 0 |
1005 | out dx, al |
1003 | out dx, al |
1006 | 1004 | ||
1007 | ; clear + enable fifo (64 bits) |
1005 | ; clear + enable fifo (64 bits) |
1008 | 1006 | ||
1009 | mov dx, debug_com_base+2 |
1007 | mov dx, debug_com_base+2 |
1010 | mov al, 0x7 + 1 shl 5 |
1008 | mov al, 0x7 + 1 shl 5 |
1011 | out dx, al |
1009 | out dx, al |
1012 | 1010 | ||
1013 | 1011 | ||
1014 | end if |
1012 | end if |
1015 | mov eax, [version_inf.rev] |
1013 | mov eax, [version_inf.rev] |
1016 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1014 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1017 | 1015 | ||
1018 | mov eax, [cpu_count] |
1016 | mov eax, [cpu_count] |
1019 | test eax, eax |
1017 | test eax, eax |
1020 | jnz @F |
1018 | jnz @F |
1021 | mov al, 1 ; at least one CPU |
1019 | mov al, 1 ; at least one CPU |
1022 | @@: |
1020 | @@: |
1023 | DEBUGF 1, "K : %d CPU detected\n", eax |
1021 | DEBUGF 1, "K : %d CPU detected\n", eax |
1024 | 1022 | ||
1025 | ; START MULTITASKING |
1023 | ; START MULTITASKING |
1026 | 1024 | ||
1027 | ; A 'All set - press ESC to start' messages if need |
1025 | ; A 'All set - press ESC to start' messages if need |
1028 | if preboot_blogesc |
1026 | if preboot_blogesc |
1029 | mov esi, boot_tasking |
1027 | mov esi, boot_tasking |
1030 | call boot_log |
1028 | call boot_log |
1031 | .bll1: |
1029 | .bll1: |
1032 | in al, 0x60 ; wait for ESC key press |
1030 | in al, 0x60 ; wait for ESC key press |
1033 | cmp al, 129 |
1031 | cmp al, 129 |
1034 | jne .bll1 |
1032 | jne .bll1 |
1035 | end if |
1033 | end if |
1036 | 1034 | ||
1037 | cmp [IDEContrRegsBaseAddr], 0 |
1035 | cmp [IDEContrRegsBaseAddr], 0 |
1038 | setnz [dma_hdd] |
1036 | setnz [dma_hdd] |
1039 | mov [timer_ticks_enable], 1 ; for cd driver |
1037 | mov [timer_ticks_enable], 1 ; for cd driver |
1040 | 1038 | ||
1041 | sti |
1039 | sti |
1042 | ; call change_task |
1040 | ; call change_task |
1043 | 1041 | ||
1044 | jmp osloop |
1042 | jmp osloop |
1045 | 1043 | ||
1046 | 1044 | ||
1047 | ; Fly :) |
1045 | ; Fly :) |
1048 | 1046 | ||
1049 | include 'unpacker.inc' |
1047 | include 'unpacker.inc' |
1050 | 1048 | ||
1051 | align 4 |
1049 | align 4 |
1052 | boot_log: |
1050 | boot_log: |
1053 | pushad |
1051 | pushad |
1054 | 1052 | ||
1055 | mov ebx, 10*65536 |
1053 | mov ebx, 10*65536 |
1056 | mov bx, word [boot_y] |
1054 | mov bx, word [boot_y] |
1057 | add [boot_y], dword 10 |
1055 | add [boot_y], dword 10 |
1058 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1056 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1059 | xor edi, edi |
1057 | xor edi, edi |
1060 | mov edx, esi |
1058 | mov edx, esi |
1061 | inc edi |
1059 | inc edi |
1062 | call dtext |
1060 | call dtext |
1063 | 1061 | ||
1064 | mov [novesachecksum], 1000 |
1062 | mov [novesachecksum], 1000 |
1065 | call checkVga_N13 |
1063 | call checkVga_N13 |
1066 | 1064 | ||
1067 | popad |
1065 | popad |
1068 | 1066 | ||
1069 | ret |
1067 | ret |
1070 | 1068 | ||
1071 | ; in: edx -> APPDATA for OS/IDLE slot |
1069 | ; in: edx -> APPDATA for OS/IDLE slot |
1072 | ; in: ebx = stack base |
1070 | ; in: ebx = stack base |
1073 | proc setup_os_slot |
1071 | proc setup_os_slot |
1074 | xor eax, eax |
1072 | xor eax, eax |
1075 | mov ecx, 256/4 |
1073 | mov ecx, 256/4 |
1076 | mov edi, edx |
1074 | mov edi, edx |
1077 | rep stosd |
1075 | rep stosd |
1078 | 1076 | ||
1079 | mov eax, tss+0x80 |
1077 | mov eax, tss+0x80 |
1080 | call get_pg_addr |
1078 | call get_pg_addr |
1081 | inc eax |
1079 | inc eax |
1082 | mov [edx+APPDATA.io_map], eax |
1080 | mov [edx+APPDATA.io_map], eax |
1083 | mov eax, tss+0x1080 |
1081 | mov eax, tss+0x1080 |
1084 | call get_pg_addr |
1082 | call get_pg_addr |
1085 | inc eax |
1083 | inc eax |
1086 | mov [edx+APPDATA.io_map+4], eax |
1084 | mov [edx+APPDATA.io_map+4], eax |
1087 | 1085 | ||
1088 | mov dword [edx+APPDATA.pl0_stack], ebx |
1086 | mov dword [edx+APPDATA.pl0_stack], ebx |
1089 | lea edi, [ebx+0x2000-512] |
1087 | lea edi, [ebx+0x2000-512] |
1090 | mov dword [edx+APPDATA.fpu_state], edi |
1088 | mov dword [edx+APPDATA.fpu_state], edi |
1091 | mov dword [edx+APPDATA.saved_esp0], edi |
1089 | mov dword [edx+APPDATA.saved_esp0], edi |
1092 | mov dword [edx+APPDATA.saved_esp], edi |
1090 | mov dword [edx+APPDATA.saved_esp], edi |
1093 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1091 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1094 | 1092 | ||
1095 | mov esi, fpu_data |
1093 | mov esi, fpu_data |
1096 | mov ecx, 512/4 |
1094 | mov ecx, 512/4 |
1097 | cld |
1095 | cld |
1098 | rep movsd |
1096 | rep movsd |
1099 | 1097 | ||
1100 | lea eax, [edx+APP_OBJ_OFFSET] |
1098 | lea eax, [edx+APP_OBJ_OFFSET] |
1101 | mov dword [edx+APPDATA.fd_obj], eax |
1099 | mov dword [edx+APPDATA.fd_obj], eax |
1102 | mov dword [edx+APPDATA.bk_obj], eax |
1100 | mov dword [edx+APPDATA.bk_obj], eax |
1103 | 1101 | ||
1104 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1102 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1105 | 1103 | ||
1106 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1104 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1107 | 1105 | ||
1108 | mov eax, edx |
1106 | mov eax, edx |
1109 | shr eax, 3 |
1107 | shr eax, 3 |
1110 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1108 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1111 | mov [eax+TASKDATA.wnd_number], dh |
1109 | mov [eax+TASKDATA.wnd_number], dh |
1112 | mov byte [eax+TASKDATA.pid], dh |
1110 | mov byte [eax+TASKDATA.pid], dh |
1113 | 1111 | ||
1114 | ret |
1112 | ret |
1115 | endp |
1113 | endp |
1116 | 1114 | ||
1117 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1115 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1118 | ; ; |
1116 | ; ; |
1119 | ; MAIN OS LOOP START ; |
1117 | ; MAIN OS LOOP START ; |
1120 | ; ; |
1118 | ; ; |
1121 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1119 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1122 | align 32 |
1120 | align 32 |
1123 | osloop: |
1121 | osloop: |
1124 | mov edx, osloop_has_work? |
1122 | mov edx, osloop_has_work? |
1125 | xor ecx, ecx |
1123 | xor ecx, ecx |
1126 | call Wait_events |
1124 | call Wait_events |
1127 | xor eax, eax |
1125 | xor eax, eax |
1128 | xchg eax, [osloop_nonperiodic_work] |
1126 | xchg eax, [osloop_nonperiodic_work] |
1129 | test eax, eax |
1127 | test eax, eax |
1130 | jz .no_periodic |
1128 | jz .no_periodic |
1131 | ; call [draw_pointer] |
1129 | ; call [draw_pointer] |
1132 | call __sys_draw_pointer |
1130 | call __sys_draw_pointer |
1133 | call window_check_events |
1131 | call window_check_events |
1134 | call mouse_check_events |
1132 | call mouse_check_events |
1135 | call checkmisc |
1133 | call checkmisc |
1136 | call checkVga_N13 |
1134 | call checkVga_N13 |
1137 | .no_periodic: |
1135 | .no_periodic: |
1138 | call stack_handler |
1136 | call stack_handler |
1139 | call check_fdd_motor_status |
1137 | call check_fdd_motor_status |
1140 | call check_ATAPI_device_event |
1138 | call check_ATAPI_device_event |
1141 | call check_lights_state |
1139 | call check_lights_state |
1142 | call check_timers |
1140 | call check_timers |
1143 | jmp osloop |
1141 | jmp osloop |
1144 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1142 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1145 | ; ; |
1143 | ; ; |
1146 | ; MAIN OS LOOP END ; |
1144 | ; MAIN OS LOOP END ; |
1147 | ; ; |
1145 | ; ; |
1148 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1146 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1149 | proc osloop_has_work? |
1147 | proc osloop_has_work? |
1150 | cmp [osloop_nonperiodic_work], 0 |
1148 | cmp [osloop_nonperiodic_work], 0 |
1151 | jnz .yes |
1149 | jnz .yes |
1152 | call stack_handler_has_work? |
1150 | call stack_handler_has_work? |
1153 | jnz .yes |
1151 | jnz .yes |
1154 | call check_fdd_motor_status_has_work? |
1152 | call check_fdd_motor_status_has_work? |
1155 | jnz .yes |
1153 | jnz .yes |
1156 | call check_ATAPI_device_event_has_work? |
1154 | call check_ATAPI_device_event_has_work? |
1157 | jnz .yes |
1155 | jnz .yes |
1158 | call check_lights_state_has_work? |
1156 | call check_lights_state_has_work? |
1159 | jnz .yes |
1157 | jnz .yes |
1160 | call check_timers_has_work? |
1158 | call check_timers_has_work? |
1161 | jnz .yes |
1159 | jnz .yes |
1162 | .no: |
1160 | .no: |
1163 | xor eax, eax |
1161 | xor eax, eax |
1164 | ret |
1162 | ret |
1165 | .yes: |
1163 | .yes: |
1166 | xor eax, eax |
1164 | xor eax, eax |
1167 | inc eax |
1165 | inc eax |
1168 | ret |
1166 | ret |
1169 | endp |
1167 | endp |
1170 | 1168 | ||
1171 | proc wakeup_osloop |
1169 | proc wakeup_osloop |
1172 | mov [osloop_nonperiodic_work], 1 |
1170 | mov [osloop_nonperiodic_work], 1 |
1173 | ret |
1171 | ret |
1174 | endp |
1172 | endp |
1175 | 1173 | ||
1176 | uglobal |
1174 | uglobal |
1177 | align 4 |
1175 | align 4 |
1178 | osloop_nonperiodic_work dd ? |
1176 | osloop_nonperiodic_work dd ? |
1179 | endg |
1177 | endg |
1180 | 1178 | ||
1181 | align 4 |
1179 | align 4 |
1182 | idle_thread: |
1180 | idle_thread: |
1183 | sti |
1181 | sti |
1184 | idle_loop: |
1182 | idle_loop: |
1185 | hlt |
1183 | hlt |
1186 | jmp idle_loop |
1184 | jmp idle_loop |
1187 | 1185 | ||
1188 | 1186 | ||
1189 | 1187 | ||
1190 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1188 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1191 | ; ; |
1189 | ; ; |
1192 | ; INCLUDED SYSTEM FILES ; |
1190 | ; INCLUDED SYSTEM FILES ; |
1193 | ; ; |
1191 | ; ; |
1194 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1192 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1195 | 1193 | ||
1196 | 1194 | ||
1197 | include "kernel32.inc" |
1195 | include "kernel32.inc" |
1198 | 1196 | ||
1199 | 1197 | ||
1200 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1198 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1201 | ; ; |
1199 | ; ; |
1202 | ; KERNEL FUNCTIONS ; |
1200 | ; KERNEL FUNCTIONS ; |
1203 | ; ; |
1201 | ; ; |
1204 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1202 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1205 | 1203 | ||
1206 | reserve_irqs_ports: |
1204 | reserve_irqs_ports: |
1207 | 1205 | ||
1208 | 1206 | ||
1209 | ; RESERVE PORTS |
1207 | ; RESERVE PORTS |
1210 | mov eax, RESERVED_PORTS |
1208 | mov eax, RESERVED_PORTS |
1211 | mov ecx, 1 |
1209 | mov ecx, 1 |
1212 | 1210 | ||
1213 | mov [eax], dword 4 |
1211 | mov [eax], dword 4 |
1214 | 1212 | ||
1215 | mov [eax+16], ecx |
1213 | mov [eax+16], ecx |
1216 | mov [eax+16+4], dword 0 |
1214 | mov [eax+16+4], dword 0 |
1217 | mov [eax+16+8], dword 0x2D |
1215 | mov [eax+16+8], dword 0x2D |
1218 | 1216 | ||
1219 | mov [eax+32], ecx |
1217 | mov [eax+32], ecx |
1220 | mov [eax+32+4], dword 0x30 |
1218 | mov [eax+32+4], dword 0x30 |
1221 | mov [eax+32+8], dword 0x4D |
1219 | mov [eax+32+8], dword 0x4D |
1222 | 1220 | ||
1223 | mov [eax+48], ecx |
1221 | mov [eax+48], ecx |
1224 | mov [eax+48+4], dword 0x50 |
1222 | mov [eax+48+4], dword 0x50 |
1225 | mov [eax+48+8], dword 0xDF |
1223 | mov [eax+48+8], dword 0xDF |
1226 | 1224 | ||
1227 | mov [eax+64], ecx |
1225 | mov [eax+64], ecx |
1228 | mov [eax+64+4], dword 0xE5 |
1226 | mov [eax+64+4], dword 0xE5 |
1229 | mov [eax+64+8], dword 0xFF |
1227 | mov [eax+64+8], dword 0xFF |
1230 | 1228 | ||
1231 | ret |
1229 | ret |
1232 | 1230 | ||
1233 | 1231 | ||
1234 | iglobal |
1232 | iglobal |
1235 | process_number dd 0x2 |
1233 | process_number dd 0x2 |
1236 | endg |
1234 | endg |
1237 | 1235 | ||
1238 | set_variables: |
1236 | set_variables: |
1239 | 1237 | ||
1240 | mov ecx, 0x16 ; flush port 0x60 |
1238 | mov ecx, 0x16 ; flush port 0x60 |
1241 | .fl60: |
1239 | .fl60: |
1242 | in al, 0x60 |
1240 | in al, 0x60 |
1243 | loop .fl60 |
1241 | loop .fl60 |
1244 | push eax |
1242 | push eax |
1245 | 1243 | ||
1246 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1244 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1247 | shr ax, 1 |
1245 | shr ax, 1 |
1248 | shl eax, 16 |
1246 | shl eax, 16 |
1249 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1247 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1250 | shr ax, 1 |
1248 | shr ax, 1 |
1251 | mov [MOUSE_X], eax |
1249 | mov [MOUSE_X], eax |
1252 | call wakeup_osloop |
1250 | call wakeup_osloop |
1253 | 1251 | ||
1254 | xor eax, eax |
1252 | xor eax, eax |
1255 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1253 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1256 | 1254 | ||
1257 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1255 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1258 | mov byte [KEY_COUNT], al ; keyboard buffer |
1256 | mov byte [KEY_COUNT], al ; keyboard buffer |
1259 | mov byte [BTN_COUNT], al ; button buffer |
1257 | mov byte [BTN_COUNT], al ; button buffer |
1260 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1258 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1261 | 1259 | ||
1262 | ;!! IP 04.02.2005: |
1260 | ;!! IP 04.02.2005: |
1263 | ; mov byte [DONT_SWITCH], al; change task if possible |
1261 | ; mov byte [DONT_SWITCH], al; change task if possible |
1264 | pop eax |
1262 | pop eax |
1265 | ret |
1263 | ret |
1266 | 1264 | ||
1267 | align 4 |
1265 | align 4 |
1268 | ;input eax=43,bl-byte of output, ecx - number of port |
1266 | ;input eax=43,bl-byte of output, ecx - number of port |
1269 | sys_outport: |
1267 | sys_outport: |
1270 | 1268 | ||
1271 | mov edi, ecx ; separate flag for read / write |
1269 | mov edi, ecx ; separate flag for read / write |
1272 | and ecx, 65535 |
1270 | and ecx, 65535 |
1273 | 1271 | ||
1274 | mov eax, [RESERVED_PORTS] |
1272 | mov eax, [RESERVED_PORTS] |
1275 | test eax, eax |
1273 | test eax, eax |
1276 | jnz .sopl8 |
1274 | jnz .sopl8 |
1277 | inc eax |
1275 | inc eax |
1278 | mov [esp+32], eax |
1276 | mov [esp+32], eax |
1279 | ret |
1277 | ret |
1280 | 1278 | ||
1281 | .sopl8: |
1279 | .sopl8: |
1282 | mov edx, [TASK_BASE] |
1280 | mov edx, [TASK_BASE] |
1283 | mov edx, [edx+0x4] |
1281 | mov edx, [edx+0x4] |
1284 | ;and ecx,65535 |
1282 | ;and ecx,65535 |
1285 | ;cld - set on interrupt 0x40 |
1283 | ;cld - set on interrupt 0x40 |
1286 | .sopl1: |
1284 | .sopl1: |
1287 | 1285 | ||
1288 | mov esi, eax |
1286 | mov esi, eax |
1289 | shl esi, 4 |
1287 | shl esi, 4 |
1290 | add esi, RESERVED_PORTS |
1288 | add esi, RESERVED_PORTS |
1291 | cmp edx, [esi+0] |
1289 | cmp edx, [esi+0] |
1292 | jne .sopl2 |
1290 | jne .sopl2 |
1293 | cmp ecx, [esi+4] |
1291 | cmp ecx, [esi+4] |
1294 | jb .sopl2 |
1292 | jb .sopl2 |
1295 | cmp ecx, [esi+8] |
1293 | cmp ecx, [esi+8] |
1296 | jg .sopl2 |
1294 | jg .sopl2 |
1297 | .sopl3: |
1295 | .sopl3: |
1298 | 1296 | ||
1299 | test edi, 0x80000000; read ? |
1297 | test edi, 0x80000000; read ? |
1300 | jnz .sopl4 |
1298 | jnz .sopl4 |
1301 | 1299 | ||
1302 | mov eax, ebx |
1300 | mov eax, ebx |
1303 | mov dx, cx ; write |
1301 | mov dx, cx ; write |
1304 | out dx, al |
1302 | out dx, al |
1305 | and [esp+32], dword 0 |
1303 | and [esp+32], dword 0 |
1306 | ret |
1304 | ret |
1307 | 1305 | ||
1308 | .sopl2: |
1306 | .sopl2: |
1309 | 1307 | ||
1310 | dec eax |
1308 | dec eax |
1311 | jnz .sopl1 |
1309 | jnz .sopl1 |
1312 | inc eax |
1310 | inc eax |
1313 | mov [esp+32], eax |
1311 | mov [esp+32], eax |
1314 | ret |
1312 | ret |
1315 | 1313 | ||
1316 | 1314 | ||
1317 | .sopl4: |
1315 | .sopl4: |
1318 | 1316 | ||
1319 | mov dx, cx ; read |
1317 | mov dx, cx ; read |
1320 | in al, dx |
1318 | in al, dx |
1321 | and eax, 0xff |
1319 | and eax, 0xff |
1322 | and [esp+32], dword 0 |
1320 | and [esp+32], dword 0 |
1323 | mov [esp+20], eax |
1321 | mov [esp+20], eax |
1324 | ret |
1322 | ret |
1325 | 1323 | ||
1326 | display_number: |
1324 | display_number: |
1327 | ;It is not optimization |
1325 | ;It is not optimization |
1328 | mov eax, ebx |
1326 | mov eax, ebx |
1329 | mov ebx, ecx |
1327 | mov ebx, ecx |
1330 | mov ecx, edx |
1328 | mov ecx, edx |
1331 | mov edx, esi |
1329 | mov edx, esi |
1332 | mov esi, edi |
1330 | mov esi, edi |
1333 | ; eax = print type, al=0 -> ebx is number |
1331 | ; eax = print type, al=0 -> ebx is number |
1334 | ; al=1 -> ebx is pointer |
1332 | ; al=1 -> ebx is pointer |
1335 | ; ah=0 -> display decimal |
1333 | ; ah=0 -> display decimal |
1336 | ; ah=1 -> display hexadecimal |
1334 | ; ah=1 -> display hexadecimal |
1337 | ; ah=2 -> display binary |
1335 | ; ah=2 -> display binary |
1338 | ; eax bits 16-21 = number of digits to display (0-32) |
1336 | ; eax bits 16-21 = number of digits to display (0-32) |
1339 | ; eax bits 22-31 = reserved |
1337 | ; eax bits 22-31 = reserved |
1340 | ; |
1338 | ; |
1341 | ; ebx = number or pointer |
1339 | ; ebx = number or pointer |
1342 | ; ecx = x shl 16 + y |
1340 | ; ecx = x shl 16 + y |
1343 | ; edx = color |
1341 | ; edx = color |
1344 | xor edi, edi |
1342 | xor edi, edi |
1345 | display_number_force: |
1343 | display_number_force: |
1346 | push eax |
1344 | push eax |
1347 | and eax, 0x3fffffff |
1345 | and eax, 0x3fffffff |
1348 | cmp eax, 0xffff ; length > 0 ? |
1346 | cmp eax, 0xffff ; length > 0 ? |
1349 | pop eax |
1347 | pop eax |
1350 | jge cont_displ |
1348 | jge cont_displ |
1351 | ret |
1349 | ret |
1352 | cont_displ: |
1350 | cont_displ: |
1353 | push eax |
1351 | push eax |
1354 | and eax, 0x3fffffff |
1352 | and eax, 0x3fffffff |
1355 | cmp eax, 61*0x10000 ; length <= 60 ? |
1353 | cmp eax, 61*0x10000 ; length <= 60 ? |
1356 | pop eax |
1354 | pop eax |
1357 | jb cont_displ2 |
1355 | jb cont_displ2 |
1358 | ret |
1356 | ret |
1359 | cont_displ2: |
1357 | cont_displ2: |
1360 | 1358 | ||
1361 | pushad |
1359 | pushad |
1362 | 1360 | ||
1363 | cmp al, 1 ; ecx is a pointer ? |
1361 | cmp al, 1 ; ecx is a pointer ? |
1364 | jne displnl1 |
1362 | jne displnl1 |
1365 | mov ebp, ebx |
1363 | mov ebp, ebx |
1366 | add ebp, 4 |
1364 | add ebp, 4 |
1367 | mov ebp, [ebp+std_application_base_address] |
1365 | mov ebp, [ebp+std_application_base_address] |
1368 | mov ebx, [ebx+std_application_base_address] |
1366 | mov ebx, [ebx+std_application_base_address] |
1369 | displnl1: |
1367 | displnl1: |
1370 | sub esp, 64 |
1368 | sub esp, 64 |
1371 | 1369 | ||
1372 | test ah, ah ; DECIMAL |
1370 | test ah, ah ; DECIMAL |
1373 | jnz no_display_desnum |
1371 | jnz no_display_desnum |
1374 | shr eax, 16 |
1372 | shr eax, 16 |
1375 | and eax, 0xC03f |
1373 | and eax, 0xC03f |
1376 | ; and eax,0x3f |
1374 | ; and eax,0x3f |
1377 | push eax |
1375 | push eax |
1378 | and eax, 0x3f |
1376 | and eax, 0x3f |
1379 | mov edi, esp |
1377 | mov edi, esp |
1380 | add edi, 4+64-1 |
1378 | add edi, 4+64-1 |
1381 | mov ecx, eax |
1379 | mov ecx, eax |
1382 | mov eax, ebx |
1380 | mov eax, ebx |
1383 | mov ebx, 10 |
1381 | mov ebx, 10 |
1384 | d_desnum: |
1382 | d_desnum: |
1385 | xor edx, edx |
1383 | xor edx, edx |
1386 | call division_64_bits |
1384 | call division_64_bits |
1387 | div ebx |
1385 | div ebx |
1388 | add dl, 48 |
1386 | add dl, 48 |
1389 | mov [edi], dl |
1387 | mov [edi], dl |
1390 | dec edi |
1388 | dec edi |
1391 | loop d_desnum |
1389 | loop d_desnum |
1392 | pop eax |
1390 | pop eax |
1393 | call normalize_number |
1391 | call normalize_number |
1394 | call draw_num_text |
1392 | call draw_num_text |
1395 | add esp, 64 |
1393 | add esp, 64 |
1396 | popad |
1394 | popad |
1397 | ret |
1395 | ret |
1398 | no_display_desnum: |
1396 | no_display_desnum: |
1399 | 1397 | ||
1400 | cmp ah, 0x01 ; HEXADECIMAL |
1398 | cmp ah, 0x01 ; HEXADECIMAL |
1401 | jne no_display_hexnum |
1399 | jne no_display_hexnum |
1402 | shr eax, 16 |
1400 | shr eax, 16 |
1403 | and eax, 0xC03f |
1401 | and eax, 0xC03f |
1404 | ; and eax,0x3f |
1402 | ; and eax,0x3f |
1405 | push eax |
1403 | push eax |
1406 | and eax, 0x3f |
1404 | and eax, 0x3f |
1407 | mov edi, esp |
1405 | mov edi, esp |
1408 | add edi, 4+64-1 |
1406 | add edi, 4+64-1 |
1409 | mov ecx, eax |
1407 | mov ecx, eax |
1410 | mov eax, ebx |
1408 | mov eax, ebx |
1411 | mov ebx, 16 |
1409 | mov ebx, 16 |
1412 | d_hexnum: |
1410 | d_hexnum: |
1413 | xor edx, edx |
1411 | xor edx, edx |
1414 | call division_64_bits |
1412 | call division_64_bits |
1415 | div ebx |
1413 | div ebx |
1416 | hexletters = __fdo_hexdigits |
1414 | hexletters = __fdo_hexdigits |
1417 | add edx, hexletters |
1415 | add edx, hexletters |
1418 | mov dl, [edx] |
1416 | mov dl, [edx] |
1419 | mov [edi], dl |
1417 | mov [edi], dl |
1420 | dec edi |
1418 | dec edi |
1421 | loop d_hexnum |
1419 | loop d_hexnum |
1422 | pop eax |
1420 | pop eax |
1423 | call normalize_number |
1421 | call normalize_number |
1424 | call draw_num_text |
1422 | call draw_num_text |
1425 | add esp, 64 |
1423 | add esp, 64 |
1426 | popad |
1424 | popad |
1427 | ret |
1425 | ret |
1428 | no_display_hexnum: |
1426 | no_display_hexnum: |
1429 | 1427 | ||
1430 | cmp ah, 0x02 ; BINARY |
1428 | cmp ah, 0x02 ; BINARY |
1431 | jne no_display_binnum |
1429 | jne no_display_binnum |
1432 | shr eax, 16 |
1430 | shr eax, 16 |
1433 | and eax, 0xC03f |
1431 | and eax, 0xC03f |
1434 | ; and eax,0x3f |
1432 | ; and eax,0x3f |
1435 | push eax |
1433 | push eax |
1436 | and eax, 0x3f |
1434 | and eax, 0x3f |
1437 | mov edi, esp |
1435 | mov edi, esp |
1438 | add edi, 4+64-1 |
1436 | add edi, 4+64-1 |
1439 | mov ecx, eax |
1437 | mov ecx, eax |
1440 | mov eax, ebx |
1438 | mov eax, ebx |
1441 | mov ebx, 2 |
1439 | mov ebx, 2 |
1442 | d_binnum: |
1440 | d_binnum: |
1443 | xor edx, edx |
1441 | xor edx, edx |
1444 | call division_64_bits |
1442 | call division_64_bits |
1445 | div ebx |
1443 | div ebx |
1446 | add dl, 48 |
1444 | add dl, 48 |
1447 | mov [edi], dl |
1445 | mov [edi], dl |
1448 | dec edi |
1446 | dec edi |
1449 | loop d_binnum |
1447 | loop d_binnum |
1450 | pop eax |
1448 | pop eax |
1451 | call normalize_number |
1449 | call normalize_number |
1452 | call draw_num_text |
1450 | call draw_num_text |
1453 | add esp, 64 |
1451 | add esp, 64 |
1454 | popad |
1452 | popad |
1455 | ret |
1453 | ret |
1456 | no_display_binnum: |
1454 | no_display_binnum: |
1457 | 1455 | ||
1458 | add esp, 64 |
1456 | add esp, 64 |
1459 | popad |
1457 | popad |
1460 | ret |
1458 | ret |
1461 | 1459 | ||
1462 | normalize_number: |
1460 | normalize_number: |
1463 | test ah, 0x80 |
1461 | test ah, 0x80 |
1464 | jz .continue |
1462 | jz .continue |
1465 | mov ecx, 48 |
1463 | mov ecx, 48 |
1466 | and eax, 0x3f |
1464 | and eax, 0x3f |
1467 | @@: |
1465 | @@: |
1468 | inc edi |
1466 | inc edi |
1469 | cmp [edi], cl |
1467 | cmp [edi], cl |
1470 | jne .continue |
1468 | jne .continue |
1471 | dec eax |
1469 | dec eax |
1472 | cmp eax, 1 |
1470 | cmp eax, 1 |
1473 | ja @r |
1471 | ja @r |
1474 | mov al, 1 |
1472 | mov al, 1 |
1475 | .continue: |
1473 | .continue: |
1476 | and eax, 0x3f |
1474 | and eax, 0x3f |
1477 | ret |
1475 | ret |
1478 | 1476 | ||
1479 | division_64_bits: |
1477 | division_64_bits: |
1480 | test [esp+1+4], byte 0x40 |
1478 | test [esp+1+4], byte 0x40 |
1481 | jz .continue |
1479 | jz .continue |
1482 | push eax |
1480 | push eax |
1483 | mov eax, ebp |
1481 | mov eax, ebp |
1484 | div ebx |
1482 | div ebx |
1485 | mov ebp, eax |
1483 | mov ebp, eax |
1486 | pop eax |
1484 | pop eax |
1487 | .continue: |
1485 | .continue: |
1488 | ret |
1486 | ret |
1489 | 1487 | ||
1490 | draw_num_text: |
1488 | draw_num_text: |
1491 | mov esi, eax |
1489 | mov esi, eax |
1492 | mov edx, 64+4 |
1490 | mov edx, 64+4 |
1493 | sub edx, eax |
1491 | sub edx, eax |
1494 | add edx, esp |
1492 | add edx, esp |
1495 | mov ebx, [esp+64+32-8+4] |
1493 | mov ebx, [esp+64+32-8+4] |
1496 | ; add window start x & y |
1494 | ; add window start x & y |
1497 | mov ecx, [TASK_BASE] |
1495 | mov ecx, [TASK_BASE] |
1498 | 1496 | ||
1499 | mov edi, [CURRENT_TASK] |
1497 | mov edi, [CURRENT_TASK] |
1500 | shl edi, 8 |
1498 | shl edi, 8 |
1501 | 1499 | ||
1502 | mov eax, [ecx-twdw+WDATA.box.left] |
1500 | mov eax, [ecx-twdw+WDATA.box.left] |
1503 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1501 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1504 | shl eax, 16 |
1502 | shl eax, 16 |
1505 | add eax, [ecx-twdw+WDATA.box.top] |
1503 | add eax, [ecx-twdw+WDATA.box.top] |
1506 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1504 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1507 | add ebx, eax |
1505 | add ebx, eax |
1508 | mov ecx, [esp+64+32-12+4] |
1506 | mov ecx, [esp+64+32-12+4] |
1509 | and ecx, not 0x80000000 ; force counted string |
1507 | and ecx, not 0x80000000 ; force counted string |
1510 | mov eax, [esp+64+8] ; background color (if given) |
1508 | mov eax, [esp+64+8] ; background color (if given) |
1511 | mov edi, [esp+64+4] |
1509 | mov edi, [esp+64+4] |
1512 | jmp dtext |
1510 | jmp dtext |
1513 | 1511 | ||
1514 | align 4 |
1512 | align 4 |
1515 | 1513 | ||
1516 | sys_setup: |
1514 | sys_setup: |
1517 | 1515 | ||
1518 | ; 1=roland mpu midi base , base io address |
1516 | ; 1=roland mpu midi base , base io address |
1519 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1517 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1520 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1518 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1521 | ; 5=system language, 1eng 2fi 3ger 4rus |
1519 | ; 5=system language, 1eng 2fi 3ger 4rus |
1522 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1520 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1523 | ; 8=fat32 partition in hd |
1521 | ; 8=fat32 partition in hd |
1524 | ; 9 |
1522 | ; 9 |
1525 | ; 10 = sound dma channel |
1523 | ; 10 = sound dma channel |
1526 | ; 11 = enable lba read |
1524 | ; 11 = enable lba read |
1527 | ; 12 = enable pci access |
1525 | ; 12 = enable pci access |
1528 | 1526 | ||
1529 | 1527 | ||
1530 | and [esp+32], dword 0 |
1528 | and [esp+32], dword 0 |
1531 | dec ebx ; MIDI |
1529 | dec ebx ; MIDI |
1532 | jnz nsyse1 |
1530 | jnz nsyse1 |
1533 | cmp ecx, 0x100 |
1531 | cmp ecx, 0x100 |
1534 | 1532 | ||
1535 | jb nsyse1 |
1533 | jb nsyse1 |
1536 | mov esi, 65535 |
1534 | mov esi, 65535 |
1537 | cmp esi, ecx |
1535 | cmp esi, ecx |
1538 | 1536 | ||
1539 | jb nsyse1 |
1537 | jb nsyse1 |
1540 | mov [midi_base], cx ;bx |
1538 | mov [midi_base], cx ;bx |
1541 | mov word [mididp], cx;bx |
1539 | mov word [mididp], cx;bx |
1542 | inc cx ;bx |
1540 | inc cx ;bx |
1543 | mov word [midisp], cx;bx |
1541 | mov word [midisp], cx;bx |
1544 | ret |
1542 | ret |
1545 | 1543 | ||
1546 | iglobal |
1544 | iglobal |
1547 | midi_base dw 0 |
1545 | midi_base dw 0 |
1548 | endg |
1546 | endg |
1549 | 1547 | ||
1550 | nsyse1: |
1548 | nsyse1: |
1551 | dec ebx ; KEYBOARD |
1549 | dec ebx ; KEYBOARD |
1552 | jnz nsyse2 |
1550 | jnz nsyse2 |
1553 | mov edi, [TASK_BASE] |
1551 | mov edi, [TASK_BASE] |
1554 | mov eax, [edi+TASKDATA.mem_start] |
1552 | mov eax, [edi+TASKDATA.mem_start] |
1555 | add eax, edx |
1553 | add eax, edx |
1556 | 1554 | ||
1557 | dec ecx |
1555 | dec ecx |
1558 | jnz kbnobase |
1556 | jnz kbnobase |
1559 | mov ebx, keymap |
1557 | mov ebx, keymap |
1560 | mov ecx, 128 |
1558 | mov ecx, 128 |
1561 | call memmove |
1559 | call memmove |
1562 | ret |
1560 | ret |
1563 | kbnobase: |
1561 | kbnobase: |
1564 | dec ecx |
1562 | dec ecx |
1565 | jnz kbnoshift |
1563 | jnz kbnoshift |
1566 | 1564 | ||
1567 | mov ebx, keymap_shift |
1565 | mov ebx, keymap_shift |
1568 | mov ecx, 128 |
1566 | mov ecx, 128 |
1569 | call memmove |
1567 | call memmove |
1570 | ret |
1568 | ret |
1571 | kbnoshift: |
1569 | kbnoshift: |
1572 | dec ecx |
1570 | dec ecx |
1573 | jnz kbnoalt |
1571 | jnz kbnoalt |
1574 | mov ebx, keymap_alt |
1572 | mov ebx, keymap_alt |
1575 | mov ecx, 128 |
1573 | mov ecx, 128 |
1576 | call memmove |
1574 | call memmove |
1577 | ret |
1575 | ret |
1578 | kbnoalt: |
1576 | kbnoalt: |
1579 | sub ecx, 6 |
1577 | sub ecx, 6 |
1580 | jnz kbnocountry |
1578 | jnz kbnocountry |
1581 | mov word [keyboard], dx |
1579 | mov word [keyboard], dx |
1582 | ret |
1580 | ret |
1583 | kbnocountry: |
1581 | kbnocountry: |
1584 | mov [esp+32], dword 1 |
1582 | mov [esp+32], dword 1 |
1585 | ret |
1583 | ret |
1586 | nsyse2: |
1584 | nsyse2: |
1587 | dec ebx ; CD |
1585 | dec ebx ; CD |
1588 | jnz nsyse4 |
1586 | jnz nsyse4 |
1589 | 1587 | ||
1590 | test ecx, ecx |
1588 | test ecx, ecx |
1591 | jz nosesl |
1589 | jz nosesl |
1592 | 1590 | ||
1593 | cmp ecx, 4 |
1591 | cmp ecx, 4 |
1594 | ja nosesl |
1592 | ja nosesl |
1595 | mov [cd_base], cl |
1593 | mov [cd_base], cl |
1596 | 1594 | ||
1597 | dec ecx |
1595 | dec ecx |
1598 | jnz noprma |
1596 | jnz noprma |
1599 | mov [cdbase], 0x1f0 |
1597 | mov [cdbase], 0x1f0 |
1600 | mov [cdid], 0xa0 |
1598 | mov [cdid], 0xa0 |
1601 | noprma: |
1599 | noprma: |
1602 | 1600 | ||
1603 | dec ecx |
1601 | dec ecx |
1604 | jnz noprsl |
1602 | jnz noprsl |
1605 | mov [cdbase], 0x1f0 |
1603 | mov [cdbase], 0x1f0 |
1606 | mov [cdid], 0xb0 |
1604 | mov [cdid], 0xb0 |
1607 | noprsl: |
1605 | noprsl: |
1608 | dec ecx |
1606 | dec ecx |
1609 | jnz nosema |
1607 | jnz nosema |
1610 | mov [cdbase], 0x170 |
1608 | mov [cdbase], 0x170 |
1611 | mov [cdid], 0xa0 |
1609 | mov [cdid], 0xa0 |
1612 | nosema: |
1610 | nosema: |
1613 | dec ecx |
1611 | dec ecx |
1614 | jnz nosesl |
1612 | jnz nosesl |
1615 | mov [cdbase], 0x170 |
1613 | mov [cdbase], 0x170 |
1616 | mov [cdid], 0xb0 |
1614 | mov [cdid], 0xb0 |
1617 | nosesl: |
1615 | nosesl: |
1618 | ret |
1616 | ret |
1619 | 1617 | ||
1620 | iglobal |
1618 | iglobal |
1621 | cd_base db 0 |
1619 | cd_base db 0 |
1622 | 1620 | ||
1623 | endg |
1621 | endg |
1624 | nsyse4: |
1622 | nsyse4: |
1625 | 1623 | ||
1626 | sub ebx, 2 ; SYSTEM LANGUAGE |
1624 | sub ebx, 2 ; SYSTEM LANGUAGE |
1627 | jnz nsyse5 |
1625 | jnz nsyse5 |
1628 | mov [syslang], ecx |
1626 | mov [syslang], ecx |
1629 | ret |
1627 | ret |
1630 | nsyse5: |
1628 | nsyse5: |
1631 | 1629 | ||
1632 | sub ebx, 2 ; HD BASE |
1630 | sub ebx, 2 ; HD BASE |
1633 | jnz nsyse7 |
1631 | jnz nsyse7 |
1634 | 1632 | ||
1635 | test ecx, ecx |
1633 | test ecx, ecx |
1636 | jz nosethd |
1634 | jz nosethd |
1637 | 1635 | ||
1638 | cmp ecx, 4 |
1636 | cmp ecx, 4 |
1639 | ja nosethd |
1637 | ja nosethd |
1640 | mov [hd_base], cl |
1638 | mov [hd_base], cl |
1641 | 1639 | ||
1642 | cmp ecx, 1 |
1640 | cmp ecx, 1 |
1643 | jnz noprmahd |
1641 | jnz noprmahd |
1644 | mov [hdbase], 0x1f0 |
1642 | mov [hdbase], 0x1f0 |
1645 | and dword [hdid], 0x0 |
1643 | and dword [hdid], 0x0 |
1646 | mov dword [hdpos], ecx |
1644 | mov dword [hdpos], ecx |
1647 | ; call set_FAT32_variables |
1645 | ; call set_FAT32_variables |
1648 | noprmahd: |
1646 | noprmahd: |
1649 | 1647 | ||
1650 | cmp ecx, 2 |
1648 | cmp ecx, 2 |
1651 | jnz noprslhd |
1649 | jnz noprslhd |
1652 | mov [hdbase], 0x1f0 |
1650 | mov [hdbase], 0x1f0 |
1653 | mov [hdid], 0x10 |
1651 | mov [hdid], 0x10 |
1654 | mov dword [hdpos], ecx |
1652 | mov dword [hdpos], ecx |
1655 | ; call set_FAT32_variables |
1653 | ; call set_FAT32_variables |
1656 | noprslhd: |
1654 | noprslhd: |
1657 | 1655 | ||
1658 | cmp ecx, 3 |
1656 | cmp ecx, 3 |
1659 | jnz nosemahd |
1657 | jnz nosemahd |
1660 | mov [hdbase], 0x170 |
1658 | mov [hdbase], 0x170 |
1661 | and dword [hdid], 0x0 |
1659 | and dword [hdid], 0x0 |
1662 | mov dword [hdpos], ecx |
1660 | mov dword [hdpos], ecx |
1663 | ; call set_FAT32_variables |
1661 | ; call set_FAT32_variables |
1664 | nosemahd: |
1662 | nosemahd: |
1665 | 1663 | ||
1666 | cmp ecx, 4 |
1664 | cmp ecx, 4 |
1667 | jnz noseslhd |
1665 | jnz noseslhd |
1668 | mov [hdbase], 0x170 |
1666 | mov [hdbase], 0x170 |
1669 | mov [hdid], 0x10 |
1667 | mov [hdid], 0x10 |
1670 | mov dword [hdpos], ecx |
1668 | mov dword [hdpos], ecx |
1671 | ; call set_FAT32_variables |
1669 | ; call set_FAT32_variables |
1672 | noseslhd: |
1670 | noseslhd: |
1673 | call reserve_hd1 |
1671 | call reserve_hd1 |
1674 | call reserve_hd_channel |
1672 | call reserve_hd_channel |
1675 | call free_hd_channel |
1673 | call free_hd_channel |
1676 | and dword [hd1_status], 0 ; free |
1674 | and dword [hd1_status], 0 ; free |
1677 | nosethd: |
1675 | nosethd: |
1678 | ret |
1676 | ret |
1679 | 1677 | ||
1680 | iglobal |
1678 | iglobal |
1681 | hd_base db 0 |
1679 | hd_base db 0 |
1682 | endg |
1680 | endg |
1683 | 1681 | ||
1684 | nsyse7: |
1682 | nsyse7: |
1685 | 1683 | ||
1686 | ; cmp eax,8 ; HD PARTITION |
1684 | ; cmp eax,8 ; HD PARTITION |
1687 | dec ebx |
1685 | dec ebx |
1688 | jnz nsyse8 |
1686 | jnz nsyse8 |
1689 | mov [fat32part], ecx |
1687 | mov [fat32part], ecx |
1690 | ; call set_FAT32_variables |
1688 | ; call set_FAT32_variables |
1691 | call reserve_hd1 |
1689 | call reserve_hd1 |
1692 | call reserve_hd_channel |
1690 | call reserve_hd_channel |
1693 | call free_hd_channel |
1691 | call free_hd_channel |
1694 | ; pusha |
1692 | ; pusha |
1695 | call choice_necessity_partition_1 |
1693 | call choice_necessity_partition_1 |
1696 | ; popa |
1694 | ; popa |
1697 | and dword [hd1_status], 0 ; free |
1695 | and dword [hd1_status], 0 ; free |
1698 | ret |
1696 | ret |
1699 | 1697 | ||
1700 | nsyse8: |
1698 | nsyse8: |
1701 | ; cmp eax,11 ; ENABLE LBA READ |
1699 | ; cmp eax,11 ; ENABLE LBA READ |
1702 | and ecx, 1 |
1700 | and ecx, 1 |
1703 | sub ebx, 3 |
1701 | sub ebx, 3 |
1704 | jnz no_set_lba_read |
1702 | jnz no_set_lba_read |
1705 | mov [lba_read_enabled], ecx |
1703 | mov [lba_read_enabled], ecx |
1706 | ret |
1704 | ret |
1707 | 1705 | ||
1708 | no_set_lba_read: |
1706 | no_set_lba_read: |
1709 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1707 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1710 | dec ebx |
1708 | dec ebx |
1711 | jnz sys_setup_err |
1709 | jnz sys_setup_err |
1712 | mov [pci_access_enabled], ecx |
1710 | mov [pci_access_enabled], ecx |
1713 | ret |
1711 | ret |
1714 | 1712 | ||
1715 | sys_setup_err: |
1713 | sys_setup_err: |
1716 | or [esp+32], dword -1 |
1714 | or [esp+32], dword -1 |
1717 | ret |
1715 | ret |
1718 | 1716 | ||
1719 | align 4 |
1717 | align 4 |
1720 | 1718 | ||
1721 | sys_getsetup: |
1719 | sys_getsetup: |
1722 | 1720 | ||
1723 | ; 1=roland mpu midi base , base io address |
1721 | ; 1=roland mpu midi base , base io address |
1724 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1722 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1725 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1723 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1726 | ; 5=system language, 1eng 2fi 3ger 4rus |
1724 | ; 5=system language, 1eng 2fi 3ger 4rus |
1727 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1725 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1728 | ; 8=fat32 partition in hd |
1726 | ; 8=fat32 partition in hd |
1729 | ; 9=get hs timer tic |
1727 | ; 9=get hs timer tic |
1730 | 1728 | ||
1731 | ; cmp eax,1 |
1729 | ; cmp eax,1 |
1732 | dec ebx |
1730 | dec ebx |
1733 | jnz ngsyse1 |
1731 | jnz ngsyse1 |
1734 | movzx eax, [midi_base] |
1732 | movzx eax, [midi_base] |
1735 | mov [esp+32], eax |
1733 | mov [esp+32], eax |
1736 | ret |
1734 | ret |
1737 | ngsyse1: |
1735 | ngsyse1: |
1738 | ; cmp eax,2 |
1736 | ; cmp eax,2 |
1739 | dec ebx |
1737 | dec ebx |
1740 | jnz ngsyse2 |
1738 | jnz ngsyse2 |
1741 | 1739 | ||
1742 | mov edi, [TASK_BASE] |
1740 | mov edi, [TASK_BASE] |
1743 | mov ebx, [edi+TASKDATA.mem_start] |
1741 | mov ebx, [edi+TASKDATA.mem_start] |
1744 | add ebx, edx |
1742 | add ebx, edx |
1745 | 1743 | ||
1746 | ; cmp ebx,1 |
1744 | ; cmp ebx,1 |
1747 | dec ecx |
1745 | dec ecx |
1748 | jnz kbnobaseret |
1746 | jnz kbnobaseret |
1749 | mov eax, keymap |
1747 | mov eax, keymap |
1750 | mov ecx, 128 |
1748 | mov ecx, 128 |
1751 | call memmove |
1749 | call memmove |
1752 | ret |
1750 | ret |
1753 | kbnobaseret: |
1751 | kbnobaseret: |
1754 | ; cmp ebx,2 |
1752 | ; cmp ebx,2 |
1755 | dec ecx |
1753 | dec ecx |
1756 | jnz kbnoshiftret |
1754 | jnz kbnoshiftret |
1757 | 1755 | ||
1758 | mov eax, keymap_shift |
1756 | mov eax, keymap_shift |
1759 | mov ecx, 128 |
1757 | mov ecx, 128 |
1760 | call memmove |
1758 | call memmove |
1761 | ret |
1759 | ret |
1762 | kbnoshiftret: |
1760 | kbnoshiftret: |
1763 | ; cmp ebx,3 |
1761 | ; cmp ebx,3 |
1764 | dec ecx |
1762 | dec ecx |
1765 | jne kbnoaltret |
1763 | jne kbnoaltret |
1766 | 1764 | ||
1767 | mov eax, keymap_alt |
1765 | mov eax, keymap_alt |
1768 | mov ecx, 128 |
1766 | mov ecx, 128 |
1769 | call memmove |
1767 | call memmove |
1770 | ret |
1768 | ret |
1771 | kbnoaltret: |
1769 | kbnoaltret: |
1772 | ; cmp ebx,9 |
1770 | ; cmp ebx,9 |
1773 | sub ecx, 6 |
1771 | sub ecx, 6 |
1774 | jnz ngsyse2 |
1772 | jnz ngsyse2 |
1775 | movzx eax, word [keyboard] |
1773 | movzx eax, word [keyboard] |
1776 | mov [esp+32], eax |
1774 | mov [esp+32], eax |
1777 | ret |
1775 | ret |
1778 | 1776 | ||
1779 | 1777 | ||
1780 | ngsyse2: |
1778 | ngsyse2: |
1781 | ; cmp eax,3 |
1779 | ; cmp eax,3 |
1782 | dec ebx |
1780 | dec ebx |
1783 | jnz ngsyse3 |
1781 | jnz ngsyse3 |
1784 | movzx eax, [cd_base] |
1782 | movzx eax, [cd_base] |
1785 | mov [esp+32], eax |
1783 | mov [esp+32], eax |
1786 | ret |
1784 | ret |
1787 | ngsyse3: |
1785 | ngsyse3: |
1788 | ; cmp eax,5 |
1786 | ; cmp eax,5 |
1789 | sub ebx, 2 |
1787 | sub ebx, 2 |
1790 | jnz ngsyse5 |
1788 | jnz ngsyse5 |
1791 | mov eax, [syslang] |
1789 | mov eax, [syslang] |
1792 | mov [esp+32], eax |
1790 | mov [esp+32], eax |
1793 | ret |
1791 | ret |
1794 | ngsyse5: |
1792 | ngsyse5: |
1795 | ; cmp eax,7 |
1793 | ; cmp eax,7 |
1796 | sub ebx, 2 |
1794 | sub ebx, 2 |
1797 | jnz ngsyse7 |
1795 | jnz ngsyse7 |
1798 | movzx eax, [hd_base] |
1796 | movzx eax, [hd_base] |
1799 | mov [esp+32], eax |
1797 | mov [esp+32], eax |
1800 | ret |
1798 | ret |
1801 | ngsyse7: |
1799 | ngsyse7: |
1802 | ; cmp eax,8 |
1800 | ; cmp eax,8 |
1803 | dec ebx |
1801 | dec ebx |
1804 | jnz ngsyse8 |
1802 | jnz ngsyse8 |
1805 | mov eax, [fat32part] |
1803 | mov eax, [fat32part] |
1806 | mov [esp+32], eax |
1804 | mov [esp+32], eax |
1807 | ret |
1805 | ret |
1808 | ngsyse8: |
1806 | ngsyse8: |
1809 | ; cmp eax,9 |
1807 | ; cmp eax,9 |
1810 | dec ebx |
1808 | dec ebx |
1811 | jnz ngsyse9 |
1809 | jnz ngsyse9 |
1812 | mov eax, [timer_ticks];[0xfdf0] |
1810 | mov eax, [timer_ticks];[0xfdf0] |
1813 | mov [esp+32], eax |
1811 | mov [esp+32], eax |
1814 | ret |
1812 | ret |
1815 | ngsyse9: |
1813 | ngsyse9: |
1816 | ; cmp eax,11 |
1814 | ; cmp eax,11 |
1817 | sub ebx, 2 |
1815 | sub ebx, 2 |
1818 | jnz ngsyse11 |
1816 | jnz ngsyse11 |
1819 | mov eax, [lba_read_enabled] |
1817 | mov eax, [lba_read_enabled] |
1820 | mov [esp+32], eax |
1818 | mov [esp+32], eax |
1821 | ret |
1819 | ret |
1822 | ngsyse11: |
1820 | ngsyse11: |
1823 | ; cmp eax,12 |
1821 | ; cmp eax,12 |
1824 | dec ebx |
1822 | dec ebx |
1825 | jnz ngsyse12 |
1823 | jnz ngsyse12 |
1826 | mov eax, [pci_access_enabled] |
1824 | mov eax, [pci_access_enabled] |
1827 | mov [esp+32], eax |
1825 | mov [esp+32], eax |
1828 | ret |
1826 | ret |
1829 | ngsyse12: |
1827 | ngsyse12: |
1830 | mov [esp+32], dword 1 |
1828 | mov [esp+32], dword 1 |
1831 | ret |
1829 | ret |
1832 | 1830 | ||
1833 | 1831 | ||
1834 | get_timer_ticks: |
1832 | get_timer_ticks: |
1835 | mov eax, [timer_ticks] |
1833 | mov eax, [timer_ticks] |
1836 | ret |
1834 | ret |
1837 | 1835 | ||
1838 | iglobal |
1836 | iglobal |
1839 | align 4 |
1837 | align 4 |
1840 | mousefn dd msscreen, mswin, msbutton, msset |
1838 | mousefn dd msscreen, mswin, msbutton, msset |
1841 | dd app_load_cursor |
1839 | dd app_load_cursor |
1842 | dd app_set_cursor |
1840 | dd app_set_cursor |
1843 | dd app_delete_cursor |
1841 | dd app_delete_cursor |
1844 | dd msz |
1842 | dd msz |
1845 | endg |
1843 | endg |
1846 | 1844 | ||
1847 | readmousepos: |
1845 | readmousepos: |
1848 | 1846 | ||
1849 | ; eax=0 screen relative |
1847 | ; eax=0 screen relative |
1850 | ; eax=1 window relative |
1848 | ; eax=1 window relative |
1851 | ; eax=2 buttons pressed |
1849 | ; eax=2 buttons pressed |
1852 | ; eax=3 set mouse pos ; reserved |
1850 | ; eax=3 set mouse pos ; reserved |
1853 | ; eax=4 load cursor |
1851 | ; eax=4 load cursor |
1854 | ; eax=5 set cursor |
1852 | ; eax=5 set cursor |
1855 | ; eax=6 delete cursor ; reserved |
1853 | ; eax=6 delete cursor ; reserved |
1856 | ; eax=7 get mouse_z |
1854 | ; eax=7 get mouse_z |
1857 | 1855 | ||
1858 | cmp ebx, 7 |
1856 | cmp ebx, 7 |
1859 | ja msset |
1857 | ja msset |
1860 | jmp [mousefn+ebx*4] |
1858 | jmp [mousefn+ebx*4] |
1861 | msscreen: |
1859 | msscreen: |
1862 | mov eax, [MOUSE_X] |
1860 | mov eax, [MOUSE_X] |
1863 | shl eax, 16 |
1861 | shl eax, 16 |
1864 | mov ax, [MOUSE_Y] |
1862 | mov ax, [MOUSE_Y] |
1865 | mov [esp+36-4], eax |
1863 | mov [esp+36-4], eax |
1866 | ret |
1864 | ret |
1867 | mswin: |
1865 | mswin: |
1868 | mov eax, [MOUSE_X] |
1866 | mov eax, [MOUSE_X] |
1869 | shl eax, 16 |
1867 | shl eax, 16 |
1870 | mov ax, [MOUSE_Y] |
1868 | mov ax, [MOUSE_Y] |
1871 | mov esi, [TASK_BASE] |
1869 | mov esi, [TASK_BASE] |
1872 | mov bx, word [esi-twdw+WDATA.box.left] |
1870 | mov bx, word [esi-twdw+WDATA.box.left] |
1873 | shl ebx, 16 |
1871 | shl ebx, 16 |
1874 | mov bx, word [esi-twdw+WDATA.box.top] |
1872 | mov bx, word [esi-twdw+WDATA.box.top] |
1875 | sub eax, ebx |
1873 | sub eax, ebx |
1876 | 1874 | ||
1877 | mov edi, [CURRENT_TASK] |
1875 | mov edi, [CURRENT_TASK] |
1878 | shl edi, 8 |
1876 | shl edi, 8 |
1879 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1877 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1880 | rol eax, 16 |
1878 | rol eax, 16 |
1881 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1879 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1882 | rol eax, 16 |
1880 | rol eax, 16 |
1883 | mov [esp+36-4], eax |
1881 | mov [esp+36-4], eax |
1884 | ret |
1882 | ret |
1885 | msbutton: |
1883 | msbutton: |
1886 | movzx eax, byte [BTN_DOWN] |
1884 | movzx eax, byte [BTN_DOWN] |
1887 | mov [esp+36-4], eax |
1885 | mov [esp+36-4], eax |
1888 | ret |
1886 | ret |
1889 | msz: |
1887 | msz: |
1890 | mov edi, [TASK_COUNT] |
1888 | mov edi, [TASK_COUNT] |
1891 | movzx edi, word [WIN_POS + edi*2] |
1889 | movzx edi, word [WIN_POS + edi*2] |
1892 | cmp edi, [CURRENT_TASK] |
1890 | cmp edi, [CURRENT_TASK] |
1893 | jne @f |
1891 | jne @f |
1894 | mov ax, [MOUSE_SCROLL_H] |
1892 | mov ax, [MOUSE_SCROLL_H] |
1895 | shl eax, 16 |
1893 | shl eax, 16 |
1896 | mov ax, [MOUSE_SCROLL_V] |
1894 | mov ax, [MOUSE_SCROLL_V] |
1897 | mov [esp+36-4], eax |
1895 | mov [esp+36-4], eax |
1898 | and [MOUSE_SCROLL_H], word 0 |
1896 | and [MOUSE_SCROLL_H], word 0 |
1899 | and [MOUSE_SCROLL_V], word 0 |
1897 | and [MOUSE_SCROLL_V], word 0 |
1900 | ret |
1898 | ret |
1901 | @@: |
1899 | @@: |
1902 | and [esp+36-4], dword 0 |
1900 | and [esp+36-4], dword 0 |
1903 | ; ret |
1901 | ; ret |
1904 | msset: |
1902 | msset: |
1905 | ret |
1903 | ret |
1906 | 1904 | ||
1907 | app_load_cursor: |
1905 | app_load_cursor: |
1908 | cmp ecx, OS_BASE |
1906 | cmp ecx, OS_BASE |
1909 | jae msset |
1907 | jae msset |
1910 | stdcall load_cursor, ecx, edx |
1908 | stdcall load_cursor, ecx, edx |
1911 | mov [esp+36-4], eax |
1909 | mov [esp+36-4], eax |
1912 | ret |
1910 | ret |
1913 | 1911 | ||
1914 | app_set_cursor: |
1912 | app_set_cursor: |
1915 | stdcall set_cursor, ecx |
1913 | stdcall set_cursor, ecx |
1916 | mov [esp+36-4], eax |
1914 | mov [esp+36-4], eax |
1917 | ret |
1915 | ret |
1918 | 1916 | ||
1919 | app_delete_cursor: |
1917 | app_delete_cursor: |
1920 | stdcall delete_cursor, ecx |
1918 | stdcall delete_cursor, ecx |
1921 | mov [esp+36-4], eax |
1919 | mov [esp+36-4], eax |
1922 | ret |
1920 | ret |
1923 | 1921 | ||
1924 | is_input: |
1922 | is_input: |
1925 | 1923 | ||
1926 | push edx |
1924 | push edx |
1927 | mov dx, word [midisp] |
1925 | mov dx, word [midisp] |
1928 | in al, dx |
1926 | in al, dx |
1929 | and al, 0x80 |
1927 | and al, 0x80 |
1930 | pop edx |
1928 | pop edx |
1931 | ret |
1929 | ret |
1932 | 1930 | ||
1933 | is_output: |
1931 | is_output: |
1934 | 1932 | ||
1935 | push edx |
1933 | push edx |
1936 | mov dx, word [midisp] |
1934 | mov dx, word [midisp] |
1937 | in al, dx |
1935 | in al, dx |
1938 | and al, 0x40 |
1936 | and al, 0x40 |
1939 | pop edx |
1937 | pop edx |
1940 | ret |
1938 | ret |
1941 | 1939 | ||
1942 | 1940 | ||
1943 | get_mpu_in: |
1941 | get_mpu_in: |
1944 | 1942 | ||
1945 | push edx |
1943 | push edx |
1946 | mov dx, word [mididp] |
1944 | mov dx, word [mididp] |
1947 | in al, dx |
1945 | in al, dx |
1948 | pop edx |
1946 | pop edx |
1949 | ret |
1947 | ret |
1950 | 1948 | ||
1951 | 1949 | ||
1952 | put_mpu_out: |
1950 | put_mpu_out: |
1953 | 1951 | ||
1954 | push edx |
1952 | push edx |
1955 | mov dx, word [mididp] |
1953 | mov dx, word [mididp] |
1956 | out dx, al |
1954 | out dx, al |
1957 | pop edx |
1955 | pop edx |
1958 | ret |
1956 | ret |
1959 | 1957 | ||
1960 | 1958 | ||
1961 | 1959 | ||
1962 | align 4 |
1960 | align 4 |
1963 | 1961 | ||
1964 | sys_midi: |
1962 | sys_midi: |
1965 | cmp [mididp], 0 |
1963 | cmp [mididp], 0 |
1966 | jnz sm0 |
1964 | jnz sm0 |
1967 | mov [esp+36], dword 1 |
1965 | mov [esp+36], dword 1 |
1968 | ret |
1966 | ret |
1969 | sm0: |
1967 | sm0: |
1970 | and [esp+36], dword 0 |
1968 | and [esp+36], dword 0 |
1971 | dec ebx |
1969 | dec ebx |
1972 | jnz smn1 |
1970 | jnz smn1 |
1973 | ; call setuart |
1971 | ; call setuart |
1974 | su1: |
1972 | su1: |
1975 | call is_output |
1973 | call is_output |
1976 | test al, al |
1974 | test al, al |
1977 | jnz su1 |
1975 | jnz su1 |
1978 | mov dx, word [midisp] |
1976 | mov dx, word [midisp] |
1979 | mov al, 0xff |
1977 | mov al, 0xff |
1980 | out dx, al |
1978 | out dx, al |
1981 | su2: |
1979 | su2: |
1982 | mov dx, word [midisp] |
1980 | mov dx, word [midisp] |
1983 | mov al, 0xff |
1981 | mov al, 0xff |
1984 | out dx, al |
1982 | out dx, al |
1985 | call is_input |
1983 | call is_input |
1986 | test al, al |
1984 | test al, al |
1987 | jnz su2 |
1985 | jnz su2 |
1988 | call get_mpu_in |
1986 | call get_mpu_in |
1989 | cmp al, 0xfe |
1987 | cmp al, 0xfe |
1990 | jnz su2 |
1988 | jnz su2 |
1991 | su3: |
1989 | su3: |
1992 | call is_output |
1990 | call is_output |
1993 | test al, al |
1991 | test al, al |
1994 | jnz su3 |
1992 | jnz su3 |
1995 | mov dx, word [midisp] |
1993 | mov dx, word [midisp] |
1996 | mov al, 0x3f |
1994 | mov al, 0x3f |
1997 | out dx, al |
1995 | out dx, al |
1998 | ret |
1996 | ret |
1999 | smn1: |
1997 | smn1: |
2000 | dec ebx |
1998 | dec ebx |
2001 | jnz smn2 |
1999 | jnz smn2 |
2002 | sm10: |
2000 | sm10: |
2003 | call get_mpu_in |
2001 | call get_mpu_in |
2004 | call is_output |
2002 | call is_output |
2005 | test al, al |
2003 | test al, al |
2006 | jnz sm10 |
2004 | jnz sm10 |
2007 | mov al, bl |
2005 | mov al, bl |
2008 | call put_mpu_out |
2006 | call put_mpu_out |
2009 | smn2: |
2007 | smn2: |
2010 | ret |
2008 | ret |
2011 | 2009 | ||
2012 | detect_devices: |
2010 | detect_devices: |
2013 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2011 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2014 | ;include 'detect/commouse.inc' |
2012 | ;include 'detect/commouse.inc' |
2015 | ;include 'detect/ps2mouse.inc' |
2013 | ;include 'detect/ps2mouse.inc' |
2016 | ;include 'detect/dev_fd.inc' |
2014 | ;include 'detect/dev_fd.inc' |
2017 | ;include 'detect/dev_hdcd.inc' |
2015 | ;include 'detect/dev_hdcd.inc' |
2018 | ;include 'detect/sear_par.inc' |
2016 | ;include 'detect/sear_par.inc' |
2019 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2017 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2020 | ret |
2018 | ret |
2021 | 2019 | ||
2022 | sys_end: |
2020 | sys_end: |
2023 | ;-------------------------------------- |
2021 | ;-------------------------------------- |
2024 | cmp [_display.select_cursor], 0 |
2022 | cmp [_display.select_cursor], 0 |
2025 | je @f |
2023 | je @f |
2026 | ; restore default cursor before killing |
2024 | ; restore default cursor before killing |
2027 | pusha |
2025 | pusha |
2028 | mov ecx, [current_slot] |
2026 | mov ecx, [current_slot] |
2029 | call restore_default_cursor_before_killing |
2027 | call restore_default_cursor_before_killing |
2030 | popa |
2028 | popa |
2031 | @@: |
2029 | @@: |
2032 | ;-------------------------------------- |
2030 | ;-------------------------------------- |
2033 | mov ecx, [current_slot] |
2031 | mov ecx, [current_slot] |
2034 | mov eax, [ecx+APPDATA.tls_base] |
2032 | mov eax, [ecx+APPDATA.tls_base] |
2035 | test eax, eax |
2033 | test eax, eax |
2036 | jz @F |
2034 | jz @F |
2037 | 2035 | ||
2038 | stdcall user_free, eax |
2036 | stdcall user_free, eax |
2039 | @@: |
2037 | @@: |
2040 | 2038 | ||
2041 | mov eax, [TASK_BASE] |
2039 | mov eax, [TASK_BASE] |
2042 | mov [eax+TASKDATA.state], 3; terminate this program |
2040 | mov [eax+TASKDATA.state], 3; terminate this program |
2043 | call wakeup_osloop |
2041 | call wakeup_osloop |
2044 | 2042 | ||
2045 | waitterm: ; wait here for termination |
2043 | waitterm: ; wait here for termination |
2046 | mov ebx, 100 |
2044 | mov ebx, 100 |
2047 | call delay_hs |
2045 | call delay_hs |
2048 | jmp waitterm |
2046 | jmp waitterm |
2049 | ;------------------------------------------------------------------------------ |
2047 | ;------------------------------------------------------------------------------ |
2050 | align 4 |
2048 | align 4 |
2051 | restore_default_cursor_before_killing: |
2049 | restore_default_cursor_before_killing: |
2052 | pushfd |
2050 | pushfd |
2053 | cli |
2051 | cli |
2054 | mov eax, [def_cursor] |
2052 | mov eax, [def_cursor] |
2055 | mov [ecx+APPDATA.cursor], eax |
2053 | mov [ecx+APPDATA.cursor], eax |
2056 | 2054 | ||
2057 | movzx eax, word [MOUSE_Y] |
2055 | movzx eax, word [MOUSE_Y] |
2058 | movzx ebx, word [MOUSE_X] |
2056 | movzx ebx, word [MOUSE_X] |
2059 | ; mov ecx, [Screen_Max_X] |
2057 | ; mov ecx, [Screen_Max_X] |
2060 | ; inc ecx |
2058 | ; inc ecx |
2061 | ; mul ecx |
2059 | ; mul ecx |
2062 | mov eax, [d_width_calc_area + eax*4] |
2060 | mov eax, [d_width_calc_area + eax*4] |
2063 | 2061 | ||
2064 | add eax, [_WinMapAddress] |
2062 | add eax, [_WinMapAddress] |
2065 | movzx edx, byte [ebx+eax] |
2063 | movzx edx, byte [ebx+eax] |
2066 | shl edx, 8 |
2064 | shl edx, 8 |
2067 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2065 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2068 | 2066 | ||
2069 | cmp esi, [current_cursor] |
2067 | cmp esi, [current_cursor] |
2070 | je @f |
2068 | je @f |
2071 | 2069 | ||
2072 | push esi |
2070 | push esi |
2073 | call [_display.select_cursor] |
2071 | call [_display.select_cursor] |
2074 | mov [current_cursor], esi |
2072 | mov [current_cursor], esi |
2075 | @@: |
2073 | @@: |
2076 | mov [redrawmouse_unconditional], 1 |
2074 | mov [redrawmouse_unconditional], 1 |
2077 | call wakeup_osloop |
2075 | call wakeup_osloop |
2078 | popfd |
2076 | popfd |
2079 | ret |
2077 | ret |
2080 | ;------------------------------------------------------------------------------ |
2078 | ;------------------------------------------------------------------------------ |
2081 | iglobal |
2079 | iglobal |
2082 | align 4 |
2080 | align 4 |
2083 | sys_system_table: |
2081 | sys_system_table: |
2084 | dd sysfn_deactivate ; 1 = deactivate window |
2082 | dd sysfn_deactivate ; 1 = deactivate window |
2085 | dd sysfn_terminate ; 2 = terminate thread |
2083 | dd sysfn_terminate ; 2 = terminate thread |
2086 | dd sysfn_activate ; 3 = activate window |
2084 | dd sysfn_activate ; 3 = activate window |
2087 | dd sysfn_getidletime ; 4 = get idle time |
2085 | dd sysfn_getidletime ; 4 = get idle time |
2088 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2086 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2089 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2087 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2090 | dd sysfn_getactive ; 7 = get active window |
2088 | dd sysfn_getactive ; 7 = get active window |
2091 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2089 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2092 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2090 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2093 | dd sysfn_minimize ; 10 = minimize window |
2091 | dd sysfn_minimize ; 10 = minimize window |
2094 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2092 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2095 | dd sysfn_lastkey ; 12 = get last pressed key |
2093 | dd sysfn_lastkey ; 12 = get last pressed key |
2096 | dd sysfn_getversion ; 13 = get kernel version |
2094 | dd sysfn_getversion ; 13 = get kernel version |
2097 | dd sysfn_waitretrace ; 14 = wait retrace |
2095 | dd sysfn_waitretrace ; 14 = wait retrace |
2098 | dd sysfn_centermouse ; 15 = center mouse cursor |
2096 | dd sysfn_centermouse ; 15 = center mouse cursor |
2099 | dd sysfn_getfreemem ; 16 = get free memory size |
2097 | dd sysfn_getfreemem ; 16 = get free memory size |
2100 | dd sysfn_getallmem ; 17 = get total memory size |
2098 | dd sysfn_getallmem ; 17 = get total memory size |
2101 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2099 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2102 | ; instead of slot |
2100 | ; instead of slot |
2103 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2101 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2104 | dd sysfn_meminfo ; 20 = get extended memory info |
2102 | dd sysfn_meminfo ; 20 = get extended memory info |
2105 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2103 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2106 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2104 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2107 | dd sysfn_min_windows ; 23 = minimize all windows |
2105 | dd sysfn_min_windows ; 23 = minimize all windows |
2108 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2106 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2109 | sysfn_num = ($ - sys_system_table)/4 |
2107 | sysfn_num = ($ - sys_system_table)/4 |
2110 | endg |
2108 | endg |
2111 | ;------------------------------------------------------------------------------ |
2109 | ;------------------------------------------------------------------------------ |
2112 | sys_system: |
2110 | sys_system: |
2113 | dec ebx |
2111 | dec ebx |
2114 | cmp ebx, sysfn_num |
2112 | cmp ebx, sysfn_num |
2115 | jae @f |
2113 | jae @f |
2116 | jmp dword [sys_system_table + ebx*4] |
2114 | jmp dword [sys_system_table + ebx*4] |
2117 | @@: |
2115 | @@: |
2118 | ret |
2116 | ret |
2119 | ;------------------------------------------------------------------------------ |
2117 | ;------------------------------------------------------------------------------ |
2120 | sysfn_shutdown: ; 18.9 = system shutdown |
2118 | sysfn_shutdown: ; 18.9 = system shutdown |
2121 | cmp ecx, 1 |
2119 | cmp ecx, 1 |
2122 | jl exit_for_anyone |
2120 | jl exit_for_anyone |
2123 | cmp ecx, 4 |
2121 | cmp ecx, 4 |
2124 | jg exit_for_anyone |
2122 | jg exit_for_anyone |
2125 | mov [BOOT_VAR+0x9030], cl |
2123 | mov [BOOT_VAR+0x9030], cl |
2126 | 2124 | ||
2127 | mov eax, [TASK_COUNT] |
2125 | mov eax, [TASK_COUNT] |
2128 | mov [SYS_SHUTDOWN], al |
2126 | mov [SYS_SHUTDOWN], al |
2129 | mov [shutdown_processes], eax |
2127 | mov [shutdown_processes], eax |
2130 | call wakeup_osloop |
2128 | call wakeup_osloop |
2131 | and dword [esp+32], 0 |
2129 | and dword [esp+32], 0 |
2132 | exit_for_anyone: |
2130 | exit_for_anyone: |
2133 | ret |
2131 | ret |
2134 | uglobal |
2132 | uglobal |
2135 | shutdown_processes: |
2133 | shutdown_processes: |
2136 | dd 0x0 |
2134 | dd 0x0 |
2137 | endg |
2135 | endg |
2138 | ;------------------------------------------------------------------------------ |
2136 | ;------------------------------------------------------------------------------ |
2139 | sysfn_terminate: ; 18.2 = TERMINATE |
2137 | sysfn_terminate: ; 18.2 = TERMINATE |
2140 | push ecx |
2138 | push ecx |
2141 | cmp ecx, 2 |
2139 | cmp ecx, 2 |
2142 | jb noprocessterminate |
2140 | jb noprocessterminate |
2143 | mov edx, [TASK_COUNT] |
2141 | mov edx, [TASK_COUNT] |
2144 | cmp ecx, edx |
2142 | cmp ecx, edx |
2145 | ja noprocessterminate |
2143 | ja noprocessterminate |
2146 | mov eax, [TASK_COUNT] |
2144 | mov eax, [TASK_COUNT] |
2147 | shl ecx, 5 |
2145 | shl ecx, 5 |
2148 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2146 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2149 | add ecx, CURRENT_TASK+TASKDATA.state |
2147 | add ecx, CURRENT_TASK+TASKDATA.state |
2150 | cmp byte [ecx], 9 |
2148 | cmp byte [ecx], 9 |
2151 | jz noprocessterminate |
2149 | jz noprocessterminate |
2152 | push ecx edx |
2150 | push ecx edx |
2153 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2151 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2154 | call request_terminate |
2152 | call request_terminate |
2155 | pop edx ecx |
2153 | pop edx ecx |
2156 | test eax, eax |
2154 | test eax, eax |
2157 | jz noprocessterminate |
2155 | jz noprocessterminate |
2158 | ;-------------------------------------- |
2156 | ;-------------------------------------- |
2159 | cmp [_display.select_cursor], 0 |
2157 | cmp [_display.select_cursor], 0 |
2160 | je .restore_end |
2158 | je .restore_end |
2161 | ; restore default cursor before killing |
2159 | ; restore default cursor before killing |
2162 | pusha |
2160 | pusha |
2163 | mov ecx, [esp+32] |
2161 | mov ecx, [esp+32] |
2164 | shl ecx, 8 |
2162 | shl ecx, 8 |
2165 | add ecx, SLOT_BASE |
2163 | add ecx, SLOT_BASE |
2166 | mov eax, [def_cursor] |
2164 | mov eax, [def_cursor] |
2167 | cmp [ecx+APPDATA.cursor], eax |
2165 | cmp [ecx+APPDATA.cursor], eax |
2168 | je @f |
2166 | je @f |
2169 | call restore_default_cursor_before_killing |
2167 | call restore_default_cursor_before_killing |
2170 | @@: |
2168 | @@: |
2171 | popa |
2169 | popa |
2172 | .restore_end: |
2170 | .restore_end: |
2173 | ;-------------------------------------- |
2171 | ;-------------------------------------- |
2174 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2172 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2175 | mov [ecx], byte 3; clear possible i40's |
2173 | mov [ecx], byte 3; clear possible i40's |
2176 | call wakeup_osloop |
2174 | call wakeup_osloop |
2177 | ;call MEM_Heap_UnLock |
2175 | ;call MEM_Heap_UnLock |
2178 | 2176 | ||
2179 | cmp edx, [application_table_owner]; clear app table stat |
2177 | cmp edx, [application_table_owner]; clear app table stat |
2180 | jne noatsc |
2178 | jne noatsc |
2181 | call unlock_application_table |
2179 | call unlock_application_table |
2182 | noatsc: |
2180 | noatsc: |
2183 | noprocessterminate: |
2181 | noprocessterminate: |
2184 | add esp, 4 |
2182 | add esp, 4 |
2185 | ret |
2183 | ret |
2186 | ;------------------------------------------------------------------------------ |
2184 | ;------------------------------------------------------------------------------ |
2187 | sysfn_terminate2: |
2185 | sysfn_terminate2: |
2188 | ;lock application_table_status mutex |
2186 | ;lock application_table_status mutex |
2189 | .table_status: |
2187 | .table_status: |
2190 | call lock_application_table |
2188 | call lock_application_table |
2191 | mov eax, ecx |
2189 | mov eax, ecx |
2192 | call pid_to_slot |
2190 | call pid_to_slot |
2193 | test eax, eax |
2191 | test eax, eax |
2194 | jz .not_found |
2192 | jz .not_found |
2195 | mov ecx, eax |
2193 | mov ecx, eax |
2196 | cli |
2194 | cli |
2197 | call sysfn_terminate |
2195 | call sysfn_terminate |
2198 | call unlock_application_table |
2196 | call unlock_application_table |
2199 | sti |
2197 | sti |
2200 | and dword [esp+32], 0 |
2198 | and dword [esp+32], 0 |
2201 | ret |
2199 | ret |
2202 | .not_found: |
2200 | .not_found: |
2203 | call unlock_application_table |
2201 | call unlock_application_table |
2204 | or dword [esp+32], -1 |
2202 | or dword [esp+32], -1 |
2205 | ret |
2203 | ret |
2206 | ;------------------------------------------------------------------------------ |
2204 | ;------------------------------------------------------------------------------ |
2207 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2205 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2208 | cmp ecx, 2 |
2206 | cmp ecx, 2 |
2209 | jb .nowindowdeactivate |
2207 | jb .nowindowdeactivate |
2210 | cmp ecx, [TASK_COUNT] |
2208 | cmp ecx, [TASK_COUNT] |
2211 | ja .nowindowdeactivate |
2209 | ja .nowindowdeactivate |
2212 | 2210 | ||
2213 | movzx esi, word [WIN_STACK + ecx*2] |
2211 | movzx esi, word [WIN_STACK + ecx*2] |
2214 | cmp esi, 1 |
2212 | cmp esi, 1 |
2215 | je .nowindowdeactivate ; already deactive |
2213 | je .nowindowdeactivate ; already deactive |
2216 | 2214 | ||
2217 | mov edi, ecx |
2215 | mov edi, ecx |
2218 | shl edi, 5 |
2216 | shl edi, 5 |
2219 | add edi, window_data |
2217 | add edi, window_data |
2220 | movzx esi, word [WIN_STACK + ecx * 2] |
2218 | movzx esi, word [WIN_STACK + ecx * 2] |
2221 | lea esi, [WIN_POS + esi * 2] |
2219 | lea esi, [WIN_POS + esi * 2] |
2222 | call window._.window_deactivate |
2220 | call window._.window_deactivate |
2223 | 2221 | ||
2224 | xor eax, eax |
2222 | xor eax, eax |
2225 | mov byte[MOUSE_BACKGROUND], al |
2223 | mov byte[MOUSE_BACKGROUND], al |
2226 | mov byte[DONT_DRAW_MOUSE], al |
2224 | mov byte[DONT_DRAW_MOUSE], al |
2227 | mov byte[MOUSE_DOWN], 0 |
2225 | mov byte[MOUSE_DOWN], 0 |
2228 | 2226 | ||
2229 | call syscall_display_settings._.calculate_whole_screen |
2227 | call syscall_display_settings._.calculate_whole_screen |
2230 | call syscall_display_settings._.redraw_whole_screen |
2228 | call syscall_display_settings._.redraw_whole_screen |
2231 | .nowindowdeactivate: |
2229 | .nowindowdeactivate: |
2232 | ret |
2230 | ret |
2233 | ;------------------------------------------------------------------------------ |
2231 | ;------------------------------------------------------------------------------ |
2234 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2232 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2235 | cmp ecx, 2 |
2233 | cmp ecx, 2 |
2236 | jb .nowindowactivate |
2234 | jb .nowindowactivate |
2237 | cmp ecx, [TASK_COUNT] |
2235 | cmp ecx, [TASK_COUNT] |
2238 | ja .nowindowactivate |
2236 | ja .nowindowactivate |
2239 | ;------------------------------------- |
2237 | ;------------------------------------- |
2240 | @@: |
2238 | @@: |
2241 | ; If the window is captured and moved by the user, |
2239 | ; If the window is captured and moved by the user, |
2242 | ; then you can't change the position in window stack!!! |
2240 | ; then you can't change the position in window stack!!! |
2243 | mov al, [mouse.active_sys_window.action] |
2241 | mov al, [mouse.active_sys_window.action] |
2244 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2242 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2245 | test al, al |
2243 | test al, al |
2246 | jz @f |
2244 | jz @f |
2247 | call change_task |
2245 | call change_task |
2248 | jmp @b |
2246 | jmp @b |
2249 | @@: |
2247 | @@: |
2250 | ;------------------------------------- |
2248 | ;------------------------------------- |
2251 | mov [window_minimize], 2; restore window if minimized |
2249 | mov [window_minimize], 2; restore window if minimized |
2252 | call wakeup_osloop |
2250 | call wakeup_osloop |
2253 | 2251 | ||
2254 | movzx esi, word [WIN_STACK + ecx*2] |
2252 | movzx esi, word [WIN_STACK + ecx*2] |
2255 | cmp esi, [TASK_COUNT] |
2253 | cmp esi, [TASK_COUNT] |
2256 | je .nowindowactivate; already active |
2254 | je .nowindowactivate; already active |
2257 | 2255 | ||
2258 | mov edi, ecx |
2256 | mov edi, ecx |
2259 | shl edi, 5 |
2257 | shl edi, 5 |
2260 | add edi, window_data |
2258 | add edi, window_data |
2261 | movzx esi, word [WIN_STACK + ecx * 2] |
2259 | movzx esi, word [WIN_STACK + ecx * 2] |
2262 | lea esi, [WIN_POS + esi * 2] |
2260 | lea esi, [WIN_POS + esi * 2] |
2263 | call waredraw |
2261 | call waredraw |
2264 | .nowindowactivate: |
2262 | .nowindowactivate: |
2265 | ret |
2263 | ret |
2266 | ;------------------------------------------------------------------------------ |
2264 | ;------------------------------------------------------------------------------ |
2267 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2265 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2268 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2266 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2269 | mov [esp+32], eax |
2267 | mov [esp+32], eax |
2270 | ret |
2268 | ret |
2271 | ;------------------------------------------------------------------------------ |
2269 | ;------------------------------------------------------------------------------ |
2272 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2270 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2273 | mov eax, dword [cpu_freq] |
2271 | mov eax, dword [cpu_freq] |
2274 | mov [esp+32], eax |
2272 | mov [esp+32], eax |
2275 | ret |
2273 | ret |
2276 | ;------------------------------------------------------------------------------ |
2274 | ;------------------------------------------------------------------------------ |
2277 | get_cpu_freq: |
2275 | get_cpu_freq: |
2278 | mov eax, dword [cpu_freq] |
2276 | mov eax, dword [cpu_freq] |
2279 | mov edx, dword [cpu_freq+4] |
2277 | mov edx, dword [cpu_freq+4] |
2280 | ret |
2278 | ret |
2281 | ; SAVE ramdisk to /hd/1/menuet.img |
2279 | ; SAVE ramdisk to /hd/1/menuet.img |
2282 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2280 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2283 | include 'blkdev/rdsave.inc' |
2281 | include 'blkdev/rdsave.inc' |
2284 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2282 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2285 | ;------------------------------------------------------------------------------ |
2283 | ;------------------------------------------------------------------------------ |
2286 | align 4 |
2284 | align 4 |
2287 | sysfn_getactive: ; 18.7 = get active window |
2285 | sysfn_getactive: ; 18.7 = get active window |
2288 | mov eax, [TASK_COUNT] |
2286 | mov eax, [TASK_COUNT] |
2289 | movzx eax, word [WIN_POS + eax*2] |
2287 | movzx eax, word [WIN_POS + eax*2] |
2290 | mov [esp+32], eax |
2288 | mov [esp+32], eax |
2291 | ret |
2289 | ret |
2292 | ;------------------------------------------------------------------------------ |
2290 | ;------------------------------------------------------------------------------ |
2293 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2291 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2294 | ; cmp ecx,1 |
2292 | ; cmp ecx,1 |
2295 | dec ecx |
2293 | dec ecx |
2296 | jnz nogetsoundflag |
2294 | jnz nogetsoundflag |
2297 | movzx eax, byte [sound_flag]; get sound_flag |
2295 | movzx eax, byte [sound_flag]; get sound_flag |
2298 | mov [esp+32], eax |
2296 | mov [esp+32], eax |
2299 | ret |
2297 | ret |
2300 | nogetsoundflag: |
2298 | nogetsoundflag: |
2301 | ; cmp ecx,2 |
2299 | ; cmp ecx,2 |
2302 | dec ecx |
2300 | dec ecx |
2303 | jnz nosoundflag |
2301 | jnz nosoundflag |
2304 | xor byte [sound_flag], 1 |
2302 | xor byte [sound_flag], 1 |
2305 | nosoundflag: |
2303 | nosoundflag: |
2306 | ret |
2304 | ret |
2307 | ;------------------------------------------------------------------------------ |
2305 | ;------------------------------------------------------------------------------ |
2308 | sysfn_minimize: ; 18.10 = minimize window |
2306 | sysfn_minimize: ; 18.10 = minimize window |
2309 | mov [window_minimize], 1 |
2307 | mov [window_minimize], 1 |
2310 | call wakeup_osloop |
2308 | call wakeup_osloop |
2311 | ret |
2309 | ret |
2312 | ;------------------------------------------------------------------------------ |
2310 | ;------------------------------------------------------------------------------ |
2313 | align 4 |
2311 | align 4 |
2314 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2312 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2315 | ; cmp ecx,1 |
2313 | ; cmp ecx,1 |
2316 | dec ecx |
2314 | dec ecx |
2317 | jnz full_table |
2315 | jnz full_table |
2318 | small_table: |
2316 | small_table: |
2319 | call for_all_tables |
2317 | call for_all_tables |
2320 | mov ecx, 10 |
2318 | mov ecx, 10 |
2321 | cld |
2319 | cld |
2322 | rep movsb |
2320 | rep movsb |
2323 | ret |
2321 | ret |
2324 | for_all_tables: |
2322 | for_all_tables: |
2325 | mov edi, edx |
2323 | mov edi, edx |
2326 | mov esi, DRIVE_DATA |
2324 | mov esi, DRIVE_DATA |
2327 | ret |
2325 | ret |
2328 | full_table: |
2326 | full_table: |
2329 | ; cmp ecx,2 |
2327 | ; cmp ecx,2 |
2330 | dec ecx |
2328 | dec ecx |
2331 | jnz exit_for_anyone |
2329 | jnz exit_for_anyone |
2332 | call for_all_tables |
2330 | call for_all_tables |
2333 | mov ecx, 16384 |
2331 | mov ecx, 16384 |
2334 | cld |
2332 | cld |
2335 | rep movsd |
2333 | rep movsd |
2336 | ret |
2334 | ret |
2337 | ;------------------------------------------------------------------------------ |
2335 | ;------------------------------------------------------------------------------ |
2338 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2336 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2339 | and dword [esp+32], 0 |
2337 | and dword [esp+32], 0 |
2340 | ret |
2338 | ret |
2341 | ;------------------------------------------------------------------------------ |
2339 | ;------------------------------------------------------------------------------ |
2342 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2340 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2343 | mov edi, ecx |
2341 | mov edi, ecx |
2344 | mov esi, version_inf |
2342 | mov esi, version_inf |
2345 | mov ecx, version_end-version_inf |
2343 | mov ecx, version_end-version_inf |
2346 | rep movsb |
2344 | rep movsb |
2347 | ret |
2345 | ret |
2348 | ;------------------------------------------------------------------------------ |
2346 | ;------------------------------------------------------------------------------ |
2349 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2347 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2350 | ;wait retrace functions |
2348 | ;wait retrace functions |
2351 | sys_wait_retrace: |
2349 | sys_wait_retrace: |
2352 | mov edx, 0x3da |
2350 | mov edx, 0x3da |
2353 | WaitRetrace_loop: |
2351 | WaitRetrace_loop: |
2354 | in al, dx |
2352 | in al, dx |
2355 | test al, 1000b |
2353 | test al, 1000b |
2356 | jz WaitRetrace_loop |
2354 | jz WaitRetrace_loop |
2357 | and [esp+32], dword 0 |
2355 | and [esp+32], dword 0 |
2358 | ret |
2356 | ret |
2359 | ;------------------------------------------------------------------------------ |
2357 | ;------------------------------------------------------------------------------ |
2360 | align 4 |
2358 | align 4 |
2361 | sysfn_centermouse: ; 18.15 = mouse centered |
2359 | sysfn_centermouse: ; 18.15 = mouse centered |
2362 | ; removed here by |
2360 | ; removed here by |
2363 | ; call mouse_centered |
2361 | ; call mouse_centered |
2364 | ;* mouse centered - start code- Mario79 |
2362 | ;* mouse centered - start code- Mario79 |
2365 | ;mouse_centered: |
2363 | ;mouse_centered: |
2366 | ; push eax |
2364 | ; push eax |
2367 | mov eax, [Screen_Max_X] |
2365 | mov eax, [Screen_Max_X] |
2368 | shr eax, 1 |
2366 | shr eax, 1 |
2369 | mov [MOUSE_X], ax |
2367 | mov [MOUSE_X], ax |
2370 | mov eax, [Screen_Max_Y] |
2368 | mov eax, [Screen_Max_Y] |
2371 | shr eax, 1 |
2369 | shr eax, 1 |
2372 | mov [MOUSE_Y], ax |
2370 | mov [MOUSE_Y], ax |
2373 | call wakeup_osloop |
2371 | call wakeup_osloop |
2374 | ; ret |
2372 | ; ret |
2375 | ;* mouse centered - end code- Mario79 |
2373 | ;* mouse centered - end code- Mario79 |
2376 | xor eax, eax |
2374 | xor eax, eax |
2377 | and [esp+32], eax |
2375 | and [esp+32], eax |
2378 | ; pop eax |
2376 | ; pop eax |
2379 | ret |
2377 | ret |
2380 | ;------------------------------------------------------------------------------ |
2378 | ;------------------------------------------------------------------------------ |
2381 | align 4 |
2379 | align 4 |
2382 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2380 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2383 | test ecx, ecx; get mouse speed factor |
2381 | test ecx, ecx; get mouse speed factor |
2384 | jnz .set_mouse_acceleration |
2382 | jnz .set_mouse_acceleration |
2385 | xor eax, eax |
2383 | xor eax, eax |
2386 | mov ax, [mouse_speed_factor] |
2384 | mov ax, [mouse_speed_factor] |
2387 | mov [esp+32], eax |
2385 | mov [esp+32], eax |
2388 | ret |
2386 | ret |
2389 | .set_mouse_acceleration: |
2387 | .set_mouse_acceleration: |
2390 | ; cmp ecx,1 ; set mouse speed factor |
2388 | ; cmp ecx,1 ; set mouse speed factor |
2391 | dec ecx |
2389 | dec ecx |
2392 | jnz .get_mouse_delay |
2390 | jnz .get_mouse_delay |
2393 | mov [mouse_speed_factor], dx |
2391 | mov [mouse_speed_factor], dx |
2394 | ret |
2392 | ret |
2395 | .get_mouse_delay: |
2393 | .get_mouse_delay: |
2396 | ; cmp ecx,2 ; get mouse delay |
2394 | ; cmp ecx,2 ; get mouse delay |
2397 | dec ecx |
2395 | dec ecx |
2398 | jnz .set_mouse_delay |
2396 | jnz .set_mouse_delay |
2399 | mov eax, [mouse_delay] |
2397 | mov eax, [mouse_delay] |
2400 | mov [esp+32], eax |
2398 | mov [esp+32], eax |
2401 | ret |
2399 | ret |
2402 | .set_mouse_delay: |
2400 | .set_mouse_delay: |
2403 | ; cmp ecx,3 ; set mouse delay |
2401 | ; cmp ecx,3 ; set mouse delay |
2404 | dec ecx |
2402 | dec ecx |
2405 | jnz .set_pointer_position |
2403 | jnz .set_pointer_position |
2406 | mov [mouse_delay], edx |
2404 | mov [mouse_delay], edx |
2407 | ret |
2405 | ret |
2408 | .set_pointer_position: |
2406 | .set_pointer_position: |
2409 | ; cmp ecx,4 ; set mouse pointer position |
2407 | ; cmp ecx,4 ; set mouse pointer position |
2410 | dec ecx |
2408 | dec ecx |
2411 | jnz .set_mouse_button |
2409 | jnz .set_mouse_button |
2412 | cmp dx, word[Screen_Max_Y] |
2410 | cmp dx, word[Screen_Max_Y] |
2413 | ja .end |
2411 | ja .end |
2414 | rol edx, 16 |
2412 | rol edx, 16 |
2415 | cmp dx, word[Screen_Max_X] |
2413 | cmp dx, word[Screen_Max_X] |
2416 | ja .end |
2414 | ja .end |
2417 | mov [MOUSE_X], edx |
2415 | mov [MOUSE_X], edx |
2418 | call wakeup_osloop |
2416 | call wakeup_osloop |
2419 | ret |
2417 | ret |
2420 | .set_mouse_button: |
2418 | .set_mouse_button: |
2421 | ; cmp ecx,5 ; set mouse button features |
2419 | ; cmp ecx,5 ; set mouse button features |
2422 | dec ecx |
2420 | dec ecx |
2423 | jnz .end |
2421 | jnz .end |
2424 | mov [BTN_DOWN], dl |
2422 | mov [BTN_DOWN], dl |
2425 | mov [mouse_active], 1 |
2423 | mov [mouse_active], 1 |
2426 | call wakeup_osloop |
2424 | call wakeup_osloop |
2427 | .end: |
2425 | .end: |
2428 | ret |
2426 | ret |
2429 | ;------------------------------------------------------------------------------ |
2427 | ;------------------------------------------------------------------------------ |
2430 | sysfn_getfreemem: |
2428 | sysfn_getfreemem: |
2431 | mov eax, [pg_data.pages_free] |
2429 | mov eax, [pg_data.pages_free] |
2432 | shl eax, 2 |
2430 | shl eax, 2 |
2433 | mov [esp+32], eax |
2431 | mov [esp+32], eax |
2434 | ret |
2432 | ret |
2435 | ;------------------------------------------------------------------------------ |
2433 | ;------------------------------------------------------------------------------ |
2436 | sysfn_getallmem: |
2434 | sysfn_getallmem: |
2437 | mov eax, [MEM_AMOUNT] |
2435 | mov eax, [MEM_AMOUNT] |
2438 | shr eax, 10 |
2436 | shr eax, 10 |
2439 | mov [esp+32], eax |
2437 | mov [esp+32], eax |
2440 | ret |
2438 | ret |
2441 | ;------------------------------------------------------------------------------ |
2439 | ;------------------------------------------------------------------------------ |
2442 | sysfn_pid_to_slot: |
2440 | sysfn_pid_to_slot: |
2443 | mov eax, ecx |
2441 | mov eax, ecx |
2444 | call pid_to_slot |
2442 | call pid_to_slot |
2445 | mov [esp+32], eax |
2443 | mov [esp+32], eax |
2446 | ret |
2444 | ret |
2447 | ;------------------------------------------------------------------------------ |
2445 | ;------------------------------------------------------------------------------ |
2448 | sysfn_min_rest_window: |
2446 | sysfn_min_rest_window: |
2449 | pushad |
2447 | pushad |
2450 | mov eax, edx ; ebx - operating |
2448 | mov eax, edx ; ebx - operating |
2451 | shr ecx, 1 |
2449 | shr ecx, 1 |
2452 | jnc @f |
2450 | jnc @f |
2453 | call pid_to_slot |
2451 | call pid_to_slot |
2454 | @@: |
2452 | @@: |
2455 | or eax, eax ; eax - number of slot |
2453 | or eax, eax ; eax - number of slot |
2456 | jz .error |
2454 | jz .error |
2457 | cmp eax, 255 ; varify maximal slot number |
2455 | cmp eax, 255 ; varify maximal slot number |
2458 | ja .error |
2456 | ja .error |
2459 | movzx eax, word [WIN_STACK + eax*2] |
2457 | movzx eax, word [WIN_STACK + eax*2] |
2460 | shr ecx, 1 |
2458 | shr ecx, 1 |
2461 | jc .restore |
2459 | jc .restore |
2462 | ; .minimize: |
2460 | ; .minimize: |
2463 | call minimize_window |
2461 | call minimize_window |
2464 | jmp .exit |
2462 | jmp .exit |
2465 | .restore: |
2463 | .restore: |
2466 | call restore_minimized_window |
2464 | call restore_minimized_window |
2467 | .exit: |
2465 | .exit: |
2468 | popad |
2466 | popad |
2469 | xor eax, eax |
2467 | xor eax, eax |
2470 | mov [esp+32], eax |
2468 | mov [esp+32], eax |
2471 | ret |
2469 | ret |
2472 | .error: |
2470 | .error: |
2473 | popad |
2471 | popad |
2474 | xor eax, eax |
2472 | xor eax, eax |
2475 | dec eax |
2473 | dec eax |
2476 | mov [esp+32], eax |
2474 | mov [esp+32], eax |
2477 | ret |
2475 | ret |
2478 | ;------------------------------------------------------------------------------ |
2476 | ;------------------------------------------------------------------------------ |
2479 | sysfn_min_windows: |
2477 | sysfn_min_windows: |
2480 | call minimize_all_window |
2478 | call minimize_all_window |
2481 | mov [esp+32], eax |
2479 | mov [esp+32], eax |
2482 | call change_task |
2480 | call change_task |
2483 | ret |
2481 | ret |
2484 | ;------------------------------------------------------------------------------ |
2482 | ;------------------------------------------------------------------------------ |
2485 | sysfn_set_screen_sizes: |
2483 | sysfn_set_screen_sizes: |
2486 | cmp [SCR_MODE], word 0x13 |
2484 | cmp [SCR_MODE], word 0x13 |
2487 | jbe .exit |
2485 | jbe .exit |
2488 | 2486 | ||
2489 | cmp [_display.select_cursor], select_cursor |
2487 | cmp [_display.select_cursor], select_cursor |
2490 | jne .exit |
2488 | jne .exit |
2491 | 2489 | ||
2492 | cmp ecx, [display_width_standard] |
2490 | cmp ecx, [display_width_standard] |
2493 | ja .exit |
2491 | ja .exit |
2494 | 2492 | ||
2495 | cmp edx, [display_height_standard] |
2493 | cmp edx, [display_height_standard] |
2496 | ja .exit |
2494 | ja .exit |
2497 | 2495 | ||
2498 | pushfd |
2496 | pushfd |
2499 | cli |
2497 | cli |
2500 | mov eax, ecx |
2498 | mov eax, ecx |
2501 | mov ecx, [BytesPerScanLine] |
2499 | mov ecx, [BytesPerScanLine] |
2502 | mov [_display.width], eax |
2500 | mov [_display.width], eax |
2503 | dec eax |
2501 | dec eax |
2504 | mov [_display.height], edx |
2502 | mov [_display.height], edx |
2505 | dec edx |
2503 | dec edx |
2506 | ; eax - new Screen_Max_X |
2504 | ; eax - new Screen_Max_X |
2507 | ; edx - new Screen_Max_Y |
2505 | ; edx - new Screen_Max_Y |
2508 | mov [do_not_touch_winmap], 1 |
2506 | mov [do_not_touch_winmap], 1 |
2509 | call set_screen |
2507 | call set_screen |
2510 | mov [do_not_touch_winmap], 0 |
2508 | mov [do_not_touch_winmap], 0 |
2511 | popfd |
2509 | popfd |
2512 | call change_task |
2510 | call change_task |
2513 | .exit: |
2511 | .exit: |
2514 | ret |
2512 | ret |
2515 | ;------------------------------------------------------------------------------ |
2513 | ;------------------------------------------------------------------------------ |
2516 | uglobal |
2514 | uglobal |
2517 | screen_workarea RECT |
2515 | screen_workarea RECT |
2518 | display_width_standard dd 0 |
2516 | display_width_standard dd 0 |
2519 | display_height_standard dd 0 |
2517 | display_height_standard dd 0 |
2520 | do_not_touch_winmap db 0 |
2518 | do_not_touch_winmap db 0 |
2521 | window_minimize db 0 |
2519 | window_minimize db 0 |
2522 | sound_flag db 0 |
2520 | sound_flag db 0 |
2523 | 2521 | ||
2524 | endg |
2522 | endg |
2525 | 2523 | ||
2526 | UID_NONE=0 |
2524 | UID_NONE=0 |
2527 | UID_MENUETOS=1 ;official |
2525 | UID_MENUETOS=1 ;official |
2528 | UID_KOLIBRI=2 ;russian |
2526 | UID_KOLIBRI=2 ;russian |
2529 | 2527 | ||
2530 | iglobal |
2528 | iglobal |
2531 | version_inf: |
2529 | version_inf: |
2532 | db 0,7,7,0 ; version 0.7.7.0 |
2530 | db 0,7,7,0 ; version 0.7.7.0 |
2533 | db 0 |
2531 | db 0 |
2534 | .rev dd __REV__ |
2532 | .rev dd __REV__ |
2535 | version_end: |
2533 | version_end: |
2536 | endg |
2534 | endg |
2537 | ;------------------------------------------------------------------------------ |
2535 | ;------------------------------------------------------------------------------ |
2538 | align 4 |
2536 | align 4 |
2539 | sys_cachetodiskette: |
2537 | sys_cachetodiskette: |
2540 | cmp ebx, 1 |
2538 | cmp ebx, 1 |
2541 | jne .no_floppy_a_save |
2539 | jne .no_floppy_a_save |
2542 | mov [flp_number], 1 |
2540 | mov [flp_number], 1 |
2543 | jmp .save_image_on_floppy |
2541 | jmp .save_image_on_floppy |
2544 | ;-------------------------------------- |
2542 | ;-------------------------------------- |
2545 | align 4 |
2543 | align 4 |
2546 | .no_floppy_a_save: |
2544 | .no_floppy_a_save: |
2547 | cmp ebx, 2 |
2545 | cmp ebx, 2 |
2548 | jne .no_floppy_b_save |
2546 | jne .no_floppy_b_save |
2549 | mov [flp_number], 2 |
2547 | mov [flp_number], 2 |
2550 | ;-------------------------------------- |
2548 | ;-------------------------------------- |
2551 | align 4 |
2549 | align 4 |
2552 | .save_image_on_floppy: |
2550 | .save_image_on_floppy: |
2553 | call save_image |
2551 | call save_image |
2554 | mov [esp + 32], dword 0 |
2552 | mov [esp + 32], dword 0 |
2555 | cmp [FDC_Status], 0 |
2553 | cmp [FDC_Status], 0 |
2556 | je .yes_floppy_save |
2554 | je .yes_floppy_save |
2557 | ;-------------------------------------- |
2555 | ;-------------------------------------- |
2558 | align 4 |
2556 | align 4 |
2559 | .no_floppy_b_save: |
2557 | .no_floppy_b_save: |
2560 | mov [esp + 32], dword 1 |
2558 | mov [esp + 32], dword 1 |
2561 | ;-------------------------------------- |
2559 | ;-------------------------------------- |
2562 | align 4 |
2560 | align 4 |
2563 | .yes_floppy_save: |
2561 | .yes_floppy_save: |
2564 | ret |
2562 | ret |
2565 | ;------------------------------------------------------------------------------ |
2563 | ;------------------------------------------------------------------------------ |
2566 | uglobal |
2564 | uglobal |
2567 | ; bgrchanged dd 0x0 |
2565 | ; bgrchanged dd 0x0 |
2568 | align 4 |
2566 | align 4 |
2569 | bgrlockpid dd 0 |
2567 | bgrlockpid dd 0 |
2570 | bgrlock db 0 |
2568 | bgrlock db 0 |
2571 | endg |
2569 | endg |
2572 | ;------------------------------------------------------------------------------ |
2570 | ;------------------------------------------------------------------------------ |
2573 | align 4 |
2571 | align 4 |
2574 | sys_background: |
2572 | sys_background: |
2575 | cmp ebx, 1 ; BACKGROUND SIZE |
2573 | cmp ebx, 1 ; BACKGROUND SIZE |
2576 | jnz nosb1 |
2574 | jnz nosb1 |
2577 | test ecx, ecx |
2575 | test ecx, ecx |
2578 | jz sbgrr |
2576 | jz sbgrr |
2579 | 2577 | ||
2580 | test edx, edx |
2578 | test edx, edx |
2581 | jz sbgrr |
2579 | jz sbgrr |
2582 | ;-------------------------------------- |
2580 | ;-------------------------------------- |
2583 | align 4 |
2581 | align 4 |
2584 | @@: |
2582 | @@: |
2585 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2583 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2586 | bts dword [bgrlock], 0 |
2584 | bts dword [bgrlock], 0 |
2587 | jnc @f |
2585 | jnc @f |
2588 | call change_task |
2586 | call change_task |
2589 | jmp @b |
2587 | jmp @b |
2590 | ;-------------------------------------- |
2588 | ;-------------------------------------- |
2591 | align 4 |
2589 | align 4 |
2592 | @@: |
2590 | @@: |
2593 | mov [BgrDataWidth], ecx |
2591 | mov [BgrDataWidth], ecx |
2594 | mov [BgrDataHeight], edx |
2592 | mov [BgrDataHeight], edx |
2595 | ; mov [bgrchanged],1 |
2593 | ; mov [bgrchanged],1 |
2596 | 2594 | ||
2597 | pushad |
2595 | pushad |
2598 | ; return memory for old background |
2596 | ; return memory for old background |
2599 | mov eax, [img_background] |
2597 | mov eax, [img_background] |
2600 | cmp eax, static_background_data |
2598 | cmp eax, static_background_data |
2601 | jz @f |
2599 | jz @f |
2602 | stdcall kernel_free, eax |
2600 | stdcall kernel_free, eax |
2603 | ;-------------------------------------- |
2601 | ;-------------------------------------- |
2604 | align 4 |
2602 | align 4 |
2605 | @@: |
2603 | @@: |
2606 | ; calculate RAW size |
2604 | ; calculate RAW size |
2607 | xor eax, eax |
2605 | xor eax, eax |
2608 | inc eax |
2606 | inc eax |
2609 | cmp [BgrDataWidth], eax |
2607 | cmp [BgrDataWidth], eax |
2610 | jae @f |
2608 | jae @f |
2611 | mov [BgrDataWidth], eax |
2609 | mov [BgrDataWidth], eax |
2612 | ;-------------------------------------- |
2610 | ;-------------------------------------- |
2613 | align 4 |
2611 | align 4 |
2614 | @@: |
2612 | @@: |
2615 | cmp [BgrDataHeight], eax |
2613 | cmp [BgrDataHeight], eax |
2616 | jae @f |
2614 | jae @f |
2617 | mov [BgrDataHeight], eax |
2615 | mov [BgrDataHeight], eax |
2618 | ;-------------------------------------- |
2616 | ;-------------------------------------- |
2619 | align 4 |
2617 | align 4 |
2620 | @@: |
2618 | @@: |
2621 | mov eax, [BgrDataWidth] |
2619 | mov eax, [BgrDataWidth] |
2622 | imul eax, [BgrDataHeight] |
2620 | imul eax, [BgrDataHeight] |
2623 | lea eax, [eax*3] |
2621 | lea eax, [eax*3] |
2624 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2622 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2625 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2623 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2626 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2624 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2627 | shr eax, 12 |
2625 | shr eax, 12 |
2628 | inc eax |
2626 | inc eax |
2629 | shl eax, 12 |
2627 | shl eax, 12 |
2630 | mov [mem_BACKGROUND], eax |
2628 | mov [mem_BACKGROUND], eax |
2631 | ; get memory for new background |
2629 | ; get memory for new background |
2632 | stdcall kernel_alloc, eax |
2630 | stdcall kernel_alloc, eax |
2633 | test eax, eax |
2631 | test eax, eax |
2634 | jz .memfailed |
2632 | jz .memfailed |
2635 | mov [img_background], eax |
2633 | mov [img_background], eax |
2636 | jmp .exit |
2634 | jmp .exit |
2637 | ;-------------------------------------- |
2635 | ;-------------------------------------- |
2638 | align 4 |
2636 | align 4 |
2639 | .memfailed: |
2637 | .memfailed: |
2640 | ; revert to static monotone data |
2638 | ; revert to static monotone data |
2641 | mov [img_background], static_background_data |
2639 | mov [img_background], static_background_data |
2642 | xor eax, eax |
2640 | xor eax, eax |
2643 | inc eax |
2641 | inc eax |
2644 | mov [BgrDataWidth], eax |
2642 | mov [BgrDataWidth], eax |
2645 | mov [BgrDataHeight], eax |
2643 | mov [BgrDataHeight], eax |
2646 | mov [mem_BACKGROUND], 4 |
2644 | mov [mem_BACKGROUND], 4 |
2647 | ;-------------------------------------- |
2645 | ;-------------------------------------- |
2648 | align 4 |
2646 | align 4 |
2649 | .exit: |
2647 | .exit: |
2650 | popad |
2648 | popad |
2651 | mov [bgrlock], 0 |
2649 | mov [bgrlock], 0 |
2652 | ;-------------------------------------- |
2650 | ;-------------------------------------- |
2653 | align 4 |
2651 | align 4 |
2654 | sbgrr: |
2652 | sbgrr: |
2655 | ret |
2653 | ret |
2656 | ;------------------------------------------------------------------------------ |
2654 | ;------------------------------------------------------------------------------ |
2657 | align 4 |
2655 | align 4 |
2658 | nosb1: |
2656 | nosb1: |
2659 | cmp ebx, 2 ; SET PIXEL |
2657 | cmp ebx, 2 ; SET PIXEL |
2660 | jnz nosb2 |
2658 | jnz nosb2 |
2661 | 2659 | ||
2662 | mov eax, [img_background] |
2660 | mov eax, [img_background] |
2663 | test ecx, ecx |
2661 | test ecx, ecx |
2664 | jz @f |
2662 | jz @f |
2665 | cmp eax, static_background_data |
2663 | cmp eax, static_background_data |
2666 | jz .ret |
2664 | jz .ret |
2667 | ;-------------------------------------- |
2665 | ;-------------------------------------- |
2668 | align 4 |
2666 | align 4 |
2669 | @@: |
2667 | @@: |
2670 | mov ebx, [mem_BACKGROUND] |
2668 | mov ebx, [mem_BACKGROUND] |
2671 | add ebx, 4095 |
2669 | add ebx, 4095 |
2672 | and ebx, -4096 |
2670 | and ebx, -4096 |
2673 | sub ebx, 4 |
2671 | sub ebx, 4 |
2674 | cmp ecx, ebx |
2672 | cmp ecx, ebx |
2675 | ja .ret |
2673 | ja .ret |
2676 | 2674 | ||
2677 | mov ebx, [eax+ecx] |
2675 | mov ebx, [eax+ecx] |
2678 | and ebx, 0xFF000000;255*256*256*256 |
2676 | and ebx, 0xFF000000;255*256*256*256 |
2679 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2677 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2680 | add edx, ebx |
2678 | add edx, ebx |
2681 | mov [eax+ecx], edx |
2679 | mov [eax+ecx], edx |
2682 | ;-------------------------------------- |
2680 | ;-------------------------------------- |
2683 | align 4 |
2681 | align 4 |
2684 | .ret: |
2682 | .ret: |
2685 | ret |
2683 | ret |
2686 | ;------------------------------------------------------------------------------ |
2684 | ;------------------------------------------------------------------------------ |
2687 | align 4 |
2685 | align 4 |
2688 | nosb2: |
2686 | nosb2: |
2689 | cmp ebx, 3 ; DRAW BACKGROUND |
2687 | cmp ebx, 3 ; DRAW BACKGROUND |
2690 | jnz nosb3 |
2688 | jnz nosb3 |
2691 | ;-------------------------------------- |
2689 | ;-------------------------------------- |
2692 | align 4 |
2690 | align 4 |
2693 | draw_background_temp: |
2691 | draw_background_temp: |
2694 | mov [background_defined], 1 |
2692 | mov [background_defined], 1 |
2695 | call force_redraw_background |
2693 | call force_redraw_background |
2696 | ;-------------------------------------- |
2694 | ;-------------------------------------- |
2697 | align 4 |
2695 | align 4 |
2698 | nosb31: |
2696 | nosb31: |
2699 | ret |
2697 | ret |
2700 | ;------------------------------------------------------------------------------ |
2698 | ;------------------------------------------------------------------------------ |
2701 | align 4 |
2699 | align 4 |
2702 | nosb3: |
2700 | nosb3: |
2703 | cmp ebx, 4 ; TILED / STRETCHED |
2701 | cmp ebx, 4 ; TILED / STRETCHED |
2704 | jnz nosb4 |
2702 | jnz nosb4 |
2705 | cmp ecx, [BgrDrawMode] |
2703 | cmp ecx, [BgrDrawMode] |
2706 | je nosb41 |
2704 | je nosb41 |
2707 | mov [BgrDrawMode], ecx |
2705 | mov [BgrDrawMode], ecx |
2708 | ;-------------------------------------- |
2706 | ;-------------------------------------- |
2709 | align 4 |
2707 | align 4 |
2710 | nosb41: |
2708 | nosb41: |
2711 | ret |
2709 | ret |
2712 | ;------------------------------------------------------------------------------ |
2710 | ;------------------------------------------------------------------------------ |
2713 | align 4 |
2711 | align 4 |
2714 | nosb4: |
2712 | nosb4: |
2715 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2713 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2716 | jnz nosb5 |
2714 | jnz nosb5 |
2717 | cmp [img_background], static_background_data |
2715 | cmp [img_background], static_background_data |
2718 | jnz @f |
2716 | jnz @f |
2719 | test edx, edx |
2717 | test edx, edx |
2720 | jnz .fin |
2718 | jnz .fin |
2721 | cmp esi, 4 |
2719 | cmp esi, 4 |
2722 | ja .fin |
2720 | ja .fin |
2723 | ;-------------------------------------- |
2721 | ;-------------------------------------- |
2724 | align 4 |
2722 | align 4 |
2725 | @@: |
2723 | @@: |
2726 | ; bughere |
2724 | ; bughere |
2727 | mov eax, ecx |
2725 | mov eax, ecx |
2728 | mov ebx, edx |
2726 | mov ebx, edx |
2729 | add ebx, [img_background];IMG_BACKGROUND |
2727 | add ebx, [img_background];IMG_BACKGROUND |
2730 | mov ecx, esi |
2728 | mov ecx, esi |
2731 | call memmove |
2729 | call memmove |
2732 | ;-------------------------------------- |
2730 | ;-------------------------------------- |
2733 | align 4 |
2731 | align 4 |
2734 | .fin: |
2732 | .fin: |
2735 | ret |
2733 | ret |
2736 | ;------------------------------------------------------------------------------ |
2734 | ;------------------------------------------------------------------------------ |
2737 | align 4 |
2735 | align 4 |
2738 | nosb5: |
2736 | nosb5: |
2739 | cmp ebx, 6 |
2737 | cmp ebx, 6 |
2740 | jnz nosb6 |
2738 | jnz nosb6 |
2741 | ;-------------------------------------- |
2739 | ;-------------------------------------- |
2742 | align 4 |
2740 | align 4 |
2743 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2741 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2744 | @@: |
2742 | @@: |
2745 | bts dword [bgrlock], 0 |
2743 | bts dword [bgrlock], 0 |
2746 | jnc @f |
2744 | jnc @f |
2747 | call change_task |
2745 | call change_task |
2748 | jmp @b |
2746 | jmp @b |
2749 | ;-------------------------------------- |
2747 | ;-------------------------------------- |
2750 | align 4 |
2748 | align 4 |
2751 | @@: |
2749 | @@: |
2752 | mov eax, [CURRENT_TASK] |
2750 | mov eax, [CURRENT_TASK] |
2753 | mov [bgrlockpid], eax |
2751 | mov [bgrlockpid], eax |
2754 | cmp [img_background], static_background_data |
2752 | cmp [img_background], static_background_data |
2755 | jz .nomem |
2753 | jz .nomem |
2756 | stdcall user_alloc, [mem_BACKGROUND] |
2754 | stdcall user_alloc, [mem_BACKGROUND] |
2757 | mov [esp+32], eax |
2755 | mov [esp+32], eax |
2758 | test eax, eax |
2756 | test eax, eax |
2759 | jz .nomem |
2757 | jz .nomem |
2760 | mov ebx, eax |
2758 | mov ebx, eax |
2761 | shr ebx, 12 |
2759 | shr ebx, 12 |
2762 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2760 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2763 | mov esi, [img_background] |
2761 | mov esi, [img_background] |
2764 | shr esi, 12 |
2762 | shr esi, 12 |
2765 | mov ecx, [mem_BACKGROUND] |
2763 | mov ecx, [mem_BACKGROUND] |
2766 | add ecx, 0xFFF |
2764 | add ecx, 0xFFF |
2767 | shr ecx, 12 |
2765 | shr ecx, 12 |
2768 | ;-------------------------------------- |
2766 | ;-------------------------------------- |
2769 | align 4 |
2767 | align 4 |
2770 | .z: |
2768 | .z: |
2771 | mov eax, [page_tabs+ebx*4] |
2769 | mov eax, [page_tabs+ebx*4] |
2772 | test al, 1 |
2770 | test al, 1 |
2773 | jz @f |
2771 | jz @f |
2774 | call free_page |
2772 | call free_page |
2775 | ;-------------------------------------- |
2773 | ;-------------------------------------- |
2776 | align 4 |
2774 | align 4 |
2777 | @@: |
2775 | @@: |
2778 | mov eax, [page_tabs+esi*4] |
2776 | mov eax, [page_tabs+esi*4] |
2779 | or al, PG_UW |
2777 | or al, PG_UW |
2780 | mov [page_tabs+ebx*4], eax |
2778 | mov [page_tabs+ebx*4], eax |
2781 | mov eax, ebx |
2779 | mov eax, ebx |
2782 | shl eax, 12 |
2780 | shl eax, 12 |
2783 | invlpg [eax] |
2781 | invlpg [eax] |
2784 | inc ebx |
2782 | inc ebx |
2785 | inc esi |
2783 | inc esi |
2786 | loop .z |
2784 | loop .z |
2787 | ret |
2785 | ret |
2788 | ;-------------------------------------- |
2786 | ;-------------------------------------- |
2789 | align 4 |
2787 | align 4 |
2790 | .nomem: |
2788 | .nomem: |
2791 | and [bgrlockpid], 0 |
2789 | and [bgrlockpid], 0 |
2792 | mov [bgrlock], 0 |
2790 | mov [bgrlock], 0 |
2793 | ;------------------------------------------------------------------------------ |
2791 | ;------------------------------------------------------------------------------ |
2794 | align 4 |
2792 | align 4 |
2795 | nosb6: |
2793 | nosb6: |
2796 | cmp ebx, 7 |
2794 | cmp ebx, 7 |
2797 | jnz nosb7 |
2795 | jnz nosb7 |
2798 | cmp [bgrlock], 0 |
2796 | cmp [bgrlock], 0 |
2799 | jz .err |
2797 | jz .err |
2800 | mov eax, [CURRENT_TASK] |
2798 | mov eax, [CURRENT_TASK] |
2801 | cmp [bgrlockpid], eax |
2799 | cmp [bgrlockpid], eax |
2802 | jnz .err |
2800 | jnz .err |
2803 | mov eax, ecx |
2801 | mov eax, ecx |
2804 | mov ebx, ecx |
2802 | mov ebx, ecx |
2805 | shr eax, 12 |
2803 | shr eax, 12 |
2806 | mov ecx, [page_tabs+(eax-1)*4] |
2804 | mov ecx, [page_tabs+(eax-1)*4] |
2807 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2805 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2808 | jz .err |
2806 | jz .err |
2809 | jnp .err |
2807 | jnp .err |
2810 | push eax |
2808 | push eax |
2811 | shr ecx, 12 |
2809 | shr ecx, 12 |
2812 | dec ecx |
2810 | dec ecx |
2813 | ;-------------------------------------- |
2811 | ;-------------------------------------- |
2814 | align 4 |
2812 | align 4 |
2815 | @@: |
2813 | @@: |
2816 | and dword [page_tabs+eax*4], 0 |
2814 | and dword [page_tabs+eax*4], 0 |
2817 | mov edx, eax |
2815 | mov edx, eax |
2818 | shl edx, 12 |
2816 | shl edx, 12 |
2819 | push eax |
2817 | push eax |
2820 | invlpg [edx] |
2818 | invlpg [edx] |
2821 | pop eax |
2819 | pop eax |
2822 | inc eax |
2820 | inc eax |
2823 | loop @b |
2821 | loop @b |
2824 | pop eax |
2822 | pop eax |
2825 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2823 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2826 | stdcall user_free, ebx |
2824 | stdcall user_free, ebx |
2827 | mov [esp+32], eax |
2825 | mov [esp+32], eax |
2828 | and [bgrlockpid], 0 |
2826 | and [bgrlockpid], 0 |
2829 | mov [bgrlock], 0 |
2827 | mov [bgrlock], 0 |
2830 | ret |
2828 | ret |
2831 | ;-------------------------------------- |
2829 | ;-------------------------------------- |
2832 | align 4 |
2830 | align 4 |
2833 | .err: |
2831 | .err: |
2834 | and dword [esp+32], 0 |
2832 | and dword [esp+32], 0 |
2835 | ret |
2833 | ret |
2836 | ;------------------------------------------------------------------------------ |
2834 | ;------------------------------------------------------------------------------ |
2837 | align 4 |
2835 | align 4 |
2838 | nosb7: |
2836 | nosb7: |
2839 | cmp ebx, 8 |
2837 | cmp ebx, 8 |
2840 | jnz nosb8 |
2838 | jnz nosb8 |
2841 | 2839 | ||
2842 | mov ecx, [current_slot] |
2840 | mov ecx, [current_slot] |
2843 | xor eax, eax |
2841 | xor eax, eax |
2844 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2842 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2845 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2843 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2846 | xor eax, eax |
2844 | xor eax, eax |
2847 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2845 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2848 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2846 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2849 | ret |
2847 | ret |
2850 | ;------------------------------------------------------------------------------ |
2848 | ;------------------------------------------------------------------------------ |
2851 | align 4 |
2849 | align 4 |
2852 | nosb8: |
2850 | nosb8: |
2853 | cmp ebx, 9 |
2851 | cmp ebx, 9 |
2854 | jnz nosb9 |
2852 | jnz nosb9 |
2855 | ; ecx = [left]*65536 + [right] |
2853 | ; ecx = [left]*65536 + [right] |
2856 | ; edx = [top]*65536 + [bottom] |
2854 | ; edx = [top]*65536 + [bottom] |
2857 | mov eax, [Screen_Max_X] |
2855 | mov eax, [Screen_Max_X] |
2858 | mov ebx, [Screen_Max_Y] |
2856 | mov ebx, [Screen_Max_Y] |
2859 | ; check [right] |
2857 | ; check [right] |
2860 | cmp cx, ax |
2858 | cmp cx, ax |
2861 | ja .exit |
2859 | ja .exit |
2862 | ; check [left] |
2860 | ; check [left] |
2863 | ror ecx, 16 |
2861 | ror ecx, 16 |
2864 | cmp cx, ax |
2862 | cmp cx, ax |
2865 | ja .exit |
2863 | ja .exit |
2866 | ; check [bottom] |
2864 | ; check [bottom] |
2867 | cmp dx, bx |
2865 | cmp dx, bx |
2868 | ja .exit |
2866 | ja .exit |
2869 | ; check [top] |
2867 | ; check [top] |
2870 | ror edx, 16 |
2868 | ror edx, 16 |
2871 | cmp dx, bx |
2869 | cmp dx, bx |
2872 | ja .exit |
2870 | ja .exit |
2873 | 2871 | ||
2874 | movzx eax, cx ; [left] |
2872 | movzx eax, cx ; [left] |
2875 | movzx ebx, dx ; [top] |
2873 | movzx ebx, dx ; [top] |
2876 | 2874 | ||
2877 | shr ecx, 16 ; [right] |
2875 | shr ecx, 16 ; [right] |
2878 | shr edx, 16 ; [bottom] |
2876 | shr edx, 16 ; [bottom] |
2879 | 2877 | ||
2880 | mov [background_defined], 1 |
2878 | mov [background_defined], 1 |
2881 | 2879 | ||
2882 | mov [draw_data+32 + RECT.left], eax |
2880 | mov [draw_data+32 + RECT.left], eax |
2883 | mov [draw_data+32 + RECT.top], ebx |
2881 | mov [draw_data+32 + RECT.top], ebx |
2884 | 2882 | ||
2885 | mov [draw_data+32 + RECT.right], ecx |
2883 | mov [draw_data+32 + RECT.right], ecx |
2886 | mov [draw_data+32 + RECT.bottom], edx |
2884 | mov [draw_data+32 + RECT.bottom], edx |
2887 | 2885 | ||
2888 | inc byte[REDRAW_BACKGROUND] |
2886 | inc byte[REDRAW_BACKGROUND] |
2889 | call wakeup_osloop |
2887 | call wakeup_osloop |
2890 | ;-------------------------------------- |
2888 | ;-------------------------------------- |
2891 | align 4 |
2889 | align 4 |
2892 | .exit: |
2890 | .exit: |
2893 | ret |
2891 | ret |
2894 | ;------------------------------------------------------------------------------ |
2892 | ;------------------------------------------------------------------------------ |
2895 | align 4 |
2893 | align 4 |
2896 | nosb9: |
2894 | nosb9: |
2897 | ret |
2895 | ret |
2898 | ;------------------------------------------------------------------------------ |
2896 | ;------------------------------------------------------------------------------ |
2899 | align 4 |
2897 | align 4 |
2900 | uglobal |
2898 | uglobal |
2901 | BG_Rect_X_left_right dd 0x0 |
2899 | BG_Rect_X_left_right dd 0x0 |
2902 | BG_Rect_Y_top_bottom dd 0x0 |
2900 | BG_Rect_Y_top_bottom dd 0x0 |
2903 | endg |
2901 | endg |
2904 | ;------------------------------------------------------------------------------ |
2902 | ;------------------------------------------------------------------------------ |
2905 | align 4 |
2903 | align 4 |
2906 | force_redraw_background: |
2904 | force_redraw_background: |
2907 | and [draw_data+32 + RECT.left], 0 |
2905 | and [draw_data+32 + RECT.left], 0 |
2908 | and [draw_data+32 + RECT.top], 0 |
2906 | and [draw_data+32 + RECT.top], 0 |
2909 | push eax ebx |
2907 | push eax ebx |
2910 | mov eax, [Screen_Max_X] |
2908 | mov eax, [Screen_Max_X] |
2911 | mov ebx, [Screen_Max_Y] |
2909 | mov ebx, [Screen_Max_Y] |
2912 | mov [draw_data+32 + RECT.right], eax |
2910 | mov [draw_data+32 + RECT.right], eax |
2913 | mov [draw_data+32 + RECT.bottom], ebx |
2911 | mov [draw_data+32 + RECT.bottom], ebx |
2914 | pop ebx eax |
2912 | pop ebx eax |
2915 | inc byte[REDRAW_BACKGROUND] |
2913 | inc byte[REDRAW_BACKGROUND] |
2916 | call wakeup_osloop |
2914 | call wakeup_osloop |
2917 | ret |
2915 | ret |
2918 | ;------------------------------------------------------------------------------ |
2916 | ;------------------------------------------------------------------------------ |
2919 | align 4 |
2917 | align 4 |
2920 | sys_getbackground: |
2918 | sys_getbackground: |
2921 | ; cmp eax,1 ; SIZE |
2919 | ; cmp eax,1 ; SIZE |
2922 | dec ebx |
2920 | dec ebx |
2923 | jnz nogb1 |
2921 | jnz nogb1 |
2924 | mov eax, [BgrDataWidth] |
2922 | mov eax, [BgrDataWidth] |
2925 | shl eax, 16 |
2923 | shl eax, 16 |
2926 | mov ax, [BgrDataHeight] |
2924 | mov ax, [BgrDataHeight] |
2927 | mov [esp+32], eax |
2925 | mov [esp+32], eax |
2928 | ret |
2926 | ret |
2929 | ;------------------------------------------------------------------------------ |
2927 | ;------------------------------------------------------------------------------ |
2930 | align 4 |
2928 | align 4 |
2931 | nogb1: |
2929 | nogb1: |
2932 | ; cmp eax,2 ; PIXEL |
2930 | ; cmp eax,2 ; PIXEL |
2933 | dec ebx |
2931 | dec ebx |
2934 | jnz nogb2 |
2932 | jnz nogb2 |
2935 | 2933 | ||
2936 | mov eax, [img_background] |
2934 | mov eax, [img_background] |
2937 | test ecx, ecx |
2935 | test ecx, ecx |
2938 | jz @f |
2936 | jz @f |
2939 | cmp eax, static_background_data |
2937 | cmp eax, static_background_data |
2940 | jz .ret |
2938 | jz .ret |
2941 | ;-------------------------------------- |
2939 | ;-------------------------------------- |
2942 | align 4 |
2940 | align 4 |
2943 | @@: |
2941 | @@: |
2944 | mov ebx, [mem_BACKGROUND] |
2942 | mov ebx, [mem_BACKGROUND] |
2945 | add ebx, 4095 |
2943 | add ebx, 4095 |
2946 | and ebx, -4096 |
2944 | and ebx, -4096 |
2947 | sub ebx, 4 |
2945 | sub ebx, 4 |
2948 | cmp ecx, ebx |
2946 | cmp ecx, ebx |
2949 | ja .ret |
2947 | ja .ret |
2950 | 2948 | ||
2951 | mov eax, [ecx+eax] |
2949 | mov eax, [ecx+eax] |
2952 | 2950 | ||
2953 | and eax, 0xFFFFFF |
2951 | and eax, 0xFFFFFF |
2954 | mov [esp+32], eax |
2952 | mov [esp+32], eax |
2955 | ;-------------------------------------- |
2953 | ;-------------------------------------- |
2956 | align 4 |
2954 | align 4 |
2957 | .ret: |
2955 | .ret: |
2958 | ret |
2956 | ret |
2959 | ;------------------------------------------------------------------------------ |
2957 | ;------------------------------------------------------------------------------ |
2960 | align 4 |
2958 | align 4 |
2961 | nogb2: |
2959 | nogb2: |
2962 | 2960 | ||
2963 | ; cmp eax,4 ; TILED / STRETCHED |
2961 | ; cmp eax,4 ; TILED / STRETCHED |
2964 | dec ebx |
2962 | dec ebx |
2965 | dec ebx |
2963 | dec ebx |
2966 | jnz nogb4 |
2964 | jnz nogb4 |
2967 | mov eax, [BgrDrawMode] |
2965 | mov eax, [BgrDrawMode] |
2968 | ;-------------------------------------- |
2966 | ;-------------------------------------- |
2969 | align 4 |
2967 | align 4 |
2970 | nogb4: |
2968 | nogb4: |
2971 | mov [esp+32], eax |
2969 | mov [esp+32], eax |
2972 | ret |
2970 | ret |
2973 | ;------------------------------------------------------------------------------ |
2971 | ;------------------------------------------------------------------------------ |
2974 | align 4 |
2972 | align 4 |
2975 | sys_getkey: |
2973 | sys_getkey: |
2976 | mov [esp + 32], dword 1 |
2974 | mov [esp + 32], dword 1 |
2977 | ; test main buffer |
2975 | ; test main buffer |
2978 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2976 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2979 | movzx ecx, word [WIN_STACK + ebx * 2] |
2977 | movzx ecx, word [WIN_STACK + ebx * 2] |
2980 | mov edx, [TASK_COUNT] |
2978 | mov edx, [TASK_COUNT] |
2981 | cmp ecx, edx |
2979 | cmp ecx, edx |
2982 | jne .finish |
2980 | jne .finish |
2983 | cmp [KEY_COUNT], byte 0 |
2981 | cmp [KEY_COUNT], byte 0 |
2984 | je .finish |
2982 | je .finish |
2985 | movzx eax, byte [KEY_BUFF] |
2983 | movzx eax, byte [KEY_BUFF] |
2986 | shl eax, 8 |
2984 | shl eax, 8 |
2987 | push eax |
2985 | push eax |
2988 | dec byte [KEY_COUNT] |
2986 | dec byte [KEY_COUNT] |
2989 | and byte [KEY_COUNT], 127 |
2987 | and byte [KEY_COUNT], 127 |
2990 | movzx ecx, byte [KEY_COUNT] |
2988 | movzx ecx, byte [KEY_COUNT] |
2991 | add ecx, 2 |
2989 | add ecx, 2 |
2992 | mov eax, KEY_BUFF + 1 |
2990 | mov eax, KEY_BUFF + 1 |
2993 | mov ebx, KEY_BUFF |
2991 | mov ebx, KEY_BUFF |
2994 | call memmove |
2992 | call memmove |
2995 | pop eax |
2993 | pop eax |
2996 | ;-------------------------------------- |
2994 | ;-------------------------------------- |
2997 | align 4 |
2995 | align 4 |
2998 | .ret_eax: |
2996 | .ret_eax: |
2999 | mov [esp + 32], eax |
2997 | mov [esp + 32], eax |
3000 | ret |
2998 | ret |
3001 | ;-------------------------------------- |
2999 | ;-------------------------------------- |
3002 | align 4 |
3000 | align 4 |
3003 | .finish: |
3001 | .finish: |
3004 | ; test hotkeys buffer |
3002 | ; test hotkeys buffer |
3005 | mov ecx, hotkey_buffer |
3003 | mov ecx, hotkey_buffer |
3006 | ;-------------------------------------- |
3004 | ;-------------------------------------- |
3007 | align 4 |
3005 | align 4 |
3008 | @@: |
3006 | @@: |
3009 | cmp [ecx], ebx |
3007 | cmp [ecx], ebx |
3010 | jz .found |
3008 | jz .found |
3011 | add ecx, 8 |
3009 | add ecx, 8 |
3012 | cmp ecx, hotkey_buffer + 120 * 8 |
3010 | cmp ecx, hotkey_buffer + 120 * 8 |
3013 | jb @b |
3011 | jb @b |
3014 | ret |
3012 | ret |
3015 | ;-------------------------------------- |
3013 | ;-------------------------------------- |
3016 | align 4 |
3014 | align 4 |
3017 | .found: |
3015 | .found: |
3018 | mov ax, [ecx + 6] |
3016 | mov ax, [ecx + 6] |
3019 | shl eax, 16 |
3017 | shl eax, 16 |
3020 | mov ah, [ecx + 4] |
3018 | mov ah, [ecx + 4] |
3021 | mov al, 2 |
3019 | mov al, 2 |
3022 | and dword [ecx + 4], 0 |
3020 | and dword [ecx + 4], 0 |
3023 | and dword [ecx], 0 |
3021 | and dword [ecx], 0 |
3024 | jmp .ret_eax |
3022 | jmp .ret_eax |
3025 | ;------------------------------------------------------------------------------ |
3023 | ;------------------------------------------------------------------------------ |
3026 | align 4 |
3024 | align 4 |
3027 | sys_getbutton: |
3025 | sys_getbutton: |
3028 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3026 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3029 | mov [esp + 32], dword 1 |
3027 | mov [esp + 32], dword 1 |
3030 | movzx ecx, word [WIN_STACK + ebx * 2] |
3028 | movzx ecx, word [WIN_STACK + ebx * 2] |
3031 | mov edx, [TASK_COUNT] ; less than 256 processes |
3029 | mov edx, [TASK_COUNT] ; less than 256 processes |
3032 | cmp ecx, edx |
3030 | cmp ecx, edx |
3033 | jne .exit |
3031 | jne .exit |
3034 | movzx eax, byte [BTN_COUNT] |
3032 | movzx eax, byte [BTN_COUNT] |
3035 | test eax, eax |
3033 | test eax, eax |
3036 | jz .exit |
3034 | jz .exit |
3037 | mov eax, [BTN_BUFF] |
3035 | mov eax, [BTN_BUFF] |
3038 | and al, 0xFE ; delete left button bit |
3036 | and al, 0xFE ; delete left button bit |
3039 | mov [BTN_COUNT], byte 0 |
3037 | mov [BTN_COUNT], byte 0 |
3040 | mov [esp + 32], eax |
3038 | mov [esp + 32], eax |
3041 | ;-------------------------------------- |
3039 | ;-------------------------------------- |
3042 | align 4 |
3040 | align 4 |
3043 | .exit: |
3041 | .exit: |
3044 | ret |
3042 | ret |
3045 | ;------------------------------------------------------------------------------ |
3043 | ;------------------------------------------------------------------------------ |
3046 | align 4 |
3044 | align 4 |
3047 | sys_cpuusage: |
3045 | sys_cpuusage: |
3048 | 3046 | ||
3049 | ; RETURN: |
3047 | ; RETURN: |
3050 | ; |
3048 | ; |
3051 | ; +00 dword process cpu usage |
3049 | ; +00 dword process cpu usage |
3052 | ; +04 word position in windowing stack |
3050 | ; +04 word position in windowing stack |
3053 | ; +06 word windowing stack value at current position (cpu nro) |
3051 | ; +06 word windowing stack value at current position (cpu nro) |
3054 | ; +10 12 bytes name |
3052 | ; +10 12 bytes name |
3055 | ; +22 dword start in mem |
3053 | ; +22 dword start in mem |
3056 | ; +26 dword used mem |
3054 | ; +26 dword used mem |
3057 | ; +30 dword PID , process idenfification number |
3055 | ; +30 dword PID , process idenfification number |
3058 | ; |
3056 | ; |
3059 | 3057 | ||
3060 | cmp ecx, -1 ; who am I ? |
3058 | cmp ecx, -1 ; who am I ? |
3061 | jne .no_who_am_i |
3059 | jne .no_who_am_i |
3062 | mov ecx, [CURRENT_TASK] |
3060 | mov ecx, [CURRENT_TASK] |
3063 | .no_who_am_i: |
3061 | .no_who_am_i: |
3064 | cmp ecx, max_processes |
3062 | cmp ecx, max_processes |
3065 | ja .nofillbuf |
3063 | ja .nofillbuf |
3066 | 3064 | ||
3067 | ; +4: word: position of the window of thread in the window stack |
3065 | ; +4: word: position of the window of thread in the window stack |
3068 | mov ax, [WIN_STACK + ecx * 2] |
3066 | mov ax, [WIN_STACK + ecx * 2] |
3069 | mov [ebx+4], ax |
3067 | mov [ebx+4], ax |
3070 | ; +6: word: number of the thread slot, which window has in the window stack |
3068 | ; +6: word: number of the thread slot, which window has in the window stack |
3071 | ; position ecx (has no relation to the specific thread) |
3069 | ; position ecx (has no relation to the specific thread) |
3072 | mov ax, [WIN_POS + ecx * 2] |
3070 | mov ax, [WIN_POS + ecx * 2] |
3073 | mov [ebx+6], ax |
3071 | mov [ebx+6], ax |
3074 | 3072 | ||
3075 | shl ecx, 5 |
3073 | shl ecx, 5 |
3076 | 3074 | ||
3077 | ; +0: dword: memory usage |
3075 | ; +0: dword: memory usage |
3078 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3076 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3079 | mov [ebx], eax |
3077 | mov [ebx], eax |
3080 | ; +10: 11 bytes: name of the process |
3078 | ; +10: 11 bytes: name of the process |
3081 | push ecx |
3079 | push ecx |
3082 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3080 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3083 | add ebx, 10 |
3081 | add ebx, 10 |
3084 | mov ecx, 11 |
3082 | mov ecx, 11 |
3085 | call memmove |
3083 | call memmove |
3086 | pop ecx |
3084 | pop ecx |
3087 | 3085 | ||
3088 | ; +22: address of the process in memory |
3086 | ; +22: address of the process in memory |
3089 | ; +26: size of used memory - 1 |
3087 | ; +26: size of used memory - 1 |
3090 | push edi |
3088 | push edi |
3091 | lea edi, [ebx+12] |
3089 | lea edi, [ebx+12] |
3092 | xor eax, eax |
3090 | xor eax, eax |
3093 | mov edx, 0x100000*16 |
3091 | mov edx, 0x100000*16 |
3094 | cmp ecx, 1 shl 5 |
3092 | cmp ecx, 1 shl 5 |
3095 | je .os_mem |
3093 | je .os_mem |
3096 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3094 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3097 | mov eax, std_application_base_address |
3095 | mov eax, std_application_base_address |
3098 | .os_mem: |
3096 | .os_mem: |
3099 | stosd |
3097 | stosd |
3100 | lea eax, [edx-1] |
3098 | lea eax, [edx-1] |
3101 | stosd |
3099 | stosd |
3102 | 3100 | ||
3103 | ; +30: PID/TID |
3101 | ; +30: PID/TID |
3104 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3102 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3105 | stosd |
3103 | stosd |
3106 | 3104 | ||
3107 | ; window position and size |
3105 | ; window position and size |
3108 | push esi |
3106 | push esi |
3109 | lea esi, [ecx + window_data + WDATA.box] |
3107 | lea esi, [ecx + window_data + WDATA.box] |
3110 | movsd |
3108 | movsd |
3111 | movsd |
3109 | movsd |
3112 | movsd |
3110 | movsd |
3113 | movsd |
3111 | movsd |
3114 | 3112 | ||
3115 | ; Process state (+50) |
3113 | ; Process state (+50) |
3116 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3114 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3117 | stosd |
3115 | stosd |
3118 | 3116 | ||
3119 | ; Window client area box |
3117 | ; Window client area box |
3120 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3118 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3121 | movsd |
3119 | movsd |
3122 | movsd |
3120 | movsd |
3123 | movsd |
3121 | movsd |
3124 | movsd |
3122 | movsd |
3125 | 3123 | ||
3126 | ; Window state |
3124 | ; Window state |
3127 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3125 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3128 | stosb |
3126 | stosb |
3129 | 3127 | ||
3130 | ; Event mask (+71) |
3128 | ; Event mask (+71) |
3131 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3129 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3132 | stosd |
3130 | stosd |
3133 | 3131 | ||
3134 | pop esi |
3132 | pop esi |
3135 | pop edi |
3133 | pop edi |
3136 | 3134 | ||
3137 | .nofillbuf: |
3135 | .nofillbuf: |
3138 | ; return number of processes |
3136 | ; return number of processes |
3139 | 3137 | ||
3140 | mov eax, [TASK_COUNT] |
3138 | mov eax, [TASK_COUNT] |
3141 | mov [esp+32], eax |
3139 | mov [esp+32], eax |
3142 | ret |
3140 | ret |
3143 | 3141 | ||
3144 | align 4 |
3142 | align 4 |
3145 | sys_clock: |
3143 | sys_clock: |
3146 | cli |
3144 | cli |
3147 | ; Mikhail Lisovin xx Jan 2005 |
3145 | ; Mikhail Lisovin xx Jan 2005 |
3148 | @@: |
3146 | @@: |
3149 | mov al, 10 |
3147 | mov al, 10 |
3150 | out 0x70, al |
3148 | out 0x70, al |
3151 | in al, 0x71 |
3149 | in al, 0x71 |
3152 | test al, al |
3150 | test al, al |
3153 | jns @f |
3151 | jns @f |
3154 | mov esi, 1 |
3152 | mov esi, 1 |
3155 | call delay_ms |
3153 | call delay_ms |
3156 | jmp @b |
3154 | jmp @b |
3157 | @@: |
3155 | @@: |
3158 | ; end Lisovin's fix |
3156 | ; end Lisovin's fix |
3159 | 3157 | ||
3160 | xor al, al ; seconds |
3158 | xor al, al ; seconds |
3161 | out 0x70, al |
3159 | out 0x70, al |
3162 | in al, 0x71 |
3160 | in al, 0x71 |
3163 | movzx ecx, al |
3161 | movzx ecx, al |
3164 | mov al, 02 ; minutes |
3162 | mov al, 02 ; minutes |
3165 | shl ecx, 16 |
3163 | shl ecx, 16 |
3166 | out 0x70, al |
3164 | out 0x70, al |
3167 | in al, 0x71 |
3165 | in al, 0x71 |
3168 | movzx edx, al |
3166 | movzx edx, al |
3169 | mov al, 04 ; hours |
3167 | mov al, 04 ; hours |
3170 | shl edx, 8 |
3168 | shl edx, 8 |
3171 | out 0x70, al |
3169 | out 0x70, al |
3172 | in al, 0x71 |
3170 | in al, 0x71 |
3173 | add ecx, edx |
3171 | add ecx, edx |
3174 | movzx edx, al |
3172 | movzx edx, al |
3175 | add ecx, edx |
3173 | add ecx, edx |
3176 | sti |
3174 | sti |
3177 | mov [esp + 32], ecx |
3175 | mov [esp + 32], ecx |
3178 | ret |
3176 | ret |
3179 | 3177 | ||
3180 | 3178 | ||
3181 | align 4 |
3179 | align 4 |
3182 | 3180 | ||
3183 | sys_date: |
3181 | sys_date: |
3184 | 3182 | ||
3185 | cli |
3183 | cli |
3186 | @@: |
3184 | @@: |
3187 | mov al, 10 |
3185 | mov al, 10 |
3188 | out 0x70, al |
3186 | out 0x70, al |
3189 | in al, 0x71 |
3187 | in al, 0x71 |
3190 | test al, al |
3188 | test al, al |
3191 | jns @f |
3189 | jns @f |
3192 | mov esi, 1 |
3190 | mov esi, 1 |
3193 | call delay_ms |
3191 | call delay_ms |
3194 | jmp @b |
3192 | jmp @b |
3195 | @@: |
3193 | @@: |
3196 | 3194 | ||
3197 | mov ch, 0 |
3195 | mov ch, 0 |
3198 | mov al, 7 ; date |
3196 | mov al, 7 ; date |
3199 | out 0x70, al |
3197 | out 0x70, al |
3200 | in al, 0x71 |
3198 | in al, 0x71 |
3201 | mov cl, al |
3199 | mov cl, al |
3202 | mov al, 8 ; month |
3200 | mov al, 8 ; month |
3203 | shl ecx, 16 |
3201 | shl ecx, 16 |
3204 | out 0x70, al |
3202 | out 0x70, al |
3205 | in al, 0x71 |
3203 | in al, 0x71 |
3206 | mov ch, al |
3204 | mov ch, al |
3207 | mov al, 9 ; year |
3205 | mov al, 9 ; year |
3208 | out 0x70, al |
3206 | out 0x70, al |
3209 | in al, 0x71 |
3207 | in al, 0x71 |
3210 | mov cl, al |
3208 | mov cl, al |
3211 | sti |
3209 | sti |
3212 | mov [esp+32], ecx |
3210 | mov [esp+32], ecx |
3213 | ret |
3211 | ret |
3214 | 3212 | ||
3215 | 3213 | ||
3216 | ; redraw status |
3214 | ; redraw status |
3217 | 3215 | ||
3218 | sys_redrawstat: |
3216 | sys_redrawstat: |
3219 | cmp ebx, 1 |
3217 | cmp ebx, 1 |
3220 | jne no_widgets_away |
3218 | jne no_widgets_away |
3221 | ; buttons away |
3219 | ; buttons away |
3222 | mov ecx, [CURRENT_TASK] |
3220 | mov ecx, [CURRENT_TASK] |
3223 | sys_newba2: |
3221 | sys_newba2: |
3224 | mov edi, [BTN_ADDR] |
3222 | mov edi, [BTN_ADDR] |
3225 | cmp [edi], dword 0 ; empty button list ? |
3223 | cmp [edi], dword 0 ; empty button list ? |
3226 | je end_of_buttons_away |
3224 | je end_of_buttons_away |
3227 | movzx ebx, word [edi] |
3225 | movzx ebx, word [edi] |
3228 | inc ebx |
3226 | inc ebx |
3229 | mov eax, edi |
3227 | mov eax, edi |
3230 | sys_newba: |
3228 | sys_newba: |
3231 | dec ebx |
3229 | dec ebx |
3232 | jz end_of_buttons_away |
3230 | jz end_of_buttons_away |
3233 | 3231 | ||
3234 | add eax, 0x10 |
3232 | add eax, 0x10 |
3235 | cmp cx, [eax] |
3233 | cmp cx, [eax] |
3236 | jnz sys_newba |
3234 | jnz sys_newba |
3237 | 3235 | ||
3238 | push eax ebx ecx |
3236 | push eax ebx ecx |
3239 | mov ecx, ebx |
3237 | mov ecx, ebx |
3240 | inc ecx |
3238 | inc ecx |
3241 | shl ecx, 4 |
3239 | shl ecx, 4 |
3242 | mov ebx, eax |
3240 | mov ebx, eax |
3243 | add eax, 0x10 |
3241 | add eax, 0x10 |
3244 | call memmove |
3242 | call memmove |
3245 | dec dword [edi] |
3243 | dec dword [edi] |
3246 | pop ecx ebx eax |
3244 | pop ecx ebx eax |
3247 | 3245 | ||
3248 | jmp sys_newba2 |
3246 | jmp sys_newba2 |
3249 | 3247 | ||
3250 | end_of_buttons_away: |
3248 | end_of_buttons_away: |
3251 | 3249 | ||
3252 | ret |
3250 | ret |
3253 | 3251 | ||
3254 | no_widgets_away: |
3252 | no_widgets_away: |
3255 | 3253 | ||
3256 | cmp ebx, 2 |
3254 | cmp ebx, 2 |
3257 | jnz srl1 |
3255 | jnz srl1 |
3258 | 3256 | ||
3259 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3257 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3260 | add edx, draw_data - CURRENT_TASK |
3258 | add edx, draw_data - CURRENT_TASK |
3261 | mov [edx + RECT.left], 0 |
3259 | mov [edx + RECT.left], 0 |
3262 | mov [edx + RECT.top], 0 |
3260 | mov [edx + RECT.top], 0 |
3263 | mov eax, [Screen_Max_X] |
3261 | mov eax, [Screen_Max_X] |
3264 | mov [edx + RECT.right], eax |
3262 | mov [edx + RECT.right], eax |
3265 | mov eax, [Screen_Max_Y] |
3263 | mov eax, [Screen_Max_Y] |
3266 | mov [edx + RECT.bottom], eax |
3264 | mov [edx + RECT.bottom], eax |
3267 | 3265 | ||
3268 | srl1: |
3266 | srl1: |
3269 | ret |
3267 | ret |
3270 | 3268 | ||
3271 | ;ok - 100% work |
3269 | ;ok - 100% work |
3272 | ;nt - not tested |
3270 | ;nt - not tested |
3273 | ;--------------------------------------------------------------------------------------------- |
3271 | ;--------------------------------------------------------------------------------------------- |
3274 | ;eax |
3272 | ;eax |
3275 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3273 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3276 | ;1 - change task. Ret nothing. Block. ok. |
3274 | ;1 - change task. Ret nothing. Block. ok. |
3277 | ;2 - performance control |
3275 | ;2 - performance control |
3278 | ; ebx |
3276 | ; ebx |
3279 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3277 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3280 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3278 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3281 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3279 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3282 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3280 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3283 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3281 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3284 | ;eax |
3282 | ;eax |
3285 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3283 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3286 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3284 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3287 | ;--------------------------------------------------------------------------------------------- |
3285 | ;--------------------------------------------------------------------------------------------- |
3288 | iglobal |
3286 | iglobal |
3289 | align 4 |
3287 | align 4 |
3290 | sheduler: |
3288 | sheduler: |
3291 | dd sys_sheduler.00 |
3289 | dd sys_sheduler.00 |
3292 | dd change_task |
3290 | dd change_task |
3293 | dd sys_sheduler.02 |
3291 | dd sys_sheduler.02 |
3294 | dd sys_sheduler.03 |
3292 | dd sys_sheduler.03 |
3295 | dd sys_sheduler.04 |
3293 | dd sys_sheduler.04 |
3296 | endg |
3294 | endg |
3297 | sys_sheduler: |
3295 | sys_sheduler: |
3298 | ;rewritten by |
3296 | ;rewritten by |
3299 | jmp dword [sheduler+ebx*4] |
3297 | jmp dword [sheduler+ebx*4] |
3300 | ;.shed_counter: |
3298 | ;.shed_counter: |
3301 | .00: |
3299 | .00: |
3302 | mov eax, [context_counter] |
3300 | mov eax, [context_counter] |
3303 | mov [esp+32], eax |
3301 | mov [esp+32], eax |
3304 | ret |
3302 | ret |
3305 | 3303 | ||
3306 | .02: |
3304 | .02: |
3307 | ;.perf_control: |
3305 | ;.perf_control: |
3308 | inc ebx ;before ebx=2, ebx=3 |
3306 | inc ebx ;before ebx=2, ebx=3 |
3309 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3307 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3310 | jz cache_disable |
3308 | jz cache_disable |
3311 | 3309 | ||
3312 | dec ebx ;ebx=2 |
3310 | dec ebx ;ebx=2 |
3313 | cmp ebx, ecx ; |
3311 | cmp ebx, ecx ; |
3314 | jz cache_enable ;if ecx=2 and ebx=2 |
3312 | jz cache_enable ;if ecx=2 and ebx=2 |
3315 | 3313 | ||
3316 | dec ebx ;ebx=1 |
3314 | dec ebx ;ebx=1 |
3317 | cmp ebx, ecx |
3315 | cmp ebx, ecx |
3318 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3316 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3319 | 3317 | ||
3320 | dec ebx |
3318 | dec ebx |
3321 | test ebx, ecx ;ebx=0 and ecx=0 |
3319 | test ebx, ecx ;ebx=0 and ecx=0 |
3322 | jz modify_pce ;if ecx=0 |
3320 | jz modify_pce ;if ecx=0 |
3323 | 3321 | ||
3324 | ret |
3322 | ret |
3325 | 3323 | ||
3326 | .03: |
3324 | .03: |
3327 | ;.rdmsr_instr: |
3325 | ;.rdmsr_instr: |
3328 | ;now counter in ecx |
3326 | ;now counter in ecx |
3329 | ;(edx:eax) esi:edi => edx:esi |
3327 | ;(edx:eax) esi:edi => edx:esi |
3330 | mov eax, esi |
3328 | mov eax, esi |
3331 | mov ecx, edx |
3329 | mov ecx, edx |
3332 | rdmsr |
3330 | rdmsr |
3333 | mov [esp+32], eax |
3331 | mov [esp+32], eax |
3334 | mov [esp+20], edx ;ret in ebx? |
3332 | mov [esp+20], edx ;ret in ebx? |
3335 | ret |
3333 | ret |
3336 | 3334 | ||
3337 | .04: |
3335 | .04: |
3338 | ;.wrmsr_instr: |
3336 | ;.wrmsr_instr: |
3339 | ;now counter in ecx |
3337 | ;now counter in ecx |
3340 | ;(edx:eax) esi:edi => edx:esi |
3338 | ;(edx:eax) esi:edi => edx:esi |
3341 | ; Fast Call MSR can't be destroy |
3339 | ; Fast Call MSR can't be destroy |
3342 | ; ® MSR_AMD_EFER ¬®¦® ¨§¬¥ïâì, â.ª. ¢ í⮬ ॣ¨áâॠ«¨è |
3340 | ; ® MSR_AMD_EFER ¬®¦® ¨§¬¥ïâì, â.ª. ¢ í⮬ ॣ¨áâॠ«¨è |
3343 | ; ¢ª«îç îâáï/¢ëª«îç îâáï à áè¨à¥ë¥ ¢®§¬®¦®á⨠|
3341 | ; ¢ª«îç îâáï/¢ëª«îç îâáï à áè¨à¥ë¥ ¢®§¬®¦®á⨠|
3344 | cmp edx, MSR_SYSENTER_CS |
3342 | cmp edx, MSR_SYSENTER_CS |
3345 | je @f |
3343 | je @f |
3346 | cmp edx, MSR_SYSENTER_ESP |
3344 | cmp edx, MSR_SYSENTER_ESP |
3347 | je @f |
3345 | je @f |
3348 | cmp edx, MSR_SYSENTER_EIP |
3346 | cmp edx, MSR_SYSENTER_EIP |
3349 | je @f |
3347 | je @f |
3350 | cmp edx, MSR_AMD_STAR |
3348 | cmp edx, MSR_AMD_STAR |
3351 | je @f |
3349 | je @f |
3352 | 3350 | ||
3353 | mov eax, esi |
3351 | mov eax, esi |
3354 | mov ecx, edx |
3352 | mov ecx, edx |
3355 | wrmsr |
3353 | wrmsr |
3356 | ; mov [esp + 32], eax |
3354 | ; mov [esp + 32], eax |
3357 | ; mov [esp + 20], edx ;ret in ebx? |
3355 | ; mov [esp + 20], edx ;ret in ebx? |
3358 | @@: |
3356 | @@: |
3359 | ret |
3357 | ret |
3360 | 3358 | ||
3361 | cache_disable: |
3359 | cache_disable: |
3362 | mov eax, cr0 |
3360 | mov eax, cr0 |
3363 | or eax, 01100000000000000000000000000000b |
3361 | or eax, 01100000000000000000000000000000b |
3364 | mov cr0, eax |
3362 | mov cr0, eax |
3365 | wbinvd ;set MESI |
3363 | wbinvd ;set MESI |
3366 | ret |
3364 | ret |
3367 | 3365 | ||
3368 | cache_enable: |
3366 | cache_enable: |
3369 | mov eax, cr0 |
3367 | mov eax, cr0 |
3370 | and eax, 10011111111111111111111111111111b |
3368 | and eax, 10011111111111111111111111111111b |
3371 | mov cr0, eax |
3369 | mov cr0, eax |
3372 | ret |
3370 | ret |
3373 | 3371 | ||
3374 | is_cache_enabled: |
3372 | is_cache_enabled: |
3375 | mov eax, cr0 |
3373 | mov eax, cr0 |
3376 | mov ebx, eax |
3374 | mov ebx, eax |
3377 | and eax, 01100000000000000000000000000000b |
3375 | and eax, 01100000000000000000000000000000b |
3378 | jz cache_disabled |
3376 | jz cache_disabled |
3379 | mov [esp+32], ebx |
3377 | mov [esp+32], ebx |
3380 | cache_disabled: |
3378 | cache_disabled: |
3381 | mov dword [esp+32], eax;0 |
3379 | mov dword [esp+32], eax;0 |
3382 | ret |
3380 | ret |
3383 | 3381 | ||
3384 | modify_pce: |
3382 | modify_pce: |
3385 | mov eax, cr4 |
3383 | mov eax, cr4 |
3386 | ; mov ebx,0 |
3384 | ; mov ebx,0 |
3387 | ; or bx,100000000b ;pce |
3385 | ; or bx,100000000b ;pce |
3388 | ; xor eax,ebx ;invert pce |
3386 | ; xor eax,ebx ;invert pce |
3389 | bts eax, 8;pce=cr4[8] |
3387 | bts eax, 8;pce=cr4[8] |
3390 | mov cr4, eax |
3388 | mov cr4, eax |
3391 | mov [esp+32], eax |
3389 | mov [esp+32], eax |
3392 | ret |
3390 | ret |
3393 | ;--------------------------------------------------------------------------------------------- |
3391 | ;--------------------------------------------------------------------------------------------- |
3394 | 3392 | ||
3395 | 3393 | ||
3396 | ; check if pixel is allowed to be drawn |
3394 | ; check if pixel is allowed to be drawn |
3397 | 3395 | ||
3398 | ;checkpixel: |
3396 | ;checkpixel: |
3399 | ; push eax edx |
3397 | ; push eax edx |
3400 | 3398 | ||
3401 | ;; mov edx, [Screen_Max_X] ; screen x size |
3399 | ;; mov edx, [Screen_Max_X] ; screen x size |
3402 | ;; inc edx |
3400 | ;; inc edx |
3403 | ;; imul edx, ebx |
3401 | ;; imul edx, ebx |
3404 | ; mov edx, [d_width_calc_area + ebx*4] |
3402 | ; mov edx, [d_width_calc_area + ebx*4] |
3405 | ; add eax, [_WinMapAddress] |
3403 | ; add eax, [_WinMapAddress] |
3406 | ; mov dl, [eax+edx]; lea eax, [...] |
3404 | ; mov dl, [eax+edx]; lea eax, [...] |
3407 | 3405 | ||
3408 | ; xor ecx, ecx |
3406 | ; xor ecx, ecx |
3409 | ; mov eax, [CURRENT_TASK] |
3407 | ; mov eax, [CURRENT_TASK] |
3410 | ; cmp al, dl |
3408 | ; cmp al, dl |
3411 | ; setne cl |
3409 | ; setne cl |
3412 | 3410 | ||
3413 | ; pop edx eax |
3411 | ; pop edx eax |
3414 | ; ret |
3412 | ; ret |
3415 | 3413 | ||
3416 | iglobal |
3414 | iglobal |
3417 | cpustring db 'CPU',0 |
3415 | cpustring db 'CPU',0 |
3418 | endg |
3416 | endg |
3419 | 3417 | ||
3420 | uglobal |
3418 | uglobal |
3421 | background_defined db 0 ; diamond, 11.04.2006 |
3419 | background_defined db 0 ; diamond, 11.04.2006 |
3422 | endg |
3420 | endg |
3423 | ;----------------------------------------------------------------------------- |
3421 | ;----------------------------------------------------------------------------- |
3424 | align 4 |
3422 | align 4 |
3425 | checkmisc: |
3423 | checkmisc: |
3426 | cmp [ctrl_alt_del], 1 |
3424 | cmp [ctrl_alt_del], 1 |
3427 | jne nocpustart |
3425 | jne nocpustart |
3428 | 3426 | ||
3429 | mov ebp, cpustring |
3427 | mov ebp, cpustring |
3430 | call fs_execute_from_sysdir |
3428 | call fs_execute_from_sysdir |
3431 | 3429 | ||
3432 | mov [ctrl_alt_del], 0 |
3430 | mov [ctrl_alt_del], 0 |
3433 | ;-------------------------------------- |
3431 | ;-------------------------------------- |
3434 | align 4 |
3432 | align 4 |
3435 | nocpustart: |
3433 | nocpustart: |
3436 | cmp [mouse_active], 1 |
3434 | cmp [mouse_active], 1 |
3437 | jne mouse_not_active |
3435 | jne mouse_not_active |
3438 | mov [mouse_active], 0 |
3436 | mov [mouse_active], 0 |
3439 | 3437 | ||
3440 | xor edi, edi |
3438 | xor edi, edi |
3441 | mov ebx, CURRENT_TASK |
3439 | mov ebx, CURRENT_TASK |
3442 | 3440 | ||
3443 | mov ecx, [TASK_COUNT] |
3441 | mov ecx, [TASK_COUNT] |
3444 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3442 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3445 | shl eax, 8 |
3443 | shl eax, 8 |
3446 | push eax |
3444 | push eax |
3447 | 3445 | ||
3448 | movzx eax, word [MOUSE_X] |
3446 | movzx eax, word [MOUSE_X] |
3449 | movzx edx, word [MOUSE_Y] |
3447 | movzx edx, word [MOUSE_Y] |
3450 | ;-------------------------------------- |
3448 | ;-------------------------------------- |
3451 | align 4 |
3449 | align 4 |
3452 | .set_mouse_event: |
3450 | .set_mouse_event: |
3453 | add edi, 256 |
3451 | add edi, 256 |
3454 | add ebx, 32 |
3452 | add ebx, 32 |
3455 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3453 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3456 | jz .pos_filter |
3454 | jz .pos_filter |
3457 | 3455 | ||
3458 | cmp edi, [esp] ; skip if filtration active |
3456 | cmp edi, [esp] ; skip if filtration active |
3459 | jne .skip |
3457 | jne .skip |
3460 | ;-------------------------------------- |
3458 | ;-------------------------------------- |
3461 | align 4 |
3459 | align 4 |
3462 | .pos_filter: |
3460 | .pos_filter: |
3463 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3461 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3464 | jz .set |
3462 | jz .set |
3465 | 3463 | ||
3466 | mov esi, [ebx-twdw+WDATA.box.left] |
3464 | mov esi, [ebx-twdw+WDATA.box.left] |
3467 | cmp eax, esi |
3465 | cmp eax, esi |
3468 | jb .skip |
3466 | jb .skip |
3469 | add esi, [ebx-twdw+WDATA.box.width] |
3467 | add esi, [ebx-twdw+WDATA.box.width] |
3470 | cmp eax, esi |
3468 | cmp eax, esi |
3471 | ja .skip |
3469 | ja .skip |
3472 | 3470 | ||
3473 | mov esi, [ebx-twdw+WDATA.box.top] |
3471 | mov esi, [ebx-twdw+WDATA.box.top] |
3474 | cmp edx, esi |
3472 | cmp edx, esi |
3475 | jb .skip |
3473 | jb .skip |
3476 | add esi, [ebx-twdw+WDATA.box.height] |
3474 | add esi, [ebx-twdw+WDATA.box.height] |
3477 | cmp edx, esi |
3475 | cmp edx, esi |
3478 | ja .skip |
3476 | ja .skip |
3479 | ;-------------------------------------- |
3477 | ;-------------------------------------- |
3480 | align 4 |
3478 | align 4 |
3481 | .set: |
3479 | .set: |
3482 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3480 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3483 | ;-------------------------------------- |
3481 | ;-------------------------------------- |
3484 | align 4 |
3482 | align 4 |
3485 | .skip: |
3483 | .skip: |
3486 | loop .set_mouse_event |
3484 | loop .set_mouse_event |
3487 | 3485 | ||
3488 | pop eax |
3486 | pop eax |
3489 | ;-------------------------------------- |
3487 | ;-------------------------------------- |
3490 | align 4 |
3488 | align 4 |
3491 | mouse_not_active: |
3489 | mouse_not_active: |
3492 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3490 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3493 | jz nobackgr |
3491 | jz nobackgr |
3494 | 3492 | ||
3495 | cmp [background_defined], 0 |
3493 | cmp [background_defined], 0 |
3496 | jz nobackgr |
3494 | jz nobackgr |
3497 | ;-------------------------------------- |
3495 | ;-------------------------------------- |
3498 | align 4 |
3496 | align 4 |
3499 | backgr: |
3497 | backgr: |
3500 | mov eax, [draw_data+32 + RECT.left] |
3498 | mov eax, [draw_data+32 + RECT.left] |
3501 | shl eax, 16 |
3499 | shl eax, 16 |
3502 | add eax, [draw_data+32 + RECT.right] |
3500 | add eax, [draw_data+32 + RECT.right] |
3503 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3501 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3504 | 3502 | ||
3505 | mov eax, [draw_data+32 + RECT.top] |
3503 | mov eax, [draw_data+32 + RECT.top] |
3506 | shl eax, 16 |
3504 | shl eax, 16 |
3507 | add eax, [draw_data+32 + RECT.bottom] |
3505 | add eax, [draw_data+32 + RECT.bottom] |
3508 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3506 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3509 | 3507 | ||
3510 | call drawbackground |
3508 | call drawbackground |
3511 | ; DEBUGF 1, "K : drawbackground\n" |
3509 | ; DEBUGF 1, "K : drawbackground\n" |
3512 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3510 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3513 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3511 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3514 | ;--------- set event 5 start ---------- |
3512 | ;--------- set event 5 start ---------- |
3515 | push ecx edi |
3513 | push ecx edi |
3516 | xor edi, edi |
3514 | xor edi, edi |
3517 | mov ecx, [TASK_COUNT] |
3515 | mov ecx, [TASK_COUNT] |
3518 | ;-------------------------------------- |
3516 | ;-------------------------------------- |
3519 | align 4 |
3517 | align 4 |
3520 | set_bgr_event: |
3518 | set_bgr_event: |
3521 | add edi, 256 |
3519 | add edi, 256 |
3522 | mov eax, [BG_Rect_X_left_right] |
3520 | mov eax, [BG_Rect_X_left_right] |
3523 | mov edx, [BG_Rect_Y_top_bottom] |
3521 | mov edx, [BG_Rect_Y_top_bottom] |
3524 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3522 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3525 | jz .set |
3523 | jz .set |
3526 | .join: |
3524 | .join: |
3527 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3525 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3528 | jbe @f |
3526 | jbe @f |
3529 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3527 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3530 | @@: |
3528 | @@: |
3531 | shr eax, 16 |
3529 | shr eax, 16 |
3532 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3530 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3533 | jae @f |
3531 | jae @f |
3534 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3532 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3535 | @@: |
3533 | @@: |
3536 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3534 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3537 | jbe @f |
3535 | jbe @f |
3538 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3536 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3539 | @@: |
3537 | @@: |
3540 | shr edx, 16 |
3538 | shr edx, 16 |
3541 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3539 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3542 | jae @f |
3540 | jae @f |
3543 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3541 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3544 | @@: |
3542 | @@: |
3545 | jmp .common |
3543 | jmp .common |
3546 | .set: |
3544 | .set: |
3547 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3545 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3548 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3546 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3549 | .common: |
3547 | .common: |
3550 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3548 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3551 | loop set_bgr_event |
3549 | loop set_bgr_event |
3552 | pop edi ecx |
3550 | pop edi ecx |
3553 | ;--------- set event 5 stop ----------- |
3551 | ;--------- set event 5 stop ----------- |
3554 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3552 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3555 | jnz backgr |
3553 | jnz backgr |
3556 | 3554 | ||
3557 | xor eax, eax |
3555 | xor eax, eax |
3558 | mov [draw_data+32 + RECT.left], eax |
3556 | mov [draw_data+32 + RECT.left], eax |
3559 | mov [draw_data+32 + RECT.top], eax |
3557 | mov [draw_data+32 + RECT.top], eax |
3560 | mov [draw_data+32 + RECT.right], eax |
3558 | mov [draw_data+32 + RECT.right], eax |
3561 | mov [draw_data+32 + RECT.bottom], eax |
3559 | mov [draw_data+32 + RECT.bottom], eax |
3562 | mov [MOUSE_BACKGROUND], byte 0 |
3560 | mov [MOUSE_BACKGROUND], byte 0 |
3563 | ;-------------------------------------- |
3561 | ;-------------------------------------- |
3564 | align 4 |
3562 | align 4 |
3565 | nobackgr: |
3563 | nobackgr: |
3566 | ; system shutdown request |
3564 | ; system shutdown request |
3567 | cmp [SYS_SHUTDOWN], byte 0 |
3565 | cmp [SYS_SHUTDOWN], byte 0 |
3568 | je noshutdown |
3566 | je noshutdown |
3569 | 3567 | ||
3570 | mov edx, [shutdown_processes] |
3568 | mov edx, [shutdown_processes] |
3571 | 3569 | ||
3572 | cmp [SYS_SHUTDOWN], dl |
3570 | cmp [SYS_SHUTDOWN], dl |
3573 | jne noshutdown |
3571 | jne noshutdown |
3574 | 3572 | ||
3575 | lea ecx, [edx-1] |
3573 | lea ecx, [edx-1] |
3576 | mov edx, OS_BASE+0x3040 |
3574 | mov edx, OS_BASE+0x3040 |
3577 | jecxz no_mark_system_shutdown |
3575 | jecxz no_mark_system_shutdown |
3578 | ;-------------------------------------- |
3576 | ;-------------------------------------- |
3579 | align 4 |
3577 | align 4 |
3580 | markz: |
3578 | markz: |
3581 | push ecx edx |
3579 | push ecx edx |
3582 | cmp [edx+TASKDATA.state], 9 |
3580 | cmp [edx+TASKDATA.state], 9 |
3583 | jz .nokill |
3581 | jz .nokill |
3584 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3582 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3585 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3583 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3586 | jz .nokill |
3584 | jz .nokill |
3587 | call request_terminate |
3585 | call request_terminate |
3588 | jmp .common |
3586 | jmp .common |
3589 | .nokill: |
3587 | .nokill: |
3590 | dec byte [SYS_SHUTDOWN] |
3588 | dec byte [SYS_SHUTDOWN] |
3591 | xor eax, eax |
3589 | xor eax, eax |
3592 | .common: |
3590 | .common: |
3593 | pop edx ecx |
3591 | pop edx ecx |
3594 | test eax, eax |
3592 | test eax, eax |
3595 | jz @f |
3593 | jz @f |
3596 | mov [edx+TASKDATA.state], byte 3 |
3594 | mov [edx+TASKDATA.state], byte 3 |
3597 | @@: |
3595 | @@: |
3598 | add edx, 0x20 |
3596 | add edx, 0x20 |
3599 | loop markz |
3597 | loop markz |
3600 | call wakeup_osloop |
3598 | call wakeup_osloop |
3601 | ;-------------------------------------- |
3599 | ;-------------------------------------- |
3602 | align 4 |
3600 | align 4 |
3603 | @@: |
3601 | @@: |
3604 | no_mark_system_shutdown: |
3602 | no_mark_system_shutdown: |
3605 | dec byte [SYS_SHUTDOWN] |
3603 | dec byte [SYS_SHUTDOWN] |
3606 | je system_shutdown |
3604 | je system_shutdown |
3607 | ;-------------------------------------- |
3605 | ;-------------------------------------- |
3608 | align 4 |
3606 | align 4 |
3609 | noshutdown: |
3607 | noshutdown: |
3610 | mov eax, [TASK_COUNT] ; termination |
3608 | mov eax, [TASK_COUNT] ; termination |
3611 | mov ebx, TASK_DATA+TASKDATA.state |
3609 | mov ebx, TASK_DATA+TASKDATA.state |
3612 | mov esi, 1 |
3610 | mov esi, 1 |
3613 | ;-------------------------------------- |
3611 | ;-------------------------------------- |
3614 | align 4 |
3612 | align 4 |
3615 | newct: |
3613 | newct: |
3616 | mov cl, [ebx] |
3614 | mov cl, [ebx] |
3617 | cmp cl, byte 3 |
3615 | cmp cl, byte 3 |
3618 | jz .terminate |
3616 | jz .terminate |
3619 | 3617 | ||
3620 | cmp cl, byte 4 |
3618 | cmp cl, byte 4 |
3621 | jnz .noterminate |
3619 | jnz .noterminate |
3622 | .terminate: |
3620 | .terminate: |
3623 | pushad |
3621 | pushad |
3624 | mov ecx, eax |
3622 | mov ecx, eax |
3625 | shl ecx, 8 |
3623 | shl ecx, 8 |
3626 | add ecx, SLOT_BASE |
3624 | add ecx, SLOT_BASE |
3627 | call restore_default_cursor_before_killing |
3625 | call restore_default_cursor_before_killing |
3628 | popad |
3626 | popad |
3629 | 3627 | ||
3630 | pushad |
3628 | pushad |
3631 | call terminate |
3629 | call terminate |
3632 | popad |
3630 | popad |
3633 | cmp byte [SYS_SHUTDOWN], 0 |
3631 | cmp byte [SYS_SHUTDOWN], 0 |
3634 | jz .noterminate |
3632 | jz .noterminate |
3635 | dec byte [SYS_SHUTDOWN] |
3633 | dec byte [SYS_SHUTDOWN] |
3636 | je system_shutdown |
3634 | je system_shutdown |
3637 | 3635 | ||
3638 | .noterminate: |
3636 | .noterminate: |
3639 | add ebx, 0x20 |
3637 | add ebx, 0x20 |
3640 | inc esi |
3638 | inc esi |
3641 | dec eax |
3639 | dec eax |
3642 | jnz newct |
3640 | jnz newct |
3643 | ret |
3641 | ret |
3644 | ;----------------------------------------------------------------------------- |
3642 | ;----------------------------------------------------------------------------- |
3645 | align 4 |
3643 | align 4 |
3646 | redrawscreen: |
3644 | redrawscreen: |
3647 | ; eax , if process window_data base is eax, do not set flag/limits |
3645 | ; eax , if process window_data base is eax, do not set flag/limits |
3648 | 3646 | ||
3649 | pushad |
3647 | pushad |
3650 | push eax |
3648 | push eax |
3651 | 3649 | ||
3652 | ;;; mov ebx,2 |
3650 | ;;; mov ebx,2 |
3653 | ;;; call delay_hs |
3651 | ;;; call delay_hs |
3654 | 3652 | ||
3655 | ;mov ecx,0 ; redraw flags for apps |
3653 | ;mov ecx,0 ; redraw flags for apps |
3656 | xor ecx, ecx |
3654 | xor ecx, ecx |
3657 | ;-------------------------------------- |
3655 | ;-------------------------------------- |
3658 | align 4 |
3656 | align 4 |
3659 | newdw2: |
3657 | newdw2: |
3660 | inc ecx |
3658 | inc ecx |
3661 | push ecx |
3659 | push ecx |
3662 | 3660 | ||
3663 | mov eax, ecx |
3661 | mov eax, ecx |
3664 | shl eax, 5 |
3662 | shl eax, 5 |
3665 | add eax, window_data |
3663 | add eax, window_data |
3666 | 3664 | ||
3667 | cmp eax, [esp+4] |
3665 | cmp eax, [esp+4] |
3668 | je not_this_task |
3666 | je not_this_task |
3669 | ; check if window in redraw area |
3667 | ; check if window in redraw area |
3670 | mov edi, eax |
3668 | mov edi, eax |
3671 | 3669 | ||
3672 | cmp ecx, 1 ; limit for background |
3670 | cmp ecx, 1 ; limit for background |
3673 | jz bgli |
3671 | jz bgli |
3674 | 3672 | ||
3675 | mov eax, [edi + WDATA.box.left] |
3673 | mov eax, [edi + WDATA.box.left] |
3676 | mov ebx, [edi + WDATA.box.top] |
3674 | mov ebx, [edi + WDATA.box.top] |
3677 | mov ecx, [edi + WDATA.box.width] |
3675 | mov ecx, [edi + WDATA.box.width] |
3678 | mov edx, [edi + WDATA.box.height] |
3676 | mov edx, [edi + WDATA.box.height] |
3679 | add ecx, eax |
3677 | add ecx, eax |
3680 | add edx, ebx |
3678 | add edx, ebx |
3681 | 3679 | ||
3682 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3680 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3683 | cmp ecx, ebx |
3681 | cmp ecx, ebx |
3684 | jb ricino |
3682 | jb ricino |
3685 | 3683 | ||
3686 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3684 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3687 | cmp ecx, eax |
3685 | cmp ecx, eax |
3688 | jb ricino |
3686 | jb ricino |
3689 | 3687 | ||
3690 | mov eax, [edi + WDATA.box.left] |
3688 | mov eax, [edi + WDATA.box.left] |
3691 | mov ebx, [edi + WDATA.box.top] |
3689 | mov ebx, [edi + WDATA.box.top] |
3692 | mov ecx, [edi + WDATA.box.width] |
3690 | mov ecx, [edi + WDATA.box.width] |
3693 | mov edx, [edi + WDATA.box.height] |
3691 | mov edx, [edi + WDATA.box.height] |
3694 | add ecx, eax |
3692 | add ecx, eax |
3695 | add edx, ebx |
3693 | add edx, ebx |
3696 | 3694 | ||
3697 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3695 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3698 | cmp edx, eax |
3696 | cmp edx, eax |
3699 | jb ricino |
3697 | jb ricino |
3700 | 3698 | ||
3701 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3699 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3702 | cmp ecx, eax |
3700 | cmp ecx, eax |
3703 | jb ricino |
3701 | jb ricino |
3704 | ;-------------------------------------- |
3702 | ;-------------------------------------- |
3705 | align 4 |
3703 | align 4 |
3706 | bgli: |
3704 | bgli: |
3707 | cmp dword[esp], 1 |
3705 | cmp dword[esp], 1 |
3708 | jnz .az |
3706 | jnz .az |
3709 | 3707 | ||
3710 | cmp byte[REDRAW_BACKGROUND], 0 |
3708 | cmp byte[REDRAW_BACKGROUND], 0 |
3711 | jz .az |
3709 | jz .az |
3712 | 3710 | ||
3713 | mov dl, 0 |
3711 | mov dl, 0 |
3714 | lea eax, [edi+draw_data-window_data] |
3712 | lea eax, [edi+draw_data-window_data] |
3715 | mov ebx, [draw_limits.left] |
3713 | mov ebx, [draw_limits.left] |
3716 | cmp ebx, [eax+RECT.left] |
3714 | cmp ebx, [eax+RECT.left] |
3717 | jae @f |
3715 | jae @f |
3718 | 3716 | ||
3719 | mov [eax+RECT.left], ebx |
3717 | mov [eax+RECT.left], ebx |
3720 | mov dl, 1 |
3718 | mov dl, 1 |
3721 | ;-------------------------------------- |
3719 | ;-------------------------------------- |
3722 | align 4 |
3720 | align 4 |
3723 | @@: |
3721 | @@: |
3724 | mov ebx, [draw_limits.top] |
3722 | mov ebx, [draw_limits.top] |
3725 | cmp ebx, [eax+RECT.top] |
3723 | cmp ebx, [eax+RECT.top] |
3726 | jae @f |
3724 | jae @f |
3727 | 3725 | ||
3728 | mov [eax+RECT.top], ebx |
3726 | mov [eax+RECT.top], ebx |
3729 | mov dl, 1 |
3727 | mov dl, 1 |
3730 | ;-------------------------------------- |
3728 | ;-------------------------------------- |
3731 | align 4 |
3729 | align 4 |
3732 | @@: |
3730 | @@: |
3733 | mov ebx, [draw_limits.right] |
3731 | mov ebx, [draw_limits.right] |
3734 | cmp ebx, [eax+RECT.right] |
3732 | cmp ebx, [eax+RECT.right] |
3735 | jbe @f |
3733 | jbe @f |
3736 | 3734 | ||
3737 | mov [eax+RECT.right], ebx |
3735 | mov [eax+RECT.right], ebx |
3738 | mov dl, 1 |
3736 | mov dl, 1 |
3739 | ;-------------------------------------- |
3737 | ;-------------------------------------- |
3740 | align 4 |
3738 | align 4 |
3741 | @@: |
3739 | @@: |
3742 | mov ebx, [draw_limits.bottom] |
3740 | mov ebx, [draw_limits.bottom] |
3743 | cmp ebx, [eax+RECT.bottom] |
3741 | cmp ebx, [eax+RECT.bottom] |
3744 | jbe @f |
3742 | jbe @f |
3745 | 3743 | ||
3746 | mov [eax+RECT.bottom], ebx |
3744 | mov [eax+RECT.bottom], ebx |
3747 | mov dl, 1 |
3745 | mov dl, 1 |
3748 | ;-------------------------------------- |
3746 | ;-------------------------------------- |
3749 | align 4 |
3747 | align 4 |
3750 | @@: |
3748 | @@: |
3751 | add byte[REDRAW_BACKGROUND], dl |
3749 | add byte[REDRAW_BACKGROUND], dl |
3752 | call wakeup_osloop |
3750 | call wakeup_osloop |
3753 | jmp newdw8 |
3751 | jmp newdw8 |
3754 | ;-------------------------------------- |
3752 | ;-------------------------------------- |
3755 | align 4 |
3753 | align 4 |
3756 | .az: |
3754 | .az: |
3757 | mov eax, edi |
3755 | mov eax, edi |
3758 | add eax, draw_data-window_data |
3756 | add eax, draw_data-window_data |
3759 | 3757 | ||
3760 | mov ebx, [draw_limits.left] ; set limits |
3758 | mov ebx, [draw_limits.left] ; set limits |
3761 | mov [eax + RECT.left], ebx |
3759 | mov [eax + RECT.left], ebx |
3762 | mov ebx, [draw_limits.top] |
3760 | mov ebx, [draw_limits.top] |
3763 | mov [eax + RECT.top], ebx |
3761 | mov [eax + RECT.top], ebx |
3764 | mov ebx, [draw_limits.right] |
3762 | mov ebx, [draw_limits.right] |
3765 | mov [eax + RECT.right], ebx |
3763 | mov [eax + RECT.right], ebx |
3766 | mov ebx, [draw_limits.bottom] |
3764 | mov ebx, [draw_limits.bottom] |
3767 | mov [eax + RECT.bottom], ebx |
3765 | mov [eax + RECT.bottom], ebx |
3768 | 3766 | ||
3769 | sub eax, draw_data-window_data |
3767 | sub eax, draw_data-window_data |
3770 | 3768 | ||
3771 | cmp dword [esp], 1 |
3769 | cmp dword [esp], 1 |
3772 | jne nobgrd |
3770 | jne nobgrd |
3773 | inc byte[REDRAW_BACKGROUND] |
3771 | inc byte[REDRAW_BACKGROUND] |
3774 | call wakeup_osloop |
3772 | call wakeup_osloop |
3775 | ;-------------------------------------- |
3773 | ;-------------------------------------- |
3776 | align 4 |
3774 | align 4 |
3777 | newdw8: |
3775 | newdw8: |
3778 | nobgrd: |
3776 | nobgrd: |
3779 | 3777 | ||
3780 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3778 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3781 | ;-------------------------------------- |
3779 | ;-------------------------------------- |
3782 | align 4 |
3780 | align 4 |
3783 | ricino: |
3781 | ricino: |
3784 | not_this_task: |
3782 | not_this_task: |
3785 | pop ecx |
3783 | pop ecx |
3786 | 3784 | ||
3787 | cmp ecx, [TASK_COUNT] |
3785 | cmp ecx, [TASK_COUNT] |
3788 | jle newdw2 |
3786 | jle newdw2 |
3789 | 3787 | ||
3790 | pop eax |
3788 | pop eax |
3791 | popad |
3789 | popad |
3792 | ret |
3790 | ret |
3793 | ;----------------------------------------------------------------------------- |
3791 | ;----------------------------------------------------------------------------- |
3794 | align 4 |
3792 | align 4 |
3795 | calculatebackground: ; background |
3793 | calculatebackground: ; background |
3796 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3794 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3797 | mov eax, 0x01010101 |
3795 | mov eax, 0x01010101 |
3798 | mov ecx, [_WinMapSize] |
3796 | mov ecx, [_WinMapSize] |
3799 | shr ecx, 2 |
3797 | shr ecx, 2 |
3800 | rep stosd |
3798 | rep stosd |
3801 | 3799 | ||
3802 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3800 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3803 | ret |
3801 | ret |
3804 | ;----------------------------------------------------------------------------- |
3802 | ;----------------------------------------------------------------------------- |
3805 | uglobal |
3803 | uglobal |
3806 | imax dd 0x0 |
3804 | imax dd 0x0 |
3807 | endg |
3805 | endg |
3808 | ;----------------------------------------------------------------------------- |
3806 | ;----------------------------------------------------------------------------- |
3809 | align 4 |
3807 | align 4 |
3810 | delay_ms: ; delay in 1/1000 sec |
3808 | delay_ms: ; delay in 1/1000 sec |
3811 | push eax |
3809 | push eax |
3812 | push ecx |
3810 | push ecx |
3813 | 3811 | ||
3814 | mov ecx, esi |
3812 | mov ecx, esi |
3815 | ; |
3813 | ; |
3816 | imul ecx, 33941 |
3814 | imul ecx, 33941 |
3817 | shr ecx, 9 |
3815 | shr ecx, 9 |
3818 | ; |
3816 | ; |
3819 | 3817 | ||
3820 | in al, 0x61 |
3818 | in al, 0x61 |
3821 | and al, 0x10 |
3819 | and al, 0x10 |
3822 | mov ah, al |
3820 | mov ah, al |
3823 | cld |
3821 | cld |
3824 | ;-------------------------------------- |
3822 | ;-------------------------------------- |
3825 | align 4 |
3823 | align 4 |
3826 | cnt1: |
3824 | cnt1: |
3827 | in al, 0x61 |
3825 | in al, 0x61 |
3828 | and al, 0x10 |
3826 | and al, 0x10 |
3829 | cmp al, ah |
3827 | cmp al, ah |
3830 | jz cnt1 |
3828 | jz cnt1 |
3831 | 3829 | ||
3832 | mov ah, al |
3830 | mov ah, al |
3833 | loop cnt1 |
3831 | loop cnt1 |
3834 | 3832 | ||
3835 | pop ecx |
3833 | pop ecx |
3836 | pop eax |
3834 | pop eax |
3837 | ret |
3835 | ret |
3838 | ;----------------------------------------------------------------------------- |
3836 | ;----------------------------------------------------------------------------- |
3839 | align 4 |
3837 | align 4 |
3840 | set_app_param: |
3838 | set_app_param: |
3841 | mov edi, [TASK_BASE] |
3839 | mov edi, [TASK_BASE] |
3842 | mov eax, ebx |
3840 | mov eax, ebx |
3843 | btr eax, 3 ; move MOUSE_FILTRATION |
3841 | btr eax, 3 ; move MOUSE_FILTRATION |
3844 | mov ebx, [current_slot] ; bit into event_filter |
3842 | mov ebx, [current_slot] ; bit into event_filter |
3845 | setc byte [ebx+APPDATA.event_filter] |
3843 | setc byte [ebx+APPDATA.event_filter] |
3846 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3844 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3847 | mov [esp+32], eax ; return old mask value |
3845 | mov [esp+32], eax ; return old mask value |
3848 | ret |
3846 | ret |
3849 | ;----------------------------------------------------------------------------- |
3847 | ;----------------------------------------------------------------------------- |
3850 | 3848 | ||
3851 | ; this is for syscall |
3849 | ; this is for syscall |
3852 | proc delay_hs_unprotected |
3850 | proc delay_hs_unprotected |
3853 | call unprotect_from_terminate |
3851 | call unprotect_from_terminate |
3854 | call delay_hs |
3852 | call delay_hs |
3855 | call protect_from_terminate |
3853 | call protect_from_terminate |
3856 | ret |
3854 | ret |
3857 | endp |
3855 | endp |
3858 | 3856 | ||
3859 | align 4 |
3857 | align 4 |
3860 | delay_hs: ; delay in 1/100 secs |
3858 | delay_hs: ; delay in 1/100 secs |
3861 | ; ebx = delay time |
3859 | ; ebx = delay time |
3862 | push ecx |
3860 | push ecx |
3863 | push edx |
3861 | push edx |
3864 | 3862 | ||
3865 | mov edx, [timer_ticks] |
3863 | mov edx, [timer_ticks] |
3866 | ;-------------------------------------- |
3864 | ;-------------------------------------- |
3867 | align 4 |
3865 | align 4 |
3868 | newtic: |
3866 | newtic: |
3869 | mov ecx, [timer_ticks] |
3867 | mov ecx, [timer_ticks] |
3870 | sub ecx, edx |
3868 | sub ecx, edx |
3871 | cmp ecx, ebx |
3869 | cmp ecx, ebx |
3872 | jae zerodelay |
3870 | jae zerodelay |
3873 | 3871 | ||
3874 | call change_task |
3872 | call change_task |
3875 | 3873 | ||
3876 | jmp newtic |
3874 | jmp newtic |
3877 | ;-------------------------------------- |
3875 | ;-------------------------------------- |
3878 | align 4 |
3876 | align 4 |
3879 | zerodelay: |
3877 | zerodelay: |
3880 | pop edx |
3878 | pop edx |
3881 | pop ecx |
3879 | pop ecx |
3882 | ret |
3880 | ret |
3883 | ;----------------------------------------------------------------------------- |
3881 | ;----------------------------------------------------------------------------- |
3884 | align 16 ;very often call this subrutine |
3882 | align 16 ;very often call this subrutine |
3885 | memmove: ; memory move in bytes |
3883 | memmove: ; memory move in bytes |
3886 | ; eax = from |
3884 | ; eax = from |
3887 | ; ebx = to |
3885 | ; ebx = to |
3888 | ; ecx = no of bytes |
3886 | ; ecx = no of bytes |
3889 | test ecx, ecx |
3887 | test ecx, ecx |
3890 | jle .ret |
3888 | jle .ret |
3891 | 3889 | ||
3892 | push esi edi ecx |
3890 | push esi edi ecx |
3893 | 3891 | ||
3894 | mov edi, ebx |
3892 | mov edi, ebx |
3895 | mov esi, eax |
3893 | mov esi, eax |
3896 | 3894 | ||
3897 | test ecx, not 11b |
3895 | test ecx, not 11b |
3898 | jz @f |
3896 | jz @f |
3899 | 3897 | ||
3900 | push ecx |
3898 | push ecx |
3901 | shr ecx, 2 |
3899 | shr ecx, 2 |
3902 | rep movsd |
3900 | rep movsd |
3903 | pop ecx |
3901 | pop ecx |
3904 | and ecx, 11b |
3902 | and ecx, 11b |
3905 | jz .finish |
3903 | jz .finish |
3906 | ;-------------------------------------- |
3904 | ;-------------------------------------- |
3907 | align 4 |
3905 | align 4 |
3908 | @@: |
3906 | @@: |
3909 | rep movsb |
3907 | rep movsb |
3910 | ;-------------------------------------- |
3908 | ;-------------------------------------- |
3911 | align 4 |
3909 | align 4 |
3912 | .finish: |
3910 | .finish: |
3913 | pop ecx edi esi |
3911 | pop ecx edi esi |
3914 | ;-------------------------------------- |
3912 | ;-------------------------------------- |
3915 | align 4 |
3913 | align 4 |
3916 | .ret: |
3914 | .ret: |
3917 | ret |
3915 | ret |
3918 | ;----------------------------------------------------------------------------- |
3916 | ;----------------------------------------------------------------------------- |
3919 | ; |
3917 | ; |
3920 | ;align 4 |
3918 | ;align 4 |
3921 | ; |
3919 | ; |
3922 | ;read_floppy_file: |
3920 | ;read_floppy_file: |
3923 | ; |
3921 | ; |
3924 | ;; as input |
3922 | ;; as input |
3925 | ;; |
3923 | ;; |
3926 | ;; eax pointer to file |
3924 | ;; eax pointer to file |
3927 | ;; ebx file lenght |
3925 | ;; ebx file lenght |
3928 | ;; ecx start 512 byte block number |
3926 | ;; ecx start 512 byte block number |
3929 | ;; edx number of blocks to read |
3927 | ;; edx number of blocks to read |
3930 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3928 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3931 | ;; |
3929 | ;; |
3932 | ;; |
3930 | ;; |
3933 | ;; on return |
3931 | ;; on return |
3934 | ;; |
3932 | ;; |
3935 | ;; eax = 0 command succesful |
3933 | ;; eax = 0 command succesful |
3936 | ;; 1 no fd base and/or partition defined |
3934 | ;; 1 no fd base and/or partition defined |
3937 | ;; 2 yet unsupported FS |
3935 | ;; 2 yet unsupported FS |
3938 | ;; 3 unknown FS |
3936 | ;; 3 unknown FS |
3939 | ;; 4 partition not defined at hd |
3937 | ;; 4 partition not defined at hd |
3940 | ;; 5 file not found |
3938 | ;; 5 file not found |
3941 | ;; ebx = size of file |
3939 | ;; ebx = size of file |
3942 | ; |
3940 | ; |
3943 | ; mov edi,[TASK_BASE] |
3941 | ; mov edi,[TASK_BASE] |
3944 | ; add edi,0x10 |
3942 | ; add edi,0x10 |
3945 | ; add esi,[edi] |
3943 | ; add esi,[edi] |
3946 | ; add eax,[edi] |
3944 | ; add eax,[edi] |
3947 | ; |
3945 | ; |
3948 | ; pushad |
3946 | ; pushad |
3949 | ; mov edi,esi |
3947 | ; mov edi,esi |
3950 | ; add edi,1024 |
3948 | ; add edi,1024 |
3951 | ; mov esi,0x100000+19*512 |
3949 | ; mov esi,0x100000+19*512 |
3952 | ; sub ecx,1 |
3950 | ; sub ecx,1 |
3953 | ; shl ecx,9 |
3951 | ; shl ecx,9 |
3954 | ; add esi,ecx |
3952 | ; add esi,ecx |
3955 | ; shl edx,9 |
3953 | ; shl edx,9 |
3956 | ; mov ecx,edx |
3954 | ; mov ecx,edx |
3957 | ; cld |
3955 | ; cld |
3958 | ; rep movsb |
3956 | ; rep movsb |
3959 | ; popad |
3957 | ; popad |
3960 | ; |
3958 | ; |
3961 | ; mov [esp+36],eax |
3959 | ; mov [esp+36],eax |
3962 | ; mov [esp+24],ebx |
3960 | ; mov [esp+24],ebx |
3963 | ; ret |
3961 | ; ret |
3964 | 3962 | ||
3965 | 3963 | ||
3966 | 3964 | ||
3967 | align 4 |
3965 | align 4 |
3968 | set_io_access_rights: |
3966 | set_io_access_rights: |
3969 | push edi eax |
3967 | push edi eax |
3970 | mov edi, tss._io_map_0 |
3968 | mov edi, tss._io_map_0 |
3971 | ; mov ecx,eax |
3969 | ; mov ecx,eax |
3972 | ; and ecx,7 ; offset in byte |
3970 | ; and ecx,7 ; offset in byte |
3973 | ; shr eax,3 ; number of byte |
3971 | ; shr eax,3 ; number of byte |
3974 | ; add edi,eax |
3972 | ; add edi,eax |
3975 | ; mov ebx,1 |
3973 | ; mov ebx,1 |
3976 | ; shl ebx,cl |
3974 | ; shl ebx,cl |
3977 | test ebp, ebp |
3975 | test ebp, ebp |
3978 | ; cmp ebp,0 ; enable access - ebp = 0 |
3976 | ; cmp ebp,0 ; enable access - ebp = 0 |
3979 | jnz .siar1 |
3977 | jnz .siar1 |
3980 | ; not ebx |
3978 | ; not ebx |
3981 | ; and [edi],byte bl |
3979 | ; and [edi],byte bl |
3982 | btr [edi], eax |
3980 | btr [edi], eax |
3983 | pop eax edi |
3981 | pop eax edi |
3984 | ret |
3982 | ret |
3985 | .siar1: |
3983 | .siar1: |
3986 | bts [edi], eax |
3984 | bts [edi], eax |
3987 | ; or [edi],byte bl ; disable access - ebp = 1 |
3985 | ; or [edi],byte bl ; disable access - ebp = 1 |
3988 | pop eax edi |
3986 | pop eax edi |
3989 | ret |
3987 | ret |
3990 | ;reserve/free group of ports |
3988 | ;reserve/free group of ports |
3991 | ; * eax = 46 - number function |
3989 | ; * eax = 46 - number function |
3992 | ; * ebx = 0 - reserve, 1 - free |
3990 | ; * ebx = 0 - reserve, 1 - free |
3993 | ; * ecx = number start arrea of ports |
3991 | ; * ecx = number start arrea of ports |
3994 | ; * edx = number end arrea of ports (include last number of port) |
3992 | ; * edx = number end arrea of ports (include last number of port) |
3995 | ;Return value: |
3993 | ;Return value: |
3996 | ; * eax = 0 - succesful |
3994 | ; * eax = 0 - succesful |
3997 | ; * eax = 1 - error |
3995 | ; * eax = 1 - error |
3998 | ; * The system has reserve this ports: |
3996 | ; * The system has reserve this ports: |
3999 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3997 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4000 | ;destroys eax,ebx, ebp |
3998 | ;destroys eax,ebx, ebp |
4001 | r_f_port_area: |
3999 | r_f_port_area: |
4002 | 4000 | ||
4003 | test ebx, ebx |
4001 | test ebx, ebx |
4004 | jnz free_port_area |
4002 | jnz free_port_area |
4005 | ; je r_port_area |
4003 | ; je r_port_area |
4006 | ; jmp free_port_area |
4004 | ; jmp free_port_area |
4007 | 4005 | ||
4008 | ; r_port_area: |
4006 | ; r_port_area: |
4009 | 4007 | ||
4010 | ; pushad |
4008 | ; pushad |
4011 | 4009 | ||
4012 | cmp ecx, edx ; beginning > end ? |
4010 | cmp ecx, edx ; beginning > end ? |
4013 | ja rpal1 |
4011 | ja rpal1 |
4014 | cmp edx, 65536 |
4012 | cmp edx, 65536 |
4015 | jae rpal1 |
4013 | jae rpal1 |
4016 | mov eax, [RESERVED_PORTS] |
4014 | mov eax, [RESERVED_PORTS] |
4017 | test eax, eax ; no reserved areas ? |
4015 | test eax, eax ; no reserved areas ? |
4018 | je rpal2 |
4016 | je rpal2 |
4019 | cmp eax, 255 ; max reserved |
4017 | cmp eax, 255 ; max reserved |
4020 | jae rpal1 |
4018 | jae rpal1 |
4021 | rpal3: |
4019 | rpal3: |
4022 | mov ebx, eax |
4020 | mov ebx, eax |
4023 | shl ebx, 4 |
4021 | shl ebx, 4 |
4024 | add ebx, RESERVED_PORTS |
4022 | add ebx, RESERVED_PORTS |
4025 | cmp ecx, [ebx+8] |
4023 | cmp ecx, [ebx+8] |
4026 | ja rpal4 |
4024 | ja rpal4 |
4027 | cmp edx, [ebx+4] |
4025 | cmp edx, [ebx+4] |
4028 | jae rpal1 |
4026 | jae rpal1 |
4029 | ; jb rpal4 |
4027 | ; jb rpal4 |
4030 | ; jmp rpal1 |
4028 | ; jmp rpal1 |
4031 | rpal4: |
4029 | rpal4: |
4032 | dec eax |
4030 | dec eax |
4033 | jnz rpal3 |
4031 | jnz rpal3 |
4034 | jmp rpal2 |
4032 | jmp rpal2 |
4035 | rpal1: |
4033 | rpal1: |
4036 | ; popad |
4034 | ; popad |
4037 | ; mov eax,1 |
4035 | ; mov eax,1 |
4038 | xor eax, eax |
4036 | xor eax, eax |
4039 | inc eax |
4037 | inc eax |
4040 | ret |
4038 | ret |
4041 | rpal2: |
4039 | rpal2: |
4042 | ; popad |
4040 | ; popad |
4043 | ; enable port access at port IO map |
4041 | ; enable port access at port IO map |
4044 | cli |
4042 | cli |
4045 | pushad ; start enable io map |
4043 | pushad ; start enable io map |
4046 | 4044 | ||
4047 | cmp edx, 65536;16384 |
4045 | cmp edx, 65536;16384 |
4048 | jae no_unmask_io; jge |
4046 | jae no_unmask_io; jge |
4049 | mov eax, ecx |
4047 | mov eax, ecx |
4050 | ; push ebp |
4048 | ; push ebp |
4051 | xor ebp, ebp ; enable - eax = port |
4049 | xor ebp, ebp ; enable - eax = port |
4052 | new_port_access: |
4050 | new_port_access: |
4053 | ; pushad |
4051 | ; pushad |
4054 | call set_io_access_rights |
4052 | call set_io_access_rights |
4055 | ; popad |
4053 | ; popad |
4056 | inc eax |
4054 | inc eax |
4057 | cmp eax, edx |
4055 | cmp eax, edx |
4058 | jbe new_port_access |
4056 | jbe new_port_access |
4059 | ; pop ebp |
4057 | ; pop ebp |
4060 | no_unmask_io: |
4058 | no_unmask_io: |
4061 | popad ; end enable io map |
4059 | popad ; end enable io map |
4062 | sti |
4060 | sti |
4063 | 4061 | ||
4064 | mov eax, [RESERVED_PORTS] |
4062 | mov eax, [RESERVED_PORTS] |
4065 | add eax, 1 |
4063 | add eax, 1 |
4066 | mov [RESERVED_PORTS], eax |
4064 | mov [RESERVED_PORTS], eax |
4067 | shl eax, 4 |
4065 | shl eax, 4 |
4068 | add eax, RESERVED_PORTS |
4066 | add eax, RESERVED_PORTS |
4069 | mov ebx, [TASK_BASE] |
4067 | mov ebx, [TASK_BASE] |
4070 | mov ebx, [ebx+TASKDATA.pid] |
4068 | mov ebx, [ebx+TASKDATA.pid] |
4071 | mov [eax], ebx |
4069 | mov [eax], ebx |
4072 | mov [eax+4], ecx |
4070 | mov [eax+4], ecx |
4073 | mov [eax+8], edx |
4071 | mov [eax+8], edx |
4074 | 4072 | ||
4075 | xor eax, eax |
4073 | xor eax, eax |
4076 | ret |
4074 | ret |
4077 | 4075 | ||
4078 | free_port_area: |
4076 | free_port_area: |
4079 | 4077 | ||
4080 | ; pushad |
4078 | ; pushad |
4081 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4079 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4082 | test eax, eax |
4080 | test eax, eax |
4083 | jz frpal2 |
4081 | jz frpal2 |
4084 | mov ebx, [TASK_BASE] |
4082 | mov ebx, [TASK_BASE] |
4085 | mov ebx, [ebx+TASKDATA.pid] |
4083 | mov ebx, [ebx+TASKDATA.pid] |
4086 | frpal3: |
4084 | frpal3: |
4087 | mov edi, eax |
4085 | mov edi, eax |
4088 | shl edi, 4 |
4086 | shl edi, 4 |
4089 | add edi, RESERVED_PORTS |
4087 | add edi, RESERVED_PORTS |
4090 | cmp ebx, [edi] |
4088 | cmp ebx, [edi] |
4091 | jne frpal4 |
4089 | jne frpal4 |
4092 | cmp ecx, [edi+4] |
4090 | cmp ecx, [edi+4] |
4093 | jne frpal4 |
4091 | jne frpal4 |
4094 | cmp edx, [edi+8] |
4092 | cmp edx, [edi+8] |
4095 | jne frpal4 |
4093 | jne frpal4 |
4096 | jmp frpal1 |
4094 | jmp frpal1 |
4097 | frpal4: |
4095 | frpal4: |
4098 | dec eax |
4096 | dec eax |
4099 | jnz frpal3 |
4097 | jnz frpal3 |
4100 | frpal2: |
4098 | frpal2: |
4101 | ; popad |
4099 | ; popad |
4102 | inc eax |
4100 | inc eax |
4103 | ret |
4101 | ret |
4104 | frpal1: |
4102 | frpal1: |
4105 | push ecx |
4103 | push ecx |
4106 | mov ecx, 256 |
4104 | mov ecx, 256 |
4107 | sub ecx, eax |
4105 | sub ecx, eax |
4108 | shl ecx, 4 |
4106 | shl ecx, 4 |
4109 | mov esi, edi |
4107 | mov esi, edi |
4110 | add esi, 16 |
4108 | add esi, 16 |
4111 | cld |
4109 | cld |
4112 | rep movsb |
4110 | rep movsb |
4113 | 4111 | ||
4114 | dec dword [RESERVED_PORTS] |
4112 | dec dword [RESERVED_PORTS] |
4115 | ;popad |
4113 | ;popad |
4116 | ;disable port access at port IO map |
4114 | ;disable port access at port IO map |
4117 | 4115 | ||
4118 | ; pushad ; start disable io map |
4116 | ; pushad ; start disable io map |
4119 | pop eax ;start port |
4117 | pop eax ;start port |
4120 | cmp edx, 65536;16384 |
4118 | cmp edx, 65536;16384 |
4121 | jge no_mask_io |
4119 | jge no_mask_io |
4122 | 4120 | ||
4123 | ; mov eax,ecx |
4121 | ; mov eax,ecx |
4124 | xor ebp, ebp |
4122 | xor ebp, ebp |
4125 | inc ebp |
4123 | inc ebp |
4126 | new_port_access_disable: |
4124 | new_port_access_disable: |
4127 | ; pushad |
4125 | ; pushad |
4128 | ; mov ebp,1 ; disable - eax = port |
4126 | ; mov ebp,1 ; disable - eax = port |
4129 | call set_io_access_rights |
4127 | call set_io_access_rights |
4130 | ; popad |
4128 | ; popad |
4131 | inc eax |
4129 | inc eax |
4132 | cmp eax, edx |
4130 | cmp eax, edx |
4133 | jbe new_port_access_disable |
4131 | jbe new_port_access_disable |
4134 | no_mask_io: |
4132 | no_mask_io: |
4135 | ; popad ; end disable io map |
4133 | ; popad ; end disable io map |
4136 | xor eax, eax |
4134 | xor eax, eax |
4137 | ret |
4135 | ret |
4138 | ;----------------------------------------------------------------------------- |
4136 | ;----------------------------------------------------------------------------- |
4139 | align 4 |
4137 | align 4 |
4140 | drawbackground: |
4138 | drawbackground: |
4141 | dbrv20: |
4139 | dbrv20: |
4142 | cmp [BgrDrawMode], dword 1 |
4140 | cmp [BgrDrawMode], dword 1 |
4143 | jne bgrstr |
4141 | jne bgrstr |
4144 | call vesa20_drawbackground_tiled |
4142 | call vesa20_drawbackground_tiled |
4145 | ; call [draw_pointer] |
4143 | ; call [draw_pointer] |
4146 | call __sys_draw_pointer |
4144 | call __sys_draw_pointer |
4147 | ret |
4145 | ret |
4148 | ;-------------------------------------- |
4146 | ;-------------------------------------- |
4149 | align 4 |
4147 | align 4 |
4150 | bgrstr: |
4148 | bgrstr: |
4151 | call vesa20_drawbackground_stretch |
4149 | call vesa20_drawbackground_stretch |
4152 | ; call [draw_pointer] |
4150 | ; call [draw_pointer] |
4153 | call __sys_draw_pointer |
4151 | call __sys_draw_pointer |
4154 | ret |
4152 | ret |
4155 | ;----------------------------------------------------------------------------- |
4153 | ;----------------------------------------------------------------------------- |
4156 | align 4 |
4154 | align 4 |
4157 | syscall_putimage: ; PutImage |
4155 | syscall_putimage: ; PutImage |
4158 | sys_putimage: |
4156 | sys_putimage: |
4159 | test ecx, 0x80008000 |
4157 | test ecx, 0x80008000 |
4160 | jnz .exit |
4158 | jnz .exit |
4161 | test ecx, 0x0000FFFF |
4159 | test ecx, 0x0000FFFF |
4162 | jz .exit |
4160 | jz .exit |
4163 | test ecx, 0xFFFF0000 |
4161 | test ecx, 0xFFFF0000 |
4164 | jnz @f |
4162 | jnz @f |
4165 | ;-------------------------------------- |
4163 | ;-------------------------------------- |
4166 | align 4 |
4164 | align 4 |
4167 | .exit: |
4165 | .exit: |
4168 | ret |
4166 | ret |
4169 | ;-------------------------------------- |
4167 | ;-------------------------------------- |
4170 | align 4 |
4168 | align 4 |
4171 | @@: |
4169 | @@: |
4172 | mov edi, [current_slot] |
4170 | mov edi, [current_slot] |
4173 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4171 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4174 | rol edx, 16 |
4172 | rol edx, 16 |
4175 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4173 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4176 | rol edx, 16 |
4174 | rol edx, 16 |
4177 | ;-------------------------------------- |
4175 | ;-------------------------------------- |
4178 | align 4 |
4176 | align 4 |
4179 | .forced: |
4177 | .forced: |
4180 | push ebp esi 0 |
4178 | push ebp esi 0 |
4181 | mov ebp, putimage_get24bpp |
4179 | mov ebp, putimage_get24bpp |
4182 | mov esi, putimage_init24bpp |
4180 | mov esi, putimage_init24bpp |
4183 | ;-------------------------------------- |
4181 | ;-------------------------------------- |
4184 | align 4 |
4182 | align 4 |
4185 | sys_putimage_bpp: |
4183 | sys_putimage_bpp: |
4186 | call vesa20_putimage |
4184 | call vesa20_putimage |
4187 | pop ebp esi ebp |
4185 | pop ebp esi ebp |
4188 | ret |
4186 | ret |
4189 | ; jmp [draw_pointer] |
4187 | ; jmp [draw_pointer] |
4190 | ;----------------------------------------------------------------------------- |
4188 | ;----------------------------------------------------------------------------- |
4191 | align 4 |
4189 | align 4 |
4192 | sys_putimage_palette: |
4190 | sys_putimage_palette: |
4193 | ; ebx = pointer to image |
4191 | ; ebx = pointer to image |
4194 | ; ecx = [xsize]*65536 + [ysize] |
4192 | ; ecx = [xsize]*65536 + [ysize] |
4195 | ; edx = [xstart]*65536 + [ystart] |
4193 | ; edx = [xstart]*65536 + [ystart] |
4196 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4194 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4197 | ; edi = pointer to palette |
4195 | ; edi = pointer to palette |
4198 | ; ebp = row delta |
4196 | ; ebp = row delta |
4199 | mov eax, [CURRENT_TASK] |
4197 | mov eax, [CURRENT_TASK] |
4200 | shl eax, 8 |
4198 | shl eax, 8 |
4201 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4199 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4202 | rol edx, 16 |
4200 | rol edx, 16 |
4203 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4201 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4204 | rol edx, 16 |
4202 | rol edx, 16 |
4205 | ;-------------------------------------- |
4203 | ;-------------------------------------- |
4206 | align 4 |
4204 | align 4 |
4207 | .forced: |
4205 | .forced: |
4208 | cmp esi, 1 |
4206 | cmp esi, 1 |
4209 | jnz @f |
4207 | jnz @f |
4210 | push edi |
4208 | push edi |
4211 | mov eax, [edi+4] |
4209 | mov eax, [edi+4] |
4212 | sub eax, [edi] |
4210 | sub eax, [edi] |
4213 | push eax |
4211 | push eax |
4214 | push dword [edi] |
4212 | push dword [edi] |
4215 | push 0ffffff80h |
4213 | push 0ffffff80h |
4216 | mov edi, esp |
4214 | mov edi, esp |
4217 | call put_mono_image |
4215 | call put_mono_image |
4218 | add esp, 12 |
4216 | add esp, 12 |
4219 | pop edi |
4217 | pop edi |
4220 | ret |
4218 | ret |
4221 | ;-------------------------------------- |
4219 | ;-------------------------------------- |
4222 | align 4 |
4220 | align 4 |
4223 | @@: |
4221 | @@: |
4224 | cmp esi, 2 |
4222 | cmp esi, 2 |
4225 | jnz @f |
4223 | jnz @f |
4226 | push edi |
4224 | push edi |
4227 | push 0ffffff80h |
4225 | push 0ffffff80h |
4228 | mov edi, esp |
4226 | mov edi, esp |
4229 | call put_2bit_image |
4227 | call put_2bit_image |
4230 | pop eax |
4228 | pop eax |
4231 | pop edi |
4229 | pop edi |
4232 | ret |
4230 | ret |
4233 | ;-------------------------------------- |
4231 | ;-------------------------------------- |
4234 | align 4 |
4232 | align 4 |
4235 | @@: |
4233 | @@: |
4236 | cmp esi, 4 |
4234 | cmp esi, 4 |
4237 | jnz @f |
4235 | jnz @f |
4238 | push edi |
4236 | push edi |
4239 | push 0ffffff80h |
4237 | push 0ffffff80h |
4240 | mov edi, esp |
4238 | mov edi, esp |
4241 | call put_4bit_image |
4239 | call put_4bit_image |
4242 | pop eax |
4240 | pop eax |
4243 | pop edi |
4241 | pop edi |
4244 | ret |
4242 | ret |
4245 | ;-------------------------------------- |
4243 | ;-------------------------------------- |
4246 | align 4 |
4244 | align 4 |
4247 | @@: |
4245 | @@: |
4248 | push ebp esi ebp |
4246 | push ebp esi ebp |
4249 | cmp esi, 8 |
4247 | cmp esi, 8 |
4250 | jnz @f |
4248 | jnz @f |
4251 | mov ebp, putimage_get8bpp |
4249 | mov ebp, putimage_get8bpp |
4252 | mov esi, putimage_init8bpp |
4250 | mov esi, putimage_init8bpp |
4253 | jmp sys_putimage_bpp |
4251 | jmp sys_putimage_bpp |
4254 | ;-------------------------------------- |
4252 | ;-------------------------------------- |
4255 | align 4 |
4253 | align 4 |
4256 | @@: |
4254 | @@: |
4257 | cmp esi, 9 |
4255 | cmp esi, 9 |
4258 | jnz @f |
4256 | jnz @f |
4259 | mov ebp, putimage_get9bpp |
4257 | mov ebp, putimage_get9bpp |
4260 | mov esi, putimage_init9bpp |
4258 | mov esi, putimage_init9bpp |
4261 | jmp sys_putimage_bpp |
4259 | jmp sys_putimage_bpp |
4262 | ;-------------------------------------- |
4260 | ;-------------------------------------- |
4263 | align 4 |
4261 | align 4 |
4264 | @@: |
4262 | @@: |
4265 | cmp esi, 15 |
4263 | cmp esi, 15 |
4266 | jnz @f |
4264 | jnz @f |
4267 | mov ebp, putimage_get15bpp |
4265 | mov ebp, putimage_get15bpp |
4268 | mov esi, putimage_init15bpp |
4266 | mov esi, putimage_init15bpp |
4269 | jmp sys_putimage_bpp |
4267 | jmp sys_putimage_bpp |
4270 | ;-------------------------------------- |
4268 | ;-------------------------------------- |
4271 | align 4 |
4269 | align 4 |
4272 | @@: |
4270 | @@: |
4273 | cmp esi, 16 |
4271 | cmp esi, 16 |
4274 | jnz @f |
4272 | jnz @f |
4275 | mov ebp, putimage_get16bpp |
4273 | mov ebp, putimage_get16bpp |
4276 | mov esi, putimage_init16bpp |
4274 | mov esi, putimage_init16bpp |
4277 | jmp sys_putimage_bpp |
4275 | jmp sys_putimage_bpp |
4278 | ;-------------------------------------- |
4276 | ;-------------------------------------- |
4279 | align 4 |
4277 | align 4 |
4280 | @@: |
4278 | @@: |
4281 | cmp esi, 24 |
4279 | cmp esi, 24 |
4282 | jnz @f |
4280 | jnz @f |
4283 | mov ebp, putimage_get24bpp |
4281 | mov ebp, putimage_get24bpp |
4284 | mov esi, putimage_init24bpp |
4282 | mov esi, putimage_init24bpp |
4285 | jmp sys_putimage_bpp |
4283 | jmp sys_putimage_bpp |
4286 | ;-------------------------------------- |
4284 | ;-------------------------------------- |
4287 | align 4 |
4285 | align 4 |
4288 | @@: |
4286 | @@: |
4289 | cmp esi, 32 |
4287 | cmp esi, 32 |
4290 | jnz @f |
4288 | jnz @f |
4291 | mov ebp, putimage_get32bpp |
4289 | mov ebp, putimage_get32bpp |
4292 | mov esi, putimage_init32bpp |
4290 | mov esi, putimage_init32bpp |
4293 | jmp sys_putimage_bpp |
4291 | jmp sys_putimage_bpp |
4294 | ;-------------------------------------- |
4292 | ;-------------------------------------- |
4295 | align 4 |
4293 | align 4 |
4296 | @@: |
4294 | @@: |
4297 | pop ebp esi ebp |
4295 | pop ebp esi ebp |
4298 | ret |
4296 | ret |
4299 | ;----------------------------------------------------------------------------- |
4297 | ;----------------------------------------------------------------------------- |
4300 | align 4 |
4298 | align 4 |
4301 | put_mono_image: |
4299 | put_mono_image: |
4302 | push ebp esi ebp |
4300 | push ebp esi ebp |
4303 | mov ebp, putimage_get1bpp |
4301 | mov ebp, putimage_get1bpp |
4304 | mov esi, putimage_init1bpp |
4302 | mov esi, putimage_init1bpp |
4305 | jmp sys_putimage_bpp |
4303 | jmp sys_putimage_bpp |
4306 | ;----------------------------------------------------------------------------- |
4304 | ;----------------------------------------------------------------------------- |
4307 | align 4 |
4305 | align 4 |
4308 | put_2bit_image: |
4306 | put_2bit_image: |
4309 | push ebp esi ebp |
4307 | push ebp esi ebp |
4310 | mov ebp, putimage_get2bpp |
4308 | mov ebp, putimage_get2bpp |
4311 | mov esi, putimage_init2bpp |
4309 | mov esi, putimage_init2bpp |
4312 | jmp sys_putimage_bpp |
4310 | jmp sys_putimage_bpp |
4313 | ;----------------------------------------------------------------------------- |
4311 | ;----------------------------------------------------------------------------- |
4314 | align 4 |
4312 | align 4 |
4315 | put_4bit_image: |
4313 | put_4bit_image: |
4316 | push ebp esi ebp |
4314 | push ebp esi ebp |
4317 | mov ebp, putimage_get4bpp |
4315 | mov ebp, putimage_get4bpp |
4318 | mov esi, putimage_init4bpp |
4316 | mov esi, putimage_init4bpp |
4319 | jmp sys_putimage_bpp |
4317 | jmp sys_putimage_bpp |
4320 | ;----------------------------------------------------------------------------- |
4318 | ;----------------------------------------------------------------------------- |
4321 | align 4 |
4319 | align 4 |
4322 | putimage_init24bpp: |
4320 | putimage_init24bpp: |
4323 | lea eax, [eax*3] |
4321 | lea eax, [eax*3] |
4324 | putimage_init8bpp: |
4322 | putimage_init8bpp: |
4325 | putimage_init9bpp: |
4323 | putimage_init9bpp: |
4326 | ret |
4324 | ret |
4327 | ;----------------------------------------------------------------------------- |
4325 | ;----------------------------------------------------------------------------- |
4328 | align 16 |
4326 | align 16 |
4329 | putimage_get24bpp: |
4327 | putimage_get24bpp: |
4330 | movzx eax, byte [esi+2] |
4328 | movzx eax, byte [esi+2] |
4331 | shl eax, 16 |
4329 | shl eax, 16 |
4332 | mov ax, [esi] |
4330 | mov ax, [esi] |
4333 | add esi, 3 |
4331 | add esi, 3 |
4334 | ret 4 |
4332 | ret 4 |
4335 | ;----------------------------------------------------------------------------- |
4333 | ;----------------------------------------------------------------------------- |
4336 | align 16 |
4334 | align 16 |
4337 | putimage_get8bpp: |
4335 | putimage_get8bpp: |
4338 | movzx eax, byte [esi] |
4336 | movzx eax, byte [esi] |
4339 | push edx |
4337 | push edx |
4340 | mov edx, [esp+8] |
4338 | mov edx, [esp+8] |
4341 | mov eax, [edx+eax*4] |
4339 | mov eax, [edx+eax*4] |
4342 | pop edx |
4340 | pop edx |
4343 | inc esi |
4341 | inc esi |
4344 | ret 4 |
4342 | ret 4 |
4345 | ;----------------------------------------------------------------------------- |
4343 | ;----------------------------------------------------------------------------- |
4346 | align 16 |
4344 | align 16 |
4347 | putimage_get9bpp: |
4345 | putimage_get9bpp: |
4348 | lodsb |
4346 | lodsb |
4349 | mov ah, al |
4347 | mov ah, al |
4350 | shl eax, 8 |
4348 | shl eax, 8 |
4351 | mov al, ah |
4349 | mov al, ah |
4352 | ret 4 |
4350 | ret 4 |
4353 | ;----------------------------------------------------------------------------- |
4351 | ;----------------------------------------------------------------------------- |
4354 | align 4 |
4352 | align 4 |
4355 | putimage_init1bpp: |
4353 | putimage_init1bpp: |
4356 | add eax, ecx |
4354 | add eax, ecx |
4357 | push ecx |
4355 | push ecx |
4358 | add eax, 7 |
4356 | add eax, 7 |
4359 | add ecx, 7 |
4357 | add ecx, 7 |
4360 | shr eax, 3 |
4358 | shr eax, 3 |
4361 | shr ecx, 3 |
4359 | shr ecx, 3 |
4362 | sub eax, ecx |
4360 | sub eax, ecx |
4363 | pop ecx |
4361 | pop ecx |
4364 | ret |
4362 | ret |
4365 | ;----------------------------------------------------------------------------- |
4363 | ;----------------------------------------------------------------------------- |
4366 | align 16 |
4364 | align 16 |
4367 | putimage_get1bpp: |
4365 | putimage_get1bpp: |
4368 | push edx |
4366 | push edx |
4369 | mov edx, [esp+8] |
4367 | mov edx, [esp+8] |
4370 | mov al, [edx] |
4368 | mov al, [edx] |
4371 | add al, al |
4369 | add al, al |
4372 | jnz @f |
4370 | jnz @f |
4373 | lodsb |
4371 | lodsb |
4374 | adc al, al |
4372 | adc al, al |
4375 | @@: |
4373 | @@: |
4376 | mov [edx], al |
4374 | mov [edx], al |
4377 | sbb eax, eax |
4375 | sbb eax, eax |
4378 | and eax, [edx+8] |
4376 | and eax, [edx+8] |
4379 | add eax, [edx+4] |
4377 | add eax, [edx+4] |
4380 | pop edx |
4378 | pop edx |
4381 | ret 4 |
4379 | ret 4 |
4382 | ;----------------------------------------------------------------------------- |
4380 | ;----------------------------------------------------------------------------- |
4383 | align 4 |
4381 | align 4 |
4384 | putimage_init2bpp: |
4382 | putimage_init2bpp: |
4385 | add eax, ecx |
4383 | add eax, ecx |
4386 | push ecx |
4384 | push ecx |
4387 | add ecx, 3 |
4385 | add ecx, 3 |
4388 | add eax, 3 |
4386 | add eax, 3 |
4389 | shr ecx, 2 |
4387 | shr ecx, 2 |
4390 | shr eax, 2 |
4388 | shr eax, 2 |
4391 | sub eax, ecx |
4389 | sub eax, ecx |
4392 | pop ecx |
4390 | pop ecx |
4393 | ret |
4391 | ret |
4394 | ;----------------------------------------------------------------------------- |
4392 | ;----------------------------------------------------------------------------- |
4395 | align 16 |
4393 | align 16 |
4396 | putimage_get2bpp: |
4394 | putimage_get2bpp: |
4397 | push edx |
4395 | push edx |
4398 | mov edx, [esp+8] |
4396 | mov edx, [esp+8] |
4399 | mov al, [edx] |
4397 | mov al, [edx] |
4400 | mov ah, al |
4398 | mov ah, al |
4401 | shr al, 6 |
4399 | shr al, 6 |
4402 | shl ah, 2 |
4400 | shl ah, 2 |
4403 | jnz .nonewbyte |
4401 | jnz .nonewbyte |
4404 | lodsb |
4402 | lodsb |
4405 | mov ah, al |
4403 | mov ah, al |
4406 | shr al, 6 |
4404 | shr al, 6 |
4407 | shl ah, 2 |
4405 | shl ah, 2 |
4408 | add ah, 1 |
4406 | add ah, 1 |
4409 | .nonewbyte: |
4407 | .nonewbyte: |
4410 | mov [edx], ah |
4408 | mov [edx], ah |
4411 | mov edx, [edx+4] |
4409 | mov edx, [edx+4] |
4412 | movzx eax, al |
4410 | movzx eax, al |
4413 | mov eax, [edx+eax*4] |
4411 | mov eax, [edx+eax*4] |
4414 | pop edx |
4412 | pop edx |
4415 | ret 4 |
4413 | ret 4 |
4416 | ;----------------------------------------------------------------------------- |
4414 | ;----------------------------------------------------------------------------- |
4417 | align 4 |
4415 | align 4 |
4418 | putimage_init4bpp: |
4416 | putimage_init4bpp: |
4419 | add eax, ecx |
4417 | add eax, ecx |
4420 | push ecx |
4418 | push ecx |
4421 | add ecx, 1 |
4419 | add ecx, 1 |
4422 | add eax, 1 |
4420 | add eax, 1 |
4423 | shr ecx, 1 |
4421 | shr ecx, 1 |
4424 | shr eax, 1 |
4422 | shr eax, 1 |
4425 | sub eax, ecx |
4423 | sub eax, ecx |
4426 | pop ecx |
4424 | pop ecx |
4427 | ret |
4425 | ret |
4428 | ;----------------------------------------------------------------------------- |
4426 | ;----------------------------------------------------------------------------- |
4429 | align 16 |
4427 | align 16 |
4430 | putimage_get4bpp: |
4428 | putimage_get4bpp: |
4431 | push edx |
4429 | push edx |
4432 | mov edx, [esp+8] |
4430 | mov edx, [esp+8] |
4433 | add byte [edx], 80h |
4431 | add byte [edx], 80h |
4434 | jc @f |
4432 | jc @f |
4435 | movzx eax, byte [edx+1] |
4433 | movzx eax, byte [edx+1] |
4436 | mov edx, [edx+4] |
4434 | mov edx, [edx+4] |
4437 | and eax, 0x0F |
4435 | and eax, 0x0F |
4438 | mov eax, [edx+eax*4] |
4436 | mov eax, [edx+eax*4] |
4439 | pop edx |
4437 | pop edx |
4440 | ret 4 |
4438 | ret 4 |
4441 | @@: |
4439 | @@: |
4442 | movzx eax, byte [esi] |
4440 | movzx eax, byte [esi] |
4443 | add esi, 1 |
4441 | add esi, 1 |
4444 | mov [edx+1], al |
4442 | mov [edx+1], al |
4445 | shr eax, 4 |
4443 | shr eax, 4 |
4446 | mov edx, [edx+4] |
4444 | mov edx, [edx+4] |
4447 | mov eax, [edx+eax*4] |
4445 | mov eax, [edx+eax*4] |
4448 | pop edx |
4446 | pop edx |
4449 | ret 4 |
4447 | ret 4 |
4450 | ;----------------------------------------------------------------------------- |
4448 | ;----------------------------------------------------------------------------- |
4451 | align 4 |
4449 | align 4 |
4452 | putimage_init32bpp: |
4450 | putimage_init32bpp: |
4453 | shl eax, 2 |
4451 | shl eax, 2 |
4454 | ret |
4452 | ret |
4455 | ;----------------------------------------------------------------------------- |
4453 | ;----------------------------------------------------------------------------- |
4456 | align 16 |
4454 | align 16 |
4457 | putimage_get32bpp: |
4455 | putimage_get32bpp: |
4458 | lodsd |
4456 | lodsd |
4459 | ret 4 |
4457 | ret 4 |
4460 | ;----------------------------------------------------------------------------- |
4458 | ;----------------------------------------------------------------------------- |
4461 | align 4 |
4459 | align 4 |
4462 | putimage_init15bpp: |
4460 | putimage_init15bpp: |
4463 | putimage_init16bpp: |
4461 | putimage_init16bpp: |
4464 | add eax, eax |
4462 | add eax, eax |
4465 | ret |
4463 | ret |
4466 | ;----------------------------------------------------------------------------- |
4464 | ;----------------------------------------------------------------------------- |
4467 | align 16 |
4465 | align 16 |
4468 | putimage_get15bpp: |
4466 | putimage_get15bpp: |
4469 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4467 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4470 | push ecx edx |
4468 | push ecx edx |
4471 | movzx eax, word [esi] |
4469 | movzx eax, word [esi] |
4472 | add esi, 2 |
4470 | add esi, 2 |
4473 | mov ecx, eax |
4471 | mov ecx, eax |
4474 | mov edx, eax |
4472 | mov edx, eax |
4475 | and eax, 0x1F |
4473 | and eax, 0x1F |
4476 | and ecx, 0x1F shl 5 |
4474 | and ecx, 0x1F shl 5 |
4477 | and edx, 0x1F shl 10 |
4475 | and edx, 0x1F shl 10 |
4478 | shl eax, 3 |
4476 | shl eax, 3 |
4479 | shl ecx, 6 |
4477 | shl ecx, 6 |
4480 | shl edx, 9 |
4478 | shl edx, 9 |
4481 | or eax, ecx |
4479 | or eax, ecx |
4482 | or eax, edx |
4480 | or eax, edx |
4483 | pop edx ecx |
4481 | pop edx ecx |
4484 | ret 4 |
4482 | ret 4 |
4485 | ;----------------------------------------------------------------------------- |
4483 | ;----------------------------------------------------------------------------- |
4486 | align 16 |
4484 | align 16 |
4487 | putimage_get16bpp: |
4485 | putimage_get16bpp: |
4488 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4486 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4489 | push ecx edx |
4487 | push ecx edx |
4490 | movzx eax, word [esi] |
4488 | movzx eax, word [esi] |
4491 | add esi, 2 |
4489 | add esi, 2 |
4492 | mov ecx, eax |
4490 | mov ecx, eax |
4493 | mov edx, eax |
4491 | mov edx, eax |
4494 | and eax, 0x1F |
4492 | and eax, 0x1F |
4495 | and ecx, 0x3F shl 5 |
4493 | and ecx, 0x3F shl 5 |
4496 | and edx, 0x1F shl 11 |
4494 | and edx, 0x1F shl 11 |
4497 | shl eax, 3 |
4495 | shl eax, 3 |
4498 | shl ecx, 5 |
4496 | shl ecx, 5 |
4499 | shl edx, 8 |
4497 | shl edx, 8 |
4500 | or eax, ecx |
4498 | or eax, ecx |
4501 | or eax, edx |
4499 | or eax, edx |
4502 | pop edx ecx |
4500 | pop edx ecx |
4503 | ret 4 |
4501 | ret 4 |
4504 | ;----------------------------------------------------------------------------- |
4502 | ;----------------------------------------------------------------------------- |
4505 | ;align 4 |
4503 | ;align 4 |
4506 | ; eax x beginning |
4504 | ; eax x beginning |
4507 | ; ebx y beginning |
4505 | ; ebx y beginning |
4508 | ; ecx x end |
4506 | ; ecx x end |
4509 | ; edx y end |
4507 | ; edx y end |
4510 | ; edi color |
4508 | ; edi color |
4511 | ;__sys_drawbar: |
4509 | ;__sys_drawbar: |
4512 | ; mov esi, [current_slot] |
4510 | ; mov esi, [current_slot] |
4513 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4511 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4514 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4512 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4515 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4513 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4516 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4514 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4517 | ;-------------------------------------- |
4515 | ;-------------------------------------- |
4518 | ;align 4 |
4516 | ;align 4 |
4519 | ;.forced: |
4517 | ;.forced: |
4520 | ; call vesa20_drawbar |
4518 | ; call vesa20_drawbar |
4521 | ; call [draw_pointer] |
4519 | ; call [draw_pointer] |
4522 | ; ret |
4520 | ; ret |
4523 | ;----------------------------------------------------------------------------- |
4521 | ;----------------------------------------------------------------------------- |
4524 | align 4 |
4522 | align 4 |
4525 | kb_read: |
4523 | kb_read: |
4526 | 4524 | ||
4527 | push ecx edx |
4525 | push ecx edx |
4528 | 4526 | ||
4529 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4527 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4530 | kr_loop: |
4528 | kr_loop: |
4531 | in al, 0x64 |
4529 | in al, 0x64 |
4532 | test al, 1 |
4530 | test al, 1 |
4533 | jnz kr_ready |
4531 | jnz kr_ready |
4534 | loop kr_loop |
4532 | loop kr_loop |
4535 | mov ah, 1 |
4533 | mov ah, 1 |
4536 | jmp kr_exit |
4534 | jmp kr_exit |
4537 | kr_ready: |
4535 | kr_ready: |
4538 | push ecx |
4536 | push ecx |
4539 | mov ecx, 32 |
4537 | mov ecx, 32 |
4540 | kr_delay: |
4538 | kr_delay: |
4541 | loop kr_delay |
4539 | loop kr_delay |
4542 | pop ecx |
4540 | pop ecx |
4543 | in al, 0x60 |
4541 | in al, 0x60 |
4544 | xor ah, ah |
4542 | xor ah, ah |
4545 | kr_exit: |
4543 | kr_exit: |
4546 | 4544 | ||
4547 | pop edx ecx |
4545 | pop edx ecx |
4548 | 4546 | ||
4549 | ret |
4547 | ret |
4550 | ;----------------------------------------------------------------------------- |
4548 | ;----------------------------------------------------------------------------- |
4551 | align 4 |
4549 | align 4 |
4552 | kb_write: |
4550 | kb_write: |
4553 | 4551 | ||
4554 | push ecx edx |
4552 | push ecx edx |
4555 | 4553 | ||
4556 | mov dl, al |
4554 | mov dl, al |
4557 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4555 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4558 | ; kw_loop1: |
4556 | ; kw_loop1: |
4559 | ; in al,0x64 |
4557 | ; in al,0x64 |
4560 | ; test al,0x20 |
4558 | ; test al,0x20 |
4561 | ; jz kw_ok1 |
4559 | ; jz kw_ok1 |
4562 | ; loop kw_loop1 |
4560 | ; loop kw_loop1 |
4563 | ; mov ah,1 |
4561 | ; mov ah,1 |
4564 | ; jmp kw_exit |
4562 | ; jmp kw_exit |
4565 | ; kw_ok1: |
4563 | ; kw_ok1: |
4566 | in al, 0x60 |
4564 | in al, 0x60 |
4567 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4565 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4568 | kw_loop: |
4566 | kw_loop: |
4569 | in al, 0x64 |
4567 | in al, 0x64 |
4570 | test al, 2 |
4568 | test al, 2 |
4571 | jz kw_ok |
4569 | jz kw_ok |
4572 | loop kw_loop |
4570 | loop kw_loop |
4573 | mov ah, 1 |
4571 | mov ah, 1 |
4574 | jmp kw_exit |
4572 | jmp kw_exit |
4575 | kw_ok: |
4573 | kw_ok: |
4576 | mov al, dl |
4574 | mov al, dl |
4577 | out 0x60, al |
4575 | out 0x60, al |
4578 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4576 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4579 | kw_loop3: |
4577 | kw_loop3: |
4580 | in al, 0x64 |
4578 | in al, 0x64 |
4581 | test al, 2 |
4579 | test al, 2 |
4582 | jz kw_ok3 |
4580 | jz kw_ok3 |
4583 | loop kw_loop3 |
4581 | loop kw_loop3 |
4584 | mov ah, 1 |
4582 | mov ah, 1 |
4585 | jmp kw_exit |
4583 | jmp kw_exit |
4586 | kw_ok3: |
4584 | kw_ok3: |
4587 | mov ah, 8 |
4585 | mov ah, 8 |
4588 | kw_loop4: |
4586 | kw_loop4: |
4589 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4587 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4590 | kw_loop5: |
4588 | kw_loop5: |
4591 | in al, 0x64 |
4589 | in al, 0x64 |
4592 | test al, 1 |
4590 | test al, 1 |
4593 | jnz kw_ok4 |
4591 | jnz kw_ok4 |
4594 | loop kw_loop5 |
4592 | loop kw_loop5 |
4595 | dec ah |
4593 | dec ah |
4596 | jnz kw_loop4 |
4594 | jnz kw_loop4 |
4597 | kw_ok4: |
4595 | kw_ok4: |
4598 | xor ah, ah |
4596 | xor ah, ah |
4599 | kw_exit: |
4597 | kw_exit: |
4600 | 4598 | ||
4601 | pop edx ecx |
4599 | pop edx ecx |
4602 | 4600 | ||
4603 | ret |
4601 | ret |
4604 | ;----------------------------------------------------------------------------- |
4602 | ;----------------------------------------------------------------------------- |
4605 | align 4 |
4603 | align 4 |
4606 | kb_cmd: |
4604 | kb_cmd: |
4607 | 4605 | ||
4608 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4606 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4609 | c_wait: |
4607 | c_wait: |
4610 | in al, 0x64 |
4608 | in al, 0x64 |
4611 | test al, 2 |
4609 | test al, 2 |
4612 | jz c_send |
4610 | jz c_send |
4613 | loop c_wait |
4611 | loop c_wait |
4614 | jmp c_error |
4612 | jmp c_error |
4615 | c_send: |
4613 | c_send: |
4616 | mov al, bl |
4614 | mov al, bl |
4617 | out 0x64, al |
4615 | out 0x64, al |
4618 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4616 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4619 | c_accept: |
4617 | c_accept: |
4620 | in al, 0x64 |
4618 | in al, 0x64 |
4621 | test al, 2 |
4619 | test al, 2 |
4622 | jz c_ok |
4620 | jz c_ok |
4623 | loop c_accept |
4621 | loop c_accept |
4624 | c_error: |
4622 | c_error: |
4625 | mov ah, 1 |
4623 | mov ah, 1 |
4626 | jmp c_exit |
4624 | jmp c_exit |
4627 | c_ok: |
4625 | c_ok: |
4628 | xor ah, ah |
4626 | xor ah, ah |
4629 | c_exit: |
4627 | c_exit: |
4630 | ret |
4628 | ret |
4631 | 4629 | ||
4632 | 4630 | ||
4633 | setmouse: ; set mousepicture -pointer |
4631 | setmouse: ; set mousepicture -pointer |
4634 | ; ps2 mouse enable |
4632 | ; ps2 mouse enable |
4635 | 4633 | ||
4636 | ; mov [MOUSE_PICTURE], dword mousepointer |
4634 | ; mov [MOUSE_PICTURE], dword mousepointer |
4637 | 4635 | ||
4638 | cli |
4636 | cli |
4639 | 4637 | ||
4640 | ret |
4638 | ret |
4641 | 4639 | ||
4642 | if used _rdtsc |
4640 | if used _rdtsc |
4643 | _rdtsc: |
4641 | _rdtsc: |
4644 | bt [cpu_caps], CAPS_TSC |
4642 | bt [cpu_caps], CAPS_TSC |
4645 | jnc ret_rdtsc |
4643 | jnc ret_rdtsc |
4646 | rdtsc |
4644 | rdtsc |
4647 | ret |
4645 | ret |
4648 | ret_rdtsc: |
4646 | ret_rdtsc: |
4649 | mov edx, 0xffffffff |
4647 | mov edx, 0xffffffff |
4650 | mov eax, 0xffffffff |
4648 | mov eax, 0xffffffff |
4651 | ret |
4649 | ret |
4652 | end if |
4650 | end if |
4653 | 4651 | ||
4654 | sys_msg_board_str: |
4652 | sys_msg_board_str: |
4655 | 4653 | ||
4656 | pushad |
4654 | pushad |
4657 | @@: |
4655 | @@: |
4658 | cmp [esi], byte 0 |
4656 | cmp [esi], byte 0 |
4659 | je @f |
4657 | je @f |
4660 | mov eax, 1 |
4658 | mov eax, 1 |
4661 | movzx ebx, byte [esi] |
4659 | movzx ebx, byte [esi] |
4662 | call sys_msg_board |
4660 | call sys_msg_board |
4663 | inc esi |
4661 | inc esi |
4664 | jmp @b |
4662 | jmp @b |
4665 | @@: |
4663 | @@: |
4666 | popad |
4664 | popad |
4667 | ret |
4665 | ret |
4668 | 4666 | ||
4669 | sys_msg_board_byte: |
4667 | sys_msg_board_byte: |
4670 | ; in: al = byte to display |
4668 | ; in: al = byte to display |
4671 | ; out: nothing |
4669 | ; out: nothing |
4672 | ; destroys: nothing |
4670 | ; destroys: nothing |
4673 | pushad |
4671 | pushad |
4674 | mov ecx, 2 |
4672 | mov ecx, 2 |
4675 | shl eax, 24 |
4673 | shl eax, 24 |
4676 | jmp @f |
4674 | jmp @f |
4677 | 4675 | ||
4678 | sys_msg_board_word: |
4676 | sys_msg_board_word: |
4679 | ; in: ax = word to display |
4677 | ; in: ax = word to display |
4680 | ; out: nothing |
4678 | ; out: nothing |
4681 | ; destroys: nothing |
4679 | ; destroys: nothing |
4682 | pushad |
4680 | pushad |
4683 | mov ecx, 4 |
4681 | mov ecx, 4 |
4684 | shl eax, 16 |
4682 | shl eax, 16 |
4685 | jmp @f |
4683 | jmp @f |
4686 | 4684 | ||
4687 | sys_msg_board_dword: |
4685 | sys_msg_board_dword: |
4688 | ; in: eax = dword to display |
4686 | ; in: eax = dword to display |
4689 | ; out: nothing |
4687 | ; out: nothing |
4690 | ; destroys: nothing |
4688 | ; destroys: nothing |
4691 | pushad |
4689 | pushad |
4692 | mov ecx, 8 |
4690 | mov ecx, 8 |
4693 | @@: |
4691 | @@: |
4694 | push ecx |
4692 | push ecx |
4695 | rol eax, 4 |
4693 | rol eax, 4 |
4696 | push eax |
4694 | push eax |
4697 | and al, 0xF |
4695 | and al, 0xF |
4698 | cmp al, 10 |
4696 | cmp al, 10 |
4699 | sbb al, 69h |
4697 | sbb al, 69h |
4700 | das |
4698 | das |
4701 | mov bl, al |
4699 | mov bl, al |
4702 | xor eax, eax |
4700 | xor eax, eax |
4703 | inc eax |
4701 | inc eax |
4704 | call sys_msg_board |
4702 | call sys_msg_board |
4705 | pop eax |
4703 | pop eax |
4706 | pop ecx |
4704 | pop ecx |
4707 | loop @b |
4705 | loop @b |
4708 | popad |
4706 | popad |
4709 | ret |
4707 | ret |
4710 | 4708 | ||
4711 | msg_board_data_size = 65536 ; Must be power of two |
4709 | msg_board_data_size = 65536 ; Must be power of two |
4712 | 4710 | ||
4713 | uglobal |
4711 | uglobal |
4714 | msg_board_data rb msg_board_data_size |
4712 | msg_board_data rb msg_board_data_size |
4715 | msg_board_count dd 0x0 |
4713 | msg_board_count dd 0x0 |
4716 | endg |
4714 | endg |
4717 | 4715 | ||
4718 | sys_msg_board: |
4716 | sys_msg_board: |
4719 | 4717 | ||
4720 | ; eax=1 : write : bl byte to write |
4718 | ; eax=1 : write : bl byte to write |
4721 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4719 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4722 | 4720 | ||
4723 | mov ecx, [msg_board_count] |
4721 | mov ecx, [msg_board_count] |
4724 | cmp eax, 1 |
4722 | cmp eax, 1 |
4725 | jne .smbl1 |
4723 | jne .smbl1 |
4726 | 4724 | ||
4727 | if defined debug_com_base |
4725 | if defined debug_com_base |
4728 | 4726 | ||
4729 | push dx ax |
4727 | push dx ax |
4730 | 4728 | ||
4731 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4729 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4732 | mov dx, debug_com_base+5 |
4730 | mov dx, debug_com_base+5 |
4733 | in al, dx |
4731 | in al, dx |
4734 | test al, 1 shl 5 |
4732 | test al, 1 shl 5 |
4735 | jz @r |
4733 | jz @r |
4736 | 4734 | ||
4737 | mov dx, debug_com_base ; Output the byte |
4735 | mov dx, debug_com_base ; Output the byte |
4738 | mov al, bl |
4736 | mov al, bl |
4739 | out dx, al |
4737 | out dx, al |
4740 | 4738 | ||
4741 | pop ax dx |
4739 | pop ax dx |
4742 | 4740 | ||
4743 | end if |
4741 | end if |
4744 | 4742 | ||
4745 | mov [msg_board_data+ecx], bl |
4743 | mov [msg_board_data+ecx], bl |
4746 | if debug_direct_print |
4744 | if debug_direct_print |
4747 | pusha |
4745 | pusha |
4748 | iglobal |
4746 | iglobal |
4749 | msg_board_pos dd 234*65536+10 |
4747 | msg_board_pos dd 234*65536+10 |
4750 | endg |
4748 | endg |
4751 | lea edx, [msg_board_data+ecx] |
4749 | lea edx, [msg_board_data+ecx] |
4752 | mov ecx, 0x40FFFFFF |
4750 | mov ecx, 0x40FFFFFF |
4753 | mov ebx, [msg_board_pos] |
4751 | mov ebx, [msg_board_pos] |
4754 | mov edi, 1 |
4752 | mov edi, 1 |
4755 | mov esi, 1 |
4753 | mov esi, 1 |
4756 | call dtext |
4754 | call dtext |
4757 | popa |
4755 | popa |
4758 | add word [msg_board_pos+2], 6 |
4756 | add word [msg_board_pos+2], 6 |
4759 | cmp bl, 10 |
4757 | cmp bl, 10 |
4760 | jnz @f |
4758 | jnz @f |
4761 | mov word [msg_board_pos+2], 234 |
4759 | mov word [msg_board_pos+2], 234 |
4762 | add word [msg_board_pos], 10 |
4760 | add word [msg_board_pos], 10 |
4763 | mov ax, [Screen_Max_Y] |
4761 | mov ax, [Screen_Max_Y] |
4764 | cmp word [msg_board_pos], ax |
4762 | cmp word [msg_board_pos], ax |
4765 | jbe @f |
4763 | jbe @f |
4766 | mov word [msg_board_pos], 10 |
4764 | mov word [msg_board_pos], 10 |
4767 | @@: |
4765 | @@: |
4768 | end if |
4766 | end if |
4769 | if 0 |
4767 | if 0 |
4770 | pusha |
4768 | pusha |
4771 | mov al, bl |
4769 | mov al, bl |
4772 | mov edx, 402h |
4770 | mov edx, 402h |
4773 | out dx, al |
4771 | out dx, al |
4774 | popa |
4772 | popa |
4775 | end if |
4773 | end if |
4776 | inc ecx |
4774 | inc ecx |
4777 | and ecx, msg_board_data_size - 1 |
4775 | and ecx, msg_board_data_size - 1 |
4778 | mov [msg_board_count], ecx |
4776 | mov [msg_board_count], ecx |
4779 | ret |
4777 | ret |
4780 | .smbl1: |
4778 | .smbl1: |
4781 | cmp eax, 2 |
4779 | cmp eax, 2 |
4782 | jne .smbl2 |
4780 | jne .smbl2 |
4783 | test ecx, ecx |
4781 | test ecx, ecx |
4784 | jz .smbl21 |
4782 | jz .smbl21 |
4785 | mov eax, msg_board_data+1 |
4783 | mov eax, msg_board_data+1 |
4786 | mov ebx, msg_board_data |
4784 | mov ebx, msg_board_data |
4787 | movzx edx, byte [ebx] |
4785 | movzx edx, byte [ebx] |
4788 | call memmove |
4786 | call memmove |
4789 | dec [msg_board_count] |
4787 | dec [msg_board_count] |
4790 | mov [esp + 36], edx ;eax |
4788 | mov [esp + 36], edx ;eax |
4791 | mov [esp + 24], dword 1 |
4789 | mov [esp + 24], dword 1 |
4792 | ret |
4790 | ret |
4793 | .smbl21: |
4791 | .smbl21: |
4794 | mov [esp+36], ecx |
4792 | mov [esp+36], ecx |
4795 | mov [esp+24], ecx |
4793 | mov [esp+24], ecx |
4796 | .smbl2: |
4794 | .smbl2: |
4797 | ret |
4795 | ret |
4798 | 4796 | ||
4799 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4797 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4800 | ;; 66 sys function. ;; |
4798 | ;; 66 sys function. ;; |
4801 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4799 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4802 | ;; out eax ;; |
4800 | ;; out eax ;; |
4803 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4801 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4804 | iglobal |
4802 | iglobal |
4805 | align 4 |
4803 | align 4 |
4806 | f66call: |
4804 | f66call: |
4807 | dd sys_process_def.1 ; 1 = set keyboard mode |
4805 | dd sys_process_def.1 ; 1 = set keyboard mode |
4808 | dd sys_process_def.2 ; 2 = get keyboard mode |
4806 | dd sys_process_def.2 ; 2 = get keyboard mode |
4809 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4807 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4810 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4808 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4811 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4809 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4812 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4810 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4813 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4811 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4814 | endg |
4812 | endg |
4815 | ;----------------------------------------------------------------------------- |
4813 | ;----------------------------------------------------------------------------- |
4816 | align 4 |
4814 | align 4 |
4817 | sys_process_def: |
4815 | sys_process_def: |
4818 | dec ebx |
4816 | dec ebx |
4819 | cmp ebx, 7 |
4817 | cmp ebx, 7 |
4820 | jae .not_support ;if >=8 then or eax,-1 |
4818 | jae .not_support ;if >=8 then or eax,-1 |
4821 | 4819 | ||
4822 | mov edi, [CURRENT_TASK] |
4820 | mov edi, [CURRENT_TASK] |
4823 | jmp dword [f66call+ebx*4] |
4821 | jmp dword [f66call+ebx*4] |
4824 | 4822 | ||
4825 | .not_support: |
4823 | .not_support: |
4826 | or eax, -1 |
4824 | or eax, -1 |
4827 | ret |
4825 | ret |
4828 | ;----------------------------------------------------------------------------- |
4826 | ;----------------------------------------------------------------------------- |
4829 | align 4 |
4827 | align 4 |
4830 | .1: |
4828 | .1: |
4831 | shl edi, 8 |
4829 | shl edi, 8 |
4832 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4830 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4833 | 4831 | ||
4834 | ret |
4832 | ret |
4835 | ;----------------------------------------------------------------------------- |
4833 | ;----------------------------------------------------------------------------- |
4836 | align 4 |
4834 | align 4 |
4837 | .2: ; 2 = get keyboard mode |
4835 | .2: ; 2 = get keyboard mode |
4838 | shl edi, 8 |
4836 | shl edi, 8 |
4839 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4837 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4840 | mov [esp+32], eax |
4838 | mov [esp+32], eax |
4841 | ret |
4839 | ret |
4842 | ;----------------------------------------------------------------------------- |
4840 | ;----------------------------------------------------------------------------- |
4843 | align 4 |
4841 | align 4 |
4844 | .3: ;3 = get keyboard ctrl, alt, shift |
4842 | .3: ;3 = get keyboard ctrl, alt, shift |
4845 | mov eax, [kb_state] |
4843 | mov eax, [kb_state] |
4846 | mov [esp+32], eax |
4844 | mov [esp+32], eax |
4847 | ret |
4845 | ret |
4848 | ;----------------------------------------------------------------------------- |
4846 | ;----------------------------------------------------------------------------- |
4849 | align 4 |
4847 | align 4 |
4850 | .4: |
4848 | .4: |
4851 | mov eax, hotkey_list |
4849 | mov eax, hotkey_list |
4852 | @@: |
4850 | @@: |
4853 | cmp dword [eax+8], 0 |
4851 | cmp dword [eax+8], 0 |
4854 | jz .found_free |
4852 | jz .found_free |
4855 | add eax, 16 |
4853 | add eax, 16 |
4856 | cmp eax, hotkey_list+16*256 |
4854 | cmp eax, hotkey_list+16*256 |
4857 | jb @b |
4855 | jb @b |
4858 | mov dword [esp+32], 1 |
4856 | mov dword [esp+32], 1 |
4859 | ret |
4857 | ret |
4860 | .found_free: |
4858 | .found_free: |
4861 | mov [eax+8], edi |
4859 | mov [eax+8], edi |
4862 | mov [eax+4], edx |
4860 | mov [eax+4], edx |
4863 | movzx ecx, cl |
4861 | movzx ecx, cl |
4864 | lea ecx, [hotkey_scancodes+ecx*4] |
4862 | lea ecx, [hotkey_scancodes+ecx*4] |
4865 | mov edx, [ecx] |
4863 | mov edx, [ecx] |
4866 | mov [eax], edx |
4864 | mov [eax], edx |
4867 | mov [ecx], eax |
4865 | mov [ecx], eax |
4868 | mov [eax+12], ecx |
4866 | mov [eax+12], ecx |
4869 | test edx, edx |
4867 | test edx, edx |
4870 | jz @f |
4868 | jz @f |
4871 | mov [edx+12], eax |
4869 | mov [edx+12], eax |
4872 | @@: |
4870 | @@: |
4873 | and dword [esp+32], 0 |
4871 | and dword [esp+32], 0 |
4874 | ret |
4872 | ret |
4875 | ;----------------------------------------------------------------------------- |
4873 | ;----------------------------------------------------------------------------- |
4876 | align 4 |
4874 | align 4 |
4877 | .5: |
4875 | .5: |
4878 | movzx ebx, cl |
4876 | movzx ebx, cl |
4879 | lea ebx, [hotkey_scancodes+ebx*4] |
4877 | lea ebx, [hotkey_scancodes+ebx*4] |
4880 | mov eax, [ebx] |
4878 | mov eax, [ebx] |
4881 | .scan: |
4879 | .scan: |
4882 | test eax, eax |
4880 | test eax, eax |
4883 | jz .notfound |
4881 | jz .notfound |
4884 | cmp [eax+8], edi |
4882 | cmp [eax+8], edi |
4885 | jnz .next |
4883 | jnz .next |
4886 | cmp [eax+4], edx |
4884 | cmp [eax+4], edx |
4887 | jz .found |
4885 | jz .found |
4888 | .next: |
4886 | .next: |
4889 | mov eax, [eax] |
4887 | mov eax, [eax] |
4890 | jmp .scan |
4888 | jmp .scan |
4891 | .notfound: |
4889 | .notfound: |
4892 | mov dword [esp+32], 1 |
4890 | mov dword [esp+32], 1 |
4893 | ret |
4891 | ret |
4894 | .found: |
4892 | .found: |
4895 | mov ecx, [eax] |
4893 | mov ecx, [eax] |
4896 | jecxz @f |
4894 | jecxz @f |
4897 | mov edx, [eax+12] |
4895 | mov edx, [eax+12] |
4898 | mov [ecx+12], edx |
4896 | mov [ecx+12], edx |
4899 | @@: |
4897 | @@: |
4900 | mov ecx, [eax+12] |
4898 | mov ecx, [eax+12] |
4901 | mov edx, [eax] |
4899 | mov edx, [eax] |
4902 | mov [ecx], edx |
4900 | mov [ecx], edx |
4903 | xor edx, edx |
4901 | xor edx, edx |
4904 | mov [eax+4], edx |
4902 | mov [eax+4], edx |
4905 | mov [eax+8], edx |
4903 | mov [eax+8], edx |
4906 | mov [eax+12], edx |
4904 | mov [eax+12], edx |
4907 | mov [eax], edx |
4905 | mov [eax], edx |
4908 | mov [esp+32], edx |
4906 | mov [esp+32], edx |
4909 | ret |
4907 | ret |
4910 | ;----------------------------------------------------------------------------- |
4908 | ;----------------------------------------------------------------------------- |
4911 | align 4 |
4909 | align 4 |
4912 | .6: |
4910 | .6: |
4913 | pushfd |
4911 | pushfd |
4914 | cli |
4912 | cli |
4915 | mov eax, [PID_lock_input] |
4913 | mov eax, [PID_lock_input] |
4916 | test eax, eax |
4914 | test eax, eax |
4917 | jnz @f |
4915 | jnz @f |
4918 | ; get current PID |
4916 | ; get current PID |
4919 | mov eax, [CURRENT_TASK] |
4917 | mov eax, [CURRENT_TASK] |
4920 | shl eax, 5 |
4918 | shl eax, 5 |
4921 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4919 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4922 | ; set current PID for lock input |
4920 | ; set current PID for lock input |
4923 | mov [PID_lock_input], eax |
4921 | mov [PID_lock_input], eax |
4924 | @@: |
4922 | @@: |
4925 | popfd |
4923 | popfd |
4926 | ret |
4924 | ret |
4927 | ;----------------------------------------------------------------------------- |
4925 | ;----------------------------------------------------------------------------- |
4928 | align 4 |
4926 | align 4 |
4929 | .7: |
4927 | .7: |
4930 | mov eax, [PID_lock_input] |
4928 | mov eax, [PID_lock_input] |
4931 | test eax, eax |
4929 | test eax, eax |
4932 | jz @f |
4930 | jz @f |
4933 | ; get current PID |
4931 | ; get current PID |
4934 | mov ebx, [CURRENT_TASK] |
4932 | mov ebx, [CURRENT_TASK] |
4935 | shl ebx, 5 |
4933 | shl ebx, 5 |
4936 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4934 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4937 | ; compare current lock input with current PID |
4935 | ; compare current lock input with current PID |
4938 | cmp ebx, eax |
4936 | cmp ebx, eax |
4939 | jne @f |
4937 | jne @f |
4940 | 4938 | ||
4941 | xor eax, eax |
4939 | xor eax, eax |
4942 | mov [PID_lock_input], eax |
4940 | mov [PID_lock_input], eax |
4943 | @@: |
4941 | @@: |
4944 | ret |
4942 | ret |
4945 | ;----------------------------------------------------------------------------- |
4943 | ;----------------------------------------------------------------------------- |
4946 | uglobal |
4944 | uglobal |
4947 | PID_lock_input dd 0x0 |
4945 | PID_lock_input dd 0x0 |
4948 | endg |
4946 | endg |
4949 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4947 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4950 | ;; 61 sys function. ;; |
4948 | ;; 61 sys function. ;; |
4951 | ;; in eax=61,ebx in [1..3] ;; |
4949 | ;; in eax=61,ebx in [1..3] ;; |
4952 | ;; out eax ;; |
4950 | ;; out eax ;; |
4953 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4951 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4954 | iglobal |
4952 | iglobal |
4955 | align 4 |
4953 | align 4 |
4956 | f61call: |
4954 | f61call: |
4957 | dd sys_gs.1 ; resolution |
4955 | dd sys_gs.1 ; resolution |
4958 | dd sys_gs.2 ; bits per pixel |
4956 | dd sys_gs.2 ; bits per pixel |
4959 | dd sys_gs.3 ; bytes per scanline |
4957 | dd sys_gs.3 ; bytes per scanline |
4960 | endg |
4958 | endg |
4961 | 4959 | ||
4962 | 4960 | ||
4963 | align 4 |
4961 | align 4 |
4964 | 4962 | ||
4965 | sys_gs: ; direct screen access |
4963 | sys_gs: ; direct screen access |
4966 | dec ebx |
4964 | dec ebx |
4967 | cmp ebx, 2 |
4965 | cmp ebx, 2 |
4968 | ja .not_support |
4966 | ja .not_support |
4969 | jmp dword [f61call+ebx*4] |
4967 | jmp dword [f61call+ebx*4] |
4970 | .not_support: |
4968 | .not_support: |
4971 | or [esp+32], dword -1 |
4969 | or [esp+32], dword -1 |
4972 | ret |
4970 | ret |
4973 | 4971 | ||
4974 | 4972 | ||
4975 | .1: ; resolution |
4973 | .1: ; resolution |
4976 | mov eax, [Screen_Max_X] |
4974 | mov eax, [Screen_Max_X] |
4977 | shl eax, 16 |
4975 | shl eax, 16 |
4978 | mov ax, [Screen_Max_Y] |
4976 | mov ax, [Screen_Max_Y] |
4979 | add eax, 0x00010001 |
4977 | add eax, 0x00010001 |
4980 | mov [esp+32], eax |
4978 | mov [esp+32], eax |
4981 | ret |
4979 | ret |
4982 | .2: ; bits per pixel |
4980 | .2: ; bits per pixel |
4983 | movzx eax, byte [ScreenBPP] |
4981 | mov eax, [_display.bpp] |
4984 | mov [esp+32], eax |
4982 | mov [esp+32], eax |
4985 | ret |
4983 | ret |
4986 | .3: ; bytes per scanline |
4984 | .3: ; bytes per scanline |
4987 | mov eax, [BytesPerScanLine] |
4985 | mov eax, [BytesPerScanLine] |
4988 | mov [esp+32], eax |
4986 | mov [esp+32], eax |
4989 | ret |
4987 | ret |
4990 | 4988 | ||
4991 | align 4 ; system functions |
4989 | align 4 ; system functions |
4992 | 4990 | ||
4993 | syscall_setpixel: ; SetPixel |
4991 | syscall_setpixel: ; SetPixel |
4994 | 4992 | ||
4995 | mov eax, ebx |
4993 | mov eax, ebx |
4996 | mov ebx, ecx |
4994 | mov ebx, ecx |
4997 | mov ecx, edx |
4995 | mov ecx, edx |
4998 | mov edx, [TASK_BASE] |
4996 | mov edx, [TASK_BASE] |
4999 | add eax, [edx-twdw+WDATA.box.left] |
4997 | add eax, [edx-twdw+WDATA.box.left] |
5000 | add ebx, [edx-twdw+WDATA.box.top] |
4998 | add ebx, [edx-twdw+WDATA.box.top] |
5001 | mov edi, [current_slot] |
4999 | mov edi, [current_slot] |
5002 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5000 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5003 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5001 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5004 | xor edi, edi ; no force |
5002 | xor edi, edi ; no force |
5005 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5003 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5006 | ; jmp [putpixel] |
5004 | ; jmp [putpixel] |
5007 | jmp __sys_putpixel |
5005 | jmp __sys_putpixel |
5008 | 5006 | ||
5009 | align 4 |
5007 | align 4 |
5010 | 5008 | ||
5011 | syscall_writetext: ; WriteText |
5009 | syscall_writetext: ; WriteText |
5012 | 5010 | ||
5013 | mov eax, [TASK_BASE] |
5011 | mov eax, [TASK_BASE] |
5014 | mov ebp, [eax-twdw+WDATA.box.left] |
5012 | mov ebp, [eax-twdw+WDATA.box.left] |
5015 | push esi |
5013 | push esi |
5016 | mov esi, [current_slot] |
5014 | mov esi, [current_slot] |
5017 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5015 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5018 | shl ebp, 16 |
5016 | shl ebp, 16 |
5019 | add ebp, [eax-twdw+WDATA.box.top] |
5017 | add ebp, [eax-twdw+WDATA.box.top] |
5020 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5018 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5021 | pop esi |
5019 | pop esi |
5022 | test ecx, 0x08000000 ; redirect the output to the user area |
5020 | test ecx, 0x08000000 ; redirect the output to the user area |
5023 | jnz @f |
5021 | jnz @f |
5024 | add ebx, ebp |
5022 | add ebx, ebp |
5025 | align 4 |
5023 | align 4 |
5026 | @@: |
5024 | @@: |
5027 | mov eax, edi |
5025 | mov eax, edi |
5028 | test ecx, 0x08000000 ; redirect the output to the user area |
5026 | test ecx, 0x08000000 ; redirect the output to the user area |
5029 | jnz dtext |
5027 | jnz dtext |
5030 | xor edi, edi |
5028 | xor edi, edi |
5031 | jmp dtext |
5029 | jmp dtext |
5032 | 5030 | ||
5033 | align 4 |
5031 | align 4 |
5034 | 5032 | ||
5035 | syscall_openramdiskfile: ; OpenRamdiskFile |
5033 | syscall_openramdiskfile: ; OpenRamdiskFile |
5036 | 5034 | ||
5037 | mov eax, ebx |
5035 | mov eax, ebx |
5038 | mov ebx, ecx |
5036 | mov ebx, ecx |
5039 | mov ecx, edx |
5037 | mov ecx, edx |
5040 | mov edx, esi |
5038 | mov edx, esi |
5041 | mov esi, 12 |
5039 | mov esi, 12 |
5042 | call fileread |
5040 | call fileread |
5043 | mov [esp+32], eax |
5041 | mov [esp+32], eax |
5044 | ret |
5042 | ret |
5045 | 5043 | ||
5046 | align 4 |
5044 | align 4 |
5047 | 5045 | ||
5048 | syscall_drawrect: ; DrawRect |
5046 | syscall_drawrect: ; DrawRect |
5049 | 5047 | ||
5050 | mov edi, edx ; color + gradient |
5048 | mov edi, edx ; color + gradient |
5051 | and edi, 0x80FFFFFF |
5049 | and edi, 0x80FFFFFF |
5052 | test bx, bx ; x.size |
5050 | test bx, bx ; x.size |
5053 | je .drectr |
5051 | je .drectr |
5054 | test cx, cx ; y.size |
5052 | test cx, cx ; y.size |
5055 | je .drectr |
5053 | je .drectr |
5056 | 5054 | ||
5057 | mov eax, ebx ; bad idea |
5055 | mov eax, ebx ; bad idea |
5058 | mov ebx, ecx |
5056 | mov ebx, ecx |
5059 | 5057 | ||
5060 | movzx ecx, ax ; ecx - x.size |
5058 | movzx ecx, ax ; ecx - x.size |
5061 | shr eax, 16 ; eax - x.coord |
5059 | shr eax, 16 ; eax - x.coord |
5062 | movzx edx, bx ; edx - y.size |
5060 | movzx edx, bx ; edx - y.size |
5063 | shr ebx, 16 ; ebx - y.coord |
5061 | shr ebx, 16 ; ebx - y.coord |
5064 | mov esi, [current_slot] |
5062 | mov esi, [current_slot] |
5065 | 5063 | ||
5066 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5064 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5067 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5065 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5068 | add ecx, eax |
5066 | add ecx, eax |
5069 | add edx, ebx |
5067 | add edx, ebx |
5070 | ; jmp [drawbar] |
5068 | ; jmp [drawbar] |
5071 | jmp vesa20_drawbar |
5069 | jmp vesa20_drawbar |
5072 | .drectr: |
5070 | .drectr: |
5073 | ret |
5071 | ret |
5074 | 5072 | ||
5075 | align 4 |
5073 | align 4 |
5076 | syscall_getscreensize: ; GetScreenSize |
5074 | syscall_getscreensize: ; GetScreenSize |
5077 | mov ax, [Screen_Max_X] |
5075 | mov ax, [Screen_Max_X] |
5078 | shl eax, 16 |
5076 | shl eax, 16 |
5079 | mov ax, [Screen_Max_Y] |
5077 | mov ax, [Screen_Max_Y] |
5080 | mov [esp + 32], eax |
5078 | mov [esp + 32], eax |
5081 | ret |
5079 | ret |
5082 | 5080 | ||
5083 | align 4 |
5081 | align 4 |
5084 | 5082 | ||
5085 | syscall_cdaudio: ; CD |
5083 | syscall_cdaudio: ; CD |
5086 | 5084 | ||
5087 | cmp ebx, 4 |
5085 | cmp ebx, 4 |
5088 | jb .audio |
5086 | jb .audio |
5089 | jz .eject |
5087 | jz .eject |
5090 | cmp ebx, 5 |
5088 | cmp ebx, 5 |
5091 | jnz .ret |
5089 | jnz .ret |
5092 | .load: |
5090 | .load: |
5093 | call .reserve |
5091 | call .reserve |
5094 | call LoadMedium |
5092 | call LoadMedium |
5095 | ;call .free |
5093 | ;call .free |
5096 | jmp .free |
5094 | jmp .free |
5097 | ; ret |
5095 | ; ret |
5098 | .eject: |
5096 | .eject: |
5099 | call .reserve |
5097 | call .reserve |
5100 | call clear_CD_cache |
5098 | call clear_CD_cache |
5101 | call allow_medium_removal |
5099 | call allow_medium_removal |
5102 | call EjectMedium |
5100 | call EjectMedium |
5103 | ; call .free |
5101 | ; call .free |
5104 | jmp .free |
5102 | jmp .free |
5105 | ; ret |
5103 | ; ret |
5106 | .audio: |
5104 | .audio: |
5107 | call sys_cd_audio |
5105 | call sys_cd_audio |
5108 | mov [esp+36-4], eax |
5106 | mov [esp+36-4], eax |
5109 | .ret: |
5107 | .ret: |
5110 | ret |
5108 | ret |
5111 | 5109 | ||
5112 | .reserve: |
5110 | .reserve: |
5113 | call reserve_cd |
5111 | call reserve_cd |
5114 | mov eax, ecx |
5112 | mov eax, ecx |
5115 | shr eax, 1 |
5113 | shr eax, 1 |
5116 | and eax, 1 |
5114 | and eax, 1 |
5117 | inc eax |
5115 | inc eax |
5118 | mov [ChannelNumber], ax |
5116 | mov [ChannelNumber], ax |
5119 | mov eax, ecx |
5117 | mov eax, ecx |
5120 | and eax, 1 |
5118 | and eax, 1 |
5121 | mov [DiskNumber], al |
5119 | mov [DiskNumber], al |
5122 | call reserve_cd_channel |
5120 | call reserve_cd_channel |
5123 | and ebx, 3 |
5121 | and ebx, 3 |
5124 | inc ebx |
5122 | inc ebx |
5125 | mov [cdpos], ebx |
5123 | mov [cdpos], ebx |
5126 | add ebx, ebx |
5124 | add ebx, ebx |
5127 | mov cl, 8 |
5125 | mov cl, 8 |
5128 | sub cl, bl |
5126 | sub cl, bl |
5129 | mov al, [DRIVE_DATA+1] |
5127 | mov al, [DRIVE_DATA+1] |
5130 | shr al, cl |
5128 | shr al, cl |
5131 | test al, 2 |
5129 | test al, 2 |
5132 | jz .free;.err |
5130 | jz .free;.err |
5133 | ret |
5131 | ret |
5134 | .free: |
5132 | .free: |
5135 | call free_cd_channel |
5133 | call free_cd_channel |
5136 | and [cd_status], 0 |
5134 | and [cd_status], 0 |
5137 | ret |
5135 | ret |
5138 | .err: |
5136 | .err: |
5139 | call .free |
5137 | call .free |
5140 | ; pop eax |
5138 | ; pop eax |
5141 | ret |
5139 | ret |
5142 | ;----------------------------------------------------------------------------- |
5140 | ;----------------------------------------------------------------------------- |
5143 | align 4 |
5141 | align 4 |
5144 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5142 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5145 | cmp ebx, [Screen_Max_X] |
5143 | cmp ebx, [Screen_Max_X] |
5146 | jbe @f |
5144 | jbe @f |
5147 | cmp ecx, [Screen_Max_Y] |
5145 | cmp ecx, [Screen_Max_Y] |
5148 | jbe @f |
5146 | jbe @f |
5149 | xor eax, eax |
5147 | xor eax, eax |
5150 | jmp .store |
5148 | jmp .store |
5151 | ;-------------------------------------- |
5149 | ;-------------------------------------- |
5152 | align 4 |
5150 | align 4 |
5153 | @@: |
5151 | @@: |
5154 | mov eax, [d_width_calc_area + ecx*4] |
5152 | mov eax, [d_width_calc_area + ecx*4] |
5155 | add eax, [_WinMapAddress] |
5153 | add eax, [_WinMapAddress] |
5156 | movzx eax, byte[eax+ebx] ; get value for current point |
5154 | movzx eax, byte[eax+ebx] ; get value for current point |
5157 | ;-------------------------------------- |
5155 | ;-------------------------------------- |
5158 | align 4 |
5156 | align 4 |
5159 | .store: |
5157 | .store: |
5160 | mov [esp + 32], eax |
5158 | mov [esp + 32], eax |
5161 | ret |
5159 | ret |
5162 | ;----------------------------------------------------------------------------- |
5160 | ;----------------------------------------------------------------------------- |
5163 | align 4 |
5161 | align 4 |
5164 | syscall_getpixel: ; GetPixel |
5162 | syscall_getpixel: ; GetPixel |
5165 | mov ecx, [Screen_Max_X] |
5163 | mov ecx, [Screen_Max_X] |
5166 | inc ecx |
5164 | inc ecx |
5167 | xor edx, edx |
5165 | xor edx, edx |
5168 | mov eax, ebx |
5166 | mov eax, ebx |
5169 | div ecx |
5167 | div ecx |
5170 | mov ebx, edx |
5168 | mov ebx, edx |
5171 | xchg eax, ebx |
5169 | xchg eax, ebx |
5172 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5170 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5173 | call dword [GETPIXEL]; eax - x, ebx - y |
5171 | call dword [GETPIXEL]; eax - x, ebx - y |
5174 | mov [esp + 32], ecx |
5172 | mov [esp + 32], ecx |
5175 | ret |
5173 | ret |
5176 | ;----------------------------------------------------------------------------- |
5174 | ;----------------------------------------------------------------------------- |
5177 | align 4 |
5175 | align 4 |
5178 | syscall_getarea: |
5176 | syscall_getarea: |
5179 | ;eax = 36 |
5177 | ;eax = 36 |
5180 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5178 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5181 | ;ecx = [size x]*65536 + [size y] |
5179 | ;ecx = [size x]*65536 + [size y] |
5182 | ;edx = [start x]*65536 + [start y] |
5180 | ;edx = [start x]*65536 + [start y] |
5183 | pushad |
5181 | pushad |
5184 | mov edi, ebx |
5182 | mov edi, ebx |
5185 | mov eax, edx |
5183 | mov eax, edx |
5186 | shr eax, 16 |
5184 | shr eax, 16 |
5187 | mov ebx, edx |
5185 | mov ebx, edx |
5188 | and ebx, 0xffff |
5186 | and ebx, 0xffff |
5189 | dec eax |
5187 | dec eax |
5190 | dec ebx |
5188 | dec ebx |
5191 | ; eax - x, ebx - y |
5189 | ; eax - x, ebx - y |
5192 | mov edx, ecx |
5190 | mov edx, ecx |
5193 | 5191 | ||
5194 | shr ecx, 16 |
5192 | shr ecx, 16 |
5195 | and edx, 0xffff |
5193 | and edx, 0xffff |
5196 | mov esi, ecx |
5194 | mov esi, ecx |
5197 | ; ecx - size x, edx - size y |
5195 | ; ecx - size x, edx - size y |
5198 | 5196 | ||
5199 | mov ebp, edx |
5197 | mov ebp, edx |
5200 | dec ebp |
5198 | dec ebp |
5201 | lea ebp, [ebp*3] |
5199 | lea ebp, [ebp*3] |
5202 | 5200 | ||
5203 | imul ebp, esi |
5201 | imul ebp, esi |
5204 | 5202 | ||
5205 | mov esi, ecx |
5203 | mov esi, ecx |
5206 | dec esi |
5204 | dec esi |
5207 | lea esi, [esi*3] |
5205 | lea esi, [esi*3] |
5208 | 5206 | ||
5209 | add ebp, esi |
5207 | add ebp, esi |
5210 | add ebp, edi |
5208 | add ebp, edi |
5211 | 5209 | ||
5212 | add ebx, edx |
5210 | add ebx, edx |
5213 | ;-------------------------------------- |
5211 | ;-------------------------------------- |
5214 | align 4 |
5212 | align 4 |
5215 | .start_y: |
5213 | .start_y: |
5216 | push ecx edx |
5214 | push ecx edx |
5217 | ;-------------------------------------- |
5215 | ;-------------------------------------- |
5218 | align 4 |
5216 | align 4 |
5219 | .start_x: |
5217 | .start_x: |
5220 | push eax ebx ecx |
5218 | push eax ebx ecx |
5221 | add eax, ecx |
5219 | add eax, ecx |
5222 | 5220 | ||
5223 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5221 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5224 | call dword [GETPIXEL]; eax - x, ebx - y |
5222 | call dword [GETPIXEL]; eax - x, ebx - y |
5225 | 5223 | ||
5226 | mov [ebp], cx |
5224 | mov [ebp], cx |
5227 | shr ecx, 16 |
5225 | shr ecx, 16 |
5228 | mov [ebp+2], cl |
5226 | mov [ebp+2], cl |
5229 | 5227 | ||
5230 | pop ecx ebx eax |
5228 | pop ecx ebx eax |
5231 | sub ebp, 3 |
5229 | sub ebp, 3 |
5232 | dec ecx |
5230 | dec ecx |
5233 | jnz .start_x |
5231 | jnz .start_x |
5234 | pop edx ecx |
5232 | pop edx ecx |
5235 | dec ebx |
5233 | dec ebx |
5236 | dec edx |
5234 | dec edx |
5237 | jnz .start_y |
5235 | jnz .start_y |
5238 | popad |
5236 | popad |
5239 | ret |
5237 | ret |
5240 | ;----------------------------------------------------------------------------- |
5238 | ;----------------------------------------------------------------------------- |
5241 | align 4 |
5239 | align 4 |
5242 | syscall_putarea_backgr: |
5240 | syscall_putarea_backgr: |
5243 | ;eax = 25 |
5241 | ;eax = 25 |
5244 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5242 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5245 | ;ecx = [size x]*65536 + [size y] |
5243 | ;ecx = [size x]*65536 + [size y] |
5246 | ;edx = [start x]*65536 + [start y] |
5244 | ;edx = [start x]*65536 + [start y] |
5247 | pushad |
5245 | pushad |
5248 | mov edi, ebx |
5246 | mov edi, ebx |
5249 | mov eax, edx |
5247 | mov eax, edx |
5250 | shr eax, 16 |
5248 | shr eax, 16 |
5251 | mov ebx, edx |
5249 | mov ebx, edx |
5252 | and ebx, 0xffff |
5250 | and ebx, 0xffff |
5253 | dec eax |
5251 | dec eax |
5254 | dec ebx |
5252 | dec ebx |
5255 | ; eax - x, ebx - y |
5253 | ; eax - x, ebx - y |
5256 | mov edx, ecx |
5254 | mov edx, ecx |
5257 | shr ecx, 16 |
5255 | shr ecx, 16 |
5258 | and edx, 0xffff |
5256 | and edx, 0xffff |
5259 | mov esi, ecx |
5257 | mov esi, ecx |
5260 | ; ecx - size x, edx - size y |
5258 | ; ecx - size x, edx - size y |
5261 | mov ebp, edx |
5259 | mov ebp, edx |
5262 | dec ebp |
5260 | dec ebp |
5263 | shl ebp, 2 |
5261 | shl ebp, 2 |
5264 | 5262 | ||
5265 | imul ebp, esi |
5263 | imul ebp, esi |
5266 | 5264 | ||
5267 | mov esi, ecx |
5265 | mov esi, ecx |
5268 | dec esi |
5266 | dec esi |
5269 | shl esi, 2 |
5267 | shl esi, 2 |
5270 | 5268 | ||
5271 | add ebp, esi |
5269 | add ebp, esi |
5272 | add ebp, edi |
5270 | add ebp, edi |
5273 | 5271 | ||
5274 | add ebx, edx |
5272 | add ebx, edx |
5275 | ;-------------------------------------- |
5273 | ;-------------------------------------- |
5276 | align 4 |
5274 | align 4 |
5277 | .start_y: |
5275 | .start_y: |
5278 | push ecx edx |
5276 | push ecx edx |
5279 | ;-------------------------------------- |
5277 | ;-------------------------------------- |
5280 | align 4 |
5278 | align 4 |
5281 | .start_x: |
5279 | .start_x: |
5282 | push eax ecx |
5280 | push eax ecx |
5283 | add eax, ecx |
5281 | add eax, ecx |
5284 | 5282 | ||
5285 | mov ecx, [ebp] |
5283 | mov ecx, [ebp] |
5286 | rol ecx, 8 |
5284 | rol ecx, 8 |
5287 | test cl, cl ; transparensy = 0 |
5285 | test cl, cl ; transparensy = 0 |
5288 | jz .no_put |
5286 | jz .no_put |
5289 | 5287 | ||
5290 | xor cl, cl |
5288 | xor cl, cl |
5291 | ror ecx, 8 |
5289 | ror ecx, 8 |
5292 | 5290 | ||
5293 | pushad |
5291 | pushad |
5294 | mov edx, [d_width_calc_area + ebx*4] |
5292 | mov edx, [d_width_calc_area + ebx*4] |
5295 | add edx, [_WinMapAddress] |
5293 | add edx, [_WinMapAddress] |
5296 | movzx edx, byte [eax+edx] |
5294 | movzx edx, byte [eax+edx] |
5297 | cmp dl, byte 1 |
5295 | cmp dl, byte 1 |
5298 | jne @f |
5296 | jne @f |
5299 | 5297 | ||
5300 | call dword [PUTPIXEL]; eax - x, ebx - y |
5298 | call dword [PUTPIXEL]; eax - x, ebx - y |
5301 | ;-------------------------------------- |
5299 | ;-------------------------------------- |
5302 | align 4 |
5300 | align 4 |
5303 | @@: |
5301 | @@: |
5304 | popad |
5302 | popad |
5305 | ;-------------------------------------- |
5303 | ;-------------------------------------- |
5306 | align 4 |
5304 | align 4 |
5307 | .no_put: |
5305 | .no_put: |
5308 | pop ecx eax |
5306 | pop ecx eax |
5309 | 5307 | ||
5310 | sub ebp, 4 |
5308 | sub ebp, 4 |
5311 | dec ecx |
5309 | dec ecx |
5312 | jnz .start_x |
5310 | jnz .start_x |
5313 | 5311 | ||
5314 | pop edx ecx |
5312 | pop edx ecx |
5315 | dec ebx |
5313 | dec ebx |
5316 | dec edx |
5314 | dec edx |
5317 | jnz .start_y |
5315 | jnz .start_y |
5318 | 5316 | ||
5319 | popad |
5317 | popad |
5320 | ret |
5318 | ret |
5321 | ;----------------------------------------------------------------------------- |
5319 | ;----------------------------------------------------------------------------- |
5322 | align 4 |
5320 | align 4 |
5323 | syscall_drawline: ; DrawLine |
5321 | syscall_drawline: ; DrawLine |
5324 | 5322 | ||
5325 | mov edi, [TASK_BASE] |
5323 | mov edi, [TASK_BASE] |
5326 | movzx eax, word[edi-twdw+WDATA.box.left] |
5324 | movzx eax, word[edi-twdw+WDATA.box.left] |
5327 | mov ebp, eax |
5325 | mov ebp, eax |
5328 | mov esi, [current_slot] |
5326 | mov esi, [current_slot] |
5329 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5327 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5330 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5328 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5331 | add ebp, ebx |
5329 | add ebp, ebx |
5332 | shl eax, 16 |
5330 | shl eax, 16 |
5333 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5331 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5334 | add eax, ebp |
5332 | add eax, ebp |
5335 | mov ebp, ebx |
5333 | mov ebp, ebx |
5336 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5334 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5337 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5335 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5338 | add ebp, ecx |
5336 | add ebp, ecx |
5339 | shl ebx, 16 |
5337 | shl ebx, 16 |
5340 | xor edi, edi |
5338 | xor edi, edi |
5341 | add ebx, ebp |
5339 | add ebx, ebp |
5342 | mov ecx, edx |
5340 | mov ecx, edx |
5343 | ; jmp [draw_line] |
5341 | ; jmp [draw_line] |
5344 | jmp __sys_draw_line |
5342 | jmp __sys_draw_line |
5345 | 5343 | ||
5346 | 5344 | ||
5347 | align 4 |
5345 | align 4 |
5348 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5346 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5349 | 5347 | ||
5350 | call r_f_port_area |
5348 | call r_f_port_area |
5351 | mov [esp+32], eax |
5349 | mov [esp+32], eax |
5352 | ret |
5350 | ret |
5353 | 5351 | ||
5354 | align 4 |
5352 | align 4 |
5355 | syscall_threads: ; CreateThreads |
5353 | syscall_threads: ; CreateThreads |
5356 | ; eax=1 create thread |
5354 | ; eax=1 create thread |
5357 | ; |
5355 | ; |
5358 | ; ebx=thread start |
5356 | ; ebx=thread start |
5359 | ; ecx=thread stack value |
5357 | ; ecx=thread stack value |
5360 | ; |
5358 | ; |
5361 | ; on return : eax = pid |
5359 | ; on return : eax = pid |
5362 | 5360 | ||
5363 | call new_sys_threads |
5361 | call new_sys_threads |
5364 | 5362 | ||
5365 | mov [esp+32], eax |
5363 | mov [esp+32], eax |
5366 | ret |
5364 | ret |
5367 | 5365 | ||
5368 | align 4 |
5366 | align 4 |
5369 | 5367 | ||
5370 | stack_driver_stat: |
5368 | stack_driver_stat: |
5371 | 5369 | ||
5372 | call app_stack_handler ; Stack status |
5370 | call app_stack_handler ; Stack status |
5373 | 5371 | ||
5374 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5372 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5375 | ; call change_task ; between sent packet |
5373 | ; call change_task ; between sent packet |
5376 | 5374 | ||
5377 | mov [esp+32], eax |
5375 | mov [esp+32], eax |
5378 | ret |
5376 | ret |
5379 | 5377 | ||
5380 | align 4 |
5378 | align 4 |
5381 | 5379 | ||
5382 | socket: ; Socket interface |
5380 | socket: ; Socket interface |
5383 | call app_socket_handler |
5381 | call app_socket_handler |
5384 | 5382 | ||
5385 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5383 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
5386 | ; call change_task ; between sent packet |
5384 | ; call change_task ; between sent packet |
5387 | 5385 | ||
5388 | mov [esp+36], eax |
5386 | mov [esp+36], eax |
5389 | mov [esp+24], ebx |
5387 | mov [esp+24], ebx |
5390 | ret |
5388 | ret |
5391 | 5389 | ||
5392 | paleholder: |
5390 | paleholder: |
5393 | ret |
5391 | ret |
5394 | ;------------------------------------------------------------------------------ |
5392 | ;------------------------------------------------------------------------------ |
5395 | align 4 |
5393 | align 4 |
5396 | calculate_fast_getting_offset_for_WinMapAddress: |
5394 | calculate_fast_getting_offset_for_WinMapAddress: |
5397 | ; calculate data area for fast getting offset to _WinMapAddress |
5395 | ; calculate data area for fast getting offset to _WinMapAddress |
5398 | xor eax, eax |
5396 | xor eax, eax |
5399 | mov ecx, [_display.height] |
5397 | mov ecx, [_display.height] |
5400 | inc ecx |
5398 | inc ecx |
5401 | mov edi, d_width_calc_area |
5399 | mov edi, d_width_calc_area |
5402 | cld |
5400 | cld |
5403 | @@: |
5401 | @@: |
5404 | stosd |
5402 | stosd |
5405 | add eax, [_display.width] |
5403 | add eax, [_display.width] |
5406 | dec ecx |
5404 | dec ecx |
5407 | jnz @r |
5405 | jnz @r |
5408 | ret |
5406 | ret |
5409 | ;------------------------------------------------------------------------------ |
5407 | ;------------------------------------------------------------------------------ |
5410 | align 4 |
5408 | align 4 |
5411 | calculate_fast_getting_offset_for_LFB: |
5409 | calculate_fast_getting_offset_for_LFB: |
5412 | ; calculate data area for fast getting offset to LFB |
5410 | ; calculate data area for fast getting offset to LFB |
5413 | xor eax, eax |
5411 | xor eax, eax |
5414 | mov ecx, [_display.height] |
5412 | mov ecx, [_display.height] |
5415 | inc ecx |
5413 | inc ecx |
5416 | mov edi, BPSLine_calc_area |
5414 | mov edi, BPSLine_calc_area |
5417 | cld |
5415 | cld |
5418 | @@: |
5416 | @@: |
5419 | stosd |
5417 | stosd |
5420 | add eax, [BytesPerScanLine] |
5418 | add eax, [BytesPerScanLine] |
5421 | dec ecx |
5419 | dec ecx |
5422 | jnz @r |
5420 | jnz @r |
5423 | ret |
5421 | ret |
5424 | ;------------------------------------------------------------------------------ |
5422 | ;------------------------------------------------------------------------------ |
5425 | align 4 |
5423 | align 4 |
5426 | set_screen: |
5424 | set_screen: |
5427 | ; in: |
5425 | ; in: |
5428 | ; eax - new Screen_Max_X |
5426 | ; eax - new Screen_Max_X |
5429 | ; ecx - new BytesPerScanLine |
5427 | ; ecx - new BytesPerScanLine |
5430 | ; edx - new Screen_Max_Y |
5428 | ; edx - new Screen_Max_Y |
5431 | cmp eax, [Screen_Max_X] |
5429 | cmp eax, [Screen_Max_X] |
5432 | jne .set |
5430 | jne .set |
5433 | 5431 | ||
5434 | cmp edx, [Screen_Max_Y] |
5432 | cmp edx, [Screen_Max_Y] |
5435 | jne .set |
5433 | jne .set |
5436 | ret |
5434 | ret |
5437 | .set: |
5435 | .set: |
5438 | pushfd |
5436 | pushfd |
5439 | cli |
5437 | cli |
5440 | 5438 | ||
5441 | mov [Screen_Max_X], eax |
5439 | mov [Screen_Max_X], eax |
5442 | mov [Screen_Max_Y], edx |
5440 | mov [Screen_Max_Y], edx |
5443 | mov [BytesPerScanLine], ecx |
5441 | mov [BytesPerScanLine], ecx |
5444 | 5442 | ||
5445 | mov [screen_workarea.right], eax |
5443 | mov [screen_workarea.right], eax |
5446 | mov [screen_workarea.bottom], edx |
5444 | mov [screen_workarea.bottom], edx |
5447 | 5445 | ||
5448 | push ebx |
5446 | push ebx |
5449 | push esi |
5447 | push esi |
5450 | push edi |
5448 | push edi |
5451 | 5449 | ||
5452 | pushad |
5450 | pushad |
5453 | 5451 | ||
5454 | cmp [do_not_touch_winmap], 1 |
5452 | cmp [do_not_touch_winmap], 1 |
5455 | je @f |
5453 | je @f |
5456 | 5454 | ||
5457 | stdcall kernel_free, [_WinMapAddress] |
5455 | stdcall kernel_free, [_WinMapAddress] |
5458 | 5456 | ||
5459 | mov eax, [_display.width] |
5457 | mov eax, [_display.width] |
5460 | mul [_display.height] |
5458 | mul [_display.height] |
5461 | mov [_WinMapSize], eax |
5459 | mov [_WinMapSize], eax |
5462 | 5460 | ||
5463 | stdcall kernel_alloc, eax |
5461 | stdcall kernel_alloc, eax |
5464 | mov [_WinMapAddress], eax |
5462 | mov [_WinMapAddress], eax |
5465 | test eax, eax |
5463 | test eax, eax |
5466 | jz .epic_fail |
5464 | jz .epic_fail |
5467 | ; store for f.18.24 |
5465 | ; store for f.18.24 |
5468 | mov eax, [_display.width] |
5466 | mov eax, [_display.width] |
5469 | mov [display_width_standard], eax |
5467 | mov [display_width_standard], eax |
5470 | 5468 | ||
5471 | mov eax, [_display.height] |
5469 | mov eax, [_display.height] |
5472 | mov [display_height_standard], eax |
5470 | mov [display_height_standard], eax |
5473 | @@: |
5471 | @@: |
5474 | call calculate_fast_getting_offset_for_WinMapAddress |
5472 | call calculate_fast_getting_offset_for_WinMapAddress |
5475 | ; for Qemu or non standart video cards |
5473 | ; for Qemu or non standart video cards |
5476 | ; Unfortunately [BytesPerScanLine] does not always |
5474 | ; Unfortunately [BytesPerScanLine] does not always |
5477 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5475 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5478 | call calculate_fast_getting_offset_for_LFB |
5476 | call calculate_fast_getting_offset_for_LFB |
5479 | popad |
5477 | popad |
5480 | 5478 | ||
5481 | call repos_windows |
5479 | call repos_windows |
5482 | xor eax, eax |
5480 | xor eax, eax |
5483 | xor ebx, ebx |
5481 | xor ebx, ebx |
5484 | mov ecx, [Screen_Max_X] |
5482 | mov ecx, [Screen_Max_X] |
5485 | mov edx, [Screen_Max_Y] |
5483 | mov edx, [Screen_Max_Y] |
5486 | call calculatescreen |
5484 | call calculatescreen |
5487 | pop edi |
5485 | pop edi |
5488 | pop esi |
5486 | pop esi |
5489 | pop ebx |
5487 | pop ebx |
5490 | 5488 | ||
5491 | popfd |
5489 | popfd |
5492 | ret |
5490 | ret |
5493 | 5491 | ||
5494 | .epic_fail: |
5492 | .epic_fail: |
5495 | hlt ; Houston, we've had a problem |
5493 | hlt ; Houston, we've had a problem |
5496 | 5494 | ||
5497 | ; --------------- APM --------------------- |
5495 | ; --------------- APM --------------------- |
5498 | uglobal |
5496 | uglobal |
5499 | apm_entry dp 0 |
5497 | apm_entry dp 0 |
5500 | apm_vf dd 0 |
5498 | apm_vf dd 0 |
5501 | endg |
5499 | endg |
5502 | 5500 | ||
5503 | align 4 |
5501 | align 4 |
5504 | sys_apm: |
5502 | sys_apm: |
5505 | xor eax, eax |
5503 | xor eax, eax |
5506 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5504 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5507 | jne @f |
5505 | jne @f |
5508 | inc eax |
5506 | inc eax |
5509 | or dword [esp + 44], eax ; error |
5507 | or dword [esp + 44], eax ; error |
5510 | add eax, 7 |
5508 | add eax, 7 |
5511 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5509 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5512 | ret |
5510 | ret |
5513 | 5511 | ||
5514 | @@: |
5512 | @@: |
5515 | ; xchg eax, ecx |
5513 | ; xchg eax, ecx |
5516 | ; xchg ebx, ecx |
5514 | ; xchg ebx, ecx |
5517 | 5515 | ||
5518 | cmp dx, 3 |
5516 | cmp dx, 3 |
5519 | ja @f |
5517 | ja @f |
5520 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5518 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5521 | mov eax, [apm_vf] |
5519 | mov eax, [apm_vf] |
5522 | mov [esp + 32], eax |
5520 | mov [esp + 32], eax |
5523 | shr eax, 16 |
5521 | shr eax, 16 |
5524 | mov [esp + 28], eax |
5522 | mov [esp + 28], eax |
5525 | ret |
5523 | ret |
5526 | 5524 | ||
5527 | @@: |
5525 | @@: |
5528 | 5526 | ||
5529 | mov esi, [master_tab+(OS_BASE shr 20)] |
5527 | mov esi, [master_tab+(OS_BASE shr 20)] |
5530 | xchg [master_tab], esi |
5528 | xchg [master_tab], esi |
5531 | push esi |
5529 | push esi |
5532 | mov edi, cr3 |
5530 | mov edi, cr3 |
5533 | mov cr3, edi ;flush TLB |
5531 | mov cr3, edi ;flush TLB |
5534 | 5532 | ||
5535 | call pword [apm_entry] ;call APM BIOS |
5533 | call pword [apm_entry] ;call APM BIOS |
5536 | 5534 | ||
5537 | xchg eax, [esp] |
5535 | xchg eax, [esp] |
5538 | mov [master_tab], eax |
5536 | mov [master_tab], eax |
5539 | mov eax, cr3 |
5537 | mov eax, cr3 |
5540 | mov cr3, eax |
5538 | mov cr3, eax |
5541 | pop eax |
5539 | pop eax |
5542 | 5540 | ||
5543 | mov [esp + 4 ], edi |
5541 | mov [esp + 4 ], edi |
5544 | mov [esp + 8], esi |
5542 | mov [esp + 8], esi |
5545 | mov [esp + 20], ebx |
5543 | mov [esp + 20], ebx |
5546 | mov [esp + 24], edx |
5544 | mov [esp + 24], edx |
5547 | mov [esp + 28], ecx |
5545 | mov [esp + 28], ecx |
5548 | mov [esp + 32], eax |
5546 | mov [esp + 32], eax |
5549 | setc al |
5547 | setc al |
5550 | and [esp + 44], byte 0xfe |
5548 | and [esp + 44], byte 0xfe |
5551 | or [esp + 44], al |
5549 | or [esp + 44], al |
5552 | ret |
5550 | ret |
5553 | ; ----------------------------------------- |
5551 | ; ----------------------------------------- |
5554 | 5552 | ||
5555 | align 4 |
5553 | align 4 |
5556 | 5554 | ||
5557 | undefined_syscall: ; Undefined system call |
5555 | undefined_syscall: ; Undefined system call |
5558 | mov [esp + 32], dword -1 |
5556 | mov [esp + 32], dword -1 |
5559 | ret |
5557 | ret |
5560 | 5558 | ||
5561 | align 4 |
5559 | align 4 |
5562 | system_shutdown: ; shut down the system |
5560 | system_shutdown: ; shut down the system |
5563 | 5561 | ||
5564 | cmp byte [BOOT_VAR+0x9030], 1 |
5562 | cmp byte [BOOT_VAR+0x9030], 1 |
5565 | jne @F |
5563 | jne @F |
5566 | ret |
5564 | ret |
5567 | @@: |
5565 | @@: |
5568 | call stop_all_services |
5566 | call stop_all_services |
5569 | push 3 ; stop playing cd |
5567 | push 3 ; stop playing cd |
5570 | pop eax |
5568 | pop eax |
5571 | call sys_cd_audio |
5569 | call sys_cd_audio |
5572 | 5570 | ||
5573 | yes_shutdown_param: |
5571 | yes_shutdown_param: |
5574 | cli |
5572 | cli |
5575 | 5573 | ||
5576 | if ~ defined extended_primary_loader |
5574 | if ~ defined extended_primary_loader |
5577 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5575 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5578 | push 12 |
5576 | push 12 |
5579 | pop esi |
5577 | pop esi |
5580 | xor ebx, ebx |
5578 | xor ebx, ebx |
5581 | or ecx, -1 |
5579 | or ecx, -1 |
5582 | mov edx, OS_BASE+0x70000 |
5580 | mov edx, OS_BASE+0x70000 |
5583 | call fileread |
5581 | call fileread |
5584 | 5582 | ||
5585 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5583 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5586 | mov edi, OS_BASE+0x40000 |
5584 | mov edi, OS_BASE+0x40000 |
5587 | mov ecx, 1000 |
5585 | mov ecx, 1000 |
5588 | rep movsb |
5586 | rep movsb |
5589 | end if |
5587 | end if |
5590 | 5588 | ||
5591 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5589 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5592 | mov edi, OS_BASE |
5590 | mov edi, OS_BASE |
5593 | mov ecx, 0x10000/4 |
5591 | mov ecx, 0x10000/4 |
5594 | cld |
5592 | cld |
5595 | rep movsd |
5593 | rep movsd |
5596 | 5594 | ||
5597 | call restorefatchain |
5595 | call restorefatchain |
5598 | 5596 | ||
5599 | call IRQ_mask_all |
5597 | call IRQ_mask_all |
5600 | 5598 | ||
5601 | if 0 |
5599 | if 0 |
5602 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5600 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5603 | mov word [OS_BASE+0x467+2], 0x1000 |
5601 | mov word [OS_BASE+0x467+2], 0x1000 |
5604 | 5602 | ||
5605 | mov al, 0x0F |
5603 | mov al, 0x0F |
5606 | out 0x70, al |
5604 | out 0x70, al |
5607 | mov al, 0x05 |
5605 | mov al, 0x05 |
5608 | out 0x71, al |
5606 | out 0x71, al |
5609 | 5607 | ||
5610 | mov al, 0xFE |
5608 | mov al, 0xFE |
5611 | out 0x64, al |
5609 | out 0x64, al |
5612 | 5610 | ||
5613 | hlt |
5611 | hlt |
5614 | jmp $-1 |
5612 | jmp $-1 |
5615 | 5613 | ||
5616 | else |
5614 | else |
5617 | cmp byte [OS_BASE + 0x9030], 2 |
5615 | cmp byte [OS_BASE + 0x9030], 2 |
5618 | jnz no_acpi_power_off |
5616 | jnz no_acpi_power_off |
5619 | 5617 | ||
5620 | ; scan for RSDP |
5618 | ; scan for RSDP |
5621 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5619 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5622 | movzx eax, word [OS_BASE + 0x40E] |
5620 | movzx eax, word [OS_BASE + 0x40E] |
5623 | shl eax, 4 |
5621 | shl eax, 4 |
5624 | jz @f |
5622 | jz @f |
5625 | mov ecx, 1024/16 |
5623 | mov ecx, 1024/16 |
5626 | call scan_rsdp |
5624 | call scan_rsdp |
5627 | jnc .rsdp_found |
5625 | jnc .rsdp_found |
5628 | @@: |
5626 | @@: |
5629 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5627 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5630 | mov eax, 0xE0000 |
5628 | mov eax, 0xE0000 |
5631 | mov ecx, 0x2000 |
5629 | mov ecx, 0x2000 |
5632 | call scan_rsdp |
5630 | call scan_rsdp |
5633 | jc no_acpi_power_off |
5631 | jc no_acpi_power_off |
5634 | .rsdp_found: |
5632 | .rsdp_found: |
5635 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5633 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5636 | mov ebp, [ipc_tmp] |
5634 | mov ebp, [ipc_tmp] |
5637 | stdcall map_page, ebp, esi, PG_MAP |
5635 | stdcall map_page, ebp, esi, PG_MAP |
5638 | lea eax, [esi+1000h] |
5636 | lea eax, [esi+1000h] |
5639 | lea edx, [ebp+1000h] |
5637 | lea edx, [ebp+1000h] |
5640 | stdcall map_page, edx, eax, PG_MAP |
5638 | stdcall map_page, edx, eax, PG_MAP |
5641 | and esi, 0xFFF |
5639 | and esi, 0xFFF |
5642 | add esi, ebp |
5640 | add esi, ebp |
5643 | cmp dword [esi], 'RSDT' |
5641 | cmp dword [esi], 'RSDT' |
5644 | jnz no_acpi_power_off |
5642 | jnz no_acpi_power_off |
5645 | mov ecx, [esi+4] |
5643 | mov ecx, [esi+4] |
5646 | sub ecx, 24h |
5644 | sub ecx, 24h |
5647 | jbe no_acpi_power_off |
5645 | jbe no_acpi_power_off |
5648 | shr ecx, 2 |
5646 | shr ecx, 2 |
5649 | add esi, 24h |
5647 | add esi, 24h |
5650 | .scan_fadt: |
5648 | .scan_fadt: |
5651 | lodsd |
5649 | lodsd |
5652 | mov ebx, eax |
5650 | mov ebx, eax |
5653 | lea eax, [ebp+2000h] |
5651 | lea eax, [ebp+2000h] |
5654 | stdcall map_page, eax, ebx, PG_MAP |
5652 | stdcall map_page, eax, ebx, PG_MAP |
5655 | lea eax, [ebp+3000h] |
5653 | lea eax, [ebp+3000h] |
5656 | add ebx, 0x1000 |
5654 | add ebx, 0x1000 |
5657 | stdcall map_page, eax, ebx, PG_MAP |
5655 | stdcall map_page, eax, ebx, PG_MAP |
5658 | and ebx, 0xFFF |
5656 | and ebx, 0xFFF |
5659 | lea ebx, [ebx+ebp+2000h] |
5657 | lea ebx, [ebx+ebp+2000h] |
5660 | cmp dword [ebx], 'FACP' |
5658 | cmp dword [ebx], 'FACP' |
5661 | jz .fadt_found |
5659 | jz .fadt_found |
5662 | loop .scan_fadt |
5660 | loop .scan_fadt |
5663 | jmp no_acpi_power_off |
5661 | jmp no_acpi_power_off |
5664 | .fadt_found: |
5662 | .fadt_found: |
5665 | ; ebx is linear address of FADT |
5663 | ; ebx is linear address of FADT |
5666 | mov edi, [ebx+40] ; physical address of the DSDT |
5664 | mov edi, [ebx+40] ; physical address of the DSDT |
5667 | lea eax, [ebp+4000h] |
5665 | lea eax, [ebp+4000h] |
5668 | stdcall map_page, eax, edi, PG_MAP |
5666 | stdcall map_page, eax, edi, PG_MAP |
5669 | lea eax, [ebp+5000h] |
5667 | lea eax, [ebp+5000h] |
5670 | lea esi, [edi+0x1000] |
5668 | lea esi, [edi+0x1000] |
5671 | stdcall map_page, eax, esi, PG_MAP |
5669 | stdcall map_page, eax, esi, PG_MAP |
5672 | and esi, 0xFFF |
5670 | and esi, 0xFFF |
5673 | sub edi, esi |
5671 | sub edi, esi |
5674 | cmp dword [esi+ebp+4000h], 'DSDT' |
5672 | cmp dword [esi+ebp+4000h], 'DSDT' |
5675 | jnz no_acpi_power_off |
5673 | jnz no_acpi_power_off |
5676 | mov eax, [esi+ebp+4004h] ; DSDT length |
5674 | mov eax, [esi+ebp+4004h] ; DSDT length |
5677 | sub eax, 36+4 |
5675 | sub eax, 36+4 |
5678 | jbe no_acpi_power_off |
5676 | jbe no_acpi_power_off |
5679 | add esi, 36 |
5677 | add esi, 36 |
5680 | .scan_dsdt: |
5678 | .scan_dsdt: |
5681 | cmp dword [esi+ebp+4000h], '_S5_' |
5679 | cmp dword [esi+ebp+4000h], '_S5_' |
5682 | jnz .scan_dsdt_cont |
5680 | jnz .scan_dsdt_cont |
5683 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5681 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5684 | jnz .scan_dsdt_cont |
5682 | jnz .scan_dsdt_cont |
5685 | mov dl, [esi+ebp+4000h+6] |
5683 | mov dl, [esi+ebp+4000h+6] |
5686 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5684 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5687 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5685 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5688 | ja .scan_dsdt_cont |
5686 | ja .scan_dsdt_cont |
5689 | cmp dl, 1 |
5687 | cmp dl, 1 |
5690 | jb .scan_dsdt_cont |
5688 | jb .scan_dsdt_cont |
5691 | lea esi, [esi+ebp+4000h+7] |
5689 | lea esi, [esi+ebp+4000h+7] |
5692 | xor ecx, ecx |
5690 | xor ecx, ecx |
5693 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5691 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5694 | jz @f |
5692 | jz @f |
5695 | cmp byte [esi], 0xA |
5693 | cmp byte [esi], 0xA |
5696 | jnz no_acpi_power_off |
5694 | jnz no_acpi_power_off |
5697 | inc esi |
5695 | inc esi |
5698 | mov cl, [esi] |
5696 | mov cl, [esi] |
5699 | @@: |
5697 | @@: |
5700 | inc esi |
5698 | inc esi |
5701 | cmp dl, 2 |
5699 | cmp dl, 2 |
5702 | jb @f |
5700 | jb @f |
5703 | cmp byte [esi], 0 |
5701 | cmp byte [esi], 0 |
5704 | jz @f |
5702 | jz @f |
5705 | cmp byte [esi], 0xA |
5703 | cmp byte [esi], 0xA |
5706 | jnz no_acpi_power_off |
5704 | jnz no_acpi_power_off |
5707 | inc esi |
5705 | inc esi |
5708 | mov ch, [esi] |
5706 | mov ch, [esi] |
5709 | @@: |
5707 | @@: |
5710 | jmp do_acpi_power_off |
5708 | jmp do_acpi_power_off |
5711 | .scan_dsdt_cont: |
5709 | .scan_dsdt_cont: |
5712 | inc esi |
5710 | inc esi |
5713 | cmp esi, 0x1000 |
5711 | cmp esi, 0x1000 |
5714 | jb @f |
5712 | jb @f |
5715 | sub esi, 0x1000 |
5713 | sub esi, 0x1000 |
5716 | add edi, 0x1000 |
5714 | add edi, 0x1000 |
5717 | push eax |
5715 | push eax |
5718 | lea eax, [ebp+4000h] |
5716 | lea eax, [ebp+4000h] |
5719 | stdcall map_page, eax, edi, PG_MAP |
5717 | stdcall map_page, eax, edi, PG_MAP |
5720 | push PG_MAP |
5718 | push PG_MAP |
5721 | lea eax, [edi+1000h] |
5719 | lea eax, [edi+1000h] |
5722 | push eax |
5720 | push eax |
5723 | lea eax, [ebp+5000h] |
5721 | lea eax, [ebp+5000h] |
5724 | push eax |
5722 | push eax |
5725 | stdcall map_page |
5723 | stdcall map_page |
5726 | pop eax |
5724 | pop eax |
5727 | @@: |
5725 | @@: |
5728 | dec eax |
5726 | dec eax |
5729 | jnz .scan_dsdt |
5727 | jnz .scan_dsdt |
5730 | jmp no_acpi_power_off |
5728 | jmp no_acpi_power_off |
5731 | do_acpi_power_off: |
5729 | do_acpi_power_off: |
5732 | mov edx, [ebx+48] |
5730 | mov edx, [ebx+48] |
5733 | test edx, edx |
5731 | test edx, edx |
5734 | jz .nosmi |
5732 | jz .nosmi |
5735 | mov al, [ebx+52] |
5733 | mov al, [ebx+52] |
5736 | out dx, al |
5734 | out dx, al |
5737 | mov edx, [ebx+64] |
5735 | mov edx, [ebx+64] |
5738 | @@: |
5736 | @@: |
5739 | in ax, dx |
5737 | in ax, dx |
5740 | test al, 1 |
5738 | test al, 1 |
5741 | jz @b |
5739 | jz @b |
5742 | .nosmi: |
5740 | .nosmi: |
5743 | and cx, 0x0707 |
5741 | and cx, 0x0707 |
5744 | shl cx, 2 |
5742 | shl cx, 2 |
5745 | or cx, 0x2020 |
5743 | or cx, 0x2020 |
5746 | mov edx, [ebx+64] |
5744 | mov edx, [ebx+64] |
5747 | in ax, dx |
5745 | in ax, dx |
5748 | and ax, 203h |
5746 | and ax, 203h |
5749 | or ah, cl |
5747 | or ah, cl |
5750 | out dx, ax |
5748 | out dx, ax |
5751 | mov edx, [ebx+68] |
5749 | mov edx, [ebx+68] |
5752 | test edx, edx |
5750 | test edx, edx |
5753 | jz @f |
5751 | jz @f |
5754 | in ax, dx |
5752 | in ax, dx |
5755 | and ax, 203h |
5753 | and ax, 203h |
5756 | or ah, ch |
5754 | or ah, ch |
5757 | out dx, ax |
5755 | out dx, ax |
5758 | @@: |
5756 | @@: |
5759 | jmp $ |
5757 | jmp $ |
5760 | 5758 | ||
5761 | 5759 | ||
5762 | no_acpi_power_off: |
5760 | no_acpi_power_off: |
5763 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5761 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5764 | mov word [OS_BASE+0x467+2], 0x1000 |
5762 | mov word [OS_BASE+0x467+2], 0x1000 |
5765 | 5763 | ||
5766 | mov al, 0x0F |
5764 | mov al, 0x0F |
5767 | out 0x70, al |
5765 | out 0x70, al |
5768 | mov al, 0x05 |
5766 | mov al, 0x05 |
5769 | out 0x71, al |
5767 | out 0x71, al |
5770 | 5768 | ||
5771 | mov al, 0xFE |
5769 | mov al, 0xFE |
5772 | out 0x64, al |
5770 | out 0x64, al |
5773 | 5771 | ||
5774 | hlt |
5772 | hlt |
5775 | jmp $-1 |
5773 | jmp $-1 |
5776 | 5774 | ||
5777 | scan_rsdp: |
5775 | scan_rsdp: |
5778 | add eax, OS_BASE |
5776 | add eax, OS_BASE |
5779 | .s: |
5777 | .s: |
5780 | cmp dword [eax], 'RSD ' |
5778 | cmp dword [eax], 'RSD ' |
5781 | jnz .n |
5779 | jnz .n |
5782 | cmp dword [eax+4], 'PTR ' |
5780 | cmp dword [eax+4], 'PTR ' |
5783 | jnz .n |
5781 | jnz .n |
5784 | xor edx, edx |
5782 | xor edx, edx |
5785 | xor esi, esi |
5783 | xor esi, esi |
5786 | @@: |
5784 | @@: |
5787 | add dl, [eax+esi] |
5785 | add dl, [eax+esi] |
5788 | inc esi |
5786 | inc esi |
5789 | cmp esi, 20 |
5787 | cmp esi, 20 |
5790 | jnz @b |
5788 | jnz @b |
5791 | test dl, dl |
5789 | test dl, dl |
5792 | jz .ok |
5790 | jz .ok |
5793 | .n: |
5791 | .n: |
5794 | add eax, 10h |
5792 | add eax, 10h |
5795 | loop .s |
5793 | loop .s |
5796 | stc |
5794 | stc |
5797 | .ok: |
5795 | .ok: |
5798 | ret |
5796 | ret |
5799 | end if |
5797 | end if |
5800 | 5798 | ||
5801 | include "data32.inc" |
5799 | include "data32.inc" |
5802 | 5800 | ||
5803 | __REV__ = __REV |
5801 | __REV__ = __REV |
5804 | 5802 | ||
5805 | uglobals_size = $ - endofcode |
5803 | uglobals_size = $ - endofcode |
5806 | if ~ lang eq sp |
5804 | if ~ lang eq sp |
5807 | diff16 "end of kernel code",0,$ |
5805 | diff16 "end of kernel code",0,$ |
5808 | end if=> |
5806 | end if=> |