Rev 4741 | Rev 5012 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4741 | Rev 4772 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2013. 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: 4741 $ |
74 | $Revision: 4772 $ |
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 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
78 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
79 | 79 | ||
80 | ; Enabling the next line will enable serial output console |
80 | ; Enabling the next line will enable serial output console |
81 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
81 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
82 | 82 | ||
83 | include "proc32.inc" |
83 | include "proc32.inc" |
84 | include "kglobals.inc" |
84 | include "kglobals.inc" |
85 | include "lang.inc" |
85 | include "lang.inc" |
86 | include "encoding.inc" |
86 | include "encoding.inc" |
87 | 87 | ||
88 | include "const.inc" |
88 | include "const.inc" |
89 | 89 | ||
90 | iglobal |
90 | iglobal |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
92 | debug_direct_print db 0 |
92 | debug_direct_print db 0 |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
94 | launcher_start db 1 |
94 | launcher_start db 1 |
95 | endg |
95 | endg |
96 | 96 | ||
97 | max_processes equ 255 |
97 | max_processes equ 255 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
99 | 99 | ||
100 | os_stack equ (os_data_l-gdts) ; GDTs |
100 | os_stack equ (os_data_l-gdts) ; GDTs |
101 | os_code equ (os_code_l-gdts) |
101 | os_code equ (os_code_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
109 | 109 | ||
110 | 110 | ||
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
112 | ;; |
112 | ;; |
113 | ;; Included files: |
113 | ;; Included files: |
114 | ;; |
114 | ;; |
115 | ;; Kernel16.inc |
115 | ;; Kernel16.inc |
116 | ;; - Booteng.inc English text for bootup |
116 | ;; - Booteng.inc English text for bootup |
117 | ;; - Bootcode.inc Hardware setup |
117 | ;; - Bootcode.inc Hardware setup |
118 | ;; - Pci16.inc PCI functions |
118 | ;; - Pci16.inc PCI functions |
119 | ;; |
119 | ;; |
120 | ;; Kernel32.inc |
120 | ;; Kernel32.inc |
121 | ;; - Sys32.inc Process management |
121 | ;; - Sys32.inc Process management |
122 | ;; - Shutdown.inc Shutdown and restart |
122 | ;; - Shutdown.inc Shutdown and restart |
123 | ;; - Fat32.inc Read / write hd |
123 | ;; - Fat32.inc Read / write hd |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
126 | ;; - Vga.inc VGA driver |
126 | ;; - Vga.inc VGA driver |
127 | ;; - Stack.inc Network interface |
127 | ;; - Stack.inc Network interface |
128 | ;; - Mouse.inc Mouse pointer |
128 | ;; - Mouse.inc Mouse pointer |
129 | ;; - Scincode.inc Window skinning |
129 | ;; - Scincode.inc Window skinning |
130 | ;; - Pci32.inc PCI functions |
130 | ;; - Pci32.inc PCI functions |
131 | ;; |
131 | ;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
133 | 133 | ||
134 | 134 | ||
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
136 | ;; ;; |
136 | ;; ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
138 | ;; ;; |
138 | ;; ;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
140 | 140 | ||
141 | use16 |
141 | use16 |
142 | org 0x0 |
142 | org 0x0 |
143 | jmp start_of_code |
143 | jmp start_of_code |
144 | 144 | ||
145 | if lang eq sp |
145 | if lang eq sp |
146 | include "kernelsp.inc" ; spanish kernel messages |
146 | include "kernelsp.inc" ; spanish kernel messages |
147 | else if lang eq et |
147 | else if lang eq et |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
149 | else |
149 | else |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
151 | end if |
151 | end if |
152 | 152 | ||
153 | include "boot/bootstr.inc" ; language-independent boot messages |
153 | include "boot/bootstr.inc" ; language-independent boot messages |
154 | include "boot/preboot.inc" |
154 | include "boot/preboot.inc" |
155 | 155 | ||
156 | if lang eq ge |
156 | if lang eq ge |
157 | include "boot/bootge.inc" ; german system boot messages |
157 | include "boot/bootge.inc" ; german system boot messages |
158 | else if lang eq sp |
158 | else if lang eq sp |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
160 | else if lang eq ru |
160 | else if lang eq ru |
161 | include "boot/bootru.inc" ; russian system boot messages |
161 | include "boot/bootru.inc" ; russian system boot messages |
162 | include "boot/ru.inc" ; Russian font |
162 | include "boot/ru.inc" ; Russian font |
163 | else if lang eq et |
163 | else if lang eq et |
164 | include "boot/bootet.inc" ; estonian system boot messages |
164 | include "boot/bootet.inc" ; estonian system boot messages |
165 | include "boot/et.inc" ; Estonian font |
165 | include "boot/et.inc" ; Estonian font |
166 | else |
166 | else |
167 | include "boot/booten.inc" ; english system boot messages |
167 | include "boot/booten.inc" ; english system boot messages |
168 | end if |
168 | end if |
169 | 169 | ||
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
171 | include "bus/pci/pci16.inc" |
171 | include "bus/pci/pci16.inc" |
172 | include "detect/biosdisk.inc" |
172 | include "detect/biosdisk.inc" |
173 | 173 | ||
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
175 | ;; ;; |
175 | ;; ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
177 | ;; ;; |
177 | ;; ;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
179 | 179 | ||
180 | 180 | ||
181 | ; CR0 Flags - Protected mode and Paging |
181 | ; CR0 Flags - Protected mode and Paging |
182 | 182 | ||
183 | mov ecx, CR0_PE |
183 | mov ecx, CR0_PE |
184 | 184 | ||
185 | ; Enabling 32 bit protected mode |
185 | ; Enabling 32 bit protected mode |
186 | 186 | ||
187 | sidt [cs:old_ints_h] |
187 | sidt [cs:old_ints_h] |
188 | 188 | ||
189 | cli ; disable all irqs |
189 | cli ; disable all irqs |
190 | cld |
190 | cld |
191 | mov al, 255 ; mask all irqs |
191 | mov al, 255 ; mask all irqs |
192 | out 0xa1, al |
192 | out 0xa1, al |
193 | out 0x21, al |
193 | out 0x21, al |
194 | l.5: |
194 | l.5: |
195 | in al, 0x64 ; Enable A20 |
195 | in al, 0x64 ; Enable A20 |
196 | test al, 2 |
196 | test al, 2 |
197 | jnz l.5 |
197 | jnz l.5 |
198 | mov al, 0xD1 |
198 | mov al, 0xD1 |
199 | out 0x64, al |
199 | out 0x64, al |
200 | l.6: |
200 | l.6: |
201 | in al, 0x64 |
201 | in al, 0x64 |
202 | test al, 2 |
202 | test al, 2 |
203 | jnz l.6 |
203 | jnz l.6 |
204 | mov al, 0xDF |
204 | mov al, 0xDF |
205 | out 0x60, al |
205 | out 0x60, al |
206 | l.7: |
206 | l.7: |
207 | in al, 0x64 |
207 | in al, 0x64 |
208 | test al, 2 |
208 | test al, 2 |
209 | jnz l.7 |
209 | jnz l.7 |
210 | mov al, 0xFF |
210 | mov al, 0xFF |
211 | out 0x64, al |
211 | out 0x64, al |
212 | 212 | ||
213 | lgdt [cs:tmp_gdt] ; Load GDT |
213 | lgdt [cs:tmp_gdt] ; Load GDT |
214 | mov eax, cr0 ; protected mode |
214 | mov eax, cr0 ; protected mode |
215 | or eax, ecx |
215 | or eax, ecx |
216 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
216 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
217 | mov cr0, eax |
217 | mov cr0, eax |
218 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
218 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
219 | 219 | ||
220 | align 8 |
220 | align 8 |
221 | tmp_gdt: |
221 | tmp_gdt: |
222 | 222 | ||
223 | dw 23 |
223 | dw 23 |
224 | dd tmp_gdt+0x10000 |
224 | dd tmp_gdt+0x10000 |
225 | dw 0 |
225 | dw 0 |
226 | 226 | ||
227 | dw 0xffff |
227 | dw 0xffff |
228 | dw 0x0000 |
228 | dw 0x0000 |
229 | db 0x00 |
229 | db 0x00 |
230 | dw 11011111b *256 +10011010b |
230 | dw 11011111b *256 +10011010b |
231 | db 0x00 |
231 | db 0x00 |
232 | 232 | ||
233 | dw 0xffff |
233 | dw 0xffff |
234 | dw 0x0000 |
234 | dw 0x0000 |
235 | db 0x00 |
235 | db 0x00 |
236 | dw 11011111b *256 +10010010b |
236 | dw 11011111b *256 +10010010b |
237 | db 0x00 |
237 | db 0x00 |
238 | 238 | ||
239 | include "data16.inc" |
239 | include "data16.inc" |
240 | 240 | ||
241 | if ~ lang eq sp |
241 | if ~ lang eq sp |
242 | diff16 "end of bootcode",0,$+0x10000 |
242 | diff16 "end of bootcode",0,$+0x10000 |
243 | end if |
243 | end if |
244 | 244 | ||
245 | use32 |
245 | use32 |
246 | org $+0x10000 |
246 | org $+0x10000 |
247 | 247 | ||
248 | align 4 |
248 | align 4 |
249 | B32: |
249 | B32: |
250 | mov ax, os_stack ; Selector for os |
250 | mov ax, os_stack ; Selector for os |
251 | mov ds, ax |
251 | mov ds, ax |
252 | mov es, ax |
252 | mov es, ax |
253 | mov fs, ax |
253 | mov fs, ax |
254 | mov gs, ax |
254 | mov gs, ax |
255 | mov ss, ax |
255 | mov ss, ax |
256 | mov esp, 0x006CC00 ; Set stack |
256 | mov esp, 0x006CC00 ; Set stack |
257 | 257 | ||
258 | ; CLEAR 0x280000 - HEAP_BASE |
258 | ; CLEAR 0x280000 - HEAP_BASE |
259 | 259 | ||
260 | xor eax, eax |
260 | xor eax, eax |
261 | mov edi, CLEAN_ZONE |
261 | mov edi, CLEAN_ZONE |
262 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
262 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
263 | cld |
263 | cld |
264 | rep stosd |
264 | rep stosd |
265 | 265 | ||
266 | ; CLEAR KERNEL UNDEFINED GLOBALS |
266 | ; CLEAR KERNEL UNDEFINED GLOBALS |
267 | mov edi, endofcode-OS_BASE |
267 | mov edi, endofcode-OS_BASE |
268 | mov ecx, 0x90000 |
268 | mov ecx, 0x90000 |
269 | sub ecx, edi |
269 | sub ecx, edi |
270 | shr ecx, 2 |
270 | shr ecx, 2 |
271 | rep stosd |
271 | rep stosd |
272 | 272 | ||
273 | ; SAVE & CLEAR 0-0xffff |
273 | ; SAVE & CLEAR 0-0xffff |
274 | 274 | ||
275 | mov edi, 0x1000 |
275 | mov edi, 0x1000 |
276 | mov ecx, 0x8000 / 4 |
276 | mov ecx, 0x8000 / 4 |
277 | rep stosd |
277 | rep stosd |
278 | mov edi, 0xa000 |
278 | mov edi, 0xa000 |
279 | mov ecx, 0x6000 / 4 |
279 | mov ecx, 0x6000 / 4 |
280 | rep stosd |
280 | rep stosd |
281 | 281 | ||
282 | call test_cpu |
282 | call test_cpu |
283 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
283 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
284 | 284 | ||
285 | call check_acpi |
285 | call check_acpi |
286 | call init_BIOS32 |
286 | call init_BIOS32 |
287 | ; MEMORY MODEL |
287 | ; MEMORY MODEL |
288 | call mem_test |
288 | call mem_test |
289 | call init_mem |
289 | call init_mem |
290 | call init_page_map |
290 | call init_page_map |
291 | 291 | ||
292 | ; ENABLE PAGING |
292 | ; ENABLE PAGING |
293 | 293 | ||
294 | mov eax, sys_pgdir-OS_BASE |
294 | mov eax, sys_pgdir-OS_BASE |
295 | mov cr3, eax |
295 | mov cr3, eax |
296 | 296 | ||
297 | mov eax, cr0 |
297 | mov eax, cr0 |
298 | or eax, CR0_PG+CR0_WP |
298 | or eax, CR0_PG+CR0_WP |
299 | mov cr0, eax |
299 | mov cr0, eax |
300 | 300 | ||
301 | lgdt [gdts] |
301 | lgdt [gdts] |
302 | jmp pword os_code:high_code |
302 | jmp pword os_code:high_code |
303 | 303 | ||
304 | align 4 |
304 | align 4 |
305 | bios32_entry dd ? |
305 | bios32_entry dd ? |
306 | tmp_page_tabs dd ? |
306 | tmp_page_tabs dd ? |
307 | 307 | ||
308 | use16 |
308 | use16 |
309 | org $-0x10000 |
309 | org $-0x10000 |
310 | include "boot/shutdown.inc" ; shutdown or restart |
310 | include "boot/shutdown.inc" ; shutdown or restart |
311 | org $+0x10000 |
311 | org $+0x10000 |
312 | use32 |
312 | use32 |
313 | 313 | ||
314 | __DEBUG__ fix 1 |
314 | __DEBUG__ fix 1 |
315 | __DEBUG_LEVEL__ fix 1 |
315 | __DEBUG_LEVEL__ fix 1 |
316 | include 'init.inc' |
316 | include 'init.inc' |
317 | 317 | ||
318 | org OS_BASE+$ |
318 | org OS_BASE+$ |
319 | 319 | ||
320 | include 'fdo.inc' |
320 | include 'fdo.inc' |
321 | 321 | ||
322 | align 4 |
322 | align 4 |
323 | high_code: |
323 | high_code: |
324 | mov ax, os_stack |
324 | mov ax, os_stack |
325 | mov bx, app_data |
325 | mov bx, app_data |
326 | mov cx, app_tls |
326 | mov cx, app_tls |
327 | mov ss, ax |
327 | mov ss, ax |
328 | add esp, OS_BASE |
328 | add esp, OS_BASE |
329 | 329 | ||
330 | mov ds, bx |
330 | mov ds, bx |
331 | mov es, bx |
331 | mov es, bx |
332 | mov fs, cx |
332 | mov fs, cx |
333 | mov gs, bx |
333 | mov gs, bx |
334 | 334 | ||
335 | bt [cpu_caps], CAPS_PGE |
335 | bt [cpu_caps], CAPS_PGE |
336 | jnc @F |
336 | jnc @F |
337 | 337 | ||
338 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
338 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
339 | 339 | ||
340 | mov ebx, cr4 |
340 | mov ebx, cr4 |
341 | or ebx, CR4_PGE |
341 | or ebx, CR4_PGE |
342 | mov cr4, ebx |
342 | mov cr4, ebx |
343 | @@: |
343 | @@: |
344 | xor eax, eax |
344 | xor eax, eax |
345 | mov dword [sys_pgdir], eax |
345 | mov dword [sys_pgdir], eax |
346 | mov dword [sys_pgdir+4], eax |
346 | mov dword [sys_pgdir+4], eax |
347 | 347 | ||
348 | mov eax, cr3 |
348 | mov eax, cr3 |
349 | mov cr3, eax ; flush TLB |
349 | mov cr3, eax ; flush TLB |
350 | 350 | ||
351 | mov ecx, pg_data.mutex |
351 | mov ecx, pg_data.mutex |
352 | call mutex_init |
352 | call mutex_init |
353 | 353 | ||
354 | mov ecx, disk_list_mutex |
354 | mov ecx, disk_list_mutex |
355 | call mutex_init |
355 | call mutex_init |
356 | 356 | ||
357 | mov ecx, keyboard_list_mutex |
357 | mov ecx, keyboard_list_mutex |
358 | call mutex_init |
358 | call mutex_init |
359 | 359 | ||
360 | mov ecx, unpack_mutex |
360 | mov ecx, unpack_mutex |
361 | call mutex_init |
361 | call mutex_init |
362 | 362 | ||
363 | mov ecx, application_table_mutex |
363 | mov ecx, application_table_mutex |
364 | call mutex_init |
364 | call mutex_init |
365 | 365 | ||
366 | mov ecx, ide_mutex |
366 | mov ecx, ide_mutex |
367 | call mutex_init |
367 | call mutex_init |
368 | mov ecx, ide_channel1_mutex |
368 | mov ecx, ide_channel1_mutex |
369 | call mutex_init |
369 | call mutex_init |
370 | mov ecx, ide_channel2_mutex |
370 | mov ecx, ide_channel2_mutex |
371 | call mutex_init |
371 | call mutex_init |
372 | mov ecx, ide_channel3_mutex |
372 | mov ecx, ide_channel3_mutex |
373 | call mutex_init |
373 | call mutex_init |
374 | mov ecx, ide_channel4_mutex |
374 | mov ecx, ide_channel4_mutex |
375 | call mutex_init |
375 | call mutex_init |
376 | mov ecx, ide_channel5_mutex |
376 | mov ecx, ide_channel5_mutex |
377 | call mutex_init |
377 | call mutex_init |
378 | mov ecx, ide_channel6_mutex |
378 | mov ecx, ide_channel6_mutex |
379 | call mutex_init |
379 | call mutex_init |
380 | ;----------------------------------------------------------------------------- |
380 | ;----------------------------------------------------------------------------- |
381 | ; SAVE REAL MODE VARIABLES |
381 | ; SAVE REAL MODE VARIABLES |
382 | ;----------------------------------------------------------------------------- |
382 | ;----------------------------------------------------------------------------- |
383 | ; --------------- APM --------------------- |
383 | ; --------------- APM --------------------- |
384 | 384 | ||
385 | ; init selectors |
385 | ; init selectors |
386 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
386 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
387 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
387 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
388 | ; protected-mode 32-bit code segment |
388 | ; protected-mode 32-bit code segment |
389 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
389 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
390 | ; protected-mode 16-bit code segment |
390 | ; protected-mode 16-bit code segment |
391 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
391 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
392 | ; protected-mode 16-bit data segment |
392 | ; protected-mode 16-bit data segment |
393 | 393 | ||
394 | shl eax, 4 |
394 | shl eax, 4 |
395 | mov [dword apm_code_32 + 2], ax |
395 | mov [dword apm_code_32 + 2], ax |
396 | shr eax, 16 |
396 | shr eax, 16 |
397 | mov [dword apm_code_32 + 4], al |
397 | mov [dword apm_code_32 + 4], al |
398 | 398 | ||
399 | shl ecx, 4 |
399 | shl ecx, 4 |
400 | mov [dword apm_code_16 + 2], cx |
400 | mov [dword apm_code_16 + 2], cx |
401 | shr ecx, 16 |
401 | shr ecx, 16 |
402 | mov [dword apm_code_16 + 4], cl |
402 | mov [dword apm_code_16 + 4], cl |
403 | 403 | ||
404 | shl edx, 4 |
404 | shl edx, 4 |
405 | mov [dword apm_data_16 + 2], dx |
405 | mov [dword apm_data_16 + 2], dx |
406 | shr edx, 16 |
406 | shr edx, 16 |
407 | mov [dword apm_data_16 + 4], dl |
407 | mov [dword apm_data_16 + 4], dl |
408 | 408 | ||
409 | mov dword[apm_entry], ebx |
409 | mov dword[apm_entry], ebx |
410 | mov word [apm_entry + 4], apm_code_32 - gdts |
410 | mov word [apm_entry + 4], apm_code_32 - gdts |
411 | 411 | ||
412 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
412 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
413 | mov [apm_vf], eax |
413 | mov [apm_vf], eax |
414 | ; ----------------------------------------- |
414 | ; ----------------------------------------- |
415 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
415 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
416 | mov [allow_dma_access], al |
416 | mov [allow_dma_access], al |
417 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
417 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
418 | mov [_display.bpp], eax |
418 | mov [_display.bpp], eax |
419 | mov [_display.vrefresh], 60 |
419 | mov [_display.vrefresh], 60 |
420 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
420 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
421 | mov [debug_direct_print], al |
421 | mov [debug_direct_print], al |
422 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
422 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
423 | mov [launcher_start], al |
423 | mov [launcher_start], al |
424 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
424 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
425 | mov [_display.width], eax |
425 | mov [_display.width], eax |
426 | mov [display_width_standard], eax |
426 | mov [display_width_standard], eax |
427 | dec eax |
427 | dec eax |
428 | mov [Screen_Max_X], eax |
428 | mov [Screen_Max_X], eax |
429 | mov [screen_workarea.right], eax |
429 | mov [screen_workarea.right], eax |
430 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
430 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
431 | mov [_display.height], eax |
431 | mov [_display.height], eax |
432 | mov [display_height_standard], eax |
432 | mov [display_height_standard], eax |
433 | dec eax |
433 | dec eax |
434 | mov [Screen_Max_Y], eax |
434 | mov [Screen_Max_Y], eax |
435 | mov [screen_workarea.bottom], eax |
435 | mov [screen_workarea.bottom], eax |
436 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
436 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
437 | mov dword [SCR_MODE], eax |
437 | mov dword [SCR_MODE], eax |
438 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
438 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
439 | ; mov [BANK_SWITCH], eax |
439 | ; mov [BANK_SWITCH], eax |
440 | mov eax, 640 *4 ; Bytes PerScanLine |
440 | mov eax, 640 *4 ; Bytes PerScanLine |
441 | cmp [SCR_MODE], word 0x13 ; 320x200 |
441 | cmp [SCR_MODE], word 0x13 ; 320x200 |
442 | je @f |
442 | je @f |
443 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
443 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
444 | je @f |
444 | je @f |
445 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
445 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
446 | @@: |
446 | @@: |
447 | mov [_display.pitch], eax |
447 | mov [_display.pitch], eax |
448 | mov eax, [_display.width] |
448 | mov eax, [_display.width] |
449 | mul [_display.height] |
449 | mul [_display.height] |
450 | mov [_WinMapSize], eax |
450 | mov [_WinMapSize], eax |
451 | 451 | ||
452 | call calculate_fast_getting_offset_for_WinMapAddress |
452 | call calculate_fast_getting_offset_for_WinMapAddress |
453 | ; for Qemu or non standart video cards |
453 | ; for Qemu or non standart video cards |
454 | ; Unfortunately [BytesPerScanLine] does not always |
454 | ; Unfortunately [BytesPerScanLine] does not always |
455 | ; equal to [_display.width] * [ScreenBPP] / 8 |
455 | ; equal to [_display.width] * [ScreenBPP] / 8 |
456 | call calculate_fast_getting_offset_for_LFB |
456 | call calculate_fast_getting_offset_for_LFB |
457 | 457 | ||
458 | mov esi, BOOT_VARS+0x9080 |
458 | mov esi, BOOT_VARS+0x9080 |
459 | movzx ecx, byte [esi-1] |
459 | movzx ecx, byte [esi-1] |
460 | mov [NumBiosDisks], ecx |
460 | mov [NumBiosDisks], ecx |
461 | mov edi, BiosDisksData |
461 | mov edi, BiosDisksData |
462 | rep movsd |
462 | rep movsd |
463 | 463 | ||
464 | ; GRAPHICS ADDRESSES |
464 | ; GRAPHICS ADDRESSES |
465 | 465 | ||
466 | mov eax, [BOOT_VARS+BOOT_LFB] |
466 | mov eax, [BOOT_VARS+BOOT_LFB] |
467 | mov [LFBAddress], eax |
467 | mov [LFBAddress], eax |
468 | 468 | ||
469 | cmp [SCR_MODE], word 0100000000000000b |
469 | cmp [SCR_MODE], word 0100000000000000b |
470 | jge setvesa20 |
470 | jge setvesa20 |
471 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
471 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
472 | je v20ga32 |
472 | je v20ga32 |
473 | jmp v20ga24 |
473 | jmp v20ga24 |
474 | 474 | ||
475 | setvesa20: |
475 | setvesa20: |
476 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
476 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
477 | mov [GETPIXEL], dword Vesa20_getpixel24 |
477 | mov [GETPIXEL], dword Vesa20_getpixel24 |
478 | cmp byte [_display.bpp], 24 |
478 | cmp byte [_display.bpp], 24 |
479 | jz v20ga24 |
479 | jz v20ga24 |
480 | v20ga32: |
480 | v20ga32: |
481 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
481 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
482 | mov [GETPIXEL], dword Vesa20_getpixel32 |
482 | mov [GETPIXEL], dword Vesa20_getpixel32 |
483 | jmp no_mode_0x12 |
483 | jmp no_mode_0x12 |
484 | v20ga24: |
484 | v20ga24: |
485 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
485 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
486 | jne no_mode_0x12 |
486 | jne no_mode_0x12 |
487 | mov [PUTPIXEL], dword VGA_putpixel |
487 | mov [PUTPIXEL], dword VGA_putpixel |
488 | mov [GETPIXEL], dword Vesa20_getpixel32 |
488 | mov [GETPIXEL], dword Vesa20_getpixel32 |
489 | no_mode_0x12: |
489 | no_mode_0x12: |
490 | 490 | ||
491 | mov [MOUSE_PICTURE], dword mousepointer |
491 | mov [MOUSE_PICTURE], dword mousepointer |
492 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
492 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
493 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
493 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
494 | 494 | ||
495 | ; -------- Fast System Call init ---------- |
495 | ; -------- Fast System Call init ---------- |
496 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
496 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
497 | bt [cpu_caps], CAPS_SEP |
497 | bt [cpu_caps], CAPS_SEP |
498 | jnc .SEnP ; SysEnter not Present |
498 | jnc .SEnP ; SysEnter not Present |
499 | xor edx, edx |
499 | xor edx, edx |
500 | mov ecx, MSR_SYSENTER_CS |
500 | mov ecx, MSR_SYSENTER_CS |
501 | mov eax, os_code |
501 | mov eax, os_code |
502 | wrmsr |
502 | wrmsr |
503 | mov ecx, MSR_SYSENTER_ESP |
503 | mov ecx, MSR_SYSENTER_ESP |
504 | ; mov eax, sysenter_stack ; Check it |
504 | ; mov eax, sysenter_stack ; Check it |
505 | xor eax, eax |
505 | xor eax, eax |
506 | wrmsr |
506 | wrmsr |
507 | mov ecx, MSR_SYSENTER_EIP |
507 | mov ecx, MSR_SYSENTER_EIP |
508 | mov eax, sysenter_entry |
508 | mov eax, sysenter_entry |
509 | wrmsr |
509 | wrmsr |
510 | .SEnP: |
510 | .SEnP: |
511 | ; AMD SYSCALL/SYSRET |
511 | ; AMD SYSCALL/SYSRET |
512 | cmp byte[cpu_vendor], 'A' |
512 | cmp byte[cpu_vendor], 'A' |
513 | jne .noSYSCALL |
513 | jne .noSYSCALL |
514 | mov eax, 0x80000001 |
514 | mov eax, 0x80000001 |
515 | cpuid |
515 | cpuid |
516 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
516 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
517 | jz .noSYSCALL |
517 | jz .noSYSCALL |
518 | mov ecx, MSR_AMD_EFER |
518 | mov ecx, MSR_AMD_EFER |
519 | rdmsr |
519 | rdmsr |
520 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
520 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
521 | wrmsr |
521 | wrmsr |
522 | 522 | ||
523 | ; !!!! It`s dirty hack, fix it !!! |
523 | ; !!!! It`s dirty hack, fix it !!! |
524 | ; Bits of EDX : |
524 | ; Bits of EDX : |
525 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
525 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
526 | ; and the contents of this field, plus 8, are copied into the SS register. |
526 | ; and the contents of this field, plus 8, are copied into the SS register. |
527 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
527 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
528 | ; and the contents of this field, plus 8, are copied into the SS register. |
528 | ; and the contents of this field, plus 8, are copied into the SS register. |
529 | 529 | ||
530 | ; mov edx, (os_code + 16) * 65536 + os_code |
530 | ; mov edx, (os_code + 16) * 65536 + os_code |
531 | mov edx, 0x1B0008 |
531 | mov edx, 0x1B0008 |
532 | 532 | ||
533 | mov eax, syscall_entry |
533 | mov eax, syscall_entry |
534 | mov ecx, MSR_AMD_STAR |
534 | mov ecx, MSR_AMD_STAR |
535 | wrmsr |
535 | wrmsr |
536 | .noSYSCALL: |
536 | .noSYSCALL: |
537 | ; ----------------------------------------- |
537 | ; ----------------------------------------- |
538 | stdcall alloc_page |
538 | stdcall alloc_page |
539 | stdcall map_page, tss-0xF80, eax, PG_SW |
539 | stdcall map_page, tss-0xF80, eax, PG_SW |
540 | stdcall alloc_page |
540 | stdcall alloc_page |
541 | stdcall map_page, tss+0x80, eax, PG_SW |
541 | stdcall map_page, tss+0x80, eax, PG_SW |
542 | stdcall alloc_page |
542 | stdcall alloc_page |
543 | stdcall map_page, tss+0x1080, eax, PG_SW |
543 | stdcall map_page, tss+0x1080, eax, PG_SW |
544 | 544 | ||
545 | ; LOAD IDT |
545 | ; LOAD IDT |
546 | 546 | ||
547 | call build_interrupt_table ;lidt is executed |
547 | call build_interrupt_table ;lidt is executed |
548 | ;lidt [idtreg] |
548 | ;lidt [idtreg] |
549 | 549 | ||
550 | call init_kernel_heap |
550 | call init_kernel_heap |
551 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
551 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
552 | mov [os_stack_seg], eax |
552 | mov [os_stack_seg], eax |
553 | 553 | ||
554 | lea esp, [eax+RING0_STACK_SIZE] |
554 | lea esp, [eax+RING0_STACK_SIZE] |
555 | 555 | ||
556 | mov [tss._ss0], os_stack |
556 | mov [tss._ss0], os_stack |
557 | mov [tss._esp0], esp |
557 | mov [tss._esp0], esp |
558 | mov [tss._esp], esp |
558 | mov [tss._esp], esp |
559 | mov [tss._cs], os_code |
559 | mov [tss._cs], os_code |
560 | mov [tss._ss], os_stack |
560 | mov [tss._ss], os_stack |
561 | mov [tss._ds], app_data |
561 | mov [tss._ds], app_data |
562 | mov [tss._es], app_data |
562 | mov [tss._es], app_data |
563 | mov [tss._fs], app_data |
563 | mov [tss._fs], app_data |
564 | mov [tss._gs], app_data |
564 | mov [tss._gs], app_data |
565 | mov [tss._io], 128 |
565 | mov [tss._io], 128 |
566 | ;Add IO access table - bit array of permitted ports |
566 | ;Add IO access table - bit array of permitted ports |
567 | mov edi, tss._io_map_0 |
567 | mov edi, tss._io_map_0 |
568 | xor eax, eax |
568 | xor eax, eax |
569 | not eax |
569 | not eax |
570 | mov ecx, 8192/4 |
570 | mov ecx, 8192/4 |
571 | rep stosd ; access to 4096*8=65536 ports |
571 | rep stosd ; access to 4096*8=65536 ports |
572 | 572 | ||
573 | mov ax, tss0 |
573 | mov ax, tss0 |
574 | ltr ax |
574 | ltr ax |
575 | 575 | ||
576 | mov [LFBSize], 0xC00000 |
576 | mov [LFBSize], 0xC00000 |
577 | call init_LFB |
577 | call init_LFB |
578 | call init_fpu |
578 | call init_fpu |
579 | call init_malloc |
579 | call init_malloc |
580 | 580 | ||
581 | stdcall alloc_kernel_space, 0x51000 |
581 | stdcall alloc_kernel_space, 0x51000 |
582 | mov [default_io_map], eax |
582 | mov [default_io_map], eax |
583 | 583 | ||
584 | add eax, 0x2000 |
584 | add eax, 0x2000 |
585 | mov [ipc_tmp], eax |
585 | mov [ipc_tmp], eax |
586 | mov ebx, 0x1000 |
586 | mov ebx, 0x1000 |
587 | 587 | ||
588 | add eax, 0x40000 |
588 | add eax, 0x40000 |
589 | mov [proc_mem_map], eax |
589 | mov [proc_mem_map], eax |
590 | 590 | ||
591 | add eax, 0x8000 |
591 | add eax, 0x8000 |
592 | mov [proc_mem_pdir], eax |
592 | mov [proc_mem_pdir], eax |
593 | 593 | ||
594 | add eax, ebx |
594 | add eax, ebx |
595 | mov [proc_mem_tab], eax |
595 | mov [proc_mem_tab], eax |
596 | 596 | ||
597 | add eax, ebx |
597 | add eax, ebx |
598 | mov [tmp_task_pdir], eax |
598 | mov [tmp_task_pdir], eax |
599 | 599 | ||
600 | add eax, ebx |
600 | add eax, ebx |
601 | mov [tmp_task_ptab], eax |
601 | mov [tmp_task_ptab], eax |
602 | 602 | ||
603 | add eax, ebx |
603 | add eax, ebx |
604 | mov [ipc_pdir], eax |
604 | mov [ipc_pdir], eax |
605 | 605 | ||
606 | add eax, ebx |
606 | add eax, ebx |
607 | mov [ipc_ptab], eax |
607 | mov [ipc_ptab], eax |
608 | 608 | ||
609 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
609 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
610 | (unpack.lc+unpack.lp)))*4 |
610 | (unpack.lc+unpack.lp)))*4 |
611 | 611 | ||
612 | mov [unpack.p], eax |
612 | mov [unpack.p], eax |
613 | 613 | ||
614 | call init_events |
614 | call init_events |
615 | mov eax, srv.fd-SRV.fd |
615 | mov eax, srv.fd-SRV.fd |
616 | mov [srv.fd], eax |
616 | mov [srv.fd], eax |
617 | mov [srv.bk], eax |
617 | mov [srv.bk], eax |
618 | 618 | ||
619 | ;Set base of graphic segment to linear address of LFB |
619 | ;Set base of graphic segment to linear address of LFB |
620 | mov eax, [LFBAddress] ; set for gs |
620 | mov eax, [LFBAddress] ; set for gs |
621 | mov [graph_data_l+2], ax |
621 | mov [graph_data_l+2], ax |
622 | shr eax, 16 |
622 | shr eax, 16 |
623 | mov [graph_data_l+4], al |
623 | mov [graph_data_l+4], al |
624 | mov [graph_data_l+7], ah |
624 | mov [graph_data_l+7], ah |
625 | 625 | ||
626 | stdcall kernel_alloc, [_WinMapSize] |
626 | stdcall kernel_alloc, [_WinMapSize] |
627 | mov [_WinMapAddress], eax |
627 | mov [_WinMapAddress], eax |
628 | 628 | ||
629 | xor eax, eax |
629 | xor eax, eax |
630 | inc eax |
630 | inc eax |
631 | 631 | ||
632 | ; set background |
632 | ; set background |
633 | 633 | ||
634 | mov [BgrDrawMode], eax |
634 | mov [BgrDrawMode], eax |
635 | mov [BgrDataWidth], eax |
635 | mov [BgrDataWidth], eax |
636 | mov [BgrDataHeight], eax |
636 | mov [BgrDataHeight], eax |
637 | mov [mem_BACKGROUND], 4 |
637 | mov [mem_BACKGROUND], 4 |
638 | mov [img_background], static_background_data |
638 | mov [img_background], static_background_data |
639 | 639 | ||
640 | ; set clipboard |
640 | ; set clipboard |
641 | 641 | ||
642 | xor eax, eax |
642 | xor eax, eax |
643 | mov [clipboard_slots], eax |
643 | mov [clipboard_slots], eax |
644 | mov [clipboard_write_lock], eax |
644 | mov [clipboard_write_lock], eax |
645 | stdcall kernel_alloc, 4096 |
645 | stdcall kernel_alloc, 4096 |
646 | test eax, eax |
646 | test eax, eax |
647 | jnz @f |
647 | jnz @f |
648 | 648 | ||
649 | dec eax |
649 | dec eax |
650 | @@: |
650 | @@: |
651 | mov [clipboard_main_list], eax |
651 | mov [clipboard_main_list], eax |
652 | 652 | ||
653 | ; SET UP OS TASK |
653 | ; SET UP OS TASK |
654 | 654 | ||
655 | mov esi, boot_setostask |
655 | mov esi, boot_setostask |
656 | call boot_log |
656 | call boot_log |
657 | 657 | ||
658 | mov edx, SLOT_BASE+256 |
658 | mov edx, SLOT_BASE+256 |
659 | mov ebx, [os_stack_seg] |
659 | mov ebx, [os_stack_seg] |
660 | add ebx, 0x2000 |
660 | add ebx, 0x2000 |
661 | call setup_os_slot |
661 | call setup_os_slot |
662 | mov dword [edx], 'IDLE' |
662 | mov dword [edx], 'IDLE' |
663 | sub [edx+APPDATA.saved_esp], 4 |
663 | sub [edx+APPDATA.saved_esp], 4 |
664 | mov eax, [edx+APPDATA.saved_esp] |
664 | mov eax, [edx+APPDATA.saved_esp] |
665 | mov dword [eax], idle_thread |
665 | mov dword [eax], idle_thread |
666 | mov ecx, IDLE_PRIORITY |
666 | mov ecx, IDLE_PRIORITY |
667 | call scheduler_add_thread |
667 | call scheduler_add_thread |
668 | 668 | ||
669 | mov edx, SLOT_BASE+256*2 |
669 | mov edx, SLOT_BASE+256*2 |
670 | mov ebx, [os_stack_seg] |
670 | mov ebx, [os_stack_seg] |
671 | call setup_os_slot |
671 | call setup_os_slot |
672 | mov dword [edx], 'OS' |
672 | mov dword [edx], 'OS' |
673 | xor ecx, ecx |
673 | xor ecx, ecx |
674 | call scheduler_add_thread |
674 | call scheduler_add_thread |
675 | 675 | ||
676 | mov dword [CURRENT_TASK], 2 |
676 | mov dword [CURRENT_TASK], 2 |
677 | mov dword [TASK_COUNT], 2 |
677 | mov dword [TASK_COUNT], 2 |
678 | mov dword [current_slot], SLOT_BASE + 256*2 |
678 | mov dword [current_slot], SLOT_BASE + 256*2 |
679 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
679 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
680 | 680 | ||
681 | 681 | ||
682 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
682 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
683 | mov esi, boot_initirq |
683 | mov esi, boot_initirq |
684 | call boot_log |
684 | call boot_log |
685 | call init_irqs |
685 | call init_irqs |
686 | 686 | ||
687 | mov esi, boot_picinit |
687 | mov esi, boot_picinit |
688 | call boot_log |
688 | call boot_log |
689 | call PIC_init |
689 | call PIC_init |
690 | 690 | ||
691 | mov esi, boot_v86machine |
691 | mov esi, boot_v86machine |
692 | call boot_log |
692 | call boot_log |
693 | ; Initialize system V86 machine |
693 | ; Initialize system V86 machine |
694 | call init_sys_v86 |
694 | call init_sys_v86 |
695 | 695 | ||
696 | mov esi, boot_inittimer |
696 | mov esi, boot_inittimer |
697 | call boot_log |
697 | call boot_log |
698 | ; Initialize system timer (IRQ0) |
698 | ; Initialize system timer (IRQ0) |
699 | call PIT_init |
699 | call PIT_init |
700 | 700 | ||
701 | ; Register ramdisk file system |
701 | ; Register ramdisk file system |
702 | mov esi, boot_initramdisk |
702 | cmp [boot_dev+OS_BASE+0x10000], 1 |
703 | call boot_log |
703 | je @f |
704 | call ramdisk_init |
- | |
- | 704 | ||
- | 705 | call register_ramdisk |
|
- | 706 | ;-------------------------------------- |
|
705 | 707 | @@: |
|
706 | mov esi, boot_initapic |
708 | mov esi, boot_initapic |
707 | call boot_log |
709 | call boot_log |
708 | ; Try to Initialize APIC |
710 | ; Try to Initialize APIC |
709 | call APIC_init |
711 | call APIC_init |
710 | 712 | ||
711 | mov esi, boot_enableirq |
713 | mov esi, boot_enableirq |
712 | call boot_log |
714 | call boot_log |
713 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
715 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
714 | ; they are used: when partitions are scanned, hd_read relies on timer |
716 | ; they are used: when partitions are scanned, hd_read relies on timer |
715 | call unmask_timer |
717 | call unmask_timer |
716 | stdcall enable_irq, 2 ; @#$%! PIC |
718 | stdcall enable_irq, 2 ; @#$%! PIC |
717 | stdcall enable_irq, 13 ; co-processor |
719 | stdcall enable_irq, 13 ; co-processor |
718 | 720 | ||
719 | ; Setup serial output console (if enabled) |
721 | ; Setup serial output console (if enabled) |
720 | if defined debug_com_base |
722 | if defined debug_com_base |
721 | 723 | ||
722 | ; reserve port so nobody else will use it |
724 | ; reserve port so nobody else will use it |
723 | xor ebx, ebx |
725 | xor ebx, ebx |
724 | mov ecx, debug_com_base |
726 | mov ecx, debug_com_base |
725 | mov edx, debug_com_base+7 |
727 | mov edx, debug_com_base+7 |
726 | call r_f_port_area |
728 | call r_f_port_area |
727 | 729 | ||
728 | ; enable Divisor latch |
730 | ; enable Divisor latch |
729 | mov dx, debug_com_base+3 |
731 | mov dx, debug_com_base+3 |
730 | mov al, 1 shl 7 |
732 | mov al, 1 shl 7 |
731 | out dx, al |
733 | out dx, al |
732 | 734 | ||
733 | ; Set speed to 115200 baud (max speed) |
735 | ; Set speed to 115200 baud (max speed) |
734 | mov dx, debug_com_base |
736 | mov dx, debug_com_base |
735 | mov al, 0x01 |
737 | mov al, 0x01 |
736 | out dx, al |
738 | out dx, al |
737 | 739 | ||
738 | mov dx, debug_com_base+1 |
740 | mov dx, debug_com_base+1 |
739 | mov al, 0x00 |
741 | mov al, 0x00 |
740 | out dx, al |
742 | out dx, al |
741 | 743 | ||
742 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
744 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
743 | mov dx, debug_com_base+3 |
745 | mov dx, debug_com_base+3 |
744 | mov al, 3 |
746 | mov al, 3 |
745 | out dx, al |
747 | out dx, al |
746 | 748 | ||
747 | ; disable interrupts |
749 | ; disable interrupts |
748 | mov dx, debug_com_base+1 |
750 | mov dx, debug_com_base+1 |
749 | mov al, 0 |
751 | mov al, 0 |
750 | out dx, al |
752 | out dx, al |
751 | 753 | ||
752 | ; clear + enable fifo (64 bits) |
754 | ; clear + enable fifo (64 bits) |
753 | mov dx, debug_com_base+2 |
755 | mov dx, debug_com_base+2 |
754 | mov al, 0x7 + 1 shl 5 |
756 | mov al, 0x7 + 1 shl 5 |
755 | out dx, al |
757 | out dx, al |
756 | 758 | ||
757 | end if |
759 | end if |
758 | 760 | ||
759 | 761 | ||
760 | ;----------------------------------------------------------------------------- |
762 | ;----------------------------------------------------------------------------- |
761 | ; show SVN version of kernel on the message board |
763 | ; show SVN version of kernel on the message board |
762 | ;----------------------------------------------------------------------------- |
764 | ;----------------------------------------------------------------------------- |
763 | mov eax, [version_inf.rev] |
765 | mov eax, [version_inf.rev] |
764 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
766 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
765 | ;----------------------------------------------------------------------------- |
767 | ;----------------------------------------------------------------------------- |
766 | ; show CPU count on the message board |
768 | ; show CPU count on the message board |
767 | ;----------------------------------------------------------------------------- |
769 | ;----------------------------------------------------------------------------- |
768 | mov eax, [cpu_count] |
770 | mov eax, [cpu_count] |
769 | test eax, eax |
771 | test eax, eax |
770 | jnz @F |
772 | jnz @F |
771 | mov al, 1 ; at least one CPU |
773 | mov al, 1 ; at least one CPU |
772 | @@: |
774 | @@: |
773 | DEBUGF 1, "K : %d CPU detected\n", eax |
775 | DEBUGF 1, "K : %d CPU detected\n", eax |
774 | ;----------------------------------------------------------------------------- |
776 | ;----------------------------------------------------------------------------- |
775 | ; detect Floppy drives |
777 | ; detect Floppy drives |
776 | ;----------------------------------------------------------------------------- |
778 | ;----------------------------------------------------------------------------- |
777 | mov esi, boot_detectfloppy |
779 | mov esi, boot_detectfloppy |
778 | call boot_log |
780 | call boot_log |
779 | include 'detect/dev_fd.inc' |
781 | include 'detect/dev_fd.inc' |
780 | ;----------------------------------------------------------------------------- |
782 | ;----------------------------------------------------------------------------- |
781 | ; create pci-devices list |
783 | ; create pci-devices list |
782 | ;----------------------------------------------------------------------------- |
784 | ;----------------------------------------------------------------------------- |
783 | mov [pci_access_enabled], 1 |
785 | mov [pci_access_enabled], 1 |
784 | call pci_enum |
786 | call pci_enum |
785 | ;----------------------------------------------------------------------------- |
787 | ;----------------------------------------------------------------------------- |
786 | ; initialisation IDE ATA code |
788 | ; initialisation IDE ATA code |
787 | ;----------------------------------------------------------------------------- |
789 | ;----------------------------------------------------------------------------- |
788 | include 'detect/init_ata.inc' |
790 | include 'detect/init_ata.inc' |
789 | ;----------------------------------------------------------------------------- |
791 | ;----------------------------------------------------------------------------- |
790 | mov esi, boot_init_sys |
- | |
791 | call boot_log |
- | |
792 | call Parser_params |
- | |
793 | - | ||
794 | if ~ defined extended_primary_loader |
- | |
795 | ; ramdisk image should be loaded by extended primary loader if it exists |
- | |
796 | ; READ RAMDISK IMAGE FROM HD |
- | |
797 | - | ||
798 | ;!!!!!!!!!!!!!!!!!!!!!!! |
- | |
799 | include 'boot/rdload.inc' |
- | |
800 | ;!!!!!!!!!!!!!!!!!!!!!!! |
- | |
801 | end if |
- | |
802 | - | ||
803 | if 0 |
792 | if 0 |
804 | mov ax, [OS_BASE+0x10000+bx_from_load] |
793 | mov ax, [OS_BASE+0x10000+bx_from_load] |
805 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
794 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
806 | je no_lib_load |
795 | je no_lib_load |
807 | 796 | ||
808 | mov esi, boot_loadlibs |
797 | mov esi, boot_loadlibs |
809 | call boot_log |
798 | call boot_log |
810 | ; LOADING LIBRARES |
799 | ; LOADING LIBRARES |
811 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
800 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
812 | call load_file_parse_table ; prepare file parse table |
801 | call load_file_parse_table ; prepare file parse table |
813 | call set_kernel_conf ; configure devices and gui |
802 | call set_kernel_conf ; configure devices and gui |
814 | no_lib_load: |
803 | no_lib_load: |
815 | end if |
804 | end if |
816 | 805 | ||
817 | ; Display APIC status |
806 | ; Display APIC status |
818 | mov esi, boot_APIC_found |
807 | mov esi, boot_APIC_found |
819 | cmp [irq_mode], IRQ_APIC |
808 | cmp [irq_mode], IRQ_APIC |
820 | je @f |
809 | je @f |
821 | mov esi, boot_APIC_nfound |
810 | mov esi, boot_APIC_nfound |
822 | @@: |
811 | @@: |
823 | call boot_log |
812 | call boot_log |
824 | 813 | ||
825 | ; PRINT AMOUNT OF MEMORY |
814 | ; PRINT AMOUNT OF MEMORY |
826 | mov esi, boot_memdetect |
815 | mov esi, boot_memdetect |
827 | call boot_log |
816 | call boot_log |
828 | 817 | ||
829 | movzx ecx, word [boot_y] |
818 | movzx ecx, word [boot_y] |
830 | if lang eq ru |
819 | if lang eq ru |
831 | or ecx, (10+30*6) shl 16 |
820 | or ecx, (10+30*6) shl 16 |
832 | else if lang eq sp |
821 | else if lang eq sp |
833 | or ecx, (10+33*6) shl 16 |
822 | or ecx, (10+33*6) shl 16 |
834 | else |
823 | else |
835 | or ecx, (10+29*6) shl 16 |
824 | or ecx, (10+29*6) shl 16 |
836 | end if |
825 | end if |
837 | sub ecx, 10 |
826 | sub ecx, 10 |
838 | mov edx, 0xFFFFFF |
827 | mov edx, 0xFFFFFF |
839 | mov ebx, [MEM_AMOUNT] |
828 | mov ebx, [MEM_AMOUNT] |
840 | shr ebx, 20 |
829 | shr ebx, 20 |
841 | xor edi, edi |
830 | xor edi, edi |
842 | mov eax, 0x00040000 |
831 | mov eax, 0x00040000 |
843 | inc edi |
832 | inc edi |
844 | call display_number_force |
833 | call display_number_force |
845 | 834 | ||
846 | ; BUILD SCHEDULER |
835 | ; BUILD SCHEDULER |
847 | 836 | ||
848 | ; call build_scheduler; sys32.inc |
837 | ; call build_scheduler; sys32.inc |
849 | 838 | ||
850 | ; mov esi, boot_devices |
839 | ; mov esi, boot_devices |
851 | ; call boot_log |
840 | ; call boot_log |
852 | 841 | ||
853 | call clear_pci_ide_interrupts |
842 | call clear_pci_ide_interrupts |
854 | 843 | ||
855 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
844 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
856 | 845 | ||
857 | stdcall load_driver, szVidintel |
846 | stdcall load_driver, szVidintel |
858 | 847 | ||
859 | call usb_init |
848 | call usb_init |
860 | 849 | ||
861 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
850 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
862 | 851 | ||
863 | mov esi, boot_windefs |
852 | mov esi, boot_windefs |
864 | call boot_log |
853 | call boot_log |
865 | call set_window_defaults |
854 | call set_window_defaults |
866 | 855 | ||
867 | ; SET BACKGROUND DEFAULTS |
856 | ; SET BACKGROUND DEFAULTS |
868 | 857 | ||
869 | mov esi, boot_bgr |
858 | mov esi, boot_bgr |
870 | call boot_log |
859 | call boot_log |
871 | call init_background |
860 | call init_background |
872 | call calculatebackground |
861 | call calculatebackground |
873 | 862 | ||
874 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
863 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
875 | 864 | ||
876 | mov esi, boot_resirqports |
865 | mov esi, boot_resirqports |
877 | call boot_log |
866 | call boot_log |
878 | call reserve_irqs_ports |
867 | call reserve_irqs_ports |
879 | 868 | ||
880 | call init_display |
869 | call init_display |
881 | mov eax, [def_cursor] |
870 | mov eax, [def_cursor] |
882 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
871 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
883 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
872 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
884 | 873 | ||
885 | ; PRINT CPU FREQUENCY |
874 | ; PRINT CPU FREQUENCY |
886 | 875 | ||
887 | mov esi, boot_cpufreq |
876 | mov esi, boot_cpufreq |
888 | call boot_log |
877 | call boot_log |
889 | 878 | ||
890 | cli ;FIXME check IF |
879 | cli ;FIXME check IF |
891 | rdtsc |
880 | rdtsc |
892 | mov ecx, eax |
881 | mov ecx, eax |
893 | mov esi, 250 ; wait 1/4 a second |
882 | mov esi, 250 ; wait 1/4 a second |
894 | call delay_ms |
883 | call delay_ms |
895 | rdtsc |
884 | rdtsc |
896 | 885 | ||
897 | sub eax, ecx |
886 | sub eax, ecx |
898 | xor edx, edx |
887 | xor edx, edx |
899 | shld edx, eax, 2 |
888 | shld edx, eax, 2 |
900 | shl eax, 2 |
889 | shl eax, 2 |
901 | mov dword [cpu_freq], eax |
890 | mov dword [cpu_freq], eax |
902 | mov dword [cpu_freq+4], edx |
891 | mov dword [cpu_freq+4], edx |
903 | mov ebx, 1000000 |
892 | mov ebx, 1000000 |
904 | div ebx |
893 | div ebx |
905 | mov ebx, eax |
894 | mov ebx, eax |
906 | 895 | ||
907 | movzx ecx, word [boot_y] |
896 | movzx ecx, word [boot_y] |
908 | if lang eq ru |
897 | if lang eq ru |
909 | add ecx, (10+19*6) shl 16 - 10 |
898 | add ecx, (10+19*6) shl 16 - 10 |
910 | else if lang eq sp |
899 | else if lang eq sp |
911 | add ecx, (10+25*6) shl 16 - 10 |
900 | add ecx, (10+25*6) shl 16 - 10 |
912 | else |
901 | else |
913 | add ecx, (10+17*6) shl 16 - 10 |
902 | add ecx, (10+17*6) shl 16 - 10 |
914 | end if |
903 | end if |
915 | 904 | ||
916 | mov edx, 0xFFFFFF |
905 | mov edx, 0xFFFFFF |
917 | xor edi, edi |
906 | xor edi, edi |
918 | mov eax, 0x00040000 |
907 | mov eax, 0x00040000 |
919 | inc edi |
908 | inc edi |
920 | call display_number_force |
909 | call display_number_force |
921 | 910 | ||
922 | ; SET VARIABLES |
911 | ; SET VARIABLES |
923 | 912 | ||
924 | call set_variables |
913 | call set_variables |
925 | 914 | ||
926 | ; STACK AND FDC |
915 | ; STACK AND FDC |
927 | 916 | ||
928 | call stack_init |
917 | call stack_init |
929 | call fdc_init |
918 | call fdc_init |
930 | 919 | ||
931 | ; PALETTE FOR 320x200 and 640x480 16 col |
920 | ; PALETTE FOR 320x200 and 640x480 16 col |
932 | 921 | ||
933 | cmp [SCR_MODE], word 0x12 |
922 | cmp [SCR_MODE], word 0x12 |
934 | jne no_pal_vga |
923 | jne no_pal_vga |
935 | mov esi, boot_pal_vga |
924 | mov esi, boot_pal_vga |
936 | call boot_log |
925 | call boot_log |
937 | call paletteVGA |
926 | call paletteVGA |
938 | no_pal_vga: |
927 | no_pal_vga: |
939 | 928 | ||
940 | cmp [SCR_MODE], word 0x13 |
929 | cmp [SCR_MODE], word 0x13 |
941 | jne no_pal_ega |
930 | jne no_pal_ega |
942 | mov esi, boot_pal_ega |
931 | mov esi, boot_pal_ega |
943 | call boot_log |
932 | call boot_log |
944 | call palette320x200 |
933 | call palette320x200 |
945 | no_pal_ega: |
934 | no_pal_ega: |
946 | 935 | ||
947 | ; LOAD DEFAULT SKIN |
936 | ; LOAD DEFAULT SKIN |
948 | 937 | ||
949 | call load_default_skin |
938 | call load_default_skin |
950 | 939 | ||
951 | ;protect io permission map |
940 | ;protect io permission map |
952 | 941 | ||
953 | mov esi, [default_io_map] |
942 | mov esi, [default_io_map] |
954 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
943 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
955 | add esi, 0x1000 |
944 | add esi, 0x1000 |
956 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
945 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
957 | 946 | ||
958 | stdcall map_page, tss._io_map_0, \ |
947 | stdcall map_page, tss._io_map_0, \ |
959 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
948 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
960 | stdcall map_page, tss._io_map_1, \ |
949 | stdcall map_page, tss._io_map_1, \ |
961 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
950 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
962 | 951 | ||
963 | ; LOAD FIRST APPLICATION |
952 | ; LOAD FIRST APPLICATION |
964 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
953 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
965 | jnz first_app_found |
954 | jnz first_app_found |
966 | 955 | ||
967 | cli |
956 | cli |
968 | mov ebp, firstapp |
957 | mov ebp, firstapp |
969 | call fs_execute_from_sysdir |
958 | call fs_execute_from_sysdir |
970 | test eax, eax |
959 | test eax, eax |
971 | jns first_app_found |
960 | jns first_app_found |
972 | 961 | ||
973 | mov esi, boot_failed |
962 | mov esi, boot_failed |
974 | call boot_log |
963 | call boot_log |
975 | 964 | ||
976 | mov eax, 0xDEADBEEF ; otherwise halt |
965 | mov eax, 0xDEADBEEF ; otherwise halt |
977 | hlt |
966 | hlt |
978 | 967 | ||
979 | first_app_found: |
968 | first_app_found: |
980 | 969 | ||
981 | cli |
970 | cli |
982 | 971 | ||
983 | ; SET KEYBOARD PARAMETERS |
972 | ; SET KEYBOARD PARAMETERS |
984 | mov al, 0xf6 ; reset keyboard, scan enabled |
973 | mov al, 0xf6 ; reset keyboard, scan enabled |
985 | call kb_write |
974 | call kb_write |
986 | test ah, ah |
975 | test ah, ah |
987 | jnz .no_keyboard |
976 | jnz .no_keyboard |
988 | 977 | ||
989 | ; wait until 8042 is ready |
978 | ; wait until 8042 is ready |
990 | xor ecx, ecx |
979 | xor ecx, ecx |
991 | @@: |
980 | @@: |
992 | in al, 64h |
981 | in al, 64h |
993 | and al, 00000010b |
982 | and al, 00000010b |
994 | loopnz @b |
983 | loopnz @b |
995 | 984 | ||
996 | iglobal |
985 | iglobal |
997 | align 4 |
986 | align 4 |
998 | ps2_keyboard_functions: |
987 | ps2_keyboard_functions: |
999 | dd .end - $ |
988 | dd .end - $ |
1000 | dd 0 ; no close |
989 | dd 0 ; no close |
1001 | dd ps2_set_lights |
990 | dd ps2_set_lights |
1002 | .end: |
991 | .end: |
1003 | endg |
992 | endg |
1004 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
993 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1005 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
994 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1006 | ; call kb_write |
995 | ; call kb_write |
1007 | ; call kb_read |
996 | ; call kb_read |
1008 | ; mov al, 111b |
997 | ; mov al, 111b |
1009 | ; call kb_write |
998 | ; call kb_write |
1010 | ; call kb_read |
999 | ; call kb_read |
1011 | 1000 | ||
1012 | mov al, 0xF3 ; set repeat rate & delay |
1001 | mov al, 0xF3 ; set repeat rate & delay |
1013 | call kb_write |
1002 | call kb_write |
1014 | ; call kb_read |
1003 | ; call kb_read |
1015 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1004 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1016 | call kb_write |
1005 | call kb_write |
1017 | ; call kb_read |
1006 | ; call kb_read |
1018 | ;// mike.dld [ |
1007 | ;// mike.dld [ |
1019 | call set_lights |
1008 | call set_lights |
1020 | ;// mike.dld ] |
1009 | ;// mike.dld ] |
1021 | stdcall attach_int_handler, 1, irq1, 0 |
1010 | stdcall attach_int_handler, 1, irq1, 0 |
1022 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1011 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1023 | .no_keyboard: |
1012 | .no_keyboard: |
1024 | 1013 | ||
1025 | ; Load PS/2 mouse driver |
1014 | ; Load PS/2 mouse driver |
1026 | 1015 | ||
1027 | stdcall load_driver, szPS2MDriver |
1016 | stdcall load_driver, szPS2MDriver |
1028 | 1017 | ||
1029 | mov esi, boot_setmouse |
1018 | mov esi, boot_setmouse |
1030 | call boot_log |
1019 | call boot_log |
1031 | call setmouse |
1020 | call setmouse |
1032 | 1021 | ||
1033 | ; START MULTITASKING |
1022 | ; START MULTITASKING |
1034 | 1023 | ||
1035 | ; A 'All set - press ESC to start' messages if need |
1024 | ; A 'All set - press ESC to start' messages if need |
1036 | if preboot_blogesc |
1025 | if preboot_blogesc |
1037 | mov esi, boot_tasking |
1026 | mov esi, boot_tasking |
1038 | call boot_log |
1027 | call boot_log |
1039 | .bll1: |
1028 | .bll1: |
1040 | in al, 0x60 ; wait for ESC key press |
1029 | in al, 0x60 ; wait for ESC key press |
1041 | cmp al, 129 |
1030 | cmp al, 129 |
1042 | jne .bll1 |
1031 | jne .bll1 |
1043 | end if |
1032 | end if |
1044 | 1033 | ||
1045 | mov [timer_ticks_enable], 1 ; for cd driver |
1034 | mov [timer_ticks_enable], 1 ; for cd driver |
1046 | 1035 | ||
1047 | sti |
1036 | sti |
1048 | 1037 | ||
1049 | call mtrr_validate |
1038 | call mtrr_validate |
1050 | 1039 | ||
1051 | jmp osloop |
1040 | jmp osloop |
1052 | 1041 | ||
1053 | 1042 | ||
1054 | ; Fly :) |
1043 | ; Fly :) |
1055 | 1044 | ||
1056 | include 'unpacker.inc' |
1045 | include 'unpacker.inc' |
1057 | 1046 | ||
1058 | align 4 |
1047 | align 4 |
1059 | boot_log: |
1048 | boot_log: |
1060 | pushad |
1049 | pushad |
1061 | 1050 | ||
1062 | mov ebx, 10*65536 |
1051 | mov ebx, 10*65536 |
1063 | mov bx, word [boot_y] |
1052 | mov bx, word [boot_y] |
1064 | add [boot_y], dword 10 |
1053 | add [boot_y], dword 10 |
1065 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1054 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1066 | xor edi, edi |
1055 | xor edi, edi |
1067 | mov edx, esi |
1056 | mov edx, esi |
1068 | inc edi |
1057 | inc edi |
1069 | call dtext |
1058 | call dtext |
1070 | 1059 | ||
1071 | mov [novesachecksum], 1000 |
1060 | mov [novesachecksum], 1000 |
1072 | call checkVga_N13 |
1061 | call checkVga_N13 |
1073 | 1062 | ||
1074 | popad |
1063 | popad |
1075 | 1064 | ||
1076 | ret |
1065 | ret |
1077 | 1066 | ||
1078 | ; in: edx -> APPDATA for OS/IDLE slot |
1067 | ; in: edx -> APPDATA for OS/IDLE slot |
1079 | ; in: ebx = stack base |
1068 | ; in: ebx = stack base |
1080 | proc setup_os_slot |
1069 | proc setup_os_slot |
1081 | xor eax, eax |
1070 | xor eax, eax |
1082 | mov ecx, 256/4 |
1071 | mov ecx, 256/4 |
1083 | mov edi, edx |
1072 | mov edi, edx |
1084 | rep stosd |
1073 | rep stosd |
1085 | 1074 | ||
1086 | mov eax, tss+0x80 |
1075 | mov eax, tss+0x80 |
1087 | call get_pg_addr |
1076 | call get_pg_addr |
1088 | inc eax |
1077 | inc eax |
1089 | mov [edx+APPDATA.io_map], eax |
1078 | mov [edx+APPDATA.io_map], eax |
1090 | mov eax, tss+0x1080 |
1079 | mov eax, tss+0x1080 |
1091 | call get_pg_addr |
1080 | call get_pg_addr |
1092 | inc eax |
1081 | inc eax |
1093 | mov [edx+APPDATA.io_map+4], eax |
1082 | mov [edx+APPDATA.io_map+4], eax |
1094 | 1083 | ||
1095 | mov dword [edx+APPDATA.pl0_stack], ebx |
1084 | mov dword [edx+APPDATA.pl0_stack], ebx |
1096 | lea edi, [ebx+0x2000-512] |
1085 | lea edi, [ebx+0x2000-512] |
1097 | mov dword [edx+APPDATA.fpu_state], edi |
1086 | mov dword [edx+APPDATA.fpu_state], edi |
1098 | mov dword [edx+APPDATA.saved_esp0], edi |
1087 | mov dword [edx+APPDATA.saved_esp0], edi |
1099 | mov dword [edx+APPDATA.saved_esp], edi |
1088 | mov dword [edx+APPDATA.saved_esp], edi |
1100 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1089 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1101 | 1090 | ||
1102 | mov esi, fpu_data |
1091 | mov esi, fpu_data |
1103 | mov ecx, 512/4 |
1092 | mov ecx, 512/4 |
1104 | cld |
1093 | cld |
1105 | rep movsd |
1094 | rep movsd |
1106 | 1095 | ||
1107 | lea eax, [edx+APP_OBJ_OFFSET] |
1096 | lea eax, [edx+APP_OBJ_OFFSET] |
1108 | mov dword [edx+APPDATA.fd_obj], eax |
1097 | mov dword [edx+APPDATA.fd_obj], eax |
1109 | mov dword [edx+APPDATA.bk_obj], eax |
1098 | mov dword [edx+APPDATA.bk_obj], eax |
1110 | 1099 | ||
1111 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1100 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1112 | 1101 | ||
1113 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1102 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1114 | 1103 | ||
1115 | mov eax, edx |
1104 | mov eax, edx |
1116 | shr eax, 3 |
1105 | shr eax, 3 |
1117 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1106 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1118 | mov [eax+TASKDATA.wnd_number], dh |
1107 | mov [eax+TASKDATA.wnd_number], dh |
1119 | mov byte [eax+TASKDATA.pid], dh |
1108 | mov byte [eax+TASKDATA.pid], dh |
1120 | 1109 | ||
1121 | ret |
1110 | ret |
1122 | endp |
1111 | endp |
1123 | 1112 | ||
1124 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1113 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1125 | ; ; |
1114 | ; ; |
1126 | ; MAIN OS LOOP START ; |
1115 | ; MAIN OS LOOP START ; |
1127 | ; ; |
1116 | ; ; |
1128 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1117 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1129 | align 32 |
1118 | align 32 |
1130 | osloop: |
1119 | osloop: |
1131 | mov edx, osloop_has_work? |
1120 | mov edx, osloop_has_work? |
1132 | xor ecx, ecx |
1121 | xor ecx, ecx |
1133 | call Wait_events |
1122 | call Wait_events |
1134 | xor eax, eax |
1123 | xor eax, eax |
1135 | xchg eax, [osloop_nonperiodic_work] |
1124 | xchg eax, [osloop_nonperiodic_work] |
1136 | test eax, eax |
1125 | test eax, eax |
1137 | jz .no_periodic |
1126 | jz .no_periodic |
1138 | 1127 | ||
1139 | call __sys_draw_pointer |
1128 | call __sys_draw_pointer |
1140 | call window_check_events |
1129 | call window_check_events |
1141 | call mouse_check_events |
1130 | call mouse_check_events |
1142 | call checkmisc |
1131 | call checkmisc |
1143 | call checkVga_N13 |
1132 | call checkVga_N13 |
1144 | ;-------------------------------------- |
1133 | ;-------------------------------------- |
1145 | .no_periodic: |
1134 | .no_periodic: |
1146 | call stack_handler |
1135 | call stack_handler |
1147 | call check_fdd_motor_status |
1136 | call check_fdd_motor_status |
1148 | call check_ATAPI_device_event |
1137 | call check_ATAPI_device_event |
1149 | call check_lights_state |
1138 | call check_lights_state |
1150 | call check_timers |
1139 | call check_timers |
1151 | 1140 | ||
1152 | jmp osloop |
1141 | jmp osloop |
1153 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1142 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1154 | ; ; |
1143 | ; ; |
1155 | ; MAIN OS LOOP END ; |
1144 | ; MAIN OS LOOP END ; |
1156 | ; ; |
1145 | ; ; |
1157 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1146 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1158 | proc osloop_has_work? |
1147 | proc osloop_has_work? |
1159 | cmp [osloop_nonperiodic_work], 0 |
1148 | cmp [osloop_nonperiodic_work], 0 |
1160 | jnz .yes |
1149 | jnz .yes |
1161 | call stack_handler_has_work? |
1150 | call stack_handler_has_work? |
1162 | jnz .yes |
1151 | jnz .yes |
1163 | call check_fdd_motor_status_has_work? |
1152 | call check_fdd_motor_status_has_work? |
1164 | jnz .yes |
1153 | jnz .yes |
1165 | call check_ATAPI_device_event_has_work? |
1154 | call check_ATAPI_device_event_has_work? |
1166 | jnz .yes |
1155 | jnz .yes |
1167 | call check_lights_state_has_work? |
1156 | call check_lights_state_has_work? |
1168 | jnz .yes |
1157 | jnz .yes |
1169 | call check_timers_has_work? |
1158 | call check_timers_has_work? |
1170 | jnz .yes |
1159 | jnz .yes |
1171 | .no: |
1160 | .no: |
1172 | xor eax, eax |
1161 | xor eax, eax |
1173 | ret |
1162 | ret |
1174 | .yes: |
1163 | .yes: |
1175 | xor eax, eax |
1164 | xor eax, eax |
1176 | inc eax |
1165 | inc eax |
1177 | ret |
1166 | ret |
1178 | endp |
1167 | endp |
1179 | 1168 | ||
1180 | proc wakeup_osloop |
1169 | proc wakeup_osloop |
1181 | mov [osloop_nonperiodic_work], 1 |
1170 | mov [osloop_nonperiodic_work], 1 |
1182 | ret |
1171 | ret |
1183 | endp |
1172 | endp |
1184 | 1173 | ||
1185 | uglobal |
1174 | uglobal |
1186 | align 4 |
1175 | align 4 |
1187 | osloop_nonperiodic_work dd ? |
1176 | osloop_nonperiodic_work dd ? |
1188 | endg |
1177 | endg |
1189 | 1178 | ||
1190 | align 4 |
1179 | align 4 |
1191 | idle_thread: |
1180 | idle_thread: |
1192 | sti |
1181 | sti |
1193 | idle_loop: |
1182 | idle_loop: |
1194 | hlt |
1183 | hlt |
1195 | jmp idle_loop |
1184 | jmp idle_loop |
1196 | 1185 | ||
1197 | 1186 | ||
1198 | 1187 | ||
1199 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1188 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1200 | ; ; |
1189 | ; ; |
1201 | ; INCLUDED SYSTEM FILES ; |
1190 | ; INCLUDED SYSTEM FILES ; |
1202 | ; ; |
1191 | ; ; |
1203 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1192 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1204 | 1193 | ||
1205 | 1194 | ||
1206 | include "kernel32.inc" |
1195 | include "kernel32.inc" |
1207 | 1196 | ||
1208 | 1197 | ||
1209 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1198 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1210 | ; ; |
1199 | ; ; |
1211 | ; KERNEL FUNCTIONS ; |
1200 | ; KERNEL FUNCTIONS ; |
1212 | ; ; |
1201 | ; ; |
1213 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1202 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1214 | 1203 | ||
1215 | reserve_irqs_ports: |
1204 | reserve_irqs_ports: |
1216 | 1205 | ||
1217 | 1206 | ||
1218 | ; RESERVE PORTS |
1207 | ; RESERVE PORTS |
1219 | mov eax, RESERVED_PORTS |
1208 | mov eax, RESERVED_PORTS |
1220 | mov ecx, 1 |
1209 | mov ecx, 1 |
1221 | 1210 | ||
1222 | mov [eax], dword 4 |
1211 | mov [eax], dword 4 |
1223 | 1212 | ||
1224 | mov [eax+16], ecx |
1213 | mov [eax+16], ecx |
1225 | mov [eax+16+4], dword 0 |
1214 | mov [eax+16+4], dword 0 |
1226 | mov [eax+16+8], dword 0x2D |
1215 | mov [eax+16+8], dword 0x2D |
1227 | 1216 | ||
1228 | mov [eax+32], ecx |
1217 | mov [eax+32], ecx |
1229 | mov [eax+32+4], dword 0x30 |
1218 | mov [eax+32+4], dword 0x30 |
1230 | mov [eax+32+8], dword 0x4D |
1219 | mov [eax+32+8], dword 0x4D |
1231 | 1220 | ||
1232 | mov [eax+48], ecx |
1221 | mov [eax+48], ecx |
1233 | mov [eax+48+4], dword 0x50 |
1222 | mov [eax+48+4], dword 0x50 |
1234 | mov [eax+48+8], dword 0xDF |
1223 | mov [eax+48+8], dword 0xDF |
1235 | 1224 | ||
1236 | mov [eax+64], ecx |
1225 | mov [eax+64], ecx |
1237 | mov [eax+64+4], dword 0xE5 |
1226 | mov [eax+64+4], dword 0xE5 |
1238 | mov [eax+64+8], dword 0xFF |
1227 | mov [eax+64+8], dword 0xFF |
1239 | 1228 | ||
1240 | ret |
1229 | ret |
1241 | 1230 | ||
1242 | 1231 | ||
1243 | iglobal |
1232 | iglobal |
1244 | process_number dd 0x2 |
1233 | process_number dd 0x2 |
1245 | endg |
1234 | endg |
1246 | 1235 | ||
1247 | set_variables: |
1236 | set_variables: |
1248 | 1237 | ||
1249 | mov ecx, 0x16 ; flush port 0x60 |
1238 | mov ecx, 0x16 ; flush port 0x60 |
1250 | .fl60: |
1239 | .fl60: |
1251 | in al, 0x60 |
1240 | in al, 0x60 |
1252 | loop .fl60 |
1241 | loop .fl60 |
1253 | push eax |
1242 | push eax |
1254 | 1243 | ||
1255 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1244 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1256 | shr ax, 1 |
1245 | shr ax, 1 |
1257 | shl eax, 16 |
1246 | shl eax, 16 |
1258 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1247 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1259 | shr ax, 1 |
1248 | shr ax, 1 |
1260 | mov [MOUSE_X], eax |
1249 | mov [MOUSE_X], eax |
1261 | call wakeup_osloop |
1250 | call wakeup_osloop |
1262 | 1251 | ||
1263 | xor eax, eax |
1252 | xor eax, eax |
1264 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1253 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1265 | 1254 | ||
1266 | mov byte [KEY_COUNT], al ; keyboard buffer |
1255 | mov byte [KEY_COUNT], al ; keyboard buffer |
1267 | mov byte [BTN_COUNT], al ; button buffer |
1256 | mov byte [BTN_COUNT], al ; button buffer |
1268 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1257 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1269 | 1258 | ||
1270 | pop eax |
1259 | pop eax |
1271 | ret |
1260 | ret |
1272 | 1261 | ||
1273 | align 4 |
1262 | align 4 |
1274 | ;input eax=43,bl-byte of output, ecx - number of port |
1263 | ;input eax=43,bl-byte of output, ecx - number of port |
1275 | sys_outport: |
1264 | sys_outport: |
1276 | 1265 | ||
1277 | mov edi, ecx ; separate flag for read / write |
1266 | mov edi, ecx ; separate flag for read / write |
1278 | and ecx, 65535 |
1267 | and ecx, 65535 |
1279 | 1268 | ||
1280 | mov eax, [RESERVED_PORTS] |
1269 | mov eax, [RESERVED_PORTS] |
1281 | test eax, eax |
1270 | test eax, eax |
1282 | jnz .sopl8 |
1271 | jnz .sopl8 |
1283 | inc eax |
1272 | inc eax |
1284 | mov [esp+32], eax |
1273 | mov [esp+32], eax |
1285 | ret |
1274 | ret |
1286 | 1275 | ||
1287 | .sopl8: |
1276 | .sopl8: |
1288 | mov edx, [TASK_BASE] |
1277 | mov edx, [TASK_BASE] |
1289 | mov edx, [edx+0x4] |
1278 | mov edx, [edx+0x4] |
1290 | ;and ecx,65535 |
1279 | ;and ecx,65535 |
1291 | ;cld - set on interrupt 0x40 |
1280 | ;cld - set on interrupt 0x40 |
1292 | .sopl1: |
1281 | .sopl1: |
1293 | 1282 | ||
1294 | mov esi, eax |
1283 | mov esi, eax |
1295 | shl esi, 4 |
1284 | shl esi, 4 |
1296 | add esi, RESERVED_PORTS |
1285 | add esi, RESERVED_PORTS |
1297 | cmp edx, [esi+0] |
1286 | cmp edx, [esi+0] |
1298 | jne .sopl2 |
1287 | jne .sopl2 |
1299 | cmp ecx, [esi+4] |
1288 | cmp ecx, [esi+4] |
1300 | jb .sopl2 |
1289 | jb .sopl2 |
1301 | cmp ecx, [esi+8] |
1290 | cmp ecx, [esi+8] |
1302 | jg .sopl2 |
1291 | jg .sopl2 |
1303 | .sopl3: |
1292 | .sopl3: |
1304 | 1293 | ||
1305 | test edi, 0x80000000; read ? |
1294 | test edi, 0x80000000; read ? |
1306 | jnz .sopl4 |
1295 | jnz .sopl4 |
1307 | 1296 | ||
1308 | mov eax, ebx |
1297 | mov eax, ebx |
1309 | mov dx, cx ; write |
1298 | mov dx, cx ; write |
1310 | out dx, al |
1299 | out dx, al |
1311 | and [esp+32], dword 0 |
1300 | and [esp+32], dword 0 |
1312 | ret |
1301 | ret |
1313 | 1302 | ||
1314 | .sopl2: |
1303 | .sopl2: |
1315 | 1304 | ||
1316 | dec eax |
1305 | dec eax |
1317 | jnz .sopl1 |
1306 | jnz .sopl1 |
1318 | inc eax |
1307 | inc eax |
1319 | mov [esp+32], eax |
1308 | mov [esp+32], eax |
1320 | ret |
1309 | ret |
1321 | 1310 | ||
1322 | 1311 | ||
1323 | .sopl4: |
1312 | .sopl4: |
1324 | 1313 | ||
1325 | mov dx, cx ; read |
1314 | mov dx, cx ; read |
1326 | in al, dx |
1315 | in al, dx |
1327 | and eax, 0xff |
1316 | and eax, 0xff |
1328 | and [esp+32], dword 0 |
1317 | and [esp+32], dword 0 |
1329 | mov [esp+20], eax |
1318 | mov [esp+20], eax |
1330 | ret |
1319 | ret |
1331 | 1320 | ||
1332 | display_number: |
1321 | display_number: |
1333 | ;It is not optimization |
1322 | ;It is not optimization |
1334 | mov eax, ebx |
1323 | mov eax, ebx |
1335 | mov ebx, ecx |
1324 | mov ebx, ecx |
1336 | mov ecx, edx |
1325 | mov ecx, edx |
1337 | mov edx, esi |
1326 | mov edx, esi |
1338 | mov esi, edi |
1327 | mov esi, edi |
1339 | ; eax = print type, al=0 -> ebx is number |
1328 | ; eax = print type, al=0 -> ebx is number |
1340 | ; al=1 -> ebx is pointer |
1329 | ; al=1 -> ebx is pointer |
1341 | ; ah=0 -> display decimal |
1330 | ; ah=0 -> display decimal |
1342 | ; ah=1 -> display hexadecimal |
1331 | ; ah=1 -> display hexadecimal |
1343 | ; ah=2 -> display binary |
1332 | ; ah=2 -> display binary |
1344 | ; eax bits 16-21 = number of digits to display (0-32) |
1333 | ; eax bits 16-21 = number of digits to display (0-32) |
1345 | ; eax bits 22-31 = reserved |
1334 | ; eax bits 22-31 = reserved |
1346 | ; |
1335 | ; |
1347 | ; ebx = number or pointer |
1336 | ; ebx = number or pointer |
1348 | ; ecx = x shl 16 + y |
1337 | ; ecx = x shl 16 + y |
1349 | ; edx = color |
1338 | ; edx = color |
1350 | xor edi, edi |
1339 | xor edi, edi |
1351 | display_number_force: |
1340 | display_number_force: |
1352 | push eax |
1341 | push eax |
1353 | and eax, 0x3fffffff |
1342 | and eax, 0x3fffffff |
1354 | cmp eax, 0xffff ; length > 0 ? |
1343 | cmp eax, 0xffff ; length > 0 ? |
1355 | pop eax |
1344 | pop eax |
1356 | jge cont_displ |
1345 | jge cont_displ |
1357 | ret |
1346 | ret |
1358 | cont_displ: |
1347 | cont_displ: |
1359 | push eax |
1348 | push eax |
1360 | and eax, 0x3fffffff |
1349 | and eax, 0x3fffffff |
1361 | cmp eax, 61*0x10000 ; length <= 60 ? |
1350 | cmp eax, 61*0x10000 ; length <= 60 ? |
1362 | pop eax |
1351 | pop eax |
1363 | jb cont_displ2 |
1352 | jb cont_displ2 |
1364 | ret |
1353 | ret |
1365 | cont_displ2: |
1354 | cont_displ2: |
1366 | 1355 | ||
1367 | pushad |
1356 | pushad |
1368 | 1357 | ||
1369 | cmp al, 1 ; ecx is a pointer ? |
1358 | cmp al, 1 ; ecx is a pointer ? |
1370 | jne displnl1 |
1359 | jne displnl1 |
1371 | mov ebp, ebx |
1360 | mov ebp, ebx |
1372 | add ebp, 4 |
1361 | add ebp, 4 |
1373 | mov ebp, [ebp+std_application_base_address] |
1362 | mov ebp, [ebp+std_application_base_address] |
1374 | mov ebx, [ebx+std_application_base_address] |
1363 | mov ebx, [ebx+std_application_base_address] |
1375 | displnl1: |
1364 | displnl1: |
1376 | sub esp, 64 |
1365 | sub esp, 64 |
1377 | 1366 | ||
1378 | test ah, ah ; DECIMAL |
1367 | test ah, ah ; DECIMAL |
1379 | jnz no_display_desnum |
1368 | jnz no_display_desnum |
1380 | shr eax, 16 |
1369 | shr eax, 16 |
1381 | and eax, 0xC03f |
1370 | and eax, 0xC03f |
1382 | ; and eax,0x3f |
1371 | ; and eax,0x3f |
1383 | push eax |
1372 | push eax |
1384 | and eax, 0x3f |
1373 | and eax, 0x3f |
1385 | mov edi, esp |
1374 | mov edi, esp |
1386 | add edi, 4+64-1 |
1375 | add edi, 4+64-1 |
1387 | mov ecx, eax |
1376 | mov ecx, eax |
1388 | mov eax, ebx |
1377 | mov eax, ebx |
1389 | mov ebx, 10 |
1378 | mov ebx, 10 |
1390 | d_desnum: |
1379 | d_desnum: |
1391 | xor edx, edx |
1380 | xor edx, edx |
1392 | call division_64_bits |
1381 | call division_64_bits |
1393 | div ebx |
1382 | div ebx |
1394 | add dl, 48 |
1383 | add dl, 48 |
1395 | mov [edi], dl |
1384 | mov [edi], dl |
1396 | dec edi |
1385 | dec edi |
1397 | loop d_desnum |
1386 | loop d_desnum |
1398 | pop eax |
1387 | pop eax |
1399 | call normalize_number |
1388 | call normalize_number |
1400 | call draw_num_text |
1389 | call draw_num_text |
1401 | add esp, 64 |
1390 | add esp, 64 |
1402 | popad |
1391 | popad |
1403 | ret |
1392 | ret |
1404 | no_display_desnum: |
1393 | no_display_desnum: |
1405 | 1394 | ||
1406 | cmp ah, 0x01 ; HEXADECIMAL |
1395 | cmp ah, 0x01 ; HEXADECIMAL |
1407 | jne no_display_hexnum |
1396 | jne no_display_hexnum |
1408 | shr eax, 16 |
1397 | shr eax, 16 |
1409 | and eax, 0xC03f |
1398 | and eax, 0xC03f |
1410 | ; and eax,0x3f |
1399 | ; and eax,0x3f |
1411 | push eax |
1400 | push eax |
1412 | and eax, 0x3f |
1401 | and eax, 0x3f |
1413 | mov edi, esp |
1402 | mov edi, esp |
1414 | add edi, 4+64-1 |
1403 | add edi, 4+64-1 |
1415 | mov ecx, eax |
1404 | mov ecx, eax |
1416 | mov eax, ebx |
1405 | mov eax, ebx |
1417 | mov ebx, 16 |
1406 | mov ebx, 16 |
1418 | d_hexnum: |
1407 | d_hexnum: |
1419 | xor edx, edx |
1408 | xor edx, edx |
1420 | call division_64_bits |
1409 | call division_64_bits |
1421 | div ebx |
1410 | div ebx |
1422 | hexletters = __fdo_hexdigits |
1411 | hexletters = __fdo_hexdigits |
1423 | add edx, hexletters |
1412 | add edx, hexletters |
1424 | mov dl, [edx] |
1413 | mov dl, [edx] |
1425 | mov [edi], dl |
1414 | mov [edi], dl |
1426 | dec edi |
1415 | dec edi |
1427 | loop d_hexnum |
1416 | loop d_hexnum |
1428 | pop eax |
1417 | pop eax |
1429 | call normalize_number |
1418 | call normalize_number |
1430 | call draw_num_text |
1419 | call draw_num_text |
1431 | add esp, 64 |
1420 | add esp, 64 |
1432 | popad |
1421 | popad |
1433 | ret |
1422 | ret |
1434 | no_display_hexnum: |
1423 | no_display_hexnum: |
1435 | 1424 | ||
1436 | cmp ah, 0x02 ; BINARY |
1425 | cmp ah, 0x02 ; BINARY |
1437 | jne no_display_binnum |
1426 | jne no_display_binnum |
1438 | shr eax, 16 |
1427 | shr eax, 16 |
1439 | and eax, 0xC03f |
1428 | and eax, 0xC03f |
1440 | ; and eax,0x3f |
1429 | ; and eax,0x3f |
1441 | push eax |
1430 | push eax |
1442 | and eax, 0x3f |
1431 | and eax, 0x3f |
1443 | mov edi, esp |
1432 | mov edi, esp |
1444 | add edi, 4+64-1 |
1433 | add edi, 4+64-1 |
1445 | mov ecx, eax |
1434 | mov ecx, eax |
1446 | mov eax, ebx |
1435 | mov eax, ebx |
1447 | mov ebx, 2 |
1436 | mov ebx, 2 |
1448 | d_binnum: |
1437 | d_binnum: |
1449 | xor edx, edx |
1438 | xor edx, edx |
1450 | call division_64_bits |
1439 | call division_64_bits |
1451 | div ebx |
1440 | div ebx |
1452 | add dl, 48 |
1441 | add dl, 48 |
1453 | mov [edi], dl |
1442 | mov [edi], dl |
1454 | dec edi |
1443 | dec edi |
1455 | loop d_binnum |
1444 | loop d_binnum |
1456 | pop eax |
1445 | pop eax |
1457 | call normalize_number |
1446 | call normalize_number |
1458 | call draw_num_text |
1447 | call draw_num_text |
1459 | add esp, 64 |
1448 | add esp, 64 |
1460 | popad |
1449 | popad |
1461 | ret |
1450 | ret |
1462 | no_display_binnum: |
1451 | no_display_binnum: |
1463 | 1452 | ||
1464 | add esp, 64 |
1453 | add esp, 64 |
1465 | popad |
1454 | popad |
1466 | ret |
1455 | ret |
1467 | 1456 | ||
1468 | normalize_number: |
1457 | normalize_number: |
1469 | test ah, 0x80 |
1458 | test ah, 0x80 |
1470 | jz .continue |
1459 | jz .continue |
1471 | mov ecx, 48 |
1460 | mov ecx, 48 |
1472 | and eax, 0x3f |
1461 | and eax, 0x3f |
1473 | @@: |
1462 | @@: |
1474 | inc edi |
1463 | inc edi |
1475 | cmp [edi], cl |
1464 | cmp [edi], cl |
1476 | jne .continue |
1465 | jne .continue |
1477 | dec eax |
1466 | dec eax |
1478 | cmp eax, 1 |
1467 | cmp eax, 1 |
1479 | ja @r |
1468 | ja @r |
1480 | mov al, 1 |
1469 | mov al, 1 |
1481 | .continue: |
1470 | .continue: |
1482 | and eax, 0x3f |
1471 | and eax, 0x3f |
1483 | ret |
1472 | ret |
1484 | 1473 | ||
1485 | division_64_bits: |
1474 | division_64_bits: |
1486 | test [esp+1+4], byte 0x40 |
1475 | test [esp+1+4], byte 0x40 |
1487 | jz .continue |
1476 | jz .continue |
1488 | push eax |
1477 | push eax |
1489 | mov eax, ebp |
1478 | mov eax, ebp |
1490 | div ebx |
1479 | div ebx |
1491 | mov ebp, eax |
1480 | mov ebp, eax |
1492 | pop eax |
1481 | pop eax |
1493 | .continue: |
1482 | .continue: |
1494 | ret |
1483 | ret |
1495 | 1484 | ||
1496 | draw_num_text: |
1485 | draw_num_text: |
1497 | mov esi, eax |
1486 | mov esi, eax |
1498 | mov edx, 64+4 |
1487 | mov edx, 64+4 |
1499 | sub edx, eax |
1488 | sub edx, eax |
1500 | add edx, esp |
1489 | add edx, esp |
1501 | mov ebx, [esp+64+32-8+4] |
1490 | mov ebx, [esp+64+32-8+4] |
1502 | ; add window start x & y |
1491 | ; add window start x & y |
1503 | mov ecx, [TASK_BASE] |
1492 | mov ecx, [TASK_BASE] |
1504 | 1493 | ||
1505 | mov edi, [CURRENT_TASK] |
1494 | mov edi, [CURRENT_TASK] |
1506 | shl edi, 8 |
1495 | shl edi, 8 |
1507 | 1496 | ||
1508 | mov eax, [ecx-twdw+WDATA.box.left] |
1497 | mov eax, [ecx-twdw+WDATA.box.left] |
1509 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1498 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1510 | shl eax, 16 |
1499 | shl eax, 16 |
1511 | add eax, [ecx-twdw+WDATA.box.top] |
1500 | add eax, [ecx-twdw+WDATA.box.top] |
1512 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1501 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1513 | add ebx, eax |
1502 | add ebx, eax |
1514 | mov ecx, [esp+64+32-12+4] |
1503 | mov ecx, [esp+64+32-12+4] |
1515 | and ecx, not 0x80000000 ; force counted string |
1504 | and ecx, not 0x80000000 ; force counted string |
1516 | mov eax, [esp+64+8] ; background color (if given) |
1505 | mov eax, [esp+64+8] ; background color (if given) |
1517 | mov edi, [esp+64+4] |
1506 | mov edi, [esp+64+4] |
1518 | jmp dtext |
1507 | jmp dtext |
1519 | ;----------------------------------------------------------------------------- |
1508 | ;----------------------------------------------------------------------------- |
1520 | iglobal |
1509 | iglobal |
1521 | midi_base dw 0 |
1510 | midi_base dw 0 |
1522 | endg |
1511 | endg |
1523 | ;----------------------------------------------------------------------------- |
1512 | ;----------------------------------------------------------------------------- |
1524 | align 4 |
1513 | align 4 |
1525 | sys_setup: |
1514 | sys_setup: |
1526 | ; 1 = roland mpu midi base , base io address |
1515 | ; 1 = roland mpu midi base , base io address |
1527 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1516 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1528 | ; 3 = not used |
1517 | ; 3 = not used |
1529 | ; 4 = not used |
1518 | ; 4 = not used |
1530 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1519 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1531 | ; 6 = not used |
1520 | ; 6 = not used |
1532 | ; 7 = not used |
1521 | ; 7 = not used |
1533 | ; 8 = not used |
1522 | ; 8 = not used |
1534 | ; 9 = not used |
1523 | ; 9 = not used |
1535 | ; 10 = not used |
1524 | ; 10 = not used |
1536 | ; 11 = enable lba read |
1525 | ; 11 = enable lba read |
1537 | ; 12 = enable pci access |
1526 | ; 12 = enable pci access |
1538 | ;----------------------------------------------------------------------------- |
1527 | ;----------------------------------------------------------------------------- |
1539 | and [esp+32], dword 0 |
1528 | and [esp+32], dword 0 |
1540 | ; F.21.1 - set MPU MIDI base port |
1529 | ; F.21.1 - set MPU MIDI base port |
1541 | dec ebx |
1530 | dec ebx |
1542 | jnz @f |
1531 | jnz @f |
1543 | 1532 | ||
1544 | cmp ecx, 0x100 |
1533 | cmp ecx, 0x100 |
1545 | jb @f |
1534 | jb @f |
1546 | 1535 | ||
1547 | mov esi, 65535 |
1536 | mov esi, 65535 |
1548 | cmp esi, ecx |
1537 | cmp esi, ecx |
1549 | jb @f |
1538 | jb @f |
1550 | 1539 | ||
1551 | mov [midi_base], cx |
1540 | mov [midi_base], cx |
1552 | mov word [mididp], cx |
1541 | mov word [mididp], cx |
1553 | inc cx |
1542 | inc cx |
1554 | mov word [midisp], cx |
1543 | mov word [midisp], cx |
1555 | ret |
1544 | ret |
1556 | ;-------------------------------------- |
1545 | ;-------------------------------------- |
1557 | @@: |
1546 | @@: |
1558 | ; F.21.2 - set keyboard layout |
1547 | ; F.21.2 - set keyboard layout |
1559 | dec ebx |
1548 | dec ebx |
1560 | jnz @f |
1549 | jnz @f |
1561 | 1550 | ||
1562 | mov edi, [TASK_BASE] |
1551 | mov edi, [TASK_BASE] |
1563 | mov eax, [edi+TASKDATA.mem_start] |
1552 | mov eax, [edi+TASKDATA.mem_start] |
1564 | add eax, edx |
1553 | add eax, edx |
1565 | ; 1 = normal layout |
1554 | ; 1 = normal layout |
1566 | dec ecx |
1555 | dec ecx |
1567 | jnz .shift |
1556 | jnz .shift |
1568 | 1557 | ||
1569 | mov ebx, keymap |
1558 | mov ebx, keymap |
1570 | mov ecx, 128 |
1559 | mov ecx, 128 |
1571 | call memmove |
1560 | call memmove |
1572 | ret |
1561 | ret |
1573 | ;-------------------------------------- |
1562 | ;-------------------------------------- |
1574 | .shift: |
1563 | .shift: |
1575 | ; 2 = layout at pressed Shift |
1564 | ; 2 = layout at pressed Shift |
1576 | dec ecx |
1565 | dec ecx |
1577 | jnz .alt |
1566 | jnz .alt |
1578 | 1567 | ||
1579 | mov ebx, keymap_shift |
1568 | mov ebx, keymap_shift |
1580 | mov ecx, 128 |
1569 | mov ecx, 128 |
1581 | call memmove |
1570 | call memmove |
1582 | ret |
1571 | ret |
1583 | ;-------------------------------------- |
1572 | ;-------------------------------------- |
1584 | .alt: |
1573 | .alt: |
1585 | ; 3 = layout at pressed Alt |
1574 | ; 3 = layout at pressed Alt |
1586 | dec ecx |
1575 | dec ecx |
1587 | jnz .country |
1576 | jnz .country |
1588 | 1577 | ||
1589 | mov ebx, keymap_alt |
1578 | mov ebx, keymap_alt |
1590 | mov ecx, 128 |
1579 | mov ecx, 128 |
1591 | call memmove |
1580 | call memmove |
1592 | ret |
1581 | ret |
1593 | ;-------------------------------------- |
1582 | ;-------------------------------------- |
1594 | .country: |
1583 | .country: |
1595 | ; country identifier |
1584 | ; country identifier |
1596 | sub ecx, 6 |
1585 | sub ecx, 6 |
1597 | jnz .error |
1586 | jnz .error |
1598 | 1587 | ||
1599 | mov word [keyboard], dx |
1588 | mov word [keyboard], dx |
1600 | ret |
1589 | ret |
1601 | ;-------------------------------------- |
1590 | ;-------------------------------------- |
1602 | @@: |
1591 | @@: |
1603 | ; F.21.5 - set system language |
1592 | ; F.21.5 - set system language |
1604 | sub ebx, 3 |
1593 | sub ebx, 3 |
1605 | jnz @f |
1594 | jnz @f |
1606 | 1595 | ||
1607 | mov [syslang], ecx |
1596 | mov [syslang], ecx |
1608 | ret |
1597 | ret |
1609 | ;-------------------------------------- |
1598 | ;-------------------------------------- |
1610 | @@: |
1599 | @@: |
1611 | ; F.21.11 - enable/disable low-level access to HD |
1600 | ; F.21.11 - enable/disable low-level access to HD |
1612 | and ecx, 1 |
1601 | and ecx, 1 |
1613 | sub ebx, 6 |
1602 | sub ebx, 6 |
1614 | jnz @f |
1603 | jnz @f |
1615 | 1604 | ||
1616 | mov [lba_read_enabled], ecx |
1605 | mov [lba_read_enabled], ecx |
1617 | ret |
1606 | ret |
1618 | ;-------------------------------------- |
1607 | ;-------------------------------------- |
1619 | @@: |
1608 | @@: |
1620 | ; F.21.12 - enable/disable low-level access to PCI |
1609 | ; F.21.12 - enable/disable low-level access to PCI |
1621 | dec ebx |
1610 | dec ebx |
1622 | jnz .error |
1611 | jnz .error |
1623 | 1612 | ||
1624 | mov [pci_access_enabled], ecx |
1613 | mov [pci_access_enabled], ecx |
1625 | ret |
1614 | ret |
1626 | ;-------------------------------------- |
1615 | ;-------------------------------------- |
1627 | .error: |
1616 | .error: |
1628 | or [esp+32], dword -1 |
1617 | or [esp+32], dword -1 |
1629 | ret |
1618 | ret |
1630 | ;----------------------------------------------------------------------------- |
1619 | ;----------------------------------------------------------------------------- |
1631 | align 4 |
1620 | align 4 |
1632 | sys_getsetup: |
1621 | sys_getsetup: |
1633 | ; 1 = roland mpu midi base , base io address |
1622 | ; 1 = roland mpu midi base , base io address |
1634 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1623 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1635 | ; 3 = not used |
1624 | ; 3 = not used |
1636 | ; 4 = not used |
1625 | ; 4 = not used |
1637 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1626 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1638 | ; 6 = not used |
1627 | ; 6 = not used |
1639 | ; 7 = not used |
1628 | ; 7 = not used |
1640 | ; 8 = not used |
1629 | ; 8 = not used |
1641 | ; 9 = get hs timer tic |
1630 | ; 9 = get hs timer tic |
1642 | ; 10 = not used |
1631 | ; 10 = not used |
1643 | ; 11 = get the state "lba read" |
1632 | ; 11 = get the state "lba read" |
1644 | ; 12 = get the state "pci access" |
1633 | ; 12 = get the state "pci access" |
1645 | ;----------------------------------------------------------------------------- |
1634 | ;----------------------------------------------------------------------------- |
1646 | ; F.26.1 - get MPU MIDI base port |
1635 | ; F.26.1 - get MPU MIDI base port |
1647 | dec ebx |
1636 | dec ebx |
1648 | jnz @f |
1637 | jnz @f |
1649 | 1638 | ||
1650 | movzx eax, [midi_base] |
1639 | movzx eax, [midi_base] |
1651 | mov [esp+32], eax |
1640 | mov [esp+32], eax |
1652 | ret |
1641 | ret |
1653 | ;-------------------------------------- |
1642 | ;-------------------------------------- |
1654 | @@: |
1643 | @@: |
1655 | ; F.26.2 - get keyboard layout |
1644 | ; F.26.2 - get keyboard layout |
1656 | dec ebx |
1645 | dec ebx |
1657 | jnz @f |
1646 | jnz @f |
1658 | 1647 | ||
1659 | mov edi, [TASK_BASE] |
1648 | mov edi, [TASK_BASE] |
1660 | mov ebx, [edi+TASKDATA.mem_start] |
1649 | mov ebx, [edi+TASKDATA.mem_start] |
1661 | add ebx, edx |
1650 | add ebx, edx |
1662 | ; 1 = normal layout |
1651 | ; 1 = normal layout |
1663 | dec ecx |
1652 | dec ecx |
1664 | jnz .shift |
1653 | jnz .shift |
1665 | 1654 | ||
1666 | mov eax, keymap |
1655 | mov eax, keymap |
1667 | mov ecx, 128 |
1656 | mov ecx, 128 |
1668 | call memmove |
1657 | call memmove |
1669 | ret |
1658 | ret |
1670 | ;-------------------------------------- |
1659 | ;-------------------------------------- |
1671 | .shift: |
1660 | .shift: |
1672 | ; 2 = layout with pressed Shift |
1661 | ; 2 = layout with pressed Shift |
1673 | dec ecx |
1662 | dec ecx |
1674 | jnz .alt |
1663 | jnz .alt |
1675 | 1664 | ||
1676 | mov eax, keymap_shift |
1665 | mov eax, keymap_shift |
1677 | mov ecx, 128 |
1666 | mov ecx, 128 |
1678 | call memmove |
1667 | call memmove |
1679 | ret |
1668 | ret |
1680 | ;-------------------------------------- |
1669 | ;-------------------------------------- |
1681 | .alt: |
1670 | .alt: |
1682 | ; 3 = layout with pressed Alt |
1671 | ; 3 = layout with pressed Alt |
1683 | dec ecx |
1672 | dec ecx |
1684 | jne .country |
1673 | jne .country |
1685 | 1674 | ||
1686 | mov eax, keymap_alt |
1675 | mov eax, keymap_alt |
1687 | mov ecx, 128 |
1676 | mov ecx, 128 |
1688 | call memmove |
1677 | call memmove |
1689 | ret |
1678 | ret |
1690 | ;-------------------------------------- |
1679 | ;-------------------------------------- |
1691 | .country: |
1680 | .country: |
1692 | ; 9 = country identifier |
1681 | ; 9 = country identifier |
1693 | sub ecx, 6 |
1682 | sub ecx, 6 |
1694 | jnz .error |
1683 | jnz .error |
1695 | 1684 | ||
1696 | movzx eax, word [keyboard] |
1685 | movzx eax, word [keyboard] |
1697 | mov [esp+32], eax |
1686 | mov [esp+32], eax |
1698 | ret |
1687 | ret |
1699 | ;-------------------------------------- |
1688 | ;-------------------------------------- |
1700 | @@: |
1689 | @@: |
1701 | ; F.26.5 - get system language |
1690 | ; F.26.5 - get system language |
1702 | sub ebx, 3 |
1691 | sub ebx, 3 |
1703 | jnz @f |
1692 | jnz @f |
1704 | 1693 | ||
1705 | mov eax, [syslang] |
1694 | mov eax, [syslang] |
1706 | mov [esp+32], eax |
1695 | mov [esp+32], eax |
1707 | ret |
1696 | ret |
1708 | ;-------------------------------------- |
1697 | ;-------------------------------------- |
1709 | @@: |
1698 | @@: |
1710 | ; F.26.9 - get the value of the time counter |
1699 | ; F.26.9 - get the value of the time counter |
1711 | sub ebx, 4 |
1700 | sub ebx, 4 |
1712 | jnz @f |
1701 | jnz @f |
1713 | 1702 | ||
1714 | mov eax, [timer_ticks] |
1703 | mov eax, [timer_ticks] |
1715 | mov [esp+32], eax |
1704 | mov [esp+32], eax |
1716 | ret |
1705 | ret |
1717 | ;-------------------------------------- |
1706 | ;-------------------------------------- |
1718 | @@: |
1707 | @@: |
1719 | ; F.26.11 - Find out whether low-level HD access is enabled |
1708 | ; F.26.11 - Find out whether low-level HD access is enabled |
1720 | sub ebx, 2 |
1709 | sub ebx, 2 |
1721 | jnz @f |
1710 | jnz @f |
1722 | 1711 | ||
1723 | mov eax, [lba_read_enabled] |
1712 | mov eax, [lba_read_enabled] |
1724 | mov [esp+32], eax |
1713 | mov [esp+32], eax |
1725 | ret |
1714 | ret |
1726 | ;-------------------------------------- |
1715 | ;-------------------------------------- |
1727 | @@: |
1716 | @@: |
1728 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1717 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1729 | dec ebx |
1718 | dec ebx |
1730 | jnz .error |
1719 | jnz .error |
1731 | 1720 | ||
1732 | mov eax, [pci_access_enabled] |
1721 | mov eax, [pci_access_enabled] |
1733 | mov [esp+32], eax |
1722 | mov [esp+32], eax |
1734 | ret |
1723 | ret |
1735 | ;-------------------------------------- |
1724 | ;-------------------------------------- |
1736 | .error: |
1725 | .error: |
1737 | or [esp+32], dword -1 |
1726 | or [esp+32], dword -1 |
1738 | ret |
1727 | ret |
1739 | ;----------------------------------------------------------------------------- |
1728 | ;----------------------------------------------------------------------------- |
1740 | get_timer_ticks: |
1729 | get_timer_ticks: |
1741 | mov eax, [timer_ticks] |
1730 | mov eax, [timer_ticks] |
1742 | ret |
1731 | ret |
1743 | ;----------------------------------------------------------------------------- |
1732 | ;----------------------------------------------------------------------------- |
1744 | iglobal |
1733 | iglobal |
1745 | align 4 |
1734 | align 4 |
1746 | mousefn dd msscreen, mswin, msbutton, msset |
1735 | mousefn dd msscreen, mswin, msbutton, msset |
1747 | dd app_load_cursor |
1736 | dd app_load_cursor |
1748 | dd app_set_cursor |
1737 | dd app_set_cursor |
1749 | dd app_delete_cursor |
1738 | dd app_delete_cursor |
1750 | dd msz |
1739 | dd msz |
1751 | endg |
1740 | endg |
1752 | ;----------------------------------------------------------------------------- |
1741 | ;----------------------------------------------------------------------------- |
1753 | readmousepos: |
1742 | readmousepos: |
1754 | 1743 | ||
1755 | ; eax=0 screen relative |
1744 | ; eax=0 screen relative |
1756 | ; eax=1 window relative |
1745 | ; eax=1 window relative |
1757 | ; eax=2 buttons pressed |
1746 | ; eax=2 buttons pressed |
1758 | ; eax=3 set mouse pos ; reserved |
1747 | ; eax=3 set mouse pos ; reserved |
1759 | ; eax=4 load cursor |
1748 | ; eax=4 load cursor |
1760 | ; eax=5 set cursor |
1749 | ; eax=5 set cursor |
1761 | ; eax=6 delete cursor ; reserved |
1750 | ; eax=6 delete cursor ; reserved |
1762 | ; eax=7 get mouse_z |
1751 | ; eax=7 get mouse_z |
1763 | 1752 | ||
1764 | cmp ebx, 7 |
1753 | cmp ebx, 7 |
1765 | ja msset |
1754 | ja msset |
1766 | jmp [mousefn+ebx*4] |
1755 | jmp [mousefn+ebx*4] |
1767 | msscreen: |
1756 | msscreen: |
1768 | mov eax, [MOUSE_X] |
1757 | mov eax, [MOUSE_X] |
1769 | shl eax, 16 |
1758 | shl eax, 16 |
1770 | mov ax, [MOUSE_Y] |
1759 | mov ax, [MOUSE_Y] |
1771 | mov [esp+36-4], eax |
1760 | mov [esp+36-4], eax |
1772 | ret |
1761 | ret |
1773 | mswin: |
1762 | mswin: |
1774 | mov eax, [MOUSE_X] |
1763 | mov eax, [MOUSE_X] |
1775 | shl eax, 16 |
1764 | shl eax, 16 |
1776 | mov ax, [MOUSE_Y] |
1765 | mov ax, [MOUSE_Y] |
1777 | mov esi, [TASK_BASE] |
1766 | mov esi, [TASK_BASE] |
1778 | mov bx, word [esi-twdw+WDATA.box.left] |
1767 | mov bx, word [esi-twdw+WDATA.box.left] |
1779 | shl ebx, 16 |
1768 | shl ebx, 16 |
1780 | mov bx, word [esi-twdw+WDATA.box.top] |
1769 | mov bx, word [esi-twdw+WDATA.box.top] |
1781 | sub eax, ebx |
1770 | sub eax, ebx |
1782 | 1771 | ||
1783 | mov edi, [CURRENT_TASK] |
1772 | mov edi, [CURRENT_TASK] |
1784 | shl edi, 8 |
1773 | shl edi, 8 |
1785 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1774 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1786 | rol eax, 16 |
1775 | rol eax, 16 |
1787 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1776 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1788 | rol eax, 16 |
1777 | rol eax, 16 |
1789 | mov [esp+36-4], eax |
1778 | mov [esp+36-4], eax |
1790 | ret |
1779 | ret |
1791 | msbutton: |
1780 | msbutton: |
1792 | movzx eax, byte [BTN_DOWN] |
1781 | movzx eax, byte [BTN_DOWN] |
1793 | mov [esp+36-4], eax |
1782 | mov [esp+36-4], eax |
1794 | ret |
1783 | ret |
1795 | msz: |
1784 | msz: |
1796 | mov edi, [TASK_COUNT] |
1785 | mov edi, [TASK_COUNT] |
1797 | movzx edi, word [WIN_POS + edi*2] |
1786 | movzx edi, word [WIN_POS + edi*2] |
1798 | cmp edi, [CURRENT_TASK] |
1787 | cmp edi, [CURRENT_TASK] |
1799 | jne @f |
1788 | jne @f |
1800 | mov ax, [MOUSE_SCROLL_H] |
1789 | mov ax, [MOUSE_SCROLL_H] |
1801 | shl eax, 16 |
1790 | shl eax, 16 |
1802 | mov ax, [MOUSE_SCROLL_V] |
1791 | mov ax, [MOUSE_SCROLL_V] |
1803 | mov [esp+36-4], eax |
1792 | mov [esp+36-4], eax |
1804 | and [MOUSE_SCROLL_H], word 0 |
1793 | and [MOUSE_SCROLL_H], word 0 |
1805 | and [MOUSE_SCROLL_V], word 0 |
1794 | and [MOUSE_SCROLL_V], word 0 |
1806 | ret |
1795 | ret |
1807 | @@: |
1796 | @@: |
1808 | and [esp+36-4], dword 0 |
1797 | and [esp+36-4], dword 0 |
1809 | ; ret |
1798 | ; ret |
1810 | msset: |
1799 | msset: |
1811 | ret |
1800 | ret |
1812 | 1801 | ||
1813 | app_load_cursor: |
1802 | app_load_cursor: |
1814 | cmp ecx, OS_BASE |
1803 | cmp ecx, OS_BASE |
1815 | jae msset |
1804 | jae msset |
1816 | stdcall load_cursor, ecx, edx |
1805 | stdcall load_cursor, ecx, edx |
1817 | mov [esp+36-4], eax |
1806 | mov [esp+36-4], eax |
1818 | ret |
1807 | ret |
1819 | 1808 | ||
1820 | app_set_cursor: |
1809 | app_set_cursor: |
1821 | stdcall set_cursor, ecx |
1810 | stdcall set_cursor, ecx |
1822 | mov [esp+36-4], eax |
1811 | mov [esp+36-4], eax |
1823 | ret |
1812 | ret |
1824 | 1813 | ||
1825 | app_delete_cursor: |
1814 | app_delete_cursor: |
1826 | stdcall delete_cursor, ecx |
1815 | stdcall delete_cursor, ecx |
1827 | mov [esp+36-4], eax |
1816 | mov [esp+36-4], eax |
1828 | ret |
1817 | ret |
1829 | 1818 | ||
1830 | is_input: |
1819 | is_input: |
1831 | 1820 | ||
1832 | push edx |
1821 | push edx |
1833 | mov dx, word [midisp] |
1822 | mov dx, word [midisp] |
1834 | in al, dx |
1823 | in al, dx |
1835 | and al, 0x80 |
1824 | and al, 0x80 |
1836 | pop edx |
1825 | pop edx |
1837 | ret |
1826 | ret |
1838 | 1827 | ||
1839 | is_output: |
1828 | is_output: |
1840 | 1829 | ||
1841 | push edx |
1830 | push edx |
1842 | mov dx, word [midisp] |
1831 | mov dx, word [midisp] |
1843 | in al, dx |
1832 | in al, dx |
1844 | and al, 0x40 |
1833 | and al, 0x40 |
1845 | pop edx |
1834 | pop edx |
1846 | ret |
1835 | ret |
1847 | 1836 | ||
1848 | 1837 | ||
1849 | get_mpu_in: |
1838 | get_mpu_in: |
1850 | 1839 | ||
1851 | push edx |
1840 | push edx |
1852 | mov dx, word [mididp] |
1841 | mov dx, word [mididp] |
1853 | in al, dx |
1842 | in al, dx |
1854 | pop edx |
1843 | pop edx |
1855 | ret |
1844 | ret |
1856 | 1845 | ||
1857 | 1846 | ||
1858 | put_mpu_out: |
1847 | put_mpu_out: |
1859 | 1848 | ||
1860 | push edx |
1849 | push edx |
1861 | mov dx, word [mididp] |
1850 | mov dx, word [mididp] |
1862 | out dx, al |
1851 | out dx, al |
1863 | pop edx |
1852 | pop edx |
1864 | ret |
1853 | ret |
1865 | 1854 | ||
1866 | 1855 | ||
1867 | 1856 | ||
1868 | align 4 |
1857 | align 4 |
1869 | 1858 | ||
1870 | sys_midi: |
1859 | sys_midi: |
1871 | cmp [mididp], 0 |
1860 | cmp [mididp], 0 |
1872 | jnz sm0 |
1861 | jnz sm0 |
1873 | mov [esp+36], dword 1 |
1862 | mov [esp+36], dword 1 |
1874 | ret |
1863 | ret |
1875 | sm0: |
1864 | sm0: |
1876 | and [esp+36], dword 0 |
1865 | and [esp+36], dword 0 |
1877 | dec ebx |
1866 | dec ebx |
1878 | jnz smn1 |
1867 | jnz smn1 |
1879 | ; call setuart |
1868 | ; call setuart |
1880 | su1: |
1869 | su1: |
1881 | call is_output |
1870 | call is_output |
1882 | test al, al |
1871 | test al, al |
1883 | jnz su1 |
1872 | jnz su1 |
1884 | mov dx, word [midisp] |
1873 | mov dx, word [midisp] |
1885 | mov al, 0xff |
1874 | mov al, 0xff |
1886 | out dx, al |
1875 | out dx, al |
1887 | su2: |
1876 | su2: |
1888 | mov dx, word [midisp] |
1877 | mov dx, word [midisp] |
1889 | mov al, 0xff |
1878 | mov al, 0xff |
1890 | out dx, al |
1879 | out dx, al |
1891 | call is_input |
1880 | call is_input |
1892 | test al, al |
1881 | test al, al |
1893 | jnz su2 |
1882 | jnz su2 |
1894 | call get_mpu_in |
1883 | call get_mpu_in |
1895 | cmp al, 0xfe |
1884 | cmp al, 0xfe |
1896 | jnz su2 |
1885 | jnz su2 |
1897 | su3: |
1886 | su3: |
1898 | call is_output |
1887 | call is_output |
1899 | test al, al |
1888 | test al, al |
1900 | jnz su3 |
1889 | jnz su3 |
1901 | mov dx, word [midisp] |
1890 | mov dx, word [midisp] |
1902 | mov al, 0x3f |
1891 | mov al, 0x3f |
1903 | out dx, al |
1892 | out dx, al |
1904 | ret |
1893 | ret |
1905 | smn1: |
1894 | smn1: |
1906 | dec ebx |
1895 | dec ebx |
1907 | jnz smn2 |
1896 | jnz smn2 |
1908 | sm10: |
1897 | sm10: |
1909 | call get_mpu_in |
1898 | call get_mpu_in |
1910 | call is_output |
1899 | call is_output |
1911 | test al, al |
1900 | test al, al |
1912 | jnz sm10 |
1901 | jnz sm10 |
1913 | mov al, bl |
1902 | mov al, bl |
1914 | call put_mpu_out |
1903 | call put_mpu_out |
1915 | smn2: |
1904 | smn2: |
1916 | ret |
1905 | ret |
1917 | 1906 | ||
1918 | detect_devices: |
1907 | detect_devices: |
1919 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1908 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1920 | ;include 'detect/commouse.inc' |
1909 | ;include 'detect/commouse.inc' |
1921 | ;include 'detect/ps2mouse.inc' |
1910 | ;include 'detect/ps2mouse.inc' |
1922 | ;include 'detect/dev_fd.inc' |
1911 | ;include 'detect/dev_fd.inc' |
1923 | ;include 'detect/dev_hdcd.inc' |
1912 | ;include 'detect/dev_hdcd.inc' |
1924 | ;include 'detect/sear_par.inc' |
1913 | ;include 'detect/sear_par.inc' |
1925 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1914 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1926 | ret |
1915 | ret |
1927 | 1916 | ||
1928 | sys_end: |
1917 | sys_end: |
1929 | ;-------------------------------------- |
1918 | ;-------------------------------------- |
1930 | cmp [_display.select_cursor], 0 |
1919 | cmp [_display.select_cursor], 0 |
1931 | je @f |
1920 | je @f |
1932 | ; restore default cursor before killing |
1921 | ; restore default cursor before killing |
1933 | pusha |
1922 | pusha |
1934 | mov ecx, [current_slot] |
1923 | mov ecx, [current_slot] |
1935 | call restore_default_cursor_before_killing |
1924 | call restore_default_cursor_before_killing |
1936 | popa |
1925 | popa |
1937 | @@: |
1926 | @@: |
1938 | ;-------------------------------------- |
1927 | ;-------------------------------------- |
1939 | ; kill all sockets this process owns |
1928 | ; kill all sockets this process owns |
1940 | pusha |
1929 | pusha |
1941 | mov edx, [TASK_BASE] |
1930 | mov edx, [TASK_BASE] |
1942 | mov edx, [edx+TASKDATA.pid] |
1931 | mov edx, [edx+TASKDATA.pid] |
1943 | call SOCKET_process_end |
1932 | call SOCKET_process_end |
1944 | popa |
1933 | popa |
1945 | ;-------------------------------------- |
1934 | ;-------------------------------------- |
1946 | mov ecx, [current_slot] |
1935 | mov ecx, [current_slot] |
1947 | mov eax, [ecx+APPDATA.tls_base] |
1936 | mov eax, [ecx+APPDATA.tls_base] |
1948 | test eax, eax |
1937 | test eax, eax |
1949 | jz @F |
1938 | jz @F |
1950 | 1939 | ||
1951 | stdcall user_free, eax |
1940 | stdcall user_free, eax |
1952 | @@: |
1941 | @@: |
1953 | 1942 | ||
1954 | mov eax, [TASK_BASE] |
1943 | mov eax, [TASK_BASE] |
1955 | mov [eax+TASKDATA.state], 3; terminate this program |
1944 | mov [eax+TASKDATA.state], 3; terminate this program |
1956 | call wakeup_osloop |
1945 | call wakeup_osloop |
1957 | 1946 | ||
1958 | .waitterm: ; wait here for termination |
1947 | .waitterm: ; wait here for termination |
1959 | call change_task |
1948 | call change_task |
1960 | jmp .waitterm |
1949 | jmp .waitterm |
1961 | ;------------------------------------------------------------------------------ |
1950 | ;------------------------------------------------------------------------------ |
1962 | align 4 |
1951 | align 4 |
1963 | restore_default_cursor_before_killing: |
1952 | restore_default_cursor_before_killing: |
1964 | pushfd |
1953 | pushfd |
1965 | cli |
1954 | cli |
1966 | mov eax, [def_cursor] |
1955 | mov eax, [def_cursor] |
1967 | mov [ecx+APPDATA.cursor], eax |
1956 | mov [ecx+APPDATA.cursor], eax |
1968 | 1957 | ||
1969 | movzx eax, word [MOUSE_Y] |
1958 | movzx eax, word [MOUSE_Y] |
1970 | movzx ebx, word [MOUSE_X] |
1959 | movzx ebx, word [MOUSE_X] |
1971 | ; mov ecx, [Screen_Max_X] |
1960 | ; mov ecx, [Screen_Max_X] |
1972 | ; inc ecx |
1961 | ; inc ecx |
1973 | ; mul ecx |
1962 | ; mul ecx |
1974 | mov eax, [d_width_calc_area + eax*4] |
1963 | mov eax, [d_width_calc_area + eax*4] |
1975 | 1964 | ||
1976 | add eax, [_WinMapAddress] |
1965 | add eax, [_WinMapAddress] |
1977 | movzx edx, byte [ebx+eax] |
1966 | movzx edx, byte [ebx+eax] |
1978 | shl edx, 8 |
1967 | shl edx, 8 |
1979 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
1968 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
1980 | 1969 | ||
1981 | cmp esi, [current_cursor] |
1970 | cmp esi, [current_cursor] |
1982 | je @f |
1971 | je @f |
1983 | 1972 | ||
1984 | push esi |
1973 | push esi |
1985 | call [_display.select_cursor] |
1974 | call [_display.select_cursor] |
1986 | mov [current_cursor], esi |
1975 | mov [current_cursor], esi |
1987 | @@: |
1976 | @@: |
1988 | mov [redrawmouse_unconditional], 1 |
1977 | mov [redrawmouse_unconditional], 1 |
1989 | call wakeup_osloop |
1978 | call wakeup_osloop |
1990 | popfd |
1979 | popfd |
1991 | ret |
1980 | ret |
1992 | ;------------------------------------------------------------------------------ |
1981 | ;------------------------------------------------------------------------------ |
1993 | iglobal |
1982 | iglobal |
1994 | align 4 |
1983 | align 4 |
1995 | sys_system_table: |
1984 | sys_system_table: |
1996 | dd sysfn_deactivate ; 1 = deactivate window |
1985 | dd sysfn_deactivate ; 1 = deactivate window |
1997 | dd sysfn_terminate ; 2 = terminate thread |
1986 | dd sysfn_terminate ; 2 = terminate thread |
1998 | dd sysfn_activate ; 3 = activate window |
1987 | dd sysfn_activate ; 3 = activate window |
1999 | dd sysfn_getidletime ; 4 = get idle time |
1988 | dd sysfn_getidletime ; 4 = get idle time |
2000 | dd sysfn_getcpuclock ; 5 = get cpu clock |
1989 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2001 | dd sysfn_saveramdisk ; 6 = save ramdisk |
1990 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2002 | dd sysfn_getactive ; 7 = get active window |
1991 | dd sysfn_getactive ; 7 = get active window |
2003 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
1992 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2004 | dd sysfn_shutdown ; 9 = shutdown with parameter |
1993 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2005 | dd sysfn_minimize ; 10 = minimize window |
1994 | dd sysfn_minimize ; 10 = minimize window |
2006 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
1995 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2007 | dd sysfn_lastkey ; 12 = get last pressed key |
1996 | dd sysfn_lastkey ; 12 = get last pressed key |
2008 | dd sysfn_getversion ; 13 = get kernel version |
1997 | dd sysfn_getversion ; 13 = get kernel version |
2009 | dd sysfn_waitretrace ; 14 = wait retrace |
1998 | dd sysfn_waitretrace ; 14 = wait retrace |
2010 | dd sysfn_centermouse ; 15 = center mouse cursor |
1999 | dd sysfn_centermouse ; 15 = center mouse cursor |
2011 | dd sysfn_getfreemem ; 16 = get free memory size |
2000 | dd sysfn_getfreemem ; 16 = get free memory size |
2012 | dd sysfn_getallmem ; 17 = get total memory size |
2001 | dd sysfn_getallmem ; 17 = get total memory size |
2013 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2002 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2014 | ; instead of slot |
2003 | ; instead of slot |
2015 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2004 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2016 | dd sysfn_meminfo ; 20 = get extended memory info |
2005 | dd sysfn_meminfo ; 20 = get extended memory info |
2017 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2006 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2018 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2007 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2019 | dd sysfn_min_windows ; 23 = minimize all windows |
2008 | dd sysfn_min_windows ; 23 = minimize all windows |
2020 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2009 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2021 | sysfn_num = ($ - sys_system_table)/4 |
2010 | sysfn_num = ($ - sys_system_table)/4 |
2022 | endg |
2011 | endg |
2023 | ;------------------------------------------------------------------------------ |
2012 | ;------------------------------------------------------------------------------ |
2024 | sys_system: |
2013 | sys_system: |
2025 | dec ebx |
2014 | dec ebx |
2026 | cmp ebx, sysfn_num |
2015 | cmp ebx, sysfn_num |
2027 | jae @f |
2016 | jae @f |
2028 | jmp dword [sys_system_table + ebx*4] |
2017 | jmp dword [sys_system_table + ebx*4] |
2029 | @@: |
2018 | @@: |
2030 | ret |
2019 | ret |
2031 | ;------------------------------------------------------------------------------ |
2020 | ;------------------------------------------------------------------------------ |
2032 | sysfn_shutdown: ; 18.9 = system shutdown |
2021 | sysfn_shutdown: ; 18.9 = system shutdown |
2033 | cmp ecx, 1 |
2022 | cmp ecx, 1 |
2034 | jl exit_for_anyone |
2023 | jl exit_for_anyone |
2035 | cmp ecx, 4 |
2024 | cmp ecx, 4 |
2036 | jg exit_for_anyone |
2025 | jg exit_for_anyone |
2037 | mov [BOOT_VARS+0x9030], cl |
2026 | mov [BOOT_VARS+0x9030], cl |
2038 | 2027 | ||
2039 | mov eax, [TASK_COUNT] |
2028 | mov eax, [TASK_COUNT] |
2040 | mov [SYS_SHUTDOWN], al |
2029 | mov [SYS_SHUTDOWN], al |
2041 | mov [shutdown_processes], eax |
2030 | mov [shutdown_processes], eax |
2042 | call wakeup_osloop |
2031 | call wakeup_osloop |
2043 | and dword [esp+32], 0 |
2032 | and dword [esp+32], 0 |
2044 | exit_for_anyone: |
2033 | exit_for_anyone: |
2045 | ret |
2034 | ret |
2046 | uglobal |
2035 | uglobal |
2047 | shutdown_processes: |
2036 | shutdown_processes: |
2048 | dd 0x0 |
2037 | dd 0x0 |
2049 | endg |
2038 | endg |
2050 | ;------------------------------------------------------------------------------ |
2039 | ;------------------------------------------------------------------------------ |
2051 | sysfn_terminate: ; 18.2 = TERMINATE |
2040 | sysfn_terminate: ; 18.2 = TERMINATE |
2052 | push ecx |
2041 | push ecx |
2053 | cmp ecx, 2 |
2042 | cmp ecx, 2 |
2054 | jb noprocessterminate |
2043 | jb noprocessterminate |
2055 | mov edx, [TASK_COUNT] |
2044 | mov edx, [TASK_COUNT] |
2056 | cmp ecx, edx |
2045 | cmp ecx, edx |
2057 | ja noprocessterminate |
2046 | ja noprocessterminate |
2058 | mov eax, [TASK_COUNT] |
2047 | mov eax, [TASK_COUNT] |
2059 | shl ecx, 5 |
2048 | shl ecx, 5 |
2060 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2049 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2061 | add ecx, CURRENT_TASK+TASKDATA.state |
2050 | add ecx, CURRENT_TASK+TASKDATA.state |
2062 | cmp byte [ecx], 9 |
2051 | cmp byte [ecx], 9 |
2063 | jz noprocessterminate |
2052 | jz noprocessterminate |
2064 | push ecx edx |
2053 | push ecx edx |
2065 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2054 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2066 | call request_terminate |
2055 | call request_terminate |
2067 | pop edx ecx |
2056 | pop edx ecx |
2068 | test eax, eax |
2057 | test eax, eax |
2069 | jz noprocessterminate |
2058 | jz noprocessterminate |
2070 | ;-------------------------------------- |
2059 | ;-------------------------------------- |
2071 | ; terminate all network sockets it used |
2060 | ; terminate all network sockets it used |
2072 | pusha |
2061 | pusha |
2073 | mov eax, edx |
2062 | mov eax, edx |
2074 | call SOCKET_process_end |
2063 | call SOCKET_process_end |
2075 | popa |
2064 | popa |
2076 | ;-------------------------------------- |
2065 | ;-------------------------------------- |
2077 | cmp [_display.select_cursor], 0 |
2066 | cmp [_display.select_cursor], 0 |
2078 | je .restore_end |
2067 | je .restore_end |
2079 | ; restore default cursor before killing |
2068 | ; restore default cursor before killing |
2080 | pusha |
2069 | pusha |
2081 | mov ecx, [esp+32] |
2070 | mov ecx, [esp+32] |
2082 | shl ecx, 8 |
2071 | shl ecx, 8 |
2083 | add ecx, SLOT_BASE |
2072 | add ecx, SLOT_BASE |
2084 | mov eax, [def_cursor] |
2073 | mov eax, [def_cursor] |
2085 | cmp [ecx+APPDATA.cursor], eax |
2074 | cmp [ecx+APPDATA.cursor], eax |
2086 | je @f |
2075 | je @f |
2087 | call restore_default_cursor_before_killing |
2076 | call restore_default_cursor_before_killing |
2088 | @@: |
2077 | @@: |
2089 | popa |
2078 | popa |
2090 | .restore_end: |
2079 | .restore_end: |
2091 | ;-------------------------------------- |
2080 | ;-------------------------------------- |
2092 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2081 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2093 | mov [ecx], byte 3; clear possible i40's |
2082 | mov [ecx], byte 3; clear possible i40's |
2094 | call wakeup_osloop |
2083 | call wakeup_osloop |
2095 | ;call MEM_Heap_UnLock |
2084 | ;call MEM_Heap_UnLock |
2096 | 2085 | ||
2097 | cmp edx, [application_table_owner]; clear app table stat |
2086 | cmp edx, [application_table_owner]; clear app table stat |
2098 | jne noatsc |
2087 | jne noatsc |
2099 | call unlock_application_table |
2088 | call unlock_application_table |
2100 | noatsc: |
2089 | noatsc: |
2101 | noprocessterminate: |
2090 | noprocessterminate: |
2102 | add esp, 4 |
2091 | add esp, 4 |
2103 | ret |
2092 | ret |
2104 | ;------------------------------------------------------------------------------ |
2093 | ;------------------------------------------------------------------------------ |
2105 | sysfn_terminate2: |
2094 | sysfn_terminate2: |
2106 | ;lock application_table_status mutex |
2095 | ;lock application_table_status mutex |
2107 | .table_status: |
2096 | .table_status: |
2108 | call lock_application_table |
2097 | call lock_application_table |
2109 | mov eax, ecx |
2098 | mov eax, ecx |
2110 | call pid_to_slot |
2099 | call pid_to_slot |
2111 | test eax, eax |
2100 | test eax, eax |
2112 | jz .not_found |
2101 | jz .not_found |
2113 | mov ecx, eax |
2102 | mov ecx, eax |
2114 | cli |
2103 | cli |
2115 | call sysfn_terminate |
2104 | call sysfn_terminate |
2116 | call unlock_application_table |
2105 | call unlock_application_table |
2117 | sti |
2106 | sti |
2118 | and dword [esp+32], 0 |
2107 | and dword [esp+32], 0 |
2119 | ret |
2108 | ret |
2120 | .not_found: |
2109 | .not_found: |
2121 | call unlock_application_table |
2110 | call unlock_application_table |
2122 | or dword [esp+32], -1 |
2111 | or dword [esp+32], -1 |
2123 | ret |
2112 | ret |
2124 | ;------------------------------------------------------------------------------ |
2113 | ;------------------------------------------------------------------------------ |
2125 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2114 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2126 | cmp ecx, 2 |
2115 | cmp ecx, 2 |
2127 | jb .nowindowdeactivate |
2116 | jb .nowindowdeactivate |
2128 | cmp ecx, [TASK_COUNT] |
2117 | cmp ecx, [TASK_COUNT] |
2129 | ja .nowindowdeactivate |
2118 | ja .nowindowdeactivate |
2130 | 2119 | ||
2131 | movzx esi, word [WIN_STACK + ecx*2] |
2120 | movzx esi, word [WIN_STACK + ecx*2] |
2132 | cmp esi, 1 |
2121 | cmp esi, 1 |
2133 | je .nowindowdeactivate ; already deactive |
2122 | je .nowindowdeactivate ; already deactive |
2134 | 2123 | ||
2135 | mov edi, ecx |
2124 | mov edi, ecx |
2136 | shl edi, 5 |
2125 | shl edi, 5 |
2137 | add edi, window_data |
2126 | add edi, window_data |
2138 | movzx esi, word [WIN_STACK + ecx * 2] |
2127 | movzx esi, word [WIN_STACK + ecx * 2] |
2139 | lea esi, [WIN_POS + esi * 2] |
2128 | lea esi, [WIN_POS + esi * 2] |
2140 | call window._.window_deactivate |
2129 | call window._.window_deactivate |
2141 | 2130 | ||
2142 | call syscall_display_settings._.calculate_whole_screen |
2131 | call syscall_display_settings._.calculate_whole_screen |
2143 | call syscall_display_settings._.redraw_whole_screen |
2132 | call syscall_display_settings._.redraw_whole_screen |
2144 | .nowindowdeactivate: |
2133 | .nowindowdeactivate: |
2145 | ret |
2134 | ret |
2146 | ;------------------------------------------------------------------------------ |
2135 | ;------------------------------------------------------------------------------ |
2147 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2136 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2148 | cmp ecx, 2 |
2137 | cmp ecx, 2 |
2149 | jb .nowindowactivate |
2138 | jb .nowindowactivate |
2150 | cmp ecx, [TASK_COUNT] |
2139 | cmp ecx, [TASK_COUNT] |
2151 | ja .nowindowactivate |
2140 | ja .nowindowactivate |
2152 | ;------------------------------------- |
2141 | ;------------------------------------- |
2153 | @@: |
2142 | @@: |
2154 | ; If the window is captured and moved by the user, |
2143 | ; If the window is captured and moved by the user, |
2155 | ; then you can't change the position in window stack!!! |
2144 | ; then you can't change the position in window stack!!! |
2156 | mov al, [mouse.active_sys_window.action] |
2145 | mov al, [mouse.active_sys_window.action] |
2157 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2146 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2158 | test al, al |
2147 | test al, al |
2159 | jz @f |
2148 | jz @f |
2160 | call change_task |
2149 | call change_task |
2161 | jmp @b |
2150 | jmp @b |
2162 | @@: |
2151 | @@: |
2163 | ;------------------------------------- |
2152 | ;------------------------------------- |
2164 | mov [window_minimize], 2; restore window if minimized |
2153 | mov [window_minimize], 2; restore window if minimized |
2165 | call wakeup_osloop |
2154 | call wakeup_osloop |
2166 | 2155 | ||
2167 | movzx esi, word [WIN_STACK + ecx*2] |
2156 | movzx esi, word [WIN_STACK + ecx*2] |
2168 | cmp esi, [TASK_COUNT] |
2157 | cmp esi, [TASK_COUNT] |
2169 | je .nowindowactivate; already active |
2158 | je .nowindowactivate; already active |
2170 | 2159 | ||
2171 | mov edi, ecx |
2160 | mov edi, ecx |
2172 | shl edi, 5 |
2161 | shl edi, 5 |
2173 | add edi, window_data |
2162 | add edi, window_data |
2174 | movzx esi, word [WIN_STACK + ecx * 2] |
2163 | movzx esi, word [WIN_STACK + ecx * 2] |
2175 | lea esi, [WIN_POS + esi * 2] |
2164 | lea esi, [WIN_POS + esi * 2] |
2176 | call waredraw |
2165 | call waredraw |
2177 | .nowindowactivate: |
2166 | .nowindowactivate: |
2178 | ret |
2167 | ret |
2179 | ;------------------------------------------------------------------------------ |
2168 | ;------------------------------------------------------------------------------ |
2180 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2169 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2181 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2170 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2182 | mov [esp+32], eax |
2171 | mov [esp+32], eax |
2183 | ret |
2172 | ret |
2184 | ;------------------------------------------------------------------------------ |
2173 | ;------------------------------------------------------------------------------ |
2185 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2174 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2186 | mov eax, dword [cpu_freq] |
2175 | mov eax, dword [cpu_freq] |
2187 | mov [esp+32], eax |
2176 | mov [esp+32], eax |
2188 | ret |
2177 | ret |
2189 | ;------------------------------------------------------------------------------ |
2178 | ;------------------------------------------------------------------------------ |
2190 | get_cpu_freq: |
2179 | get_cpu_freq: |
2191 | mov eax, dword [cpu_freq] |
2180 | mov eax, dword [cpu_freq] |
2192 | mov edx, dword [cpu_freq+4] |
2181 | mov edx, dword [cpu_freq+4] |
2193 | ret |
2182 | ret |
2194 | ; SAVE ramdisk to /hd/1/menuet.img |
2183 | ; SAVE ramdisk to /hd/1/menuet.img |
2195 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2184 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2196 | include 'blkdev/rdsave.inc' |
2185 | include 'blkdev/rdsave.inc' |
2197 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2186 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2198 | ;------------------------------------------------------------------------------ |
2187 | ;------------------------------------------------------------------------------ |
2199 | align 4 |
2188 | align 4 |
2200 | sysfn_getactive: ; 18.7 = get active window |
2189 | sysfn_getactive: ; 18.7 = get active window |
2201 | mov eax, [TASK_COUNT] |
2190 | mov eax, [TASK_COUNT] |
2202 | movzx eax, word [WIN_POS + eax*2] |
2191 | movzx eax, word [WIN_POS + eax*2] |
2203 | mov [esp+32], eax |
2192 | mov [esp+32], eax |
2204 | ret |
2193 | ret |
2205 | ;------------------------------------------------------------------------------ |
2194 | ;------------------------------------------------------------------------------ |
2206 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2195 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2207 | ; cmp ecx,1 |
2196 | ; cmp ecx,1 |
2208 | dec ecx |
2197 | dec ecx |
2209 | jnz nogetsoundflag |
2198 | jnz nogetsoundflag |
2210 | movzx eax, byte [sound_flag]; get sound_flag |
2199 | movzx eax, byte [sound_flag]; get sound_flag |
2211 | mov [esp+32], eax |
2200 | mov [esp+32], eax |
2212 | ret |
2201 | ret |
2213 | nogetsoundflag: |
2202 | nogetsoundflag: |
2214 | ; cmp ecx,2 |
2203 | ; cmp ecx,2 |
2215 | dec ecx |
2204 | dec ecx |
2216 | jnz nosoundflag |
2205 | jnz nosoundflag |
2217 | xor byte [sound_flag], 1 |
2206 | xor byte [sound_flag], 1 |
2218 | nosoundflag: |
2207 | nosoundflag: |
2219 | ret |
2208 | ret |
2220 | ;------------------------------------------------------------------------------ |
2209 | ;------------------------------------------------------------------------------ |
2221 | sysfn_minimize: ; 18.10 = minimize window |
2210 | sysfn_minimize: ; 18.10 = minimize window |
2222 | mov [window_minimize], 1 |
2211 | mov [window_minimize], 1 |
2223 | call wakeup_osloop |
2212 | call wakeup_osloop |
2224 | ret |
2213 | ret |
2225 | ;------------------------------------------------------------------------------ |
2214 | ;------------------------------------------------------------------------------ |
2226 | align 4 |
2215 | align 4 |
2227 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2216 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2228 | dec ecx |
2217 | dec ecx |
2229 | jnz .exit |
2218 | jnz .exit |
2230 | .small_table: |
2219 | .small_table: |
2231 | mov edi, edx |
2220 | mov edi, edx |
2232 | mov esi, DRIVE_DATA |
2221 | mov esi, DRIVE_DATA |
2233 | mov ecx, DRIVE_DATA_SIZE ;10 |
2222 | mov ecx, DRIVE_DATA_SIZE ;10 |
2234 | cld |
2223 | cld |
2235 | rep movsb |
2224 | rep movsb |
2236 | .exit: |
2225 | .exit: |
2237 | ret |
2226 | ret |
2238 | ;------------------------------------------------------------------------------ |
2227 | ;------------------------------------------------------------------------------ |
2239 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2228 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2240 | and dword [esp+32], 0 |
2229 | and dword [esp+32], 0 |
2241 | ret |
2230 | ret |
2242 | ;------------------------------------------------------------------------------ |
2231 | ;------------------------------------------------------------------------------ |
2243 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2232 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2244 | mov edi, ecx |
2233 | mov edi, ecx |
2245 | mov esi, version_inf |
2234 | mov esi, version_inf |
2246 | mov ecx, version_end-version_inf |
2235 | mov ecx, version_end-version_inf |
2247 | rep movsb |
2236 | rep movsb |
2248 | ret |
2237 | ret |
2249 | ;------------------------------------------------------------------------------ |
2238 | ;------------------------------------------------------------------------------ |
2250 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2239 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2251 | ;wait retrace functions |
2240 | ;wait retrace functions |
2252 | sys_wait_retrace: |
2241 | sys_wait_retrace: |
2253 | mov edx, 0x3da |
2242 | mov edx, 0x3da |
2254 | WaitRetrace_loop: |
2243 | WaitRetrace_loop: |
2255 | in al, dx |
2244 | in al, dx |
2256 | test al, 1000b |
2245 | test al, 1000b |
2257 | jz WaitRetrace_loop |
2246 | jz WaitRetrace_loop |
2258 | and [esp+32], dword 0 |
2247 | and [esp+32], dword 0 |
2259 | ret |
2248 | ret |
2260 | ;------------------------------------------------------------------------------ |
2249 | ;------------------------------------------------------------------------------ |
2261 | align 4 |
2250 | align 4 |
2262 | sysfn_centermouse: ; 18.15 = mouse centered |
2251 | sysfn_centermouse: ; 18.15 = mouse centered |
2263 | ; removed here by |
2252 | ; removed here by |
2264 | ; call mouse_centered |
2253 | ; call mouse_centered |
2265 | ;* mouse centered - start code- Mario79 |
2254 | ;* mouse centered - start code- Mario79 |
2266 | ;mouse_centered: |
2255 | ;mouse_centered: |
2267 | ; push eax |
2256 | ; push eax |
2268 | mov eax, [Screen_Max_X] |
2257 | mov eax, [Screen_Max_X] |
2269 | shr eax, 1 |
2258 | shr eax, 1 |
2270 | mov [MOUSE_X], ax |
2259 | mov [MOUSE_X], ax |
2271 | mov eax, [Screen_Max_Y] |
2260 | mov eax, [Screen_Max_Y] |
2272 | shr eax, 1 |
2261 | shr eax, 1 |
2273 | mov [MOUSE_Y], ax |
2262 | mov [MOUSE_Y], ax |
2274 | call wakeup_osloop |
2263 | call wakeup_osloop |
2275 | ; ret |
2264 | ; ret |
2276 | ;* mouse centered - end code- Mario79 |
2265 | ;* mouse centered - end code- Mario79 |
2277 | xor eax, eax |
2266 | xor eax, eax |
2278 | and [esp+32], eax |
2267 | and [esp+32], eax |
2279 | ; pop eax |
2268 | ; pop eax |
2280 | ret |
2269 | ret |
2281 | ;------------------------------------------------------------------------------ |
2270 | ;------------------------------------------------------------------------------ |
2282 | align 4 |
2271 | align 4 |
2283 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2272 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2284 | test ecx, ecx; get mouse speed factor |
2273 | test ecx, ecx; get mouse speed factor |
2285 | jnz .set_mouse_acceleration |
2274 | jnz .set_mouse_acceleration |
2286 | xor eax, eax |
2275 | xor eax, eax |
2287 | mov ax, [mouse_speed_factor] |
2276 | mov ax, [mouse_speed_factor] |
2288 | mov [esp+32], eax |
2277 | mov [esp+32], eax |
2289 | ret |
2278 | ret |
2290 | .set_mouse_acceleration: |
2279 | .set_mouse_acceleration: |
2291 | ; cmp ecx,1 ; set mouse speed factor |
2280 | ; cmp ecx,1 ; set mouse speed factor |
2292 | dec ecx |
2281 | dec ecx |
2293 | jnz .get_mouse_delay |
2282 | jnz .get_mouse_delay |
2294 | mov [mouse_speed_factor], dx |
2283 | mov [mouse_speed_factor], dx |
2295 | ret |
2284 | ret |
2296 | .get_mouse_delay: |
2285 | .get_mouse_delay: |
2297 | ; cmp ecx,2 ; get mouse delay |
2286 | ; cmp ecx,2 ; get mouse delay |
2298 | dec ecx |
2287 | dec ecx |
2299 | jnz .set_mouse_delay |
2288 | jnz .set_mouse_delay |
2300 | mov eax, [mouse_delay] |
2289 | mov eax, [mouse_delay] |
2301 | mov [esp+32], eax |
2290 | mov [esp+32], eax |
2302 | ret |
2291 | ret |
2303 | .set_mouse_delay: |
2292 | .set_mouse_delay: |
2304 | ; cmp ecx,3 ; set mouse delay |
2293 | ; cmp ecx,3 ; set mouse delay |
2305 | dec ecx |
2294 | dec ecx |
2306 | jnz .set_pointer_position |
2295 | jnz .set_pointer_position |
2307 | mov [mouse_delay], edx |
2296 | mov [mouse_delay], edx |
2308 | ret |
2297 | ret |
2309 | .set_pointer_position: |
2298 | .set_pointer_position: |
2310 | ; cmp ecx,4 ; set mouse pointer position |
2299 | ; cmp ecx,4 ; set mouse pointer position |
2311 | dec ecx |
2300 | dec ecx |
2312 | jnz .set_mouse_button |
2301 | jnz .set_mouse_button |
2313 | cmp dx, word[Screen_Max_Y] |
2302 | cmp dx, word[Screen_Max_Y] |
2314 | ja .end |
2303 | ja .end |
2315 | rol edx, 16 |
2304 | rol edx, 16 |
2316 | cmp dx, word[Screen_Max_X] |
2305 | cmp dx, word[Screen_Max_X] |
2317 | ja .end |
2306 | ja .end |
2318 | mov [MOUSE_X], edx |
2307 | mov [MOUSE_X], edx |
2319 | mov [mouse_active], 1 |
2308 | mov [mouse_active], 1 |
2320 | call wakeup_osloop |
2309 | call wakeup_osloop |
2321 | ret |
2310 | ret |
2322 | .set_mouse_button: |
2311 | .set_mouse_button: |
2323 | ; cmp ecx,5 ; set mouse button features |
2312 | ; cmp ecx,5 ; set mouse button features |
2324 | dec ecx |
2313 | dec ecx |
2325 | jnz .end |
2314 | jnz .end |
2326 | mov [BTN_DOWN], dl |
2315 | mov [BTN_DOWN], dl |
2327 | mov [mouse_active], 1 |
2316 | mov [mouse_active], 1 |
2328 | call wakeup_osloop |
2317 | call wakeup_osloop |
2329 | .end: |
2318 | .end: |
2330 | ret |
2319 | ret |
2331 | ;------------------------------------------------------------------------------ |
2320 | ;------------------------------------------------------------------------------ |
2332 | sysfn_getfreemem: |
2321 | sysfn_getfreemem: |
2333 | mov eax, [pg_data.pages_free] |
2322 | mov eax, [pg_data.pages_free] |
2334 | shl eax, 2 |
2323 | shl eax, 2 |
2335 | mov [esp+32], eax |
2324 | mov [esp+32], eax |
2336 | ret |
2325 | ret |
2337 | ;------------------------------------------------------------------------------ |
2326 | ;------------------------------------------------------------------------------ |
2338 | sysfn_getallmem: |
2327 | sysfn_getallmem: |
2339 | mov eax, [MEM_AMOUNT] |
2328 | mov eax, [MEM_AMOUNT] |
2340 | shr eax, 10 |
2329 | shr eax, 10 |
2341 | mov [esp+32], eax |
2330 | mov [esp+32], eax |
2342 | ret |
2331 | ret |
2343 | ;------------------------------------------------------------------------------ |
2332 | ;------------------------------------------------------------------------------ |
2344 | sysfn_pid_to_slot: |
2333 | sysfn_pid_to_slot: |
2345 | mov eax, ecx |
2334 | mov eax, ecx |
2346 | call pid_to_slot |
2335 | call pid_to_slot |
2347 | mov [esp+32], eax |
2336 | mov [esp+32], eax |
2348 | ret |
2337 | ret |
2349 | ;------------------------------------------------------------------------------ |
2338 | ;------------------------------------------------------------------------------ |
2350 | sysfn_min_rest_window: |
2339 | sysfn_min_rest_window: |
2351 | pushad |
2340 | pushad |
2352 | mov eax, edx ; ebx - operating |
2341 | mov eax, edx ; ebx - operating |
2353 | shr ecx, 1 |
2342 | shr ecx, 1 |
2354 | jnc @f |
2343 | jnc @f |
2355 | call pid_to_slot |
2344 | call pid_to_slot |
2356 | @@: |
2345 | @@: |
2357 | or eax, eax ; eax - number of slot |
2346 | or eax, eax ; eax - number of slot |
2358 | jz .error |
2347 | jz .error |
2359 | cmp eax, 255 ; varify maximal slot number |
2348 | cmp eax, 255 ; varify maximal slot number |
2360 | ja .error |
2349 | ja .error |
2361 | movzx eax, word [WIN_STACK + eax*2] |
2350 | movzx eax, word [WIN_STACK + eax*2] |
2362 | shr ecx, 1 |
2351 | shr ecx, 1 |
2363 | jc .restore |
2352 | jc .restore |
2364 | ; .minimize: |
2353 | ; .minimize: |
2365 | call minimize_window |
2354 | call minimize_window |
2366 | jmp .exit |
2355 | jmp .exit |
2367 | .restore: |
2356 | .restore: |
2368 | call restore_minimized_window |
2357 | call restore_minimized_window |
2369 | .exit: |
2358 | .exit: |
2370 | popad |
2359 | popad |
2371 | xor eax, eax |
2360 | xor eax, eax |
2372 | mov [esp+32], eax |
2361 | mov [esp+32], eax |
2373 | ret |
2362 | ret |
2374 | .error: |
2363 | .error: |
2375 | popad |
2364 | popad |
2376 | xor eax, eax |
2365 | xor eax, eax |
2377 | dec eax |
2366 | dec eax |
2378 | mov [esp+32], eax |
2367 | mov [esp+32], eax |
2379 | ret |
2368 | ret |
2380 | ;------------------------------------------------------------------------------ |
2369 | ;------------------------------------------------------------------------------ |
2381 | sysfn_min_windows: |
2370 | sysfn_min_windows: |
2382 | call minimize_all_window |
2371 | call minimize_all_window |
2383 | mov [esp+32], eax |
2372 | mov [esp+32], eax |
2384 | call change_task |
2373 | call change_task |
2385 | ret |
2374 | ret |
2386 | ;------------------------------------------------------------------------------ |
2375 | ;------------------------------------------------------------------------------ |
2387 | sysfn_set_screen_sizes: |
2376 | sysfn_set_screen_sizes: |
2388 | cmp [SCR_MODE], word 0x13 |
2377 | cmp [SCR_MODE], word 0x13 |
2389 | jbe .exit |
2378 | jbe .exit |
2390 | 2379 | ||
2391 | cmp [_display.select_cursor], select_cursor |
2380 | cmp [_display.select_cursor], select_cursor |
2392 | jne .exit |
2381 | jne .exit |
2393 | 2382 | ||
2394 | cmp ecx, [display_width_standard] |
2383 | cmp ecx, [display_width_standard] |
2395 | ja .exit |
2384 | ja .exit |
2396 | 2385 | ||
2397 | cmp edx, [display_height_standard] |
2386 | cmp edx, [display_height_standard] |
2398 | ja .exit |
2387 | ja .exit |
2399 | 2388 | ||
2400 | pushfd |
2389 | pushfd |
2401 | cli |
2390 | cli |
2402 | mov eax, ecx |
2391 | mov eax, ecx |
2403 | mov ecx, [_display.pitch] |
2392 | mov ecx, [_display.pitch] |
2404 | mov [_display.width], eax |
2393 | mov [_display.width], eax |
2405 | dec eax |
2394 | dec eax |
2406 | mov [_display.height], edx |
2395 | mov [_display.height], edx |
2407 | dec edx |
2396 | dec edx |
2408 | ; eax - new Screen_Max_X |
2397 | ; eax - new Screen_Max_X |
2409 | ; edx - new Screen_Max_Y |
2398 | ; edx - new Screen_Max_Y |
2410 | mov [do_not_touch_winmap], 1 |
2399 | mov [do_not_touch_winmap], 1 |
2411 | call set_screen |
2400 | call set_screen |
2412 | mov [do_not_touch_winmap], 0 |
2401 | mov [do_not_touch_winmap], 0 |
2413 | popfd |
2402 | popfd |
2414 | call change_task |
2403 | call change_task |
2415 | .exit: |
2404 | .exit: |
2416 | ret |
2405 | ret |
2417 | ;------------------------------------------------------------------------------ |
2406 | ;------------------------------------------------------------------------------ |
2418 | uglobal |
2407 | uglobal |
2419 | screen_workarea RECT |
2408 | screen_workarea RECT |
2420 | display_width_standard dd 0 |
2409 | display_width_standard dd 0 |
2421 | display_height_standard dd 0 |
2410 | display_height_standard dd 0 |
2422 | do_not_touch_winmap db 0 |
2411 | do_not_touch_winmap db 0 |
2423 | window_minimize db 0 |
2412 | window_minimize db 0 |
2424 | sound_flag db 0 |
2413 | sound_flag db 0 |
2425 | 2414 | ||
2426 | endg |
2415 | endg |
2427 | 2416 | ||
2428 | UID_NONE=0 |
2417 | UID_NONE=0 |
2429 | UID_MENUETOS=1 ;official |
2418 | UID_MENUETOS=1 ;official |
2430 | UID_KOLIBRI=2 ;russian |
2419 | UID_KOLIBRI=2 ;russian |
2431 | 2420 | ||
2432 | iglobal |
2421 | iglobal |
2433 | version_inf: |
2422 | version_inf: |
2434 | db 0,7,7,0 ; version 0.7.7.0 |
2423 | db 0,7,7,0 ; version 0.7.7.0 |
2435 | db 0 |
2424 | db 0 |
2436 | .rev dd __REV__ |
2425 | .rev dd __REV__ |
2437 | version_end: |
2426 | version_end: |
2438 | endg |
2427 | endg |
2439 | ;------------------------------------------------------------------------------ |
2428 | ;------------------------------------------------------------------------------ |
2440 | align 4 |
2429 | align 4 |
2441 | sys_cachetodiskette: |
2430 | sys_cachetodiskette: |
2442 | cmp ebx, 1 |
2431 | cmp ebx, 1 |
2443 | jb .no_floppy_save |
2432 | jb .no_floppy_save |
2444 | cmp ebx, 2 |
2433 | cmp ebx, 2 |
2445 | ja .no_floppy_save |
2434 | ja .no_floppy_save |
2446 | call save_image |
2435 | call save_image |
2447 | mov [esp + 32], eax |
2436 | mov [esp + 32], eax |
2448 | ret |
2437 | ret |
2449 | .no_floppy_save: |
2438 | .no_floppy_save: |
2450 | mov [esp + 32], dword 1 |
2439 | mov [esp + 32], dword 1 |
2451 | ret |
2440 | ret |
2452 | ;------------------------------------------------------------------------------ |
2441 | ;------------------------------------------------------------------------------ |
2453 | uglobal |
2442 | uglobal |
2454 | ; bgrchanged dd 0x0 |
2443 | ; bgrchanged dd 0x0 |
2455 | align 4 |
2444 | align 4 |
2456 | bgrlockpid dd 0 |
2445 | bgrlockpid dd 0 |
2457 | bgrlock db 0 |
2446 | bgrlock db 0 |
2458 | endg |
2447 | endg |
2459 | ;------------------------------------------------------------------------------ |
2448 | ;------------------------------------------------------------------------------ |
2460 | align 4 |
2449 | align 4 |
2461 | sys_background: |
2450 | sys_background: |
2462 | cmp ebx, 1 ; BACKGROUND SIZE |
2451 | cmp ebx, 1 ; BACKGROUND SIZE |
2463 | jnz nosb1 |
2452 | jnz nosb1 |
2464 | test ecx, ecx |
2453 | test ecx, ecx |
2465 | jz sbgrr |
2454 | jz sbgrr |
2466 | 2455 | ||
2467 | test edx, edx |
2456 | test edx, edx |
2468 | jz sbgrr |
2457 | jz sbgrr |
2469 | ;-------------------------------------- |
2458 | ;-------------------------------------- |
2470 | align 4 |
2459 | align 4 |
2471 | @@: |
2460 | @@: |
2472 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2461 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2473 | bts dword [bgrlock], 0 |
2462 | bts dword [bgrlock], 0 |
2474 | jnc @f |
2463 | jnc @f |
2475 | call change_task |
2464 | call change_task |
2476 | jmp @b |
2465 | jmp @b |
2477 | ;-------------------------------------- |
2466 | ;-------------------------------------- |
2478 | align 4 |
2467 | align 4 |
2479 | @@: |
2468 | @@: |
2480 | mov [BgrDataWidth], ecx |
2469 | mov [BgrDataWidth], ecx |
2481 | mov [BgrDataHeight], edx |
2470 | mov [BgrDataHeight], edx |
2482 | ; mov [bgrchanged],1 |
2471 | ; mov [bgrchanged],1 |
2483 | 2472 | ||
2484 | pushad |
2473 | pushad |
2485 | ; return memory for old background |
2474 | ; return memory for old background |
2486 | mov eax, [img_background] |
2475 | mov eax, [img_background] |
2487 | cmp eax, static_background_data |
2476 | cmp eax, static_background_data |
2488 | jz @f |
2477 | jz @f |
2489 | stdcall kernel_free, eax |
2478 | stdcall kernel_free, eax |
2490 | ;-------------------------------------- |
2479 | ;-------------------------------------- |
2491 | align 4 |
2480 | align 4 |
2492 | @@: |
2481 | @@: |
2493 | ; calculate RAW size |
2482 | ; calculate RAW size |
2494 | xor eax, eax |
2483 | xor eax, eax |
2495 | inc eax |
2484 | inc eax |
2496 | cmp [BgrDataWidth], eax |
2485 | cmp [BgrDataWidth], eax |
2497 | jae @f |
2486 | jae @f |
2498 | mov [BgrDataWidth], eax |
2487 | mov [BgrDataWidth], eax |
2499 | ;-------------------------------------- |
2488 | ;-------------------------------------- |
2500 | align 4 |
2489 | align 4 |
2501 | @@: |
2490 | @@: |
2502 | cmp [BgrDataHeight], eax |
2491 | cmp [BgrDataHeight], eax |
2503 | jae @f |
2492 | jae @f |
2504 | mov [BgrDataHeight], eax |
2493 | mov [BgrDataHeight], eax |
2505 | ;-------------------------------------- |
2494 | ;-------------------------------------- |
2506 | align 4 |
2495 | align 4 |
2507 | @@: |
2496 | @@: |
2508 | mov eax, [BgrDataWidth] |
2497 | mov eax, [BgrDataWidth] |
2509 | imul eax, [BgrDataHeight] |
2498 | imul eax, [BgrDataHeight] |
2510 | lea eax, [eax*3] |
2499 | lea eax, [eax*3] |
2511 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2500 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2512 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2501 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2513 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2502 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2514 | shr eax, 12 |
2503 | shr eax, 12 |
2515 | inc eax |
2504 | inc eax |
2516 | shl eax, 12 |
2505 | shl eax, 12 |
2517 | mov [mem_BACKGROUND], eax |
2506 | mov [mem_BACKGROUND], eax |
2518 | ; get memory for new background |
2507 | ; get memory for new background |
2519 | stdcall kernel_alloc, eax |
2508 | stdcall kernel_alloc, eax |
2520 | test eax, eax |
2509 | test eax, eax |
2521 | jz .memfailed |
2510 | jz .memfailed |
2522 | mov [img_background], eax |
2511 | mov [img_background], eax |
2523 | jmp .exit |
2512 | jmp .exit |
2524 | ;-------------------------------------- |
2513 | ;-------------------------------------- |
2525 | align 4 |
2514 | align 4 |
2526 | .memfailed: |
2515 | .memfailed: |
2527 | ; revert to static monotone data |
2516 | ; revert to static monotone data |
2528 | mov [img_background], static_background_data |
2517 | mov [img_background], static_background_data |
2529 | xor eax, eax |
2518 | xor eax, eax |
2530 | inc eax |
2519 | inc eax |
2531 | mov [BgrDataWidth], eax |
2520 | mov [BgrDataWidth], eax |
2532 | mov [BgrDataHeight], eax |
2521 | mov [BgrDataHeight], eax |
2533 | mov [mem_BACKGROUND], 4 |
2522 | mov [mem_BACKGROUND], 4 |
2534 | ;-------------------------------------- |
2523 | ;-------------------------------------- |
2535 | align 4 |
2524 | align 4 |
2536 | .exit: |
2525 | .exit: |
2537 | popad |
2526 | popad |
2538 | mov [bgrlock], 0 |
2527 | mov [bgrlock], 0 |
2539 | ;-------------------------------------- |
2528 | ;-------------------------------------- |
2540 | align 4 |
2529 | align 4 |
2541 | sbgrr: |
2530 | sbgrr: |
2542 | ret |
2531 | ret |
2543 | ;------------------------------------------------------------------------------ |
2532 | ;------------------------------------------------------------------------------ |
2544 | align 4 |
2533 | align 4 |
2545 | nosb1: |
2534 | nosb1: |
2546 | cmp ebx, 2 ; SET PIXEL |
2535 | cmp ebx, 2 ; SET PIXEL |
2547 | jnz nosb2 |
2536 | jnz nosb2 |
2548 | 2537 | ||
2549 | mov eax, [img_background] |
2538 | mov eax, [img_background] |
2550 | test ecx, ecx |
2539 | test ecx, ecx |
2551 | jz @f |
2540 | jz @f |
2552 | cmp eax, static_background_data |
2541 | cmp eax, static_background_data |
2553 | jz .ret |
2542 | jz .ret |
2554 | ;-------------------------------------- |
2543 | ;-------------------------------------- |
2555 | align 4 |
2544 | align 4 |
2556 | @@: |
2545 | @@: |
2557 | mov ebx, [mem_BACKGROUND] |
2546 | mov ebx, [mem_BACKGROUND] |
2558 | add ebx, 4095 |
2547 | add ebx, 4095 |
2559 | and ebx, -4096 |
2548 | and ebx, -4096 |
2560 | sub ebx, 4 |
2549 | sub ebx, 4 |
2561 | cmp ecx, ebx |
2550 | cmp ecx, ebx |
2562 | ja .ret |
2551 | ja .ret |
2563 | 2552 | ||
2564 | mov ebx, [eax+ecx] |
2553 | mov ebx, [eax+ecx] |
2565 | and ebx, 0xFF000000;255*256*256*256 |
2554 | and ebx, 0xFF000000;255*256*256*256 |
2566 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2555 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2567 | add edx, ebx |
2556 | add edx, ebx |
2568 | mov [eax+ecx], edx |
2557 | mov [eax+ecx], edx |
2569 | ;-------------------------------------- |
2558 | ;-------------------------------------- |
2570 | align 4 |
2559 | align 4 |
2571 | .ret: |
2560 | .ret: |
2572 | ret |
2561 | ret |
2573 | ;------------------------------------------------------------------------------ |
2562 | ;------------------------------------------------------------------------------ |
2574 | align 4 |
2563 | align 4 |
2575 | nosb2: |
2564 | nosb2: |
2576 | cmp ebx, 3 ; DRAW BACKGROUND |
2565 | cmp ebx, 3 ; DRAW BACKGROUND |
2577 | jnz nosb3 |
2566 | jnz nosb3 |
2578 | ;-------------------------------------- |
2567 | ;-------------------------------------- |
2579 | align 4 |
2568 | align 4 |
2580 | draw_background_temp: |
2569 | draw_background_temp: |
2581 | mov [background_defined], 1 |
2570 | mov [background_defined], 1 |
2582 | call force_redraw_background |
2571 | call force_redraw_background |
2583 | ;-------------------------------------- |
2572 | ;-------------------------------------- |
2584 | align 4 |
2573 | align 4 |
2585 | nosb31: |
2574 | nosb31: |
2586 | ret |
2575 | ret |
2587 | ;------------------------------------------------------------------------------ |
2576 | ;------------------------------------------------------------------------------ |
2588 | align 4 |
2577 | align 4 |
2589 | nosb3: |
2578 | nosb3: |
2590 | cmp ebx, 4 ; TILED / STRETCHED |
2579 | cmp ebx, 4 ; TILED / STRETCHED |
2591 | jnz nosb4 |
2580 | jnz nosb4 |
2592 | cmp ecx, [BgrDrawMode] |
2581 | cmp ecx, [BgrDrawMode] |
2593 | je nosb41 |
2582 | je nosb41 |
2594 | mov [BgrDrawMode], ecx |
2583 | mov [BgrDrawMode], ecx |
2595 | ;-------------------------------------- |
2584 | ;-------------------------------------- |
2596 | align 4 |
2585 | align 4 |
2597 | nosb41: |
2586 | nosb41: |
2598 | ret |
2587 | ret |
2599 | ;------------------------------------------------------------------------------ |
2588 | ;------------------------------------------------------------------------------ |
2600 | align 4 |
2589 | align 4 |
2601 | nosb4: |
2590 | nosb4: |
2602 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2591 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2603 | jnz nosb5 |
2592 | jnz nosb5 |
2604 | cmp [img_background], static_background_data |
2593 | cmp [img_background], static_background_data |
2605 | jnz @f |
2594 | jnz @f |
2606 | test edx, edx |
2595 | test edx, edx |
2607 | jnz .fin |
2596 | jnz .fin |
2608 | cmp esi, 4 |
2597 | cmp esi, 4 |
2609 | ja .fin |
2598 | ja .fin |
2610 | ;-------------------------------------- |
2599 | ;-------------------------------------- |
2611 | align 4 |
2600 | align 4 |
2612 | @@: |
2601 | @@: |
2613 | ; bughere |
2602 | ; bughere |
2614 | mov eax, ecx |
2603 | mov eax, ecx |
2615 | mov ebx, edx |
2604 | mov ebx, edx |
2616 | add ebx, [img_background];IMG_BACKGROUND |
2605 | add ebx, [img_background];IMG_BACKGROUND |
2617 | mov ecx, esi |
2606 | mov ecx, esi |
2618 | call memmove |
2607 | call memmove |
2619 | ;-------------------------------------- |
2608 | ;-------------------------------------- |
2620 | align 4 |
2609 | align 4 |
2621 | .fin: |
2610 | .fin: |
2622 | ret |
2611 | ret |
2623 | ;------------------------------------------------------------------------------ |
2612 | ;------------------------------------------------------------------------------ |
2624 | align 4 |
2613 | align 4 |
2625 | nosb5: |
2614 | nosb5: |
2626 | cmp ebx, 6 |
2615 | cmp ebx, 6 |
2627 | jnz nosb6 |
2616 | jnz nosb6 |
2628 | ;-------------------------------------- |
2617 | ;-------------------------------------- |
2629 | align 4 |
2618 | align 4 |
2630 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2619 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2631 | @@: |
2620 | @@: |
2632 | bts dword [bgrlock], 0 |
2621 | bts dword [bgrlock], 0 |
2633 | jnc @f |
2622 | jnc @f |
2634 | call change_task |
2623 | call change_task |
2635 | jmp @b |
2624 | jmp @b |
2636 | ;-------------------------------------- |
2625 | ;-------------------------------------- |
2637 | align 4 |
2626 | align 4 |
2638 | @@: |
2627 | @@: |
2639 | mov eax, [CURRENT_TASK] |
2628 | mov eax, [CURRENT_TASK] |
2640 | mov [bgrlockpid], eax |
2629 | mov [bgrlockpid], eax |
2641 | cmp [img_background], static_background_data |
2630 | cmp [img_background], static_background_data |
2642 | jz .nomem |
2631 | jz .nomem |
2643 | stdcall user_alloc, [mem_BACKGROUND] |
2632 | stdcall user_alloc, [mem_BACKGROUND] |
2644 | mov [esp+32], eax |
2633 | mov [esp+32], eax |
2645 | test eax, eax |
2634 | test eax, eax |
2646 | jz .nomem |
2635 | jz .nomem |
2647 | mov ebx, eax |
2636 | mov ebx, eax |
2648 | shr ebx, 12 |
2637 | shr ebx, 12 |
2649 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2638 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2650 | mov esi, [img_background] |
2639 | mov esi, [img_background] |
2651 | shr esi, 12 |
2640 | shr esi, 12 |
2652 | mov ecx, [mem_BACKGROUND] |
2641 | mov ecx, [mem_BACKGROUND] |
2653 | add ecx, 0xFFF |
2642 | add ecx, 0xFFF |
2654 | shr ecx, 12 |
2643 | shr ecx, 12 |
2655 | ;-------------------------------------- |
2644 | ;-------------------------------------- |
2656 | align 4 |
2645 | align 4 |
2657 | .z: |
2646 | .z: |
2658 | mov eax, [page_tabs+ebx*4] |
2647 | mov eax, [page_tabs+ebx*4] |
2659 | test al, 1 |
2648 | test al, 1 |
2660 | jz @f |
2649 | jz @f |
2661 | call free_page |
2650 | call free_page |
2662 | ;-------------------------------------- |
2651 | ;-------------------------------------- |
2663 | align 4 |
2652 | align 4 |
2664 | @@: |
2653 | @@: |
2665 | mov eax, [page_tabs+esi*4] |
2654 | mov eax, [page_tabs+esi*4] |
2666 | or al, PG_UW |
2655 | or al, PG_UW |
2667 | mov [page_tabs+ebx*4], eax |
2656 | mov [page_tabs+ebx*4], eax |
2668 | mov eax, ebx |
2657 | mov eax, ebx |
2669 | shl eax, 12 |
2658 | shl eax, 12 |
2670 | invlpg [eax] |
2659 | invlpg [eax] |
2671 | inc ebx |
2660 | inc ebx |
2672 | inc esi |
2661 | inc esi |
2673 | loop .z |
2662 | loop .z |
2674 | ret |
2663 | ret |
2675 | ;-------------------------------------- |
2664 | ;-------------------------------------- |
2676 | align 4 |
2665 | align 4 |
2677 | .nomem: |
2666 | .nomem: |
2678 | and [bgrlockpid], 0 |
2667 | and [bgrlockpid], 0 |
2679 | mov [bgrlock], 0 |
2668 | mov [bgrlock], 0 |
2680 | ;------------------------------------------------------------------------------ |
2669 | ;------------------------------------------------------------------------------ |
2681 | align 4 |
2670 | align 4 |
2682 | nosb6: |
2671 | nosb6: |
2683 | cmp ebx, 7 |
2672 | cmp ebx, 7 |
2684 | jnz nosb7 |
2673 | jnz nosb7 |
2685 | cmp [bgrlock], 0 |
2674 | cmp [bgrlock], 0 |
2686 | jz .err |
2675 | jz .err |
2687 | mov eax, [CURRENT_TASK] |
2676 | mov eax, [CURRENT_TASK] |
2688 | cmp [bgrlockpid], eax |
2677 | cmp [bgrlockpid], eax |
2689 | jnz .err |
2678 | jnz .err |
2690 | mov eax, ecx |
2679 | mov eax, ecx |
2691 | mov ebx, ecx |
2680 | mov ebx, ecx |
2692 | shr eax, 12 |
2681 | shr eax, 12 |
2693 | mov ecx, [page_tabs+(eax-1)*4] |
2682 | mov ecx, [page_tabs+(eax-1)*4] |
2694 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2683 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2695 | jz .err |
2684 | jz .err |
2696 | jnp .err |
2685 | jnp .err |
2697 | push eax |
2686 | push eax |
2698 | shr ecx, 12 |
2687 | shr ecx, 12 |
2699 | dec ecx |
2688 | dec ecx |
2700 | ;-------------------------------------- |
2689 | ;-------------------------------------- |
2701 | align 4 |
2690 | align 4 |
2702 | @@: |
2691 | @@: |
2703 | and dword [page_tabs+eax*4], 0 |
2692 | and dword [page_tabs+eax*4], 0 |
2704 | mov edx, eax |
2693 | mov edx, eax |
2705 | shl edx, 12 |
2694 | shl edx, 12 |
2706 | push eax |
2695 | push eax |
2707 | invlpg [edx] |
2696 | invlpg [edx] |
2708 | pop eax |
2697 | pop eax |
2709 | inc eax |
2698 | inc eax |
2710 | loop @b |
2699 | loop @b |
2711 | pop eax |
2700 | pop eax |
2712 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2701 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2713 | stdcall user_free, ebx |
2702 | stdcall user_free, ebx |
2714 | mov [esp+32], eax |
2703 | mov [esp+32], eax |
2715 | and [bgrlockpid], 0 |
2704 | and [bgrlockpid], 0 |
2716 | mov [bgrlock], 0 |
2705 | mov [bgrlock], 0 |
2717 | ret |
2706 | ret |
2718 | ;-------------------------------------- |
2707 | ;-------------------------------------- |
2719 | align 4 |
2708 | align 4 |
2720 | .err: |
2709 | .err: |
2721 | and dword [esp+32], 0 |
2710 | and dword [esp+32], 0 |
2722 | ret |
2711 | ret |
2723 | ;------------------------------------------------------------------------------ |
2712 | ;------------------------------------------------------------------------------ |
2724 | align 4 |
2713 | align 4 |
2725 | nosb7: |
2714 | nosb7: |
2726 | cmp ebx, 8 |
2715 | cmp ebx, 8 |
2727 | jnz nosb8 |
2716 | jnz nosb8 |
2728 | 2717 | ||
2729 | mov ecx, [current_slot] |
2718 | mov ecx, [current_slot] |
2730 | xor eax, eax |
2719 | xor eax, eax |
2731 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2720 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2732 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2721 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2733 | xor eax, eax |
2722 | xor eax, eax |
2734 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2723 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2735 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2724 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2736 | ret |
2725 | ret |
2737 | ;------------------------------------------------------------------------------ |
2726 | ;------------------------------------------------------------------------------ |
2738 | align 4 |
2727 | align 4 |
2739 | nosb8: |
2728 | nosb8: |
2740 | cmp ebx, 9 |
2729 | cmp ebx, 9 |
2741 | jnz nosb9 |
2730 | jnz nosb9 |
2742 | ; ecx = [left]*65536 + [right] |
2731 | ; ecx = [left]*65536 + [right] |
2743 | ; edx = [top]*65536 + [bottom] |
2732 | ; edx = [top]*65536 + [bottom] |
2744 | mov eax, [Screen_Max_X] |
2733 | mov eax, [Screen_Max_X] |
2745 | mov ebx, [Screen_Max_Y] |
2734 | mov ebx, [Screen_Max_Y] |
2746 | ; check [right] |
2735 | ; check [right] |
2747 | cmp cx, ax |
2736 | cmp cx, ax |
2748 | ja .exit |
2737 | ja .exit |
2749 | ; check [left] |
2738 | ; check [left] |
2750 | ror ecx, 16 |
2739 | ror ecx, 16 |
2751 | cmp cx, ax |
2740 | cmp cx, ax |
2752 | ja .exit |
2741 | ja .exit |
2753 | ; check [bottom] |
2742 | ; check [bottom] |
2754 | cmp dx, bx |
2743 | cmp dx, bx |
2755 | ja .exit |
2744 | ja .exit |
2756 | ; check [top] |
2745 | ; check [top] |
2757 | ror edx, 16 |
2746 | ror edx, 16 |
2758 | cmp dx, bx |
2747 | cmp dx, bx |
2759 | ja .exit |
2748 | ja .exit |
2760 | 2749 | ||
2761 | movzx eax, cx ; [left] |
2750 | movzx eax, cx ; [left] |
2762 | movzx ebx, dx ; [top] |
2751 | movzx ebx, dx ; [top] |
2763 | 2752 | ||
2764 | shr ecx, 16 ; [right] |
2753 | shr ecx, 16 ; [right] |
2765 | shr edx, 16 ; [bottom] |
2754 | shr edx, 16 ; [bottom] |
2766 | 2755 | ||
2767 | mov [background_defined], 1 |
2756 | mov [background_defined], 1 |
2768 | 2757 | ||
2769 | mov [draw_data+32 + RECT.left], eax |
2758 | mov [draw_data+32 + RECT.left], eax |
2770 | mov [draw_data+32 + RECT.top], ebx |
2759 | mov [draw_data+32 + RECT.top], ebx |
2771 | 2760 | ||
2772 | mov [draw_data+32 + RECT.right], ecx |
2761 | mov [draw_data+32 + RECT.right], ecx |
2773 | mov [draw_data+32 + RECT.bottom], edx |
2762 | mov [draw_data+32 + RECT.bottom], edx |
2774 | 2763 | ||
2775 | inc byte[REDRAW_BACKGROUND] |
2764 | inc byte[REDRAW_BACKGROUND] |
2776 | call wakeup_osloop |
2765 | call wakeup_osloop |
2777 | ;-------------------------------------- |
2766 | ;-------------------------------------- |
2778 | align 4 |
2767 | align 4 |
2779 | .exit: |
2768 | .exit: |
2780 | ret |
2769 | ret |
2781 | ;------------------------------------------------------------------------------ |
2770 | ;------------------------------------------------------------------------------ |
2782 | align 4 |
2771 | align 4 |
2783 | nosb9: |
2772 | nosb9: |
2784 | ret |
2773 | ret |
2785 | ;------------------------------------------------------------------------------ |
2774 | ;------------------------------------------------------------------------------ |
2786 | align 4 |
2775 | align 4 |
2787 | uglobal |
2776 | uglobal |
2788 | BG_Rect_X_left_right dd 0x0 |
2777 | BG_Rect_X_left_right dd 0x0 |
2789 | BG_Rect_Y_top_bottom dd 0x0 |
2778 | BG_Rect_Y_top_bottom dd 0x0 |
2790 | endg |
2779 | endg |
2791 | ;------------------------------------------------------------------------------ |
2780 | ;------------------------------------------------------------------------------ |
2792 | align 4 |
2781 | align 4 |
2793 | force_redraw_background: |
2782 | force_redraw_background: |
2794 | and [draw_data+32 + RECT.left], 0 |
2783 | and [draw_data+32 + RECT.left], 0 |
2795 | and [draw_data+32 + RECT.top], 0 |
2784 | and [draw_data+32 + RECT.top], 0 |
2796 | push eax ebx |
2785 | push eax ebx |
2797 | mov eax, [Screen_Max_X] |
2786 | mov eax, [Screen_Max_X] |
2798 | mov ebx, [Screen_Max_Y] |
2787 | mov ebx, [Screen_Max_Y] |
2799 | mov [draw_data+32 + RECT.right], eax |
2788 | mov [draw_data+32 + RECT.right], eax |
2800 | mov [draw_data+32 + RECT.bottom], ebx |
2789 | mov [draw_data+32 + RECT.bottom], ebx |
2801 | pop ebx eax |
2790 | pop ebx eax |
2802 | inc byte[REDRAW_BACKGROUND] |
2791 | inc byte[REDRAW_BACKGROUND] |
2803 | call wakeup_osloop |
2792 | call wakeup_osloop |
2804 | ret |
2793 | ret |
2805 | ;------------------------------------------------------------------------------ |
2794 | ;------------------------------------------------------------------------------ |
2806 | align 4 |
2795 | align 4 |
2807 | sys_getbackground: |
2796 | sys_getbackground: |
2808 | ; cmp eax,1 ; SIZE |
2797 | ; cmp eax,1 ; SIZE |
2809 | dec ebx |
2798 | dec ebx |
2810 | jnz nogb1 |
2799 | jnz nogb1 |
2811 | mov eax, [BgrDataWidth] |
2800 | mov eax, [BgrDataWidth] |
2812 | shl eax, 16 |
2801 | shl eax, 16 |
2813 | mov ax, word [BgrDataHeight] |
2802 | mov ax, word [BgrDataHeight] |
2814 | mov [esp+32], eax |
2803 | mov [esp+32], eax |
2815 | ret |
2804 | ret |
2816 | ;------------------------------------------------------------------------------ |
2805 | ;------------------------------------------------------------------------------ |
2817 | align 4 |
2806 | align 4 |
2818 | nogb1: |
2807 | nogb1: |
2819 | ; cmp eax,2 ; PIXEL |
2808 | ; cmp eax,2 ; PIXEL |
2820 | dec ebx |
2809 | dec ebx |
2821 | jnz nogb2 |
2810 | jnz nogb2 |
2822 | 2811 | ||
2823 | mov eax, [img_background] |
2812 | mov eax, [img_background] |
2824 | test ecx, ecx |
2813 | test ecx, ecx |
2825 | jz @f |
2814 | jz @f |
2826 | cmp eax, static_background_data |
2815 | cmp eax, static_background_data |
2827 | jz .ret |
2816 | jz .ret |
2828 | ;-------------------------------------- |
2817 | ;-------------------------------------- |
2829 | align 4 |
2818 | align 4 |
2830 | @@: |
2819 | @@: |
2831 | mov ebx, [mem_BACKGROUND] |
2820 | mov ebx, [mem_BACKGROUND] |
2832 | add ebx, 4095 |
2821 | add ebx, 4095 |
2833 | and ebx, -4096 |
2822 | and ebx, -4096 |
2834 | sub ebx, 4 |
2823 | sub ebx, 4 |
2835 | cmp ecx, ebx |
2824 | cmp ecx, ebx |
2836 | ja .ret |
2825 | ja .ret |
2837 | 2826 | ||
2838 | mov eax, [ecx+eax] |
2827 | mov eax, [ecx+eax] |
2839 | 2828 | ||
2840 | and eax, 0xFFFFFF |
2829 | and eax, 0xFFFFFF |
2841 | mov [esp+32], eax |
2830 | mov [esp+32], eax |
2842 | ;-------------------------------------- |
2831 | ;-------------------------------------- |
2843 | align 4 |
2832 | align 4 |
2844 | .ret: |
2833 | .ret: |
2845 | ret |
2834 | ret |
2846 | ;------------------------------------------------------------------------------ |
2835 | ;------------------------------------------------------------------------------ |
2847 | align 4 |
2836 | align 4 |
2848 | nogb2: |
2837 | nogb2: |
2849 | 2838 | ||
2850 | ; cmp eax,4 ; TILED / STRETCHED |
2839 | ; cmp eax,4 ; TILED / STRETCHED |
2851 | dec ebx |
2840 | dec ebx |
2852 | dec ebx |
2841 | dec ebx |
2853 | jnz nogb4 |
2842 | jnz nogb4 |
2854 | mov eax, [BgrDrawMode] |
2843 | mov eax, [BgrDrawMode] |
2855 | ;-------------------------------------- |
2844 | ;-------------------------------------- |
2856 | align 4 |
2845 | align 4 |
2857 | nogb4: |
2846 | nogb4: |
2858 | mov [esp+32], eax |
2847 | mov [esp+32], eax |
2859 | ret |
2848 | ret |
2860 | ;------------------------------------------------------------------------------ |
2849 | ;------------------------------------------------------------------------------ |
2861 | align 4 |
2850 | align 4 |
2862 | sys_getkey: |
2851 | sys_getkey: |
2863 | mov [esp + 32], dword 1 |
2852 | mov [esp + 32], dword 1 |
2864 | ; test main buffer |
2853 | ; test main buffer |
2865 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2854 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2866 | movzx ecx, word [WIN_STACK + ebx * 2] |
2855 | movzx ecx, word [WIN_STACK + ebx * 2] |
2867 | mov edx, [TASK_COUNT] |
2856 | mov edx, [TASK_COUNT] |
2868 | cmp ecx, edx |
2857 | cmp ecx, edx |
2869 | jne .finish |
2858 | jne .finish |
2870 | cmp [KEY_COUNT], byte 0 |
2859 | cmp [KEY_COUNT], byte 0 |
2871 | je .finish |
2860 | je .finish |
2872 | movzx ax, byte [KEY_BUFF + 120 + 2] |
2861 | movzx ax, byte [KEY_BUFF + 120 + 2] |
2873 | shl eax, 8 |
2862 | shl eax, 8 |
2874 | mov al, byte [KEY_BUFF] |
2863 | mov al, byte [KEY_BUFF] |
2875 | shl eax, 8 |
2864 | shl eax, 8 |
2876 | push eax |
2865 | push eax |
2877 | dec byte [KEY_COUNT] |
2866 | dec byte [KEY_COUNT] |
2878 | and byte [KEY_COUNT], 127 |
2867 | and byte [KEY_COUNT], 127 |
2879 | movzx ecx, byte [KEY_COUNT] |
2868 | movzx ecx, byte [KEY_COUNT] |
2880 | add ecx, 2 |
2869 | add ecx, 2 |
2881 | mov eax, KEY_BUFF + 1 |
2870 | mov eax, KEY_BUFF + 1 |
2882 | mov ebx, KEY_BUFF |
2871 | mov ebx, KEY_BUFF |
2883 | call memmove |
2872 | call memmove |
2884 | add eax, 120 + 2 |
2873 | add eax, 120 + 2 |
2885 | add ebx, 120 + 2 |
2874 | add ebx, 120 + 2 |
2886 | call memmove |
2875 | call memmove |
2887 | pop eax |
2876 | pop eax |
2888 | ;-------------------------------------- |
2877 | ;-------------------------------------- |
2889 | align 4 |
2878 | align 4 |
2890 | .ret_eax: |
2879 | .ret_eax: |
2891 | mov [esp + 32], eax |
2880 | mov [esp + 32], eax |
2892 | ret |
2881 | ret |
2893 | ;-------------------------------------- |
2882 | ;-------------------------------------- |
2894 | align 4 |
2883 | align 4 |
2895 | .finish: |
2884 | .finish: |
2896 | ; test hotkeys buffer |
2885 | ; test hotkeys buffer |
2897 | mov ecx, hotkey_buffer |
2886 | mov ecx, hotkey_buffer |
2898 | ;-------------------------------------- |
2887 | ;-------------------------------------- |
2899 | align 4 |
2888 | align 4 |
2900 | @@: |
2889 | @@: |
2901 | cmp [ecx], ebx |
2890 | cmp [ecx], ebx |
2902 | jz .found |
2891 | jz .found |
2903 | add ecx, 8 |
2892 | add ecx, 8 |
2904 | cmp ecx, hotkey_buffer + 120 * 8 |
2893 | cmp ecx, hotkey_buffer + 120 * 8 |
2905 | jb @b |
2894 | jb @b |
2906 | ret |
2895 | ret |
2907 | ;-------------------------------------- |
2896 | ;-------------------------------------- |
2908 | align 4 |
2897 | align 4 |
2909 | .found: |
2898 | .found: |
2910 | mov ax, [ecx + 6] |
2899 | mov ax, [ecx + 6] |
2911 | shl eax, 16 |
2900 | shl eax, 16 |
2912 | mov ah, [ecx + 4] |
2901 | mov ah, [ecx + 4] |
2913 | mov al, 2 |
2902 | mov al, 2 |
2914 | and dword [ecx + 4], 0 |
2903 | and dword [ecx + 4], 0 |
2915 | and dword [ecx], 0 |
2904 | and dword [ecx], 0 |
2916 | jmp .ret_eax |
2905 | jmp .ret_eax |
2917 | ;------------------------------------------------------------------------------ |
2906 | ;------------------------------------------------------------------------------ |
2918 | align 4 |
2907 | align 4 |
2919 | sys_getbutton: |
2908 | sys_getbutton: |
2920 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2909 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2921 | mov [esp + 32], dword 1 |
2910 | mov [esp + 32], dword 1 |
2922 | movzx ecx, word [WIN_STACK + ebx * 2] |
2911 | movzx ecx, word [WIN_STACK + ebx * 2] |
2923 | mov edx, [TASK_COUNT] ; less than 256 processes |
2912 | mov edx, [TASK_COUNT] ; less than 256 processes |
2924 | cmp ecx, edx |
2913 | cmp ecx, edx |
2925 | jne .exit |
2914 | jne .exit |
2926 | movzx eax, byte [BTN_COUNT] |
2915 | movzx eax, byte [BTN_COUNT] |
2927 | test eax, eax |
2916 | test eax, eax |
2928 | jz .exit |
2917 | jz .exit |
2929 | mov eax, [BTN_BUFF] |
2918 | mov eax, [BTN_BUFF] |
2930 | and al, 0xFE ; delete left button bit |
2919 | and al, 0xFE ; delete left button bit |
2931 | mov [BTN_COUNT], byte 0 |
2920 | mov [BTN_COUNT], byte 0 |
2932 | mov [esp + 32], eax |
2921 | mov [esp + 32], eax |
2933 | ;-------------------------------------- |
2922 | ;-------------------------------------- |
2934 | align 4 |
2923 | align 4 |
2935 | .exit: |
2924 | .exit: |
2936 | ret |
2925 | ret |
2937 | ;------------------------------------------------------------------------------ |
2926 | ;------------------------------------------------------------------------------ |
2938 | align 4 |
2927 | align 4 |
2939 | sys_cpuusage: |
2928 | sys_cpuusage: |
2940 | 2929 | ||
2941 | ; RETURN: |
2930 | ; RETURN: |
2942 | ; |
2931 | ; |
2943 | ; +00 dword process cpu usage |
2932 | ; +00 dword process cpu usage |
2944 | ; +04 word position in windowing stack |
2933 | ; +04 word position in windowing stack |
2945 | ; +06 word windowing stack value at current position (cpu nro) |
2934 | ; +06 word windowing stack value at current position (cpu nro) |
2946 | ; +10 12 bytes name |
2935 | ; +10 12 bytes name |
2947 | ; +22 dword start in mem |
2936 | ; +22 dword start in mem |
2948 | ; +26 dword used mem |
2937 | ; +26 dword used mem |
2949 | ; +30 dword PID , process idenfification number |
2938 | ; +30 dword PID , process idenfification number |
2950 | ; |
2939 | ; |
2951 | 2940 | ||
2952 | cmp ecx, -1 ; who am I ? |
2941 | cmp ecx, -1 ; who am I ? |
2953 | jne .no_who_am_i |
2942 | jne .no_who_am_i |
2954 | mov ecx, [CURRENT_TASK] |
2943 | mov ecx, [CURRENT_TASK] |
2955 | .no_who_am_i: |
2944 | .no_who_am_i: |
2956 | cmp ecx, max_processes |
2945 | cmp ecx, max_processes |
2957 | ja .nofillbuf |
2946 | ja .nofillbuf |
2958 | 2947 | ||
2959 | ; +4: word: position of the window of thread in the window stack |
2948 | ; +4: word: position of the window of thread in the window stack |
2960 | mov ax, [WIN_STACK + ecx * 2] |
2949 | mov ax, [WIN_STACK + ecx * 2] |
2961 | mov [ebx+4], ax |
2950 | mov [ebx+4], ax |
2962 | ; +6: word: number of the thread slot, which window has in the window stack |
2951 | ; +6: word: number of the thread slot, which window has in the window stack |
2963 | ; position ecx (has no relation to the specific thread) |
2952 | ; position ecx (has no relation to the specific thread) |
2964 | mov ax, [WIN_POS + ecx * 2] |
2953 | mov ax, [WIN_POS + ecx * 2] |
2965 | mov [ebx+6], ax |
2954 | mov [ebx+6], ax |
2966 | 2955 | ||
2967 | shl ecx, 5 |
2956 | shl ecx, 5 |
2968 | 2957 | ||
2969 | ; +0: dword: memory usage |
2958 | ; +0: dword: memory usage |
2970 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2959 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2971 | mov [ebx], eax |
2960 | mov [ebx], eax |
2972 | ; +10: 11 bytes: name of the process |
2961 | ; +10: 11 bytes: name of the process |
2973 | push ecx |
2962 | push ecx |
2974 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
2963 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
2975 | add ebx, 10 |
2964 | add ebx, 10 |
2976 | mov ecx, 11 |
2965 | mov ecx, 11 |
2977 | call memmove |
2966 | call memmove |
2978 | pop ecx |
2967 | pop ecx |
2979 | 2968 | ||
2980 | ; +22: address of the process in memory |
2969 | ; +22: address of the process in memory |
2981 | ; +26: size of used memory - 1 |
2970 | ; +26: size of used memory - 1 |
2982 | push edi |
2971 | push edi |
2983 | lea edi, [ebx+12] |
2972 | lea edi, [ebx+12] |
2984 | xor eax, eax |
2973 | xor eax, eax |
2985 | mov edx, 0x100000*16 |
2974 | mov edx, 0x100000*16 |
2986 | cmp ecx, 1 shl 5 |
2975 | cmp ecx, 1 shl 5 |
2987 | je .os_mem |
2976 | je .os_mem |
2988 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
2977 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
2989 | mov eax, std_application_base_address |
2978 | mov eax, std_application_base_address |
2990 | .os_mem: |
2979 | .os_mem: |
2991 | stosd |
2980 | stosd |
2992 | lea eax, [edx-1] |
2981 | lea eax, [edx-1] |
2993 | stosd |
2982 | stosd |
2994 | 2983 | ||
2995 | ; +30: PID/TID |
2984 | ; +30: PID/TID |
2996 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2985 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2997 | stosd |
2986 | stosd |
2998 | 2987 | ||
2999 | ; window position and size |
2988 | ; window position and size |
3000 | push esi |
2989 | push esi |
3001 | lea esi, [ecx + window_data + WDATA.box] |
2990 | lea esi, [ecx + window_data + WDATA.box] |
3002 | movsd |
2991 | movsd |
3003 | movsd |
2992 | movsd |
3004 | movsd |
2993 | movsd |
3005 | movsd |
2994 | movsd |
3006 | 2995 | ||
3007 | ; Process state (+50) |
2996 | ; Process state (+50) |
3008 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
2997 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3009 | stosd |
2998 | stosd |
3010 | 2999 | ||
3011 | ; Window client area box |
3000 | ; Window client area box |
3012 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3001 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3013 | movsd |
3002 | movsd |
3014 | movsd |
3003 | movsd |
3015 | movsd |
3004 | movsd |
3016 | movsd |
3005 | movsd |
3017 | 3006 | ||
3018 | ; Window state |
3007 | ; Window state |
3019 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3008 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3020 | stosb |
3009 | stosb |
3021 | 3010 | ||
3022 | ; Event mask (+71) |
3011 | ; Event mask (+71) |
3023 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3012 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3024 | stosd |
3013 | stosd |
3025 | 3014 | ||
3026 | ; Keyboard mode (+75) |
3015 | ; Keyboard mode (+75) |
3027 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3016 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3028 | stosb |
3017 | stosb |
3029 | 3018 | ||
3030 | pop esi |
3019 | pop esi |
3031 | pop edi |
3020 | pop edi |
3032 | 3021 | ||
3033 | .nofillbuf: |
3022 | .nofillbuf: |
3034 | ; return number of processes |
3023 | ; return number of processes |
3035 | 3024 | ||
3036 | mov eax, [TASK_COUNT] |
3025 | mov eax, [TASK_COUNT] |
3037 | mov [esp+32], eax |
3026 | mov [esp+32], eax |
3038 | ret |
3027 | ret |
3039 | 3028 | ||
3040 | align 4 |
3029 | align 4 |
3041 | sys_clock: |
3030 | sys_clock: |
3042 | cli |
3031 | cli |
3043 | ; Mikhail Lisovin xx Jan 2005 |
3032 | ; Mikhail Lisovin xx Jan 2005 |
3044 | @@: |
3033 | @@: |
3045 | mov al, 10 |
3034 | mov al, 10 |
3046 | out 0x70, al |
3035 | out 0x70, al |
3047 | in al, 0x71 |
3036 | in al, 0x71 |
3048 | test al, al |
3037 | test al, al |
3049 | jns @f |
3038 | jns @f |
3050 | mov esi, 1 |
3039 | mov esi, 1 |
3051 | call delay_ms |
3040 | call delay_ms |
3052 | jmp @b |
3041 | jmp @b |
3053 | @@: |
3042 | @@: |
3054 | ; end Lisovin's fix |
3043 | ; end Lisovin's fix |
3055 | 3044 | ||
3056 | xor al, al ; seconds |
3045 | xor al, al ; seconds |
3057 | out 0x70, al |
3046 | out 0x70, al |
3058 | in al, 0x71 |
3047 | in al, 0x71 |
3059 | movzx ecx, al |
3048 | movzx ecx, al |
3060 | mov al, 02 ; minutes |
3049 | mov al, 02 ; minutes |
3061 | shl ecx, 16 |
3050 | shl ecx, 16 |
3062 | out 0x70, al |
3051 | out 0x70, al |
3063 | in al, 0x71 |
3052 | in al, 0x71 |
3064 | movzx edx, al |
3053 | movzx edx, al |
3065 | mov al, 04 ; hours |
3054 | mov al, 04 ; hours |
3066 | shl edx, 8 |
3055 | shl edx, 8 |
3067 | out 0x70, al |
3056 | out 0x70, al |
3068 | in al, 0x71 |
3057 | in al, 0x71 |
3069 | add ecx, edx |
3058 | add ecx, edx |
3070 | movzx edx, al |
3059 | movzx edx, al |
3071 | add ecx, edx |
3060 | add ecx, edx |
3072 | sti |
3061 | sti |
3073 | mov [esp + 32], ecx |
3062 | mov [esp + 32], ecx |
3074 | ret |
3063 | ret |
3075 | 3064 | ||
3076 | 3065 | ||
3077 | align 4 |
3066 | align 4 |
3078 | 3067 | ||
3079 | sys_date: |
3068 | sys_date: |
3080 | 3069 | ||
3081 | cli |
3070 | cli |
3082 | @@: |
3071 | @@: |
3083 | mov al, 10 |
3072 | mov al, 10 |
3084 | out 0x70, al |
3073 | out 0x70, al |
3085 | in al, 0x71 |
3074 | in al, 0x71 |
3086 | test al, al |
3075 | test al, al |
3087 | jns @f |
3076 | jns @f |
3088 | mov esi, 1 |
3077 | mov esi, 1 |
3089 | call delay_ms |
3078 | call delay_ms |
3090 | jmp @b |
3079 | jmp @b |
3091 | @@: |
3080 | @@: |
3092 | 3081 | ||
3093 | mov ch, 0 |
3082 | mov ch, 0 |
3094 | mov al, 7 ; date |
3083 | mov al, 7 ; date |
3095 | out 0x70, al |
3084 | out 0x70, al |
3096 | in al, 0x71 |
3085 | in al, 0x71 |
3097 | mov cl, al |
3086 | mov cl, al |
3098 | mov al, 8 ; month |
3087 | mov al, 8 ; month |
3099 | shl ecx, 16 |
3088 | shl ecx, 16 |
3100 | out 0x70, al |
3089 | out 0x70, al |
3101 | in al, 0x71 |
3090 | in al, 0x71 |
3102 | mov ch, al |
3091 | mov ch, al |
3103 | mov al, 9 ; year |
3092 | mov al, 9 ; year |
3104 | out 0x70, al |
3093 | out 0x70, al |
3105 | in al, 0x71 |
3094 | in al, 0x71 |
3106 | mov cl, al |
3095 | mov cl, al |
3107 | sti |
3096 | sti |
3108 | mov [esp+32], ecx |
3097 | mov [esp+32], ecx |
3109 | ret |
3098 | ret |
3110 | 3099 | ||
3111 | 3100 | ||
3112 | ; redraw status |
3101 | ; redraw status |
3113 | 3102 | ||
3114 | sys_redrawstat: |
3103 | sys_redrawstat: |
3115 | cmp ebx, 1 |
3104 | cmp ebx, 1 |
3116 | jne no_widgets_away |
3105 | jne no_widgets_away |
3117 | ; buttons away |
3106 | ; buttons away |
3118 | mov ecx, [CURRENT_TASK] |
3107 | mov ecx, [CURRENT_TASK] |
3119 | sys_newba2: |
3108 | sys_newba2: |
3120 | mov edi, [BTN_ADDR] |
3109 | mov edi, [BTN_ADDR] |
3121 | cmp [edi], dword 0 ; empty button list ? |
3110 | cmp [edi], dword 0 ; empty button list ? |
3122 | je end_of_buttons_away |
3111 | je end_of_buttons_away |
3123 | movzx ebx, word [edi] |
3112 | movzx ebx, word [edi] |
3124 | inc ebx |
3113 | inc ebx |
3125 | mov eax, edi |
3114 | mov eax, edi |
3126 | sys_newba: |
3115 | sys_newba: |
3127 | dec ebx |
3116 | dec ebx |
3128 | jz end_of_buttons_away |
3117 | jz end_of_buttons_away |
3129 | 3118 | ||
3130 | add eax, 0x10 |
3119 | add eax, 0x10 |
3131 | cmp cx, [eax] |
3120 | cmp cx, [eax] |
3132 | jnz sys_newba |
3121 | jnz sys_newba |
3133 | 3122 | ||
3134 | push eax ebx ecx |
3123 | push eax ebx ecx |
3135 | mov ecx, ebx |
3124 | mov ecx, ebx |
3136 | inc ecx |
3125 | inc ecx |
3137 | shl ecx, 4 |
3126 | shl ecx, 4 |
3138 | mov ebx, eax |
3127 | mov ebx, eax |
3139 | add eax, 0x10 |
3128 | add eax, 0x10 |
3140 | call memmove |
3129 | call memmove |
3141 | dec dword [edi] |
3130 | dec dword [edi] |
3142 | pop ecx ebx eax |
3131 | pop ecx ebx eax |
3143 | 3132 | ||
3144 | jmp sys_newba2 |
3133 | jmp sys_newba2 |
3145 | 3134 | ||
3146 | end_of_buttons_away: |
3135 | end_of_buttons_away: |
3147 | 3136 | ||
3148 | ret |
3137 | ret |
3149 | 3138 | ||
3150 | no_widgets_away: |
3139 | no_widgets_away: |
3151 | 3140 | ||
3152 | cmp ebx, 2 |
3141 | cmp ebx, 2 |
3153 | jnz srl1 |
3142 | jnz srl1 |
3154 | 3143 | ||
3155 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3144 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3156 | add edx, draw_data - CURRENT_TASK |
3145 | add edx, draw_data - CURRENT_TASK |
3157 | mov [edx + RECT.left], 0 |
3146 | mov [edx + RECT.left], 0 |
3158 | mov [edx + RECT.top], 0 |
3147 | mov [edx + RECT.top], 0 |
3159 | mov eax, [Screen_Max_X] |
3148 | mov eax, [Screen_Max_X] |
3160 | mov [edx + RECT.right], eax |
3149 | mov [edx + RECT.right], eax |
3161 | mov eax, [Screen_Max_Y] |
3150 | mov eax, [Screen_Max_Y] |
3162 | mov [edx + RECT.bottom], eax |
3151 | mov [edx + RECT.bottom], eax |
3163 | 3152 | ||
3164 | srl1: |
3153 | srl1: |
3165 | ret |
3154 | ret |
3166 | 3155 | ||
3167 | ;ok - 100% work |
3156 | ;ok - 100% work |
3168 | ;nt - not tested |
3157 | ;nt - not tested |
3169 | ;--------------------------------------------------------------------------------------------- |
3158 | ;--------------------------------------------------------------------------------------------- |
3170 | ;eax |
3159 | ;eax |
3171 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3160 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3172 | ;1 - change task. Ret nothing. Block. ok. |
3161 | ;1 - change task. Ret nothing. Block. ok. |
3173 | ;2 - performance control |
3162 | ;2 - performance control |
3174 | ; ebx |
3163 | ; ebx |
3175 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3164 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3176 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3165 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3177 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3166 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3178 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3167 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3179 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3168 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3180 | ;eax |
3169 | ;eax |
3181 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3170 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3182 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3171 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3183 | ;--------------------------------------------------------------------------------------------- |
3172 | ;--------------------------------------------------------------------------------------------- |
3184 | iglobal |
3173 | iglobal |
3185 | align 4 |
3174 | align 4 |
3186 | sheduler: |
3175 | sheduler: |
3187 | dd sys_sheduler.00 |
3176 | dd sys_sheduler.00 |
3188 | dd change_task |
3177 | dd change_task |
3189 | dd sys_sheduler.02 |
3178 | dd sys_sheduler.02 |
3190 | dd sys_sheduler.03 |
3179 | dd sys_sheduler.03 |
3191 | dd sys_sheduler.04 |
3180 | dd sys_sheduler.04 |
3192 | endg |
3181 | endg |
3193 | sys_sheduler: |
3182 | sys_sheduler: |
3194 | ;rewritten by |
3183 | ;rewritten by |
3195 | jmp dword [sheduler+ebx*4] |
3184 | jmp dword [sheduler+ebx*4] |
3196 | ;.shed_counter: |
3185 | ;.shed_counter: |
3197 | .00: |
3186 | .00: |
3198 | mov eax, [context_counter] |
3187 | mov eax, [context_counter] |
3199 | mov [esp+32], eax |
3188 | mov [esp+32], eax |
3200 | ret |
3189 | ret |
3201 | 3190 | ||
3202 | .02: |
3191 | .02: |
3203 | ;.perf_control: |
3192 | ;.perf_control: |
3204 | inc ebx ;before ebx=2, ebx=3 |
3193 | inc ebx ;before ebx=2, ebx=3 |
3205 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3194 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3206 | jz cache_disable |
3195 | jz cache_disable |
3207 | 3196 | ||
3208 | dec ebx ;ebx=2 |
3197 | dec ebx ;ebx=2 |
3209 | cmp ebx, ecx ; |
3198 | cmp ebx, ecx ; |
3210 | jz cache_enable ;if ecx=2 and ebx=2 |
3199 | jz cache_enable ;if ecx=2 and ebx=2 |
3211 | 3200 | ||
3212 | dec ebx ;ebx=1 |
3201 | dec ebx ;ebx=1 |
3213 | cmp ebx, ecx |
3202 | cmp ebx, ecx |
3214 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3203 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3215 | 3204 | ||
3216 | dec ebx |
3205 | dec ebx |
3217 | test ebx, ecx ;ebx=0 and ecx=0 |
3206 | test ebx, ecx ;ebx=0 and ecx=0 |
3218 | jz modify_pce ;if ecx=0 |
3207 | jz modify_pce ;if ecx=0 |
3219 | 3208 | ||
3220 | ret |
3209 | ret |
3221 | 3210 | ||
3222 | .03: |
3211 | .03: |
3223 | ;.rdmsr_instr: |
3212 | ;.rdmsr_instr: |
3224 | ;now counter in ecx |
3213 | ;now counter in ecx |
3225 | ;(edx:eax) esi:edi => edx:esi |
3214 | ;(edx:eax) esi:edi => edx:esi |
3226 | mov eax, esi |
3215 | mov eax, esi |
3227 | mov ecx, edx |
3216 | mov ecx, edx |
3228 | rdmsr |
3217 | rdmsr |
3229 | mov [esp+32], eax |
3218 | mov [esp+32], eax |
3230 | mov [esp+20], edx ;ret in ebx? |
3219 | mov [esp+20], edx ;ret in ebx? |
3231 | ret |
3220 | ret |
3232 | 3221 | ||
3233 | .04: |
3222 | .04: |
3234 | ;.wrmsr_instr: |
3223 | ;.wrmsr_instr: |
3235 | ;now counter in ecx |
3224 | ;now counter in ecx |
3236 | ;(edx:eax) esi:edi => edx:esi |
3225 | ;(edx:eax) esi:edi => edx:esi |
3237 | ; Fast Call MSR can't be destroy |
3226 | ; Fast Call MSR can't be destroy |
3238 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3227 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3239 | ; включаются/выключаются расширенные возможности |
3228 | ; включаются/выключаются расширенные возможности |
3240 | cmp edx, MSR_SYSENTER_CS |
3229 | cmp edx, MSR_SYSENTER_CS |
3241 | je @f |
3230 | je @f |
3242 | cmp edx, MSR_SYSENTER_ESP |
3231 | cmp edx, MSR_SYSENTER_ESP |
3243 | je @f |
3232 | je @f |
3244 | cmp edx, MSR_SYSENTER_EIP |
3233 | cmp edx, MSR_SYSENTER_EIP |
3245 | je @f |
3234 | je @f |
3246 | cmp edx, MSR_AMD_STAR |
3235 | cmp edx, MSR_AMD_STAR |
3247 | je @f |
3236 | je @f |
3248 | 3237 | ||
3249 | mov eax, esi |
3238 | mov eax, esi |
3250 | mov ecx, edx |
3239 | mov ecx, edx |
3251 | wrmsr |
3240 | wrmsr |
3252 | ; mov [esp + 32], eax |
3241 | ; mov [esp + 32], eax |
3253 | ; mov [esp + 20], edx ;ret in ebx? |
3242 | ; mov [esp + 20], edx ;ret in ebx? |
3254 | @@: |
3243 | @@: |
3255 | ret |
3244 | ret |
3256 | 3245 | ||
3257 | cache_disable: |
3246 | cache_disable: |
3258 | mov eax, cr0 |
3247 | mov eax, cr0 |
3259 | or eax, 01100000000000000000000000000000b |
3248 | or eax, 01100000000000000000000000000000b |
3260 | mov cr0, eax |
3249 | mov cr0, eax |
3261 | wbinvd ;set MESI |
3250 | wbinvd ;set MESI |
3262 | ret |
3251 | ret |
3263 | 3252 | ||
3264 | cache_enable: |
3253 | cache_enable: |
3265 | mov eax, cr0 |
3254 | mov eax, cr0 |
3266 | and eax, 10011111111111111111111111111111b |
3255 | and eax, 10011111111111111111111111111111b |
3267 | mov cr0, eax |
3256 | mov cr0, eax |
3268 | ret |
3257 | ret |
3269 | 3258 | ||
3270 | is_cache_enabled: |
3259 | is_cache_enabled: |
3271 | mov eax, cr0 |
3260 | mov eax, cr0 |
3272 | mov ebx, eax |
3261 | mov ebx, eax |
3273 | and eax, 01100000000000000000000000000000b |
3262 | and eax, 01100000000000000000000000000000b |
3274 | jz cache_disabled |
3263 | jz cache_disabled |
3275 | mov [esp+32], ebx |
3264 | mov [esp+32], ebx |
3276 | cache_disabled: |
3265 | cache_disabled: |
3277 | mov dword [esp+32], eax;0 |
3266 | mov dword [esp+32], eax;0 |
3278 | ret |
3267 | ret |
3279 | 3268 | ||
3280 | modify_pce: |
3269 | modify_pce: |
3281 | mov eax, cr4 |
3270 | mov eax, cr4 |
3282 | ; mov ebx,0 |
3271 | ; mov ebx,0 |
3283 | ; or bx,100000000b ;pce |
3272 | ; or bx,100000000b ;pce |
3284 | ; xor eax,ebx ;invert pce |
3273 | ; xor eax,ebx ;invert pce |
3285 | bts eax, 8;pce=cr4[8] |
3274 | bts eax, 8;pce=cr4[8] |
3286 | mov cr4, eax |
3275 | mov cr4, eax |
3287 | mov [esp+32], eax |
3276 | mov [esp+32], eax |
3288 | ret |
3277 | ret |
3289 | ;--------------------------------------------------------------------------------------------- |
3278 | ;--------------------------------------------------------------------------------------------- |
3290 | 3279 | ||
3291 | 3280 | ||
3292 | ; check if pixel is allowed to be drawn |
3281 | ; check if pixel is allowed to be drawn |
3293 | 3282 | ||
3294 | ;checkpixel: |
3283 | ;checkpixel: |
3295 | ; push eax edx |
3284 | ; push eax edx |
3296 | 3285 | ||
3297 | ;; mov edx, [Screen_Max_X] ; screen x size |
3286 | ;; mov edx, [Screen_Max_X] ; screen x size |
3298 | ;; inc edx |
3287 | ;; inc edx |
3299 | ;; imul edx, ebx |
3288 | ;; imul edx, ebx |
3300 | ; mov edx, [d_width_calc_area + ebx*4] |
3289 | ; mov edx, [d_width_calc_area + ebx*4] |
3301 | ; add eax, [_WinMapAddress] |
3290 | ; add eax, [_WinMapAddress] |
3302 | ; mov dl, [eax+edx]; lea eax, [...] |
3291 | ; mov dl, [eax+edx]; lea eax, [...] |
3303 | 3292 | ||
3304 | ; xor ecx, ecx |
3293 | ; xor ecx, ecx |
3305 | ; mov eax, [CURRENT_TASK] |
3294 | ; mov eax, [CURRENT_TASK] |
3306 | ; cmp al, dl |
3295 | ; cmp al, dl |
3307 | ; setne cl |
3296 | ; setne cl |
3308 | 3297 | ||
3309 | ; pop edx eax |
3298 | ; pop edx eax |
3310 | ; ret |
3299 | ; ret |
3311 | 3300 | ||
3312 | iglobal |
3301 | iglobal |
3313 | cpustring db 'CPU',0 |
3302 | cpustring db 'CPU',0 |
3314 | endg |
3303 | endg |
3315 | 3304 | ||
3316 | uglobal |
3305 | uglobal |
3317 | background_defined db 0 ; diamond, 11.04.2006 |
3306 | background_defined db 0 ; diamond, 11.04.2006 |
3318 | endg |
3307 | endg |
3319 | ;----------------------------------------------------------------------------- |
3308 | ;----------------------------------------------------------------------------- |
3320 | align 4 |
3309 | align 4 |
3321 | checkmisc: |
3310 | checkmisc: |
3322 | cmp [ctrl_alt_del], 1 |
3311 | cmp [ctrl_alt_del], 1 |
3323 | jne nocpustart |
3312 | jne nocpustart |
3324 | 3313 | ||
3325 | mov ebp, cpustring |
3314 | mov ebp, cpustring |
3326 | call fs_execute_from_sysdir |
3315 | call fs_execute_from_sysdir |
3327 | 3316 | ||
3328 | mov [ctrl_alt_del], 0 |
3317 | mov [ctrl_alt_del], 0 |
3329 | ;-------------------------------------- |
3318 | ;-------------------------------------- |
3330 | align 4 |
3319 | align 4 |
3331 | nocpustart: |
3320 | nocpustart: |
3332 | cmp [mouse_active], 1 |
3321 | cmp [mouse_active], 1 |
3333 | jne mouse_not_active |
3322 | jne mouse_not_active |
3334 | mov [mouse_active], 0 |
3323 | mov [mouse_active], 0 |
3335 | 3324 | ||
3336 | xor edi, edi |
3325 | xor edi, edi |
3337 | mov ebx, CURRENT_TASK |
3326 | mov ebx, CURRENT_TASK |
3338 | 3327 | ||
3339 | mov ecx, [TASK_COUNT] |
3328 | mov ecx, [TASK_COUNT] |
3340 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3329 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3341 | shl eax, 8 |
3330 | shl eax, 8 |
3342 | push eax |
3331 | push eax |
3343 | 3332 | ||
3344 | movzx eax, word [MOUSE_X] |
3333 | movzx eax, word [MOUSE_X] |
3345 | movzx edx, word [MOUSE_Y] |
3334 | movzx edx, word [MOUSE_Y] |
3346 | ;-------------------------------------- |
3335 | ;-------------------------------------- |
3347 | align 4 |
3336 | align 4 |
3348 | .set_mouse_event: |
3337 | .set_mouse_event: |
3349 | add edi, 256 |
3338 | add edi, 256 |
3350 | add ebx, 32 |
3339 | add ebx, 32 |
3351 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3340 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3352 | jz .pos_filter |
3341 | jz .pos_filter |
3353 | 3342 | ||
3354 | cmp edi, [esp] ; skip if filtration active |
3343 | cmp edi, [esp] ; skip if filtration active |
3355 | jne .skip |
3344 | jne .skip |
3356 | ;-------------------------------------- |
3345 | ;-------------------------------------- |
3357 | align 4 |
3346 | align 4 |
3358 | .pos_filter: |
3347 | .pos_filter: |
3359 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3348 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3360 | jz .set |
3349 | jz .set |
3361 | 3350 | ||
3362 | mov esi, [ebx-twdw+WDATA.box.left] |
3351 | mov esi, [ebx-twdw+WDATA.box.left] |
3363 | cmp eax, esi |
3352 | cmp eax, esi |
3364 | jb .skip |
3353 | jb .skip |
3365 | add esi, [ebx-twdw+WDATA.box.width] |
3354 | add esi, [ebx-twdw+WDATA.box.width] |
3366 | cmp eax, esi |
3355 | cmp eax, esi |
3367 | ja .skip |
3356 | ja .skip |
3368 | 3357 | ||
3369 | mov esi, [ebx-twdw+WDATA.box.top] |
3358 | mov esi, [ebx-twdw+WDATA.box.top] |
3370 | cmp edx, esi |
3359 | cmp edx, esi |
3371 | jb .skip |
3360 | jb .skip |
3372 | add esi, [ebx-twdw+WDATA.box.height] |
3361 | add esi, [ebx-twdw+WDATA.box.height] |
3373 | cmp edx, esi |
3362 | cmp edx, esi |
3374 | ja .skip |
3363 | ja .skip |
3375 | ;-------------------------------------- |
3364 | ;-------------------------------------- |
3376 | align 4 |
3365 | align 4 |
3377 | .set: |
3366 | .set: |
3378 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3367 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3379 | ;-------------------------------------- |
3368 | ;-------------------------------------- |
3380 | align 4 |
3369 | align 4 |
3381 | .skip: |
3370 | .skip: |
3382 | loop .set_mouse_event |
3371 | loop .set_mouse_event |
3383 | 3372 | ||
3384 | pop eax |
3373 | pop eax |
3385 | ;-------------------------------------- |
3374 | ;-------------------------------------- |
3386 | align 4 |
3375 | align 4 |
3387 | mouse_not_active: |
3376 | mouse_not_active: |
3388 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3377 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3389 | jz nobackgr |
3378 | jz nobackgr |
3390 | 3379 | ||
3391 | cmp [background_defined], 0 |
3380 | cmp [background_defined], 0 |
3392 | jz nobackgr |
3381 | jz nobackgr |
3393 | ;-------------------------------------- |
3382 | ;-------------------------------------- |
3394 | align 4 |
3383 | align 4 |
3395 | backgr: |
3384 | backgr: |
3396 | mov eax, [draw_data+32 + RECT.left] |
3385 | mov eax, [draw_data+32 + RECT.left] |
3397 | shl eax, 16 |
3386 | shl eax, 16 |
3398 | add eax, [draw_data+32 + RECT.right] |
3387 | add eax, [draw_data+32 + RECT.right] |
3399 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3388 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3400 | 3389 | ||
3401 | mov eax, [draw_data+32 + RECT.top] |
3390 | mov eax, [draw_data+32 + RECT.top] |
3402 | shl eax, 16 |
3391 | shl eax, 16 |
3403 | add eax, [draw_data+32 + RECT.bottom] |
3392 | add eax, [draw_data+32 + RECT.bottom] |
3404 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3393 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3405 | 3394 | ||
3406 | call drawbackground |
3395 | call drawbackground |
3407 | ; DEBUGF 1, "K : drawbackground\n" |
3396 | ; DEBUGF 1, "K : drawbackground\n" |
3408 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3397 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3409 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3398 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3410 | ;--------- set event 5 start ---------- |
3399 | ;--------- set event 5 start ---------- |
3411 | push ecx edi |
3400 | push ecx edi |
3412 | xor edi, edi |
3401 | xor edi, edi |
3413 | mov ecx, [TASK_COUNT] |
3402 | mov ecx, [TASK_COUNT] |
3414 | ;-------------------------------------- |
3403 | ;-------------------------------------- |
3415 | align 4 |
3404 | align 4 |
3416 | set_bgr_event: |
3405 | set_bgr_event: |
3417 | add edi, 256 |
3406 | add edi, 256 |
3418 | mov eax, [BG_Rect_X_left_right] |
3407 | mov eax, [BG_Rect_X_left_right] |
3419 | mov edx, [BG_Rect_Y_top_bottom] |
3408 | mov edx, [BG_Rect_Y_top_bottom] |
3420 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3409 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3421 | jz .set |
3410 | jz .set |
3422 | .join: |
3411 | .join: |
3423 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3412 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3424 | jae @f |
3413 | jae @f |
3425 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3414 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3426 | @@: |
3415 | @@: |
3427 | shr eax, 16 |
3416 | shr eax, 16 |
3428 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3417 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3429 | jbe @f |
3418 | jbe @f |
3430 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3419 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3431 | @@: |
3420 | @@: |
3432 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3421 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3433 | jae @f |
3422 | jae @f |
3434 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3423 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3435 | @@: |
3424 | @@: |
3436 | shr edx, 16 |
3425 | shr edx, 16 |
3437 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3426 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3438 | jbe @f |
3427 | jbe @f |
3439 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3428 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3440 | @@: |
3429 | @@: |
3441 | jmp .common |
3430 | jmp .common |
3442 | .set: |
3431 | .set: |
3443 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3432 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3444 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3433 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3445 | .common: |
3434 | .common: |
3446 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3435 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3447 | loop set_bgr_event |
3436 | loop set_bgr_event |
3448 | pop edi ecx |
3437 | pop edi ecx |
3449 | ;--------- set event 5 stop ----------- |
3438 | ;--------- set event 5 stop ----------- |
3450 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3439 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3451 | jnz backgr |
3440 | jnz backgr |
3452 | 3441 | ||
3453 | xor eax, eax |
3442 | xor eax, eax |
3454 | mov [draw_data+32 + RECT.left], eax |
3443 | mov [draw_data+32 + RECT.left], eax |
3455 | mov [draw_data+32 + RECT.top], eax |
3444 | mov [draw_data+32 + RECT.top], eax |
3456 | mov [draw_data+32 + RECT.right], eax |
3445 | mov [draw_data+32 + RECT.right], eax |
3457 | mov [draw_data+32 + RECT.bottom], eax |
3446 | mov [draw_data+32 + RECT.bottom], eax |
3458 | ;-------------------------------------- |
3447 | ;-------------------------------------- |
3459 | align 4 |
3448 | align 4 |
3460 | nobackgr: |
3449 | nobackgr: |
3461 | ; system shutdown request |
3450 | ; system shutdown request |
3462 | cmp [SYS_SHUTDOWN], byte 0 |
3451 | cmp [SYS_SHUTDOWN], byte 0 |
3463 | je noshutdown |
3452 | je noshutdown |
3464 | 3453 | ||
3465 | mov edx, [shutdown_processes] |
3454 | mov edx, [shutdown_processes] |
3466 | 3455 | ||
3467 | cmp [SYS_SHUTDOWN], dl |
3456 | cmp [SYS_SHUTDOWN], dl |
3468 | jne noshutdown |
3457 | jne noshutdown |
3469 | 3458 | ||
3470 | lea ecx, [edx-1] |
3459 | lea ecx, [edx-1] |
3471 | mov edx, OS_BASE+0x3040 |
3460 | mov edx, OS_BASE+0x3040 |
3472 | jecxz no_mark_system_shutdown |
3461 | jecxz no_mark_system_shutdown |
3473 | ;-------------------------------------- |
3462 | ;-------------------------------------- |
3474 | align 4 |
3463 | align 4 |
3475 | markz: |
3464 | markz: |
3476 | push ecx edx |
3465 | push ecx edx |
3477 | cmp [edx+TASKDATA.state], 9 |
3466 | cmp [edx+TASKDATA.state], 9 |
3478 | jz .nokill |
3467 | jz .nokill |
3479 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3468 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3480 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3469 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3481 | jz .nokill |
3470 | jz .nokill |
3482 | call request_terminate |
3471 | call request_terminate |
3483 | jmp .common |
3472 | jmp .common |
3484 | .nokill: |
3473 | .nokill: |
3485 | dec byte [SYS_SHUTDOWN] |
3474 | dec byte [SYS_SHUTDOWN] |
3486 | xor eax, eax |
3475 | xor eax, eax |
3487 | .common: |
3476 | .common: |
3488 | pop edx ecx |
3477 | pop edx ecx |
3489 | test eax, eax |
3478 | test eax, eax |
3490 | jz @f |
3479 | jz @f |
3491 | mov [edx+TASKDATA.state], byte 3 |
3480 | mov [edx+TASKDATA.state], byte 3 |
3492 | @@: |
3481 | @@: |
3493 | add edx, 0x20 |
3482 | add edx, 0x20 |
3494 | loop markz |
3483 | loop markz |
3495 | call wakeup_osloop |
3484 | call wakeup_osloop |
3496 | ;-------------------------------------- |
3485 | ;-------------------------------------- |
3497 | align 4 |
3486 | align 4 |
3498 | @@: |
3487 | @@: |
3499 | no_mark_system_shutdown: |
3488 | no_mark_system_shutdown: |
3500 | dec byte [SYS_SHUTDOWN] |
3489 | dec byte [SYS_SHUTDOWN] |
3501 | je system_shutdown |
3490 | je system_shutdown |
3502 | ;-------------------------------------- |
3491 | ;-------------------------------------- |
3503 | align 4 |
3492 | align 4 |
3504 | noshutdown: |
3493 | noshutdown: |
3505 | mov eax, [TASK_COUNT] ; termination |
3494 | mov eax, [TASK_COUNT] ; termination |
3506 | mov ebx, TASK_DATA+TASKDATA.state |
3495 | mov ebx, TASK_DATA+TASKDATA.state |
3507 | mov esi, 1 |
3496 | mov esi, 1 |
3508 | ;-------------------------------------- |
3497 | ;-------------------------------------- |
3509 | align 4 |
3498 | align 4 |
3510 | newct: |
3499 | newct: |
3511 | mov cl, [ebx] |
3500 | mov cl, [ebx] |
3512 | cmp cl, byte 3 |
3501 | cmp cl, byte 3 |
3513 | jz .terminate |
3502 | jz .terminate |
3514 | 3503 | ||
3515 | cmp cl, byte 4 |
3504 | cmp cl, byte 4 |
3516 | jnz .noterminate |
3505 | jnz .noterminate |
3517 | .terminate: |
3506 | .terminate: |
3518 | pushad |
3507 | pushad |
3519 | mov ecx, eax |
3508 | mov ecx, eax |
3520 | shl ecx, 8 |
3509 | shl ecx, 8 |
3521 | add ecx, SLOT_BASE |
3510 | add ecx, SLOT_BASE |
3522 | call restore_default_cursor_before_killing |
3511 | call restore_default_cursor_before_killing |
3523 | popad |
3512 | popad |
3524 | 3513 | ||
3525 | pushad |
3514 | pushad |
3526 | call terminate |
3515 | call terminate |
3527 | popad |
3516 | popad |
3528 | cmp byte [SYS_SHUTDOWN], 0 |
3517 | cmp byte [SYS_SHUTDOWN], 0 |
3529 | jz .noterminate |
3518 | jz .noterminate |
3530 | dec byte [SYS_SHUTDOWN] |
3519 | dec byte [SYS_SHUTDOWN] |
3531 | je system_shutdown |
3520 | je system_shutdown |
3532 | 3521 | ||
3533 | .noterminate: |
3522 | .noterminate: |
3534 | add ebx, 0x20 |
3523 | add ebx, 0x20 |
3535 | inc esi |
3524 | inc esi |
3536 | dec eax |
3525 | dec eax |
3537 | jnz newct |
3526 | jnz newct |
3538 | ret |
3527 | ret |
3539 | ;----------------------------------------------------------------------------- |
3528 | ;----------------------------------------------------------------------------- |
3540 | align 4 |
3529 | align 4 |
3541 | redrawscreen: |
3530 | redrawscreen: |
3542 | ; eax , if process window_data base is eax, do not set flag/limits |
3531 | ; eax , if process window_data base is eax, do not set flag/limits |
3543 | 3532 | ||
3544 | pushad |
3533 | pushad |
3545 | push eax |
3534 | push eax |
3546 | 3535 | ||
3547 | ;;; mov ebx,2 |
3536 | ;;; mov ebx,2 |
3548 | ;;; call delay_hs |
3537 | ;;; call delay_hs |
3549 | 3538 | ||
3550 | ;mov ecx,0 ; redraw flags for apps |
3539 | ;mov ecx,0 ; redraw flags for apps |
3551 | xor ecx, ecx |
3540 | xor ecx, ecx |
3552 | ;-------------------------------------- |
3541 | ;-------------------------------------- |
3553 | align 4 |
3542 | align 4 |
3554 | newdw2: |
3543 | newdw2: |
3555 | inc ecx |
3544 | inc ecx |
3556 | push ecx |
3545 | push ecx |
3557 | 3546 | ||
3558 | mov eax, ecx |
3547 | mov eax, ecx |
3559 | shl eax, 5 |
3548 | shl eax, 5 |
3560 | add eax, window_data |
3549 | add eax, window_data |
3561 | 3550 | ||
3562 | cmp eax, [esp+4] |
3551 | cmp eax, [esp+4] |
3563 | je not_this_task |
3552 | je not_this_task |
3564 | ; check if window in redraw area |
3553 | ; check if window in redraw area |
3565 | mov edi, eax |
3554 | mov edi, eax |
3566 | 3555 | ||
3567 | cmp ecx, 1 ; limit for background |
3556 | cmp ecx, 1 ; limit for background |
3568 | jz bgli |
3557 | jz bgli |
3569 | 3558 | ||
3570 | mov eax, [edi + WDATA.box.left] |
3559 | mov eax, [edi + WDATA.box.left] |
3571 | mov ebx, [edi + WDATA.box.top] |
3560 | mov ebx, [edi + WDATA.box.top] |
3572 | 3561 | ||
3573 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3562 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3574 | cmp ecx, ebx |
3563 | cmp ecx, ebx |
3575 | jb ricino |
3564 | jb ricino |
3576 | 3565 | ||
3577 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3566 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3578 | cmp ecx, eax |
3567 | cmp ecx, eax |
3579 | jb ricino |
3568 | jb ricino |
3580 | 3569 | ||
3581 | mov eax, [edi + WDATA.box.left] |
3570 | mov eax, [edi + WDATA.box.left] |
3582 | mov ebx, [edi + WDATA.box.top] |
3571 | mov ebx, [edi + WDATA.box.top] |
3583 | mov ecx, [edi + WDATA.box.width] |
3572 | mov ecx, [edi + WDATA.box.width] |
3584 | mov edx, [edi + WDATA.box.height] |
3573 | mov edx, [edi + WDATA.box.height] |
3585 | add ecx, eax |
3574 | add ecx, eax |
3586 | add edx, ebx |
3575 | add edx, ebx |
3587 | 3576 | ||
3588 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3577 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3589 | cmp edx, eax |
3578 | cmp edx, eax |
3590 | jb ricino |
3579 | jb ricino |
3591 | 3580 | ||
3592 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3581 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3593 | cmp ecx, eax |
3582 | cmp ecx, eax |
3594 | jb ricino |
3583 | jb ricino |
3595 | ;-------------------------------------- |
3584 | ;-------------------------------------- |
3596 | align 4 |
3585 | align 4 |
3597 | bgli: |
3586 | bgli: |
3598 | cmp dword[esp], 1 |
3587 | cmp dword[esp], 1 |
3599 | jnz .az |
3588 | jnz .az |
3600 | 3589 | ||
3601 | cmp byte[REDRAW_BACKGROUND], 0 |
3590 | cmp byte[REDRAW_BACKGROUND], 0 |
3602 | jz .az |
3591 | jz .az |
3603 | 3592 | ||
3604 | mov dl, 0 |
3593 | mov dl, 0 |
3605 | lea eax, [edi+draw_data-window_data] |
3594 | lea eax, [edi+draw_data-window_data] |
3606 | mov ebx, [draw_limits.left] |
3595 | mov ebx, [draw_limits.left] |
3607 | cmp ebx, [eax+RECT.left] |
3596 | cmp ebx, [eax+RECT.left] |
3608 | jae @f |
3597 | jae @f |
3609 | 3598 | ||
3610 | mov [eax+RECT.left], ebx |
3599 | mov [eax+RECT.left], ebx |
3611 | mov dl, 1 |
3600 | mov dl, 1 |
3612 | ;-------------------------------------- |
3601 | ;-------------------------------------- |
3613 | align 4 |
3602 | align 4 |
3614 | @@: |
3603 | @@: |
3615 | mov ebx, [draw_limits.top] |
3604 | mov ebx, [draw_limits.top] |
3616 | cmp ebx, [eax+RECT.top] |
3605 | cmp ebx, [eax+RECT.top] |
3617 | jae @f |
3606 | jae @f |
3618 | 3607 | ||
3619 | mov [eax+RECT.top], ebx |
3608 | mov [eax+RECT.top], ebx |
3620 | mov dl, 1 |
3609 | mov dl, 1 |
3621 | ;-------------------------------------- |
3610 | ;-------------------------------------- |
3622 | align 4 |
3611 | align 4 |
3623 | @@: |
3612 | @@: |
3624 | mov ebx, [draw_limits.right] |
3613 | mov ebx, [draw_limits.right] |
3625 | cmp ebx, [eax+RECT.right] |
3614 | cmp ebx, [eax+RECT.right] |
3626 | jbe @f |
3615 | jbe @f |
3627 | 3616 | ||
3628 | mov [eax+RECT.right], ebx |
3617 | mov [eax+RECT.right], ebx |
3629 | mov dl, 1 |
3618 | mov dl, 1 |
3630 | ;-------------------------------------- |
3619 | ;-------------------------------------- |
3631 | align 4 |
3620 | align 4 |
3632 | @@: |
3621 | @@: |
3633 | mov ebx, [draw_limits.bottom] |
3622 | mov ebx, [draw_limits.bottom] |
3634 | cmp ebx, [eax+RECT.bottom] |
3623 | cmp ebx, [eax+RECT.bottom] |
3635 | jbe @f |
3624 | jbe @f |
3636 | 3625 | ||
3637 | mov [eax+RECT.bottom], ebx |
3626 | mov [eax+RECT.bottom], ebx |
3638 | mov dl, 1 |
3627 | mov dl, 1 |
3639 | ;-------------------------------------- |
3628 | ;-------------------------------------- |
3640 | align 4 |
3629 | align 4 |
3641 | @@: |
3630 | @@: |
3642 | add byte[REDRAW_BACKGROUND], dl |
3631 | add byte[REDRAW_BACKGROUND], dl |
3643 | call wakeup_osloop |
3632 | call wakeup_osloop |
3644 | jmp newdw8 |
3633 | jmp newdw8 |
3645 | ;-------------------------------------- |
3634 | ;-------------------------------------- |
3646 | align 4 |
3635 | align 4 |
3647 | .az: |
3636 | .az: |
3648 | mov eax, edi |
3637 | mov eax, edi |
3649 | add eax, draw_data-window_data |
3638 | add eax, draw_data-window_data |
3650 | 3639 | ||
3651 | mov ebx, [draw_limits.left] ; set limits |
3640 | mov ebx, [draw_limits.left] ; set limits |
3652 | mov [eax + RECT.left], ebx |
3641 | mov [eax + RECT.left], ebx |
3653 | mov ebx, [draw_limits.top] |
3642 | mov ebx, [draw_limits.top] |
3654 | mov [eax + RECT.top], ebx |
3643 | mov [eax + RECT.top], ebx |
3655 | mov ebx, [draw_limits.right] |
3644 | mov ebx, [draw_limits.right] |
3656 | mov [eax + RECT.right], ebx |
3645 | mov [eax + RECT.right], ebx |
3657 | mov ebx, [draw_limits.bottom] |
3646 | mov ebx, [draw_limits.bottom] |
3658 | mov [eax + RECT.bottom], ebx |
3647 | mov [eax + RECT.bottom], ebx |
3659 | 3648 | ||
3660 | sub eax, draw_data-window_data |
3649 | sub eax, draw_data-window_data |
3661 | 3650 | ||
3662 | cmp dword [esp], 1 |
3651 | cmp dword [esp], 1 |
3663 | jne nobgrd |
3652 | jne nobgrd |
3664 | inc byte[REDRAW_BACKGROUND] |
3653 | inc byte[REDRAW_BACKGROUND] |
3665 | call wakeup_osloop |
3654 | call wakeup_osloop |
3666 | ;-------------------------------------- |
3655 | ;-------------------------------------- |
3667 | align 4 |
3656 | align 4 |
3668 | newdw8: |
3657 | newdw8: |
3669 | nobgrd: |
3658 | nobgrd: |
3670 | ;-------------------------------------- |
3659 | ;-------------------------------------- |
3671 | push eax edi ebp |
3660 | push eax edi ebp |
3672 | mov edi, [esp+12] |
3661 | mov edi, [esp+12] |
3673 | cmp edi, 1 |
3662 | cmp edi, 1 |
3674 | je .found |
3663 | je .found |
3675 | 3664 | ||
3676 | mov eax, [draw_limits.left] |
3665 | mov eax, [draw_limits.left] |
3677 | mov ebx, [draw_limits.top] |
3666 | mov ebx, [draw_limits.top] |
3678 | mov ecx, [draw_limits.right] |
3667 | mov ecx, [draw_limits.right] |
3679 | sub ecx, eax |
3668 | sub ecx, eax |
3680 | test ecx, ecx |
3669 | test ecx, ecx |
3681 | jz .not_found |
3670 | jz .not_found |
3682 | 3671 | ||
3683 | mov edx, [draw_limits.bottom] |
3672 | mov edx, [draw_limits.bottom] |
3684 | sub edx, ebx |
3673 | sub edx, ebx |
3685 | test edx, edx |
3674 | test edx, edx |
3686 | jz .not_found |
3675 | jz .not_found |
3687 | 3676 | ||
3688 | ; eax - x, ebx - y |
3677 | ; eax - x, ebx - y |
3689 | ; ecx - size x, edx - size y |
3678 | ; ecx - size x, edx - size y |
3690 | add ebx, edx |
3679 | add ebx, edx |
3691 | ;-------------------------------------- |
3680 | ;-------------------------------------- |
3692 | align 4 |
3681 | align 4 |
3693 | .start_y: |
3682 | .start_y: |
3694 | push ecx |
3683 | push ecx |
3695 | ;-------------------------------------- |
3684 | ;-------------------------------------- |
3696 | align 4 |
3685 | align 4 |
3697 | .start_x: |
3686 | .start_x: |
3698 | add eax, ecx |
3687 | add eax, ecx |
3699 | mov ebp, [d_width_calc_area + ebx*4] |
3688 | mov ebp, [d_width_calc_area + ebx*4] |
3700 | add ebp, [_WinMapAddress] |
3689 | add ebp, [_WinMapAddress] |
3701 | movzx ebp, byte[eax+ebp] ; get value for current point |
3690 | movzx ebp, byte[eax+ebp] ; get value for current point |
3702 | cmp ebp, edi |
3691 | cmp ebp, edi |
3703 | jne @f |
3692 | jne @f |
3704 | 3693 | ||
3705 | pop ecx |
3694 | pop ecx |
3706 | jmp .found |
3695 | jmp .found |
3707 | ;-------------------------------------- |
3696 | ;-------------------------------------- |
3708 | align 4 |
3697 | align 4 |
3709 | @@: |
3698 | @@: |
3710 | sub eax, ecx |
3699 | sub eax, ecx |
3711 | 3700 | ||
3712 | dec ecx |
3701 | dec ecx |
3713 | jnz .start_x |
3702 | jnz .start_x |
3714 | 3703 | ||
3715 | pop ecx |
3704 | pop ecx |
3716 | dec ebx |
3705 | dec ebx |
3717 | dec edx |
3706 | dec edx |
3718 | jnz .start_y |
3707 | jnz .start_y |
3719 | ;-------------------------------------- |
3708 | ;-------------------------------------- |
3720 | align 4 |
3709 | align 4 |
3721 | .not_found: |
3710 | .not_found: |
3722 | pop ebp edi eax |
3711 | pop ebp edi eax |
3723 | jmp ricino |
3712 | jmp ricino |
3724 | ;-------------------------------------- |
3713 | ;-------------------------------------- |
3725 | align 4 |
3714 | align 4 |
3726 | .found: |
3715 | .found: |
3727 | pop ebp edi eax |
3716 | pop ebp edi eax |
3728 | 3717 | ||
3729 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3718 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3730 | ;-------------------------------------- |
3719 | ;-------------------------------------- |
3731 | align 4 |
3720 | align 4 |
3732 | ricino: |
3721 | ricino: |
3733 | not_this_task: |
3722 | not_this_task: |
3734 | pop ecx |
3723 | pop ecx |
3735 | 3724 | ||
3736 | cmp ecx, [TASK_COUNT] |
3725 | cmp ecx, [TASK_COUNT] |
3737 | jle newdw2 |
3726 | jle newdw2 |
3738 | 3727 | ||
3739 | pop eax |
3728 | pop eax |
3740 | popad |
3729 | popad |
3741 | ret |
3730 | ret |
3742 | ;----------------------------------------------------------------------------- |
3731 | ;----------------------------------------------------------------------------- |
3743 | align 4 |
3732 | align 4 |
3744 | calculatebackground: ; background |
3733 | calculatebackground: ; background |
3745 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3734 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3746 | mov eax, 0x01010101 |
3735 | mov eax, 0x01010101 |
3747 | mov ecx, [_WinMapSize] |
3736 | mov ecx, [_WinMapSize] |
3748 | shr ecx, 2 |
3737 | shr ecx, 2 |
3749 | rep stosd |
3738 | rep stosd |
3750 | 3739 | ||
3751 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3740 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3752 | ret |
3741 | ret |
3753 | ;----------------------------------------------------------------------------- |
3742 | ;----------------------------------------------------------------------------- |
3754 | uglobal |
3743 | uglobal |
3755 | imax dd 0x0 |
3744 | imax dd 0x0 |
3756 | endg |
3745 | endg |
3757 | ;----------------------------------------------------------------------------- |
3746 | ;----------------------------------------------------------------------------- |
3758 | align 4 |
3747 | align 4 |
3759 | delay_ms: ; delay in 1/1000 sec |
3748 | delay_ms: ; delay in 1/1000 sec |
3760 | push eax |
3749 | push eax |
3761 | push ecx |
3750 | push ecx |
3762 | 3751 | ||
3763 | mov ecx, esi |
3752 | mov ecx, esi |
3764 | ; |
3753 | ; |
3765 | imul ecx, 33941 |
3754 | imul ecx, 33941 |
3766 | shr ecx, 9 |
3755 | shr ecx, 9 |
3767 | ; |
3756 | ; |
3768 | 3757 | ||
3769 | in al, 0x61 |
3758 | in al, 0x61 |
3770 | and al, 0x10 |
3759 | and al, 0x10 |
3771 | mov ah, al |
3760 | mov ah, al |
3772 | cld |
3761 | cld |
3773 | ;-------------------------------------- |
3762 | ;-------------------------------------- |
3774 | align 4 |
3763 | align 4 |
3775 | cnt1: |
3764 | cnt1: |
3776 | in al, 0x61 |
3765 | in al, 0x61 |
3777 | and al, 0x10 |
3766 | and al, 0x10 |
3778 | cmp al, ah |
3767 | cmp al, ah |
3779 | jz cnt1 |
3768 | jz cnt1 |
3780 | 3769 | ||
3781 | mov ah, al |
3770 | mov ah, al |
3782 | loop cnt1 |
3771 | loop cnt1 |
3783 | 3772 | ||
3784 | pop ecx |
3773 | pop ecx |
3785 | pop eax |
3774 | pop eax |
3786 | ret |
3775 | ret |
3787 | ;----------------------------------------------------------------------------- |
3776 | ;----------------------------------------------------------------------------- |
3788 | align 4 |
3777 | align 4 |
3789 | set_app_param: |
3778 | set_app_param: |
3790 | mov edi, [TASK_BASE] |
3779 | mov edi, [TASK_BASE] |
3791 | mov eax, ebx |
3780 | mov eax, ebx |
3792 | btr eax, 3 ; move MOUSE_FILTRATION |
3781 | btr eax, 3 ; move MOUSE_FILTRATION |
3793 | mov ebx, [current_slot] ; bit into event_filter |
3782 | mov ebx, [current_slot] ; bit into event_filter |
3794 | setc byte [ebx+APPDATA.event_filter] |
3783 | setc byte [ebx+APPDATA.event_filter] |
3795 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3784 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3796 | mov [esp+32], eax ; return old mask value |
3785 | mov [esp+32], eax ; return old mask value |
3797 | ret |
3786 | ret |
3798 | ;----------------------------------------------------------------------------- |
3787 | ;----------------------------------------------------------------------------- |
3799 | 3788 | ||
3800 | ; this is for syscall |
3789 | ; this is for syscall |
3801 | proc delay_hs_unprotected |
3790 | proc delay_hs_unprotected |
3802 | call unprotect_from_terminate |
3791 | call unprotect_from_terminate |
3803 | call delay_hs |
3792 | call delay_hs |
3804 | call protect_from_terminate |
3793 | call protect_from_terminate |
3805 | ret |
3794 | ret |
3806 | endp |
3795 | endp |
3807 | 3796 | ||
3808 | if 1 |
3797 | if 1 |
3809 | align 4 |
3798 | align 4 |
3810 | delay_hs: ; delay in 1/100 secs |
3799 | delay_hs: ; delay in 1/100 secs |
3811 | ; ebx = delay time |
3800 | ; ebx = delay time |
3812 | 3801 | ||
3813 | pushad |
3802 | pushad |
3814 | push ebx |
3803 | push ebx |
3815 | xor esi, esi |
3804 | xor esi, esi |
3816 | mov ecx, MANUAL_DESTROY |
3805 | mov ecx, MANUAL_DESTROY |
3817 | call create_event |
3806 | call create_event |
3818 | test eax, eax |
3807 | test eax, eax |
3819 | jz .done |
3808 | jz .done |
3820 | 3809 | ||
3821 | mov ebx, edx |
3810 | mov ebx, edx |
3822 | mov ecx, [esp] |
3811 | mov ecx, [esp] |
3823 | push edx |
3812 | push edx |
3824 | push eax |
3813 | push eax |
3825 | call wait_event_timeout |
3814 | call wait_event_timeout |
3826 | pop eax |
3815 | pop eax |
3827 | pop ebx |
3816 | pop ebx |
3828 | call destroy_event |
3817 | call destroy_event |
3829 | .done: |
3818 | .done: |
3830 | add esp, 4 |
3819 | add esp, 4 |
3831 | popad |
3820 | popad |
3832 | ret |
3821 | ret |
3833 | 3822 | ||
3834 | else |
3823 | else |
3835 | 3824 | ||
3836 | align 4 |
3825 | align 4 |
3837 | delay_hs: ; delay in 1/100 secs |
3826 | delay_hs: ; delay in 1/100 secs |
3838 | ; ebx = delay time |
3827 | ; ebx = delay time |
3839 | push ecx |
3828 | push ecx |
3840 | push edx |
3829 | push edx |
3841 | 3830 | ||
3842 | mov edx, [timer_ticks] |
3831 | mov edx, [timer_ticks] |
3843 | ;-------------------------------------- |
3832 | ;-------------------------------------- |
3844 | align 4 |
3833 | align 4 |
3845 | newtic: |
3834 | newtic: |
3846 | mov ecx, [timer_ticks] |
3835 | mov ecx, [timer_ticks] |
3847 | sub ecx, edx |
3836 | sub ecx, edx |
3848 | cmp ecx, ebx |
3837 | cmp ecx, ebx |
3849 | jae zerodelay |
3838 | jae zerodelay |
3850 | 3839 | ||
3851 | call change_task |
3840 | call change_task |
3852 | 3841 | ||
3853 | jmp newtic |
3842 | jmp newtic |
3854 | ;-------------------------------------- |
3843 | ;-------------------------------------- |
3855 | align 4 |
3844 | align 4 |
3856 | zerodelay: |
3845 | zerodelay: |
3857 | pop edx |
3846 | pop edx |
3858 | pop ecx |
3847 | pop ecx |
3859 | ret |
3848 | ret |
3860 | end if |
3849 | end if |
3861 | 3850 | ||
3862 | ;----------------------------------------------------------------------------- |
3851 | ;----------------------------------------------------------------------------- |
3863 | align 16 ;very often call this subrutine |
3852 | align 16 ;very often call this subrutine |
3864 | memmove: ; memory move in bytes |
3853 | memmove: ; memory move in bytes |
3865 | ; eax = from |
3854 | ; eax = from |
3866 | ; ebx = to |
3855 | ; ebx = to |
3867 | ; ecx = no of bytes |
3856 | ; ecx = no of bytes |
3868 | test ecx, ecx |
3857 | test ecx, ecx |
3869 | jle .ret |
3858 | jle .ret |
3870 | 3859 | ||
3871 | push esi edi ecx |
3860 | push esi edi ecx |
3872 | 3861 | ||
3873 | mov edi, ebx |
3862 | mov edi, ebx |
3874 | mov esi, eax |
3863 | mov esi, eax |
3875 | 3864 | ||
3876 | test ecx, not 11b |
3865 | test ecx, not 11b |
3877 | jz @f |
3866 | jz @f |
3878 | 3867 | ||
3879 | push ecx |
3868 | push ecx |
3880 | shr ecx, 2 |
3869 | shr ecx, 2 |
3881 | rep movsd |
3870 | rep movsd |
3882 | pop ecx |
3871 | pop ecx |
3883 | and ecx, 11b |
3872 | and ecx, 11b |
3884 | jz .finish |
3873 | jz .finish |
3885 | ;-------------------------------------- |
3874 | ;-------------------------------------- |
3886 | align 4 |
3875 | align 4 |
3887 | @@: |
3876 | @@: |
3888 | rep movsb |
3877 | rep movsb |
3889 | ;-------------------------------------- |
3878 | ;-------------------------------------- |
3890 | align 4 |
3879 | align 4 |
3891 | .finish: |
3880 | .finish: |
3892 | pop ecx edi esi |
3881 | pop ecx edi esi |
3893 | ;-------------------------------------- |
3882 | ;-------------------------------------- |
3894 | align 4 |
3883 | align 4 |
3895 | .ret: |
3884 | .ret: |
3896 | ret |
3885 | ret |
3897 | ;----------------------------------------------------------------------------- |
3886 | ;----------------------------------------------------------------------------- |
3898 | ; |
3887 | ; |
3899 | ;align 4 |
3888 | ;align 4 |
3900 | ; |
3889 | ; |
3901 | ;read_floppy_file: |
3890 | ;read_floppy_file: |
3902 | ; |
3891 | ; |
3903 | ;; as input |
3892 | ;; as input |
3904 | ;; |
3893 | ;; |
3905 | ;; eax pointer to file |
3894 | ;; eax pointer to file |
3906 | ;; ebx file lenght |
3895 | ;; ebx file lenght |
3907 | ;; ecx start 512 byte block number |
3896 | ;; ecx start 512 byte block number |
3908 | ;; edx number of blocks to read |
3897 | ;; edx number of blocks to read |
3909 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3898 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3910 | ;; |
3899 | ;; |
3911 | ;; |
3900 | ;; |
3912 | ;; on return |
3901 | ;; on return |
3913 | ;; |
3902 | ;; |
3914 | ;; eax = 0 command succesful |
3903 | ;; eax = 0 command succesful |
3915 | ;; 1 no fd base and/or partition defined |
3904 | ;; 1 no fd base and/or partition defined |
3916 | ;; 2 yet unsupported FS |
3905 | ;; 2 yet unsupported FS |
3917 | ;; 3 unknown FS |
3906 | ;; 3 unknown FS |
3918 | ;; 4 partition not defined at hd |
3907 | ;; 4 partition not defined at hd |
3919 | ;; 5 file not found |
3908 | ;; 5 file not found |
3920 | ;; ebx = size of file |
3909 | ;; ebx = size of file |
3921 | ; |
3910 | ; |
3922 | ; mov edi,[TASK_BASE] |
3911 | ; mov edi,[TASK_BASE] |
3923 | ; add edi,0x10 |
3912 | ; add edi,0x10 |
3924 | ; add esi,[edi] |
3913 | ; add esi,[edi] |
3925 | ; add eax,[edi] |
3914 | ; add eax,[edi] |
3926 | ; |
3915 | ; |
3927 | ; pushad |
3916 | ; pushad |
3928 | ; mov edi,esi |
3917 | ; mov edi,esi |
3929 | ; add edi,1024 |
3918 | ; add edi,1024 |
3930 | ; mov esi,0x100000+19*512 |
3919 | ; mov esi,0x100000+19*512 |
3931 | ; sub ecx,1 |
3920 | ; sub ecx,1 |
3932 | ; shl ecx,9 |
3921 | ; shl ecx,9 |
3933 | ; add esi,ecx |
3922 | ; add esi,ecx |
3934 | ; shl edx,9 |
3923 | ; shl edx,9 |
3935 | ; mov ecx,edx |
3924 | ; mov ecx,edx |
3936 | ; cld |
3925 | ; cld |
3937 | ; rep movsb |
3926 | ; rep movsb |
3938 | ; popad |
3927 | ; popad |
3939 | ; |
3928 | ; |
3940 | ; mov [esp+36],eax |
3929 | ; mov [esp+36],eax |
3941 | ; mov [esp+24],ebx |
3930 | ; mov [esp+24],ebx |
3942 | ; ret |
3931 | ; ret |
3943 | 3932 | ||
3944 | 3933 | ||
3945 | 3934 | ||
3946 | align 4 |
3935 | align 4 |
3947 | set_io_access_rights: |
3936 | set_io_access_rights: |
3948 | push edi eax |
3937 | push edi eax |
3949 | mov edi, tss._io_map_0 |
3938 | mov edi, tss._io_map_0 |
3950 | ; mov ecx,eax |
3939 | ; mov ecx,eax |
3951 | ; and ecx,7 ; offset in byte |
3940 | ; and ecx,7 ; offset in byte |
3952 | ; shr eax,3 ; number of byte |
3941 | ; shr eax,3 ; number of byte |
3953 | ; add edi,eax |
3942 | ; add edi,eax |
3954 | ; mov ebx,1 |
3943 | ; mov ebx,1 |
3955 | ; shl ebx,cl |
3944 | ; shl ebx,cl |
3956 | test ebp, ebp |
3945 | test ebp, ebp |
3957 | ; cmp ebp,0 ; enable access - ebp = 0 |
3946 | ; cmp ebp,0 ; enable access - ebp = 0 |
3958 | jnz .siar1 |
3947 | jnz .siar1 |
3959 | ; not ebx |
3948 | ; not ebx |
3960 | ; and [edi],byte bl |
3949 | ; and [edi],byte bl |
3961 | btr [edi], eax |
3950 | btr [edi], eax |
3962 | pop eax edi |
3951 | pop eax edi |
3963 | ret |
3952 | ret |
3964 | .siar1: |
3953 | .siar1: |
3965 | bts [edi], eax |
3954 | bts [edi], eax |
3966 | ; or [edi],byte bl ; disable access - ebp = 1 |
3955 | ; or [edi],byte bl ; disable access - ebp = 1 |
3967 | pop eax edi |
3956 | pop eax edi |
3968 | ret |
3957 | ret |
3969 | ;reserve/free group of ports |
3958 | ;reserve/free group of ports |
3970 | ; * eax = 46 - number function |
3959 | ; * eax = 46 - number function |
3971 | ; * ebx = 0 - reserve, 1 - free |
3960 | ; * ebx = 0 - reserve, 1 - free |
3972 | ; * ecx = number start arrea of ports |
3961 | ; * ecx = number start arrea of ports |
3973 | ; * edx = number end arrea of ports (include last number of port) |
3962 | ; * edx = number end arrea of ports (include last number of port) |
3974 | ;Return value: |
3963 | ;Return value: |
3975 | ; * eax = 0 - succesful |
3964 | ; * eax = 0 - succesful |
3976 | ; * eax = 1 - error |
3965 | ; * eax = 1 - error |
3977 | ; * The system has reserve this ports: |
3966 | ; * The system has reserve this ports: |
3978 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3967 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3979 | ;destroys eax,ebx, ebp |
3968 | ;destroys eax,ebx, ebp |
3980 | r_f_port_area: |
3969 | r_f_port_area: |
3981 | 3970 | ||
3982 | test ebx, ebx |
3971 | test ebx, ebx |
3983 | jnz free_port_area |
3972 | jnz free_port_area |
3984 | ; je r_port_area |
3973 | ; je r_port_area |
3985 | ; jmp free_port_area |
3974 | ; jmp free_port_area |
3986 | 3975 | ||
3987 | ; r_port_area: |
3976 | ; r_port_area: |
3988 | 3977 | ||
3989 | ; pushad |
3978 | ; pushad |
3990 | 3979 | ||
3991 | cmp ecx, edx ; beginning > end ? |
3980 | cmp ecx, edx ; beginning > end ? |
3992 | ja rpal1 |
3981 | ja rpal1 |
3993 | cmp edx, 65536 |
3982 | cmp edx, 65536 |
3994 | jae rpal1 |
3983 | jae rpal1 |
3995 | mov eax, [RESERVED_PORTS] |
3984 | mov eax, [RESERVED_PORTS] |
3996 | test eax, eax ; no reserved areas ? |
3985 | test eax, eax ; no reserved areas ? |
3997 | je rpal2 |
3986 | je rpal2 |
3998 | cmp eax, 255 ; max reserved |
3987 | cmp eax, 255 ; max reserved |
3999 | jae rpal1 |
3988 | jae rpal1 |
4000 | rpal3: |
3989 | rpal3: |
4001 | mov ebx, eax |
3990 | mov ebx, eax |
4002 | shl ebx, 4 |
3991 | shl ebx, 4 |
4003 | add ebx, RESERVED_PORTS |
3992 | add ebx, RESERVED_PORTS |
4004 | cmp ecx, [ebx+8] |
3993 | cmp ecx, [ebx+8] |
4005 | ja rpal4 |
3994 | ja rpal4 |
4006 | cmp edx, [ebx+4] |
3995 | cmp edx, [ebx+4] |
4007 | jae rpal1 |
3996 | jae rpal1 |
4008 | ; jb rpal4 |
3997 | ; jb rpal4 |
4009 | ; jmp rpal1 |
3998 | ; jmp rpal1 |
4010 | rpal4: |
3999 | rpal4: |
4011 | dec eax |
4000 | dec eax |
4012 | jnz rpal3 |
4001 | jnz rpal3 |
4013 | jmp rpal2 |
4002 | jmp rpal2 |
4014 | rpal1: |
4003 | rpal1: |
4015 | ; popad |
4004 | ; popad |
4016 | ; mov eax,1 |
4005 | ; mov eax,1 |
4017 | xor eax, eax |
4006 | xor eax, eax |
4018 | inc eax |
4007 | inc eax |
4019 | ret |
4008 | ret |
4020 | rpal2: |
4009 | rpal2: |
4021 | ; popad |
4010 | ; popad |
4022 | ; enable port access at port IO map |
4011 | ; enable port access at port IO map |
4023 | cli |
4012 | cli |
4024 | pushad ; start enable io map |
4013 | pushad ; start enable io map |
4025 | 4014 | ||
4026 | cmp edx, 65536;16384 |
4015 | cmp edx, 65536;16384 |
4027 | jae no_unmask_io; jge |
4016 | jae no_unmask_io; jge |
4028 | mov eax, ecx |
4017 | mov eax, ecx |
4029 | ; push ebp |
4018 | ; push ebp |
4030 | xor ebp, ebp ; enable - eax = port |
4019 | xor ebp, ebp ; enable - eax = port |
4031 | new_port_access: |
4020 | new_port_access: |
4032 | ; pushad |
4021 | ; pushad |
4033 | call set_io_access_rights |
4022 | call set_io_access_rights |
4034 | ; popad |
4023 | ; popad |
4035 | inc eax |
4024 | inc eax |
4036 | cmp eax, edx |
4025 | cmp eax, edx |
4037 | jbe new_port_access |
4026 | jbe new_port_access |
4038 | ; pop ebp |
4027 | ; pop ebp |
4039 | no_unmask_io: |
4028 | no_unmask_io: |
4040 | popad ; end enable io map |
4029 | popad ; end enable io map |
4041 | sti |
4030 | sti |
4042 | 4031 | ||
4043 | mov eax, [RESERVED_PORTS] |
4032 | mov eax, [RESERVED_PORTS] |
4044 | add eax, 1 |
4033 | add eax, 1 |
4045 | mov [RESERVED_PORTS], eax |
4034 | mov [RESERVED_PORTS], eax |
4046 | shl eax, 4 |
4035 | shl eax, 4 |
4047 | add eax, RESERVED_PORTS |
4036 | add eax, RESERVED_PORTS |
4048 | mov ebx, [TASK_BASE] |
4037 | mov ebx, [TASK_BASE] |
4049 | mov ebx, [ebx+TASKDATA.pid] |
4038 | mov ebx, [ebx+TASKDATA.pid] |
4050 | mov [eax], ebx |
4039 | mov [eax], ebx |
4051 | mov [eax+4], ecx |
4040 | mov [eax+4], ecx |
4052 | mov [eax+8], edx |
4041 | mov [eax+8], edx |
4053 | 4042 | ||
4054 | xor eax, eax |
4043 | xor eax, eax |
4055 | ret |
4044 | ret |
4056 | 4045 | ||
4057 | free_port_area: |
4046 | free_port_area: |
4058 | 4047 | ||
4059 | ; pushad |
4048 | ; pushad |
4060 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4049 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4061 | test eax, eax |
4050 | test eax, eax |
4062 | jz frpal2 |
4051 | jz frpal2 |
4063 | mov ebx, [TASK_BASE] |
4052 | mov ebx, [TASK_BASE] |
4064 | mov ebx, [ebx+TASKDATA.pid] |
4053 | mov ebx, [ebx+TASKDATA.pid] |
4065 | frpal3: |
4054 | frpal3: |
4066 | mov edi, eax |
4055 | mov edi, eax |
4067 | shl edi, 4 |
4056 | shl edi, 4 |
4068 | add edi, RESERVED_PORTS |
4057 | add edi, RESERVED_PORTS |
4069 | cmp ebx, [edi] |
4058 | cmp ebx, [edi] |
4070 | jne frpal4 |
4059 | jne frpal4 |
4071 | cmp ecx, [edi+4] |
4060 | cmp ecx, [edi+4] |
4072 | jne frpal4 |
4061 | jne frpal4 |
4073 | cmp edx, [edi+8] |
4062 | cmp edx, [edi+8] |
4074 | jne frpal4 |
4063 | jne frpal4 |
4075 | jmp frpal1 |
4064 | jmp frpal1 |
4076 | frpal4: |
4065 | frpal4: |
4077 | dec eax |
4066 | dec eax |
4078 | jnz frpal3 |
4067 | jnz frpal3 |
4079 | frpal2: |
4068 | frpal2: |
4080 | ; popad |
4069 | ; popad |
4081 | inc eax |
4070 | inc eax |
4082 | ret |
4071 | ret |
4083 | frpal1: |
4072 | frpal1: |
4084 | push ecx |
4073 | push ecx |
4085 | mov ecx, 256 |
4074 | mov ecx, 256 |
4086 | sub ecx, eax |
4075 | sub ecx, eax |
4087 | shl ecx, 4 |
4076 | shl ecx, 4 |
4088 | mov esi, edi |
4077 | mov esi, edi |
4089 | add esi, 16 |
4078 | add esi, 16 |
4090 | cld |
4079 | cld |
4091 | rep movsb |
4080 | rep movsb |
4092 | 4081 | ||
4093 | dec dword [RESERVED_PORTS] |
4082 | dec dword [RESERVED_PORTS] |
4094 | ;popad |
4083 | ;popad |
4095 | ;disable port access at port IO map |
4084 | ;disable port access at port IO map |
4096 | 4085 | ||
4097 | ; pushad ; start disable io map |
4086 | ; pushad ; start disable io map |
4098 | pop eax ;start port |
4087 | pop eax ;start port |
4099 | cmp edx, 65536;16384 |
4088 | cmp edx, 65536;16384 |
4100 | jge no_mask_io |
4089 | jge no_mask_io |
4101 | 4090 | ||
4102 | ; mov eax,ecx |
4091 | ; mov eax,ecx |
4103 | xor ebp, ebp |
4092 | xor ebp, ebp |
4104 | inc ebp |
4093 | inc ebp |
4105 | new_port_access_disable: |
4094 | new_port_access_disable: |
4106 | ; pushad |
4095 | ; pushad |
4107 | ; mov ebp,1 ; disable - eax = port |
4096 | ; mov ebp,1 ; disable - eax = port |
4108 | call set_io_access_rights |
4097 | call set_io_access_rights |
4109 | ; popad |
4098 | ; popad |
4110 | inc eax |
4099 | inc eax |
4111 | cmp eax, edx |
4100 | cmp eax, edx |
4112 | jbe new_port_access_disable |
4101 | jbe new_port_access_disable |
4113 | no_mask_io: |
4102 | no_mask_io: |
4114 | ; popad ; end disable io map |
4103 | ; popad ; end disable io map |
4115 | xor eax, eax |
4104 | xor eax, eax |
4116 | ret |
4105 | ret |
4117 | ;----------------------------------------------------------------------------- |
4106 | ;----------------------------------------------------------------------------- |
4118 | align 4 |
4107 | align 4 |
4119 | drawbackground: |
4108 | drawbackground: |
4120 | dbrv20: |
4109 | dbrv20: |
4121 | cmp [BgrDrawMode], dword 1 |
4110 | cmp [BgrDrawMode], dword 1 |
4122 | jne bgrstr |
4111 | jne bgrstr |
4123 | call vesa20_drawbackground_tiled |
4112 | call vesa20_drawbackground_tiled |
4124 | ; call [draw_pointer] |
4113 | ; call [draw_pointer] |
4125 | call __sys_draw_pointer |
4114 | call __sys_draw_pointer |
4126 | ret |
4115 | ret |
4127 | ;-------------------------------------- |
4116 | ;-------------------------------------- |
4128 | align 4 |
4117 | align 4 |
4129 | bgrstr: |
4118 | bgrstr: |
4130 | call vesa20_drawbackground_stretch |
4119 | call vesa20_drawbackground_stretch |
4131 | ; call [draw_pointer] |
4120 | ; call [draw_pointer] |
4132 | call __sys_draw_pointer |
4121 | call __sys_draw_pointer |
4133 | ret |
4122 | ret |
4134 | ;----------------------------------------------------------------------------- |
4123 | ;----------------------------------------------------------------------------- |
4135 | align 4 |
4124 | align 4 |
4136 | syscall_putimage: ; PutImage |
4125 | syscall_putimage: ; PutImage |
4137 | sys_putimage: |
4126 | sys_putimage: |
4138 | test ecx, 0x80008000 |
4127 | test ecx, 0x80008000 |
4139 | jnz .exit |
4128 | jnz .exit |
4140 | test ecx, 0x0000FFFF |
4129 | test ecx, 0x0000FFFF |
4141 | jz .exit |
4130 | jz .exit |
4142 | test ecx, 0xFFFF0000 |
4131 | test ecx, 0xFFFF0000 |
4143 | jnz @f |
4132 | jnz @f |
4144 | ;-------------------------------------- |
4133 | ;-------------------------------------- |
4145 | align 4 |
4134 | align 4 |
4146 | .exit: |
4135 | .exit: |
4147 | ret |
4136 | ret |
4148 | ;-------------------------------------- |
4137 | ;-------------------------------------- |
4149 | align 4 |
4138 | align 4 |
4150 | @@: |
4139 | @@: |
4151 | mov edi, [current_slot] |
4140 | mov edi, [current_slot] |
4152 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4141 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4153 | rol edx, 16 |
4142 | rol edx, 16 |
4154 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4143 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4155 | rol edx, 16 |
4144 | rol edx, 16 |
4156 | ;-------------------------------------- |
4145 | ;-------------------------------------- |
4157 | align 4 |
4146 | align 4 |
4158 | .forced: |
4147 | .forced: |
4159 | push ebp esi 0 |
4148 | push ebp esi 0 |
4160 | mov ebp, putimage_get24bpp |
4149 | mov ebp, putimage_get24bpp |
4161 | mov esi, putimage_init24bpp |
4150 | mov esi, putimage_init24bpp |
4162 | ;-------------------------------------- |
4151 | ;-------------------------------------- |
4163 | align 4 |
4152 | align 4 |
4164 | sys_putimage_bpp: |
4153 | sys_putimage_bpp: |
4165 | call vesa20_putimage |
4154 | call vesa20_putimage |
4166 | pop ebp esi ebp |
4155 | pop ebp esi ebp |
4167 | ret |
4156 | ret |
4168 | ; jmp [draw_pointer] |
4157 | ; jmp [draw_pointer] |
4169 | ;----------------------------------------------------------------------------- |
4158 | ;----------------------------------------------------------------------------- |
4170 | align 4 |
4159 | align 4 |
4171 | sys_putimage_palette: |
4160 | sys_putimage_palette: |
4172 | ; ebx = pointer to image |
4161 | ; ebx = pointer to image |
4173 | ; ecx = [xsize]*65536 + [ysize] |
4162 | ; ecx = [xsize]*65536 + [ysize] |
4174 | ; edx = [xstart]*65536 + [ystart] |
4163 | ; edx = [xstart]*65536 + [ystart] |
4175 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4164 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4176 | ; edi = pointer to palette |
4165 | ; edi = pointer to palette |
4177 | ; ebp = row delta |
4166 | ; ebp = row delta |
4178 | mov eax, [CURRENT_TASK] |
4167 | mov eax, [CURRENT_TASK] |
4179 | shl eax, 8 |
4168 | shl eax, 8 |
4180 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4169 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4181 | rol edx, 16 |
4170 | rol edx, 16 |
4182 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4171 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4183 | rol edx, 16 |
4172 | rol edx, 16 |
4184 | ;-------------------------------------- |
4173 | ;-------------------------------------- |
4185 | align 4 |
4174 | align 4 |
4186 | .forced: |
4175 | .forced: |
4187 | cmp esi, 1 |
4176 | cmp esi, 1 |
4188 | jnz @f |
4177 | jnz @f |
4189 | push edi |
4178 | push edi |
4190 | mov eax, [edi+4] |
4179 | mov eax, [edi+4] |
4191 | sub eax, [edi] |
4180 | sub eax, [edi] |
4192 | push eax |
4181 | push eax |
4193 | push dword [edi] |
4182 | push dword [edi] |
4194 | push 0ffffff80h |
4183 | push 0ffffff80h |
4195 | mov edi, esp |
4184 | mov edi, esp |
4196 | call put_mono_image |
4185 | call put_mono_image |
4197 | add esp, 12 |
4186 | add esp, 12 |
4198 | pop edi |
4187 | pop edi |
4199 | ret |
4188 | ret |
4200 | ;-------------------------------------- |
4189 | ;-------------------------------------- |
4201 | align 4 |
4190 | align 4 |
4202 | @@: |
4191 | @@: |
4203 | cmp esi, 2 |
4192 | cmp esi, 2 |
4204 | jnz @f |
4193 | jnz @f |
4205 | push edi |
4194 | push edi |
4206 | push 0ffffff80h |
4195 | push 0ffffff80h |
4207 | mov edi, esp |
4196 | mov edi, esp |
4208 | call put_2bit_image |
4197 | call put_2bit_image |
4209 | pop eax |
4198 | pop eax |
4210 | pop edi |
4199 | pop edi |
4211 | ret |
4200 | ret |
4212 | ;-------------------------------------- |
4201 | ;-------------------------------------- |
4213 | align 4 |
4202 | align 4 |
4214 | @@: |
4203 | @@: |
4215 | cmp esi, 4 |
4204 | cmp esi, 4 |
4216 | jnz @f |
4205 | jnz @f |
4217 | push edi |
4206 | push edi |
4218 | push 0ffffff80h |
4207 | push 0ffffff80h |
4219 | mov edi, esp |
4208 | mov edi, esp |
4220 | call put_4bit_image |
4209 | call put_4bit_image |
4221 | pop eax |
4210 | pop eax |
4222 | pop edi |
4211 | pop edi |
4223 | ret |
4212 | ret |
4224 | ;-------------------------------------- |
4213 | ;-------------------------------------- |
4225 | align 4 |
4214 | align 4 |
4226 | @@: |
4215 | @@: |
4227 | push ebp esi ebp |
4216 | push ebp esi ebp |
4228 | cmp esi, 8 |
4217 | cmp esi, 8 |
4229 | jnz @f |
4218 | jnz @f |
4230 | mov ebp, putimage_get8bpp |
4219 | mov ebp, putimage_get8bpp |
4231 | mov esi, putimage_init8bpp |
4220 | mov esi, putimage_init8bpp |
4232 | jmp sys_putimage_bpp |
4221 | jmp sys_putimage_bpp |
4233 | ;-------------------------------------- |
4222 | ;-------------------------------------- |
4234 | align 4 |
4223 | align 4 |
4235 | @@: |
4224 | @@: |
4236 | cmp esi, 9 |
4225 | cmp esi, 9 |
4237 | jnz @f |
4226 | jnz @f |
4238 | mov ebp, putimage_get9bpp |
4227 | mov ebp, putimage_get9bpp |
4239 | mov esi, putimage_init9bpp |
4228 | mov esi, putimage_init9bpp |
4240 | jmp sys_putimage_bpp |
4229 | jmp sys_putimage_bpp |
4241 | ;-------------------------------------- |
4230 | ;-------------------------------------- |
4242 | align 4 |
4231 | align 4 |
4243 | @@: |
4232 | @@: |
4244 | cmp esi, 15 |
4233 | cmp esi, 15 |
4245 | jnz @f |
4234 | jnz @f |
4246 | mov ebp, putimage_get15bpp |
4235 | mov ebp, putimage_get15bpp |
4247 | mov esi, putimage_init15bpp |
4236 | mov esi, putimage_init15bpp |
4248 | jmp sys_putimage_bpp |
4237 | jmp sys_putimage_bpp |
4249 | ;-------------------------------------- |
4238 | ;-------------------------------------- |
4250 | align 4 |
4239 | align 4 |
4251 | @@: |
4240 | @@: |
4252 | cmp esi, 16 |
4241 | cmp esi, 16 |
4253 | jnz @f |
4242 | jnz @f |
4254 | mov ebp, putimage_get16bpp |
4243 | mov ebp, putimage_get16bpp |
4255 | mov esi, putimage_init16bpp |
4244 | mov esi, putimage_init16bpp |
4256 | jmp sys_putimage_bpp |
4245 | jmp sys_putimage_bpp |
4257 | ;-------------------------------------- |
4246 | ;-------------------------------------- |
4258 | align 4 |
4247 | align 4 |
4259 | @@: |
4248 | @@: |
4260 | cmp esi, 24 |
4249 | cmp esi, 24 |
4261 | jnz @f |
4250 | jnz @f |
4262 | mov ebp, putimage_get24bpp |
4251 | mov ebp, putimage_get24bpp |
4263 | mov esi, putimage_init24bpp |
4252 | mov esi, putimage_init24bpp |
4264 | jmp sys_putimage_bpp |
4253 | jmp sys_putimage_bpp |
4265 | ;-------------------------------------- |
4254 | ;-------------------------------------- |
4266 | align 4 |
4255 | align 4 |
4267 | @@: |
4256 | @@: |
4268 | cmp esi, 32 |
4257 | cmp esi, 32 |
4269 | jnz @f |
4258 | jnz @f |
4270 | mov ebp, putimage_get32bpp |
4259 | mov ebp, putimage_get32bpp |
4271 | mov esi, putimage_init32bpp |
4260 | mov esi, putimage_init32bpp |
4272 | jmp sys_putimage_bpp |
4261 | jmp sys_putimage_bpp |
4273 | ;-------------------------------------- |
4262 | ;-------------------------------------- |
4274 | align 4 |
4263 | align 4 |
4275 | @@: |
4264 | @@: |
4276 | pop ebp esi ebp |
4265 | pop ebp esi ebp |
4277 | ret |
4266 | ret |
4278 | ;----------------------------------------------------------------------------- |
4267 | ;----------------------------------------------------------------------------- |
4279 | align 4 |
4268 | align 4 |
4280 | put_mono_image: |
4269 | put_mono_image: |
4281 | push ebp esi ebp |
4270 | push ebp esi ebp |
4282 | mov ebp, putimage_get1bpp |
4271 | mov ebp, putimage_get1bpp |
4283 | mov esi, putimage_init1bpp |
4272 | mov esi, putimage_init1bpp |
4284 | jmp sys_putimage_bpp |
4273 | jmp sys_putimage_bpp |
4285 | ;----------------------------------------------------------------------------- |
4274 | ;----------------------------------------------------------------------------- |
4286 | align 4 |
4275 | align 4 |
4287 | put_2bit_image: |
4276 | put_2bit_image: |
4288 | push ebp esi ebp |
4277 | push ebp esi ebp |
4289 | mov ebp, putimage_get2bpp |
4278 | mov ebp, putimage_get2bpp |
4290 | mov esi, putimage_init2bpp |
4279 | mov esi, putimage_init2bpp |
4291 | jmp sys_putimage_bpp |
4280 | jmp sys_putimage_bpp |
4292 | ;----------------------------------------------------------------------------- |
4281 | ;----------------------------------------------------------------------------- |
4293 | align 4 |
4282 | align 4 |
4294 | put_4bit_image: |
4283 | put_4bit_image: |
4295 | push ebp esi ebp |
4284 | push ebp esi ebp |
4296 | mov ebp, putimage_get4bpp |
4285 | mov ebp, putimage_get4bpp |
4297 | mov esi, putimage_init4bpp |
4286 | mov esi, putimage_init4bpp |
4298 | jmp sys_putimage_bpp |
4287 | jmp sys_putimage_bpp |
4299 | ;----------------------------------------------------------------------------- |
4288 | ;----------------------------------------------------------------------------- |
4300 | align 4 |
4289 | align 4 |
4301 | putimage_init24bpp: |
4290 | putimage_init24bpp: |
4302 | lea eax, [eax*3] |
4291 | lea eax, [eax*3] |
4303 | putimage_init8bpp: |
4292 | putimage_init8bpp: |
4304 | putimage_init9bpp: |
4293 | putimage_init9bpp: |
4305 | ret |
4294 | ret |
4306 | ;----------------------------------------------------------------------------- |
4295 | ;----------------------------------------------------------------------------- |
4307 | align 16 |
4296 | align 16 |
4308 | putimage_get24bpp: |
4297 | putimage_get24bpp: |
4309 | movzx eax, byte [esi+2] |
4298 | movzx eax, byte [esi+2] |
4310 | shl eax, 16 |
4299 | shl eax, 16 |
4311 | mov ax, [esi] |
4300 | mov ax, [esi] |
4312 | add esi, 3 |
4301 | add esi, 3 |
4313 | ret 4 |
4302 | ret 4 |
4314 | ;----------------------------------------------------------------------------- |
4303 | ;----------------------------------------------------------------------------- |
4315 | align 16 |
4304 | align 16 |
4316 | putimage_get8bpp: |
4305 | putimage_get8bpp: |
4317 | movzx eax, byte [esi] |
4306 | movzx eax, byte [esi] |
4318 | push edx |
4307 | push edx |
4319 | mov edx, [esp+8] |
4308 | mov edx, [esp+8] |
4320 | mov eax, [edx+eax*4] |
4309 | mov eax, [edx+eax*4] |
4321 | pop edx |
4310 | pop edx |
4322 | inc esi |
4311 | inc esi |
4323 | ret 4 |
4312 | ret 4 |
4324 | ;----------------------------------------------------------------------------- |
4313 | ;----------------------------------------------------------------------------- |
4325 | align 16 |
4314 | align 16 |
4326 | putimage_get9bpp: |
4315 | putimage_get9bpp: |
4327 | lodsb |
4316 | lodsb |
4328 | mov ah, al |
4317 | mov ah, al |
4329 | shl eax, 8 |
4318 | shl eax, 8 |
4330 | mov al, ah |
4319 | mov al, ah |
4331 | ret 4 |
4320 | ret 4 |
4332 | ;----------------------------------------------------------------------------- |
4321 | ;----------------------------------------------------------------------------- |
4333 | align 4 |
4322 | align 4 |
4334 | putimage_init1bpp: |
4323 | putimage_init1bpp: |
4335 | add eax, ecx |
4324 | add eax, ecx |
4336 | push ecx |
4325 | push ecx |
4337 | add eax, 7 |
4326 | add eax, 7 |
4338 | add ecx, 7 |
4327 | add ecx, 7 |
4339 | shr eax, 3 |
4328 | shr eax, 3 |
4340 | shr ecx, 3 |
4329 | shr ecx, 3 |
4341 | sub eax, ecx |
4330 | sub eax, ecx |
4342 | pop ecx |
4331 | pop ecx |
4343 | ret |
4332 | ret |
4344 | ;----------------------------------------------------------------------------- |
4333 | ;----------------------------------------------------------------------------- |
4345 | align 16 |
4334 | align 16 |
4346 | putimage_get1bpp: |
4335 | putimage_get1bpp: |
4347 | push edx |
4336 | push edx |
4348 | mov edx, [esp+8] |
4337 | mov edx, [esp+8] |
4349 | mov al, [edx] |
4338 | mov al, [edx] |
4350 | add al, al |
4339 | add al, al |
4351 | jnz @f |
4340 | jnz @f |
4352 | lodsb |
4341 | lodsb |
4353 | adc al, al |
4342 | adc al, al |
4354 | @@: |
4343 | @@: |
4355 | mov [edx], al |
4344 | mov [edx], al |
4356 | sbb eax, eax |
4345 | sbb eax, eax |
4357 | and eax, [edx+8] |
4346 | and eax, [edx+8] |
4358 | add eax, [edx+4] |
4347 | add eax, [edx+4] |
4359 | pop edx |
4348 | pop edx |
4360 | ret 4 |
4349 | ret 4 |
4361 | ;----------------------------------------------------------------------------- |
4350 | ;----------------------------------------------------------------------------- |
4362 | align 4 |
4351 | align 4 |
4363 | putimage_init2bpp: |
4352 | putimage_init2bpp: |
4364 | add eax, ecx |
4353 | add eax, ecx |
4365 | push ecx |
4354 | push ecx |
4366 | add ecx, 3 |
4355 | add ecx, 3 |
4367 | add eax, 3 |
4356 | add eax, 3 |
4368 | shr ecx, 2 |
4357 | shr ecx, 2 |
4369 | shr eax, 2 |
4358 | shr eax, 2 |
4370 | sub eax, ecx |
4359 | sub eax, ecx |
4371 | pop ecx |
4360 | pop ecx |
4372 | ret |
4361 | ret |
4373 | ;----------------------------------------------------------------------------- |
4362 | ;----------------------------------------------------------------------------- |
4374 | align 16 |
4363 | align 16 |
4375 | putimage_get2bpp: |
4364 | putimage_get2bpp: |
4376 | push edx |
4365 | push edx |
4377 | mov edx, [esp+8] |
4366 | mov edx, [esp+8] |
4378 | mov al, [edx] |
4367 | mov al, [edx] |
4379 | mov ah, al |
4368 | mov ah, al |
4380 | shr al, 6 |
4369 | shr al, 6 |
4381 | shl ah, 2 |
4370 | shl ah, 2 |
4382 | jnz .nonewbyte |
4371 | jnz .nonewbyte |
4383 | lodsb |
4372 | lodsb |
4384 | mov ah, al |
4373 | mov ah, al |
4385 | shr al, 6 |
4374 | shr al, 6 |
4386 | shl ah, 2 |
4375 | shl ah, 2 |
4387 | add ah, 1 |
4376 | add ah, 1 |
4388 | .nonewbyte: |
4377 | .nonewbyte: |
4389 | mov [edx], ah |
4378 | mov [edx], ah |
4390 | mov edx, [edx+4] |
4379 | mov edx, [edx+4] |
4391 | movzx eax, al |
4380 | movzx eax, al |
4392 | mov eax, [edx+eax*4] |
4381 | mov eax, [edx+eax*4] |
4393 | pop edx |
4382 | pop edx |
4394 | ret 4 |
4383 | ret 4 |
4395 | ;----------------------------------------------------------------------------- |
4384 | ;----------------------------------------------------------------------------- |
4396 | align 4 |
4385 | align 4 |
4397 | putimage_init4bpp: |
4386 | putimage_init4bpp: |
4398 | add eax, ecx |
4387 | add eax, ecx |
4399 | push ecx |
4388 | push ecx |
4400 | add ecx, 1 |
4389 | add ecx, 1 |
4401 | add eax, 1 |
4390 | add eax, 1 |
4402 | shr ecx, 1 |
4391 | shr ecx, 1 |
4403 | shr eax, 1 |
4392 | shr eax, 1 |
4404 | sub eax, ecx |
4393 | sub eax, ecx |
4405 | pop ecx |
4394 | pop ecx |
4406 | ret |
4395 | ret |
4407 | ;----------------------------------------------------------------------------- |
4396 | ;----------------------------------------------------------------------------- |
4408 | align 16 |
4397 | align 16 |
4409 | putimage_get4bpp: |
4398 | putimage_get4bpp: |
4410 | push edx |
4399 | push edx |
4411 | mov edx, [esp+8] |
4400 | mov edx, [esp+8] |
4412 | add byte [edx], 80h |
4401 | add byte [edx], 80h |
4413 | jc @f |
4402 | jc @f |
4414 | movzx eax, byte [edx+1] |
4403 | movzx eax, byte [edx+1] |
4415 | mov edx, [edx+4] |
4404 | mov edx, [edx+4] |
4416 | and eax, 0x0F |
4405 | and eax, 0x0F |
4417 | mov eax, [edx+eax*4] |
4406 | mov eax, [edx+eax*4] |
4418 | pop edx |
4407 | pop edx |
4419 | ret 4 |
4408 | ret 4 |
4420 | @@: |
4409 | @@: |
4421 | movzx eax, byte [esi] |
4410 | movzx eax, byte [esi] |
4422 | add esi, 1 |
4411 | add esi, 1 |
4423 | mov [edx+1], al |
4412 | mov [edx+1], al |
4424 | shr eax, 4 |
4413 | shr eax, 4 |
4425 | mov edx, [edx+4] |
4414 | mov edx, [edx+4] |
4426 | mov eax, [edx+eax*4] |
4415 | mov eax, [edx+eax*4] |
4427 | pop edx |
4416 | pop edx |
4428 | ret 4 |
4417 | ret 4 |
4429 | ;----------------------------------------------------------------------------- |
4418 | ;----------------------------------------------------------------------------- |
4430 | align 4 |
4419 | align 4 |
4431 | putimage_init32bpp: |
4420 | putimage_init32bpp: |
4432 | shl eax, 2 |
4421 | shl eax, 2 |
4433 | ret |
4422 | ret |
4434 | ;----------------------------------------------------------------------------- |
4423 | ;----------------------------------------------------------------------------- |
4435 | align 16 |
4424 | align 16 |
4436 | putimage_get32bpp: |
4425 | putimage_get32bpp: |
4437 | lodsd |
4426 | lodsd |
4438 | ret 4 |
4427 | ret 4 |
4439 | ;----------------------------------------------------------------------------- |
4428 | ;----------------------------------------------------------------------------- |
4440 | align 4 |
4429 | align 4 |
4441 | putimage_init15bpp: |
4430 | putimage_init15bpp: |
4442 | putimage_init16bpp: |
4431 | putimage_init16bpp: |
4443 | add eax, eax |
4432 | add eax, eax |
4444 | ret |
4433 | ret |
4445 | ;----------------------------------------------------------------------------- |
4434 | ;----------------------------------------------------------------------------- |
4446 | align 16 |
4435 | align 16 |
4447 | putimage_get15bpp: |
4436 | putimage_get15bpp: |
4448 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4437 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4449 | push ecx edx |
4438 | push ecx edx |
4450 | movzx eax, word [esi] |
4439 | movzx eax, word [esi] |
4451 | add esi, 2 |
4440 | add esi, 2 |
4452 | mov ecx, eax |
4441 | mov ecx, eax |
4453 | mov edx, eax |
4442 | mov edx, eax |
4454 | and eax, 0x1F |
4443 | and eax, 0x1F |
4455 | and ecx, 0x1F shl 5 |
4444 | and ecx, 0x1F shl 5 |
4456 | and edx, 0x1F shl 10 |
4445 | and edx, 0x1F shl 10 |
4457 | shl eax, 3 |
4446 | shl eax, 3 |
4458 | shl ecx, 6 |
4447 | shl ecx, 6 |
4459 | shl edx, 9 |
4448 | shl edx, 9 |
4460 | or eax, ecx |
4449 | or eax, ecx |
4461 | or eax, edx |
4450 | or eax, edx |
4462 | pop edx ecx |
4451 | pop edx ecx |
4463 | ret 4 |
4452 | ret 4 |
4464 | ;----------------------------------------------------------------------------- |
4453 | ;----------------------------------------------------------------------------- |
4465 | align 16 |
4454 | align 16 |
4466 | putimage_get16bpp: |
4455 | putimage_get16bpp: |
4467 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4456 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4468 | push ecx edx |
4457 | push ecx edx |
4469 | movzx eax, word [esi] |
4458 | movzx eax, word [esi] |
4470 | add esi, 2 |
4459 | add esi, 2 |
4471 | mov ecx, eax |
4460 | mov ecx, eax |
4472 | mov edx, eax |
4461 | mov edx, eax |
4473 | and eax, 0x1F |
4462 | and eax, 0x1F |
4474 | and ecx, 0x3F shl 5 |
4463 | and ecx, 0x3F shl 5 |
4475 | and edx, 0x1F shl 11 |
4464 | and edx, 0x1F shl 11 |
4476 | shl eax, 3 |
4465 | shl eax, 3 |
4477 | shl ecx, 5 |
4466 | shl ecx, 5 |
4478 | shl edx, 8 |
4467 | shl edx, 8 |
4479 | or eax, ecx |
4468 | or eax, ecx |
4480 | or eax, edx |
4469 | or eax, edx |
4481 | pop edx ecx |
4470 | pop edx ecx |
4482 | ret 4 |
4471 | ret 4 |
4483 | ;----------------------------------------------------------------------------- |
4472 | ;----------------------------------------------------------------------------- |
4484 | ;align 4 |
4473 | ;align 4 |
4485 | ; eax x beginning |
4474 | ; eax x beginning |
4486 | ; ebx y beginning |
4475 | ; ebx y beginning |
4487 | ; ecx x end |
4476 | ; ecx x end |
4488 | ; edx y end |
4477 | ; edx y end |
4489 | ; edi color |
4478 | ; edi color |
4490 | ;__sys_drawbar: |
4479 | ;__sys_drawbar: |
4491 | ; mov esi, [current_slot] |
4480 | ; mov esi, [current_slot] |
4492 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4481 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4493 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4482 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4494 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4483 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4495 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4484 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4496 | ;-------------------------------------- |
4485 | ;-------------------------------------- |
4497 | ;align 4 |
4486 | ;align 4 |
4498 | ;.forced: |
4487 | ;.forced: |
4499 | ; call vesa20_drawbar |
4488 | ; call vesa20_drawbar |
4500 | ; call [draw_pointer] |
4489 | ; call [draw_pointer] |
4501 | ; ret |
4490 | ; ret |
4502 | ;----------------------------------------------------------------------------- |
4491 | ;----------------------------------------------------------------------------- |
4503 | align 4 |
4492 | align 4 |
4504 | kb_read: |
4493 | kb_read: |
4505 | 4494 | ||
4506 | push ecx edx |
4495 | push ecx edx |
4507 | 4496 | ||
4508 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4497 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4509 | kr_loop: |
4498 | kr_loop: |
4510 | in al, 0x64 |
4499 | in al, 0x64 |
4511 | test al, 1 |
4500 | test al, 1 |
4512 | jnz kr_ready |
4501 | jnz kr_ready |
4513 | loop kr_loop |
4502 | loop kr_loop |
4514 | mov ah, 1 |
4503 | mov ah, 1 |
4515 | jmp kr_exit |
4504 | jmp kr_exit |
4516 | kr_ready: |
4505 | kr_ready: |
4517 | push ecx |
4506 | push ecx |
4518 | mov ecx, 32 |
4507 | mov ecx, 32 |
4519 | kr_delay: |
4508 | kr_delay: |
4520 | loop kr_delay |
4509 | loop kr_delay |
4521 | pop ecx |
4510 | pop ecx |
4522 | in al, 0x60 |
4511 | in al, 0x60 |
4523 | xor ah, ah |
4512 | xor ah, ah |
4524 | kr_exit: |
4513 | kr_exit: |
4525 | 4514 | ||
4526 | pop edx ecx |
4515 | pop edx ecx |
4527 | 4516 | ||
4528 | ret |
4517 | ret |
4529 | ;----------------------------------------------------------------------------- |
4518 | ;----------------------------------------------------------------------------- |
4530 | align 4 |
4519 | align 4 |
4531 | kb_write: |
4520 | kb_write: |
4532 | 4521 | ||
4533 | push ecx edx |
4522 | push ecx edx |
4534 | 4523 | ||
4535 | mov dl, al |
4524 | mov dl, al |
4536 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4525 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4537 | ; kw_loop1: |
4526 | ; kw_loop1: |
4538 | ; in al,0x64 |
4527 | ; in al,0x64 |
4539 | ; test al,0x20 |
4528 | ; test al,0x20 |
4540 | ; jz kw_ok1 |
4529 | ; jz kw_ok1 |
4541 | ; loop kw_loop1 |
4530 | ; loop kw_loop1 |
4542 | ; mov ah,1 |
4531 | ; mov ah,1 |
4543 | ; jmp kw_exit |
4532 | ; jmp kw_exit |
4544 | ; kw_ok1: |
4533 | ; kw_ok1: |
4545 | in al, 0x60 |
4534 | in al, 0x60 |
4546 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4535 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4547 | kw_loop: |
4536 | kw_loop: |
4548 | in al, 0x64 |
4537 | in al, 0x64 |
4549 | test al, 2 |
4538 | test al, 2 |
4550 | jz kw_ok |
4539 | jz kw_ok |
4551 | loop kw_loop |
4540 | loop kw_loop |
4552 | mov ah, 1 |
4541 | mov ah, 1 |
4553 | jmp kw_exit |
4542 | jmp kw_exit |
4554 | kw_ok: |
4543 | kw_ok: |
4555 | mov al, dl |
4544 | mov al, dl |
4556 | out 0x60, al |
4545 | out 0x60, al |
4557 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4546 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4558 | kw_loop3: |
4547 | kw_loop3: |
4559 | in al, 0x64 |
4548 | in al, 0x64 |
4560 | test al, 2 |
4549 | test al, 2 |
4561 | jz kw_ok3 |
4550 | jz kw_ok3 |
4562 | loop kw_loop3 |
4551 | loop kw_loop3 |
4563 | mov ah, 1 |
4552 | mov ah, 1 |
4564 | jmp kw_exit |
4553 | jmp kw_exit |
4565 | kw_ok3: |
4554 | kw_ok3: |
4566 | mov ah, 8 |
4555 | mov ah, 8 |
4567 | kw_loop4: |
4556 | kw_loop4: |
4568 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4557 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4569 | kw_loop5: |
4558 | kw_loop5: |
4570 | in al, 0x64 |
4559 | in al, 0x64 |
4571 | test al, 1 |
4560 | test al, 1 |
4572 | jnz kw_ok4 |
4561 | jnz kw_ok4 |
4573 | loop kw_loop5 |
4562 | loop kw_loop5 |
4574 | dec ah |
4563 | dec ah |
4575 | jnz kw_loop4 |
4564 | jnz kw_loop4 |
4576 | kw_ok4: |
4565 | kw_ok4: |
4577 | xor ah, ah |
4566 | xor ah, ah |
4578 | kw_exit: |
4567 | kw_exit: |
4579 | 4568 | ||
4580 | pop edx ecx |
4569 | pop edx ecx |
4581 | 4570 | ||
4582 | ret |
4571 | ret |
4583 | ;----------------------------------------------------------------------------- |
4572 | ;----------------------------------------------------------------------------- |
4584 | align 4 |
4573 | align 4 |
4585 | kb_cmd: |
4574 | kb_cmd: |
4586 | 4575 | ||
4587 | 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 |
4588 | c_wait: |
4577 | c_wait: |
4589 | in al, 0x64 |
4578 | in al, 0x64 |
4590 | test al, 2 |
4579 | test al, 2 |
4591 | jz c_send |
4580 | jz c_send |
4592 | loop c_wait |
4581 | loop c_wait |
4593 | jmp c_error |
4582 | jmp c_error |
4594 | c_send: |
4583 | c_send: |
4595 | mov al, bl |
4584 | mov al, bl |
4596 | out 0x64, al |
4585 | out 0x64, al |
4597 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4586 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4598 | c_accept: |
4587 | c_accept: |
4599 | in al, 0x64 |
4588 | in al, 0x64 |
4600 | test al, 2 |
4589 | test al, 2 |
4601 | jz c_ok |
4590 | jz c_ok |
4602 | loop c_accept |
4591 | loop c_accept |
4603 | c_error: |
4592 | c_error: |
4604 | mov ah, 1 |
4593 | mov ah, 1 |
4605 | jmp c_exit |
4594 | jmp c_exit |
4606 | c_ok: |
4595 | c_ok: |
4607 | xor ah, ah |
4596 | xor ah, ah |
4608 | c_exit: |
4597 | c_exit: |
4609 | ret |
4598 | ret |
4610 | 4599 | ||
4611 | 4600 | ||
4612 | setmouse: ; set mousepicture -pointer |
4601 | setmouse: ; set mousepicture -pointer |
4613 | ; ps2 mouse enable |
4602 | ; ps2 mouse enable |
4614 | 4603 | ||
4615 | ; mov [MOUSE_PICTURE], dword mousepointer |
4604 | ; mov [MOUSE_PICTURE], dword mousepointer |
4616 | 4605 | ||
4617 | cli |
4606 | cli |
4618 | 4607 | ||
4619 | ret |
4608 | ret |
4620 | 4609 | ||
4621 | if used _rdtsc |
4610 | if used _rdtsc |
4622 | _rdtsc: |
4611 | _rdtsc: |
4623 | bt [cpu_caps], CAPS_TSC |
4612 | bt [cpu_caps], CAPS_TSC |
4624 | jnc ret_rdtsc |
4613 | jnc ret_rdtsc |
4625 | rdtsc |
4614 | rdtsc |
4626 | ret |
4615 | ret |
4627 | ret_rdtsc: |
4616 | ret_rdtsc: |
4628 | mov edx, 0xffffffff |
4617 | mov edx, 0xffffffff |
4629 | mov eax, 0xffffffff |
4618 | mov eax, 0xffffffff |
4630 | ret |
4619 | ret |
4631 | end if |
4620 | end if |
4632 | 4621 | ||
4633 | sys_msg_board_str: |
4622 | sys_msg_board_str: |
4634 | 4623 | ||
4635 | pushad |
4624 | pushad |
4636 | @@: |
4625 | @@: |
4637 | cmp [esi], byte 0 |
4626 | cmp [esi], byte 0 |
4638 | je @f |
4627 | je @f |
4639 | mov ebx, 1 |
4628 | mov ebx, 1 |
4640 | movzx ecx, byte [esi] |
4629 | movzx ecx, byte [esi] |
4641 | call sys_msg_board |
4630 | call sys_msg_board |
4642 | inc esi |
4631 | inc esi |
4643 | jmp @b |
4632 | jmp @b |
4644 | @@: |
4633 | @@: |
4645 | popad |
4634 | popad |
4646 | ret |
4635 | ret |
4647 | 4636 | ||
4648 | sys_msg_board_byte: |
4637 | sys_msg_board_byte: |
4649 | ; in: al = byte to display |
4638 | ; in: al = byte to display |
4650 | ; out: nothing |
4639 | ; out: nothing |
4651 | ; destroys: nothing |
4640 | ; destroys: nothing |
4652 | pushad |
4641 | pushad |
4653 | mov ecx, 2 |
4642 | mov ecx, 2 |
4654 | shl eax, 24 |
4643 | shl eax, 24 |
4655 | jmp @f |
4644 | jmp @f |
4656 | 4645 | ||
4657 | sys_msg_board_word: |
4646 | sys_msg_board_word: |
4658 | ; in: ax = word to display |
4647 | ; in: ax = word to display |
4659 | ; out: nothing |
4648 | ; out: nothing |
4660 | ; destroys: nothing |
4649 | ; destroys: nothing |
4661 | pushad |
4650 | pushad |
4662 | mov ecx, 4 |
4651 | mov ecx, 4 |
4663 | shl eax, 16 |
4652 | shl eax, 16 |
4664 | jmp @f |
4653 | jmp @f |
4665 | 4654 | ||
4666 | sys_msg_board_dword: |
4655 | sys_msg_board_dword: |
4667 | ; in: eax = dword to display |
4656 | ; in: eax = dword to display |
4668 | ; out: nothing |
4657 | ; out: nothing |
4669 | ; destroys: nothing |
4658 | ; destroys: nothing |
4670 | pushad |
4659 | pushad |
4671 | mov ecx, 8 |
4660 | mov ecx, 8 |
4672 | @@: |
4661 | @@: |
4673 | push ecx |
4662 | push ecx |
4674 | rol eax, 4 |
4663 | rol eax, 4 |
4675 | push eax |
4664 | push eax |
4676 | and al, 0xF |
4665 | and al, 0xF |
4677 | cmp al, 10 |
4666 | cmp al, 10 |
4678 | sbb al, 69h |
4667 | sbb al, 69h |
4679 | das |
4668 | das |
4680 | mov cl, al |
4669 | mov cl, al |
4681 | xor ebx, ebx |
4670 | xor ebx, ebx |
4682 | inc ebx |
4671 | inc ebx |
4683 | call sys_msg_board |
4672 | call sys_msg_board |
4684 | pop eax |
4673 | pop eax |
4685 | pop ecx |
4674 | pop ecx |
4686 | loop @b |
4675 | loop @b |
4687 | popad |
4676 | popad |
4688 | ret |
4677 | ret |
4689 | 4678 | ||
4690 | msg_board_data_size = 65536 ; Must be power of two |
4679 | msg_board_data_size = 65536 ; Must be power of two |
4691 | 4680 | ||
4692 | uglobal |
4681 | uglobal |
4693 | msg_board_data rb msg_board_data_size |
4682 | msg_board_data rb msg_board_data_size |
4694 | msg_board_count dd 0x0 |
4683 | msg_board_count dd 0x0 |
4695 | endg |
4684 | endg |
4696 | 4685 | ||
4697 | sys_msg_board: |
4686 | sys_msg_board: |
4698 | 4687 | ||
4699 | ; ebx=1 : write : bl byte to write |
4688 | ; ebx=1 : write : bl byte to write |
4700 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4689 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4701 | 4690 | ||
4702 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4691 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4703 | mov eax, ebx |
4692 | mov eax, ebx |
4704 | mov ebx, ecx |
4693 | mov ebx, ecx |
4705 | 4694 | ||
4706 | mov ecx, [msg_board_count] |
4695 | mov ecx, [msg_board_count] |
4707 | cmp eax, 1 |
4696 | cmp eax, 1 |
4708 | jne .smbl1 |
4697 | jne .smbl1 |
4709 | 4698 | ||
4710 | if defined debug_com_base |
4699 | if defined debug_com_base |
4711 | 4700 | ||
4712 | push dx ax |
4701 | push dx ax |
4713 | 4702 | ||
4714 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4703 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4715 | mov dx, debug_com_base+5 |
4704 | mov dx, debug_com_base+5 |
4716 | in al, dx |
4705 | in al, dx |
4717 | test al, 1 shl 5 |
4706 | test al, 1 shl 5 |
4718 | jz @r |
4707 | jz @r |
4719 | 4708 | ||
4720 | mov dx, debug_com_base ; Output the byte |
4709 | mov dx, debug_com_base ; Output the byte |
4721 | mov al, bl |
4710 | mov al, bl |
4722 | out dx, al |
4711 | out dx, al |
4723 | 4712 | ||
4724 | pop ax dx |
4713 | pop ax dx |
4725 | 4714 | ||
4726 | end if |
4715 | end if |
4727 | 4716 | ||
4728 | mov [msg_board_data+ecx], bl |
4717 | mov [msg_board_data+ecx], bl |
4729 | ; // if debug_direct_print == 1 |
4718 | ; // if debug_direct_print == 1 |
4730 | cmp byte [debug_direct_print], 1 |
4719 | cmp byte [debug_direct_print], 1 |
4731 | jnz @f |
4720 | jnz @f |
4732 | pusha |
4721 | pusha |
4733 | iglobal |
4722 | iglobal |
4734 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4723 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4735 | endg |
4724 | endg |
4736 | lea edx, [msg_board_data+ecx] |
4725 | lea edx, [msg_board_data+ecx] |
4737 | mov ecx, 0x40FFFFFF |
4726 | mov ecx, 0x40FFFFFF |
4738 | mov ebx, [msg_board_pos] |
4727 | mov ebx, [msg_board_pos] |
4739 | mov edi, 1 |
4728 | mov edi, 1 |
4740 | mov esi, 1 |
4729 | mov esi, 1 |
4741 | call dtext |
4730 | call dtext |
4742 | popa |
4731 | popa |
4743 | add word [msg_board_pos+2], 6 |
4732 | add word [msg_board_pos+2], 6 |
4744 | cmp bl, 10 |
4733 | cmp bl, 10 |
4745 | jnz @f |
4734 | jnz @f |
4746 | mov word [msg_board_pos+2], (42*6) |
4735 | mov word [msg_board_pos+2], (42*6) |
4747 | add word [msg_board_pos], 10 |
4736 | add word [msg_board_pos], 10 |
4748 | mov ax, word [Screen_Max_Y] |
4737 | mov ax, word [Screen_Max_Y] |
4749 | cmp word [msg_board_pos], ax |
4738 | cmp word [msg_board_pos], ax |
4750 | jbe @f |
4739 | jbe @f |
4751 | mov word [msg_board_pos], 10 |
4740 | mov word [msg_board_pos], 10 |
4752 | @@: |
4741 | @@: |
4753 | ; // end if |
4742 | ; // end if |
4754 | 4743 | ||
4755 | if 0 |
4744 | if 0 |
4756 | pusha |
4745 | pusha |
4757 | mov al, bl |
4746 | mov al, bl |
4758 | mov edx, 402h |
4747 | mov edx, 402h |
4759 | out dx, al |
4748 | out dx, al |
4760 | popa |
4749 | popa |
4761 | end if |
4750 | end if |
4762 | inc ecx |
4751 | inc ecx |
4763 | and ecx, msg_board_data_size - 1 |
4752 | and ecx, msg_board_data_size - 1 |
4764 | mov [msg_board_count], ecx |
4753 | mov [msg_board_count], ecx |
4765 | 4754 | ||
4766 | pop ebx eax |
4755 | pop ebx eax |
4767 | ret |
4756 | ret |
4768 | .smbl1: |
4757 | .smbl1: |
4769 | cmp eax, 2 |
4758 | cmp eax, 2 |
4770 | jne .smbl2 |
4759 | jne .smbl2 |
4771 | test ecx, ecx |
4760 | test ecx, ecx |
4772 | jz .smbl21 |
4761 | jz .smbl21 |
4773 | 4762 | ||
4774 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4763 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4775 | mov eax, msg_board_data+1 |
4764 | mov eax, msg_board_data+1 |
4776 | mov ebx, msg_board_data |
4765 | mov ebx, msg_board_data |
4777 | movzx edx, byte [ebx] |
4766 | movzx edx, byte [ebx] |
4778 | call memmove |
4767 | call memmove |
4779 | dec [msg_board_count] |
4768 | dec [msg_board_count] |
4780 | mov [esp + 32], edx ;eax |
4769 | mov [esp + 32], edx ;eax |
4781 | mov [esp + 20], dword 1 |
4770 | mov [esp + 20], dword 1 |
4782 | ret |
4771 | ret |
4783 | .smbl21: |
4772 | .smbl21: |
4784 | mov [esp+32], ecx |
4773 | mov [esp+32], ecx |
4785 | mov [esp+20], ecx |
4774 | mov [esp+20], ecx |
4786 | .smbl2: |
4775 | .smbl2: |
4787 | pop ebx eax |
4776 | pop ebx eax |
4788 | ret |
4777 | ret |
4789 | 4778 | ||
4790 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4779 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4791 | ;; 66 sys function. ;; |
4780 | ;; 66 sys function. ;; |
4792 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4781 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4793 | ;; out eax ;; |
4782 | ;; out eax ;; |
4794 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4783 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4795 | iglobal |
4784 | iglobal |
4796 | align 4 |
4785 | align 4 |
4797 | f66call: |
4786 | f66call: |
4798 | dd sys_process_def.1 ; 1 = set keyboard mode |
4787 | dd sys_process_def.1 ; 1 = set keyboard mode |
4799 | dd sys_process_def.2 ; 2 = get keyboard mode |
4788 | dd sys_process_def.2 ; 2 = get keyboard mode |
4800 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4789 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4801 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4790 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4802 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4791 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4803 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4792 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4804 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4793 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4805 | endg |
4794 | endg |
4806 | ;----------------------------------------------------------------------------- |
4795 | ;----------------------------------------------------------------------------- |
4807 | align 4 |
4796 | align 4 |
4808 | sys_process_def: |
4797 | sys_process_def: |
4809 | dec ebx |
4798 | dec ebx |
4810 | cmp ebx, 7 |
4799 | cmp ebx, 7 |
4811 | jae .not_support ;if >=8 then or eax,-1 |
4800 | jae .not_support ;if >=8 then or eax,-1 |
4812 | 4801 | ||
4813 | mov edi, [CURRENT_TASK] |
4802 | mov edi, [CURRENT_TASK] |
4814 | jmp dword [f66call+ebx*4] |
4803 | jmp dword [f66call+ebx*4] |
4815 | 4804 | ||
4816 | .not_support: |
4805 | .not_support: |
4817 | or eax, -1 |
4806 | or eax, -1 |
4818 | ret |
4807 | ret |
4819 | ;----------------------------------------------------------------------------- |
4808 | ;----------------------------------------------------------------------------- |
4820 | align 4 |
4809 | align 4 |
4821 | .1: |
4810 | .1: |
4822 | shl edi, 8 |
4811 | shl edi, 8 |
4823 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4812 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4824 | 4813 | ||
4825 | ret |
4814 | ret |
4826 | ;----------------------------------------------------------------------------- |
4815 | ;----------------------------------------------------------------------------- |
4827 | align 4 |
4816 | align 4 |
4828 | .2: ; 2 = get keyboard mode |
4817 | .2: ; 2 = get keyboard mode |
4829 | shl edi, 8 |
4818 | shl edi, 8 |
4830 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4819 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4831 | mov [esp+32], eax |
4820 | mov [esp+32], eax |
4832 | ret |
4821 | ret |
4833 | ;----------------------------------------------------------------------------- |
4822 | ;----------------------------------------------------------------------------- |
4834 | align 4 |
4823 | align 4 |
4835 | .3: ;3 = get keyboard ctrl, alt, shift |
4824 | .3: ;3 = get keyboard ctrl, alt, shift |
4836 | mov eax, [kb_state] |
4825 | mov eax, [kb_state] |
4837 | mov [esp+32], eax |
4826 | mov [esp+32], eax |
4838 | ret |
4827 | ret |
4839 | ;----------------------------------------------------------------------------- |
4828 | ;----------------------------------------------------------------------------- |
4840 | align 4 |
4829 | align 4 |
4841 | .4: |
4830 | .4: |
4842 | mov eax, hotkey_list |
4831 | mov eax, hotkey_list |
4843 | @@: |
4832 | @@: |
4844 | cmp dword [eax+8], 0 |
4833 | cmp dword [eax+8], 0 |
4845 | jz .found_free |
4834 | jz .found_free |
4846 | add eax, 16 |
4835 | add eax, 16 |
4847 | cmp eax, hotkey_list+16*256 |
4836 | cmp eax, hotkey_list+16*256 |
4848 | jb @b |
4837 | jb @b |
4849 | mov dword [esp+32], 1 |
4838 | mov dword [esp+32], 1 |
4850 | ret |
4839 | ret |
4851 | .found_free: |
4840 | .found_free: |
4852 | mov [eax+8], edi |
4841 | mov [eax+8], edi |
4853 | mov [eax+4], edx |
4842 | mov [eax+4], edx |
4854 | movzx ecx, cl |
4843 | movzx ecx, cl |
4855 | lea ecx, [hotkey_scancodes+ecx*4] |
4844 | lea ecx, [hotkey_scancodes+ecx*4] |
4856 | mov edx, [ecx] |
4845 | mov edx, [ecx] |
4857 | mov [eax], edx |
4846 | mov [eax], edx |
4858 | mov [ecx], eax |
4847 | mov [ecx], eax |
4859 | mov [eax+12], ecx |
4848 | mov [eax+12], ecx |
4860 | test edx, edx |
4849 | test edx, edx |
4861 | jz @f |
4850 | jz @f |
4862 | mov [edx+12], eax |
4851 | mov [edx+12], eax |
4863 | @@: |
4852 | @@: |
4864 | and dword [esp+32], 0 |
4853 | and dword [esp+32], 0 |
4865 | ret |
4854 | ret |
4866 | ;----------------------------------------------------------------------------- |
4855 | ;----------------------------------------------------------------------------- |
4867 | align 4 |
4856 | align 4 |
4868 | .5: |
4857 | .5: |
4869 | movzx ebx, cl |
4858 | movzx ebx, cl |
4870 | lea ebx, [hotkey_scancodes+ebx*4] |
4859 | lea ebx, [hotkey_scancodes+ebx*4] |
4871 | mov eax, [ebx] |
4860 | mov eax, [ebx] |
4872 | .scan: |
4861 | .scan: |
4873 | test eax, eax |
4862 | test eax, eax |
4874 | jz .notfound |
4863 | jz .notfound |
4875 | cmp [eax+8], edi |
4864 | cmp [eax+8], edi |
4876 | jnz .next |
4865 | jnz .next |
4877 | cmp [eax+4], edx |
4866 | cmp [eax+4], edx |
4878 | jz .found |
4867 | jz .found |
4879 | .next: |
4868 | .next: |
4880 | mov eax, [eax] |
4869 | mov eax, [eax] |
4881 | jmp .scan |
4870 | jmp .scan |
4882 | .notfound: |
4871 | .notfound: |
4883 | mov dword [esp+32], 1 |
4872 | mov dword [esp+32], 1 |
4884 | ret |
4873 | ret |
4885 | .found: |
4874 | .found: |
4886 | mov ecx, [eax] |
4875 | mov ecx, [eax] |
4887 | jecxz @f |
4876 | jecxz @f |
4888 | mov edx, [eax+12] |
4877 | mov edx, [eax+12] |
4889 | mov [ecx+12], edx |
4878 | mov [ecx+12], edx |
4890 | @@: |
4879 | @@: |
4891 | mov ecx, [eax+12] |
4880 | mov ecx, [eax+12] |
4892 | mov edx, [eax] |
4881 | mov edx, [eax] |
4893 | mov [ecx], edx |
4882 | mov [ecx], edx |
4894 | xor edx, edx |
4883 | xor edx, edx |
4895 | mov [eax+4], edx |
4884 | mov [eax+4], edx |
4896 | mov [eax+8], edx |
4885 | mov [eax+8], edx |
4897 | mov [eax+12], edx |
4886 | mov [eax+12], edx |
4898 | mov [eax], edx |
4887 | mov [eax], edx |
4899 | mov [esp+32], edx |
4888 | mov [esp+32], edx |
4900 | ret |
4889 | ret |
4901 | ;----------------------------------------------------------------------------- |
4890 | ;----------------------------------------------------------------------------- |
4902 | align 4 |
4891 | align 4 |
4903 | .6: |
4892 | .6: |
4904 | pushfd |
4893 | pushfd |
4905 | cli |
4894 | cli |
4906 | mov eax, [PID_lock_input] |
4895 | mov eax, [PID_lock_input] |
4907 | test eax, eax |
4896 | test eax, eax |
4908 | jnz @f |
4897 | jnz @f |
4909 | ; get current PID |
4898 | ; get current PID |
4910 | mov eax, [CURRENT_TASK] |
4899 | mov eax, [CURRENT_TASK] |
4911 | shl eax, 5 |
4900 | shl eax, 5 |
4912 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4901 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4913 | ; set current PID for lock input |
4902 | ; set current PID for lock input |
4914 | mov [PID_lock_input], eax |
4903 | mov [PID_lock_input], eax |
4915 | @@: |
4904 | @@: |
4916 | popfd |
4905 | popfd |
4917 | ret |
4906 | ret |
4918 | ;----------------------------------------------------------------------------- |
4907 | ;----------------------------------------------------------------------------- |
4919 | align 4 |
4908 | align 4 |
4920 | .7: |
4909 | .7: |
4921 | mov eax, [PID_lock_input] |
4910 | mov eax, [PID_lock_input] |
4922 | test eax, eax |
4911 | test eax, eax |
4923 | jz @f |
4912 | jz @f |
4924 | ; get current PID |
4913 | ; get current PID |
4925 | mov ebx, [CURRENT_TASK] |
4914 | mov ebx, [CURRENT_TASK] |
4926 | shl ebx, 5 |
4915 | shl ebx, 5 |
4927 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4916 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4928 | ; compare current lock input with current PID |
4917 | ; compare current lock input with current PID |
4929 | cmp ebx, eax |
4918 | cmp ebx, eax |
4930 | jne @f |
4919 | jne @f |
4931 | 4920 | ||
4932 | xor eax, eax |
4921 | xor eax, eax |
4933 | mov [PID_lock_input], eax |
4922 | mov [PID_lock_input], eax |
4934 | @@: |
4923 | @@: |
4935 | ret |
4924 | ret |
4936 | ;----------------------------------------------------------------------------- |
4925 | ;----------------------------------------------------------------------------- |
4937 | uglobal |
4926 | uglobal |
4938 | PID_lock_input dd 0x0 |
4927 | PID_lock_input dd 0x0 |
4939 | endg |
4928 | endg |
4940 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4929 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4941 | ;; 61 sys function. ;; |
4930 | ;; 61 sys function. ;; |
4942 | ;; in eax=61,ebx in [1..3] ;; |
4931 | ;; in eax=61,ebx in [1..3] ;; |
4943 | ;; out eax ;; |
4932 | ;; out eax ;; |
4944 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4933 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4945 | iglobal |
4934 | iglobal |
4946 | align 4 |
4935 | align 4 |
4947 | f61call: |
4936 | f61call: |
4948 | dd sys_gs.1 ; resolution |
4937 | dd sys_gs.1 ; resolution |
4949 | dd sys_gs.2 ; bits per pixel |
4938 | dd sys_gs.2 ; bits per pixel |
4950 | dd sys_gs.3 ; bytes per scanline |
4939 | dd sys_gs.3 ; bytes per scanline |
4951 | endg |
4940 | endg |
4952 | 4941 | ||
4953 | 4942 | ||
4954 | align 4 |
4943 | align 4 |
4955 | 4944 | ||
4956 | sys_gs: ; direct screen access |
4945 | sys_gs: ; direct screen access |
4957 | dec ebx |
4946 | dec ebx |
4958 | cmp ebx, 2 |
4947 | cmp ebx, 2 |
4959 | ja .not_support |
4948 | ja .not_support |
4960 | jmp dword [f61call+ebx*4] |
4949 | jmp dword [f61call+ebx*4] |
4961 | .not_support: |
4950 | .not_support: |
4962 | or [esp+32], dword -1 |
4951 | or [esp+32], dword -1 |
4963 | ret |
4952 | ret |
4964 | 4953 | ||
4965 | 4954 | ||
4966 | .1: ; resolution |
4955 | .1: ; resolution |
4967 | mov eax, [Screen_Max_X] |
4956 | mov eax, [Screen_Max_X] |
4968 | shl eax, 16 |
4957 | shl eax, 16 |
4969 | mov ax, word [Screen_Max_Y] |
4958 | mov ax, word [Screen_Max_Y] |
4970 | add eax, 0x00010001 |
4959 | add eax, 0x00010001 |
4971 | mov [esp+32], eax |
4960 | mov [esp+32], eax |
4972 | ret |
4961 | ret |
4973 | .2: ; bits per pixel |
4962 | .2: ; bits per pixel |
4974 | mov eax, [_display.bpp] |
4963 | mov eax, [_display.bpp] |
4975 | mov [esp+32], eax |
4964 | mov [esp+32], eax |
4976 | ret |
4965 | ret |
4977 | .3: ; bytes per scanline |
4966 | .3: ; bytes per scanline |
4978 | mov eax, [_display.pitch] |
4967 | mov eax, [_display.pitch] |
4979 | mov [esp+32], eax |
4968 | mov [esp+32], eax |
4980 | ret |
4969 | ret |
4981 | 4970 | ||
4982 | align 4 ; system functions |
4971 | align 4 ; system functions |
4983 | 4972 | ||
4984 | syscall_setpixel: ; SetPixel |
4973 | syscall_setpixel: ; SetPixel |
4985 | 4974 | ||
4986 | mov eax, ebx |
4975 | mov eax, ebx |
4987 | mov ebx, ecx |
4976 | mov ebx, ecx |
4988 | mov ecx, edx |
4977 | mov ecx, edx |
4989 | mov edx, [TASK_BASE] |
4978 | mov edx, [TASK_BASE] |
4990 | add eax, [edx-twdw+WDATA.box.left] |
4979 | add eax, [edx-twdw+WDATA.box.left] |
4991 | add ebx, [edx-twdw+WDATA.box.top] |
4980 | add ebx, [edx-twdw+WDATA.box.top] |
4992 | mov edi, [current_slot] |
4981 | mov edi, [current_slot] |
4993 | add eax, [edi+APPDATA.wnd_clientbox.left] |
4982 | add eax, [edi+APPDATA.wnd_clientbox.left] |
4994 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
4983 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
4995 | xor edi, edi ; no force |
4984 | xor edi, edi ; no force |
4996 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
4985 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
4997 | ; jmp [putpixel] |
4986 | ; jmp [putpixel] |
4998 | jmp __sys_putpixel |
4987 | jmp __sys_putpixel |
4999 | 4988 | ||
5000 | align 4 |
4989 | align 4 |
5001 | 4990 | ||
5002 | syscall_writetext: ; WriteText |
4991 | syscall_writetext: ; WriteText |
5003 | 4992 | ||
5004 | mov eax, [TASK_BASE] |
4993 | mov eax, [TASK_BASE] |
5005 | mov ebp, [eax-twdw+WDATA.box.left] |
4994 | mov ebp, [eax-twdw+WDATA.box.left] |
5006 | push esi |
4995 | push esi |
5007 | mov esi, [current_slot] |
4996 | mov esi, [current_slot] |
5008 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
4997 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5009 | shl ebp, 16 |
4998 | shl ebp, 16 |
5010 | add ebp, [eax-twdw+WDATA.box.top] |
4999 | add ebp, [eax-twdw+WDATA.box.top] |
5011 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5000 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5012 | pop esi |
5001 | pop esi |
5013 | test ecx, 0x08000000 ; redirect the output to the user area |
5002 | test ecx, 0x08000000 ; redirect the output to the user area |
5014 | jnz @f |
5003 | jnz @f |
5015 | add ebx, ebp |
5004 | add ebx, ebp |
5016 | align 4 |
5005 | align 4 |
5017 | @@: |
5006 | @@: |
5018 | mov eax, edi |
5007 | mov eax, edi |
5019 | test ecx, 0x08000000 ; redirect the output to the user area |
5008 | test ecx, 0x08000000 ; redirect the output to the user area |
5020 | jnz dtext |
5009 | jnz dtext |
5021 | xor edi, edi |
5010 | xor edi, edi |
5022 | jmp dtext |
5011 | jmp dtext |
5023 | 5012 | ||
5024 | align 4 |
5013 | align 4 |
5025 | 5014 | ||
5026 | syscall_drawrect: ; DrawRect |
5015 | syscall_drawrect: ; DrawRect |
5027 | 5016 | ||
5028 | mov edi, edx ; color + gradient |
5017 | mov edi, edx ; color + gradient |
5029 | and edi, 0x80FFFFFF |
5018 | and edi, 0x80FFFFFF |
5030 | test bx, bx ; x.size |
5019 | test bx, bx ; x.size |
5031 | je .drectr |
5020 | je .drectr |
5032 | test cx, cx ; y.size |
5021 | test cx, cx ; y.size |
5033 | je .drectr |
5022 | je .drectr |
5034 | 5023 | ||
5035 | mov eax, ebx ; bad idea |
5024 | mov eax, ebx ; bad idea |
5036 | mov ebx, ecx |
5025 | mov ebx, ecx |
5037 | 5026 | ||
5038 | movzx ecx, ax ; ecx - x.size |
5027 | movzx ecx, ax ; ecx - x.size |
5039 | shr eax, 16 ; eax - x.coord |
5028 | shr eax, 16 ; eax - x.coord |
5040 | movzx edx, bx ; edx - y.size |
5029 | movzx edx, bx ; edx - y.size |
5041 | shr ebx, 16 ; ebx - y.coord |
5030 | shr ebx, 16 ; ebx - y.coord |
5042 | mov esi, [current_slot] |
5031 | mov esi, [current_slot] |
5043 | 5032 | ||
5044 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5033 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5045 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5034 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5046 | add ecx, eax |
5035 | add ecx, eax |
5047 | add edx, ebx |
5036 | add edx, ebx |
5048 | ; jmp [drawbar] |
5037 | ; jmp [drawbar] |
5049 | jmp vesa20_drawbar |
5038 | jmp vesa20_drawbar |
5050 | .drectr: |
5039 | .drectr: |
5051 | ret |
5040 | ret |
5052 | 5041 | ||
5053 | align 4 |
5042 | align 4 |
5054 | syscall_getscreensize: ; GetScreenSize |
5043 | syscall_getscreensize: ; GetScreenSize |
5055 | mov ax, word [Screen_Max_X] |
5044 | mov ax, word [Screen_Max_X] |
5056 | shl eax, 16 |
5045 | shl eax, 16 |
5057 | mov ax, word [Screen_Max_Y] |
5046 | mov ax, word [Screen_Max_Y] |
5058 | mov [esp + 32], eax |
5047 | mov [esp + 32], eax |
5059 | ret |
5048 | ret |
5060 | ;----------------------------------------------------------------------------- |
5049 | ;----------------------------------------------------------------------------- |
5061 | align 4 |
5050 | align 4 |
5062 | syscall_cdaudio: |
5051 | syscall_cdaudio: |
5063 | ; ECX - position of CD/DVD-drive |
5052 | ; ECX - position of CD/DVD-drive |
5064 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5053 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5065 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5054 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5066 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5055 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5067 | cmp ecx, 11 |
5056 | cmp ecx, 11 |
5068 | ja .exit |
5057 | ja .exit |
5069 | 5058 | ||
5070 | mov eax, ecx |
5059 | mov eax, ecx |
5071 | shr eax, 2 |
5060 | shr eax, 2 |
5072 | lea eax, [eax*5] |
5061 | lea eax, [eax*5] |
5073 | mov al, [eax+DRIVE_DATA+1] |
5062 | mov al, [eax+DRIVE_DATA+1] |
5074 | 5063 | ||
5075 | push ecx ebx |
5064 | push ecx ebx |
5076 | mov ebx, ecx |
5065 | mov ebx, ecx |
5077 | and ebx, 11b |
5066 | and ebx, 11b |
5078 | shl ebx, 1 |
5067 | shl ebx, 1 |
5079 | mov cl, 6 |
5068 | mov cl, 6 |
5080 | sub cl, bl |
5069 | sub cl, bl |
5081 | shr al, cl |
5070 | shr al, cl |
5082 | test al, 2 ; it's not an ATAPI device |
5071 | test al, 2 ; it's not an ATAPI device |
5083 | pop ebx ecx |
5072 | pop ebx ecx |
5084 | 5073 | ||
5085 | jz .exit |
5074 | jz .exit |
5086 | 5075 | ||
5087 | cmp ebx, 4 |
5076 | cmp ebx, 4 |
5088 | je .eject |
5077 | je .eject |
5089 | 5078 | ||
5090 | cmp ebx, 5 |
5079 | cmp ebx, 5 |
5091 | je .load |
5080 | je .load |
5092 | ;-------------------------------------- |
5081 | ;-------------------------------------- |
5093 | .exit: |
5082 | .exit: |
5094 | ret |
5083 | ret |
5095 | ;-------------------------------------- |
5084 | ;-------------------------------------- |
5096 | .load: |
5085 | .load: |
5097 | call .reserve |
5086 | call .reserve |
5098 | call LoadMedium |
5087 | call LoadMedium |
5099 | jmp .free |
5088 | jmp .free |
5100 | ;-------------------------------------- |
5089 | ;-------------------------------------- |
5101 | .eject: |
5090 | .eject: |
5102 | call .reserve |
5091 | call .reserve |
5103 | call clear_CD_cache |
5092 | call clear_CD_cache |
5104 | call allow_medium_removal |
5093 | call allow_medium_removal |
5105 | call EjectMedium |
5094 | call EjectMedium |
5106 | jmp .free |
5095 | jmp .free |
5107 | ;-------------------------------------- |
5096 | ;-------------------------------------- |
5108 | .reserve: |
5097 | .reserve: |
5109 | call reserve_cd |
5098 | call reserve_cd |
5110 | 5099 | ||
5111 | mov ebx, ecx |
5100 | mov ebx, ecx |
5112 | inc ebx |
5101 | inc ebx |
5113 | mov [cdpos], ebx |
5102 | mov [cdpos], ebx |
5114 | 5103 | ||
5115 | mov eax, ecx |
5104 | mov eax, ecx |
5116 | shr eax, 1 |
5105 | shr eax, 1 |
5117 | and eax, 1 |
5106 | and eax, 1 |
5118 | inc eax |
5107 | inc eax |
5119 | mov [ChannelNumber], ax |
5108 | mov [ChannelNumber], ax |
5120 | mov eax, ecx |
5109 | mov eax, ecx |
5121 | and eax, 1 |
5110 | and eax, 1 |
5122 | mov [DiskNumber], al |
5111 | mov [DiskNumber], al |
5123 | call reserve_cd_channel |
5112 | call reserve_cd_channel |
5124 | ret |
5113 | ret |
5125 | ;-------------------------------------- |
5114 | ;-------------------------------------- |
5126 | .free: |
5115 | .free: |
5127 | call free_cd_channel |
5116 | call free_cd_channel |
5128 | and [cd_status], 0 |
5117 | and [cd_status], 0 |
5129 | ret |
5118 | ret |
5130 | ;----------------------------------------------------------------------------- |
5119 | ;----------------------------------------------------------------------------- |
5131 | align 4 |
5120 | align 4 |
5132 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5121 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5133 | cmp ebx, [Screen_Max_X] |
5122 | cmp ebx, [Screen_Max_X] |
5134 | jbe @f |
5123 | jbe @f |
5135 | cmp ecx, [Screen_Max_Y] |
5124 | cmp ecx, [Screen_Max_Y] |
5136 | jbe @f |
5125 | jbe @f |
5137 | xor eax, eax |
5126 | xor eax, eax |
5138 | jmp .store |
5127 | jmp .store |
5139 | ;-------------------------------------- |
5128 | ;-------------------------------------- |
5140 | align 4 |
5129 | align 4 |
5141 | @@: |
5130 | @@: |
5142 | mov eax, [d_width_calc_area + ecx*4] |
5131 | mov eax, [d_width_calc_area + ecx*4] |
5143 | add eax, [_WinMapAddress] |
5132 | add eax, [_WinMapAddress] |
5144 | movzx eax, byte[eax+ebx] ; get value for current point |
5133 | movzx eax, byte[eax+ebx] ; get value for current point |
5145 | ;-------------------------------------- |
5134 | ;-------------------------------------- |
5146 | align 4 |
5135 | align 4 |
5147 | .store: |
5136 | .store: |
5148 | mov [esp + 32], eax |
5137 | mov [esp + 32], eax |
5149 | ret |
5138 | ret |
5150 | ;----------------------------------------------------------------------------- |
5139 | ;----------------------------------------------------------------------------- |
5151 | align 4 |
5140 | align 4 |
5152 | syscall_getpixel: ; GetPixel |
5141 | syscall_getpixel: ; GetPixel |
5153 | mov ecx, [Screen_Max_X] |
5142 | mov ecx, [Screen_Max_X] |
5154 | inc ecx |
5143 | inc ecx |
5155 | xor edx, edx |
5144 | xor edx, edx |
5156 | mov eax, ebx |
5145 | mov eax, ebx |
5157 | div ecx |
5146 | div ecx |
5158 | mov ebx, edx |
5147 | mov ebx, edx |
5159 | xchg eax, ebx |
5148 | xchg eax, ebx |
5160 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5149 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5161 | call dword [GETPIXEL]; eax - x, ebx - y |
5150 | call dword [GETPIXEL]; eax - x, ebx - y |
5162 | mov [esp + 32], ecx |
5151 | mov [esp + 32], ecx |
5163 | ret |
5152 | ret |
5164 | ;----------------------------------------------------------------------------- |
5153 | ;----------------------------------------------------------------------------- |
5165 | align 4 |
5154 | align 4 |
5166 | syscall_getarea: |
5155 | syscall_getarea: |
5167 | ;eax = 36 |
5156 | ;eax = 36 |
5168 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5157 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5169 | ;ecx = [size x]*65536 + [size y] |
5158 | ;ecx = [size x]*65536 + [size y] |
5170 | ;edx = [start x]*65536 + [start y] |
5159 | ;edx = [start x]*65536 + [start y] |
5171 | pushad |
5160 | pushad |
5172 | mov edi, ebx |
5161 | mov edi, ebx |
5173 | mov eax, edx |
5162 | mov eax, edx |
5174 | shr eax, 16 |
5163 | shr eax, 16 |
5175 | mov ebx, edx |
5164 | mov ebx, edx |
5176 | and ebx, 0xffff |
5165 | and ebx, 0xffff |
5177 | dec eax |
5166 | dec eax |
5178 | dec ebx |
5167 | dec ebx |
5179 | ; eax - x, ebx - y |
5168 | ; eax - x, ebx - y |
5180 | mov edx, ecx |
5169 | mov edx, ecx |
5181 | 5170 | ||
5182 | shr ecx, 16 |
5171 | shr ecx, 16 |
5183 | and edx, 0xffff |
5172 | and edx, 0xffff |
5184 | mov esi, ecx |
5173 | mov esi, ecx |
5185 | ; ecx - size x, edx - size y |
5174 | ; ecx - size x, edx - size y |
5186 | 5175 | ||
5187 | mov ebp, edx |
5176 | mov ebp, edx |
5188 | dec ebp |
5177 | dec ebp |
5189 | lea ebp, [ebp*3] |
5178 | lea ebp, [ebp*3] |
5190 | 5179 | ||
5191 | imul ebp, esi |
5180 | imul ebp, esi |
5192 | 5181 | ||
5193 | mov esi, ecx |
5182 | mov esi, ecx |
5194 | dec esi |
5183 | dec esi |
5195 | lea esi, [esi*3] |
5184 | lea esi, [esi*3] |
5196 | 5185 | ||
5197 | add ebp, esi |
5186 | add ebp, esi |
5198 | add ebp, edi |
5187 | add ebp, edi |
5199 | 5188 | ||
5200 | add ebx, edx |
5189 | add ebx, edx |
5201 | ;-------------------------------------- |
5190 | ;-------------------------------------- |
5202 | align 4 |
5191 | align 4 |
5203 | .start_y: |
5192 | .start_y: |
5204 | push ecx edx |
5193 | push ecx edx |
5205 | ;-------------------------------------- |
5194 | ;-------------------------------------- |
5206 | align 4 |
5195 | align 4 |
5207 | .start_x: |
5196 | .start_x: |
5208 | push eax ebx ecx |
5197 | push eax ebx ecx |
5209 | add eax, ecx |
5198 | add eax, ecx |
5210 | 5199 | ||
5211 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5200 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5212 | call dword [GETPIXEL]; eax - x, ebx - y |
5201 | call dword [GETPIXEL]; eax - x, ebx - y |
5213 | 5202 | ||
5214 | mov [ebp], cx |
5203 | mov [ebp], cx |
5215 | shr ecx, 16 |
5204 | shr ecx, 16 |
5216 | mov [ebp+2], cl |
5205 | mov [ebp+2], cl |
5217 | 5206 | ||
5218 | pop ecx ebx eax |
5207 | pop ecx ebx eax |
5219 | sub ebp, 3 |
5208 | sub ebp, 3 |
5220 | dec ecx |
5209 | dec ecx |
5221 | jnz .start_x |
5210 | jnz .start_x |
5222 | pop edx ecx |
5211 | pop edx ecx |
5223 | dec ebx |
5212 | dec ebx |
5224 | dec edx |
5213 | dec edx |
5225 | jnz .start_y |
5214 | jnz .start_y |
5226 | popad |
5215 | popad |
5227 | ret |
5216 | ret |
5228 | ;----------------------------------------------------------------------------- |
5217 | ;----------------------------------------------------------------------------- |
5229 | align 4 |
5218 | align 4 |
5230 | syscall_putarea_backgr: |
5219 | syscall_putarea_backgr: |
5231 | ;eax = 25 |
5220 | ;eax = 25 |
5232 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5221 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5233 | ;ecx = [size x]*65536 + [size y] |
5222 | ;ecx = [size x]*65536 + [size y] |
5234 | ;edx = [start x]*65536 + [start y] |
5223 | ;edx = [start x]*65536 + [start y] |
5235 | pushad |
5224 | pushad |
5236 | mov edi, ebx |
5225 | mov edi, ebx |
5237 | mov eax, edx |
5226 | mov eax, edx |
5238 | shr eax, 16 |
5227 | shr eax, 16 |
5239 | mov ebx, edx |
5228 | mov ebx, edx |
5240 | and ebx, 0xffff |
5229 | and ebx, 0xffff |
5241 | dec eax |
5230 | dec eax |
5242 | dec ebx |
5231 | dec ebx |
5243 | ; eax - x, ebx - y |
5232 | ; eax - x, ebx - y |
5244 | mov edx, ecx |
5233 | mov edx, ecx |
5245 | shr ecx, 16 |
5234 | shr ecx, 16 |
5246 | and edx, 0xffff |
5235 | and edx, 0xffff |
5247 | mov esi, ecx |
5236 | mov esi, ecx |
5248 | ; ecx - size x, edx - size y |
5237 | ; ecx - size x, edx - size y |
5249 | mov ebp, edx |
5238 | mov ebp, edx |
5250 | dec ebp |
5239 | dec ebp |
5251 | shl ebp, 2 |
5240 | shl ebp, 2 |
5252 | 5241 | ||
5253 | imul ebp, esi |
5242 | imul ebp, esi |
5254 | 5243 | ||
5255 | mov esi, ecx |
5244 | mov esi, ecx |
5256 | dec esi |
5245 | dec esi |
5257 | shl esi, 2 |
5246 | shl esi, 2 |
5258 | 5247 | ||
5259 | add ebp, esi |
5248 | add ebp, esi |
5260 | add ebp, edi |
5249 | add ebp, edi |
5261 | 5250 | ||
5262 | add ebx, edx |
5251 | add ebx, edx |
5263 | ;-------------------------------------- |
5252 | ;-------------------------------------- |
5264 | align 4 |
5253 | align 4 |
5265 | .start_y: |
5254 | .start_y: |
5266 | push ecx edx |
5255 | push ecx edx |
5267 | ;-------------------------------------- |
5256 | ;-------------------------------------- |
5268 | align 4 |
5257 | align 4 |
5269 | .start_x: |
5258 | .start_x: |
5270 | push eax ecx |
5259 | push eax ecx |
5271 | add eax, ecx |
5260 | add eax, ecx |
5272 | 5261 | ||
5273 | mov ecx, [ebp] |
5262 | mov ecx, [ebp] |
5274 | rol ecx, 8 |
5263 | rol ecx, 8 |
5275 | test cl, cl ; transparensy = 0 |
5264 | test cl, cl ; transparensy = 0 |
5276 | jz .no_put |
5265 | jz .no_put |
5277 | 5266 | ||
5278 | xor cl, cl |
5267 | xor cl, cl |
5279 | ror ecx, 8 |
5268 | ror ecx, 8 |
5280 | 5269 | ||
5281 | pushad |
5270 | pushad |
5282 | mov edx, [d_width_calc_area + ebx*4] |
5271 | mov edx, [d_width_calc_area + ebx*4] |
5283 | add edx, [_WinMapAddress] |
5272 | add edx, [_WinMapAddress] |
5284 | movzx edx, byte [eax+edx] |
5273 | movzx edx, byte [eax+edx] |
5285 | cmp dl, byte 1 |
5274 | cmp dl, byte 1 |
5286 | jne @f |
5275 | jne @f |
5287 | 5276 | ||
5288 | call dword [PUTPIXEL]; eax - x, ebx - y |
5277 | call dword [PUTPIXEL]; eax - x, ebx - y |
5289 | ;-------------------------------------- |
5278 | ;-------------------------------------- |
5290 | align 4 |
5279 | align 4 |
5291 | @@: |
5280 | @@: |
5292 | popad |
5281 | popad |
5293 | ;-------------------------------------- |
5282 | ;-------------------------------------- |
5294 | align 4 |
5283 | align 4 |
5295 | .no_put: |
5284 | .no_put: |
5296 | pop ecx eax |
5285 | pop ecx eax |
5297 | 5286 | ||
5298 | sub ebp, 4 |
5287 | sub ebp, 4 |
5299 | dec ecx |
5288 | dec ecx |
5300 | jnz .start_x |
5289 | jnz .start_x |
5301 | 5290 | ||
5302 | pop edx ecx |
5291 | pop edx ecx |
5303 | dec ebx |
5292 | dec ebx |
5304 | dec edx |
5293 | dec edx |
5305 | jnz .start_y |
5294 | jnz .start_y |
5306 | 5295 | ||
5307 | popad |
5296 | popad |
5308 | ret |
5297 | ret |
5309 | ;----------------------------------------------------------------------------- |
5298 | ;----------------------------------------------------------------------------- |
5310 | align 4 |
5299 | align 4 |
5311 | syscall_drawline: ; DrawLine |
5300 | syscall_drawline: ; DrawLine |
5312 | 5301 | ||
5313 | mov edi, [TASK_BASE] |
5302 | mov edi, [TASK_BASE] |
5314 | movzx eax, word[edi-twdw+WDATA.box.left] |
5303 | movzx eax, word[edi-twdw+WDATA.box.left] |
5315 | mov ebp, eax |
5304 | mov ebp, eax |
5316 | mov esi, [current_slot] |
5305 | mov esi, [current_slot] |
5317 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5306 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5318 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5307 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5319 | add ebp, ebx |
5308 | add ebp, ebx |
5320 | shl eax, 16 |
5309 | shl eax, 16 |
5321 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5310 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5322 | add eax, ebp |
5311 | add eax, ebp |
5323 | mov ebp, ebx |
5312 | mov ebp, ebx |
5324 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5313 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5325 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5314 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5326 | add ebp, ecx |
5315 | add ebp, ecx |
5327 | shl ebx, 16 |
5316 | shl ebx, 16 |
5328 | xor edi, edi |
5317 | xor edi, edi |
5329 | add ebx, ebp |
5318 | add ebx, ebp |
5330 | mov ecx, edx |
5319 | mov ecx, edx |
5331 | ; jmp [draw_line] |
5320 | ; jmp [draw_line] |
5332 | jmp __sys_draw_line |
5321 | jmp __sys_draw_line |
5333 | 5322 | ||
5334 | 5323 | ||
5335 | align 4 |
5324 | align 4 |
5336 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5325 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5337 | 5326 | ||
5338 | call r_f_port_area |
5327 | call r_f_port_area |
5339 | mov [esp+32], eax |
5328 | mov [esp+32], eax |
5340 | ret |
5329 | ret |
5341 | 5330 | ||
5342 | align 4 |
5331 | align 4 |
5343 | syscall_threads: ; CreateThreads |
5332 | syscall_threads: ; CreateThreads |
5344 | ; |
5333 | ; |
5345 | ; ecx=thread entry point |
5334 | ; ecx=thread entry point |
5346 | ; edx=thread stack pointer |
5335 | ; edx=thread stack pointer |
5347 | ; |
5336 | ; |
5348 | ; on return : eax = pid |
5337 | ; on return : eax = pid |
5349 | 5338 | ||
5350 | xor ebx, ebx |
5339 | xor ebx, ebx |
5351 | call new_sys_threads |
5340 | call new_sys_threads |
5352 | 5341 | ||
5353 | mov [esp+32], eax |
5342 | mov [esp+32], eax |
5354 | ret |
5343 | ret |
5355 | 5344 | ||
5356 | align 4 |
5345 | align 4 |
5357 | 5346 | ||
5358 | paleholder: |
5347 | paleholder: |
5359 | ret |
5348 | ret |
5360 | ;------------------------------------------------------------------------------ |
5349 | ;------------------------------------------------------------------------------ |
5361 | align 4 |
5350 | align 4 |
5362 | calculate_fast_getting_offset_for_WinMapAddress: |
5351 | calculate_fast_getting_offset_for_WinMapAddress: |
5363 | ; calculate data area for fast getting offset to _WinMapAddress |
5352 | ; calculate data area for fast getting offset to _WinMapAddress |
5364 | xor eax, eax |
5353 | xor eax, eax |
5365 | mov ecx, [_display.height] |
5354 | mov ecx, [_display.height] |
5366 | mov edi, d_width_calc_area |
5355 | mov edi, d_width_calc_area |
5367 | cld |
5356 | cld |
5368 | @@: |
5357 | @@: |
5369 | stosd |
5358 | stosd |
5370 | add eax, [_display.width] |
5359 | add eax, [_display.width] |
5371 | dec ecx |
5360 | dec ecx |
5372 | jnz @r |
5361 | jnz @r |
5373 | ret |
5362 | ret |
5374 | ;------------------------------------------------------------------------------ |
5363 | ;------------------------------------------------------------------------------ |
5375 | align 4 |
5364 | align 4 |
5376 | calculate_fast_getting_offset_for_LFB: |
5365 | calculate_fast_getting_offset_for_LFB: |
5377 | ; calculate data area for fast getting offset to LFB |
5366 | ; calculate data area for fast getting offset to LFB |
5378 | xor eax, eax |
5367 | xor eax, eax |
5379 | mov ecx, [_display.height] |
5368 | mov ecx, [_display.height] |
5380 | mov edi, BPSLine_calc_area |
5369 | mov edi, BPSLine_calc_area |
5381 | cld |
5370 | cld |
5382 | @@: |
5371 | @@: |
5383 | stosd |
5372 | stosd |
5384 | add eax, [_display.pitch] |
5373 | add eax, [_display.pitch] |
5385 | dec ecx |
5374 | dec ecx |
5386 | jnz @r |
5375 | jnz @r |
5387 | ret |
5376 | ret |
5388 | ;------------------------------------------------------------------------------ |
5377 | ;------------------------------------------------------------------------------ |
5389 | align 4 |
5378 | align 4 |
5390 | set_screen: |
5379 | set_screen: |
5391 | ; in: |
5380 | ; in: |
5392 | ; eax - new Screen_Max_X |
5381 | ; eax - new Screen_Max_X |
5393 | ; ecx - new BytesPerScanLine |
5382 | ; ecx - new BytesPerScanLine |
5394 | ; edx - new Screen_Max_Y |
5383 | ; edx - new Screen_Max_Y |
5395 | 5384 | ||
5396 | pushfd |
5385 | pushfd |
5397 | cli |
5386 | cli |
5398 | 5387 | ||
5399 | mov [Screen_Max_X], eax |
5388 | mov [Screen_Max_X], eax |
5400 | mov [Screen_Max_Y], edx |
5389 | mov [Screen_Max_Y], edx |
5401 | mov [_display.pitch], ecx |
5390 | mov [_display.pitch], ecx |
5402 | 5391 | ||
5403 | mov [screen_workarea.right], eax |
5392 | mov [screen_workarea.right], eax |
5404 | mov [screen_workarea.bottom], edx |
5393 | mov [screen_workarea.bottom], edx |
5405 | 5394 | ||
5406 | push ebx |
5395 | push ebx |
5407 | push esi |
5396 | push esi |
5408 | push edi |
5397 | push edi |
5409 | 5398 | ||
5410 | pushad |
5399 | pushad |
5411 | 5400 | ||
5412 | cmp [do_not_touch_winmap], 1 |
5401 | cmp [do_not_touch_winmap], 1 |
5413 | je @f |
5402 | je @f |
5414 | 5403 | ||
5415 | stdcall kernel_free, [_WinMapAddress] |
5404 | stdcall kernel_free, [_WinMapAddress] |
5416 | 5405 | ||
5417 | mov eax, [_display.width] |
5406 | mov eax, [_display.width] |
5418 | mul [_display.height] |
5407 | mul [_display.height] |
5419 | mov [_WinMapSize], eax |
5408 | mov [_WinMapSize], eax |
5420 | 5409 | ||
5421 | stdcall kernel_alloc, eax |
5410 | stdcall kernel_alloc, eax |
5422 | mov [_WinMapAddress], eax |
5411 | mov [_WinMapAddress], eax |
5423 | test eax, eax |
5412 | test eax, eax |
5424 | jz .epic_fail |
5413 | jz .epic_fail |
5425 | ; store for f.18.24 |
5414 | ; store for f.18.24 |
5426 | mov eax, [_display.width] |
5415 | mov eax, [_display.width] |
5427 | mov [display_width_standard], eax |
5416 | mov [display_width_standard], eax |
5428 | 5417 | ||
5429 | mov eax, [_display.height] |
5418 | mov eax, [_display.height] |
5430 | mov [display_height_standard], eax |
5419 | mov [display_height_standard], eax |
5431 | @@: |
5420 | @@: |
5432 | call calculate_fast_getting_offset_for_WinMapAddress |
5421 | call calculate_fast_getting_offset_for_WinMapAddress |
5433 | ; for Qemu or non standart video cards |
5422 | ; for Qemu or non standart video cards |
5434 | ; Unfortunately [BytesPerScanLine] does not always |
5423 | ; Unfortunately [BytesPerScanLine] does not always |
5435 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5424 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5436 | call calculate_fast_getting_offset_for_LFB |
5425 | call calculate_fast_getting_offset_for_LFB |
5437 | popad |
5426 | popad |
5438 | 5427 | ||
5439 | call repos_windows |
5428 | call repos_windows |
5440 | xor eax, eax |
5429 | xor eax, eax |
5441 | xor ebx, ebx |
5430 | xor ebx, ebx |
5442 | mov ecx, [Screen_Max_X] |
5431 | mov ecx, [Screen_Max_X] |
5443 | mov edx, [Screen_Max_Y] |
5432 | mov edx, [Screen_Max_Y] |
5444 | call calculatescreen |
5433 | call calculatescreen |
5445 | pop edi |
5434 | pop edi |
5446 | pop esi |
5435 | pop esi |
5447 | pop ebx |
5436 | pop ebx |
5448 | 5437 | ||
5449 | popfd |
5438 | popfd |
5450 | ret |
5439 | ret |
5451 | 5440 | ||
5452 | .epic_fail: |
5441 | .epic_fail: |
5453 | hlt ; Houston, we've had a problem |
5442 | hlt ; Houston, we've had a problem |
5454 | 5443 | ||
5455 | ; --------------- APM --------------------- |
5444 | ; --------------- APM --------------------- |
5456 | uglobal |
5445 | uglobal |
5457 | apm_entry dp 0 |
5446 | apm_entry dp 0 |
5458 | apm_vf dd 0 |
5447 | apm_vf dd 0 |
5459 | endg |
5448 | endg |
5460 | 5449 | ||
5461 | align 4 |
5450 | align 4 |
5462 | sys_apm: |
5451 | sys_apm: |
5463 | xor eax, eax |
5452 | xor eax, eax |
5464 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5453 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5465 | jne @f |
5454 | jne @f |
5466 | inc eax |
5455 | inc eax |
5467 | or dword [esp + 44], eax ; error |
5456 | or dword [esp + 44], eax ; error |
5468 | add eax, 7 |
5457 | add eax, 7 |
5469 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5458 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5470 | ret |
5459 | ret |
5471 | 5460 | ||
5472 | @@: |
5461 | @@: |
5473 | ; xchg eax, ecx |
5462 | ; xchg eax, ecx |
5474 | ; xchg ebx, ecx |
5463 | ; xchg ebx, ecx |
5475 | 5464 | ||
5476 | cmp dx, 3 |
5465 | cmp dx, 3 |
5477 | ja @f |
5466 | ja @f |
5478 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5467 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5479 | mov eax, [apm_vf] |
5468 | mov eax, [apm_vf] |
5480 | mov [esp + 32], eax |
5469 | mov [esp + 32], eax |
5481 | shr eax, 16 |
5470 | shr eax, 16 |
5482 | mov [esp + 28], eax |
5471 | mov [esp + 28], eax |
5483 | ret |
5472 | ret |
5484 | 5473 | ||
5485 | @@: |
5474 | @@: |
5486 | 5475 | ||
5487 | mov esi, [master_tab+(OS_BASE shr 20)] |
5476 | mov esi, [master_tab+(OS_BASE shr 20)] |
5488 | xchg [master_tab], esi |
5477 | xchg [master_tab], esi |
5489 | push esi |
5478 | push esi |
5490 | mov edi, cr3 |
5479 | mov edi, cr3 |
5491 | mov cr3, edi ;flush TLB |
5480 | mov cr3, edi ;flush TLB |
5492 | 5481 | ||
5493 | call pword [apm_entry] ;call APM BIOS |
5482 | call pword [apm_entry] ;call APM BIOS |
5494 | 5483 | ||
5495 | xchg eax, [esp] |
5484 | xchg eax, [esp] |
5496 | mov [master_tab], eax |
5485 | mov [master_tab], eax |
5497 | mov eax, cr3 |
5486 | mov eax, cr3 |
5498 | mov cr3, eax |
5487 | mov cr3, eax |
5499 | pop eax |
5488 | pop eax |
5500 | 5489 | ||
5501 | mov [esp + 4 ], edi |
5490 | mov [esp + 4 ], edi |
5502 | mov [esp + 8], esi |
5491 | mov [esp + 8], esi |
5503 | mov [esp + 20], ebx |
5492 | mov [esp + 20], ebx |
5504 | mov [esp + 24], edx |
5493 | mov [esp + 24], edx |
5505 | mov [esp + 28], ecx |
5494 | mov [esp + 28], ecx |
5506 | mov [esp + 32], eax |
5495 | mov [esp + 32], eax |
5507 | setc al |
5496 | setc al |
5508 | and [esp + 44], byte 0xfe |
5497 | and [esp + 44], byte 0xfe |
5509 | or [esp + 44], al |
5498 | or [esp + 44], al |
5510 | ret |
5499 | ret |
5511 | ; ----------------------------------------- |
5500 | ; ----------------------------------------- |
5512 | 5501 | ||
5513 | align 4 |
5502 | align 4 |
5514 | 5503 | ||
5515 | undefined_syscall: ; Undefined system call |
5504 | undefined_syscall: ; Undefined system call |
5516 | mov [esp + 32], dword -1 |
5505 | mov [esp + 32], dword -1 |
5517 | ret |
5506 | ret |
5518 | 5507 | ||
5519 | align 4 |
5508 | align 4 |
5520 | system_shutdown: ; shut down the system |
5509 | system_shutdown: ; shut down the system |
5521 | 5510 | ||
5522 | cmp byte [BOOT_VARS+0x9030], 1 |
5511 | cmp byte [BOOT_VARS+0x9030], 1 |
5523 | jne @F |
5512 | jne @F |
5524 | ret |
5513 | ret |
5525 | @@: |
5514 | @@: |
5526 | call stop_all_services |
5515 | call stop_all_services |
5527 | 5516 | ||
5528 | yes_shutdown_param: |
5517 | yes_shutdown_param: |
5529 | cli |
5518 | cli |
5530 | 5519 | ||
5531 | if ~ defined extended_primary_loader |
5520 | if ~ defined extended_primary_loader |
5532 | ; load kernel.mnt to 0x7000:0 |
5521 | ; load kernel.mnt to 0x7000:0 |
5533 | mov ebx, kernel_file_load |
5522 | mov ebx, kernel_file_load |
5534 | pushad |
5523 | pushad |
5535 | call file_system_lfn |
5524 | call file_system_lfn |
5536 | popad |
5525 | popad |
5537 | 5526 | ||
5538 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5527 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5539 | mov edi, OS_BASE+0x40000 |
5528 | mov edi, OS_BASE+0x40000 |
5540 | mov ecx, 1000 |
5529 | mov ecx, 1000 |
5541 | rep movsb |
5530 | rep movsb |
5542 | end if |
5531 | end if |
5543 | 5532 | ||
5544 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5533 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5545 | ; mov edi, OS_BASE |
5534 | ; mov edi, OS_BASE |
5546 | ; mov ecx, 0x10000/4 |
5535 | ; mov ecx, 0x10000/4 |
5547 | ; cld |
5536 | ; cld |
5548 | ; rep movsd |
5537 | ; rep movsd |
5549 | 5538 | ||
5550 | call IRQ_mask_all |
5539 | call IRQ_mask_all |
5551 | 5540 | ||
5552 | if 0 |
5541 | if 0 |
5553 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5542 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5554 | mov word [OS_BASE+0x467+2], 0x1000 |
5543 | mov word [OS_BASE+0x467+2], 0x1000 |
5555 | 5544 | ||
5556 | mov al, 0x0F |
5545 | mov al, 0x0F |
5557 | out 0x70, al |
5546 | out 0x70, al |
5558 | mov al, 0x05 |
5547 | mov al, 0x05 |
5559 | out 0x71, al |
5548 | out 0x71, al |
5560 | 5549 | ||
5561 | mov al, 0xFE |
5550 | mov al, 0xFE |
5562 | out 0x64, al |
5551 | out 0x64, al |
5563 | 5552 | ||
5564 | hlt |
5553 | hlt |
5565 | jmp $-1 |
5554 | jmp $-1 |
5566 | 5555 | ||
5567 | else |
5556 | else |
5568 | cmp byte [OS_BASE + 0x9030], 2 |
5557 | cmp byte [OS_BASE + 0x9030], 2 |
5569 | jnz no_acpi_power_off |
5558 | jnz no_acpi_power_off |
5570 | 5559 | ||
5571 | ; scan for RSDP |
5560 | ; scan for RSDP |
5572 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5561 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5573 | movzx eax, word [OS_BASE + 0x40E] |
5562 | movzx eax, word [OS_BASE + 0x40E] |
5574 | shl eax, 4 |
5563 | shl eax, 4 |
5575 | jz @f |
5564 | jz @f |
5576 | mov ecx, 1024/16 |
5565 | mov ecx, 1024/16 |
5577 | call scan_rsdp |
5566 | call scan_rsdp |
5578 | jnc .rsdp_found |
5567 | jnc .rsdp_found |
5579 | @@: |
5568 | @@: |
5580 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5569 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5581 | mov eax, 0xE0000 |
5570 | mov eax, 0xE0000 |
5582 | mov ecx, 0x2000 |
5571 | mov ecx, 0x2000 |
5583 | call scan_rsdp |
5572 | call scan_rsdp |
5584 | jc no_acpi_power_off |
5573 | jc no_acpi_power_off |
5585 | .rsdp_found: |
5574 | .rsdp_found: |
5586 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5575 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5587 | mov ebp, [ipc_tmp] |
5576 | mov ebp, [ipc_tmp] |
5588 | stdcall map_page, ebp, esi, PG_MAP |
5577 | stdcall map_page, ebp, esi, PG_MAP |
5589 | lea eax, [esi+1000h] |
5578 | lea eax, [esi+1000h] |
5590 | lea edx, [ebp+1000h] |
5579 | lea edx, [ebp+1000h] |
5591 | stdcall map_page, edx, eax, PG_MAP |
5580 | stdcall map_page, edx, eax, PG_MAP |
5592 | and esi, 0xFFF |
5581 | and esi, 0xFFF |
5593 | add esi, ebp |
5582 | add esi, ebp |
5594 | cmp dword [esi], 'RSDT' |
5583 | cmp dword [esi], 'RSDT' |
5595 | jnz no_acpi_power_off |
5584 | jnz no_acpi_power_off |
5596 | mov ecx, [esi+4] |
5585 | mov ecx, [esi+4] |
5597 | sub ecx, 24h |
5586 | sub ecx, 24h |
5598 | jbe no_acpi_power_off |
5587 | jbe no_acpi_power_off |
5599 | shr ecx, 2 |
5588 | shr ecx, 2 |
5600 | add esi, 24h |
5589 | add esi, 24h |
5601 | .scan_fadt: |
5590 | .scan_fadt: |
5602 | lodsd |
5591 | lodsd |
5603 | mov ebx, eax |
5592 | mov ebx, eax |
5604 | lea eax, [ebp+2000h] |
5593 | lea eax, [ebp+2000h] |
5605 | stdcall map_page, eax, ebx, PG_MAP |
5594 | stdcall map_page, eax, ebx, PG_MAP |
5606 | lea eax, [ebp+3000h] |
5595 | lea eax, [ebp+3000h] |
5607 | add ebx, 0x1000 |
5596 | add ebx, 0x1000 |
5608 | stdcall map_page, eax, ebx, PG_MAP |
5597 | stdcall map_page, eax, ebx, PG_MAP |
5609 | and ebx, 0xFFF |
5598 | and ebx, 0xFFF |
5610 | lea ebx, [ebx+ebp+2000h] |
5599 | lea ebx, [ebx+ebp+2000h] |
5611 | cmp dword [ebx], 'FACP' |
5600 | cmp dword [ebx], 'FACP' |
5612 | jz .fadt_found |
5601 | jz .fadt_found |
5613 | loop .scan_fadt |
5602 | loop .scan_fadt |
5614 | jmp no_acpi_power_off |
5603 | jmp no_acpi_power_off |
5615 | .fadt_found: |
5604 | .fadt_found: |
5616 | ; ebx is linear address of FADT |
5605 | ; ebx is linear address of FADT |
5617 | mov edi, [ebx+40] ; physical address of the DSDT |
5606 | mov edi, [ebx+40] ; physical address of the DSDT |
5618 | lea eax, [ebp+4000h] |
5607 | lea eax, [ebp+4000h] |
5619 | stdcall map_page, eax, edi, PG_MAP |
5608 | stdcall map_page, eax, edi, PG_MAP |
5620 | lea eax, [ebp+5000h] |
5609 | lea eax, [ebp+5000h] |
5621 | lea esi, [edi+0x1000] |
5610 | lea esi, [edi+0x1000] |
5622 | stdcall map_page, eax, esi, PG_MAP |
5611 | stdcall map_page, eax, esi, PG_MAP |
5623 | and esi, 0xFFF |
5612 | and esi, 0xFFF |
5624 | sub edi, esi |
5613 | sub edi, esi |
5625 | cmp dword [esi+ebp+4000h], 'DSDT' |
5614 | cmp dword [esi+ebp+4000h], 'DSDT' |
5626 | jnz no_acpi_power_off |
5615 | jnz no_acpi_power_off |
5627 | mov eax, [esi+ebp+4004h] ; DSDT length |
5616 | mov eax, [esi+ebp+4004h] ; DSDT length |
5628 | sub eax, 36+4 |
5617 | sub eax, 36+4 |
5629 | jbe no_acpi_power_off |
5618 | jbe no_acpi_power_off |
5630 | add esi, 36 |
5619 | add esi, 36 |
5631 | .scan_dsdt: |
5620 | .scan_dsdt: |
5632 | cmp dword [esi+ebp+4000h], '_S5_' |
5621 | cmp dword [esi+ebp+4000h], '_S5_' |
5633 | jnz .scan_dsdt_cont |
5622 | jnz .scan_dsdt_cont |
5634 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5623 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5635 | jnz .scan_dsdt_cont |
5624 | jnz .scan_dsdt_cont |
5636 | mov dl, [esi+ebp+4000h+6] |
5625 | mov dl, [esi+ebp+4000h+6] |
5637 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5626 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5638 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5627 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5639 | ja .scan_dsdt_cont |
5628 | ja .scan_dsdt_cont |
5640 | cmp dl, 1 |
5629 | cmp dl, 1 |
5641 | jb .scan_dsdt_cont |
5630 | jb .scan_dsdt_cont |
5642 | lea esi, [esi+ebp+4000h+7] |
5631 | lea esi, [esi+ebp+4000h+7] |
5643 | xor ecx, ecx |
5632 | xor ecx, ecx |
5644 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5633 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5645 | jz @f |
5634 | jz @f |
5646 | cmp byte [esi], 0xA |
5635 | cmp byte [esi], 0xA |
5647 | jnz no_acpi_power_off |
5636 | jnz no_acpi_power_off |
5648 | inc esi |
5637 | inc esi |
5649 | mov cl, [esi] |
5638 | mov cl, [esi] |
5650 | @@: |
5639 | @@: |
5651 | inc esi |
5640 | inc esi |
5652 | cmp dl, 2 |
5641 | cmp dl, 2 |
5653 | jb @f |
5642 | jb @f |
5654 | cmp byte [esi], 0 |
5643 | cmp byte [esi], 0 |
5655 | jz @f |
5644 | jz @f |
5656 | cmp byte [esi], 0xA |
5645 | cmp byte [esi], 0xA |
5657 | jnz no_acpi_power_off |
5646 | jnz no_acpi_power_off |
5658 | inc esi |
5647 | inc esi |
5659 | mov ch, [esi] |
5648 | mov ch, [esi] |
5660 | @@: |
5649 | @@: |
5661 | jmp do_acpi_power_off |
5650 | jmp do_acpi_power_off |
5662 | .scan_dsdt_cont: |
5651 | .scan_dsdt_cont: |
5663 | inc esi |
5652 | inc esi |
5664 | cmp esi, 0x1000 |
5653 | cmp esi, 0x1000 |
5665 | jb @f |
5654 | jb @f |
5666 | sub esi, 0x1000 |
5655 | sub esi, 0x1000 |
5667 | add edi, 0x1000 |
5656 | add edi, 0x1000 |
5668 | push eax |
5657 | push eax |
5669 | lea eax, [ebp+4000h] |
5658 | lea eax, [ebp+4000h] |
5670 | stdcall map_page, eax, edi, PG_MAP |
5659 | stdcall map_page, eax, edi, PG_MAP |
5671 | push PG_MAP |
5660 | push PG_MAP |
5672 | lea eax, [edi+1000h] |
5661 | lea eax, [edi+1000h] |
5673 | push eax |
5662 | push eax |
5674 | lea eax, [ebp+5000h] |
5663 | lea eax, [ebp+5000h] |
5675 | push eax |
5664 | push eax |
5676 | stdcall map_page |
5665 | stdcall map_page |
5677 | pop eax |
5666 | pop eax |
5678 | @@: |
5667 | @@: |
5679 | dec eax |
5668 | dec eax |
5680 | jnz .scan_dsdt |
5669 | jnz .scan_dsdt |
5681 | jmp no_acpi_power_off |
5670 | jmp no_acpi_power_off |
5682 | do_acpi_power_off: |
5671 | do_acpi_power_off: |
5683 | mov edx, [ebx+48] |
5672 | mov edx, [ebx+48] |
5684 | test edx, edx |
5673 | test edx, edx |
5685 | jz .nosmi |
5674 | jz .nosmi |
5686 | mov al, [ebx+52] |
5675 | mov al, [ebx+52] |
5687 | out dx, al |
5676 | out dx, al |
5688 | mov edx, [ebx+64] |
5677 | mov edx, [ebx+64] |
5689 | @@: |
5678 | @@: |
5690 | in ax, dx |
5679 | in ax, dx |
5691 | test al, 1 |
5680 | test al, 1 |
5692 | jz @b |
5681 | jz @b |
5693 | .nosmi: |
5682 | .nosmi: |
5694 | and cx, 0x0707 |
5683 | and cx, 0x0707 |
5695 | shl cx, 2 |
5684 | shl cx, 2 |
5696 | or cx, 0x2020 |
5685 | or cx, 0x2020 |
5697 | mov edx, [ebx+64] |
5686 | mov edx, [ebx+64] |
5698 | in ax, dx |
5687 | in ax, dx |
5699 | and ax, 203h |
5688 | and ax, 203h |
5700 | or ah, cl |
5689 | or ah, cl |
5701 | out dx, ax |
5690 | out dx, ax |
5702 | mov edx, [ebx+68] |
5691 | mov edx, [ebx+68] |
5703 | test edx, edx |
5692 | test edx, edx |
5704 | jz @f |
5693 | jz @f |
5705 | in ax, dx |
5694 | in ax, dx |
5706 | and ax, 203h |
5695 | and ax, 203h |
5707 | or ah, ch |
5696 | or ah, ch |
5708 | out dx, ax |
5697 | out dx, ax |
5709 | @@: |
5698 | @@: |
5710 | jmp $ |
5699 | jmp $ |
5711 | 5700 | ||
5712 | 5701 | ||
5713 | no_acpi_power_off: |
5702 | no_acpi_power_off: |
5714 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5703 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5715 | mov word [OS_BASE+0x467+2], 0x1000 |
5704 | mov word [OS_BASE+0x467+2], 0x1000 |
5716 | 5705 | ||
5717 | mov al, 0x0F |
5706 | mov al, 0x0F |
5718 | out 0x70, al |
5707 | out 0x70, al |
5719 | mov al, 0x05 |
5708 | mov al, 0x05 |
5720 | out 0x71, al |
5709 | out 0x71, al |
5721 | 5710 | ||
5722 | mov al, 0xFE |
5711 | mov al, 0xFE |
5723 | out 0x64, al |
5712 | out 0x64, al |
5724 | 5713 | ||
5725 | hlt |
5714 | hlt |
5726 | jmp $-1 |
5715 | jmp $-1 |
5727 | 5716 | ||
5728 | scan_rsdp: |
5717 | scan_rsdp: |
5729 | add eax, OS_BASE |
5718 | add eax, OS_BASE |
5730 | .s: |
5719 | .s: |
5731 | cmp dword [eax], 'RSD ' |
5720 | cmp dword [eax], 'RSD ' |
5732 | jnz .n |
5721 | jnz .n |
5733 | cmp dword [eax+4], 'PTR ' |
5722 | cmp dword [eax+4], 'PTR ' |
5734 | jnz .n |
5723 | jnz .n |
5735 | xor edx, edx |
5724 | xor edx, edx |
5736 | xor esi, esi |
5725 | xor esi, esi |
5737 | @@: |
5726 | @@: |
5738 | add dl, [eax+esi] |
5727 | add dl, [eax+esi] |
5739 | inc esi |
5728 | inc esi |
5740 | cmp esi, 20 |
5729 | cmp esi, 20 |
5741 | jnz @b |
5730 | jnz @b |
5742 | test dl, dl |
5731 | test dl, dl |
5743 | jz .ok |
5732 | jz .ok |
5744 | .n: |
5733 | .n: |
5745 | add eax, 10h |
5734 | add eax, 10h |
5746 | loop .s |
5735 | loop .s |
5747 | stc |
5736 | stc |
5748 | .ok: |
5737 | .ok: |
5749 | ret |
5738 | ret |
5750 | end if |
5739 | end if |
5751 | 5740 | ||
5752 | if ~ lang eq sp |
5741 | if ~ lang eq sp |
5753 | diff16 "end of .text segment",0,$ |
5742 | diff16 "end of .text segment",0,$ |
5754 | end if |
5743 | end if |
5755 | 5744 | ||
5756 | include "data32.inc" |
5745 | include "data32.inc" |
5757 | 5746 | ||
5758 | __REV__ = __REV |
5747 | __REV__ = __REV |
5759 | 5748 | ||
5760 | if ~ lang eq sp |
5749 | if ~ lang eq sp |
5761 | diff16 "end of kernel code",0,$ |
5750 | diff16 "end of kernel code",0,$ |
5762 | end if=> |
5751 | end if=> |