Rev 5033 | Rev 5044 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5033 | Rev 5039 | ||
---|---|---|---|
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: 5033 $ |
74 | $Revision: 5039 $ |
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 | 312 | ||
313 | ap_init16: |
313 | ap_init16: |
314 | cli |
314 | cli |
315 | lgdt [cs:gdts_ap-ap_init16] |
315 | lgdt [cs:gdts_ap-ap_init16] |
316 | mov eax, [cs:cr3_ap-ap_init16] |
316 | mov eax, [cs:cr3_ap-ap_init16] |
317 | mov cr3, eax |
317 | mov cr3, eax |
318 | mov eax, [cs:cr4_ap-ap_init16] |
318 | mov eax, [cs:cr4_ap-ap_init16] |
319 | mov cr4, eax |
319 | mov cr4, eax |
320 | mov eax, CR0_PE+CR0_PG+CR0_WP |
320 | mov eax, CR0_PE+CR0_PG+CR0_WP |
321 | mov cr0, eax |
321 | mov cr0, eax |
322 | jmp pword os_code:ap_init_high |
322 | jmp pword os_code:ap_init_high |
323 | align 16 |
323 | align 16 |
324 | gdts_ap: |
324 | gdts_ap: |
325 | dw gdte-gdts-1 |
325 | dw gdte-gdts-1 |
326 | dd gdts |
326 | dd gdts |
327 | dw 0 |
327 | dw 0 |
328 | cr3_ap dd ? |
328 | cr3_ap dd ? |
329 | cr4_ap dd ? |
329 | cr4_ap dd ? |
330 | ap_init16_size = $ - ap_init16 |
330 | ap_init16_size = $ - ap_init16 |
331 | use32 |
331 | use32 |
332 | 332 | ||
333 | __DEBUG__ fix 1 |
333 | __DEBUG__ fix 1 |
334 | __DEBUG_LEVEL__ fix 1 |
334 | __DEBUG_LEVEL__ fix 1 |
335 | include 'init.inc' |
335 | include 'init.inc' |
336 | 336 | ||
337 | org OS_BASE+$ |
337 | org OS_BASE+$ |
338 | 338 | ||
339 | include 'fdo.inc' |
339 | include 'fdo.inc' |
340 | 340 | ||
341 | align 4 |
341 | align 4 |
342 | high_code: |
342 | high_code: |
343 | mov ax, os_stack |
343 | mov ax, os_stack |
344 | mov bx, app_data |
344 | mov bx, app_data |
345 | mov cx, app_tls |
345 | mov cx, app_tls |
346 | mov ss, ax |
346 | mov ss, ax |
347 | add esp, OS_BASE |
347 | add esp, OS_BASE |
348 | 348 | ||
349 | mov ds, bx |
349 | mov ds, bx |
350 | mov es, bx |
350 | mov es, bx |
351 | mov fs, cx |
351 | mov fs, cx |
352 | mov gs, bx |
352 | mov gs, bx |
353 | 353 | ||
354 | bt [cpu_caps], CAPS_PGE |
354 | bt [cpu_caps], CAPS_PGE |
355 | jnc @F |
355 | jnc @F |
356 | 356 | ||
357 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
357 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
358 | 358 | ||
359 | mov ebx, cr4 |
359 | mov ebx, cr4 |
360 | or ebx, CR4_PGE |
360 | or ebx, CR4_PGE |
361 | mov cr4, ebx |
361 | mov cr4, ebx |
362 | @@: |
362 | @@: |
363 | xor eax, eax |
363 | xor eax, eax |
364 | mov dword [sys_pgdir], eax |
364 | mov dword [sys_pgdir], eax |
365 | mov dword [sys_pgdir+4], eax |
365 | mov dword [sys_pgdir+4], eax |
366 | 366 | ||
367 | mov eax, cr3 |
367 | mov eax, cr3 |
368 | mov cr3, eax ; flush TLB |
368 | mov cr3, eax ; flush TLB |
369 | 369 | ||
370 | mov ecx, pg_data.mutex |
370 | mov ecx, pg_data.mutex |
371 | call mutex_init |
371 | call mutex_init |
372 | 372 | ||
373 | mov ecx, disk_list_mutex |
373 | mov ecx, disk_list_mutex |
374 | call mutex_init |
374 | call mutex_init |
375 | 375 | ||
376 | mov ecx, keyboard_list_mutex |
376 | mov ecx, keyboard_list_mutex |
377 | call mutex_init |
377 | call mutex_init |
378 | 378 | ||
379 | mov ecx, unpack_mutex |
379 | mov ecx, unpack_mutex |
380 | call mutex_init |
380 | call mutex_init |
381 | 381 | ||
382 | mov ecx, application_table_mutex |
382 | mov ecx, application_table_mutex |
383 | call mutex_init |
383 | call mutex_init |
384 | 384 | ||
385 | mov ecx, ide_mutex |
385 | mov ecx, ide_mutex |
386 | call mutex_init |
386 | call mutex_init |
387 | mov ecx, ide_channel1_mutex |
387 | mov ecx, ide_channel1_mutex |
388 | call mutex_init |
388 | call mutex_init |
389 | mov ecx, ide_channel2_mutex |
389 | mov ecx, ide_channel2_mutex |
390 | call mutex_init |
390 | call mutex_init |
391 | mov ecx, ide_channel3_mutex |
391 | mov ecx, ide_channel3_mutex |
392 | call mutex_init |
392 | call mutex_init |
393 | mov ecx, ide_channel4_mutex |
393 | mov ecx, ide_channel4_mutex |
394 | call mutex_init |
394 | call mutex_init |
395 | mov ecx, ide_channel5_mutex |
395 | mov ecx, ide_channel5_mutex |
396 | call mutex_init |
396 | call mutex_init |
397 | mov ecx, ide_channel6_mutex |
397 | mov ecx, ide_channel6_mutex |
398 | call mutex_init |
398 | call mutex_init |
399 | ;----------------------------------------------------------------------------- |
399 | ;----------------------------------------------------------------------------- |
400 | ; SAVE REAL MODE VARIABLES |
400 | ; SAVE REAL MODE VARIABLES |
401 | ;----------------------------------------------------------------------------- |
401 | ;----------------------------------------------------------------------------- |
402 | ; --------------- APM --------------------- |
402 | ; --------------- APM --------------------- |
403 | 403 | ||
404 | ; init selectors |
404 | ; init selectors |
405 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
405 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
406 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
406 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
407 | ; protected-mode 32-bit code segment |
407 | ; protected-mode 32-bit code segment |
408 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
408 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
409 | ; protected-mode 16-bit code segment |
409 | ; protected-mode 16-bit code segment |
410 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
410 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
411 | ; protected-mode 16-bit data segment |
411 | ; protected-mode 16-bit data segment |
412 | 412 | ||
413 | shl eax, 4 |
413 | shl eax, 4 |
414 | mov [dword apm_code_32 + 2], ax |
414 | mov [dword apm_code_32 + 2], ax |
415 | shr eax, 16 |
415 | shr eax, 16 |
416 | mov [dword apm_code_32 + 4], al |
416 | mov [dword apm_code_32 + 4], al |
417 | 417 | ||
418 | shl ecx, 4 |
418 | shl ecx, 4 |
419 | mov [dword apm_code_16 + 2], cx |
419 | mov [dword apm_code_16 + 2], cx |
420 | shr ecx, 16 |
420 | shr ecx, 16 |
421 | mov [dword apm_code_16 + 4], cl |
421 | mov [dword apm_code_16 + 4], cl |
422 | 422 | ||
423 | shl edx, 4 |
423 | shl edx, 4 |
424 | mov [dword apm_data_16 + 2], dx |
424 | mov [dword apm_data_16 + 2], dx |
425 | shr edx, 16 |
425 | shr edx, 16 |
426 | mov [dword apm_data_16 + 4], dl |
426 | mov [dword apm_data_16 + 4], dl |
427 | 427 | ||
428 | mov dword[apm_entry], ebx |
428 | mov dword[apm_entry], ebx |
429 | mov word [apm_entry + 4], apm_code_32 - gdts |
429 | mov word [apm_entry + 4], apm_code_32 - gdts |
430 | 430 | ||
431 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
431 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
432 | mov [apm_vf], eax |
432 | mov [apm_vf], eax |
433 | ; ----------------------------------------- |
433 | ; ----------------------------------------- |
434 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
434 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
435 | mov [allow_dma_access], al |
435 | mov [allow_dma_access], al |
436 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
436 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
437 | mov [_display.bpp], eax |
437 | mov [_display.bpp], eax |
438 | mov [_display.vrefresh], 60 |
438 | mov [_display.vrefresh], 60 |
439 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
439 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
440 | mov [debug_direct_print], al |
440 | mov [debug_direct_print], al |
441 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
441 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
442 | mov [launcher_start], al |
442 | mov [launcher_start], al |
443 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
443 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
444 | mov [_display.width], eax |
444 | mov [_display.width], eax |
445 | mov [display_width_standard], eax |
445 | mov [display_width_standard], eax |
446 | dec eax |
446 | dec eax |
447 | mov [Screen_Max_X], eax |
447 | mov [Screen_Max_X], eax |
448 | mov [screen_workarea.right], eax |
448 | mov [screen_workarea.right], eax |
449 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
449 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
450 | mov [_display.height], eax |
450 | mov [_display.height], eax |
451 | mov [display_height_standard], eax |
451 | mov [display_height_standard], eax |
452 | dec eax |
452 | dec eax |
453 | mov [Screen_Max_Y], eax |
453 | mov [Screen_Max_Y], eax |
454 | mov [screen_workarea.bottom], eax |
454 | mov [screen_workarea.bottom], eax |
455 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
455 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
456 | mov dword [SCR_MODE], eax |
456 | mov dword [SCR_MODE], eax |
457 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
457 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
458 | ; mov [BANK_SWITCH], eax |
458 | ; mov [BANK_SWITCH], eax |
459 | mov eax, 640 *4 ; Bytes PerScanLine |
459 | mov eax, 640 *4 ; Bytes PerScanLine |
460 | cmp [SCR_MODE], word 0x13 ; 320x200 |
460 | cmp [SCR_MODE], word 0x13 ; 320x200 |
461 | je @f |
461 | je @f |
462 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
462 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
463 | je @f |
463 | je @f |
464 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
464 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
465 | @@: |
465 | @@: |
466 | mov [_display.pitch], eax |
466 | mov [_display.pitch], eax |
467 | mov eax, [_display.width] |
467 | mov eax, [_display.width] |
468 | mul [_display.height] |
468 | mul [_display.height] |
469 | mov [_WinMapSize], eax |
469 | mov [_WinMapSize], eax |
470 | 470 | ||
471 | call calculate_fast_getting_offset_for_WinMapAddress |
471 | call calculate_fast_getting_offset_for_WinMapAddress |
472 | ; for Qemu or non standart video cards |
472 | ; for Qemu or non standart video cards |
473 | ; Unfortunately [BytesPerScanLine] does not always |
473 | ; Unfortunately [BytesPerScanLine] does not always |
474 | ; equal to [_display.width] * [ScreenBPP] / 8 |
474 | ; equal to [_display.width] * [ScreenBPP] / 8 |
475 | call calculate_fast_getting_offset_for_LFB |
475 | call calculate_fast_getting_offset_for_LFB |
476 | 476 | ||
477 | mov esi, BOOT_VARS+0x9080 |
477 | mov esi, BOOT_VARS+0x9080 |
478 | movzx ecx, byte [esi-1] |
478 | movzx ecx, byte [esi-1] |
479 | mov [NumBiosDisks], ecx |
479 | mov [NumBiosDisks], ecx |
480 | mov edi, BiosDisksData |
480 | mov edi, BiosDisksData |
481 | rep movsd |
481 | rep movsd |
482 | 482 | ||
483 | ; GRAPHICS ADDRESSES |
483 | ; GRAPHICS ADDRESSES |
484 | 484 | ||
485 | mov eax, [BOOT_VARS+BOOT_LFB] |
485 | mov eax, [BOOT_VARS+BOOT_LFB] |
486 | mov [LFBAddress], eax |
486 | mov [LFBAddress], eax |
487 | 487 | ||
488 | cmp [SCR_MODE], word 0100000000000000b |
488 | cmp [SCR_MODE], word 0100000000000000b |
489 | jge setvesa20 |
489 | jge setvesa20 |
490 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
490 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
491 | je v20ga32 |
491 | je v20ga32 |
492 | jmp v20ga24 |
492 | jmp v20ga24 |
493 | 493 | ||
494 | setvesa20: |
494 | setvesa20: |
495 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
495 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
496 | mov [GETPIXEL], dword Vesa20_getpixel24 |
496 | mov [GETPIXEL], dword Vesa20_getpixel24 |
497 | cmp byte [_display.bpp], 24 |
497 | cmp byte [_display.bpp], 24 |
498 | jz v20ga24 |
498 | jz v20ga24 |
499 | v20ga32: |
499 | v20ga32: |
500 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
500 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
501 | mov [GETPIXEL], dword Vesa20_getpixel32 |
501 | mov [GETPIXEL], dword Vesa20_getpixel32 |
502 | jmp no_mode_0x12 |
502 | jmp no_mode_0x12 |
503 | v20ga24: |
503 | v20ga24: |
504 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
504 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
505 | jne no_mode_0x12 |
505 | jne no_mode_0x12 |
506 | mov [PUTPIXEL], dword VGA_putpixel |
506 | mov [PUTPIXEL], dword VGA_putpixel |
507 | mov [GETPIXEL], dword Vesa20_getpixel32 |
507 | mov [GETPIXEL], dword Vesa20_getpixel32 |
508 | no_mode_0x12: |
508 | no_mode_0x12: |
509 | 509 | ||
510 | mov [MOUSE_PICTURE], dword mousepointer |
510 | mov [MOUSE_PICTURE], dword mousepointer |
511 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
511 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
512 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
512 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
513 | 513 | ||
514 | ; -------- Fast System Call init ---------- |
514 | ; -------- Fast System Call init ---------- |
515 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
515 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
516 | bt [cpu_caps], CAPS_SEP |
516 | bt [cpu_caps], CAPS_SEP |
517 | jnc .SEnP ; SysEnter not Present |
517 | jnc .SEnP ; SysEnter not Present |
518 | xor edx, edx |
518 | xor edx, edx |
519 | mov ecx, MSR_SYSENTER_CS |
519 | mov ecx, MSR_SYSENTER_CS |
520 | mov eax, os_code |
520 | mov eax, os_code |
521 | wrmsr |
521 | wrmsr |
522 | mov ecx, MSR_SYSENTER_ESP |
522 | mov ecx, MSR_SYSENTER_ESP |
523 | ; mov eax, sysenter_stack ; Check it |
523 | ; mov eax, sysenter_stack ; Check it |
524 | xor eax, eax |
524 | xor eax, eax |
525 | wrmsr |
525 | wrmsr |
526 | mov ecx, MSR_SYSENTER_EIP |
526 | mov ecx, MSR_SYSENTER_EIP |
527 | mov eax, sysenter_entry |
527 | mov eax, sysenter_entry |
528 | wrmsr |
528 | wrmsr |
529 | .SEnP: |
529 | .SEnP: |
530 | ; AMD SYSCALL/SYSRET |
530 | ; AMD SYSCALL/SYSRET |
531 | cmp byte[cpu_vendor], 'A' |
531 | cmp byte[cpu_vendor], 'A' |
532 | jne .noSYSCALL |
532 | jne .noSYSCALL |
533 | mov eax, 0x80000001 |
533 | mov eax, 0x80000001 |
534 | cpuid |
534 | cpuid |
535 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
535 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
536 | jz .noSYSCALL |
536 | jz .noSYSCALL |
537 | mov ecx, MSR_AMD_EFER |
537 | mov ecx, MSR_AMD_EFER |
538 | rdmsr |
538 | rdmsr |
539 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
539 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
540 | wrmsr |
540 | wrmsr |
541 | 541 | ||
542 | ; !!!! It`s dirty hack, fix it !!! |
542 | ; !!!! It`s dirty hack, fix it !!! |
543 | ; Bits of EDX : |
543 | ; Bits of EDX : |
544 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
544 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
545 | ; and the contents of this field, plus 8, are copied into the SS register. |
545 | ; and the contents of this field, plus 8, are copied into the SS register. |
546 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
546 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
547 | ; and the contents of this field, plus 8, are copied into the SS register. |
547 | ; and the contents of this field, plus 8, are copied into the SS register. |
548 | 548 | ||
549 | ; mov edx, (os_code + 16) * 65536 + os_code |
549 | ; mov edx, (os_code + 16) * 65536 + os_code |
550 | mov edx, 0x1B0008 |
550 | mov edx, 0x1B0008 |
551 | 551 | ||
552 | mov eax, syscall_entry |
552 | mov eax, syscall_entry |
553 | mov ecx, MSR_AMD_STAR |
553 | mov ecx, MSR_AMD_STAR |
554 | wrmsr |
554 | wrmsr |
555 | .noSYSCALL: |
555 | .noSYSCALL: |
556 | ; ----------------------------------------- |
556 | ; ----------------------------------------- |
557 | stdcall alloc_page |
557 | stdcall alloc_page |
558 | stdcall map_page, tss-0xF80, eax, PG_SW |
558 | stdcall map_page, tss-0xF80, eax, PG_SW |
559 | stdcall alloc_page |
559 | stdcall alloc_page |
560 | stdcall map_page, tss+0x80, eax, PG_SW |
560 | stdcall map_page, tss+0x80, eax, PG_SW |
561 | stdcall alloc_page |
561 | stdcall alloc_page |
562 | stdcall map_page, tss+0x1080, eax, PG_SW |
562 | stdcall map_page, tss+0x1080, eax, PG_SW |
563 | 563 | ||
564 | ; LOAD IDT |
564 | ; LOAD IDT |
565 | 565 | ||
566 | call build_interrupt_table ;lidt is executed |
566 | call build_interrupt_table ;lidt is executed |
567 | ;lidt [idtreg] |
567 | ;lidt [idtreg] |
568 | 568 | ||
569 | call init_kernel_heap |
569 | call init_kernel_heap |
570 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
570 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
571 | mov [os_stack_seg], eax |
571 | mov [os_stack_seg], eax |
572 | 572 | ||
573 | lea esp, [eax+RING0_STACK_SIZE] |
573 | lea esp, [eax+RING0_STACK_SIZE] |
574 | 574 | ||
575 | mov [tss._ss0], os_stack |
575 | mov [tss._ss0], os_stack |
576 | mov [tss._esp0], esp |
576 | mov [tss._esp0], esp |
577 | mov [tss._esp], esp |
577 | mov [tss._esp], esp |
578 | mov [tss._cs], os_code |
578 | mov [tss._cs], os_code |
579 | mov [tss._ss], os_stack |
579 | mov [tss._ss], os_stack |
580 | mov [tss._ds], app_data |
580 | mov [tss._ds], app_data |
581 | mov [tss._es], app_data |
581 | mov [tss._es], app_data |
582 | mov [tss._fs], app_data |
582 | mov [tss._fs], app_data |
583 | mov [tss._gs], app_data |
583 | mov [tss._gs], app_data |
584 | mov [tss._io], 128 |
584 | mov [tss._io], 128 |
585 | ;Add IO access table - bit array of permitted ports |
585 | ;Add IO access table - bit array of permitted ports |
586 | mov edi, tss._io_map_0 |
586 | mov edi, tss._io_map_0 |
587 | xor eax, eax |
587 | xor eax, eax |
588 | not eax |
588 | not eax |
589 | mov ecx, 8192/4 |
589 | mov ecx, 8192/4 |
590 | rep stosd ; access to 4096*8=65536 ports |
590 | rep stosd ; access to 4096*8=65536 ports |
591 | 591 | ||
592 | mov ax, tss0 |
592 | mov ax, tss0 |
593 | ltr ax |
593 | ltr ax |
594 | 594 | ||
595 | mov [LFBSize], 0xC00000 |
595 | mov [LFBSize], 0xC00000 |
596 | call init_LFB |
596 | call init_LFB |
597 | call init_fpu |
597 | call init_fpu |
598 | call init_malloc |
598 | call init_malloc |
599 | 599 | ||
600 | stdcall alloc_kernel_space, 0x51000 |
600 | stdcall alloc_kernel_space, 0x51000 |
601 | mov [default_io_map], eax |
601 | mov [default_io_map], eax |
602 | 602 | ||
603 | add eax, 0x2000 |
603 | add eax, 0x2000 |
604 | mov [ipc_tmp], eax |
604 | mov [ipc_tmp], eax |
605 | mov ebx, 0x1000 |
605 | mov ebx, 0x1000 |
606 | 606 | ||
607 | add eax, 0x40000 |
607 | add eax, 0x40000 |
608 | mov [proc_mem_map], eax |
608 | mov [proc_mem_map], eax |
609 | 609 | ||
610 | add eax, 0x8000 |
610 | add eax, 0x8000 |
611 | mov [proc_mem_pdir], eax |
611 | mov [proc_mem_pdir], eax |
612 | 612 | ||
613 | add eax, ebx |
613 | add eax, ebx |
614 | mov [proc_mem_tab], eax |
614 | mov [proc_mem_tab], eax |
615 | 615 | ||
616 | add eax, ebx |
616 | add eax, ebx |
617 | mov [tmp_task_pdir], eax |
617 | mov [tmp_task_pdir], eax |
618 | 618 | ||
619 | add eax, ebx |
619 | add eax, ebx |
620 | mov [tmp_task_ptab], eax |
620 | mov [tmp_task_ptab], eax |
621 | 621 | ||
622 | add eax, ebx |
622 | add eax, ebx |
623 | mov [ipc_pdir], eax |
623 | mov [ipc_pdir], eax |
624 | 624 | ||
625 | add eax, ebx |
625 | add eax, ebx |
626 | mov [ipc_ptab], eax |
626 | mov [ipc_ptab], eax |
627 | 627 | ||
628 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
628 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
629 | (unpack.lc+unpack.lp)))*4 |
629 | (unpack.lc+unpack.lp)))*4 |
630 | 630 | ||
631 | mov [unpack.p], eax |
631 | mov [unpack.p], eax |
632 | 632 | ||
633 | call init_events |
633 | call init_events |
634 | mov eax, srv.fd-SRV.fd |
634 | mov eax, srv.fd-SRV.fd |
635 | mov [srv.fd], eax |
635 | mov [srv.fd], eax |
636 | mov [srv.bk], eax |
636 | mov [srv.bk], eax |
637 | 637 | ||
638 | ;Set base of graphic segment to linear address of LFB |
638 | ;Set base of graphic segment to linear address of LFB |
639 | mov eax, [LFBAddress] ; set for gs |
639 | mov eax, [LFBAddress] ; set for gs |
640 | mov [graph_data_l+2], ax |
640 | mov [graph_data_l+2], ax |
641 | shr eax, 16 |
641 | shr eax, 16 |
642 | mov [graph_data_l+4], al |
642 | mov [graph_data_l+4], al |
643 | mov [graph_data_l+7], ah |
643 | mov [graph_data_l+7], ah |
644 | 644 | ||
645 | stdcall kernel_alloc, [_WinMapSize] |
645 | stdcall kernel_alloc, [_WinMapSize] |
646 | mov [_WinMapAddress], eax |
646 | mov [_WinMapAddress], eax |
647 | 647 | ||
648 | xor eax, eax |
648 | xor eax, eax |
649 | inc eax |
649 | inc eax |
650 | 650 | ||
651 | ; set background |
651 | ; set background |
652 | 652 | ||
653 | mov [BgrDrawMode], eax |
653 | mov [BgrDrawMode], eax |
654 | mov [BgrDataWidth], eax |
654 | mov [BgrDataWidth], eax |
655 | mov [BgrDataHeight], eax |
655 | mov [BgrDataHeight], eax |
656 | mov [mem_BACKGROUND], 4 |
656 | mov [mem_BACKGROUND], 4 |
657 | mov [img_background], static_background_data |
657 | mov [img_background], static_background_data |
658 | 658 | ||
659 | ; set clipboard |
659 | ; set clipboard |
660 | 660 | ||
661 | xor eax, eax |
661 | xor eax, eax |
662 | mov [clipboard_slots], eax |
662 | mov [clipboard_slots], eax |
663 | mov [clipboard_write_lock], eax |
663 | mov [clipboard_write_lock], eax |
664 | stdcall kernel_alloc, 4096 |
664 | stdcall kernel_alloc, 4096 |
665 | test eax, eax |
665 | test eax, eax |
666 | jnz @f |
666 | jnz @f |
667 | 667 | ||
668 | dec eax |
668 | dec eax |
669 | @@: |
669 | @@: |
670 | mov [clipboard_main_list], eax |
670 | mov [clipboard_main_list], eax |
671 | 671 | ||
672 | ; SET UP OS TASK |
672 | ; SET UP OS TASK |
673 | 673 | ||
674 | mov esi, boot_setostask |
674 | mov esi, boot_setostask |
675 | call boot_log |
675 | call boot_log |
676 | 676 | ||
677 | mov edx, SLOT_BASE+256 |
677 | mov edx, SLOT_BASE+256 |
678 | mov ebx, [os_stack_seg] |
678 | mov ebx, [os_stack_seg] |
679 | add ebx, 0x2000 |
679 | add ebx, 0x2000 |
680 | call setup_os_slot |
680 | call setup_os_slot |
681 | mov dword [edx], 'IDLE' |
681 | mov dword [edx], 'IDLE' |
682 | sub [edx+APPDATA.saved_esp], 4 |
682 | sub [edx+APPDATA.saved_esp], 4 |
683 | mov eax, [edx+APPDATA.saved_esp] |
683 | mov eax, [edx+APPDATA.saved_esp] |
684 | mov dword [eax], idle_thread |
684 | mov dword [eax], idle_thread |
685 | mov ecx, IDLE_PRIORITY |
685 | mov ecx, IDLE_PRIORITY |
686 | call scheduler_add_thread |
686 | call scheduler_add_thread |
687 | 687 | ||
688 | mov edx, SLOT_BASE+256*2 |
688 | mov edx, SLOT_BASE+256*2 |
689 | mov ebx, [os_stack_seg] |
689 | mov ebx, [os_stack_seg] |
690 | call setup_os_slot |
690 | call setup_os_slot |
691 | mov dword [edx], 'OS' |
691 | mov dword [edx], 'OS' |
692 | xor ecx, ecx |
692 | xor ecx, ecx |
693 | call scheduler_add_thread |
693 | call scheduler_add_thread |
694 | 694 | ||
695 | mov dword [CURRENT_TASK], 2 |
695 | mov dword [CURRENT_TASK], 2 |
696 | mov dword [TASK_COUNT], 2 |
696 | mov dword [TASK_COUNT], 2 |
697 | mov dword [current_slot], SLOT_BASE + 256*2 |
697 | mov dword [current_slot], SLOT_BASE + 256*2 |
698 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
698 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
699 | 699 | ||
700 | ; Move other CPUs to deep sleep, if it is useful |
700 | ; Move other CPUs to deep sleep, if it is useful |
701 | uglobal |
701 | uglobal |
702 | use_mwait_for_idle db 0 |
702 | use_mwait_for_idle db 0 |
703 | endg |
703 | endg |
704 | cmp [cpu_vendor+8], 'ntel' |
704 | cmp [cpu_vendor+8], 'ntel' |
705 | jnz .no_wake_cpus |
705 | jnz .no_wake_cpus |
706 | bt [cpu_caps+4], CAPS_MONITOR-32 |
706 | bt [cpu_caps+4], CAPS_MONITOR-32 |
707 | jnc .no_wake_cpus |
707 | jnc .no_wake_cpus |
708 | dbgstr 'using mwait for idle loop' |
708 | dbgstr 'using mwait for idle loop' |
709 | inc [use_mwait_for_idle] |
709 | inc [use_mwait_for_idle] |
710 | mov ebx, [cpu_count] |
710 | mov ebx, [cpu_count] |
711 | cmp ebx, 1 |
711 | cmp ebx, 1 |
712 | jbe .no_wake_cpus |
712 | jbe .no_wake_cpus |
713 | call create_trampoline_pgmap |
713 | call create_trampoline_pgmap |
714 | mov [cr3_ap+OS_BASE], eax |
714 | mov [cr3_ap+OS_BASE], eax |
715 | mov eax, cr4 |
715 | mov eax, cr4 |
716 | mov [cr4_ap+OS_BASE], eax |
716 | mov [cr4_ap+OS_BASE], eax |
717 | mov esi, OS_BASE + ap_init16 |
717 | mov esi, OS_BASE + ap_init16 |
718 | mov edi, OS_BASE + 8000h |
718 | mov edi, OS_BASE + 8000h |
719 | mov ecx, (ap_init16_size + 3) / 4 |
719 | mov ecx, (ap_init16_size + 3) / 4 |
720 | rep movsd |
720 | rep movsd |
721 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE |
721 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE |
722 | mov [LAPIC_BASE], eax |
722 | mov [LAPIC_BASE], eax |
723 | lea edi, [eax+300h] |
723 | lea edi, [eax+300h] |
724 | mov esi, smpt+4 |
724 | mov esi, smpt+4 |
725 | dec ebx |
725 | dec ebx |
726 | .wake_cpus_loop: |
726 | .wake_cpus_loop: |
727 | lodsd |
727 | lodsd |
728 | shl eax, 24 |
728 | shl eax, 24 |
729 | mov [edi+10h], eax |
729 | mov [edi+10h], eax |
730 | ; assert INIT IPI |
730 | ; assert INIT IPI |
731 | mov dword [edi], 0C500h |
731 | mov dword [edi], 0C500h |
732 | @@: |
732 | @@: |
733 | test dword [edi], 1000h |
733 | test dword [edi], 1000h |
734 | jnz @b |
734 | jnz @b |
735 | ; deassert INIT IPI |
735 | ; deassert INIT IPI |
736 | mov dword [edi], 8500h |
736 | mov dword [edi], 8500h |
737 | @@: |
737 | @@: |
738 | test dword [edi], 1000h |
738 | test dword [edi], 1000h |
739 | jnz @b |
739 | jnz @b |
740 | ; send STARTUP IPI |
740 | ; send STARTUP IPI |
741 | mov dword [edi], 600h + (8000h shr 12) |
741 | mov dword [edi], 600h + (8000h shr 12) |
742 | @@: |
742 | @@: |
743 | test dword [edi], 1000h |
743 | test dword [edi], 1000h |
744 | jnz @b |
744 | jnz @b |
745 | dec ebx |
745 | dec ebx |
746 | jnz .wake_cpus_loop |
746 | jnz .wake_cpus_loop |
747 | mov eax, [cpu_count] |
747 | mov eax, [cpu_count] |
748 | dec eax |
748 | dec eax |
749 | @@: |
749 | @@: |
750 | cmp [ap_initialized], eax |
750 | cmp [ap_initialized], eax |
751 | jnz @b |
751 | jnz @b |
752 | mov eax, [cr3_ap+OS_BASE] |
752 | mov eax, [cr3_ap+OS_BASE] |
753 | call free_page |
753 | call free_page |
754 | .no_wake_cpus: |
754 | .no_wake_cpus: |
755 | 755 | ||
756 | 756 | ||
757 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
757 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
758 | mov esi, boot_initirq |
758 | mov esi, boot_initirq |
759 | call boot_log |
759 | call boot_log |
760 | call init_irqs |
760 | call init_irqs |
761 | 761 | ||
762 | mov esi, boot_picinit |
762 | mov esi, boot_picinit |
763 | call boot_log |
763 | call boot_log |
764 | call PIC_init |
764 | call PIC_init |
765 | 765 | ||
766 | mov esi, boot_v86machine |
766 | mov esi, boot_v86machine |
767 | call boot_log |
767 | call boot_log |
768 | ; Initialize system V86 machine |
768 | ; Initialize system V86 machine |
769 | call init_sys_v86 |
769 | call init_sys_v86 |
770 | 770 | ||
771 | mov esi, boot_inittimer |
771 | mov esi, boot_inittimer |
772 | call boot_log |
772 | call boot_log |
773 | ; Initialize system timer (IRQ0) |
773 | ; Initialize system timer (IRQ0) |
774 | call PIT_init |
774 | call PIT_init |
775 | 775 | ||
776 | ; Register ramdisk file system |
776 | ; Register ramdisk file system |
777 | cmp [boot_dev+OS_BASE+0x10000], 1 |
777 | cmp [boot_dev+OS_BASE+0x10000], 1 |
778 | je @f |
778 | je @f |
779 | 779 | ||
780 | call register_ramdisk |
780 | call register_ramdisk |
781 | ;-------------------------------------- |
781 | ;-------------------------------------- |
782 | @@: |
782 | @@: |
783 | mov esi, boot_initapic |
783 | mov esi, boot_initapic |
784 | call boot_log |
784 | call boot_log |
785 | ; Try to Initialize APIC |
785 | ; Try to Initialize APIC |
786 | call APIC_init |
786 | call APIC_init |
787 | 787 | ||
788 | mov esi, boot_enableirq |
788 | mov esi, boot_enableirq |
789 | call boot_log |
789 | call boot_log |
790 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
790 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
791 | ; they are used: when partitions are scanned, hd_read relies on timer |
791 | ; they are used: when partitions are scanned, hd_read relies on timer |
792 | call unmask_timer |
792 | call unmask_timer |
793 | stdcall enable_irq, 2 ; @#$%! PIC |
793 | stdcall enable_irq, 2 ; @#$%! PIC |
794 | stdcall enable_irq, 13 ; co-processor |
794 | stdcall enable_irq, 13 ; co-processor |
795 | 795 | ||
796 | ; Setup serial output console (if enabled) |
796 | ; Setup serial output console (if enabled) |
797 | if defined debug_com_base |
797 | if defined debug_com_base |
798 | 798 | ||
799 | ; reserve port so nobody else will use it |
799 | ; reserve port so nobody else will use it |
800 | xor ebx, ebx |
800 | xor ebx, ebx |
801 | mov ecx, debug_com_base |
801 | mov ecx, debug_com_base |
802 | mov edx, debug_com_base+7 |
802 | mov edx, debug_com_base+7 |
803 | call r_f_port_area |
803 | call r_f_port_area |
804 | 804 | ||
805 | ; enable Divisor latch |
805 | ; enable Divisor latch |
806 | mov dx, debug_com_base+3 |
806 | mov dx, debug_com_base+3 |
807 | mov al, 1 shl 7 |
807 | mov al, 1 shl 7 |
808 | out dx, al |
808 | out dx, al |
809 | 809 | ||
810 | ; Set speed to 115200 baud (max speed) |
810 | ; Set speed to 115200 baud (max speed) |
811 | mov dx, debug_com_base |
811 | mov dx, debug_com_base |
812 | mov al, 0x01 |
812 | mov al, 0x01 |
813 | out dx, al |
813 | out dx, al |
814 | 814 | ||
815 | mov dx, debug_com_base+1 |
815 | mov dx, debug_com_base+1 |
816 | mov al, 0x00 |
816 | mov al, 0x00 |
817 | out dx, al |
817 | out dx, al |
818 | 818 | ||
819 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
819 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
820 | mov dx, debug_com_base+3 |
820 | mov dx, debug_com_base+3 |
821 | mov al, 3 |
821 | mov al, 3 |
822 | out dx, al |
822 | out dx, al |
823 | 823 | ||
824 | ; disable interrupts |
824 | ; disable interrupts |
825 | mov dx, debug_com_base+1 |
825 | mov dx, debug_com_base+1 |
826 | mov al, 0 |
826 | mov al, 0 |
827 | out dx, al |
827 | out dx, al |
828 | 828 | ||
829 | ; clear + enable fifo (64 bits) |
829 | ; clear + enable fifo (64 bits) |
830 | mov dx, debug_com_base+2 |
830 | mov dx, debug_com_base+2 |
831 | mov al, 0x7 + 1 shl 5 |
831 | mov al, 0x7 + 1 shl 5 |
832 | out dx, al |
832 | out dx, al |
833 | 833 | ||
834 | end if |
834 | end if |
835 | 835 | ||
836 | 836 | ||
837 | ;----------------------------------------------------------------------------- |
837 | ;----------------------------------------------------------------------------- |
838 | ; show SVN version of kernel on the message board |
838 | ; show SVN version of kernel on the message board |
839 | ;----------------------------------------------------------------------------- |
839 | ;----------------------------------------------------------------------------- |
840 | mov eax, [version_inf.rev] |
840 | mov eax, [version_inf.rev] |
841 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
841 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
842 | ;----------------------------------------------------------------------------- |
842 | ;----------------------------------------------------------------------------- |
843 | ; show CPU count on the message board |
843 | ; show CPU count on the message board |
844 | ;----------------------------------------------------------------------------- |
844 | ;----------------------------------------------------------------------------- |
845 | mov eax, [cpu_count] |
845 | mov eax, [cpu_count] |
846 | test eax, eax |
846 | test eax, eax |
847 | jnz @F |
847 | jnz @F |
848 | mov al, 1 ; at least one CPU |
848 | mov al, 1 ; at least one CPU |
849 | @@: |
849 | @@: |
850 | DEBUGF 1, "K : %d CPU detected\n", eax |
850 | DEBUGF 1, "K : %d CPU detected\n", eax |
851 | ;----------------------------------------------------------------------------- |
851 | ;----------------------------------------------------------------------------- |
852 | ; detect Floppy drives |
852 | ; detect Floppy drives |
853 | ;----------------------------------------------------------------------------- |
853 | ;----------------------------------------------------------------------------- |
854 | mov esi, boot_detectfloppy |
854 | mov esi, boot_detectfloppy |
855 | call boot_log |
855 | call boot_log |
856 | include 'detect/dev_fd.inc' |
856 | include 'detect/dev_fd.inc' |
857 | ;----------------------------------------------------------------------------- |
857 | ;----------------------------------------------------------------------------- |
858 | ; create pci-devices list |
858 | ; create pci-devices list |
859 | ;----------------------------------------------------------------------------- |
859 | ;----------------------------------------------------------------------------- |
860 | mov [pci_access_enabled], 1 |
860 | mov [pci_access_enabled], 1 |
861 | call pci_enum |
861 | call pci_enum |
862 | ;----------------------------------------------------------------------------- |
862 | ;----------------------------------------------------------------------------- |
863 | ; initialisation IDE ATA code |
863 | ; initialisation IDE ATA code |
864 | ;----------------------------------------------------------------------------- |
864 | ;----------------------------------------------------------------------------- |
865 | include 'detect/init_ata.inc' |
865 | include 'detect/init_ata.inc' |
866 | ;----------------------------------------------------------------------------- |
866 | ;----------------------------------------------------------------------------- |
867 | if 0 |
867 | if 0 |
868 | mov ax, [OS_BASE+0x10000+bx_from_load] |
868 | mov ax, [OS_BASE+0x10000+bx_from_load] |
869 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
869 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
870 | je no_lib_load |
870 | je no_lib_load |
871 | 871 | ||
872 | mov esi, boot_loadlibs |
872 | mov esi, boot_loadlibs |
873 | call boot_log |
873 | call boot_log |
874 | ; LOADING LIBRARES |
874 | ; LOADING LIBRARES |
875 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
875 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
876 | call load_file_parse_table ; prepare file parse table |
876 | call load_file_parse_table ; prepare file parse table |
877 | call set_kernel_conf ; configure devices and gui |
877 | call set_kernel_conf ; configure devices and gui |
878 | no_lib_load: |
878 | no_lib_load: |
879 | end if |
879 | end if |
880 | 880 | ||
881 | ; Display APIC status |
881 | ; Display APIC status |
882 | mov esi, boot_APIC_found |
882 | mov esi, boot_APIC_found |
883 | cmp [irq_mode], IRQ_APIC |
883 | cmp [irq_mode], IRQ_APIC |
884 | je @f |
884 | je @f |
885 | mov esi, boot_APIC_nfound |
885 | mov esi, boot_APIC_nfound |
886 | @@: |
886 | @@: |
887 | call boot_log |
887 | call boot_log |
888 | 888 | ||
889 | ; PRINT AMOUNT OF MEMORY |
889 | ; PRINT AMOUNT OF MEMORY |
890 | mov esi, boot_memdetect |
890 | mov esi, boot_memdetect |
891 | call boot_log |
891 | call boot_log |
892 | 892 | ||
893 | movzx ecx, word [boot_y] |
893 | movzx ecx, word [boot_y] |
894 | if lang eq ru |
894 | if lang eq ru |
895 | or ecx, (10+30*6) shl 16 |
895 | or ecx, (10+30*6) shl 16 |
896 | else if lang eq sp |
896 | else if lang eq sp |
897 | or ecx, (10+33*6) shl 16 |
897 | or ecx, (10+33*6) shl 16 |
898 | else |
898 | else |
899 | or ecx, (10+29*6) shl 16 |
899 | or ecx, (10+29*6) shl 16 |
900 | end if |
900 | end if |
901 | sub ecx, 10 |
901 | sub ecx, 10 |
902 | mov edx, 0xFFFFFF |
902 | mov edx, 0xFFFFFF |
903 | mov ebx, [MEM_AMOUNT] |
903 | mov ebx, [MEM_AMOUNT] |
904 | shr ebx, 20 |
904 | shr ebx, 20 |
905 | xor edi, edi |
905 | xor edi, edi |
906 | mov eax, 0x00040000 |
906 | mov eax, 0x00040000 |
907 | inc edi |
907 | inc edi |
908 | call display_number_force |
908 | call display_number_force |
909 | 909 | ||
910 | ; BUILD SCHEDULER |
910 | ; BUILD SCHEDULER |
911 | 911 | ||
912 | ; call build_scheduler; sys32.inc |
912 | ; call build_scheduler; sys32.inc |
913 | 913 | ||
914 | ; mov esi, boot_devices |
914 | ; mov esi, boot_devices |
915 | ; call boot_log |
915 | ; call boot_log |
916 | 916 | ||
917 | call clear_pci_ide_interrupts |
917 | call clear_pci_ide_interrupts |
918 | 918 | ||
919 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
919 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
920 | 920 | ||
921 | stdcall load_driver, szVidintel |
921 | stdcall load_pe_driver, szVidintel, 0 |
922 | 922 | ||
923 | call usb_init |
923 | call usb_init |
924 | 924 | ||
925 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
925 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
926 | 926 | ||
927 | mov esi, boot_windefs |
927 | mov esi, boot_windefs |
928 | call boot_log |
928 | call boot_log |
929 | call set_window_defaults |
929 | call set_window_defaults |
930 | 930 | ||
931 | ; SET BACKGROUND DEFAULTS |
931 | ; SET BACKGROUND DEFAULTS |
932 | 932 | ||
933 | mov esi, boot_bgr |
933 | mov esi, boot_bgr |
934 | call boot_log |
934 | call boot_log |
935 | call init_background |
935 | call init_background |
936 | call calculatebackground |
936 | call calculatebackground |
937 | 937 | ||
938 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
938 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
939 | 939 | ||
940 | mov esi, boot_resirqports |
940 | mov esi, boot_resirqports |
941 | call boot_log |
941 | call boot_log |
942 | call reserve_irqs_ports |
942 | call reserve_irqs_ports |
943 | 943 | ||
944 | call init_display |
944 | call init_display |
945 | mov eax, [def_cursor] |
945 | mov eax, [def_cursor] |
946 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
946 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
947 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
947 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
948 | 948 | ||
949 | ; PRINT CPU FREQUENCY |
949 | ; PRINT CPU FREQUENCY |
950 | 950 | ||
951 | mov esi, boot_cpufreq |
951 | mov esi, boot_cpufreq |
952 | call boot_log |
952 | call boot_log |
953 | 953 | ||
954 | cli ;FIXME check IF |
954 | cli ;FIXME check IF |
955 | rdtsc |
955 | rdtsc |
956 | mov ecx, eax |
956 | mov ecx, eax |
957 | mov esi, 250 ; wait 1/4 a second |
957 | mov esi, 250 ; wait 1/4 a second |
958 | call delay_ms |
958 | call delay_ms |
959 | rdtsc |
959 | rdtsc |
960 | sti |
960 | sti |
961 | 961 | ||
962 | sub eax, ecx |
962 | sub eax, ecx |
963 | xor edx, edx |
963 | xor edx, edx |
964 | shld edx, eax, 2 |
964 | shld edx, eax, 2 |
965 | shl eax, 2 |
965 | shl eax, 2 |
966 | mov dword [cpu_freq], eax |
966 | mov dword [cpu_freq], eax |
967 | mov dword [cpu_freq+4], edx |
967 | mov dword [cpu_freq+4], edx |
968 | mov ebx, 1000000 |
968 | mov ebx, 1000000 |
969 | div ebx |
969 | div ebx |
970 | mov ebx, eax |
970 | mov ebx, eax |
971 | 971 | ||
972 | movzx ecx, word [boot_y] |
972 | movzx ecx, word [boot_y] |
973 | if lang eq ru |
973 | if lang eq ru |
974 | add ecx, (10+19*6) shl 16 - 10 |
974 | add ecx, (10+19*6) shl 16 - 10 |
975 | else if lang eq sp |
975 | else if lang eq sp |
976 | add ecx, (10+25*6) shl 16 - 10 |
976 | add ecx, (10+25*6) shl 16 - 10 |
977 | else |
977 | else |
978 | add ecx, (10+17*6) shl 16 - 10 |
978 | add ecx, (10+17*6) shl 16 - 10 |
979 | end if |
979 | end if |
980 | 980 | ||
981 | mov edx, 0xFFFFFF |
981 | mov edx, 0xFFFFFF |
982 | xor edi, edi |
982 | xor edi, edi |
983 | mov eax, 0x00040000 |
983 | mov eax, 0x00040000 |
984 | inc edi |
984 | inc edi |
985 | call display_number_force |
985 | call display_number_force |
986 | 986 | ||
987 | ; SET VARIABLES |
987 | ; SET VARIABLES |
988 | 988 | ||
989 | call set_variables |
989 | call set_variables |
990 | 990 | ||
991 | ; STACK AND FDC |
991 | ; STACK AND FDC |
992 | 992 | ||
993 | call stack_init |
993 | call stack_init |
994 | call fdc_init |
994 | call fdc_init |
995 | 995 | ||
996 | ; PALETTE FOR 320x200 and 640x480 16 col |
996 | ; PALETTE FOR 320x200 and 640x480 16 col |
997 | 997 | ||
998 | cmp [SCR_MODE], word 0x12 |
998 | cmp [SCR_MODE], word 0x12 |
999 | jne no_pal_vga |
999 | jne no_pal_vga |
1000 | mov esi, boot_pal_vga |
1000 | mov esi, boot_pal_vga |
1001 | call boot_log |
1001 | call boot_log |
1002 | call paletteVGA |
1002 | call paletteVGA |
1003 | no_pal_vga: |
1003 | no_pal_vga: |
1004 | 1004 | ||
1005 | cmp [SCR_MODE], word 0x13 |
1005 | cmp [SCR_MODE], word 0x13 |
1006 | jne no_pal_ega |
1006 | jne no_pal_ega |
1007 | mov esi, boot_pal_ega |
1007 | mov esi, boot_pal_ega |
1008 | call boot_log |
1008 | call boot_log |
1009 | call palette320x200 |
1009 | call palette320x200 |
1010 | no_pal_ega: |
1010 | no_pal_ega: |
1011 | 1011 | ||
1012 | ; LOAD DEFAULT SKIN |
1012 | ; LOAD DEFAULT SKIN |
1013 | 1013 | ||
1014 | call load_default_skin |
1014 | call load_default_skin |
1015 | 1015 | ||
1016 | ;protect io permission map |
1016 | ;protect io permission map |
1017 | 1017 | ||
1018 | mov esi, [default_io_map] |
1018 | mov esi, [default_io_map] |
1019 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1019 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1020 | add esi, 0x1000 |
1020 | add esi, 0x1000 |
1021 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1021 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1022 | 1022 | ||
1023 | stdcall map_page, tss._io_map_0, \ |
1023 | stdcall map_page, tss._io_map_0, \ |
1024 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1024 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1025 | stdcall map_page, tss._io_map_1, \ |
1025 | stdcall map_page, tss._io_map_1, \ |
1026 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1026 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1027 | 1027 | ||
1028 | ; SET KEYBOARD PARAMETERS |
1028 | ; SET KEYBOARD PARAMETERS |
1029 | mov al, 0xf6 ; reset keyboard, scan enabled |
1029 | mov al, 0xf6 ; reset keyboard, scan enabled |
1030 | call kb_write_wait_ack |
1030 | call kb_write_wait_ack |
1031 | test ah, ah |
1031 | test ah, ah |
1032 | jnz .no_keyboard |
1032 | jnz .no_keyboard |
1033 | 1033 | ||
1034 | iglobal |
1034 | iglobal |
1035 | align 4 |
1035 | align 4 |
1036 | ps2_keyboard_functions: |
1036 | ps2_keyboard_functions: |
1037 | dd .end - $ |
1037 | dd .end - $ |
1038 | dd 0 ; no close |
1038 | dd 0 ; no close |
1039 | dd ps2_set_lights |
1039 | dd ps2_set_lights |
1040 | .end: |
1040 | .end: |
1041 | endg |
1041 | endg |
1042 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1042 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1043 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1043 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1044 | ; call kb_write_wait_ack |
1044 | ; call kb_write_wait_ack |
1045 | ; mov al, 111b |
1045 | ; mov al, 111b |
1046 | ; call kb_write_wait_ack |
1046 | ; call kb_write_wait_ack |
1047 | 1047 | ||
1048 | mov al, 0xF3 ; set repeat rate & delay |
1048 | mov al, 0xF3 ; set repeat rate & delay |
1049 | call kb_write_wait_ack |
1049 | call kb_write_wait_ack |
1050 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1050 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1051 | call kb_write_wait_ack |
1051 | call kb_write_wait_ack |
1052 | ;// mike.dld [ |
1052 | ;// mike.dld [ |
1053 | call set_lights |
1053 | call set_lights |
1054 | ;// mike.dld ] |
1054 | ;// mike.dld ] |
1055 | stdcall attach_int_handler, 1, irq1, 0 |
1055 | stdcall attach_int_handler, 1, irq1, 0 |
1056 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1056 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1057 | .no_keyboard: |
1057 | .no_keyboard: |
1058 | 1058 | ||
1059 | ; Load PS/2 mouse driver |
1059 | ; Load PS/2 mouse driver |
1060 | 1060 | ||
1061 | stdcall load_driver, szPS2MDriver |
1061 | stdcall load_driver, szPS2MDriver |
1062 | 1062 | ||
1063 | mov esi, boot_setmouse |
1063 | mov esi, boot_setmouse |
1064 | call boot_log |
1064 | call boot_log |
1065 | call setmouse |
1065 | call setmouse |
1066 | 1066 | ||
1067 | ; LOAD FIRST APPLICATION |
1067 | ; LOAD FIRST APPLICATION |
1068 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1068 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1069 | jnz first_app_found |
1069 | jnz first_app_found |
1070 | 1070 | ||
1071 | cli |
1071 | cli |
1072 | mov ebp, firstapp |
1072 | mov ebp, firstapp |
1073 | call fs_execute_from_sysdir |
1073 | call fs_execute_from_sysdir |
1074 | test eax, eax |
1074 | test eax, eax |
1075 | jns first_app_found |
1075 | jns first_app_found |
1076 | 1076 | ||
1077 | mov esi, boot_failed |
1077 | mov esi, boot_failed |
1078 | call boot_log |
1078 | call boot_log |
1079 | 1079 | ||
1080 | mov eax, 0xDEADBEEF ; otherwise halt |
1080 | mov eax, 0xDEADBEEF ; otherwise halt |
1081 | hlt |
1081 | hlt |
1082 | 1082 | ||
1083 | first_app_found: |
1083 | first_app_found: |
1084 | 1084 | ||
1085 | ; START MULTITASKING |
1085 | ; START MULTITASKING |
1086 | 1086 | ||
1087 | ; A 'All set - press ESC to start' messages if need |
1087 | ; A 'All set - press ESC to start' messages if need |
1088 | if preboot_blogesc |
1088 | if preboot_blogesc |
1089 | mov esi, boot_tasking |
1089 | mov esi, boot_tasking |
1090 | call boot_log |
1090 | call boot_log |
1091 | .bll1: |
1091 | .bll1: |
1092 | in al, 0x60 ; wait for ESC key press |
1092 | in al, 0x60 ; wait for ESC key press |
1093 | cmp al, 129 |
1093 | cmp al, 129 |
1094 | jne .bll1 |
1094 | jne .bll1 |
1095 | end if |
1095 | end if |
1096 | 1096 | ||
1097 | mov [timer_ticks_enable], 1 ; for cd driver |
1097 | mov [timer_ticks_enable], 1 ; for cd driver |
1098 | 1098 | ||
1099 | sti |
1099 | sti |
1100 | 1100 | ||
1101 | call mtrr_validate |
1101 | call mtrr_validate |
1102 | 1102 | ||
1103 | jmp osloop |
1103 | jmp osloop |
1104 | 1104 | ||
1105 | 1105 | ||
1106 | ; Fly :) |
1106 | ; Fly :) |
1107 | 1107 | ||
1108 | uglobal |
1108 | uglobal |
1109 | align 4 |
1109 | align 4 |
1110 | ap_initialized dd 0 |
1110 | ap_initialized dd 0 |
1111 | endg |
1111 | endg |
1112 | 1112 | ||
1113 | ap_init_high: |
1113 | ap_init_high: |
1114 | mov ax, os_stack |
1114 | mov ax, os_stack |
1115 | mov bx, app_data |
1115 | mov bx, app_data |
1116 | mov cx, app_tls |
1116 | mov cx, app_tls |
1117 | mov ss, ax |
1117 | mov ss, ax |
1118 | mov ds, bx |
1118 | mov ds, bx |
1119 | mov es, bx |
1119 | mov es, bx |
1120 | mov fs, cx |
1120 | mov fs, cx |
1121 | mov gs, bx |
1121 | mov gs, bx |
1122 | xor esp, esp |
1122 | xor esp, esp |
1123 | mov eax, sys_pgdir-OS_BASE |
1123 | mov eax, sys_pgdir-OS_BASE |
1124 | mov cr3, eax |
1124 | mov cr3, eax |
1125 | lock inc [ap_initialized] |
1125 | lock inc [ap_initialized] |
1126 | jmp idle_loop |
1126 | jmp idle_loop |
1127 | 1127 | ||
1128 | 1128 | ||
1129 | include 'unpacker.inc' |
1129 | include 'unpacker.inc' |
1130 | 1130 | ||
1131 | align 4 |
1131 | align 4 |
1132 | boot_log: |
1132 | boot_log: |
1133 | pushad |
1133 | pushad |
1134 | 1134 | ||
1135 | mov ebx, 10*65536 |
1135 | mov ebx, 10*65536 |
1136 | mov bx, word [boot_y] |
1136 | mov bx, word [boot_y] |
1137 | add [boot_y], dword 10 |
1137 | add [boot_y], dword 10 |
1138 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1138 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1139 | xor edi, edi |
1139 | xor edi, edi |
1140 | mov edx, esi |
1140 | mov edx, esi |
1141 | inc edi |
1141 | inc edi |
1142 | call dtext |
1142 | call dtext |
1143 | 1143 | ||
1144 | mov [novesachecksum], 1000 |
1144 | mov [novesachecksum], 1000 |
1145 | call checkVga_N13 |
1145 | call checkVga_N13 |
1146 | 1146 | ||
1147 | popad |
1147 | popad |
1148 | 1148 | ||
1149 | ret |
1149 | ret |
1150 | 1150 | ||
1151 | ; in: edx -> APPDATA for OS/IDLE slot |
1151 | ; in: edx -> APPDATA for OS/IDLE slot |
1152 | ; in: ebx = stack base |
1152 | ; in: ebx = stack base |
1153 | proc setup_os_slot |
1153 | proc setup_os_slot |
1154 | xor eax, eax |
1154 | xor eax, eax |
1155 | mov ecx, 256/4 |
1155 | mov ecx, 256/4 |
1156 | mov edi, edx |
1156 | mov edi, edx |
1157 | rep stosd |
1157 | rep stosd |
1158 | 1158 | ||
1159 | mov eax, tss+0x80 |
1159 | mov eax, tss+0x80 |
1160 | call get_pg_addr |
1160 | call get_pg_addr |
1161 | inc eax |
1161 | inc eax |
1162 | mov [edx+APPDATA.io_map], eax |
1162 | mov [edx+APPDATA.io_map], eax |
1163 | mov eax, tss+0x1080 |
1163 | mov eax, tss+0x1080 |
1164 | call get_pg_addr |
1164 | call get_pg_addr |
1165 | inc eax |
1165 | inc eax |
1166 | mov [edx+APPDATA.io_map+4], eax |
1166 | mov [edx+APPDATA.io_map+4], eax |
1167 | 1167 | ||
1168 | mov dword [edx+APPDATA.pl0_stack], ebx |
1168 | mov dword [edx+APPDATA.pl0_stack], ebx |
1169 | lea edi, [ebx+0x2000-512] |
1169 | lea edi, [ebx+0x2000-512] |
1170 | mov dword [edx+APPDATA.fpu_state], edi |
1170 | mov dword [edx+APPDATA.fpu_state], edi |
1171 | mov dword [edx+APPDATA.saved_esp0], edi |
1171 | mov dword [edx+APPDATA.saved_esp0], edi |
1172 | mov dword [edx+APPDATA.saved_esp], edi |
1172 | mov dword [edx+APPDATA.saved_esp], edi |
1173 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1173 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1174 | 1174 | ||
1175 | mov esi, fpu_data |
1175 | mov esi, fpu_data |
1176 | mov ecx, 512/4 |
1176 | mov ecx, 512/4 |
1177 | cld |
1177 | cld |
1178 | rep movsd |
1178 | rep movsd |
1179 | 1179 | ||
1180 | lea eax, [edx+APP_OBJ_OFFSET] |
1180 | lea eax, [edx+APP_OBJ_OFFSET] |
1181 | mov dword [edx+APPDATA.fd_obj], eax |
1181 | mov dword [edx+APPDATA.fd_obj], eax |
1182 | mov dword [edx+APPDATA.bk_obj], eax |
1182 | mov dword [edx+APPDATA.bk_obj], eax |
1183 | 1183 | ||
1184 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1184 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1185 | 1185 | ||
1186 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1186 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1187 | 1187 | ||
1188 | mov eax, edx |
1188 | mov eax, edx |
1189 | shr eax, 3 |
1189 | shr eax, 3 |
1190 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1190 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1191 | mov [eax+TASKDATA.wnd_number], dh |
1191 | mov [eax+TASKDATA.wnd_number], dh |
1192 | mov byte [eax+TASKDATA.pid], dh |
1192 | mov byte [eax+TASKDATA.pid], dh |
1193 | 1193 | ||
1194 | ret |
1194 | ret |
1195 | endp |
1195 | endp |
1196 | 1196 | ||
1197 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1197 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1198 | ; ; |
1198 | ; ; |
1199 | ; MAIN OS LOOP START ; |
1199 | ; MAIN OS LOOP START ; |
1200 | ; ; |
1200 | ; ; |
1201 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1201 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1202 | align 32 |
1202 | align 32 |
1203 | osloop: |
1203 | osloop: |
1204 | mov edx, osloop_has_work? |
1204 | mov edx, osloop_has_work? |
1205 | xor ecx, ecx |
1205 | xor ecx, ecx |
1206 | call Wait_events |
1206 | call Wait_events |
1207 | xor eax, eax |
1207 | xor eax, eax |
1208 | xchg eax, [osloop_nonperiodic_work] |
1208 | xchg eax, [osloop_nonperiodic_work] |
1209 | test eax, eax |
1209 | test eax, eax |
1210 | jz .no_periodic |
1210 | jz .no_periodic |
1211 | 1211 | ||
1212 | call __sys_draw_pointer |
1212 | call __sys_draw_pointer |
1213 | call window_check_events |
1213 | call window_check_events |
1214 | call mouse_check_events |
1214 | call mouse_check_events |
1215 | call checkmisc |
1215 | call checkmisc |
1216 | call checkVga_N13 |
1216 | call checkVga_N13 |
1217 | ;-------------------------------------- |
1217 | ;-------------------------------------- |
1218 | .no_periodic: |
1218 | .no_periodic: |
1219 | call stack_handler |
1219 | call stack_handler |
1220 | call check_fdd_motor_status |
1220 | call check_fdd_motor_status |
1221 | call check_ATAPI_device_event |
1221 | call check_ATAPI_device_event |
1222 | call check_lights_state |
1222 | call check_lights_state |
1223 | call check_timers |
1223 | call check_timers |
1224 | 1224 | ||
1225 | jmp osloop |
1225 | jmp osloop |
1226 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1226 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1227 | ; ; |
1227 | ; ; |
1228 | ; MAIN OS LOOP END ; |
1228 | ; MAIN OS LOOP END ; |
1229 | ; ; |
1229 | ; ; |
1230 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1230 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1231 | proc osloop_has_work? |
1231 | proc osloop_has_work? |
1232 | cmp [osloop_nonperiodic_work], 0 |
1232 | cmp [osloop_nonperiodic_work], 0 |
1233 | jnz .yes |
1233 | jnz .yes |
1234 | call stack_handler_has_work? |
1234 | call stack_handler_has_work? |
1235 | jnz .yes |
1235 | jnz .yes |
1236 | call check_fdd_motor_status_has_work? |
1236 | call check_fdd_motor_status_has_work? |
1237 | jnz .yes |
1237 | jnz .yes |
1238 | call check_ATAPI_device_event_has_work? |
1238 | call check_ATAPI_device_event_has_work? |
1239 | jnz .yes |
1239 | jnz .yes |
1240 | call check_lights_state_has_work? |
1240 | call check_lights_state_has_work? |
1241 | jnz .yes |
1241 | jnz .yes |
1242 | call check_timers_has_work? |
1242 | call check_timers_has_work? |
1243 | jnz .yes |
1243 | jnz .yes |
1244 | .no: |
1244 | .no: |
1245 | xor eax, eax |
1245 | xor eax, eax |
1246 | ret |
1246 | ret |
1247 | .yes: |
1247 | .yes: |
1248 | xor eax, eax |
1248 | xor eax, eax |
1249 | inc eax |
1249 | inc eax |
1250 | ret |
1250 | ret |
1251 | endp |
1251 | endp |
1252 | 1252 | ||
1253 | proc wakeup_osloop |
1253 | proc wakeup_osloop |
1254 | mov [osloop_nonperiodic_work], 1 |
1254 | mov [osloop_nonperiodic_work], 1 |
1255 | ret |
1255 | ret |
1256 | endp |
1256 | endp |
1257 | 1257 | ||
1258 | uglobal |
1258 | uglobal |
1259 | align 4 |
1259 | align 4 |
1260 | osloop_nonperiodic_work dd ? |
1260 | osloop_nonperiodic_work dd ? |
1261 | endg |
1261 | endg |
1262 | 1262 | ||
1263 | uglobal |
1263 | uglobal |
1264 | align 64 |
1264 | align 64 |
1265 | idle_addr rb 64 |
1265 | idle_addr rb 64 |
1266 | endg |
1266 | endg |
1267 | 1267 | ||
1268 | idle_thread: |
1268 | idle_thread: |
1269 | sti |
1269 | sti |
1270 | 1270 | ||
1271 | ; The following code can be executed by all CPUs in the system. |
1271 | ; The following code can be executed by all CPUs in the system. |
1272 | ; All other parts of the kernel do not expect multi-CPU. |
1272 | ; All other parts of the kernel do not expect multi-CPU. |
1273 | ; Also, APs don't even have a stack here. |
1273 | ; Also, APs don't even have a stack here. |
1274 | ; Beware. Don't do anything here. Anything at all. |
1274 | ; Beware. Don't do anything here. Anything at all. |
1275 | idle_loop: |
1275 | idle_loop: |
1276 | cmp [use_mwait_for_idle], 0 |
1276 | cmp [use_mwait_for_idle], 0 |
1277 | jnz idle_loop_mwait |
1277 | jnz idle_loop_mwait |
1278 | 1278 | ||
1279 | idle_loop_hlt: |
1279 | idle_loop_hlt: |
1280 | hlt |
1280 | hlt |
1281 | jmp idle_loop_hlt |
1281 | jmp idle_loop_hlt |
1282 | 1282 | ||
1283 | idle_loop_mwait: |
1283 | idle_loop_mwait: |
1284 | mov eax, idle_addr |
1284 | mov eax, idle_addr |
1285 | xor ecx, ecx |
1285 | xor ecx, ecx |
1286 | xor edx, edx |
1286 | xor edx, edx |
1287 | monitor |
1287 | monitor |
1288 | xor ecx, ecx |
1288 | xor ecx, ecx |
1289 | mov eax, 20h ; or 10h |
1289 | mov eax, 20h ; or 10h |
1290 | mwait |
1290 | mwait |
1291 | jmp idle_loop_mwait |
1291 | jmp idle_loop_mwait |
1292 | 1292 | ||
1293 | 1293 | ||
1294 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1294 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1295 | ; ; |
1295 | ; ; |
1296 | ; INCLUDED SYSTEM FILES ; |
1296 | ; INCLUDED SYSTEM FILES ; |
1297 | ; ; |
1297 | ; ; |
1298 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1298 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1299 | 1299 | ||
1300 | 1300 | ||
1301 | include "kernel32.inc" |
1301 | include "kernel32.inc" |
1302 | 1302 | ||
1303 | 1303 | ||
1304 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1304 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1305 | ; ; |
1305 | ; ; |
1306 | ; KERNEL FUNCTIONS ; |
1306 | ; KERNEL FUNCTIONS ; |
1307 | ; ; |
1307 | ; ; |
1308 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1308 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1309 | 1309 | ||
1310 | reserve_irqs_ports: |
1310 | reserve_irqs_ports: |
1311 | 1311 | ||
1312 | 1312 | ||
1313 | ; RESERVE PORTS |
1313 | ; RESERVE PORTS |
1314 | mov eax, RESERVED_PORTS |
1314 | mov eax, RESERVED_PORTS |
1315 | mov ecx, 1 |
1315 | mov ecx, 1 |
1316 | 1316 | ||
1317 | mov [eax], dword 4 |
1317 | mov [eax], dword 4 |
1318 | 1318 | ||
1319 | mov [eax+16], ecx |
1319 | mov [eax+16], ecx |
1320 | mov [eax+16+4], dword 0 |
1320 | mov [eax+16+4], dword 0 |
1321 | mov [eax+16+8], dword 0x2D |
1321 | mov [eax+16+8], dword 0x2D |
1322 | 1322 | ||
1323 | mov [eax+32], ecx |
1323 | mov [eax+32], ecx |
1324 | mov [eax+32+4], dword 0x30 |
1324 | mov [eax+32+4], dword 0x30 |
1325 | mov [eax+32+8], dword 0x4D |
1325 | mov [eax+32+8], dword 0x4D |
1326 | 1326 | ||
1327 | mov [eax+48], ecx |
1327 | mov [eax+48], ecx |
1328 | mov [eax+48+4], dword 0x50 |
1328 | mov [eax+48+4], dword 0x50 |
1329 | mov [eax+48+8], dword 0xDF |
1329 | mov [eax+48+8], dword 0xDF |
1330 | 1330 | ||
1331 | mov [eax+64], ecx |
1331 | mov [eax+64], ecx |
1332 | mov [eax+64+4], dword 0xE5 |
1332 | mov [eax+64+4], dword 0xE5 |
1333 | mov [eax+64+8], dword 0xFF |
1333 | mov [eax+64+8], dword 0xFF |
1334 | 1334 | ||
1335 | ret |
1335 | ret |
1336 | 1336 | ||
1337 | 1337 | ||
1338 | iglobal |
1338 | iglobal |
1339 | process_number dd 0x2 |
1339 | process_number dd 0x2 |
1340 | endg |
1340 | endg |
1341 | 1341 | ||
1342 | set_variables: |
1342 | set_variables: |
1343 | 1343 | ||
1344 | mov ecx, 0x16 ; flush port 0x60 |
1344 | mov ecx, 0x16 ; flush port 0x60 |
1345 | .fl60: |
1345 | .fl60: |
1346 | in al, 0x60 |
1346 | in al, 0x60 |
1347 | loop .fl60 |
1347 | loop .fl60 |
1348 | push eax |
1348 | push eax |
1349 | 1349 | ||
1350 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1350 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1351 | shr ax, 1 |
1351 | shr ax, 1 |
1352 | shl eax, 16 |
1352 | shl eax, 16 |
1353 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1353 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1354 | shr ax, 1 |
1354 | shr ax, 1 |
1355 | mov [MOUSE_X], eax |
1355 | mov [MOUSE_X], eax |
1356 | call wakeup_osloop |
1356 | call wakeup_osloop |
1357 | 1357 | ||
1358 | xor eax, eax |
1358 | xor eax, eax |
1359 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1359 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1360 | 1360 | ||
1361 | mov byte [KEY_COUNT], al ; keyboard buffer |
1361 | mov byte [KEY_COUNT], al ; keyboard buffer |
1362 | mov byte [BTN_COUNT], al ; button buffer |
1362 | mov byte [BTN_COUNT], al ; button buffer |
1363 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1363 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1364 | 1364 | ||
1365 | pop eax |
1365 | pop eax |
1366 | ret |
1366 | ret |
1367 | 1367 | ||
1368 | align 4 |
1368 | align 4 |
1369 | ;input eax=43,bl-byte of output, ecx - number of port |
1369 | ;input eax=43,bl-byte of output, ecx - number of port |
1370 | sys_outport: |
1370 | sys_outport: |
1371 | 1371 | ||
1372 | mov edi, ecx ; separate flag for read / write |
1372 | mov edi, ecx ; separate flag for read / write |
1373 | and ecx, 65535 |
1373 | and ecx, 65535 |
1374 | 1374 | ||
1375 | mov eax, [RESERVED_PORTS] |
1375 | mov eax, [RESERVED_PORTS] |
1376 | test eax, eax |
1376 | test eax, eax |
1377 | jnz .sopl8 |
1377 | jnz .sopl8 |
1378 | inc eax |
1378 | inc eax |
1379 | mov [esp+32], eax |
1379 | mov [esp+32], eax |
1380 | ret |
1380 | ret |
1381 | 1381 | ||
1382 | .sopl8: |
1382 | .sopl8: |
1383 | mov edx, [TASK_BASE] |
1383 | mov edx, [TASK_BASE] |
1384 | mov edx, [edx+0x4] |
1384 | mov edx, [edx+0x4] |
1385 | ;and ecx,65535 |
1385 | ;and ecx,65535 |
1386 | ;cld - set on interrupt 0x40 |
1386 | ;cld - set on interrupt 0x40 |
1387 | .sopl1: |
1387 | .sopl1: |
1388 | 1388 | ||
1389 | mov esi, eax |
1389 | mov esi, eax |
1390 | shl esi, 4 |
1390 | shl esi, 4 |
1391 | add esi, RESERVED_PORTS |
1391 | add esi, RESERVED_PORTS |
1392 | cmp edx, [esi+0] |
1392 | cmp edx, [esi+0] |
1393 | jne .sopl2 |
1393 | jne .sopl2 |
1394 | cmp ecx, [esi+4] |
1394 | cmp ecx, [esi+4] |
1395 | jb .sopl2 |
1395 | jb .sopl2 |
1396 | cmp ecx, [esi+8] |
1396 | cmp ecx, [esi+8] |
1397 | jg .sopl2 |
1397 | jg .sopl2 |
1398 | .sopl3: |
1398 | .sopl3: |
1399 | 1399 | ||
1400 | test edi, 0x80000000; read ? |
1400 | test edi, 0x80000000; read ? |
1401 | jnz .sopl4 |
1401 | jnz .sopl4 |
1402 | 1402 | ||
1403 | mov eax, ebx |
1403 | mov eax, ebx |
1404 | mov dx, cx ; write |
1404 | mov dx, cx ; write |
1405 | out dx, al |
1405 | out dx, al |
1406 | and [esp+32], dword 0 |
1406 | and [esp+32], dword 0 |
1407 | ret |
1407 | ret |
1408 | 1408 | ||
1409 | .sopl2: |
1409 | .sopl2: |
1410 | 1410 | ||
1411 | dec eax |
1411 | dec eax |
1412 | jnz .sopl1 |
1412 | jnz .sopl1 |
1413 | inc eax |
1413 | inc eax |
1414 | mov [esp+32], eax |
1414 | mov [esp+32], eax |
1415 | ret |
1415 | ret |
1416 | 1416 | ||
1417 | 1417 | ||
1418 | .sopl4: |
1418 | .sopl4: |
1419 | 1419 | ||
1420 | mov dx, cx ; read |
1420 | mov dx, cx ; read |
1421 | in al, dx |
1421 | in al, dx |
1422 | and eax, 0xff |
1422 | and eax, 0xff |
1423 | and [esp+32], dword 0 |
1423 | and [esp+32], dword 0 |
1424 | mov [esp+20], eax |
1424 | mov [esp+20], eax |
1425 | ret |
1425 | ret |
1426 | 1426 | ||
1427 | display_number: |
1427 | display_number: |
1428 | ;It is not optimization |
1428 | ;It is not optimization |
1429 | mov eax, ebx |
1429 | mov eax, ebx |
1430 | mov ebx, ecx |
1430 | mov ebx, ecx |
1431 | mov ecx, edx |
1431 | mov ecx, edx |
1432 | mov edx, esi |
1432 | mov edx, esi |
1433 | mov esi, edi |
1433 | mov esi, edi |
1434 | ; eax = print type, al=0 -> ebx is number |
1434 | ; eax = print type, al=0 -> ebx is number |
1435 | ; al=1 -> ebx is pointer |
1435 | ; al=1 -> ebx is pointer |
1436 | ; ah=0 -> display decimal |
1436 | ; ah=0 -> display decimal |
1437 | ; ah=1 -> display hexadecimal |
1437 | ; ah=1 -> display hexadecimal |
1438 | ; ah=2 -> display binary |
1438 | ; ah=2 -> display binary |
1439 | ; eax bits 16-21 = number of digits to display (0-32) |
1439 | ; eax bits 16-21 = number of digits to display (0-32) |
1440 | ; eax bits 22-31 = reserved |
1440 | ; eax bits 22-31 = reserved |
1441 | ; |
1441 | ; |
1442 | ; ebx = number or pointer |
1442 | ; ebx = number or pointer |
1443 | ; ecx = x shl 16 + y |
1443 | ; ecx = x shl 16 + y |
1444 | ; edx = color |
1444 | ; edx = color |
1445 | xor edi, edi |
1445 | xor edi, edi |
1446 | display_number_force: |
1446 | display_number_force: |
1447 | push eax |
1447 | push eax |
1448 | and eax, 0x3fffffff |
1448 | and eax, 0x3fffffff |
1449 | cmp eax, 0xffff ; length > 0 ? |
1449 | cmp eax, 0xffff ; length > 0 ? |
1450 | pop eax |
1450 | pop eax |
1451 | jge cont_displ |
1451 | jge cont_displ |
1452 | ret |
1452 | ret |
1453 | cont_displ: |
1453 | cont_displ: |
1454 | push eax |
1454 | push eax |
1455 | and eax, 0x3fffffff |
1455 | and eax, 0x3fffffff |
1456 | cmp eax, 61*0x10000 ; length <= 60 ? |
1456 | cmp eax, 61*0x10000 ; length <= 60 ? |
1457 | pop eax |
1457 | pop eax |
1458 | jb cont_displ2 |
1458 | jb cont_displ2 |
1459 | ret |
1459 | ret |
1460 | cont_displ2: |
1460 | cont_displ2: |
1461 | 1461 | ||
1462 | pushad |
1462 | pushad |
1463 | 1463 | ||
1464 | cmp al, 1 ; ecx is a pointer ? |
1464 | cmp al, 1 ; ecx is a pointer ? |
1465 | jne displnl1 |
1465 | jne displnl1 |
1466 | mov ebp, ebx |
1466 | mov ebp, ebx |
1467 | add ebp, 4 |
1467 | add ebp, 4 |
1468 | mov ebp, [ebp+std_application_base_address] |
1468 | mov ebp, [ebp+std_application_base_address] |
1469 | mov ebx, [ebx+std_application_base_address] |
1469 | mov ebx, [ebx+std_application_base_address] |
1470 | displnl1: |
1470 | displnl1: |
1471 | sub esp, 64 |
1471 | sub esp, 64 |
1472 | 1472 | ||
1473 | test ah, ah ; DECIMAL |
1473 | test ah, ah ; DECIMAL |
1474 | jnz no_display_desnum |
1474 | jnz no_display_desnum |
1475 | shr eax, 16 |
1475 | shr eax, 16 |
1476 | and eax, 0xC03f |
1476 | and eax, 0xC03f |
1477 | ; and eax,0x3f |
1477 | ; and eax,0x3f |
1478 | push eax |
1478 | push eax |
1479 | and eax, 0x3f |
1479 | and eax, 0x3f |
1480 | mov edi, esp |
1480 | mov edi, esp |
1481 | add edi, 4+64-1 |
1481 | add edi, 4+64-1 |
1482 | mov ecx, eax |
1482 | mov ecx, eax |
1483 | mov eax, ebx |
1483 | mov eax, ebx |
1484 | mov ebx, 10 |
1484 | mov ebx, 10 |
1485 | d_desnum: |
1485 | d_desnum: |
1486 | xor edx, edx |
1486 | xor edx, edx |
1487 | call division_64_bits |
1487 | call division_64_bits |
1488 | div ebx |
1488 | div ebx |
1489 | add dl, 48 |
1489 | add dl, 48 |
1490 | mov [edi], dl |
1490 | mov [edi], dl |
1491 | dec edi |
1491 | dec edi |
1492 | loop d_desnum |
1492 | loop d_desnum |
1493 | pop eax |
1493 | pop eax |
1494 | call normalize_number |
1494 | call normalize_number |
1495 | call draw_num_text |
1495 | call draw_num_text |
1496 | add esp, 64 |
1496 | add esp, 64 |
1497 | popad |
1497 | popad |
1498 | ret |
1498 | ret |
1499 | no_display_desnum: |
1499 | no_display_desnum: |
1500 | 1500 | ||
1501 | cmp ah, 0x01 ; HEXADECIMAL |
1501 | cmp ah, 0x01 ; HEXADECIMAL |
1502 | jne no_display_hexnum |
1502 | jne no_display_hexnum |
1503 | shr eax, 16 |
1503 | shr eax, 16 |
1504 | and eax, 0xC03f |
1504 | and eax, 0xC03f |
1505 | ; and eax,0x3f |
1505 | ; and eax,0x3f |
1506 | push eax |
1506 | push eax |
1507 | and eax, 0x3f |
1507 | and eax, 0x3f |
1508 | mov edi, esp |
1508 | mov edi, esp |
1509 | add edi, 4+64-1 |
1509 | add edi, 4+64-1 |
1510 | mov ecx, eax |
1510 | mov ecx, eax |
1511 | mov eax, ebx |
1511 | mov eax, ebx |
1512 | mov ebx, 16 |
1512 | mov ebx, 16 |
1513 | d_hexnum: |
1513 | d_hexnum: |
1514 | xor edx, edx |
1514 | xor edx, edx |
1515 | call division_64_bits |
1515 | call division_64_bits |
1516 | div ebx |
1516 | div ebx |
1517 | hexletters = __fdo_hexdigits |
1517 | hexletters = __fdo_hexdigits |
1518 | add edx, hexletters |
1518 | add edx, hexletters |
1519 | mov dl, [edx] |
1519 | mov dl, [edx] |
1520 | mov [edi], dl |
1520 | mov [edi], dl |
1521 | dec edi |
1521 | dec edi |
1522 | loop d_hexnum |
1522 | loop d_hexnum |
1523 | pop eax |
1523 | pop eax |
1524 | call normalize_number |
1524 | call normalize_number |
1525 | call draw_num_text |
1525 | call draw_num_text |
1526 | add esp, 64 |
1526 | add esp, 64 |
1527 | popad |
1527 | popad |
1528 | ret |
1528 | ret |
1529 | no_display_hexnum: |
1529 | no_display_hexnum: |
1530 | 1530 | ||
1531 | cmp ah, 0x02 ; BINARY |
1531 | cmp ah, 0x02 ; BINARY |
1532 | jne no_display_binnum |
1532 | jne no_display_binnum |
1533 | shr eax, 16 |
1533 | shr eax, 16 |
1534 | and eax, 0xC03f |
1534 | and eax, 0xC03f |
1535 | ; and eax,0x3f |
1535 | ; and eax,0x3f |
1536 | push eax |
1536 | push eax |
1537 | and eax, 0x3f |
1537 | and eax, 0x3f |
1538 | mov edi, esp |
1538 | mov edi, esp |
1539 | add edi, 4+64-1 |
1539 | add edi, 4+64-1 |
1540 | mov ecx, eax |
1540 | mov ecx, eax |
1541 | mov eax, ebx |
1541 | mov eax, ebx |
1542 | mov ebx, 2 |
1542 | mov ebx, 2 |
1543 | d_binnum: |
1543 | d_binnum: |
1544 | xor edx, edx |
1544 | xor edx, edx |
1545 | call division_64_bits |
1545 | call division_64_bits |
1546 | div ebx |
1546 | div ebx |
1547 | add dl, 48 |
1547 | add dl, 48 |
1548 | mov [edi], dl |
1548 | mov [edi], dl |
1549 | dec edi |
1549 | dec edi |
1550 | loop d_binnum |
1550 | loop d_binnum |
1551 | pop eax |
1551 | pop eax |
1552 | call normalize_number |
1552 | call normalize_number |
1553 | call draw_num_text |
1553 | call draw_num_text |
1554 | add esp, 64 |
1554 | add esp, 64 |
1555 | popad |
1555 | popad |
1556 | ret |
1556 | ret |
1557 | no_display_binnum: |
1557 | no_display_binnum: |
1558 | 1558 | ||
1559 | add esp, 64 |
1559 | add esp, 64 |
1560 | popad |
1560 | popad |
1561 | ret |
1561 | ret |
1562 | 1562 | ||
1563 | normalize_number: |
1563 | normalize_number: |
1564 | test ah, 0x80 |
1564 | test ah, 0x80 |
1565 | jz .continue |
1565 | jz .continue |
1566 | mov ecx, 48 |
1566 | mov ecx, 48 |
1567 | and eax, 0x3f |
1567 | and eax, 0x3f |
1568 | @@: |
1568 | @@: |
1569 | inc edi |
1569 | inc edi |
1570 | cmp [edi], cl |
1570 | cmp [edi], cl |
1571 | jne .continue |
1571 | jne .continue |
1572 | dec eax |
1572 | dec eax |
1573 | cmp eax, 1 |
1573 | cmp eax, 1 |
1574 | ja @r |
1574 | ja @r |
1575 | mov al, 1 |
1575 | mov al, 1 |
1576 | .continue: |
1576 | .continue: |
1577 | and eax, 0x3f |
1577 | and eax, 0x3f |
1578 | ret |
1578 | ret |
1579 | 1579 | ||
1580 | division_64_bits: |
1580 | division_64_bits: |
1581 | test [esp+1+4], byte 0x40 |
1581 | test [esp+1+4], byte 0x40 |
1582 | jz .continue |
1582 | jz .continue |
1583 | push eax |
1583 | push eax |
1584 | mov eax, ebp |
1584 | mov eax, ebp |
1585 | div ebx |
1585 | div ebx |
1586 | mov ebp, eax |
1586 | mov ebp, eax |
1587 | pop eax |
1587 | pop eax |
1588 | .continue: |
1588 | .continue: |
1589 | ret |
1589 | ret |
1590 | 1590 | ||
1591 | draw_num_text: |
1591 | draw_num_text: |
1592 | mov esi, eax |
1592 | mov esi, eax |
1593 | mov edx, 64+4 |
1593 | mov edx, 64+4 |
1594 | sub edx, eax |
1594 | sub edx, eax |
1595 | add edx, esp |
1595 | add edx, esp |
1596 | mov ebx, [esp+64+32-8+4] |
1596 | mov ebx, [esp+64+32-8+4] |
1597 | ; add window start x & y |
1597 | ; add window start x & y |
1598 | mov ecx, [TASK_BASE] |
1598 | mov ecx, [TASK_BASE] |
1599 | 1599 | ||
1600 | mov edi, [CURRENT_TASK] |
1600 | mov edi, [CURRENT_TASK] |
1601 | shl edi, 8 |
1601 | shl edi, 8 |
1602 | 1602 | ||
1603 | mov eax, [ecx-twdw+WDATA.box.left] |
1603 | mov eax, [ecx-twdw+WDATA.box.left] |
1604 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1604 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1605 | shl eax, 16 |
1605 | shl eax, 16 |
1606 | add eax, [ecx-twdw+WDATA.box.top] |
1606 | add eax, [ecx-twdw+WDATA.box.top] |
1607 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1607 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1608 | add ebx, eax |
1608 | add ebx, eax |
1609 | mov ecx, [esp+64+32-12+4] |
1609 | mov ecx, [esp+64+32-12+4] |
1610 | and ecx, not 0x80000000 ; force counted string |
1610 | and ecx, not 0x80000000 ; force counted string |
1611 | mov eax, [esp+64+8] ; background color (if given) |
1611 | mov eax, [esp+64+8] ; background color (if given) |
1612 | mov edi, [esp+64+4] |
1612 | mov edi, [esp+64+4] |
1613 | jmp dtext |
1613 | jmp dtext |
1614 | ;----------------------------------------------------------------------------- |
1614 | ;----------------------------------------------------------------------------- |
1615 | iglobal |
1615 | iglobal |
1616 | midi_base dw 0 |
1616 | midi_base dw 0 |
1617 | endg |
1617 | endg |
1618 | ;----------------------------------------------------------------------------- |
1618 | ;----------------------------------------------------------------------------- |
1619 | align 4 |
1619 | align 4 |
1620 | sys_setup: |
1620 | sys_setup: |
1621 | ; 1 = roland mpu midi base , base io address |
1621 | ; 1 = roland mpu midi base , base io address |
1622 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1622 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1623 | ; 3 = not used |
1623 | ; 3 = not used |
1624 | ; 4 = not used |
1624 | ; 4 = not used |
1625 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1625 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1626 | ; 6 = not used |
1626 | ; 6 = not used |
1627 | ; 7 = not used |
1627 | ; 7 = not used |
1628 | ; 8 = not used |
1628 | ; 8 = not used |
1629 | ; 9 = not used |
1629 | ; 9 = not used |
1630 | ; 10 = not used |
1630 | ; 10 = not used |
1631 | ; 11 = enable lba read |
1631 | ; 11 = enable lba read |
1632 | ; 12 = enable pci access |
1632 | ; 12 = enable pci access |
1633 | ;----------------------------------------------------------------------------- |
1633 | ;----------------------------------------------------------------------------- |
1634 | and [esp+32], dword 0 |
1634 | and [esp+32], dword 0 |
1635 | ; F.21.1 - set MPU MIDI base port |
1635 | ; F.21.1 - set MPU MIDI base port |
1636 | dec ebx |
1636 | dec ebx |
1637 | jnz @f |
1637 | jnz @f |
1638 | 1638 | ||
1639 | cmp ecx, 0x100 |
1639 | cmp ecx, 0x100 |
1640 | jb @f |
1640 | jb @f |
1641 | 1641 | ||
1642 | mov esi, 65535 |
1642 | mov esi, 65535 |
1643 | cmp esi, ecx |
1643 | cmp esi, ecx |
1644 | jb @f |
1644 | jb @f |
1645 | 1645 | ||
1646 | mov [midi_base], cx |
1646 | mov [midi_base], cx |
1647 | mov word [mididp], cx |
1647 | mov word [mididp], cx |
1648 | inc cx |
1648 | inc cx |
1649 | mov word [midisp], cx |
1649 | mov word [midisp], cx |
1650 | ret |
1650 | ret |
1651 | ;-------------------------------------- |
1651 | ;-------------------------------------- |
1652 | @@: |
1652 | @@: |
1653 | ; F.21.2 - set keyboard layout |
1653 | ; F.21.2 - set keyboard layout |
1654 | dec ebx |
1654 | dec ebx |
1655 | jnz @f |
1655 | jnz @f |
1656 | 1656 | ||
1657 | mov edi, [TASK_BASE] |
1657 | mov edi, [TASK_BASE] |
1658 | mov eax, [edi+TASKDATA.mem_start] |
1658 | mov eax, [edi+TASKDATA.mem_start] |
1659 | add eax, edx |
1659 | add eax, edx |
1660 | ; 1 = normal layout |
1660 | ; 1 = normal layout |
1661 | dec ecx |
1661 | dec ecx |
1662 | jnz .shift |
1662 | jnz .shift |
1663 | 1663 | ||
1664 | mov ebx, keymap |
1664 | mov ebx, keymap |
1665 | mov ecx, 128 |
1665 | mov ecx, 128 |
1666 | call memmove |
1666 | call memmove |
1667 | ret |
1667 | ret |
1668 | ;-------------------------------------- |
1668 | ;-------------------------------------- |
1669 | .shift: |
1669 | .shift: |
1670 | ; 2 = layout at pressed Shift |
1670 | ; 2 = layout at pressed Shift |
1671 | dec ecx |
1671 | dec ecx |
1672 | jnz .alt |
1672 | jnz .alt |
1673 | 1673 | ||
1674 | mov ebx, keymap_shift |
1674 | mov ebx, keymap_shift |
1675 | mov ecx, 128 |
1675 | mov ecx, 128 |
1676 | call memmove |
1676 | call memmove |
1677 | ret |
1677 | ret |
1678 | ;-------------------------------------- |
1678 | ;-------------------------------------- |
1679 | .alt: |
1679 | .alt: |
1680 | ; 3 = layout at pressed Alt |
1680 | ; 3 = layout at pressed Alt |
1681 | dec ecx |
1681 | dec ecx |
1682 | jnz .country |
1682 | jnz .country |
1683 | 1683 | ||
1684 | mov ebx, keymap_alt |
1684 | mov ebx, keymap_alt |
1685 | mov ecx, 128 |
1685 | mov ecx, 128 |
1686 | call memmove |
1686 | call memmove |
1687 | ret |
1687 | ret |
1688 | ;-------------------------------------- |
1688 | ;-------------------------------------- |
1689 | .country: |
1689 | .country: |
1690 | ; country identifier |
1690 | ; country identifier |
1691 | sub ecx, 6 |
1691 | sub ecx, 6 |
1692 | jnz .error |
1692 | jnz .error |
1693 | 1693 | ||
1694 | mov word [keyboard], dx |
1694 | mov word [keyboard], dx |
1695 | ret |
1695 | ret |
1696 | ;-------------------------------------- |
1696 | ;-------------------------------------- |
1697 | @@: |
1697 | @@: |
1698 | ; F.21.5 - set system language |
1698 | ; F.21.5 - set system language |
1699 | sub ebx, 3 |
1699 | sub ebx, 3 |
1700 | jnz @f |
1700 | jnz @f |
1701 | 1701 | ||
1702 | mov [syslang], ecx |
1702 | mov [syslang], ecx |
1703 | ret |
1703 | ret |
1704 | ;-------------------------------------- |
1704 | ;-------------------------------------- |
1705 | @@: |
1705 | @@: |
1706 | ; F.21.11 - enable/disable low-level access to HD |
1706 | ; F.21.11 - enable/disable low-level access to HD |
1707 | and ecx, 1 |
1707 | and ecx, 1 |
1708 | sub ebx, 6 |
1708 | sub ebx, 6 |
1709 | jnz @f |
1709 | jnz @f |
1710 | 1710 | ||
1711 | mov [lba_read_enabled], ecx |
1711 | mov [lba_read_enabled], ecx |
1712 | ret |
1712 | ret |
1713 | ;-------------------------------------- |
1713 | ;-------------------------------------- |
1714 | @@: |
1714 | @@: |
1715 | ; F.21.12 - enable/disable low-level access to PCI |
1715 | ; F.21.12 - enable/disable low-level access to PCI |
1716 | dec ebx |
1716 | dec ebx |
1717 | jnz .error |
1717 | jnz .error |
1718 | 1718 | ||
1719 | mov [pci_access_enabled], ecx |
1719 | mov [pci_access_enabled], ecx |
1720 | ret |
1720 | ret |
1721 | ;-------------------------------------- |
1721 | ;-------------------------------------- |
1722 | .error: |
1722 | .error: |
1723 | or [esp+32], dword -1 |
1723 | or [esp+32], dword -1 |
1724 | ret |
1724 | ret |
1725 | ;----------------------------------------------------------------------------- |
1725 | ;----------------------------------------------------------------------------- |
1726 | align 4 |
1726 | align 4 |
1727 | sys_getsetup: |
1727 | sys_getsetup: |
1728 | ; 1 = roland mpu midi base , base io address |
1728 | ; 1 = roland mpu midi base , base io address |
1729 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1729 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1730 | ; 3 = not used |
1730 | ; 3 = not used |
1731 | ; 4 = not used |
1731 | ; 4 = not used |
1732 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1732 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1733 | ; 6 = not used |
1733 | ; 6 = not used |
1734 | ; 7 = not used |
1734 | ; 7 = not used |
1735 | ; 8 = not used |
1735 | ; 8 = not used |
1736 | ; 9 = get hs timer tic |
1736 | ; 9 = get hs timer tic |
1737 | ; 10 = not used |
1737 | ; 10 = not used |
1738 | ; 11 = get the state "lba read" |
1738 | ; 11 = get the state "lba read" |
1739 | ; 12 = get the state "pci access" |
1739 | ; 12 = get the state "pci access" |
1740 | ;----------------------------------------------------------------------------- |
1740 | ;----------------------------------------------------------------------------- |
1741 | ; F.26.1 - get MPU MIDI base port |
1741 | ; F.26.1 - get MPU MIDI base port |
1742 | dec ebx |
1742 | dec ebx |
1743 | jnz @f |
1743 | jnz @f |
1744 | 1744 | ||
1745 | movzx eax, [midi_base] |
1745 | movzx eax, [midi_base] |
1746 | mov [esp+32], eax |
1746 | mov [esp+32], eax |
1747 | ret |
1747 | ret |
1748 | ;-------------------------------------- |
1748 | ;-------------------------------------- |
1749 | @@: |
1749 | @@: |
1750 | ; F.26.2 - get keyboard layout |
1750 | ; F.26.2 - get keyboard layout |
1751 | dec ebx |
1751 | dec ebx |
1752 | jnz @f |
1752 | jnz @f |
1753 | 1753 | ||
1754 | mov edi, [TASK_BASE] |
1754 | mov edi, [TASK_BASE] |
1755 | mov ebx, [edi+TASKDATA.mem_start] |
1755 | mov ebx, [edi+TASKDATA.mem_start] |
1756 | add ebx, edx |
1756 | add ebx, edx |
1757 | ; 1 = normal layout |
1757 | ; 1 = normal layout |
1758 | dec ecx |
1758 | dec ecx |
1759 | jnz .shift |
1759 | jnz .shift |
1760 | 1760 | ||
1761 | mov eax, keymap |
1761 | mov eax, keymap |
1762 | mov ecx, 128 |
1762 | mov ecx, 128 |
1763 | call memmove |
1763 | call memmove |
1764 | ret |
1764 | ret |
1765 | ;-------------------------------------- |
1765 | ;-------------------------------------- |
1766 | .shift: |
1766 | .shift: |
1767 | ; 2 = layout with pressed Shift |
1767 | ; 2 = layout with pressed Shift |
1768 | dec ecx |
1768 | dec ecx |
1769 | jnz .alt |
1769 | jnz .alt |
1770 | 1770 | ||
1771 | mov eax, keymap_shift |
1771 | mov eax, keymap_shift |
1772 | mov ecx, 128 |
1772 | mov ecx, 128 |
1773 | call memmove |
1773 | call memmove |
1774 | ret |
1774 | ret |
1775 | ;-------------------------------------- |
1775 | ;-------------------------------------- |
1776 | .alt: |
1776 | .alt: |
1777 | ; 3 = layout with pressed Alt |
1777 | ; 3 = layout with pressed Alt |
1778 | dec ecx |
1778 | dec ecx |
1779 | jne .country |
1779 | jne .country |
1780 | 1780 | ||
1781 | mov eax, keymap_alt |
1781 | mov eax, keymap_alt |
1782 | mov ecx, 128 |
1782 | mov ecx, 128 |
1783 | call memmove |
1783 | call memmove |
1784 | ret |
1784 | ret |
1785 | ;-------------------------------------- |
1785 | ;-------------------------------------- |
1786 | .country: |
1786 | .country: |
1787 | ; 9 = country identifier |
1787 | ; 9 = country identifier |
1788 | sub ecx, 6 |
1788 | sub ecx, 6 |
1789 | jnz .error |
1789 | jnz .error |
1790 | 1790 | ||
1791 | movzx eax, word [keyboard] |
1791 | movzx eax, word [keyboard] |
1792 | mov [esp+32], eax |
1792 | mov [esp+32], eax |
1793 | ret |
1793 | ret |
1794 | ;-------------------------------------- |
1794 | ;-------------------------------------- |
1795 | @@: |
1795 | @@: |
1796 | ; F.26.5 - get system language |
1796 | ; F.26.5 - get system language |
1797 | sub ebx, 3 |
1797 | sub ebx, 3 |
1798 | jnz @f |
1798 | jnz @f |
1799 | 1799 | ||
1800 | mov eax, [syslang] |
1800 | mov eax, [syslang] |
1801 | mov [esp+32], eax |
1801 | mov [esp+32], eax |
1802 | ret |
1802 | ret |
1803 | ;-------------------------------------- |
1803 | ;-------------------------------------- |
1804 | @@: |
1804 | @@: |
1805 | ; F.26.9 - get the value of the time counter |
1805 | ; F.26.9 - get the value of the time counter |
1806 | sub ebx, 4 |
1806 | sub ebx, 4 |
1807 | jnz @f |
1807 | jnz @f |
1808 | 1808 | ||
1809 | mov eax, [timer_ticks] |
1809 | mov eax, [timer_ticks] |
1810 | mov [esp+32], eax |
1810 | mov [esp+32], eax |
1811 | ret |
1811 | ret |
1812 | ;-------------------------------------- |
1812 | ;-------------------------------------- |
1813 | @@: |
1813 | @@: |
1814 | ; F.26.11 - Find out whether low-level HD access is enabled |
1814 | ; F.26.11 - Find out whether low-level HD access is enabled |
1815 | sub ebx, 2 |
1815 | sub ebx, 2 |
1816 | jnz @f |
1816 | jnz @f |
1817 | 1817 | ||
1818 | mov eax, [lba_read_enabled] |
1818 | mov eax, [lba_read_enabled] |
1819 | mov [esp+32], eax |
1819 | mov [esp+32], eax |
1820 | ret |
1820 | ret |
1821 | ;-------------------------------------- |
1821 | ;-------------------------------------- |
1822 | @@: |
1822 | @@: |
1823 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1823 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1824 | dec ebx |
1824 | dec ebx |
1825 | jnz .error |
1825 | jnz .error |
1826 | 1826 | ||
1827 | mov eax, [pci_access_enabled] |
1827 | mov eax, [pci_access_enabled] |
1828 | mov [esp+32], eax |
1828 | mov [esp+32], eax |
1829 | ret |
1829 | ret |
1830 | ;-------------------------------------- |
1830 | ;-------------------------------------- |
1831 | .error: |
1831 | .error: |
1832 | or [esp+32], dword -1 |
1832 | or [esp+32], dword -1 |
1833 | ret |
1833 | ret |
1834 | ;----------------------------------------------------------------------------- |
1834 | ;----------------------------------------------------------------------------- |
1835 | get_timer_ticks: |
1835 | get_timer_ticks: |
1836 | mov eax, [timer_ticks] |
1836 | mov eax, [timer_ticks] |
1837 | ret |
1837 | ret |
1838 | ;----------------------------------------------------------------------------- |
1838 | ;----------------------------------------------------------------------------- |
1839 | iglobal |
1839 | iglobal |
1840 | align 4 |
1840 | align 4 |
1841 | mousefn dd msscreen, mswin, msbutton, msset |
1841 | mousefn dd msscreen, mswin, msbutton, msset |
1842 | dd app_load_cursor |
1842 | dd app_load_cursor |
1843 | dd app_set_cursor |
1843 | dd app_set_cursor |
1844 | dd app_delete_cursor |
1844 | dd app_delete_cursor |
1845 | dd msz |
1845 | dd msz |
1846 | endg |
1846 | endg |
1847 | ;----------------------------------------------------------------------------- |
1847 | ;----------------------------------------------------------------------------- |
1848 | readmousepos: |
1848 | readmousepos: |
1849 | 1849 | ||
1850 | ; eax=0 screen relative |
1850 | ; eax=0 screen relative |
1851 | ; eax=1 window relative |
1851 | ; eax=1 window relative |
1852 | ; eax=2 buttons pressed |
1852 | ; eax=2 buttons pressed |
1853 | ; eax=3 set mouse pos ; reserved |
1853 | ; eax=3 set mouse pos ; reserved |
1854 | ; eax=4 load cursor |
1854 | ; eax=4 load cursor |
1855 | ; eax=5 set cursor |
1855 | ; eax=5 set cursor |
1856 | ; eax=6 delete cursor ; reserved |
1856 | ; eax=6 delete cursor ; reserved |
1857 | ; eax=7 get mouse_z |
1857 | ; eax=7 get mouse_z |
1858 | 1858 | ||
1859 | cmp ebx, 7 |
1859 | cmp ebx, 7 |
1860 | ja msset |
1860 | ja msset |
1861 | jmp [mousefn+ebx*4] |
1861 | jmp [mousefn+ebx*4] |
1862 | msscreen: |
1862 | msscreen: |
1863 | mov eax, [MOUSE_X] |
1863 | mov eax, [MOUSE_X] |
1864 | shl eax, 16 |
1864 | shl eax, 16 |
1865 | mov ax, [MOUSE_Y] |
1865 | mov ax, [MOUSE_Y] |
1866 | mov [esp+36-4], eax |
1866 | mov [esp+36-4], eax |
1867 | ret |
1867 | ret |
1868 | mswin: |
1868 | mswin: |
1869 | mov eax, [MOUSE_X] |
1869 | mov eax, [MOUSE_X] |
1870 | shl eax, 16 |
1870 | shl eax, 16 |
1871 | mov ax, [MOUSE_Y] |
1871 | mov ax, [MOUSE_Y] |
1872 | mov esi, [TASK_BASE] |
1872 | mov esi, [TASK_BASE] |
1873 | mov bx, word [esi-twdw+WDATA.box.left] |
1873 | mov bx, word [esi-twdw+WDATA.box.left] |
1874 | shl ebx, 16 |
1874 | shl ebx, 16 |
1875 | mov bx, word [esi-twdw+WDATA.box.top] |
1875 | mov bx, word [esi-twdw+WDATA.box.top] |
1876 | sub eax, ebx |
1876 | sub eax, ebx |
1877 | 1877 | ||
1878 | mov edi, [CURRENT_TASK] |
1878 | mov edi, [CURRENT_TASK] |
1879 | shl edi, 8 |
1879 | shl edi, 8 |
1880 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1880 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1881 | rol eax, 16 |
1881 | rol eax, 16 |
1882 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1882 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1883 | rol eax, 16 |
1883 | rol eax, 16 |
1884 | mov [esp+36-4], eax |
1884 | mov [esp+36-4], eax |
1885 | ret |
1885 | ret |
1886 | msbutton: |
1886 | msbutton: |
1887 | movzx eax, byte [BTN_DOWN] |
1887 | movzx eax, byte [BTN_DOWN] |
1888 | mov [esp+36-4], eax |
1888 | mov [esp+36-4], eax |
1889 | ret |
1889 | ret |
1890 | msz: |
1890 | msz: |
1891 | mov edi, [TASK_COUNT] |
1891 | mov edi, [TASK_COUNT] |
1892 | movzx edi, word [WIN_POS + edi*2] |
1892 | movzx edi, word [WIN_POS + edi*2] |
1893 | cmp edi, [CURRENT_TASK] |
1893 | cmp edi, [CURRENT_TASK] |
1894 | jne @f |
1894 | jne @f |
1895 | mov ax, [MOUSE_SCROLL_H] |
1895 | mov ax, [MOUSE_SCROLL_H] |
1896 | shl eax, 16 |
1896 | shl eax, 16 |
1897 | mov ax, [MOUSE_SCROLL_V] |
1897 | mov ax, [MOUSE_SCROLL_V] |
1898 | mov [esp+36-4], eax |
1898 | mov [esp+36-4], eax |
1899 | and [MOUSE_SCROLL_H], word 0 |
1899 | and [MOUSE_SCROLL_H], word 0 |
1900 | and [MOUSE_SCROLL_V], word 0 |
1900 | and [MOUSE_SCROLL_V], word 0 |
1901 | ret |
1901 | ret |
1902 | @@: |
1902 | @@: |
1903 | and [esp+36-4], dword 0 |
1903 | and [esp+36-4], dword 0 |
1904 | ; ret |
1904 | ; ret |
1905 | msset: |
1905 | msset: |
1906 | ret |
1906 | ret |
1907 | 1907 | ||
1908 | app_load_cursor: |
1908 | app_load_cursor: |
1909 | cmp ecx, OS_BASE |
1909 | cmp ecx, OS_BASE |
1910 | jae msset |
1910 | jae msset |
1911 | stdcall load_cursor, ecx, edx |
1911 | stdcall load_cursor, ecx, edx |
1912 | mov [esp+36-4], eax |
1912 | mov [esp+36-4], eax |
1913 | ret |
1913 | ret |
1914 | 1914 | ||
1915 | app_set_cursor: |
1915 | app_set_cursor: |
1916 | stdcall set_cursor, ecx |
1916 | stdcall set_cursor, ecx |
1917 | mov [esp+36-4], eax |
1917 | mov [esp+36-4], eax |
1918 | ret |
1918 | ret |
1919 | 1919 | ||
1920 | app_delete_cursor: |
1920 | app_delete_cursor: |
1921 | stdcall delete_cursor, ecx |
1921 | stdcall delete_cursor, ecx |
1922 | mov [esp+36-4], eax |
1922 | mov [esp+36-4], eax |
1923 | ret |
1923 | ret |
1924 | 1924 | ||
1925 | is_input: |
1925 | is_input: |
1926 | 1926 | ||
1927 | push edx |
1927 | push edx |
1928 | mov dx, word [midisp] |
1928 | mov dx, word [midisp] |
1929 | in al, dx |
1929 | in al, dx |
1930 | and al, 0x80 |
1930 | and al, 0x80 |
1931 | pop edx |
1931 | pop edx |
1932 | ret |
1932 | ret |
1933 | 1933 | ||
1934 | is_output: |
1934 | is_output: |
1935 | 1935 | ||
1936 | push edx |
1936 | push edx |
1937 | mov dx, word [midisp] |
1937 | mov dx, word [midisp] |
1938 | in al, dx |
1938 | in al, dx |
1939 | and al, 0x40 |
1939 | and al, 0x40 |
1940 | pop edx |
1940 | pop edx |
1941 | ret |
1941 | ret |
1942 | 1942 | ||
1943 | 1943 | ||
1944 | get_mpu_in: |
1944 | get_mpu_in: |
1945 | 1945 | ||
1946 | push edx |
1946 | push edx |
1947 | mov dx, word [mididp] |
1947 | mov dx, word [mididp] |
1948 | in al, dx |
1948 | in al, dx |
1949 | pop edx |
1949 | pop edx |
1950 | ret |
1950 | ret |
1951 | 1951 | ||
1952 | 1952 | ||
1953 | put_mpu_out: |
1953 | put_mpu_out: |
1954 | 1954 | ||
1955 | push edx |
1955 | push edx |
1956 | mov dx, word [mididp] |
1956 | mov dx, word [mididp] |
1957 | out dx, al |
1957 | out dx, al |
1958 | pop edx |
1958 | pop edx |
1959 | ret |
1959 | ret |
1960 | 1960 | ||
1961 | 1961 | ||
1962 | 1962 | ||
1963 | align 4 |
1963 | align 4 |
1964 | 1964 | ||
1965 | sys_midi: |
1965 | sys_midi: |
1966 | cmp [mididp], 0 |
1966 | cmp [mididp], 0 |
1967 | jnz sm0 |
1967 | jnz sm0 |
1968 | mov [esp+36], dword 1 |
1968 | mov [esp+36], dword 1 |
1969 | ret |
1969 | ret |
1970 | sm0: |
1970 | sm0: |
1971 | and [esp+36], dword 0 |
1971 | and [esp+36], dword 0 |
1972 | dec ebx |
1972 | dec ebx |
1973 | jnz smn1 |
1973 | jnz smn1 |
1974 | ; call setuart |
1974 | ; call setuart |
1975 | su1: |
1975 | su1: |
1976 | call is_output |
1976 | call is_output |
1977 | test al, al |
1977 | test al, al |
1978 | jnz su1 |
1978 | jnz su1 |
1979 | mov dx, word [midisp] |
1979 | mov dx, word [midisp] |
1980 | mov al, 0xff |
1980 | mov al, 0xff |
1981 | out dx, al |
1981 | out dx, al |
1982 | su2: |
1982 | su2: |
1983 | mov dx, word [midisp] |
1983 | mov dx, word [midisp] |
1984 | mov al, 0xff |
1984 | mov al, 0xff |
1985 | out dx, al |
1985 | out dx, al |
1986 | call is_input |
1986 | call is_input |
1987 | test al, al |
1987 | test al, al |
1988 | jnz su2 |
1988 | jnz su2 |
1989 | call get_mpu_in |
1989 | call get_mpu_in |
1990 | cmp al, 0xfe |
1990 | cmp al, 0xfe |
1991 | jnz su2 |
1991 | jnz su2 |
1992 | su3: |
1992 | su3: |
1993 | call is_output |
1993 | call is_output |
1994 | test al, al |
1994 | test al, al |
1995 | jnz su3 |
1995 | jnz su3 |
1996 | mov dx, word [midisp] |
1996 | mov dx, word [midisp] |
1997 | mov al, 0x3f |
1997 | mov al, 0x3f |
1998 | out dx, al |
1998 | out dx, al |
1999 | ret |
1999 | ret |
2000 | smn1: |
2000 | smn1: |
2001 | dec ebx |
2001 | dec ebx |
2002 | jnz smn2 |
2002 | jnz smn2 |
2003 | sm10: |
2003 | sm10: |
2004 | call get_mpu_in |
2004 | call get_mpu_in |
2005 | call is_output |
2005 | call is_output |
2006 | test al, al |
2006 | test al, al |
2007 | jnz sm10 |
2007 | jnz sm10 |
2008 | mov al, bl |
2008 | mov al, bl |
2009 | call put_mpu_out |
2009 | call put_mpu_out |
2010 | smn2: |
2010 | smn2: |
2011 | ret |
2011 | ret |
2012 | 2012 | ||
2013 | detect_devices: |
2013 | detect_devices: |
2014 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2014 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2015 | ;include 'detect/commouse.inc' |
2015 | ;include 'detect/commouse.inc' |
2016 | ;include 'detect/ps2mouse.inc' |
2016 | ;include 'detect/ps2mouse.inc' |
2017 | ;include 'detect/dev_fd.inc' |
2017 | ;include 'detect/dev_fd.inc' |
2018 | ;include 'detect/dev_hdcd.inc' |
2018 | ;include 'detect/dev_hdcd.inc' |
2019 | ;include 'detect/sear_par.inc' |
2019 | ;include 'detect/sear_par.inc' |
2020 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2020 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2021 | ret |
2021 | ret |
2022 | 2022 | ||
2023 | sys_end: |
2023 | sys_end: |
2024 | ;-------------------------------------- |
2024 | ;-------------------------------------- |
2025 | cmp [_display.select_cursor], 0 |
2025 | cmp [_display.select_cursor], 0 |
2026 | je @f |
2026 | je @f |
2027 | ; restore default cursor before killing |
2027 | ; restore default cursor before killing |
2028 | pusha |
2028 | pusha |
2029 | mov ecx, [current_slot] |
2029 | mov ecx, [current_slot] |
2030 | call restore_default_cursor_before_killing |
2030 | call restore_default_cursor_before_killing |
2031 | popa |
2031 | popa |
2032 | @@: |
2032 | @@: |
2033 | ;-------------------------------------- |
2033 | ;-------------------------------------- |
2034 | ; kill all sockets this process owns |
2034 | ; kill all sockets this process owns |
2035 | pusha |
2035 | pusha |
2036 | mov edx, [TASK_BASE] |
2036 | mov edx, [TASK_BASE] |
2037 | mov edx, [edx+TASKDATA.pid] |
2037 | mov edx, [edx+TASKDATA.pid] |
2038 | call SOCKET_process_end |
2038 | call SOCKET_process_end |
2039 | popa |
2039 | popa |
2040 | ;-------------------------------------- |
2040 | ;-------------------------------------- |
2041 | mov ecx, [current_slot] |
2041 | mov ecx, [current_slot] |
2042 | mov eax, [ecx+APPDATA.tls_base] |
2042 | mov eax, [ecx+APPDATA.tls_base] |
2043 | test eax, eax |
2043 | test eax, eax |
2044 | jz @F |
2044 | jz @F |
2045 | 2045 | ||
2046 | stdcall user_free, eax |
2046 | stdcall user_free, eax |
2047 | @@: |
2047 | @@: |
2048 | 2048 | ||
2049 | mov eax, [TASK_BASE] |
2049 | mov eax, [TASK_BASE] |
2050 | mov [eax+TASKDATA.state], 3; terminate this program |
2050 | mov [eax+TASKDATA.state], 3; terminate this program |
2051 | call wakeup_osloop |
2051 | call wakeup_osloop |
2052 | 2052 | ||
2053 | .waitterm: ; wait here for termination |
2053 | .waitterm: ; wait here for termination |
2054 | call change_task |
2054 | call change_task |
2055 | jmp .waitterm |
2055 | jmp .waitterm |
2056 | ;------------------------------------------------------------------------------ |
2056 | ;------------------------------------------------------------------------------ |
2057 | align 4 |
2057 | align 4 |
2058 | restore_default_cursor_before_killing: |
2058 | restore_default_cursor_before_killing: |
2059 | pushfd |
2059 | pushfd |
2060 | cli |
2060 | cli |
2061 | mov eax, [def_cursor] |
2061 | mov eax, [def_cursor] |
2062 | mov [ecx+APPDATA.cursor], eax |
2062 | mov [ecx+APPDATA.cursor], eax |
2063 | 2063 | ||
2064 | movzx eax, word [MOUSE_Y] |
2064 | movzx eax, word [MOUSE_Y] |
2065 | movzx ebx, word [MOUSE_X] |
2065 | movzx ebx, word [MOUSE_X] |
2066 | ; mov ecx, [Screen_Max_X] |
2066 | ; mov ecx, [Screen_Max_X] |
2067 | ; inc ecx |
2067 | ; inc ecx |
2068 | ; mul ecx |
2068 | ; mul ecx |
2069 | mov eax, [d_width_calc_area + eax*4] |
2069 | mov eax, [d_width_calc_area + eax*4] |
2070 | 2070 | ||
2071 | add eax, [_WinMapAddress] |
2071 | add eax, [_WinMapAddress] |
2072 | movzx edx, byte [ebx+eax] |
2072 | movzx edx, byte [ebx+eax] |
2073 | shl edx, 8 |
2073 | shl edx, 8 |
2074 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2074 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2075 | 2075 | ||
2076 | cmp esi, [current_cursor] |
2076 | cmp esi, [current_cursor] |
2077 | je @f |
2077 | je @f |
2078 | 2078 | ||
2079 | push esi |
2079 | push esi |
2080 | call [_display.select_cursor] |
2080 | call [_display.select_cursor] |
2081 | mov [current_cursor], esi |
2081 | mov [current_cursor], esi |
2082 | @@: |
2082 | @@: |
2083 | mov [redrawmouse_unconditional], 1 |
2083 | mov [redrawmouse_unconditional], 1 |
2084 | call wakeup_osloop |
2084 | call wakeup_osloop |
2085 | popfd |
2085 | popfd |
2086 | ret |
2086 | ret |
2087 | ;------------------------------------------------------------------------------ |
2087 | ;------------------------------------------------------------------------------ |
2088 | iglobal |
2088 | iglobal |
2089 | align 4 |
2089 | align 4 |
2090 | sys_system_table: |
2090 | sys_system_table: |
2091 | dd sysfn_deactivate ; 1 = deactivate window |
2091 | dd sysfn_deactivate ; 1 = deactivate window |
2092 | dd sysfn_terminate ; 2 = terminate thread |
2092 | dd sysfn_terminate ; 2 = terminate thread |
2093 | dd sysfn_activate ; 3 = activate window |
2093 | dd sysfn_activate ; 3 = activate window |
2094 | dd sysfn_getidletime ; 4 = get idle time |
2094 | dd sysfn_getidletime ; 4 = get idle time |
2095 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2095 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2096 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2096 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2097 | dd sysfn_getactive ; 7 = get active window |
2097 | dd sysfn_getactive ; 7 = get active window |
2098 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2098 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2099 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2099 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2100 | dd sysfn_minimize ; 10 = minimize window |
2100 | dd sysfn_minimize ; 10 = minimize window |
2101 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2101 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2102 | dd sysfn_lastkey ; 12 = get last pressed key |
2102 | dd sysfn_lastkey ; 12 = get last pressed key |
2103 | dd sysfn_getversion ; 13 = get kernel version |
2103 | dd sysfn_getversion ; 13 = get kernel version |
2104 | dd sysfn_waitretrace ; 14 = wait retrace |
2104 | dd sysfn_waitretrace ; 14 = wait retrace |
2105 | dd sysfn_centermouse ; 15 = center mouse cursor |
2105 | dd sysfn_centermouse ; 15 = center mouse cursor |
2106 | dd sysfn_getfreemem ; 16 = get free memory size |
2106 | dd sysfn_getfreemem ; 16 = get free memory size |
2107 | dd sysfn_getallmem ; 17 = get total memory size |
2107 | dd sysfn_getallmem ; 17 = get total memory size |
2108 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2108 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2109 | ; instead of slot |
2109 | ; instead of slot |
2110 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2110 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2111 | dd sysfn_meminfo ; 20 = get extended memory info |
2111 | dd sysfn_meminfo ; 20 = get extended memory info |
2112 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2112 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2113 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2113 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2114 | dd sysfn_min_windows ; 23 = minimize all windows |
2114 | dd sysfn_min_windows ; 23 = minimize all windows |
2115 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2115 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2116 | sysfn_num = ($ - sys_system_table)/4 |
2116 | sysfn_num = ($ - sys_system_table)/4 |
2117 | endg |
2117 | endg |
2118 | ;------------------------------------------------------------------------------ |
2118 | ;------------------------------------------------------------------------------ |
2119 | sys_system: |
2119 | sys_system: |
2120 | dec ebx |
2120 | dec ebx |
2121 | cmp ebx, sysfn_num |
2121 | cmp ebx, sysfn_num |
2122 | jae @f |
2122 | jae @f |
2123 | jmp dword [sys_system_table + ebx*4] |
2123 | jmp dword [sys_system_table + ebx*4] |
2124 | @@: |
2124 | @@: |
2125 | ret |
2125 | ret |
2126 | ;------------------------------------------------------------------------------ |
2126 | ;------------------------------------------------------------------------------ |
2127 | sysfn_shutdown: ; 18.9 = system shutdown |
2127 | sysfn_shutdown: ; 18.9 = system shutdown |
2128 | cmp ecx, 1 |
2128 | cmp ecx, 1 |
2129 | jl exit_for_anyone |
2129 | jl exit_for_anyone |
2130 | cmp ecx, 4 |
2130 | cmp ecx, 4 |
2131 | jg exit_for_anyone |
2131 | jg exit_for_anyone |
2132 | mov [BOOT_VARS+0x9030], cl |
2132 | mov [BOOT_VARS+0x9030], cl |
2133 | 2133 | ||
2134 | mov eax, [TASK_COUNT] |
2134 | mov eax, [TASK_COUNT] |
2135 | mov [SYS_SHUTDOWN], al |
2135 | mov [SYS_SHUTDOWN], al |
2136 | mov [shutdown_processes], eax |
2136 | mov [shutdown_processes], eax |
2137 | call wakeup_osloop |
2137 | call wakeup_osloop |
2138 | and dword [esp+32], 0 |
2138 | and dword [esp+32], 0 |
2139 | exit_for_anyone: |
2139 | exit_for_anyone: |
2140 | ret |
2140 | ret |
2141 | uglobal |
2141 | uglobal |
2142 | shutdown_processes: |
2142 | shutdown_processes: |
2143 | dd 0x0 |
2143 | dd 0x0 |
2144 | endg |
2144 | endg |
2145 | ;------------------------------------------------------------------------------ |
2145 | ;------------------------------------------------------------------------------ |
2146 | sysfn_terminate: ; 18.2 = TERMINATE |
2146 | sysfn_terminate: ; 18.2 = TERMINATE |
2147 | push ecx |
2147 | push ecx |
2148 | cmp ecx, 2 |
2148 | cmp ecx, 2 |
2149 | jb noprocessterminate |
2149 | jb noprocessterminate |
2150 | mov edx, [TASK_COUNT] |
2150 | mov edx, [TASK_COUNT] |
2151 | cmp ecx, edx |
2151 | cmp ecx, edx |
2152 | ja noprocessterminate |
2152 | ja noprocessterminate |
2153 | mov eax, [TASK_COUNT] |
2153 | mov eax, [TASK_COUNT] |
2154 | shl ecx, 5 |
2154 | shl ecx, 5 |
2155 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2155 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2156 | add ecx, CURRENT_TASK+TASKDATA.state |
2156 | add ecx, CURRENT_TASK+TASKDATA.state |
2157 | cmp byte [ecx], 9 |
2157 | cmp byte [ecx], 9 |
2158 | jz noprocessterminate |
2158 | jz noprocessterminate |
2159 | push ecx edx |
2159 | push ecx edx |
2160 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2160 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2161 | call request_terminate |
2161 | call request_terminate |
2162 | pop edx ecx |
2162 | pop edx ecx |
2163 | test eax, eax |
2163 | test eax, eax |
2164 | jz noprocessterminate |
2164 | jz noprocessterminate |
2165 | ;-------------------------------------- |
2165 | ;-------------------------------------- |
2166 | ; terminate all network sockets it used |
2166 | ; terminate all network sockets it used |
2167 | pusha |
2167 | pusha |
2168 | mov eax, edx |
2168 | mov eax, edx |
2169 | call SOCKET_process_end |
2169 | call SOCKET_process_end |
2170 | popa |
2170 | popa |
2171 | ;-------------------------------------- |
2171 | ;-------------------------------------- |
2172 | cmp [_display.select_cursor], 0 |
2172 | cmp [_display.select_cursor], 0 |
2173 | je .restore_end |
2173 | je .restore_end |
2174 | ; restore default cursor before killing |
2174 | ; restore default cursor before killing |
2175 | pusha |
2175 | pusha |
2176 | mov ecx, [esp+32] |
2176 | mov ecx, [esp+32] |
2177 | shl ecx, 8 |
2177 | shl ecx, 8 |
2178 | add ecx, SLOT_BASE |
2178 | add ecx, SLOT_BASE |
2179 | mov eax, [def_cursor] |
2179 | mov eax, [def_cursor] |
2180 | cmp [ecx+APPDATA.cursor], eax |
2180 | cmp [ecx+APPDATA.cursor], eax |
2181 | je @f |
2181 | je @f |
2182 | call restore_default_cursor_before_killing |
2182 | call restore_default_cursor_before_killing |
2183 | @@: |
2183 | @@: |
2184 | popa |
2184 | popa |
2185 | .restore_end: |
2185 | .restore_end: |
2186 | ;-------------------------------------- |
2186 | ;-------------------------------------- |
2187 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2187 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2188 | mov [ecx], byte 3; clear possible i40's |
2188 | mov [ecx], byte 3; clear possible i40's |
2189 | call wakeup_osloop |
2189 | call wakeup_osloop |
2190 | ;call MEM_Heap_UnLock |
2190 | ;call MEM_Heap_UnLock |
2191 | 2191 | ||
2192 | cmp edx, [application_table_owner]; clear app table stat |
2192 | cmp edx, [application_table_owner]; clear app table stat |
2193 | jne noatsc |
2193 | jne noatsc |
2194 | call unlock_application_table |
2194 | call unlock_application_table |
2195 | noatsc: |
2195 | noatsc: |
2196 | noprocessterminate: |
2196 | noprocessterminate: |
2197 | add esp, 4 |
2197 | add esp, 4 |
2198 | ret |
2198 | ret |
2199 | ;------------------------------------------------------------------------------ |
2199 | ;------------------------------------------------------------------------------ |
2200 | sysfn_terminate2: |
2200 | sysfn_terminate2: |
2201 | ;lock application_table_status mutex |
2201 | ;lock application_table_status mutex |
2202 | .table_status: |
2202 | .table_status: |
2203 | call lock_application_table |
2203 | call lock_application_table |
2204 | mov eax, ecx |
2204 | mov eax, ecx |
2205 | call pid_to_slot |
2205 | call pid_to_slot |
2206 | test eax, eax |
2206 | test eax, eax |
2207 | jz .not_found |
2207 | jz .not_found |
2208 | mov ecx, eax |
2208 | mov ecx, eax |
2209 | cli |
2209 | cli |
2210 | call sysfn_terminate |
2210 | call sysfn_terminate |
2211 | call unlock_application_table |
2211 | call unlock_application_table |
2212 | sti |
2212 | sti |
2213 | and dword [esp+32], 0 |
2213 | and dword [esp+32], 0 |
2214 | ret |
2214 | ret |
2215 | .not_found: |
2215 | .not_found: |
2216 | call unlock_application_table |
2216 | call unlock_application_table |
2217 | or dword [esp+32], -1 |
2217 | or dword [esp+32], -1 |
2218 | ret |
2218 | ret |
2219 | ;------------------------------------------------------------------------------ |
2219 | ;------------------------------------------------------------------------------ |
2220 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2220 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2221 | cmp ecx, 2 |
2221 | cmp ecx, 2 |
2222 | jb .nowindowdeactivate |
2222 | jb .nowindowdeactivate |
2223 | cmp ecx, [TASK_COUNT] |
2223 | cmp ecx, [TASK_COUNT] |
2224 | ja .nowindowdeactivate |
2224 | ja .nowindowdeactivate |
2225 | 2225 | ||
2226 | movzx esi, word [WIN_STACK + ecx*2] |
2226 | movzx esi, word [WIN_STACK + ecx*2] |
2227 | cmp esi, 1 |
2227 | cmp esi, 1 |
2228 | je .nowindowdeactivate ; already deactive |
2228 | je .nowindowdeactivate ; already deactive |
2229 | 2229 | ||
2230 | mov edi, ecx |
2230 | mov edi, ecx |
2231 | shl edi, 5 |
2231 | shl edi, 5 |
2232 | add edi, window_data |
2232 | add edi, window_data |
2233 | movzx esi, word [WIN_STACK + ecx * 2] |
2233 | movzx esi, word [WIN_STACK + ecx * 2] |
2234 | lea esi, [WIN_POS + esi * 2] |
2234 | lea esi, [WIN_POS + esi * 2] |
2235 | call window._.window_deactivate |
2235 | call window._.window_deactivate |
2236 | 2236 | ||
2237 | call syscall_display_settings._.calculate_whole_screen |
2237 | call syscall_display_settings._.calculate_whole_screen |
2238 | call syscall_display_settings._.redraw_whole_screen |
2238 | call syscall_display_settings._.redraw_whole_screen |
2239 | .nowindowdeactivate: |
2239 | .nowindowdeactivate: |
2240 | ret |
2240 | ret |
2241 | ;------------------------------------------------------------------------------ |
2241 | ;------------------------------------------------------------------------------ |
2242 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2242 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2243 | cmp ecx, 2 |
2243 | cmp ecx, 2 |
2244 | jb .nowindowactivate |
2244 | jb .nowindowactivate |
2245 | cmp ecx, [TASK_COUNT] |
2245 | cmp ecx, [TASK_COUNT] |
2246 | ja .nowindowactivate |
2246 | ja .nowindowactivate |
2247 | ;------------------------------------- |
2247 | ;------------------------------------- |
2248 | @@: |
2248 | @@: |
2249 | ; If the window is captured and moved by the user, |
2249 | ; If the window is captured and moved by the user, |
2250 | ; then you can't change the position in window stack!!! |
2250 | ; then you can't change the position in window stack!!! |
2251 | mov al, [mouse.active_sys_window.action] |
2251 | mov al, [mouse.active_sys_window.action] |
2252 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2252 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2253 | test al, al |
2253 | test al, al |
2254 | jz @f |
2254 | jz @f |
2255 | call change_task |
2255 | call change_task |
2256 | jmp @b |
2256 | jmp @b |
2257 | @@: |
2257 | @@: |
2258 | ;------------------------------------- |
2258 | ;------------------------------------- |
2259 | mov [window_minimize], 2; restore window if minimized |
2259 | mov [window_minimize], 2; restore window if minimized |
2260 | call wakeup_osloop |
2260 | call wakeup_osloop |
2261 | 2261 | ||
2262 | movzx esi, word [WIN_STACK + ecx*2] |
2262 | movzx esi, word [WIN_STACK + ecx*2] |
2263 | cmp esi, [TASK_COUNT] |
2263 | cmp esi, [TASK_COUNT] |
2264 | je .nowindowactivate; already active |
2264 | je .nowindowactivate; already active |
2265 | 2265 | ||
2266 | mov edi, ecx |
2266 | mov edi, ecx |
2267 | shl edi, 5 |
2267 | shl edi, 5 |
2268 | add edi, window_data |
2268 | add edi, window_data |
2269 | movzx esi, word [WIN_STACK + ecx * 2] |
2269 | movzx esi, word [WIN_STACK + ecx * 2] |
2270 | lea esi, [WIN_POS + esi * 2] |
2270 | lea esi, [WIN_POS + esi * 2] |
2271 | call waredraw |
2271 | call waredraw |
2272 | .nowindowactivate: |
2272 | .nowindowactivate: |
2273 | ret |
2273 | ret |
2274 | ;------------------------------------------------------------------------------ |
2274 | ;------------------------------------------------------------------------------ |
2275 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2275 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2276 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2276 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2277 | mov [esp+32], eax |
2277 | mov [esp+32], eax |
2278 | ret |
2278 | ret |
2279 | ;------------------------------------------------------------------------------ |
2279 | ;------------------------------------------------------------------------------ |
2280 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2280 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2281 | mov eax, dword [cpu_freq] |
2281 | mov eax, dword [cpu_freq] |
2282 | mov [esp+32], eax |
2282 | mov [esp+32], eax |
2283 | ret |
2283 | ret |
2284 | ;------------------------------------------------------------------------------ |
2284 | ;------------------------------------------------------------------------------ |
2285 | get_cpu_freq: |
2285 | get_cpu_freq: |
2286 | mov eax, dword [cpu_freq] |
2286 | mov eax, dword [cpu_freq] |
2287 | mov edx, dword [cpu_freq+4] |
2287 | mov edx, dword [cpu_freq+4] |
2288 | ret |
2288 | ret |
2289 | ; SAVE ramdisk to /hd/1/menuet.img |
2289 | ; SAVE ramdisk to /hd/1/menuet.img |
2290 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2290 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2291 | include 'blkdev/rdsave.inc' |
2291 | include 'blkdev/rdsave.inc' |
2292 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2292 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2293 | ;------------------------------------------------------------------------------ |
2293 | ;------------------------------------------------------------------------------ |
2294 | align 4 |
2294 | align 4 |
2295 | sysfn_getactive: ; 18.7 = get active window |
2295 | sysfn_getactive: ; 18.7 = get active window |
2296 | mov eax, [TASK_COUNT] |
2296 | mov eax, [TASK_COUNT] |
2297 | movzx eax, word [WIN_POS + eax*2] |
2297 | movzx eax, word [WIN_POS + eax*2] |
2298 | mov [esp+32], eax |
2298 | mov [esp+32], eax |
2299 | ret |
2299 | ret |
2300 | ;------------------------------------------------------------------------------ |
2300 | ;------------------------------------------------------------------------------ |
2301 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2301 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2302 | ; cmp ecx,1 |
2302 | ; cmp ecx,1 |
2303 | dec ecx |
2303 | dec ecx |
2304 | jnz nogetsoundflag |
2304 | jnz nogetsoundflag |
2305 | movzx eax, byte [sound_flag]; get sound_flag |
2305 | movzx eax, byte [sound_flag]; get sound_flag |
2306 | mov [esp+32], eax |
2306 | mov [esp+32], eax |
2307 | ret |
2307 | ret |
2308 | nogetsoundflag: |
2308 | nogetsoundflag: |
2309 | ; cmp ecx,2 |
2309 | ; cmp ecx,2 |
2310 | dec ecx |
2310 | dec ecx |
2311 | jnz nosoundflag |
2311 | jnz nosoundflag |
2312 | xor byte [sound_flag], 1 |
2312 | xor byte [sound_flag], 1 |
2313 | nosoundflag: |
2313 | nosoundflag: |
2314 | ret |
2314 | ret |
2315 | ;------------------------------------------------------------------------------ |
2315 | ;------------------------------------------------------------------------------ |
2316 | sysfn_minimize: ; 18.10 = minimize window |
2316 | sysfn_minimize: ; 18.10 = minimize window |
2317 | mov [window_minimize], 1 |
2317 | mov [window_minimize], 1 |
2318 | call wakeup_osloop |
2318 | call wakeup_osloop |
2319 | ret |
2319 | ret |
2320 | ;------------------------------------------------------------------------------ |
2320 | ;------------------------------------------------------------------------------ |
2321 | align 4 |
2321 | align 4 |
2322 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2322 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2323 | dec ecx |
2323 | dec ecx |
2324 | jnz .exit |
2324 | jnz .exit |
2325 | .small_table: |
2325 | .small_table: |
2326 | mov edi, edx |
2326 | mov edi, edx |
2327 | mov esi, DRIVE_DATA |
2327 | mov esi, DRIVE_DATA |
2328 | mov ecx, DRIVE_DATA_SIZE ;10 |
2328 | mov ecx, DRIVE_DATA_SIZE ;10 |
2329 | cld |
2329 | cld |
2330 | rep movsb |
2330 | rep movsb |
2331 | .exit: |
2331 | .exit: |
2332 | ret |
2332 | ret |
2333 | ;------------------------------------------------------------------------------ |
2333 | ;------------------------------------------------------------------------------ |
2334 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2334 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2335 | and dword [esp+32], 0 |
2335 | and dword [esp+32], 0 |
2336 | ret |
2336 | ret |
2337 | ;------------------------------------------------------------------------------ |
2337 | ;------------------------------------------------------------------------------ |
2338 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2338 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2339 | mov edi, ecx |
2339 | mov edi, ecx |
2340 | mov esi, version_inf |
2340 | mov esi, version_inf |
2341 | mov ecx, version_end-version_inf |
2341 | mov ecx, version_end-version_inf |
2342 | rep movsb |
2342 | rep movsb |
2343 | ret |
2343 | ret |
2344 | ;------------------------------------------------------------------------------ |
2344 | ;------------------------------------------------------------------------------ |
2345 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2345 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2346 | ;wait retrace functions |
2346 | ;wait retrace functions |
2347 | sys_wait_retrace: |
2347 | sys_wait_retrace: |
2348 | mov edx, 0x3da |
2348 | mov edx, 0x3da |
2349 | WaitRetrace_loop: |
2349 | WaitRetrace_loop: |
2350 | in al, dx |
2350 | in al, dx |
2351 | test al, 1000b |
2351 | test al, 1000b |
2352 | jz WaitRetrace_loop |
2352 | jz WaitRetrace_loop |
2353 | and [esp+32], dword 0 |
2353 | and [esp+32], dword 0 |
2354 | ret |
2354 | ret |
2355 | ;------------------------------------------------------------------------------ |
2355 | ;------------------------------------------------------------------------------ |
2356 | align 4 |
2356 | align 4 |
2357 | sysfn_centermouse: ; 18.15 = mouse centered |
2357 | sysfn_centermouse: ; 18.15 = mouse centered |
2358 | ; removed here by |
2358 | ; removed here by |
2359 | ; call mouse_centered |
2359 | ; call mouse_centered |
2360 | ;* mouse centered - start code- Mario79 |
2360 | ;* mouse centered - start code- Mario79 |
2361 | ;mouse_centered: |
2361 | ;mouse_centered: |
2362 | ; push eax |
2362 | ; push eax |
2363 | mov eax, [Screen_Max_X] |
2363 | mov eax, [Screen_Max_X] |
2364 | shr eax, 1 |
2364 | shr eax, 1 |
2365 | mov [MOUSE_X], ax |
2365 | mov [MOUSE_X], ax |
2366 | mov eax, [Screen_Max_Y] |
2366 | mov eax, [Screen_Max_Y] |
2367 | shr eax, 1 |
2367 | shr eax, 1 |
2368 | mov [MOUSE_Y], ax |
2368 | mov [MOUSE_Y], ax |
2369 | call wakeup_osloop |
2369 | call wakeup_osloop |
2370 | ; ret |
2370 | ; ret |
2371 | ;* mouse centered - end code- Mario79 |
2371 | ;* mouse centered - end code- Mario79 |
2372 | xor eax, eax |
2372 | xor eax, eax |
2373 | and [esp+32], eax |
2373 | and [esp+32], eax |
2374 | ; pop eax |
2374 | ; pop eax |
2375 | ret |
2375 | ret |
2376 | ;------------------------------------------------------------------------------ |
2376 | ;------------------------------------------------------------------------------ |
2377 | align 4 |
2377 | align 4 |
2378 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2378 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2379 | test ecx, ecx; get mouse speed factor |
2379 | test ecx, ecx; get mouse speed factor |
2380 | jnz .set_mouse_acceleration |
2380 | jnz .set_mouse_acceleration |
2381 | xor eax, eax |
2381 | xor eax, eax |
2382 | mov ax, [mouse_speed_factor] |
2382 | mov ax, [mouse_speed_factor] |
2383 | mov [esp+32], eax |
2383 | mov [esp+32], eax |
2384 | ret |
2384 | ret |
2385 | .set_mouse_acceleration: |
2385 | .set_mouse_acceleration: |
2386 | ; cmp ecx,1 ; set mouse speed factor |
2386 | ; cmp ecx,1 ; set mouse speed factor |
2387 | dec ecx |
2387 | dec ecx |
2388 | jnz .get_mouse_delay |
2388 | jnz .get_mouse_delay |
2389 | mov [mouse_speed_factor], dx |
2389 | mov [mouse_speed_factor], dx |
2390 | ret |
2390 | ret |
2391 | .get_mouse_delay: |
2391 | .get_mouse_delay: |
2392 | ; cmp ecx,2 ; get mouse delay |
2392 | ; cmp ecx,2 ; get mouse delay |
2393 | dec ecx |
2393 | dec ecx |
2394 | jnz .set_mouse_delay |
2394 | jnz .set_mouse_delay |
2395 | mov eax, [mouse_delay] |
2395 | mov eax, [mouse_delay] |
2396 | mov [esp+32], eax |
2396 | mov [esp+32], eax |
2397 | ret |
2397 | ret |
2398 | .set_mouse_delay: |
2398 | .set_mouse_delay: |
2399 | ; cmp ecx,3 ; set mouse delay |
2399 | ; cmp ecx,3 ; set mouse delay |
2400 | dec ecx |
2400 | dec ecx |
2401 | jnz .set_pointer_position |
2401 | jnz .set_pointer_position |
2402 | mov [mouse_delay], edx |
2402 | mov [mouse_delay], edx |
2403 | ret |
2403 | ret |
2404 | .set_pointer_position: |
2404 | .set_pointer_position: |
2405 | ; cmp ecx,4 ; set mouse pointer position |
2405 | ; cmp ecx,4 ; set mouse pointer position |
2406 | dec ecx |
2406 | dec ecx |
2407 | jnz .set_mouse_button |
2407 | jnz .set_mouse_button |
2408 | cmp dx, word[Screen_Max_Y] |
2408 | cmp dx, word[Screen_Max_Y] |
2409 | ja .end |
2409 | ja .end |
2410 | rol edx, 16 |
2410 | rol edx, 16 |
2411 | cmp dx, word[Screen_Max_X] |
2411 | cmp dx, word[Screen_Max_X] |
2412 | ja .end |
2412 | ja .end |
2413 | mov [MOUSE_X], edx |
2413 | mov [MOUSE_X], edx |
2414 | mov [mouse_active], 1 |
2414 | mov [mouse_active], 1 |
2415 | call wakeup_osloop |
2415 | call wakeup_osloop |
2416 | ret |
2416 | ret |
2417 | .set_mouse_button: |
2417 | .set_mouse_button: |
2418 | ; cmp ecx,5 ; set mouse button features |
2418 | ; cmp ecx,5 ; set mouse button features |
2419 | dec ecx |
2419 | dec ecx |
2420 | jnz .end |
2420 | jnz .end |
2421 | mov [BTN_DOWN], dl |
2421 | mov [BTN_DOWN], dl |
2422 | mov [mouse_active], 1 |
2422 | mov [mouse_active], 1 |
2423 | call wakeup_osloop |
2423 | call wakeup_osloop |
2424 | .end: |
2424 | .end: |
2425 | ret |
2425 | ret |
2426 | ;------------------------------------------------------------------------------ |
2426 | ;------------------------------------------------------------------------------ |
2427 | sysfn_getfreemem: |
2427 | sysfn_getfreemem: |
2428 | mov eax, [pg_data.pages_free] |
2428 | mov eax, [pg_data.pages_free] |
2429 | shl eax, 2 |
2429 | shl eax, 2 |
2430 | mov [esp+32], eax |
2430 | mov [esp+32], eax |
2431 | ret |
2431 | ret |
2432 | ;------------------------------------------------------------------------------ |
2432 | ;------------------------------------------------------------------------------ |
2433 | sysfn_getallmem: |
2433 | sysfn_getallmem: |
2434 | mov eax, [MEM_AMOUNT] |
2434 | mov eax, [MEM_AMOUNT] |
2435 | shr eax, 10 |
2435 | shr eax, 10 |
2436 | mov [esp+32], eax |
2436 | mov [esp+32], eax |
2437 | ret |
2437 | ret |
2438 | ;------------------------------------------------------------------------------ |
2438 | ;------------------------------------------------------------------------------ |
2439 | sysfn_pid_to_slot: |
2439 | sysfn_pid_to_slot: |
2440 | mov eax, ecx |
2440 | mov eax, ecx |
2441 | call pid_to_slot |
2441 | call pid_to_slot |
2442 | mov [esp+32], eax |
2442 | mov [esp+32], eax |
2443 | ret |
2443 | ret |
2444 | ;------------------------------------------------------------------------------ |
2444 | ;------------------------------------------------------------------------------ |
2445 | sysfn_min_rest_window: |
2445 | sysfn_min_rest_window: |
2446 | pushad |
2446 | pushad |
2447 | mov eax, edx ; ebx - operating |
2447 | mov eax, edx ; ebx - operating |
2448 | shr ecx, 1 |
2448 | shr ecx, 1 |
2449 | jnc @f |
2449 | jnc @f |
2450 | call pid_to_slot |
2450 | call pid_to_slot |
2451 | @@: |
2451 | @@: |
2452 | or eax, eax ; eax - number of slot |
2452 | or eax, eax ; eax - number of slot |
2453 | jz .error |
2453 | jz .error |
2454 | cmp eax, 255 ; varify maximal slot number |
2454 | cmp eax, 255 ; varify maximal slot number |
2455 | ja .error |
2455 | ja .error |
2456 | movzx eax, word [WIN_STACK + eax*2] |
2456 | movzx eax, word [WIN_STACK + eax*2] |
2457 | shr ecx, 1 |
2457 | shr ecx, 1 |
2458 | jc .restore |
2458 | jc .restore |
2459 | ; .minimize: |
2459 | ; .minimize: |
2460 | call minimize_window |
2460 | call minimize_window |
2461 | jmp .exit |
2461 | jmp .exit |
2462 | .restore: |
2462 | .restore: |
2463 | call restore_minimized_window |
2463 | call restore_minimized_window |
2464 | .exit: |
2464 | .exit: |
2465 | popad |
2465 | popad |
2466 | xor eax, eax |
2466 | xor eax, eax |
2467 | mov [esp+32], eax |
2467 | mov [esp+32], eax |
2468 | ret |
2468 | ret |
2469 | .error: |
2469 | .error: |
2470 | popad |
2470 | popad |
2471 | xor eax, eax |
2471 | xor eax, eax |
2472 | dec eax |
2472 | dec eax |
2473 | mov [esp+32], eax |
2473 | mov [esp+32], eax |
2474 | ret |
2474 | ret |
2475 | ;------------------------------------------------------------------------------ |
2475 | ;------------------------------------------------------------------------------ |
2476 | sysfn_min_windows: |
2476 | sysfn_min_windows: |
2477 | call minimize_all_window |
2477 | call minimize_all_window |
2478 | mov [esp+32], eax |
2478 | mov [esp+32], eax |
2479 | call change_task |
2479 | call change_task |
2480 | ret |
2480 | ret |
2481 | ;------------------------------------------------------------------------------ |
2481 | ;------------------------------------------------------------------------------ |
2482 | sysfn_set_screen_sizes: |
2482 | sysfn_set_screen_sizes: |
2483 | cmp [SCR_MODE], word 0x13 |
2483 | cmp [SCR_MODE], word 0x13 |
2484 | jbe .exit |
2484 | jbe .exit |
2485 | 2485 | ||
2486 | cmp [_display.select_cursor], select_cursor |
2486 | cmp [_display.select_cursor], select_cursor |
2487 | jne .exit |
2487 | jne .exit |
2488 | 2488 | ||
2489 | cmp ecx, [display_width_standard] |
2489 | cmp ecx, [display_width_standard] |
2490 | ja .exit |
2490 | ja .exit |
2491 | 2491 | ||
2492 | cmp edx, [display_height_standard] |
2492 | cmp edx, [display_height_standard] |
2493 | ja .exit |
2493 | ja .exit |
2494 | 2494 | ||
2495 | pushfd |
2495 | pushfd |
2496 | cli |
2496 | cli |
2497 | mov eax, ecx |
2497 | mov eax, ecx |
2498 | mov ecx, [_display.pitch] |
2498 | mov ecx, [_display.pitch] |
2499 | mov [_display.width], eax |
2499 | mov [_display.width], eax |
2500 | dec eax |
2500 | dec eax |
2501 | mov [_display.height], edx |
2501 | mov [_display.height], edx |
2502 | dec edx |
2502 | dec edx |
2503 | ; eax - new Screen_Max_X |
2503 | ; eax - new Screen_Max_X |
2504 | ; edx - new Screen_Max_Y |
2504 | ; edx - new Screen_Max_Y |
2505 | mov [do_not_touch_winmap], 1 |
2505 | mov [do_not_touch_winmap], 1 |
2506 | call set_screen |
2506 | call set_screen |
2507 | mov [do_not_touch_winmap], 0 |
2507 | mov [do_not_touch_winmap], 0 |
2508 | popfd |
2508 | popfd |
2509 | call change_task |
2509 | call change_task |
2510 | .exit: |
2510 | .exit: |
2511 | ret |
2511 | ret |
2512 | ;------------------------------------------------------------------------------ |
2512 | ;------------------------------------------------------------------------------ |
2513 | uglobal |
2513 | uglobal |
2514 | screen_workarea RECT |
2514 | screen_workarea RECT |
2515 | display_width_standard dd 0 |
2515 | display_width_standard dd 0 |
2516 | display_height_standard dd 0 |
2516 | display_height_standard dd 0 |
2517 | do_not_touch_winmap db 0 |
2517 | do_not_touch_winmap db 0 |
2518 | window_minimize db 0 |
2518 | window_minimize db 0 |
2519 | sound_flag db 0 |
2519 | sound_flag db 0 |
2520 | 2520 | ||
2521 | endg |
2521 | endg |
2522 | 2522 | ||
2523 | UID_NONE=0 |
2523 | UID_NONE=0 |
2524 | UID_MENUETOS=1 ;official |
2524 | UID_MENUETOS=1 ;official |
2525 | UID_KOLIBRI=2 ;russian |
2525 | UID_KOLIBRI=2 ;russian |
2526 | 2526 | ||
2527 | iglobal |
2527 | iglobal |
2528 | version_inf: |
2528 | version_inf: |
2529 | db 0,7,7,0 ; version 0.7.7.0 |
2529 | db 0,7,7,0 ; version 0.7.7.0 |
2530 | db 0 |
2530 | db 0 |
2531 | .rev dd __REV__ |
2531 | .rev dd __REV__ |
2532 | version_end: |
2532 | version_end: |
2533 | endg |
2533 | endg |
2534 | ;------------------------------------------------------------------------------ |
2534 | ;------------------------------------------------------------------------------ |
2535 | align 4 |
2535 | align 4 |
2536 | sys_cachetodiskette: |
2536 | sys_cachetodiskette: |
2537 | cmp ebx, 1 |
2537 | cmp ebx, 1 |
2538 | jb .no_floppy_save |
2538 | jb .no_floppy_save |
2539 | cmp ebx, 2 |
2539 | cmp ebx, 2 |
2540 | ja .no_floppy_save |
2540 | ja .no_floppy_save |
2541 | call save_image |
2541 | call save_image |
2542 | mov [esp + 32], eax |
2542 | mov [esp + 32], eax |
2543 | ret |
2543 | ret |
2544 | .no_floppy_save: |
2544 | .no_floppy_save: |
2545 | mov [esp + 32], dword 1 |
2545 | mov [esp + 32], dword 1 |
2546 | ret |
2546 | ret |
2547 | ;------------------------------------------------------------------------------ |
2547 | ;------------------------------------------------------------------------------ |
2548 | uglobal |
2548 | uglobal |
2549 | ; bgrchanged dd 0x0 |
2549 | ; bgrchanged dd 0x0 |
2550 | align 4 |
2550 | align 4 |
2551 | bgrlockpid dd 0 |
2551 | bgrlockpid dd 0 |
2552 | bgrlock db 0 |
2552 | bgrlock db 0 |
2553 | endg |
2553 | endg |
2554 | ;------------------------------------------------------------------------------ |
2554 | ;------------------------------------------------------------------------------ |
2555 | align 4 |
2555 | align 4 |
2556 | sys_background: |
2556 | sys_background: |
2557 | cmp ebx, 1 ; BACKGROUND SIZE |
2557 | cmp ebx, 1 ; BACKGROUND SIZE |
2558 | jnz nosb1 |
2558 | jnz nosb1 |
2559 | test ecx, ecx |
2559 | test ecx, ecx |
2560 | jz sbgrr |
2560 | jz sbgrr |
2561 | 2561 | ||
2562 | test edx, edx |
2562 | test edx, edx |
2563 | jz sbgrr |
2563 | jz sbgrr |
2564 | ;-------------------------------------- |
2564 | ;-------------------------------------- |
2565 | align 4 |
2565 | align 4 |
2566 | @@: |
2566 | @@: |
2567 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2567 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2568 | bts dword [bgrlock], 0 |
2568 | bts dword [bgrlock], 0 |
2569 | jnc @f |
2569 | jnc @f |
2570 | call change_task |
2570 | call change_task |
2571 | jmp @b |
2571 | jmp @b |
2572 | ;-------------------------------------- |
2572 | ;-------------------------------------- |
2573 | align 4 |
2573 | align 4 |
2574 | @@: |
2574 | @@: |
2575 | mov [BgrDataWidth], ecx |
2575 | mov [BgrDataWidth], ecx |
2576 | mov [BgrDataHeight], edx |
2576 | mov [BgrDataHeight], edx |
2577 | ; mov [bgrchanged],1 |
2577 | ; mov [bgrchanged],1 |
2578 | 2578 | ||
2579 | pushad |
2579 | pushad |
2580 | ; return memory for old background |
2580 | ; return memory for old background |
2581 | mov eax, [img_background] |
2581 | mov eax, [img_background] |
2582 | cmp eax, static_background_data |
2582 | cmp eax, static_background_data |
2583 | jz @f |
2583 | jz @f |
2584 | stdcall kernel_free, eax |
2584 | stdcall kernel_free, eax |
2585 | ;-------------------------------------- |
2585 | ;-------------------------------------- |
2586 | align 4 |
2586 | align 4 |
2587 | @@: |
2587 | @@: |
2588 | ; calculate RAW size |
2588 | ; calculate RAW size |
2589 | xor eax, eax |
2589 | xor eax, eax |
2590 | inc eax |
2590 | inc eax |
2591 | cmp [BgrDataWidth], eax |
2591 | cmp [BgrDataWidth], eax |
2592 | jae @f |
2592 | jae @f |
2593 | mov [BgrDataWidth], eax |
2593 | mov [BgrDataWidth], eax |
2594 | ;-------------------------------------- |
2594 | ;-------------------------------------- |
2595 | align 4 |
2595 | align 4 |
2596 | @@: |
2596 | @@: |
2597 | cmp [BgrDataHeight], eax |
2597 | cmp [BgrDataHeight], eax |
2598 | jae @f |
2598 | jae @f |
2599 | mov [BgrDataHeight], eax |
2599 | mov [BgrDataHeight], eax |
2600 | ;-------------------------------------- |
2600 | ;-------------------------------------- |
2601 | align 4 |
2601 | align 4 |
2602 | @@: |
2602 | @@: |
2603 | mov eax, [BgrDataWidth] |
2603 | mov eax, [BgrDataWidth] |
2604 | imul eax, [BgrDataHeight] |
2604 | imul eax, [BgrDataHeight] |
2605 | lea eax, [eax*3] |
2605 | lea eax, [eax*3] |
2606 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2606 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2607 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2607 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2608 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2608 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2609 | shr eax, 12 |
2609 | shr eax, 12 |
2610 | inc eax |
2610 | inc eax |
2611 | shl eax, 12 |
2611 | shl eax, 12 |
2612 | mov [mem_BACKGROUND], eax |
2612 | mov [mem_BACKGROUND], eax |
2613 | ; get memory for new background |
2613 | ; get memory for new background |
2614 | stdcall kernel_alloc, eax |
2614 | stdcall kernel_alloc, eax |
2615 | test eax, eax |
2615 | test eax, eax |
2616 | jz .memfailed |
2616 | jz .memfailed |
2617 | mov [img_background], eax |
2617 | mov [img_background], eax |
2618 | jmp .exit |
2618 | jmp .exit |
2619 | ;-------------------------------------- |
2619 | ;-------------------------------------- |
2620 | align 4 |
2620 | align 4 |
2621 | .memfailed: |
2621 | .memfailed: |
2622 | ; revert to static monotone data |
2622 | ; revert to static monotone data |
2623 | mov [img_background], static_background_data |
2623 | mov [img_background], static_background_data |
2624 | xor eax, eax |
2624 | xor eax, eax |
2625 | inc eax |
2625 | inc eax |
2626 | mov [BgrDataWidth], eax |
2626 | mov [BgrDataWidth], eax |
2627 | mov [BgrDataHeight], eax |
2627 | mov [BgrDataHeight], eax |
2628 | mov [mem_BACKGROUND], 4 |
2628 | mov [mem_BACKGROUND], 4 |
2629 | ;-------------------------------------- |
2629 | ;-------------------------------------- |
2630 | align 4 |
2630 | align 4 |
2631 | .exit: |
2631 | .exit: |
2632 | popad |
2632 | popad |
2633 | mov [bgrlock], 0 |
2633 | mov [bgrlock], 0 |
2634 | ;-------------------------------------- |
2634 | ;-------------------------------------- |
2635 | align 4 |
2635 | align 4 |
2636 | sbgrr: |
2636 | sbgrr: |
2637 | ret |
2637 | ret |
2638 | ;------------------------------------------------------------------------------ |
2638 | ;------------------------------------------------------------------------------ |
2639 | align 4 |
2639 | align 4 |
2640 | nosb1: |
2640 | nosb1: |
2641 | cmp ebx, 2 ; SET PIXEL |
2641 | cmp ebx, 2 ; SET PIXEL |
2642 | jnz nosb2 |
2642 | jnz nosb2 |
2643 | 2643 | ||
2644 | mov eax, [img_background] |
2644 | mov eax, [img_background] |
2645 | test ecx, ecx |
2645 | test ecx, ecx |
2646 | jz @f |
2646 | jz @f |
2647 | cmp eax, static_background_data |
2647 | cmp eax, static_background_data |
2648 | jz .ret |
2648 | jz .ret |
2649 | ;-------------------------------------- |
2649 | ;-------------------------------------- |
2650 | align 4 |
2650 | align 4 |
2651 | @@: |
2651 | @@: |
2652 | mov ebx, [mem_BACKGROUND] |
2652 | mov ebx, [mem_BACKGROUND] |
2653 | add ebx, 4095 |
2653 | add ebx, 4095 |
2654 | and ebx, -4096 |
2654 | and ebx, -4096 |
2655 | sub ebx, 4 |
2655 | sub ebx, 4 |
2656 | cmp ecx, ebx |
2656 | cmp ecx, ebx |
2657 | ja .ret |
2657 | ja .ret |
2658 | 2658 | ||
2659 | mov ebx, [eax+ecx] |
2659 | mov ebx, [eax+ecx] |
2660 | and ebx, 0xFF000000;255*256*256*256 |
2660 | and ebx, 0xFF000000;255*256*256*256 |
2661 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2661 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2662 | add edx, ebx |
2662 | add edx, ebx |
2663 | mov [eax+ecx], edx |
2663 | mov [eax+ecx], edx |
2664 | ;-------------------------------------- |
2664 | ;-------------------------------------- |
2665 | align 4 |
2665 | align 4 |
2666 | .ret: |
2666 | .ret: |
2667 | ret |
2667 | ret |
2668 | ;------------------------------------------------------------------------------ |
2668 | ;------------------------------------------------------------------------------ |
2669 | align 4 |
2669 | align 4 |
2670 | nosb2: |
2670 | nosb2: |
2671 | cmp ebx, 3 ; DRAW BACKGROUND |
2671 | cmp ebx, 3 ; DRAW BACKGROUND |
2672 | jnz nosb3 |
2672 | jnz nosb3 |
2673 | ;-------------------------------------- |
2673 | ;-------------------------------------- |
2674 | align 4 |
2674 | align 4 |
2675 | draw_background_temp: |
2675 | draw_background_temp: |
2676 | mov [background_defined], 1 |
2676 | mov [background_defined], 1 |
2677 | call force_redraw_background |
2677 | call force_redraw_background |
2678 | ;-------------------------------------- |
2678 | ;-------------------------------------- |
2679 | align 4 |
2679 | align 4 |
2680 | nosb31: |
2680 | nosb31: |
2681 | ret |
2681 | ret |
2682 | ;------------------------------------------------------------------------------ |
2682 | ;------------------------------------------------------------------------------ |
2683 | align 4 |
2683 | align 4 |
2684 | nosb3: |
2684 | nosb3: |
2685 | cmp ebx, 4 ; TILED / STRETCHED |
2685 | cmp ebx, 4 ; TILED / STRETCHED |
2686 | jnz nosb4 |
2686 | jnz nosb4 |
2687 | cmp ecx, [BgrDrawMode] |
2687 | cmp ecx, [BgrDrawMode] |
2688 | je nosb41 |
2688 | je nosb41 |
2689 | mov [BgrDrawMode], ecx |
2689 | mov [BgrDrawMode], ecx |
2690 | ;-------------------------------------- |
2690 | ;-------------------------------------- |
2691 | align 4 |
2691 | align 4 |
2692 | nosb41: |
2692 | nosb41: |
2693 | ret |
2693 | ret |
2694 | ;------------------------------------------------------------------------------ |
2694 | ;------------------------------------------------------------------------------ |
2695 | align 4 |
2695 | align 4 |
2696 | nosb4: |
2696 | nosb4: |
2697 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2697 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2698 | jnz nosb5 |
2698 | jnz nosb5 |
2699 | cmp [img_background], static_background_data |
2699 | cmp [img_background], static_background_data |
2700 | jnz @f |
2700 | jnz @f |
2701 | test edx, edx |
2701 | test edx, edx |
2702 | jnz .fin |
2702 | jnz .fin |
2703 | cmp esi, 4 |
2703 | cmp esi, 4 |
2704 | ja .fin |
2704 | ja .fin |
2705 | ;-------------------------------------- |
2705 | ;-------------------------------------- |
2706 | align 4 |
2706 | align 4 |
2707 | @@: |
2707 | @@: |
2708 | ; bughere |
2708 | ; bughere |
2709 | mov eax, ecx |
2709 | mov eax, ecx |
2710 | mov ebx, edx |
2710 | mov ebx, edx |
2711 | add ebx, [img_background];IMG_BACKGROUND |
2711 | add ebx, [img_background];IMG_BACKGROUND |
2712 | mov ecx, esi |
2712 | mov ecx, esi |
2713 | call memmove |
2713 | call memmove |
2714 | ;-------------------------------------- |
2714 | ;-------------------------------------- |
2715 | align 4 |
2715 | align 4 |
2716 | .fin: |
2716 | .fin: |
2717 | ret |
2717 | ret |
2718 | ;------------------------------------------------------------------------------ |
2718 | ;------------------------------------------------------------------------------ |
2719 | align 4 |
2719 | align 4 |
2720 | nosb5: |
2720 | nosb5: |
2721 | cmp ebx, 6 |
2721 | cmp ebx, 6 |
2722 | jnz nosb6 |
2722 | jnz nosb6 |
2723 | ;-------------------------------------- |
2723 | ;-------------------------------------- |
2724 | align 4 |
2724 | align 4 |
2725 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2725 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2726 | @@: |
2726 | @@: |
2727 | bts dword [bgrlock], 0 |
2727 | bts dword [bgrlock], 0 |
2728 | jnc @f |
2728 | jnc @f |
2729 | call change_task |
2729 | call change_task |
2730 | jmp @b |
2730 | jmp @b |
2731 | ;-------------------------------------- |
2731 | ;-------------------------------------- |
2732 | align 4 |
2732 | align 4 |
2733 | @@: |
2733 | @@: |
2734 | mov eax, [CURRENT_TASK] |
2734 | mov eax, [CURRENT_TASK] |
2735 | mov [bgrlockpid], eax |
2735 | mov [bgrlockpid], eax |
2736 | cmp [img_background], static_background_data |
2736 | cmp [img_background], static_background_data |
2737 | jz .nomem |
2737 | jz .nomem |
2738 | stdcall user_alloc, [mem_BACKGROUND] |
2738 | stdcall user_alloc, [mem_BACKGROUND] |
2739 | mov [esp+32], eax |
2739 | mov [esp+32], eax |
2740 | test eax, eax |
2740 | test eax, eax |
2741 | jz .nomem |
2741 | jz .nomem |
2742 | mov ebx, eax |
2742 | mov ebx, eax |
2743 | shr ebx, 12 |
2743 | shr ebx, 12 |
2744 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2744 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2745 | mov esi, [img_background] |
2745 | mov esi, [img_background] |
2746 | shr esi, 12 |
2746 | shr esi, 12 |
2747 | mov ecx, [mem_BACKGROUND] |
2747 | mov ecx, [mem_BACKGROUND] |
2748 | add ecx, 0xFFF |
2748 | add ecx, 0xFFF |
2749 | shr ecx, 12 |
2749 | shr ecx, 12 |
2750 | ;-------------------------------------- |
2750 | ;-------------------------------------- |
2751 | align 4 |
2751 | align 4 |
2752 | .z: |
2752 | .z: |
2753 | mov eax, [page_tabs+ebx*4] |
2753 | mov eax, [page_tabs+ebx*4] |
2754 | test al, 1 |
2754 | test al, 1 |
2755 | jz @f |
2755 | jz @f |
2756 | call free_page |
2756 | call free_page |
2757 | ;-------------------------------------- |
2757 | ;-------------------------------------- |
2758 | align 4 |
2758 | align 4 |
2759 | @@: |
2759 | @@: |
2760 | mov eax, [page_tabs+esi*4] |
2760 | mov eax, [page_tabs+esi*4] |
2761 | or al, PG_UW |
2761 | or al, PG_UW |
2762 | mov [page_tabs+ebx*4], eax |
2762 | mov [page_tabs+ebx*4], eax |
2763 | mov eax, ebx |
2763 | mov eax, ebx |
2764 | shl eax, 12 |
2764 | shl eax, 12 |
2765 | invlpg [eax] |
2765 | invlpg [eax] |
2766 | inc ebx |
2766 | inc ebx |
2767 | inc esi |
2767 | inc esi |
2768 | loop .z |
2768 | loop .z |
2769 | ret |
2769 | ret |
2770 | ;-------------------------------------- |
2770 | ;-------------------------------------- |
2771 | align 4 |
2771 | align 4 |
2772 | .nomem: |
2772 | .nomem: |
2773 | and [bgrlockpid], 0 |
2773 | and [bgrlockpid], 0 |
2774 | mov [bgrlock], 0 |
2774 | mov [bgrlock], 0 |
2775 | ;------------------------------------------------------------------------------ |
2775 | ;------------------------------------------------------------------------------ |
2776 | align 4 |
2776 | align 4 |
2777 | nosb6: |
2777 | nosb6: |
2778 | cmp ebx, 7 |
2778 | cmp ebx, 7 |
2779 | jnz nosb7 |
2779 | jnz nosb7 |
2780 | cmp [bgrlock], 0 |
2780 | cmp [bgrlock], 0 |
2781 | jz .err |
2781 | jz .err |
2782 | mov eax, [CURRENT_TASK] |
2782 | mov eax, [CURRENT_TASK] |
2783 | cmp [bgrlockpid], eax |
2783 | cmp [bgrlockpid], eax |
2784 | jnz .err |
2784 | jnz .err |
2785 | mov eax, ecx |
2785 | mov eax, ecx |
2786 | mov ebx, ecx |
2786 | mov ebx, ecx |
2787 | shr eax, 12 |
2787 | shr eax, 12 |
2788 | mov ecx, [page_tabs+(eax-1)*4] |
2788 | mov ecx, [page_tabs+(eax-1)*4] |
2789 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2789 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2790 | jz .err |
2790 | jz .err |
2791 | jnp .err |
2791 | jnp .err |
2792 | push eax |
2792 | push eax |
2793 | shr ecx, 12 |
2793 | shr ecx, 12 |
2794 | dec ecx |
2794 | dec ecx |
2795 | ;-------------------------------------- |
2795 | ;-------------------------------------- |
2796 | align 4 |
2796 | align 4 |
2797 | @@: |
2797 | @@: |
2798 | and dword [page_tabs+eax*4], 0 |
2798 | and dword [page_tabs+eax*4], 0 |
2799 | mov edx, eax |
2799 | mov edx, eax |
2800 | shl edx, 12 |
2800 | shl edx, 12 |
2801 | push eax |
2801 | push eax |
2802 | invlpg [edx] |
2802 | invlpg [edx] |
2803 | pop eax |
2803 | pop eax |
2804 | inc eax |
2804 | inc eax |
2805 | loop @b |
2805 | loop @b |
2806 | pop eax |
2806 | pop eax |
2807 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2807 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2808 | stdcall user_free, ebx |
2808 | stdcall user_free, ebx |
2809 | mov [esp+32], eax |
2809 | mov [esp+32], eax |
2810 | and [bgrlockpid], 0 |
2810 | and [bgrlockpid], 0 |
2811 | mov [bgrlock], 0 |
2811 | mov [bgrlock], 0 |
2812 | ret |
2812 | ret |
2813 | ;-------------------------------------- |
2813 | ;-------------------------------------- |
2814 | align 4 |
2814 | align 4 |
2815 | .err: |
2815 | .err: |
2816 | and dword [esp+32], 0 |
2816 | and dword [esp+32], 0 |
2817 | ret |
2817 | ret |
2818 | ;------------------------------------------------------------------------------ |
2818 | ;------------------------------------------------------------------------------ |
2819 | align 4 |
2819 | align 4 |
2820 | nosb7: |
2820 | nosb7: |
2821 | cmp ebx, 8 |
2821 | cmp ebx, 8 |
2822 | jnz nosb8 |
2822 | jnz nosb8 |
2823 | 2823 | ||
2824 | mov ecx, [current_slot] |
2824 | mov ecx, [current_slot] |
2825 | xor eax, eax |
2825 | xor eax, eax |
2826 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2826 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2827 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2827 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2828 | xor eax, eax |
2828 | xor eax, eax |
2829 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2829 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2830 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2830 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2831 | ret |
2831 | ret |
2832 | ;------------------------------------------------------------------------------ |
2832 | ;------------------------------------------------------------------------------ |
2833 | align 4 |
2833 | align 4 |
2834 | nosb8: |
2834 | nosb8: |
2835 | cmp ebx, 9 |
2835 | cmp ebx, 9 |
2836 | jnz nosb9 |
2836 | jnz nosb9 |
2837 | ; ecx = [left]*65536 + [right] |
2837 | ; ecx = [left]*65536 + [right] |
2838 | ; edx = [top]*65536 + [bottom] |
2838 | ; edx = [top]*65536 + [bottom] |
2839 | mov eax, [Screen_Max_X] |
2839 | mov eax, [Screen_Max_X] |
2840 | mov ebx, [Screen_Max_Y] |
2840 | mov ebx, [Screen_Max_Y] |
2841 | ; check [right] |
2841 | ; check [right] |
2842 | cmp cx, ax |
2842 | cmp cx, ax |
2843 | ja .exit |
2843 | ja .exit |
2844 | ; check [left] |
2844 | ; check [left] |
2845 | ror ecx, 16 |
2845 | ror ecx, 16 |
2846 | cmp cx, ax |
2846 | cmp cx, ax |
2847 | ja .exit |
2847 | ja .exit |
2848 | ; check [bottom] |
2848 | ; check [bottom] |
2849 | cmp dx, bx |
2849 | cmp dx, bx |
2850 | ja .exit |
2850 | ja .exit |
2851 | ; check [top] |
2851 | ; check [top] |
2852 | ror edx, 16 |
2852 | ror edx, 16 |
2853 | cmp dx, bx |
2853 | cmp dx, bx |
2854 | ja .exit |
2854 | ja .exit |
2855 | 2855 | ||
2856 | movzx eax, cx ; [left] |
2856 | movzx eax, cx ; [left] |
2857 | movzx ebx, dx ; [top] |
2857 | movzx ebx, dx ; [top] |
2858 | 2858 | ||
2859 | shr ecx, 16 ; [right] |
2859 | shr ecx, 16 ; [right] |
2860 | shr edx, 16 ; [bottom] |
2860 | shr edx, 16 ; [bottom] |
2861 | 2861 | ||
2862 | mov [background_defined], 1 |
2862 | mov [background_defined], 1 |
2863 | 2863 | ||
2864 | mov [draw_data+32 + RECT.left], eax |
2864 | mov [draw_data+32 + RECT.left], eax |
2865 | mov [draw_data+32 + RECT.top], ebx |
2865 | mov [draw_data+32 + RECT.top], ebx |
2866 | 2866 | ||
2867 | mov [draw_data+32 + RECT.right], ecx |
2867 | mov [draw_data+32 + RECT.right], ecx |
2868 | mov [draw_data+32 + RECT.bottom], edx |
2868 | mov [draw_data+32 + RECT.bottom], edx |
2869 | 2869 | ||
2870 | inc byte[REDRAW_BACKGROUND] |
2870 | inc byte[REDRAW_BACKGROUND] |
2871 | call wakeup_osloop |
2871 | call wakeup_osloop |
2872 | ;-------------------------------------- |
2872 | ;-------------------------------------- |
2873 | align 4 |
2873 | align 4 |
2874 | .exit: |
2874 | .exit: |
2875 | ret |
2875 | ret |
2876 | ;------------------------------------------------------------------------------ |
2876 | ;------------------------------------------------------------------------------ |
2877 | align 4 |
2877 | align 4 |
2878 | nosb9: |
2878 | nosb9: |
2879 | ret |
2879 | ret |
2880 | ;------------------------------------------------------------------------------ |
2880 | ;------------------------------------------------------------------------------ |
2881 | align 4 |
2881 | align 4 |
2882 | uglobal |
2882 | uglobal |
2883 | BG_Rect_X_left_right dd 0x0 |
2883 | BG_Rect_X_left_right dd 0x0 |
2884 | BG_Rect_Y_top_bottom dd 0x0 |
2884 | BG_Rect_Y_top_bottom dd 0x0 |
2885 | endg |
2885 | endg |
2886 | ;------------------------------------------------------------------------------ |
2886 | ;------------------------------------------------------------------------------ |
2887 | align 4 |
2887 | align 4 |
2888 | force_redraw_background: |
2888 | force_redraw_background: |
2889 | and [draw_data+32 + RECT.left], 0 |
2889 | and [draw_data+32 + RECT.left], 0 |
2890 | and [draw_data+32 + RECT.top], 0 |
2890 | and [draw_data+32 + RECT.top], 0 |
2891 | push eax ebx |
2891 | push eax ebx |
2892 | mov eax, [Screen_Max_X] |
2892 | mov eax, [Screen_Max_X] |
2893 | mov ebx, [Screen_Max_Y] |
2893 | mov ebx, [Screen_Max_Y] |
2894 | mov [draw_data+32 + RECT.right], eax |
2894 | mov [draw_data+32 + RECT.right], eax |
2895 | mov [draw_data+32 + RECT.bottom], ebx |
2895 | mov [draw_data+32 + RECT.bottom], ebx |
2896 | pop ebx eax |
2896 | pop ebx eax |
2897 | inc byte[REDRAW_BACKGROUND] |
2897 | inc byte[REDRAW_BACKGROUND] |
2898 | call wakeup_osloop |
2898 | call wakeup_osloop |
2899 | ret |
2899 | ret |
2900 | ;------------------------------------------------------------------------------ |
2900 | ;------------------------------------------------------------------------------ |
2901 | align 4 |
2901 | align 4 |
2902 | sys_getbackground: |
2902 | sys_getbackground: |
2903 | ; cmp eax,1 ; SIZE |
2903 | ; cmp eax,1 ; SIZE |
2904 | dec ebx |
2904 | dec ebx |
2905 | jnz nogb1 |
2905 | jnz nogb1 |
2906 | mov eax, [BgrDataWidth] |
2906 | mov eax, [BgrDataWidth] |
2907 | shl eax, 16 |
2907 | shl eax, 16 |
2908 | mov ax, word [BgrDataHeight] |
2908 | mov ax, word [BgrDataHeight] |
2909 | mov [esp+32], eax |
2909 | mov [esp+32], eax |
2910 | ret |
2910 | ret |
2911 | ;------------------------------------------------------------------------------ |
2911 | ;------------------------------------------------------------------------------ |
2912 | align 4 |
2912 | align 4 |
2913 | nogb1: |
2913 | nogb1: |
2914 | ; cmp eax,2 ; PIXEL |
2914 | ; cmp eax,2 ; PIXEL |
2915 | dec ebx |
2915 | dec ebx |
2916 | jnz nogb2 |
2916 | jnz nogb2 |
2917 | 2917 | ||
2918 | mov eax, [img_background] |
2918 | mov eax, [img_background] |
2919 | test ecx, ecx |
2919 | test ecx, ecx |
2920 | jz @f |
2920 | jz @f |
2921 | cmp eax, static_background_data |
2921 | cmp eax, static_background_data |
2922 | jz .ret |
2922 | jz .ret |
2923 | ;-------------------------------------- |
2923 | ;-------------------------------------- |
2924 | align 4 |
2924 | align 4 |
2925 | @@: |
2925 | @@: |
2926 | mov ebx, [mem_BACKGROUND] |
2926 | mov ebx, [mem_BACKGROUND] |
2927 | add ebx, 4095 |
2927 | add ebx, 4095 |
2928 | and ebx, -4096 |
2928 | and ebx, -4096 |
2929 | sub ebx, 4 |
2929 | sub ebx, 4 |
2930 | cmp ecx, ebx |
2930 | cmp ecx, ebx |
2931 | ja .ret |
2931 | ja .ret |
2932 | 2932 | ||
2933 | mov eax, [ecx+eax] |
2933 | mov eax, [ecx+eax] |
2934 | 2934 | ||
2935 | and eax, 0xFFFFFF |
2935 | and eax, 0xFFFFFF |
2936 | mov [esp+32], eax |
2936 | mov [esp+32], eax |
2937 | ;-------------------------------------- |
2937 | ;-------------------------------------- |
2938 | align 4 |
2938 | align 4 |
2939 | .ret: |
2939 | .ret: |
2940 | ret |
2940 | ret |
2941 | ;------------------------------------------------------------------------------ |
2941 | ;------------------------------------------------------------------------------ |
2942 | align 4 |
2942 | align 4 |
2943 | nogb2: |
2943 | nogb2: |
2944 | 2944 | ||
2945 | ; cmp eax,4 ; TILED / STRETCHED |
2945 | ; cmp eax,4 ; TILED / STRETCHED |
2946 | dec ebx |
2946 | dec ebx |
2947 | dec ebx |
2947 | dec ebx |
2948 | jnz nogb4 |
2948 | jnz nogb4 |
2949 | mov eax, [BgrDrawMode] |
2949 | mov eax, [BgrDrawMode] |
2950 | ;-------------------------------------- |
2950 | ;-------------------------------------- |
2951 | align 4 |
2951 | align 4 |
2952 | nogb4: |
2952 | nogb4: |
2953 | mov [esp+32], eax |
2953 | mov [esp+32], eax |
2954 | ret |
2954 | ret |
2955 | ;------------------------------------------------------------------------------ |
2955 | ;------------------------------------------------------------------------------ |
2956 | align 4 |
2956 | align 4 |
2957 | sys_getkey: |
2957 | sys_getkey: |
2958 | mov [esp + 32], dword 1 |
2958 | mov [esp + 32], dword 1 |
2959 | ; test main buffer |
2959 | ; test main buffer |
2960 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2960 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2961 | movzx ecx, word [WIN_STACK + ebx * 2] |
2961 | movzx ecx, word [WIN_STACK + ebx * 2] |
2962 | mov edx, [TASK_COUNT] |
2962 | mov edx, [TASK_COUNT] |
2963 | cmp ecx, edx |
2963 | cmp ecx, edx |
2964 | jne .finish |
2964 | jne .finish |
2965 | cmp [KEY_COUNT], byte 0 |
2965 | cmp [KEY_COUNT], byte 0 |
2966 | je .finish |
2966 | je .finish |
2967 | movzx ax, byte [KEY_BUFF + 120 + 2] |
2967 | movzx ax, byte [KEY_BUFF + 120 + 2] |
2968 | shl eax, 8 |
2968 | shl eax, 8 |
2969 | mov al, byte [KEY_BUFF] |
2969 | mov al, byte [KEY_BUFF] |
2970 | shl eax, 8 |
2970 | shl eax, 8 |
2971 | push eax |
2971 | push eax |
2972 | dec byte [KEY_COUNT] |
2972 | dec byte [KEY_COUNT] |
2973 | and byte [KEY_COUNT], 127 |
2973 | and byte [KEY_COUNT], 127 |
2974 | movzx ecx, byte [KEY_COUNT] |
2974 | movzx ecx, byte [KEY_COUNT] |
2975 | add ecx, 2 |
2975 | add ecx, 2 |
2976 | mov eax, KEY_BUFF + 1 |
2976 | mov eax, KEY_BUFF + 1 |
2977 | mov ebx, KEY_BUFF |
2977 | mov ebx, KEY_BUFF |
2978 | call memmove |
2978 | call memmove |
2979 | add eax, 120 + 2 |
2979 | add eax, 120 + 2 |
2980 | add ebx, 120 + 2 |
2980 | add ebx, 120 + 2 |
2981 | call memmove |
2981 | call memmove |
2982 | pop eax |
2982 | pop eax |
2983 | ;-------------------------------------- |
2983 | ;-------------------------------------- |
2984 | align 4 |
2984 | align 4 |
2985 | .ret_eax: |
2985 | .ret_eax: |
2986 | mov [esp + 32], eax |
2986 | mov [esp + 32], eax |
2987 | ret |
2987 | ret |
2988 | ;-------------------------------------- |
2988 | ;-------------------------------------- |
2989 | align 4 |
2989 | align 4 |
2990 | .finish: |
2990 | .finish: |
2991 | ; test hotkeys buffer |
2991 | ; test hotkeys buffer |
2992 | mov ecx, hotkey_buffer |
2992 | mov ecx, hotkey_buffer |
2993 | ;-------------------------------------- |
2993 | ;-------------------------------------- |
2994 | align 4 |
2994 | align 4 |
2995 | @@: |
2995 | @@: |
2996 | cmp [ecx], ebx |
2996 | cmp [ecx], ebx |
2997 | jz .found |
2997 | jz .found |
2998 | add ecx, 8 |
2998 | add ecx, 8 |
2999 | cmp ecx, hotkey_buffer + 120 * 8 |
2999 | cmp ecx, hotkey_buffer + 120 * 8 |
3000 | jb @b |
3000 | jb @b |
3001 | ret |
3001 | ret |
3002 | ;-------------------------------------- |
3002 | ;-------------------------------------- |
3003 | align 4 |
3003 | align 4 |
3004 | .found: |
3004 | .found: |
3005 | mov ax, [ecx + 6] |
3005 | mov ax, [ecx + 6] |
3006 | shl eax, 16 |
3006 | shl eax, 16 |
3007 | mov ah, [ecx + 4] |
3007 | mov ah, [ecx + 4] |
3008 | mov al, 2 |
3008 | mov al, 2 |
3009 | and dword [ecx + 4], 0 |
3009 | and dword [ecx + 4], 0 |
3010 | and dword [ecx], 0 |
3010 | and dword [ecx], 0 |
3011 | jmp .ret_eax |
3011 | jmp .ret_eax |
3012 | ;------------------------------------------------------------------------------ |
3012 | ;------------------------------------------------------------------------------ |
3013 | align 4 |
3013 | align 4 |
3014 | sys_getbutton: |
3014 | sys_getbutton: |
3015 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3015 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3016 | mov [esp + 32], dword 1 |
3016 | mov [esp + 32], dword 1 |
3017 | movzx ecx, word [WIN_STACK + ebx * 2] |
3017 | movzx ecx, word [WIN_STACK + ebx * 2] |
3018 | mov edx, [TASK_COUNT] ; less than 256 processes |
3018 | mov edx, [TASK_COUNT] ; less than 256 processes |
3019 | cmp ecx, edx |
3019 | cmp ecx, edx |
3020 | jne .exit |
3020 | jne .exit |
3021 | movzx eax, byte [BTN_COUNT] |
3021 | movzx eax, byte [BTN_COUNT] |
3022 | test eax, eax |
3022 | test eax, eax |
3023 | jz .exit |
3023 | jz .exit |
3024 | mov eax, [BTN_BUFF] |
3024 | mov eax, [BTN_BUFF] |
3025 | and al, 0xFE ; delete left button bit |
3025 | and al, 0xFE ; delete left button bit |
3026 | mov [BTN_COUNT], byte 0 |
3026 | mov [BTN_COUNT], byte 0 |
3027 | mov [esp + 32], eax |
3027 | mov [esp + 32], eax |
3028 | ;-------------------------------------- |
3028 | ;-------------------------------------- |
3029 | align 4 |
3029 | align 4 |
3030 | .exit: |
3030 | .exit: |
3031 | ret |
3031 | ret |
3032 | ;------------------------------------------------------------------------------ |
3032 | ;------------------------------------------------------------------------------ |
3033 | align 4 |
3033 | align 4 |
3034 | sys_cpuusage: |
3034 | sys_cpuusage: |
3035 | 3035 | ||
3036 | ; RETURN: |
3036 | ; RETURN: |
3037 | ; |
3037 | ; |
3038 | ; +00 dword process cpu usage |
3038 | ; +00 dword process cpu usage |
3039 | ; +04 word position in windowing stack |
3039 | ; +04 word position in windowing stack |
3040 | ; +06 word windowing stack value at current position (cpu nro) |
3040 | ; +06 word windowing stack value at current position (cpu nro) |
3041 | ; +10 12 bytes name |
3041 | ; +10 12 bytes name |
3042 | ; +22 dword start in mem |
3042 | ; +22 dword start in mem |
3043 | ; +26 dword used mem |
3043 | ; +26 dword used mem |
3044 | ; +30 dword PID , process idenfification number |
3044 | ; +30 dword PID , process idenfification number |
3045 | ; |
3045 | ; |
3046 | 3046 | ||
3047 | cmp ecx, -1 ; who am I ? |
3047 | cmp ecx, -1 ; who am I ? |
3048 | jne .no_who_am_i |
3048 | jne .no_who_am_i |
3049 | mov ecx, [CURRENT_TASK] |
3049 | mov ecx, [CURRENT_TASK] |
3050 | .no_who_am_i: |
3050 | .no_who_am_i: |
3051 | cmp ecx, max_processes |
3051 | cmp ecx, max_processes |
3052 | ja .nofillbuf |
3052 | ja .nofillbuf |
3053 | 3053 | ||
3054 | ; +4: word: position of the window of thread in the window stack |
3054 | ; +4: word: position of the window of thread in the window stack |
3055 | mov ax, [WIN_STACK + ecx * 2] |
3055 | mov ax, [WIN_STACK + ecx * 2] |
3056 | mov [ebx+4], ax |
3056 | mov [ebx+4], ax |
3057 | ; +6: word: number of the thread slot, which window has in the window stack |
3057 | ; +6: word: number of the thread slot, which window has in the window stack |
3058 | ; position ecx (has no relation to the specific thread) |
3058 | ; position ecx (has no relation to the specific thread) |
3059 | mov ax, [WIN_POS + ecx * 2] |
3059 | mov ax, [WIN_POS + ecx * 2] |
3060 | mov [ebx+6], ax |
3060 | mov [ebx+6], ax |
3061 | 3061 | ||
3062 | shl ecx, 5 |
3062 | shl ecx, 5 |
3063 | 3063 | ||
3064 | ; +0: dword: memory usage |
3064 | ; +0: dword: memory usage |
3065 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3065 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3066 | mov [ebx], eax |
3066 | mov [ebx], eax |
3067 | ; +10: 11 bytes: name of the process |
3067 | ; +10: 11 bytes: name of the process |
3068 | push ecx |
3068 | push ecx |
3069 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3069 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3070 | add ebx, 10 |
3070 | add ebx, 10 |
3071 | mov ecx, 11 |
3071 | mov ecx, 11 |
3072 | call memmove |
3072 | call memmove |
3073 | pop ecx |
3073 | pop ecx |
3074 | 3074 | ||
3075 | ; +22: address of the process in memory |
3075 | ; +22: address of the process in memory |
3076 | ; +26: size of used memory - 1 |
3076 | ; +26: size of used memory - 1 |
3077 | push edi |
3077 | push edi |
3078 | lea edi, [ebx+12] |
3078 | lea edi, [ebx+12] |
3079 | xor eax, eax |
3079 | xor eax, eax |
3080 | mov edx, 0x100000*16 |
3080 | mov edx, 0x100000*16 |
3081 | cmp ecx, 1 shl 5 |
3081 | cmp ecx, 1 shl 5 |
3082 | je .os_mem |
3082 | je .os_mem |
3083 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3083 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3084 | mov eax, std_application_base_address |
3084 | mov eax, std_application_base_address |
3085 | .os_mem: |
3085 | .os_mem: |
3086 | stosd |
3086 | stosd |
3087 | lea eax, [edx-1] |
3087 | lea eax, [edx-1] |
3088 | stosd |
3088 | stosd |
3089 | 3089 | ||
3090 | ; +30: PID/TID |
3090 | ; +30: PID/TID |
3091 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3091 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3092 | stosd |
3092 | stosd |
3093 | 3093 | ||
3094 | ; window position and size |
3094 | ; window position and size |
3095 | push esi |
3095 | push esi |
3096 | lea esi, [ecx + window_data + WDATA.box] |
3096 | lea esi, [ecx + window_data + WDATA.box] |
3097 | movsd |
3097 | movsd |
3098 | movsd |
3098 | movsd |
3099 | movsd |
3099 | movsd |
3100 | movsd |
3100 | movsd |
3101 | 3101 | ||
3102 | ; Process state (+50) |
3102 | ; Process state (+50) |
3103 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3103 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3104 | stosd |
3104 | stosd |
3105 | 3105 | ||
3106 | ; Window client area box |
3106 | ; Window client area box |
3107 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3107 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3108 | movsd |
3108 | movsd |
3109 | movsd |
3109 | movsd |
3110 | movsd |
3110 | movsd |
3111 | movsd |
3111 | movsd |
3112 | 3112 | ||
3113 | ; Window state |
3113 | ; Window state |
3114 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3114 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3115 | stosb |
3115 | stosb |
3116 | 3116 | ||
3117 | ; Event mask (+71) |
3117 | ; Event mask (+71) |
3118 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3118 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3119 | stosd |
3119 | stosd |
3120 | 3120 | ||
3121 | ; Keyboard mode (+75) |
3121 | ; Keyboard mode (+75) |
3122 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3122 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3123 | stosb |
3123 | stosb |
3124 | 3124 | ||
3125 | pop esi |
3125 | pop esi |
3126 | pop edi |
3126 | pop edi |
3127 | 3127 | ||
3128 | .nofillbuf: |
3128 | .nofillbuf: |
3129 | ; return number of processes |
3129 | ; return number of processes |
3130 | 3130 | ||
3131 | mov eax, [TASK_COUNT] |
3131 | mov eax, [TASK_COUNT] |
3132 | mov [esp+32], eax |
3132 | mov [esp+32], eax |
3133 | ret |
3133 | ret |
3134 | 3134 | ||
3135 | align 4 |
3135 | align 4 |
3136 | sys_clock: |
3136 | sys_clock: |
3137 | cli |
3137 | cli |
3138 | ; Mikhail Lisovin xx Jan 2005 |
3138 | ; Mikhail Lisovin xx Jan 2005 |
3139 | @@: |
3139 | @@: |
3140 | mov al, 10 |
3140 | mov al, 10 |
3141 | out 0x70, al |
3141 | out 0x70, al |
3142 | in al, 0x71 |
3142 | in al, 0x71 |
3143 | test al, al |
3143 | test al, al |
3144 | jns @f |
3144 | jns @f |
3145 | mov esi, 1 |
3145 | mov esi, 1 |
3146 | call delay_ms |
3146 | call delay_ms |
3147 | jmp @b |
3147 | jmp @b |
3148 | @@: |
3148 | @@: |
3149 | ; end Lisovin's fix |
3149 | ; end Lisovin's fix |
3150 | 3150 | ||
3151 | xor al, al ; seconds |
3151 | xor al, al ; seconds |
3152 | out 0x70, al |
3152 | out 0x70, al |
3153 | in al, 0x71 |
3153 | in al, 0x71 |
3154 | movzx ecx, al |
3154 | movzx ecx, al |
3155 | mov al, 02 ; minutes |
3155 | mov al, 02 ; minutes |
3156 | shl ecx, 16 |
3156 | shl ecx, 16 |
3157 | out 0x70, al |
3157 | out 0x70, al |
3158 | in al, 0x71 |
3158 | in al, 0x71 |
3159 | movzx edx, al |
3159 | movzx edx, al |
3160 | mov al, 04 ; hours |
3160 | mov al, 04 ; hours |
3161 | shl edx, 8 |
3161 | shl edx, 8 |
3162 | out 0x70, al |
3162 | out 0x70, al |
3163 | in al, 0x71 |
3163 | in al, 0x71 |
3164 | add ecx, edx |
3164 | add ecx, edx |
3165 | movzx edx, al |
3165 | movzx edx, al |
3166 | add ecx, edx |
3166 | add ecx, edx |
3167 | sti |
3167 | sti |
3168 | mov [esp + 32], ecx |
3168 | mov [esp + 32], ecx |
3169 | ret |
3169 | ret |
3170 | 3170 | ||
3171 | 3171 | ||
3172 | align 4 |
3172 | align 4 |
3173 | 3173 | ||
3174 | sys_date: |
3174 | sys_date: |
3175 | 3175 | ||
3176 | cli |
3176 | cli |
3177 | @@: |
3177 | @@: |
3178 | mov al, 10 |
3178 | mov al, 10 |
3179 | out 0x70, al |
3179 | out 0x70, al |
3180 | in al, 0x71 |
3180 | in al, 0x71 |
3181 | test al, al |
3181 | test al, al |
3182 | jns @f |
3182 | jns @f |
3183 | mov esi, 1 |
3183 | mov esi, 1 |
3184 | call delay_ms |
3184 | call delay_ms |
3185 | jmp @b |
3185 | jmp @b |
3186 | @@: |
3186 | @@: |
3187 | 3187 | ||
3188 | mov ch, 0 |
3188 | mov ch, 0 |
3189 | mov al, 7 ; date |
3189 | mov al, 7 ; date |
3190 | out 0x70, al |
3190 | out 0x70, al |
3191 | in al, 0x71 |
3191 | in al, 0x71 |
3192 | mov cl, al |
3192 | mov cl, al |
3193 | mov al, 8 ; month |
3193 | mov al, 8 ; month |
3194 | shl ecx, 16 |
3194 | shl ecx, 16 |
3195 | out 0x70, al |
3195 | out 0x70, al |
3196 | in al, 0x71 |
3196 | in al, 0x71 |
3197 | mov ch, al |
3197 | mov ch, al |
3198 | mov al, 9 ; year |
3198 | mov al, 9 ; year |
3199 | out 0x70, al |
3199 | out 0x70, al |
3200 | in al, 0x71 |
3200 | in al, 0x71 |
3201 | mov cl, al |
3201 | mov cl, al |
3202 | sti |
3202 | sti |
3203 | mov [esp+32], ecx |
3203 | mov [esp+32], ecx |
3204 | ret |
3204 | ret |
3205 | 3205 | ||
3206 | 3206 | ||
3207 | ; redraw status |
3207 | ; redraw status |
3208 | 3208 | ||
3209 | sys_redrawstat: |
3209 | sys_redrawstat: |
3210 | cmp ebx, 1 |
3210 | cmp ebx, 1 |
3211 | jne no_widgets_away |
3211 | jne no_widgets_away |
3212 | ; buttons away |
3212 | ; buttons away |
3213 | mov ecx, [CURRENT_TASK] |
3213 | mov ecx, [CURRENT_TASK] |
3214 | sys_newba2: |
3214 | sys_newba2: |
3215 | mov edi, [BTN_ADDR] |
3215 | mov edi, [BTN_ADDR] |
3216 | cmp [edi], dword 0 ; empty button list ? |
3216 | cmp [edi], dword 0 ; empty button list ? |
3217 | je end_of_buttons_away |
3217 | je end_of_buttons_away |
3218 | movzx ebx, word [edi] |
3218 | movzx ebx, word [edi] |
3219 | inc ebx |
3219 | inc ebx |
3220 | mov eax, edi |
3220 | mov eax, edi |
3221 | sys_newba: |
3221 | sys_newba: |
3222 | dec ebx |
3222 | dec ebx |
3223 | jz end_of_buttons_away |
3223 | jz end_of_buttons_away |
3224 | 3224 | ||
3225 | add eax, 0x10 |
3225 | add eax, 0x10 |
3226 | cmp cx, [eax] |
3226 | cmp cx, [eax] |
3227 | jnz sys_newba |
3227 | jnz sys_newba |
3228 | 3228 | ||
3229 | push eax ebx ecx |
3229 | push eax ebx ecx |
3230 | mov ecx, ebx |
3230 | mov ecx, ebx |
3231 | inc ecx |
3231 | inc ecx |
3232 | shl ecx, 4 |
3232 | shl ecx, 4 |
3233 | mov ebx, eax |
3233 | mov ebx, eax |
3234 | add eax, 0x10 |
3234 | add eax, 0x10 |
3235 | call memmove |
3235 | call memmove |
3236 | dec dword [edi] |
3236 | dec dword [edi] |
3237 | pop ecx ebx eax |
3237 | pop ecx ebx eax |
3238 | 3238 | ||
3239 | jmp sys_newba2 |
3239 | jmp sys_newba2 |
3240 | 3240 | ||
3241 | end_of_buttons_away: |
3241 | end_of_buttons_away: |
3242 | 3242 | ||
3243 | ret |
3243 | ret |
3244 | 3244 | ||
3245 | no_widgets_away: |
3245 | no_widgets_away: |
3246 | 3246 | ||
3247 | cmp ebx, 2 |
3247 | cmp ebx, 2 |
3248 | jnz srl1 |
3248 | jnz srl1 |
3249 | 3249 | ||
3250 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3250 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3251 | add edx, draw_data - CURRENT_TASK |
3251 | add edx, draw_data - CURRENT_TASK |
3252 | mov [edx + RECT.left], 0 |
3252 | mov [edx + RECT.left], 0 |
3253 | mov [edx + RECT.top], 0 |
3253 | mov [edx + RECT.top], 0 |
3254 | mov eax, [Screen_Max_X] |
3254 | mov eax, [Screen_Max_X] |
3255 | mov [edx + RECT.right], eax |
3255 | mov [edx + RECT.right], eax |
3256 | mov eax, [Screen_Max_Y] |
3256 | mov eax, [Screen_Max_Y] |
3257 | mov [edx + RECT.bottom], eax |
3257 | mov [edx + RECT.bottom], eax |
3258 | 3258 | ||
3259 | srl1: |
3259 | srl1: |
3260 | ret |
3260 | ret |
3261 | 3261 | ||
3262 | ;ok - 100% work |
3262 | ;ok - 100% work |
3263 | ;nt - not tested |
3263 | ;nt - not tested |
3264 | ;--------------------------------------------------------------------------------------------- |
3264 | ;--------------------------------------------------------------------------------------------- |
3265 | ;eax |
3265 | ;eax |
3266 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3266 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3267 | ;1 - change task. Ret nothing. Block. ok. |
3267 | ;1 - change task. Ret nothing. Block. ok. |
3268 | ;2 - performance control |
3268 | ;2 - performance control |
3269 | ; ebx |
3269 | ; ebx |
3270 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3270 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3271 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3271 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3272 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3272 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3273 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3273 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3274 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3274 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3275 | ;eax |
3275 | ;eax |
3276 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3276 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3277 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3277 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3278 | ;--------------------------------------------------------------------------------------------- |
3278 | ;--------------------------------------------------------------------------------------------- |
3279 | iglobal |
3279 | iglobal |
3280 | align 4 |
3280 | align 4 |
3281 | sheduler: |
3281 | sheduler: |
3282 | dd sys_sheduler.00 |
3282 | dd sys_sheduler.00 |
3283 | dd change_task |
3283 | dd change_task |
3284 | dd sys_sheduler.02 |
3284 | dd sys_sheduler.02 |
3285 | dd sys_sheduler.03 |
3285 | dd sys_sheduler.03 |
3286 | dd sys_sheduler.04 |
3286 | dd sys_sheduler.04 |
3287 | endg |
3287 | endg |
3288 | sys_sheduler: |
3288 | sys_sheduler: |
3289 | ;rewritten by |
3289 | ;rewritten by |
3290 | jmp dword [sheduler+ebx*4] |
3290 | jmp dword [sheduler+ebx*4] |
3291 | ;.shed_counter: |
3291 | ;.shed_counter: |
3292 | .00: |
3292 | .00: |
3293 | mov eax, [context_counter] |
3293 | mov eax, [context_counter] |
3294 | mov [esp+32], eax |
3294 | mov [esp+32], eax |
3295 | ret |
3295 | ret |
3296 | 3296 | ||
3297 | .02: |
3297 | .02: |
3298 | ;.perf_control: |
3298 | ;.perf_control: |
3299 | inc ebx ;before ebx=2, ebx=3 |
3299 | inc ebx ;before ebx=2, ebx=3 |
3300 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3300 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3301 | jz cache_disable |
3301 | jz cache_disable |
3302 | 3302 | ||
3303 | dec ebx ;ebx=2 |
3303 | dec ebx ;ebx=2 |
3304 | cmp ebx, ecx ; |
3304 | cmp ebx, ecx ; |
3305 | jz cache_enable ;if ecx=2 and ebx=2 |
3305 | jz cache_enable ;if ecx=2 and ebx=2 |
3306 | 3306 | ||
3307 | dec ebx ;ebx=1 |
3307 | dec ebx ;ebx=1 |
3308 | cmp ebx, ecx |
3308 | cmp ebx, ecx |
3309 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3309 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3310 | 3310 | ||
3311 | dec ebx |
3311 | dec ebx |
3312 | test ebx, ecx ;ebx=0 and ecx=0 |
3312 | test ebx, ecx ;ebx=0 and ecx=0 |
3313 | jz modify_pce ;if ecx=0 |
3313 | jz modify_pce ;if ecx=0 |
3314 | 3314 | ||
3315 | ret |
3315 | ret |
3316 | 3316 | ||
3317 | .03: |
3317 | .03: |
3318 | ;.rdmsr_instr: |
3318 | ;.rdmsr_instr: |
3319 | ;now counter in ecx |
3319 | ;now counter in ecx |
3320 | ;(edx:eax) esi:edi => edx:esi |
3320 | ;(edx:eax) esi:edi => edx:esi |
3321 | mov eax, esi |
3321 | mov eax, esi |
3322 | mov ecx, edx |
3322 | mov ecx, edx |
3323 | rdmsr |
3323 | rdmsr |
3324 | mov [esp+32], eax |
3324 | mov [esp+32], eax |
3325 | mov [esp+20], edx ;ret in ebx? |
3325 | mov [esp+20], edx ;ret in ebx? |
3326 | ret |
3326 | ret |
3327 | 3327 | ||
3328 | .04: |
3328 | .04: |
3329 | ;.wrmsr_instr: |
3329 | ;.wrmsr_instr: |
3330 | ;now counter in ecx |
3330 | ;now counter in ecx |
3331 | ;(edx:eax) esi:edi => edx:esi |
3331 | ;(edx:eax) esi:edi => edx:esi |
3332 | ; Fast Call MSR can't be destroy |
3332 | ; Fast Call MSR can't be destroy |
3333 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3333 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3334 | ; включаются/выключаются расширенные возможности |
3334 | ; включаются/выключаются расширенные возможности |
3335 | cmp edx, MSR_SYSENTER_CS |
3335 | cmp edx, MSR_SYSENTER_CS |
3336 | je @f |
3336 | je @f |
3337 | cmp edx, MSR_SYSENTER_ESP |
3337 | cmp edx, MSR_SYSENTER_ESP |
3338 | je @f |
3338 | je @f |
3339 | cmp edx, MSR_SYSENTER_EIP |
3339 | cmp edx, MSR_SYSENTER_EIP |
3340 | je @f |
3340 | je @f |
3341 | cmp edx, MSR_AMD_STAR |
3341 | cmp edx, MSR_AMD_STAR |
3342 | je @f |
3342 | je @f |
3343 | 3343 | ||
3344 | mov eax, esi |
3344 | mov eax, esi |
3345 | mov ecx, edx |
3345 | mov ecx, edx |
3346 | wrmsr |
3346 | wrmsr |
3347 | ; mov [esp + 32], eax |
3347 | ; mov [esp + 32], eax |
3348 | ; mov [esp + 20], edx ;ret in ebx? |
3348 | ; mov [esp + 20], edx ;ret in ebx? |
3349 | @@: |
3349 | @@: |
3350 | ret |
3350 | ret |
3351 | 3351 | ||
3352 | cache_disable: |
3352 | cache_disable: |
3353 | mov eax, cr0 |
3353 | mov eax, cr0 |
3354 | or eax, 01100000000000000000000000000000b |
3354 | or eax, 01100000000000000000000000000000b |
3355 | mov cr0, eax |
3355 | mov cr0, eax |
3356 | wbinvd ;set MESI |
3356 | wbinvd ;set MESI |
3357 | ret |
3357 | ret |
3358 | 3358 | ||
3359 | cache_enable: |
3359 | cache_enable: |
3360 | mov eax, cr0 |
3360 | mov eax, cr0 |
3361 | and eax, 10011111111111111111111111111111b |
3361 | and eax, 10011111111111111111111111111111b |
3362 | mov cr0, eax |
3362 | mov cr0, eax |
3363 | ret |
3363 | ret |
3364 | 3364 | ||
3365 | is_cache_enabled: |
3365 | is_cache_enabled: |
3366 | mov eax, cr0 |
3366 | mov eax, cr0 |
3367 | mov ebx, eax |
3367 | mov ebx, eax |
3368 | and eax, 01100000000000000000000000000000b |
3368 | and eax, 01100000000000000000000000000000b |
3369 | jz cache_disabled |
3369 | jz cache_disabled |
3370 | mov [esp+32], ebx |
3370 | mov [esp+32], ebx |
3371 | cache_disabled: |
3371 | cache_disabled: |
3372 | mov dword [esp+32], eax;0 |
3372 | mov dword [esp+32], eax;0 |
3373 | ret |
3373 | ret |
3374 | 3374 | ||
3375 | modify_pce: |
3375 | modify_pce: |
3376 | mov eax, cr4 |
3376 | mov eax, cr4 |
3377 | ; mov ebx,0 |
3377 | ; mov ebx,0 |
3378 | ; or bx,100000000b ;pce |
3378 | ; or bx,100000000b ;pce |
3379 | ; xor eax,ebx ;invert pce |
3379 | ; xor eax,ebx ;invert pce |
3380 | bts eax, 8;pce=cr4[8] |
3380 | bts eax, 8;pce=cr4[8] |
3381 | mov cr4, eax |
3381 | mov cr4, eax |
3382 | mov [esp+32], eax |
3382 | mov [esp+32], eax |
3383 | ret |
3383 | ret |
3384 | ;--------------------------------------------------------------------------------------------- |
3384 | ;--------------------------------------------------------------------------------------------- |
3385 | 3385 | ||
3386 | 3386 | ||
3387 | ; check if pixel is allowed to be drawn |
3387 | ; check if pixel is allowed to be drawn |
3388 | 3388 | ||
3389 | ;checkpixel: |
3389 | ;checkpixel: |
3390 | ; push eax edx |
3390 | ; push eax edx |
3391 | 3391 | ||
3392 | ;; mov edx, [Screen_Max_X] ; screen x size |
3392 | ;; mov edx, [Screen_Max_X] ; screen x size |
3393 | ;; inc edx |
3393 | ;; inc edx |
3394 | ;; imul edx, ebx |
3394 | ;; imul edx, ebx |
3395 | ; mov edx, [d_width_calc_area + ebx*4] |
3395 | ; mov edx, [d_width_calc_area + ebx*4] |
3396 | ; add eax, [_WinMapAddress] |
3396 | ; add eax, [_WinMapAddress] |
3397 | ; mov dl, [eax+edx]; lea eax, [...] |
3397 | ; mov dl, [eax+edx]; lea eax, [...] |
3398 | 3398 | ||
3399 | ; xor ecx, ecx |
3399 | ; xor ecx, ecx |
3400 | ; mov eax, [CURRENT_TASK] |
3400 | ; mov eax, [CURRENT_TASK] |
3401 | ; cmp al, dl |
3401 | ; cmp al, dl |
3402 | ; setne cl |
3402 | ; setne cl |
3403 | 3403 | ||
3404 | ; pop edx eax |
3404 | ; pop edx eax |
3405 | ; ret |
3405 | ; ret |
3406 | 3406 | ||
3407 | iglobal |
3407 | iglobal |
3408 | cpustring db 'CPU',0 |
3408 | cpustring db 'CPU',0 |
3409 | endg |
3409 | endg |
3410 | 3410 | ||
3411 | uglobal |
3411 | uglobal |
3412 | background_defined db 0 ; diamond, 11.04.2006 |
3412 | background_defined db 0 ; diamond, 11.04.2006 |
3413 | endg |
3413 | endg |
3414 | ;----------------------------------------------------------------------------- |
3414 | ;----------------------------------------------------------------------------- |
3415 | align 4 |
3415 | align 4 |
3416 | checkmisc: |
3416 | checkmisc: |
3417 | cmp [ctrl_alt_del], 1 |
3417 | cmp [ctrl_alt_del], 1 |
3418 | jne nocpustart |
3418 | jne nocpustart |
3419 | 3419 | ||
3420 | mov ebp, cpustring |
3420 | mov ebp, cpustring |
3421 | call fs_execute_from_sysdir |
3421 | call fs_execute_from_sysdir |
3422 | 3422 | ||
3423 | mov [ctrl_alt_del], 0 |
3423 | mov [ctrl_alt_del], 0 |
3424 | ;-------------------------------------- |
3424 | ;-------------------------------------- |
3425 | align 4 |
3425 | align 4 |
3426 | nocpustart: |
3426 | nocpustart: |
3427 | cmp [mouse_active], 1 |
3427 | cmp [mouse_active], 1 |
3428 | jne mouse_not_active |
3428 | jne mouse_not_active |
3429 | mov [mouse_active], 0 |
3429 | mov [mouse_active], 0 |
3430 | 3430 | ||
3431 | xor edi, edi |
3431 | xor edi, edi |
3432 | mov ebx, CURRENT_TASK |
3432 | mov ebx, CURRENT_TASK |
3433 | 3433 | ||
3434 | mov ecx, [TASK_COUNT] |
3434 | mov ecx, [TASK_COUNT] |
3435 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3435 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3436 | shl eax, 8 |
3436 | shl eax, 8 |
3437 | push eax |
3437 | push eax |
3438 | 3438 | ||
3439 | movzx eax, word [MOUSE_X] |
3439 | movzx eax, word [MOUSE_X] |
3440 | movzx edx, word [MOUSE_Y] |
3440 | movzx edx, word [MOUSE_Y] |
3441 | ;-------------------------------------- |
3441 | ;-------------------------------------- |
3442 | align 4 |
3442 | align 4 |
3443 | .set_mouse_event: |
3443 | .set_mouse_event: |
3444 | add edi, 256 |
3444 | add edi, 256 |
3445 | add ebx, 32 |
3445 | add ebx, 32 |
3446 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3446 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3447 | jz .pos_filter |
3447 | jz .pos_filter |
3448 | 3448 | ||
3449 | cmp edi, [esp] ; skip if filtration active |
3449 | cmp edi, [esp] ; skip if filtration active |
3450 | jne .skip |
3450 | jne .skip |
3451 | ;-------------------------------------- |
3451 | ;-------------------------------------- |
3452 | align 4 |
3452 | align 4 |
3453 | .pos_filter: |
3453 | .pos_filter: |
3454 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3454 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3455 | jz .set |
3455 | jz .set |
3456 | 3456 | ||
3457 | mov esi, [ebx-twdw+WDATA.box.left] |
3457 | mov esi, [ebx-twdw+WDATA.box.left] |
3458 | cmp eax, esi |
3458 | cmp eax, esi |
3459 | jb .skip |
3459 | jb .skip |
3460 | add esi, [ebx-twdw+WDATA.box.width] |
3460 | add esi, [ebx-twdw+WDATA.box.width] |
3461 | cmp eax, esi |
3461 | cmp eax, esi |
3462 | ja .skip |
3462 | ja .skip |
3463 | 3463 | ||
3464 | mov esi, [ebx-twdw+WDATA.box.top] |
3464 | mov esi, [ebx-twdw+WDATA.box.top] |
3465 | cmp edx, esi |
3465 | cmp edx, esi |
3466 | jb .skip |
3466 | jb .skip |
3467 | add esi, [ebx-twdw+WDATA.box.height] |
3467 | add esi, [ebx-twdw+WDATA.box.height] |
3468 | cmp edx, esi |
3468 | cmp edx, esi |
3469 | ja .skip |
3469 | ja .skip |
3470 | ;-------------------------------------- |
3470 | ;-------------------------------------- |
3471 | align 4 |
3471 | align 4 |
3472 | .set: |
3472 | .set: |
3473 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3473 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3474 | ;-------------------------------------- |
3474 | ;-------------------------------------- |
3475 | align 4 |
3475 | align 4 |
3476 | .skip: |
3476 | .skip: |
3477 | loop .set_mouse_event |
3477 | loop .set_mouse_event |
3478 | 3478 | ||
3479 | pop eax |
3479 | pop eax |
3480 | ;-------------------------------------- |
3480 | ;-------------------------------------- |
3481 | align 4 |
3481 | align 4 |
3482 | mouse_not_active: |
3482 | mouse_not_active: |
3483 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3483 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3484 | jz nobackgr |
3484 | jz nobackgr |
3485 | 3485 | ||
3486 | cmp [background_defined], 0 |
3486 | cmp [background_defined], 0 |
3487 | jz nobackgr |
3487 | jz nobackgr |
3488 | ;-------------------------------------- |
3488 | ;-------------------------------------- |
3489 | align 4 |
3489 | align 4 |
3490 | backgr: |
3490 | backgr: |
3491 | mov eax, [draw_data+32 + RECT.left] |
3491 | mov eax, [draw_data+32 + RECT.left] |
3492 | shl eax, 16 |
3492 | shl eax, 16 |
3493 | add eax, [draw_data+32 + RECT.right] |
3493 | add eax, [draw_data+32 + RECT.right] |
3494 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3494 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3495 | 3495 | ||
3496 | mov eax, [draw_data+32 + RECT.top] |
3496 | mov eax, [draw_data+32 + RECT.top] |
3497 | shl eax, 16 |
3497 | shl eax, 16 |
3498 | add eax, [draw_data+32 + RECT.bottom] |
3498 | add eax, [draw_data+32 + RECT.bottom] |
3499 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3499 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3500 | 3500 | ||
3501 | call drawbackground |
3501 | call drawbackground |
3502 | ; DEBUGF 1, "K : drawbackground\n" |
3502 | ; DEBUGF 1, "K : drawbackground\n" |
3503 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3503 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3504 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3504 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3505 | ;--------- set event 5 start ---------- |
3505 | ;--------- set event 5 start ---------- |
3506 | push ecx edi |
3506 | push ecx edi |
3507 | xor edi, edi |
3507 | xor edi, edi |
3508 | mov ecx, [TASK_COUNT] |
3508 | mov ecx, [TASK_COUNT] |
3509 | ;-------------------------------------- |
3509 | ;-------------------------------------- |
3510 | align 4 |
3510 | align 4 |
3511 | set_bgr_event: |
3511 | set_bgr_event: |
3512 | add edi, 256 |
3512 | add edi, 256 |
3513 | mov eax, [BG_Rect_X_left_right] |
3513 | mov eax, [BG_Rect_X_left_right] |
3514 | mov edx, [BG_Rect_Y_top_bottom] |
3514 | mov edx, [BG_Rect_Y_top_bottom] |
3515 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3515 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3516 | jz .set |
3516 | jz .set |
3517 | .join: |
3517 | .join: |
3518 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3518 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3519 | jae @f |
3519 | jae @f |
3520 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3520 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3521 | @@: |
3521 | @@: |
3522 | shr eax, 16 |
3522 | shr eax, 16 |
3523 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3523 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3524 | jbe @f |
3524 | jbe @f |
3525 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3525 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3526 | @@: |
3526 | @@: |
3527 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3527 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3528 | jae @f |
3528 | jae @f |
3529 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3529 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3530 | @@: |
3530 | @@: |
3531 | shr edx, 16 |
3531 | shr edx, 16 |
3532 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3532 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3533 | jbe @f |
3533 | jbe @f |
3534 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3534 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3535 | @@: |
3535 | @@: |
3536 | jmp .common |
3536 | jmp .common |
3537 | .set: |
3537 | .set: |
3538 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3538 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3539 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3539 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3540 | .common: |
3540 | .common: |
3541 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3541 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3542 | loop set_bgr_event |
3542 | loop set_bgr_event |
3543 | pop edi ecx |
3543 | pop edi ecx |
3544 | ;--------- set event 5 stop ----------- |
3544 | ;--------- set event 5 stop ----------- |
3545 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3545 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3546 | jnz backgr |
3546 | jnz backgr |
3547 | 3547 | ||
3548 | xor eax, eax |
3548 | xor eax, eax |
3549 | mov [draw_data+32 + RECT.left], eax |
3549 | mov [draw_data+32 + RECT.left], eax |
3550 | mov [draw_data+32 + RECT.top], eax |
3550 | mov [draw_data+32 + RECT.top], eax |
3551 | mov [draw_data+32 + RECT.right], eax |
3551 | mov [draw_data+32 + RECT.right], eax |
3552 | mov [draw_data+32 + RECT.bottom], eax |
3552 | mov [draw_data+32 + RECT.bottom], eax |
3553 | ;-------------------------------------- |
3553 | ;-------------------------------------- |
3554 | align 4 |
3554 | align 4 |
3555 | nobackgr: |
3555 | nobackgr: |
3556 | ; system shutdown request |
3556 | ; system shutdown request |
3557 | cmp [SYS_SHUTDOWN], byte 0 |
3557 | cmp [SYS_SHUTDOWN], byte 0 |
3558 | je noshutdown |
3558 | je noshutdown |
3559 | 3559 | ||
3560 | mov edx, [shutdown_processes] |
3560 | mov edx, [shutdown_processes] |
3561 | 3561 | ||
3562 | cmp [SYS_SHUTDOWN], dl |
3562 | cmp [SYS_SHUTDOWN], dl |
3563 | jne noshutdown |
3563 | jne noshutdown |
3564 | 3564 | ||
3565 | lea ecx, [edx-1] |
3565 | lea ecx, [edx-1] |
3566 | mov edx, OS_BASE+0x3040 |
3566 | mov edx, OS_BASE+0x3040 |
3567 | jecxz no_mark_system_shutdown |
3567 | jecxz no_mark_system_shutdown |
3568 | ;-------------------------------------- |
3568 | ;-------------------------------------- |
3569 | align 4 |
3569 | align 4 |
3570 | markz: |
3570 | markz: |
3571 | push ecx edx |
3571 | push ecx edx |
3572 | cmp [edx+TASKDATA.state], 9 |
3572 | cmp [edx+TASKDATA.state], 9 |
3573 | jz .nokill |
3573 | jz .nokill |
3574 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3574 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3575 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3575 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3576 | jz .nokill |
3576 | jz .nokill |
3577 | call request_terminate |
3577 | call request_terminate |
3578 | jmp .common |
3578 | jmp .common |
3579 | .nokill: |
3579 | .nokill: |
3580 | dec byte [SYS_SHUTDOWN] |
3580 | dec byte [SYS_SHUTDOWN] |
3581 | xor eax, eax |
3581 | xor eax, eax |
3582 | .common: |
3582 | .common: |
3583 | pop edx ecx |
3583 | pop edx ecx |
3584 | test eax, eax |
3584 | test eax, eax |
3585 | jz @f |
3585 | jz @f |
3586 | mov [edx+TASKDATA.state], byte 3 |
3586 | mov [edx+TASKDATA.state], byte 3 |
3587 | @@: |
3587 | @@: |
3588 | add edx, 0x20 |
3588 | add edx, 0x20 |
3589 | loop markz |
3589 | loop markz |
3590 | call wakeup_osloop |
3590 | call wakeup_osloop |
3591 | ;-------------------------------------- |
3591 | ;-------------------------------------- |
3592 | align 4 |
3592 | align 4 |
3593 | @@: |
3593 | @@: |
3594 | no_mark_system_shutdown: |
3594 | no_mark_system_shutdown: |
3595 | dec byte [SYS_SHUTDOWN] |
3595 | dec byte [SYS_SHUTDOWN] |
3596 | je system_shutdown |
3596 | je system_shutdown |
3597 | ;-------------------------------------- |
3597 | ;-------------------------------------- |
3598 | align 4 |
3598 | align 4 |
3599 | noshutdown: |
3599 | noshutdown: |
3600 | mov eax, [TASK_COUNT] ; termination |
3600 | mov eax, [TASK_COUNT] ; termination |
3601 | mov ebx, TASK_DATA+TASKDATA.state |
3601 | mov ebx, TASK_DATA+TASKDATA.state |
3602 | mov esi, 1 |
3602 | mov esi, 1 |
3603 | ;-------------------------------------- |
3603 | ;-------------------------------------- |
3604 | align 4 |
3604 | align 4 |
3605 | newct: |
3605 | newct: |
3606 | mov cl, [ebx] |
3606 | mov cl, [ebx] |
3607 | cmp cl, byte 3 |
3607 | cmp cl, byte 3 |
3608 | jz .terminate |
3608 | jz .terminate |
3609 | 3609 | ||
3610 | cmp cl, byte 4 |
3610 | cmp cl, byte 4 |
3611 | jnz .noterminate |
3611 | jnz .noterminate |
3612 | .terminate: |
3612 | .terminate: |
3613 | pushad |
3613 | pushad |
3614 | mov ecx, eax |
3614 | mov ecx, eax |
3615 | shl ecx, 8 |
3615 | shl ecx, 8 |
3616 | add ecx, SLOT_BASE |
3616 | add ecx, SLOT_BASE |
3617 | call restore_default_cursor_before_killing |
3617 | call restore_default_cursor_before_killing |
3618 | popad |
3618 | popad |
3619 | 3619 | ||
3620 | pushad |
3620 | pushad |
3621 | call terminate |
3621 | call terminate |
3622 | popad |
3622 | popad |
3623 | cmp byte [SYS_SHUTDOWN], 0 |
3623 | cmp byte [SYS_SHUTDOWN], 0 |
3624 | jz .noterminate |
3624 | jz .noterminate |
3625 | dec byte [SYS_SHUTDOWN] |
3625 | dec byte [SYS_SHUTDOWN] |
3626 | je system_shutdown |
3626 | je system_shutdown |
3627 | 3627 | ||
3628 | .noterminate: |
3628 | .noterminate: |
3629 | add ebx, 0x20 |
3629 | add ebx, 0x20 |
3630 | inc esi |
3630 | inc esi |
3631 | dec eax |
3631 | dec eax |
3632 | jnz newct |
3632 | jnz newct |
3633 | ret |
3633 | ret |
3634 | ;----------------------------------------------------------------------------- |
3634 | ;----------------------------------------------------------------------------- |
3635 | align 4 |
3635 | align 4 |
3636 | redrawscreen: |
3636 | redrawscreen: |
3637 | ; eax , if process window_data base is eax, do not set flag/limits |
3637 | ; eax , if process window_data base is eax, do not set flag/limits |
3638 | 3638 | ||
3639 | pushad |
3639 | pushad |
3640 | push eax |
3640 | push eax |
3641 | 3641 | ||
3642 | ;;; mov ebx,2 |
3642 | ;;; mov ebx,2 |
3643 | ;;; call delay_hs |
3643 | ;;; call delay_hs |
3644 | 3644 | ||
3645 | ;mov ecx,0 ; redraw flags for apps |
3645 | ;mov ecx,0 ; redraw flags for apps |
3646 | xor ecx, ecx |
3646 | xor ecx, ecx |
3647 | ;-------------------------------------- |
3647 | ;-------------------------------------- |
3648 | align 4 |
3648 | align 4 |
3649 | newdw2: |
3649 | newdw2: |
3650 | inc ecx |
3650 | inc ecx |
3651 | push ecx |
3651 | push ecx |
3652 | 3652 | ||
3653 | mov eax, ecx |
3653 | mov eax, ecx |
3654 | shl eax, 5 |
3654 | shl eax, 5 |
3655 | add eax, window_data |
3655 | add eax, window_data |
3656 | 3656 | ||
3657 | cmp eax, [esp+4] |
3657 | cmp eax, [esp+4] |
3658 | je not_this_task |
3658 | je not_this_task |
3659 | ; check if window in redraw area |
3659 | ; check if window in redraw area |
3660 | mov edi, eax |
3660 | mov edi, eax |
3661 | 3661 | ||
3662 | cmp ecx, 1 ; limit for background |
3662 | cmp ecx, 1 ; limit for background |
3663 | jz bgli |
3663 | jz bgli |
3664 | 3664 | ||
3665 | mov eax, [edi + WDATA.box.left] |
3665 | mov eax, [edi + WDATA.box.left] |
3666 | mov ebx, [edi + WDATA.box.top] |
3666 | mov ebx, [edi + WDATA.box.top] |
3667 | 3667 | ||
3668 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3668 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3669 | cmp ecx, ebx |
3669 | cmp ecx, ebx |
3670 | jb ricino |
3670 | jb ricino |
3671 | 3671 | ||
3672 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3672 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3673 | cmp ecx, eax |
3673 | cmp ecx, eax |
3674 | jb ricino |
3674 | jb ricino |
3675 | 3675 | ||
3676 | mov eax, [edi + WDATA.box.left] |
3676 | mov eax, [edi + WDATA.box.left] |
3677 | mov ebx, [edi + WDATA.box.top] |
3677 | mov ebx, [edi + WDATA.box.top] |
3678 | mov ecx, [edi + WDATA.box.width] |
3678 | mov ecx, [edi + WDATA.box.width] |
3679 | mov edx, [edi + WDATA.box.height] |
3679 | mov edx, [edi + WDATA.box.height] |
3680 | add ecx, eax |
3680 | add ecx, eax |
3681 | add edx, ebx |
3681 | add edx, ebx |
3682 | 3682 | ||
3683 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3683 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3684 | cmp edx, eax |
3684 | cmp edx, eax |
3685 | jb ricino |
3685 | jb ricino |
3686 | 3686 | ||
3687 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3687 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3688 | cmp ecx, eax |
3688 | cmp ecx, eax |
3689 | jb ricino |
3689 | jb ricino |
3690 | ;-------------------------------------- |
3690 | ;-------------------------------------- |
3691 | align 4 |
3691 | align 4 |
3692 | bgli: |
3692 | bgli: |
3693 | cmp dword[esp], 1 |
3693 | cmp dword[esp], 1 |
3694 | jnz .az |
3694 | jnz .az |
3695 | 3695 | ||
3696 | cmp byte[REDRAW_BACKGROUND], 0 |
3696 | cmp byte[REDRAW_BACKGROUND], 0 |
3697 | jz .az |
3697 | jz .az |
3698 | 3698 | ||
3699 | mov dl, 0 |
3699 | mov dl, 0 |
3700 | lea eax, [edi+draw_data-window_data] |
3700 | lea eax, [edi+draw_data-window_data] |
3701 | mov ebx, [draw_limits.left] |
3701 | mov ebx, [draw_limits.left] |
3702 | cmp ebx, [eax+RECT.left] |
3702 | cmp ebx, [eax+RECT.left] |
3703 | jae @f |
3703 | jae @f |
3704 | 3704 | ||
3705 | mov [eax+RECT.left], ebx |
3705 | mov [eax+RECT.left], ebx |
3706 | mov dl, 1 |
3706 | mov dl, 1 |
3707 | ;-------------------------------------- |
3707 | ;-------------------------------------- |
3708 | align 4 |
3708 | align 4 |
3709 | @@: |
3709 | @@: |
3710 | mov ebx, [draw_limits.top] |
3710 | mov ebx, [draw_limits.top] |
3711 | cmp ebx, [eax+RECT.top] |
3711 | cmp ebx, [eax+RECT.top] |
3712 | jae @f |
3712 | jae @f |
3713 | 3713 | ||
3714 | mov [eax+RECT.top], ebx |
3714 | mov [eax+RECT.top], ebx |
3715 | mov dl, 1 |
3715 | mov dl, 1 |
3716 | ;-------------------------------------- |
3716 | ;-------------------------------------- |
3717 | align 4 |
3717 | align 4 |
3718 | @@: |
3718 | @@: |
3719 | mov ebx, [draw_limits.right] |
3719 | mov ebx, [draw_limits.right] |
3720 | cmp ebx, [eax+RECT.right] |
3720 | cmp ebx, [eax+RECT.right] |
3721 | jbe @f |
3721 | jbe @f |
3722 | 3722 | ||
3723 | mov [eax+RECT.right], ebx |
3723 | mov [eax+RECT.right], ebx |
3724 | mov dl, 1 |
3724 | mov dl, 1 |
3725 | ;-------------------------------------- |
3725 | ;-------------------------------------- |
3726 | align 4 |
3726 | align 4 |
3727 | @@: |
3727 | @@: |
3728 | mov ebx, [draw_limits.bottom] |
3728 | mov ebx, [draw_limits.bottom] |
3729 | cmp ebx, [eax+RECT.bottom] |
3729 | cmp ebx, [eax+RECT.bottom] |
3730 | jbe @f |
3730 | jbe @f |
3731 | 3731 | ||
3732 | mov [eax+RECT.bottom], ebx |
3732 | mov [eax+RECT.bottom], ebx |
3733 | mov dl, 1 |
3733 | mov dl, 1 |
3734 | ;-------------------------------------- |
3734 | ;-------------------------------------- |
3735 | align 4 |
3735 | align 4 |
3736 | @@: |
3736 | @@: |
3737 | add byte[REDRAW_BACKGROUND], dl |
3737 | add byte[REDRAW_BACKGROUND], dl |
3738 | call wakeup_osloop |
3738 | call wakeup_osloop |
3739 | jmp newdw8 |
3739 | jmp newdw8 |
3740 | ;-------------------------------------- |
3740 | ;-------------------------------------- |
3741 | align 4 |
3741 | align 4 |
3742 | .az: |
3742 | .az: |
3743 | mov eax, edi |
3743 | mov eax, edi |
3744 | add eax, draw_data-window_data |
3744 | add eax, draw_data-window_data |
3745 | 3745 | ||
3746 | mov ebx, [draw_limits.left] ; set limits |
3746 | mov ebx, [draw_limits.left] ; set limits |
3747 | mov [eax + RECT.left], ebx |
3747 | mov [eax + RECT.left], ebx |
3748 | mov ebx, [draw_limits.top] |
3748 | mov ebx, [draw_limits.top] |
3749 | mov [eax + RECT.top], ebx |
3749 | mov [eax + RECT.top], ebx |
3750 | mov ebx, [draw_limits.right] |
3750 | mov ebx, [draw_limits.right] |
3751 | mov [eax + RECT.right], ebx |
3751 | mov [eax + RECT.right], ebx |
3752 | mov ebx, [draw_limits.bottom] |
3752 | mov ebx, [draw_limits.bottom] |
3753 | mov [eax + RECT.bottom], ebx |
3753 | mov [eax + RECT.bottom], ebx |
3754 | 3754 | ||
3755 | sub eax, draw_data-window_data |
3755 | sub eax, draw_data-window_data |
3756 | 3756 | ||
3757 | cmp dword [esp], 1 |
3757 | cmp dword [esp], 1 |
3758 | jne nobgrd |
3758 | jne nobgrd |
3759 | inc byte[REDRAW_BACKGROUND] |
3759 | inc byte[REDRAW_BACKGROUND] |
3760 | call wakeup_osloop |
3760 | call wakeup_osloop |
3761 | ;-------------------------------------- |
3761 | ;-------------------------------------- |
3762 | align 4 |
3762 | align 4 |
3763 | newdw8: |
3763 | newdw8: |
3764 | nobgrd: |
3764 | nobgrd: |
3765 | ;-------------------------------------- |
3765 | ;-------------------------------------- |
3766 | push eax edi ebp |
3766 | push eax edi ebp |
3767 | mov edi, [esp+12] |
3767 | mov edi, [esp+12] |
3768 | cmp edi, 1 |
3768 | cmp edi, 1 |
3769 | je .found |
3769 | je .found |
3770 | 3770 | ||
3771 | mov eax, [draw_limits.left] |
3771 | mov eax, [draw_limits.left] |
3772 | mov ebx, [draw_limits.top] |
3772 | mov ebx, [draw_limits.top] |
3773 | mov ecx, [draw_limits.right] |
3773 | mov ecx, [draw_limits.right] |
3774 | sub ecx, eax |
3774 | sub ecx, eax |
3775 | test ecx, ecx |
3775 | test ecx, ecx |
3776 | jz .not_found |
3776 | jz .not_found |
3777 | 3777 | ||
3778 | mov edx, [draw_limits.bottom] |
3778 | mov edx, [draw_limits.bottom] |
3779 | sub edx, ebx |
3779 | sub edx, ebx |
3780 | test edx, edx |
3780 | test edx, edx |
3781 | jz .not_found |
3781 | jz .not_found |
3782 | 3782 | ||
3783 | ; eax - x, ebx - y |
3783 | ; eax - x, ebx - y |
3784 | ; ecx - size x, edx - size y |
3784 | ; ecx - size x, edx - size y |
3785 | add ebx, edx |
3785 | add ebx, edx |
3786 | ;-------------------------------------- |
3786 | ;-------------------------------------- |
3787 | align 4 |
3787 | align 4 |
3788 | .start_y: |
3788 | .start_y: |
3789 | push ecx |
3789 | push ecx |
3790 | ;-------------------------------------- |
3790 | ;-------------------------------------- |
3791 | align 4 |
3791 | align 4 |
3792 | .start_x: |
3792 | .start_x: |
3793 | add eax, ecx |
3793 | add eax, ecx |
3794 | mov ebp, [d_width_calc_area + ebx*4] |
3794 | mov ebp, [d_width_calc_area + ebx*4] |
3795 | add ebp, [_WinMapAddress] |
3795 | add ebp, [_WinMapAddress] |
3796 | movzx ebp, byte[eax+ebp] ; get value for current point |
3796 | movzx ebp, byte[eax+ebp] ; get value for current point |
3797 | cmp ebp, edi |
3797 | cmp ebp, edi |
3798 | jne @f |
3798 | jne @f |
3799 | 3799 | ||
3800 | pop ecx |
3800 | pop ecx |
3801 | jmp .found |
3801 | jmp .found |
3802 | ;-------------------------------------- |
3802 | ;-------------------------------------- |
3803 | align 4 |
3803 | align 4 |
3804 | @@: |
3804 | @@: |
3805 | sub eax, ecx |
3805 | sub eax, ecx |
3806 | 3806 | ||
3807 | dec ecx |
3807 | dec ecx |
3808 | jnz .start_x |
3808 | jnz .start_x |
3809 | 3809 | ||
3810 | pop ecx |
3810 | pop ecx |
3811 | dec ebx |
3811 | dec ebx |
3812 | dec edx |
3812 | dec edx |
3813 | jnz .start_y |
3813 | jnz .start_y |
3814 | ;-------------------------------------- |
3814 | ;-------------------------------------- |
3815 | align 4 |
3815 | align 4 |
3816 | .not_found: |
3816 | .not_found: |
3817 | pop ebp edi eax |
3817 | pop ebp edi eax |
3818 | jmp ricino |
3818 | jmp ricino |
3819 | ;-------------------------------------- |
3819 | ;-------------------------------------- |
3820 | align 4 |
3820 | align 4 |
3821 | .found: |
3821 | .found: |
3822 | pop ebp edi eax |
3822 | pop ebp edi eax |
3823 | 3823 | ||
3824 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3824 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3825 | ;-------------------------------------- |
3825 | ;-------------------------------------- |
3826 | align 4 |
3826 | align 4 |
3827 | ricino: |
3827 | ricino: |
3828 | not_this_task: |
3828 | not_this_task: |
3829 | pop ecx |
3829 | pop ecx |
3830 | 3830 | ||
3831 | cmp ecx, [TASK_COUNT] |
3831 | cmp ecx, [TASK_COUNT] |
3832 | jle newdw2 |
3832 | jle newdw2 |
3833 | 3833 | ||
3834 | pop eax |
3834 | pop eax |
3835 | popad |
3835 | popad |
3836 | ret |
3836 | ret |
3837 | ;----------------------------------------------------------------------------- |
3837 | ;----------------------------------------------------------------------------- |
3838 | align 4 |
3838 | align 4 |
3839 | calculatebackground: ; background |
3839 | calculatebackground: ; background |
3840 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3840 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3841 | mov eax, 0x01010101 |
3841 | mov eax, 0x01010101 |
3842 | mov ecx, [_WinMapSize] |
3842 | mov ecx, [_WinMapSize] |
3843 | shr ecx, 2 |
3843 | shr ecx, 2 |
3844 | rep stosd |
3844 | rep stosd |
3845 | 3845 | ||
3846 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3846 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3847 | ret |
3847 | ret |
3848 | ;----------------------------------------------------------------------------- |
3848 | ;----------------------------------------------------------------------------- |
3849 | uglobal |
3849 | uglobal |
3850 | imax dd 0x0 |
3850 | imax dd 0x0 |
3851 | endg |
3851 | endg |
3852 | ;----------------------------------------------------------------------------- |
3852 | ;----------------------------------------------------------------------------- |
3853 | align 4 |
3853 | align 4 |
3854 | delay_ms: ; delay in 1/1000 sec |
3854 | delay_ms: ; delay in 1/1000 sec |
3855 | push eax |
3855 | push eax |
3856 | push ecx |
3856 | push ecx |
3857 | 3857 | ||
3858 | mov ecx, esi |
3858 | mov ecx, esi |
3859 | ; |
3859 | ; |
3860 | imul ecx, 33941 |
3860 | imul ecx, 33941 |
3861 | shr ecx, 9 |
3861 | shr ecx, 9 |
3862 | ; |
3862 | ; |
3863 | 3863 | ||
3864 | in al, 0x61 |
3864 | in al, 0x61 |
3865 | and al, 0x10 |
3865 | and al, 0x10 |
3866 | mov ah, al |
3866 | mov ah, al |
3867 | cld |
3867 | cld |
3868 | ;-------------------------------------- |
3868 | ;-------------------------------------- |
3869 | align 4 |
3869 | align 4 |
3870 | cnt1: |
3870 | cnt1: |
3871 | in al, 0x61 |
3871 | in al, 0x61 |
3872 | and al, 0x10 |
3872 | and al, 0x10 |
3873 | cmp al, ah |
3873 | cmp al, ah |
3874 | jz cnt1 |
3874 | jz cnt1 |
3875 | 3875 | ||
3876 | mov ah, al |
3876 | mov ah, al |
3877 | loop cnt1 |
3877 | loop cnt1 |
3878 | 3878 | ||
3879 | pop ecx |
3879 | pop ecx |
3880 | pop eax |
3880 | pop eax |
3881 | ret |
3881 | ret |
3882 | ;----------------------------------------------------------------------------- |
3882 | ;----------------------------------------------------------------------------- |
3883 | align 4 |
3883 | align 4 |
3884 | set_app_param: |
3884 | set_app_param: |
3885 | mov edi, [TASK_BASE] |
3885 | mov edi, [TASK_BASE] |
3886 | mov eax, ebx |
3886 | mov eax, ebx |
3887 | btr eax, 3 ; move MOUSE_FILTRATION |
3887 | btr eax, 3 ; move MOUSE_FILTRATION |
3888 | mov ebx, [current_slot] ; bit into event_filter |
3888 | mov ebx, [current_slot] ; bit into event_filter |
3889 | setc byte [ebx+APPDATA.event_filter] |
3889 | setc byte [ebx+APPDATA.event_filter] |
3890 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3890 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3891 | mov [esp+32], eax ; return old mask value |
3891 | mov [esp+32], eax ; return old mask value |
3892 | ret |
3892 | ret |
3893 | ;----------------------------------------------------------------------------- |
3893 | ;----------------------------------------------------------------------------- |
3894 | 3894 | ||
3895 | ; this is for syscall |
3895 | ; this is for syscall |
3896 | proc delay_hs_unprotected |
3896 | proc delay_hs_unprotected |
3897 | call unprotect_from_terminate |
3897 | call unprotect_from_terminate |
3898 | call delay_hs |
3898 | call delay_hs |
3899 | call protect_from_terminate |
3899 | call protect_from_terminate |
3900 | ret |
3900 | ret |
3901 | endp |
3901 | endp |
3902 | 3902 | ||
3903 | if 1 |
3903 | if 1 |
3904 | align 4 |
3904 | align 4 |
3905 | delay_hs: ; delay in 1/100 secs |
3905 | delay_hs: ; delay in 1/100 secs |
3906 | ; ebx = delay time |
3906 | ; ebx = delay time |
3907 | 3907 | ||
3908 | pushad |
3908 | pushad |
3909 | push ebx |
3909 | push ebx |
3910 | xor esi, esi |
3910 | xor esi, esi |
3911 | mov ecx, MANUAL_DESTROY |
3911 | mov ecx, MANUAL_DESTROY |
3912 | call create_event |
3912 | call create_event |
3913 | test eax, eax |
3913 | test eax, eax |
3914 | jz .done |
3914 | jz .done |
3915 | 3915 | ||
3916 | mov ebx, edx |
3916 | mov ebx, edx |
3917 | mov ecx, [esp] |
3917 | mov ecx, [esp] |
3918 | push edx |
3918 | push edx |
3919 | push eax |
3919 | push eax |
3920 | call wait_event_timeout |
3920 | call wait_event_timeout |
3921 | pop eax |
3921 | pop eax |
3922 | pop ebx |
3922 | pop ebx |
3923 | call destroy_event |
3923 | call destroy_event |
3924 | .done: |
3924 | .done: |
3925 | add esp, 4 |
3925 | add esp, 4 |
3926 | popad |
3926 | popad |
3927 | ret |
3927 | ret |
3928 | 3928 | ||
3929 | else |
3929 | else |
3930 | 3930 | ||
3931 | align 4 |
3931 | align 4 |
3932 | delay_hs: ; delay in 1/100 secs |
3932 | delay_hs: ; delay in 1/100 secs |
3933 | ; ebx = delay time |
3933 | ; ebx = delay time |
3934 | push ecx |
3934 | push ecx |
3935 | push edx |
3935 | push edx |
3936 | 3936 | ||
3937 | mov edx, [timer_ticks] |
3937 | mov edx, [timer_ticks] |
3938 | ;-------------------------------------- |
3938 | ;-------------------------------------- |
3939 | align 4 |
3939 | align 4 |
3940 | newtic: |
3940 | newtic: |
3941 | mov ecx, [timer_ticks] |
3941 | mov ecx, [timer_ticks] |
3942 | sub ecx, edx |
3942 | sub ecx, edx |
3943 | cmp ecx, ebx |
3943 | cmp ecx, ebx |
3944 | jae zerodelay |
3944 | jae zerodelay |
3945 | 3945 | ||
3946 | call change_task |
3946 | call change_task |
3947 | 3947 | ||
3948 | jmp newtic |
3948 | jmp newtic |
3949 | ;-------------------------------------- |
3949 | ;-------------------------------------- |
3950 | align 4 |
3950 | align 4 |
3951 | zerodelay: |
3951 | zerodelay: |
3952 | pop edx |
3952 | pop edx |
3953 | pop ecx |
3953 | pop ecx |
3954 | ret |
3954 | ret |
3955 | end if |
3955 | end if |
3956 | 3956 | ||
3957 | ;----------------------------------------------------------------------------- |
3957 | ;----------------------------------------------------------------------------- |
3958 | align 16 ;very often call this subrutine |
3958 | align 16 ;very often call this subrutine |
3959 | memmove: ; memory move in bytes |
3959 | memmove: ; memory move in bytes |
3960 | ; eax = from |
3960 | ; eax = from |
3961 | ; ebx = to |
3961 | ; ebx = to |
3962 | ; ecx = no of bytes |
3962 | ; ecx = no of bytes |
3963 | test ecx, ecx |
3963 | test ecx, ecx |
3964 | jle .ret |
3964 | jle .ret |
3965 | 3965 | ||
3966 | push esi edi ecx |
3966 | push esi edi ecx |
3967 | 3967 | ||
3968 | mov edi, ebx |
3968 | mov edi, ebx |
3969 | mov esi, eax |
3969 | mov esi, eax |
3970 | 3970 | ||
3971 | test ecx, not 11b |
3971 | test ecx, not 11b |
3972 | jz @f |
3972 | jz @f |
3973 | 3973 | ||
3974 | push ecx |
3974 | push ecx |
3975 | shr ecx, 2 |
3975 | shr ecx, 2 |
3976 | rep movsd |
3976 | rep movsd |
3977 | pop ecx |
3977 | pop ecx |
3978 | and ecx, 11b |
3978 | and ecx, 11b |
3979 | jz .finish |
3979 | jz .finish |
3980 | ;-------------------------------------- |
3980 | ;-------------------------------------- |
3981 | align 4 |
3981 | align 4 |
3982 | @@: |
3982 | @@: |
3983 | rep movsb |
3983 | rep movsb |
3984 | ;-------------------------------------- |
3984 | ;-------------------------------------- |
3985 | align 4 |
3985 | align 4 |
3986 | .finish: |
3986 | .finish: |
3987 | pop ecx edi esi |
3987 | pop ecx edi esi |
3988 | ;-------------------------------------- |
3988 | ;-------------------------------------- |
3989 | align 4 |
3989 | align 4 |
3990 | .ret: |
3990 | .ret: |
3991 | ret |
3991 | ret |
3992 | ;----------------------------------------------------------------------------- |
3992 | ;----------------------------------------------------------------------------- |
3993 | ; |
3993 | ; |
3994 | ;align 4 |
3994 | ;align 4 |
3995 | ; |
3995 | ; |
3996 | ;read_floppy_file: |
3996 | ;read_floppy_file: |
3997 | ; |
3997 | ; |
3998 | ;; as input |
3998 | ;; as input |
3999 | ;; |
3999 | ;; |
4000 | ;; eax pointer to file |
4000 | ;; eax pointer to file |
4001 | ;; ebx file lenght |
4001 | ;; ebx file lenght |
4002 | ;; ecx start 512 byte block number |
4002 | ;; ecx start 512 byte block number |
4003 | ;; edx number of blocks to read |
4003 | ;; edx number of blocks to read |
4004 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4004 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4005 | ;; |
4005 | ;; |
4006 | ;; |
4006 | ;; |
4007 | ;; on return |
4007 | ;; on return |
4008 | ;; |
4008 | ;; |
4009 | ;; eax = 0 command succesful |
4009 | ;; eax = 0 command succesful |
4010 | ;; 1 no fd base and/or partition defined |
4010 | ;; 1 no fd base and/or partition defined |
4011 | ;; 2 yet unsupported FS |
4011 | ;; 2 yet unsupported FS |
4012 | ;; 3 unknown FS |
4012 | ;; 3 unknown FS |
4013 | ;; 4 partition not defined at hd |
4013 | ;; 4 partition not defined at hd |
4014 | ;; 5 file not found |
4014 | ;; 5 file not found |
4015 | ;; ebx = size of file |
4015 | ;; ebx = size of file |
4016 | ; |
4016 | ; |
4017 | ; mov edi,[TASK_BASE] |
4017 | ; mov edi,[TASK_BASE] |
4018 | ; add edi,0x10 |
4018 | ; add edi,0x10 |
4019 | ; add esi,[edi] |
4019 | ; add esi,[edi] |
4020 | ; add eax,[edi] |
4020 | ; add eax,[edi] |
4021 | ; |
4021 | ; |
4022 | ; pushad |
4022 | ; pushad |
4023 | ; mov edi,esi |
4023 | ; mov edi,esi |
4024 | ; add edi,1024 |
4024 | ; add edi,1024 |
4025 | ; mov esi,0x100000+19*512 |
4025 | ; mov esi,0x100000+19*512 |
4026 | ; sub ecx,1 |
4026 | ; sub ecx,1 |
4027 | ; shl ecx,9 |
4027 | ; shl ecx,9 |
4028 | ; add esi,ecx |
4028 | ; add esi,ecx |
4029 | ; shl edx,9 |
4029 | ; shl edx,9 |
4030 | ; mov ecx,edx |
4030 | ; mov ecx,edx |
4031 | ; cld |
4031 | ; cld |
4032 | ; rep movsb |
4032 | ; rep movsb |
4033 | ; popad |
4033 | ; popad |
4034 | ; |
4034 | ; |
4035 | ; mov [esp+36],eax |
4035 | ; mov [esp+36],eax |
4036 | ; mov [esp+24],ebx |
4036 | ; mov [esp+24],ebx |
4037 | ; ret |
4037 | ; ret |
4038 | 4038 | ||
4039 | 4039 | ||
4040 | 4040 | ||
4041 | align 4 |
4041 | align 4 |
4042 | set_io_access_rights: |
4042 | set_io_access_rights: |
4043 | push edi eax |
4043 | push edi eax |
4044 | mov edi, tss._io_map_0 |
4044 | mov edi, tss._io_map_0 |
4045 | ; mov ecx,eax |
4045 | ; mov ecx,eax |
4046 | ; and ecx,7 ; offset in byte |
4046 | ; and ecx,7 ; offset in byte |
4047 | ; shr eax,3 ; number of byte |
4047 | ; shr eax,3 ; number of byte |
4048 | ; add edi,eax |
4048 | ; add edi,eax |
4049 | ; mov ebx,1 |
4049 | ; mov ebx,1 |
4050 | ; shl ebx,cl |
4050 | ; shl ebx,cl |
4051 | test ebp, ebp |
4051 | test ebp, ebp |
4052 | ; cmp ebp,0 ; enable access - ebp = 0 |
4052 | ; cmp ebp,0 ; enable access - ebp = 0 |
4053 | jnz .siar1 |
4053 | jnz .siar1 |
4054 | ; not ebx |
4054 | ; not ebx |
4055 | ; and [edi],byte bl |
4055 | ; and [edi],byte bl |
4056 | btr [edi], eax |
4056 | btr [edi], eax |
4057 | pop eax edi |
4057 | pop eax edi |
4058 | ret |
4058 | ret |
4059 | .siar1: |
4059 | .siar1: |
4060 | bts [edi], eax |
4060 | bts [edi], eax |
4061 | ; or [edi],byte bl ; disable access - ebp = 1 |
4061 | ; or [edi],byte bl ; disable access - ebp = 1 |
4062 | pop eax edi |
4062 | pop eax edi |
4063 | ret |
4063 | ret |
4064 | ;reserve/free group of ports |
4064 | ;reserve/free group of ports |
4065 | ; * eax = 46 - number function |
4065 | ; * eax = 46 - number function |
4066 | ; * ebx = 0 - reserve, 1 - free |
4066 | ; * ebx = 0 - reserve, 1 - free |
4067 | ; * ecx = number start arrea of ports |
4067 | ; * ecx = number start arrea of ports |
4068 | ; * edx = number end arrea of ports (include last number of port) |
4068 | ; * edx = number end arrea of ports (include last number of port) |
4069 | ;Return value: |
4069 | ;Return value: |
4070 | ; * eax = 0 - succesful |
4070 | ; * eax = 0 - succesful |
4071 | ; * eax = 1 - error |
4071 | ; * eax = 1 - error |
4072 | ; * The system has reserve this ports: |
4072 | ; * The system has reserve this ports: |
4073 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4073 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4074 | ;destroys eax,ebx, ebp |
4074 | ;destroys eax,ebx, ebp |
4075 | r_f_port_area: |
4075 | r_f_port_area: |
4076 | 4076 | ||
4077 | test ebx, ebx |
4077 | test ebx, ebx |
4078 | jnz free_port_area |
4078 | jnz free_port_area |
4079 | ; je r_port_area |
4079 | ; je r_port_area |
4080 | ; jmp free_port_area |
4080 | ; jmp free_port_area |
4081 | 4081 | ||
4082 | ; r_port_area: |
4082 | ; r_port_area: |
4083 | 4083 | ||
4084 | ; pushad |
4084 | ; pushad |
4085 | 4085 | ||
4086 | cmp ecx, edx ; beginning > end ? |
4086 | cmp ecx, edx ; beginning > end ? |
4087 | ja rpal1 |
4087 | ja rpal1 |
4088 | cmp edx, 65536 |
4088 | cmp edx, 65536 |
4089 | jae rpal1 |
4089 | jae rpal1 |
4090 | mov eax, [RESERVED_PORTS] |
4090 | mov eax, [RESERVED_PORTS] |
4091 | test eax, eax ; no reserved areas ? |
4091 | test eax, eax ; no reserved areas ? |
4092 | je rpal2 |
4092 | je rpal2 |
4093 | cmp eax, 255 ; max reserved |
4093 | cmp eax, 255 ; max reserved |
4094 | jae rpal1 |
4094 | jae rpal1 |
4095 | rpal3: |
4095 | rpal3: |
4096 | mov ebx, eax |
4096 | mov ebx, eax |
4097 | shl ebx, 4 |
4097 | shl ebx, 4 |
4098 | add ebx, RESERVED_PORTS |
4098 | add ebx, RESERVED_PORTS |
4099 | cmp ecx, [ebx+8] |
4099 | cmp ecx, [ebx+8] |
4100 | ja rpal4 |
4100 | ja rpal4 |
4101 | cmp edx, [ebx+4] |
4101 | cmp edx, [ebx+4] |
4102 | jae rpal1 |
4102 | jae rpal1 |
4103 | ; jb rpal4 |
4103 | ; jb rpal4 |
4104 | ; jmp rpal1 |
4104 | ; jmp rpal1 |
4105 | rpal4: |
4105 | rpal4: |
4106 | dec eax |
4106 | dec eax |
4107 | jnz rpal3 |
4107 | jnz rpal3 |
4108 | jmp rpal2 |
4108 | jmp rpal2 |
4109 | rpal1: |
4109 | rpal1: |
4110 | ; popad |
4110 | ; popad |
4111 | ; mov eax,1 |
4111 | ; mov eax,1 |
4112 | xor eax, eax |
4112 | xor eax, eax |
4113 | inc eax |
4113 | inc eax |
4114 | ret |
4114 | ret |
4115 | rpal2: |
4115 | rpal2: |
4116 | ; popad |
4116 | ; popad |
4117 | ; enable port access at port IO map |
4117 | ; enable port access at port IO map |
4118 | cli |
4118 | cli |
4119 | pushad ; start enable io map |
4119 | pushad ; start enable io map |
4120 | 4120 | ||
4121 | cmp edx, 65536;16384 |
4121 | cmp edx, 65536;16384 |
4122 | jae no_unmask_io; jge |
4122 | jae no_unmask_io; jge |
4123 | mov eax, ecx |
4123 | mov eax, ecx |
4124 | ; push ebp |
4124 | ; push ebp |
4125 | xor ebp, ebp ; enable - eax = port |
4125 | xor ebp, ebp ; enable - eax = port |
4126 | new_port_access: |
4126 | new_port_access: |
4127 | ; pushad |
4127 | ; pushad |
4128 | call set_io_access_rights |
4128 | call set_io_access_rights |
4129 | ; popad |
4129 | ; popad |
4130 | inc eax |
4130 | inc eax |
4131 | cmp eax, edx |
4131 | cmp eax, edx |
4132 | jbe new_port_access |
4132 | jbe new_port_access |
4133 | ; pop ebp |
4133 | ; pop ebp |
4134 | no_unmask_io: |
4134 | no_unmask_io: |
4135 | popad ; end enable io map |
4135 | popad ; end enable io map |
4136 | sti |
4136 | sti |
4137 | 4137 | ||
4138 | mov eax, [RESERVED_PORTS] |
4138 | mov eax, [RESERVED_PORTS] |
4139 | add eax, 1 |
4139 | add eax, 1 |
4140 | mov [RESERVED_PORTS], eax |
4140 | mov [RESERVED_PORTS], eax |
4141 | shl eax, 4 |
4141 | shl eax, 4 |
4142 | add eax, RESERVED_PORTS |
4142 | add eax, RESERVED_PORTS |
4143 | mov ebx, [TASK_BASE] |
4143 | mov ebx, [TASK_BASE] |
4144 | mov ebx, [ebx+TASKDATA.pid] |
4144 | mov ebx, [ebx+TASKDATA.pid] |
4145 | mov [eax], ebx |
4145 | mov [eax], ebx |
4146 | mov [eax+4], ecx |
4146 | mov [eax+4], ecx |
4147 | mov [eax+8], edx |
4147 | mov [eax+8], edx |
4148 | 4148 | ||
4149 | xor eax, eax |
4149 | xor eax, eax |
4150 | ret |
4150 | ret |
4151 | 4151 | ||
4152 | free_port_area: |
4152 | free_port_area: |
4153 | 4153 | ||
4154 | ; pushad |
4154 | ; pushad |
4155 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4155 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4156 | test eax, eax |
4156 | test eax, eax |
4157 | jz frpal2 |
4157 | jz frpal2 |
4158 | mov ebx, [TASK_BASE] |
4158 | mov ebx, [TASK_BASE] |
4159 | mov ebx, [ebx+TASKDATA.pid] |
4159 | mov ebx, [ebx+TASKDATA.pid] |
4160 | frpal3: |
4160 | frpal3: |
4161 | mov edi, eax |
4161 | mov edi, eax |
4162 | shl edi, 4 |
4162 | shl edi, 4 |
4163 | add edi, RESERVED_PORTS |
4163 | add edi, RESERVED_PORTS |
4164 | cmp ebx, [edi] |
4164 | cmp ebx, [edi] |
4165 | jne frpal4 |
4165 | jne frpal4 |
4166 | cmp ecx, [edi+4] |
4166 | cmp ecx, [edi+4] |
4167 | jne frpal4 |
4167 | jne frpal4 |
4168 | cmp edx, [edi+8] |
4168 | cmp edx, [edi+8] |
4169 | jne frpal4 |
4169 | jne frpal4 |
4170 | jmp frpal1 |
4170 | jmp frpal1 |
4171 | frpal4: |
4171 | frpal4: |
4172 | dec eax |
4172 | dec eax |
4173 | jnz frpal3 |
4173 | jnz frpal3 |
4174 | frpal2: |
4174 | frpal2: |
4175 | ; popad |
4175 | ; popad |
4176 | inc eax |
4176 | inc eax |
4177 | ret |
4177 | ret |
4178 | frpal1: |
4178 | frpal1: |
4179 | push ecx |
4179 | push ecx |
4180 | mov ecx, 256 |
4180 | mov ecx, 256 |
4181 | sub ecx, eax |
4181 | sub ecx, eax |
4182 | shl ecx, 4 |
4182 | shl ecx, 4 |
4183 | mov esi, edi |
4183 | mov esi, edi |
4184 | add esi, 16 |
4184 | add esi, 16 |
4185 | cld |
4185 | cld |
4186 | rep movsb |
4186 | rep movsb |
4187 | 4187 | ||
4188 | dec dword [RESERVED_PORTS] |
4188 | dec dword [RESERVED_PORTS] |
4189 | ;popad |
4189 | ;popad |
4190 | ;disable port access at port IO map |
4190 | ;disable port access at port IO map |
4191 | 4191 | ||
4192 | ; pushad ; start disable io map |
4192 | ; pushad ; start disable io map |
4193 | pop eax ;start port |
4193 | pop eax ;start port |
4194 | cmp edx, 65536;16384 |
4194 | cmp edx, 65536;16384 |
4195 | jge no_mask_io |
4195 | jge no_mask_io |
4196 | 4196 | ||
4197 | ; mov eax,ecx |
4197 | ; mov eax,ecx |
4198 | xor ebp, ebp |
4198 | xor ebp, ebp |
4199 | inc ebp |
4199 | inc ebp |
4200 | new_port_access_disable: |
4200 | new_port_access_disable: |
4201 | ; pushad |
4201 | ; pushad |
4202 | ; mov ebp,1 ; disable - eax = port |
4202 | ; mov ebp,1 ; disable - eax = port |
4203 | call set_io_access_rights |
4203 | call set_io_access_rights |
4204 | ; popad |
4204 | ; popad |
4205 | inc eax |
4205 | inc eax |
4206 | cmp eax, edx |
4206 | cmp eax, edx |
4207 | jbe new_port_access_disable |
4207 | jbe new_port_access_disable |
4208 | no_mask_io: |
4208 | no_mask_io: |
4209 | ; popad ; end disable io map |
4209 | ; popad ; end disable io map |
4210 | xor eax, eax |
4210 | xor eax, eax |
4211 | ret |
4211 | ret |
4212 | ;----------------------------------------------------------------------------- |
4212 | ;----------------------------------------------------------------------------- |
4213 | align 4 |
4213 | align 4 |
4214 | drawbackground: |
4214 | drawbackground: |
4215 | dbrv20: |
4215 | dbrv20: |
4216 | cmp [BgrDrawMode], dword 1 |
4216 | cmp [BgrDrawMode], dword 1 |
4217 | jne bgrstr |
4217 | jne bgrstr |
4218 | call vesa20_drawbackground_tiled |
4218 | call vesa20_drawbackground_tiled |
4219 | ; call [draw_pointer] |
4219 | ; call [draw_pointer] |
4220 | call __sys_draw_pointer |
4220 | call __sys_draw_pointer |
4221 | ret |
4221 | ret |
4222 | ;-------------------------------------- |
4222 | ;-------------------------------------- |
4223 | align 4 |
4223 | align 4 |
4224 | bgrstr: |
4224 | bgrstr: |
4225 | call vesa20_drawbackground_stretch |
4225 | call vesa20_drawbackground_stretch |
4226 | ; call [draw_pointer] |
4226 | ; call [draw_pointer] |
4227 | call __sys_draw_pointer |
4227 | call __sys_draw_pointer |
4228 | ret |
4228 | ret |
4229 | ;----------------------------------------------------------------------------- |
4229 | ;----------------------------------------------------------------------------- |
4230 | align 4 |
4230 | align 4 |
4231 | syscall_putimage: ; PutImage |
4231 | syscall_putimage: ; PutImage |
4232 | sys_putimage: |
4232 | sys_putimage: |
4233 | test ecx, 0x80008000 |
4233 | test ecx, 0x80008000 |
4234 | jnz .exit |
4234 | jnz .exit |
4235 | test ecx, 0x0000FFFF |
4235 | test ecx, 0x0000FFFF |
4236 | jz .exit |
4236 | jz .exit |
4237 | test ecx, 0xFFFF0000 |
4237 | test ecx, 0xFFFF0000 |
4238 | jnz @f |
4238 | jnz @f |
4239 | ;-------------------------------------- |
4239 | ;-------------------------------------- |
4240 | align 4 |
4240 | align 4 |
4241 | .exit: |
4241 | .exit: |
4242 | ret |
4242 | ret |
4243 | ;-------------------------------------- |
4243 | ;-------------------------------------- |
4244 | align 4 |
4244 | align 4 |
4245 | @@: |
4245 | @@: |
4246 | mov edi, [current_slot] |
4246 | mov edi, [current_slot] |
4247 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4247 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4248 | rol edx, 16 |
4248 | rol edx, 16 |
4249 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4249 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4250 | rol edx, 16 |
4250 | rol edx, 16 |
4251 | ;-------------------------------------- |
4251 | ;-------------------------------------- |
4252 | align 4 |
4252 | align 4 |
4253 | .forced: |
4253 | .forced: |
4254 | push ebp esi 0 |
4254 | push ebp esi 0 |
4255 | mov ebp, putimage_get24bpp |
4255 | mov ebp, putimage_get24bpp |
4256 | mov esi, putimage_init24bpp |
4256 | mov esi, putimage_init24bpp |
4257 | ;-------------------------------------- |
4257 | ;-------------------------------------- |
4258 | align 4 |
4258 | align 4 |
4259 | sys_putimage_bpp: |
4259 | sys_putimage_bpp: |
4260 | call vesa20_putimage |
4260 | call vesa20_putimage |
4261 | pop ebp esi ebp |
4261 | pop ebp esi ebp |
4262 | ret |
4262 | ret |
4263 | ; jmp [draw_pointer] |
4263 | ; jmp [draw_pointer] |
4264 | ;----------------------------------------------------------------------------- |
4264 | ;----------------------------------------------------------------------------- |
4265 | align 4 |
4265 | align 4 |
4266 | sys_putimage_palette: |
4266 | sys_putimage_palette: |
4267 | ; ebx = pointer to image |
4267 | ; ebx = pointer to image |
4268 | ; ecx = [xsize]*65536 + [ysize] |
4268 | ; ecx = [xsize]*65536 + [ysize] |
4269 | ; edx = [xstart]*65536 + [ystart] |
4269 | ; edx = [xstart]*65536 + [ystart] |
4270 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4270 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4271 | ; edi = pointer to palette |
4271 | ; edi = pointer to palette |
4272 | ; ebp = row delta |
4272 | ; ebp = row delta |
4273 | mov eax, [CURRENT_TASK] |
4273 | mov eax, [CURRENT_TASK] |
4274 | shl eax, 8 |
4274 | shl eax, 8 |
4275 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4275 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4276 | rol edx, 16 |
4276 | rol edx, 16 |
4277 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4277 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4278 | rol edx, 16 |
4278 | rol edx, 16 |
4279 | ;-------------------------------------- |
4279 | ;-------------------------------------- |
4280 | align 4 |
4280 | align 4 |
4281 | .forced: |
4281 | .forced: |
4282 | cmp esi, 1 |
4282 | cmp esi, 1 |
4283 | jnz @f |
4283 | jnz @f |
4284 | push edi |
4284 | push edi |
4285 | mov eax, [edi+4] |
4285 | mov eax, [edi+4] |
4286 | sub eax, [edi] |
4286 | sub eax, [edi] |
4287 | push eax |
4287 | push eax |
4288 | push dword [edi] |
4288 | push dword [edi] |
4289 | push 0ffffff80h |
4289 | push 0ffffff80h |
4290 | mov edi, esp |
4290 | mov edi, esp |
4291 | call put_mono_image |
4291 | call put_mono_image |
4292 | add esp, 12 |
4292 | add esp, 12 |
4293 | pop edi |
4293 | pop edi |
4294 | ret |
4294 | ret |
4295 | ;-------------------------------------- |
4295 | ;-------------------------------------- |
4296 | align 4 |
4296 | align 4 |
4297 | @@: |
4297 | @@: |
4298 | cmp esi, 2 |
4298 | cmp esi, 2 |
4299 | jnz @f |
4299 | jnz @f |
4300 | push edi |
4300 | push edi |
4301 | push 0ffffff80h |
4301 | push 0ffffff80h |
4302 | mov edi, esp |
4302 | mov edi, esp |
4303 | call put_2bit_image |
4303 | call put_2bit_image |
4304 | pop eax |
4304 | pop eax |
4305 | pop edi |
4305 | pop edi |
4306 | ret |
4306 | ret |
4307 | ;-------------------------------------- |
4307 | ;-------------------------------------- |
4308 | align 4 |
4308 | align 4 |
4309 | @@: |
4309 | @@: |
4310 | cmp esi, 4 |
4310 | cmp esi, 4 |
4311 | jnz @f |
4311 | jnz @f |
4312 | push edi |
4312 | push edi |
4313 | push 0ffffff80h |
4313 | push 0ffffff80h |
4314 | mov edi, esp |
4314 | mov edi, esp |
4315 | call put_4bit_image |
4315 | call put_4bit_image |
4316 | pop eax |
4316 | pop eax |
4317 | pop edi |
4317 | pop edi |
4318 | ret |
4318 | ret |
4319 | ;-------------------------------------- |
4319 | ;-------------------------------------- |
4320 | align 4 |
4320 | align 4 |
4321 | @@: |
4321 | @@: |
4322 | push ebp esi ebp |
4322 | push ebp esi ebp |
4323 | cmp esi, 8 |
4323 | cmp esi, 8 |
4324 | jnz @f |
4324 | jnz @f |
4325 | mov ebp, putimage_get8bpp |
4325 | mov ebp, putimage_get8bpp |
4326 | mov esi, putimage_init8bpp |
4326 | mov esi, putimage_init8bpp |
4327 | jmp sys_putimage_bpp |
4327 | jmp sys_putimage_bpp |
4328 | ;-------------------------------------- |
4328 | ;-------------------------------------- |
4329 | align 4 |
4329 | align 4 |
4330 | @@: |
4330 | @@: |
4331 | cmp esi, 9 |
4331 | cmp esi, 9 |
4332 | jnz @f |
4332 | jnz @f |
4333 | mov ebp, putimage_get9bpp |
4333 | mov ebp, putimage_get9bpp |
4334 | mov esi, putimage_init9bpp |
4334 | mov esi, putimage_init9bpp |
4335 | jmp sys_putimage_bpp |
4335 | jmp sys_putimage_bpp |
4336 | ;-------------------------------------- |
4336 | ;-------------------------------------- |
4337 | align 4 |
4337 | align 4 |
4338 | @@: |
4338 | @@: |
4339 | cmp esi, 15 |
4339 | cmp esi, 15 |
4340 | jnz @f |
4340 | jnz @f |
4341 | mov ebp, putimage_get15bpp |
4341 | mov ebp, putimage_get15bpp |
4342 | mov esi, putimage_init15bpp |
4342 | mov esi, putimage_init15bpp |
4343 | jmp sys_putimage_bpp |
4343 | jmp sys_putimage_bpp |
4344 | ;-------------------------------------- |
4344 | ;-------------------------------------- |
4345 | align 4 |
4345 | align 4 |
4346 | @@: |
4346 | @@: |
4347 | cmp esi, 16 |
4347 | cmp esi, 16 |
4348 | jnz @f |
4348 | jnz @f |
4349 | mov ebp, putimage_get16bpp |
4349 | mov ebp, putimage_get16bpp |
4350 | mov esi, putimage_init16bpp |
4350 | mov esi, putimage_init16bpp |
4351 | jmp sys_putimage_bpp |
4351 | jmp sys_putimage_bpp |
4352 | ;-------------------------------------- |
4352 | ;-------------------------------------- |
4353 | align 4 |
4353 | align 4 |
4354 | @@: |
4354 | @@: |
4355 | cmp esi, 24 |
4355 | cmp esi, 24 |
4356 | jnz @f |
4356 | jnz @f |
4357 | mov ebp, putimage_get24bpp |
4357 | mov ebp, putimage_get24bpp |
4358 | mov esi, putimage_init24bpp |
4358 | mov esi, putimage_init24bpp |
4359 | jmp sys_putimage_bpp |
4359 | jmp sys_putimage_bpp |
4360 | ;-------------------------------------- |
4360 | ;-------------------------------------- |
4361 | align 4 |
4361 | align 4 |
4362 | @@: |
4362 | @@: |
4363 | cmp esi, 32 |
4363 | cmp esi, 32 |
4364 | jnz @f |
4364 | jnz @f |
4365 | mov ebp, putimage_get32bpp |
4365 | mov ebp, putimage_get32bpp |
4366 | mov esi, putimage_init32bpp |
4366 | mov esi, putimage_init32bpp |
4367 | jmp sys_putimage_bpp |
4367 | jmp sys_putimage_bpp |
4368 | ;-------------------------------------- |
4368 | ;-------------------------------------- |
4369 | align 4 |
4369 | align 4 |
4370 | @@: |
4370 | @@: |
4371 | pop ebp esi ebp |
4371 | pop ebp esi ebp |
4372 | ret |
4372 | ret |
4373 | ;----------------------------------------------------------------------------- |
4373 | ;----------------------------------------------------------------------------- |
4374 | align 4 |
4374 | align 4 |
4375 | put_mono_image: |
4375 | put_mono_image: |
4376 | push ebp esi ebp |
4376 | push ebp esi ebp |
4377 | mov ebp, putimage_get1bpp |
4377 | mov ebp, putimage_get1bpp |
4378 | mov esi, putimage_init1bpp |
4378 | mov esi, putimage_init1bpp |
4379 | jmp sys_putimage_bpp |
4379 | jmp sys_putimage_bpp |
4380 | ;----------------------------------------------------------------------------- |
4380 | ;----------------------------------------------------------------------------- |
4381 | align 4 |
4381 | align 4 |
4382 | put_2bit_image: |
4382 | put_2bit_image: |
4383 | push ebp esi ebp |
4383 | push ebp esi ebp |
4384 | mov ebp, putimage_get2bpp |
4384 | mov ebp, putimage_get2bpp |
4385 | mov esi, putimage_init2bpp |
4385 | mov esi, putimage_init2bpp |
4386 | jmp sys_putimage_bpp |
4386 | jmp sys_putimage_bpp |
4387 | ;----------------------------------------------------------------------------- |
4387 | ;----------------------------------------------------------------------------- |
4388 | align 4 |
4388 | align 4 |
4389 | put_4bit_image: |
4389 | put_4bit_image: |
4390 | push ebp esi ebp |
4390 | push ebp esi ebp |
4391 | mov ebp, putimage_get4bpp |
4391 | mov ebp, putimage_get4bpp |
4392 | mov esi, putimage_init4bpp |
4392 | mov esi, putimage_init4bpp |
4393 | jmp sys_putimage_bpp |
4393 | jmp sys_putimage_bpp |
4394 | ;----------------------------------------------------------------------------- |
4394 | ;----------------------------------------------------------------------------- |
4395 | align 4 |
4395 | align 4 |
4396 | putimage_init24bpp: |
4396 | putimage_init24bpp: |
4397 | lea eax, [eax*3] |
4397 | lea eax, [eax*3] |
4398 | putimage_init8bpp: |
4398 | putimage_init8bpp: |
4399 | putimage_init9bpp: |
4399 | putimage_init9bpp: |
4400 | ret |
4400 | ret |
4401 | ;----------------------------------------------------------------------------- |
4401 | ;----------------------------------------------------------------------------- |
4402 | align 16 |
4402 | align 16 |
4403 | putimage_get24bpp: |
4403 | putimage_get24bpp: |
4404 | movzx eax, byte [esi+2] |
4404 | movzx eax, byte [esi+2] |
4405 | shl eax, 16 |
4405 | shl eax, 16 |
4406 | mov ax, [esi] |
4406 | mov ax, [esi] |
4407 | add esi, 3 |
4407 | add esi, 3 |
4408 | ret 4 |
4408 | ret 4 |
4409 | ;----------------------------------------------------------------------------- |
4409 | ;----------------------------------------------------------------------------- |
4410 | align 16 |
4410 | align 16 |
4411 | putimage_get8bpp: |
4411 | putimage_get8bpp: |
4412 | movzx eax, byte [esi] |
4412 | movzx eax, byte [esi] |
4413 | push edx |
4413 | push edx |
4414 | mov edx, [esp+8] |
4414 | mov edx, [esp+8] |
4415 | mov eax, [edx+eax*4] |
4415 | mov eax, [edx+eax*4] |
4416 | pop edx |
4416 | pop edx |
4417 | inc esi |
4417 | inc esi |
4418 | ret 4 |
4418 | ret 4 |
4419 | ;----------------------------------------------------------------------------- |
4419 | ;----------------------------------------------------------------------------- |
4420 | align 16 |
4420 | align 16 |
4421 | putimage_get9bpp: |
4421 | putimage_get9bpp: |
4422 | lodsb |
4422 | lodsb |
4423 | mov ah, al |
4423 | mov ah, al |
4424 | shl eax, 8 |
4424 | shl eax, 8 |
4425 | mov al, ah |
4425 | mov al, ah |
4426 | ret 4 |
4426 | ret 4 |
4427 | ;----------------------------------------------------------------------------- |
4427 | ;----------------------------------------------------------------------------- |
4428 | align 4 |
4428 | align 4 |
4429 | putimage_init1bpp: |
4429 | putimage_init1bpp: |
4430 | add eax, ecx |
4430 | add eax, ecx |
4431 | push ecx |
4431 | push ecx |
4432 | add eax, 7 |
4432 | add eax, 7 |
4433 | add ecx, 7 |
4433 | add ecx, 7 |
4434 | shr eax, 3 |
4434 | shr eax, 3 |
4435 | shr ecx, 3 |
4435 | shr ecx, 3 |
4436 | sub eax, ecx |
4436 | sub eax, ecx |
4437 | pop ecx |
4437 | pop ecx |
4438 | ret |
4438 | ret |
4439 | ;----------------------------------------------------------------------------- |
4439 | ;----------------------------------------------------------------------------- |
4440 | align 16 |
4440 | align 16 |
4441 | putimage_get1bpp: |
4441 | putimage_get1bpp: |
4442 | push edx |
4442 | push edx |
4443 | mov edx, [esp+8] |
4443 | mov edx, [esp+8] |
4444 | mov al, [edx] |
4444 | mov al, [edx] |
4445 | add al, al |
4445 | add al, al |
4446 | jnz @f |
4446 | jnz @f |
4447 | lodsb |
4447 | lodsb |
4448 | adc al, al |
4448 | adc al, al |
4449 | @@: |
4449 | @@: |
4450 | mov [edx], al |
4450 | mov [edx], al |
4451 | sbb eax, eax |
4451 | sbb eax, eax |
4452 | and eax, [edx+8] |
4452 | and eax, [edx+8] |
4453 | add eax, [edx+4] |
4453 | add eax, [edx+4] |
4454 | pop edx |
4454 | pop edx |
4455 | ret 4 |
4455 | ret 4 |
4456 | ;----------------------------------------------------------------------------- |
4456 | ;----------------------------------------------------------------------------- |
4457 | align 4 |
4457 | align 4 |
4458 | putimage_init2bpp: |
4458 | putimage_init2bpp: |
4459 | add eax, ecx |
4459 | add eax, ecx |
4460 | push ecx |
4460 | push ecx |
4461 | add ecx, 3 |
4461 | add ecx, 3 |
4462 | add eax, 3 |
4462 | add eax, 3 |
4463 | shr ecx, 2 |
4463 | shr ecx, 2 |
4464 | shr eax, 2 |
4464 | shr eax, 2 |
4465 | sub eax, ecx |
4465 | sub eax, ecx |
4466 | pop ecx |
4466 | pop ecx |
4467 | ret |
4467 | ret |
4468 | ;----------------------------------------------------------------------------- |
4468 | ;----------------------------------------------------------------------------- |
4469 | align 16 |
4469 | align 16 |
4470 | putimage_get2bpp: |
4470 | putimage_get2bpp: |
4471 | push edx |
4471 | push edx |
4472 | mov edx, [esp+8] |
4472 | mov edx, [esp+8] |
4473 | mov al, [edx] |
4473 | mov al, [edx] |
4474 | mov ah, al |
4474 | mov ah, al |
4475 | shr al, 6 |
4475 | shr al, 6 |
4476 | shl ah, 2 |
4476 | shl ah, 2 |
4477 | jnz .nonewbyte |
4477 | jnz .nonewbyte |
4478 | lodsb |
4478 | lodsb |
4479 | mov ah, al |
4479 | mov ah, al |
4480 | shr al, 6 |
4480 | shr al, 6 |
4481 | shl ah, 2 |
4481 | shl ah, 2 |
4482 | add ah, 1 |
4482 | add ah, 1 |
4483 | .nonewbyte: |
4483 | .nonewbyte: |
4484 | mov [edx], ah |
4484 | mov [edx], ah |
4485 | mov edx, [edx+4] |
4485 | mov edx, [edx+4] |
4486 | movzx eax, al |
4486 | movzx eax, al |
4487 | mov eax, [edx+eax*4] |
4487 | mov eax, [edx+eax*4] |
4488 | pop edx |
4488 | pop edx |
4489 | ret 4 |
4489 | ret 4 |
4490 | ;----------------------------------------------------------------------------- |
4490 | ;----------------------------------------------------------------------------- |
4491 | align 4 |
4491 | align 4 |
4492 | putimage_init4bpp: |
4492 | putimage_init4bpp: |
4493 | add eax, ecx |
4493 | add eax, ecx |
4494 | push ecx |
4494 | push ecx |
4495 | add ecx, 1 |
4495 | add ecx, 1 |
4496 | add eax, 1 |
4496 | add eax, 1 |
4497 | shr ecx, 1 |
4497 | shr ecx, 1 |
4498 | shr eax, 1 |
4498 | shr eax, 1 |
4499 | sub eax, ecx |
4499 | sub eax, ecx |
4500 | pop ecx |
4500 | pop ecx |
4501 | ret |
4501 | ret |
4502 | ;----------------------------------------------------------------------------- |
4502 | ;----------------------------------------------------------------------------- |
4503 | align 16 |
4503 | align 16 |
4504 | putimage_get4bpp: |
4504 | putimage_get4bpp: |
4505 | push edx |
4505 | push edx |
4506 | mov edx, [esp+8] |
4506 | mov edx, [esp+8] |
4507 | add byte [edx], 80h |
4507 | add byte [edx], 80h |
4508 | jc @f |
4508 | jc @f |
4509 | movzx eax, byte [edx+1] |
4509 | movzx eax, byte [edx+1] |
4510 | mov edx, [edx+4] |
4510 | mov edx, [edx+4] |
4511 | and eax, 0x0F |
4511 | and eax, 0x0F |
4512 | mov eax, [edx+eax*4] |
4512 | mov eax, [edx+eax*4] |
4513 | pop edx |
4513 | pop edx |
4514 | ret 4 |
4514 | ret 4 |
4515 | @@: |
4515 | @@: |
4516 | movzx eax, byte [esi] |
4516 | movzx eax, byte [esi] |
4517 | add esi, 1 |
4517 | add esi, 1 |
4518 | mov [edx+1], al |
4518 | mov [edx+1], al |
4519 | shr eax, 4 |
4519 | shr eax, 4 |
4520 | mov edx, [edx+4] |
4520 | mov edx, [edx+4] |
4521 | mov eax, [edx+eax*4] |
4521 | mov eax, [edx+eax*4] |
4522 | pop edx |
4522 | pop edx |
4523 | ret 4 |
4523 | ret 4 |
4524 | ;----------------------------------------------------------------------------- |
4524 | ;----------------------------------------------------------------------------- |
4525 | align 4 |
4525 | align 4 |
4526 | putimage_init32bpp: |
4526 | putimage_init32bpp: |
4527 | shl eax, 2 |
4527 | shl eax, 2 |
4528 | ret |
4528 | ret |
4529 | ;----------------------------------------------------------------------------- |
4529 | ;----------------------------------------------------------------------------- |
4530 | align 16 |
4530 | align 16 |
4531 | putimage_get32bpp: |
4531 | putimage_get32bpp: |
4532 | lodsd |
4532 | lodsd |
4533 | ret 4 |
4533 | ret 4 |
4534 | ;----------------------------------------------------------------------------- |
4534 | ;----------------------------------------------------------------------------- |
4535 | align 4 |
4535 | align 4 |
4536 | putimage_init15bpp: |
4536 | putimage_init15bpp: |
4537 | putimage_init16bpp: |
4537 | putimage_init16bpp: |
4538 | add eax, eax |
4538 | add eax, eax |
4539 | ret |
4539 | ret |
4540 | ;----------------------------------------------------------------------------- |
4540 | ;----------------------------------------------------------------------------- |
4541 | align 16 |
4541 | align 16 |
4542 | putimage_get15bpp: |
4542 | putimage_get15bpp: |
4543 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4543 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4544 | push ecx edx |
4544 | push ecx edx |
4545 | movzx eax, word [esi] |
4545 | movzx eax, word [esi] |
4546 | add esi, 2 |
4546 | add esi, 2 |
4547 | mov ecx, eax |
4547 | mov ecx, eax |
4548 | mov edx, eax |
4548 | mov edx, eax |
4549 | and eax, 0x1F |
4549 | and eax, 0x1F |
4550 | and ecx, 0x1F shl 5 |
4550 | and ecx, 0x1F shl 5 |
4551 | and edx, 0x1F shl 10 |
4551 | and edx, 0x1F shl 10 |
4552 | shl eax, 3 |
4552 | shl eax, 3 |
4553 | shl ecx, 6 |
4553 | shl ecx, 6 |
4554 | shl edx, 9 |
4554 | shl edx, 9 |
4555 | or eax, ecx |
4555 | or eax, ecx |
4556 | or eax, edx |
4556 | or eax, edx |
4557 | pop edx ecx |
4557 | pop edx ecx |
4558 | ret 4 |
4558 | ret 4 |
4559 | ;----------------------------------------------------------------------------- |
4559 | ;----------------------------------------------------------------------------- |
4560 | align 16 |
4560 | align 16 |
4561 | putimage_get16bpp: |
4561 | putimage_get16bpp: |
4562 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4562 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4563 | push ecx edx |
4563 | push ecx edx |
4564 | movzx eax, word [esi] |
4564 | movzx eax, word [esi] |
4565 | add esi, 2 |
4565 | add esi, 2 |
4566 | mov ecx, eax |
4566 | mov ecx, eax |
4567 | mov edx, eax |
4567 | mov edx, eax |
4568 | and eax, 0x1F |
4568 | and eax, 0x1F |
4569 | and ecx, 0x3F shl 5 |
4569 | and ecx, 0x3F shl 5 |
4570 | and edx, 0x1F shl 11 |
4570 | and edx, 0x1F shl 11 |
4571 | shl eax, 3 |
4571 | shl eax, 3 |
4572 | shl ecx, 5 |
4572 | shl ecx, 5 |
4573 | shl edx, 8 |
4573 | shl edx, 8 |
4574 | or eax, ecx |
4574 | or eax, ecx |
4575 | or eax, edx |
4575 | or eax, edx |
4576 | pop edx ecx |
4576 | pop edx ecx |
4577 | ret 4 |
4577 | ret 4 |
4578 | ;----------------------------------------------------------------------------- |
4578 | ;----------------------------------------------------------------------------- |
4579 | ;align 4 |
4579 | ;align 4 |
4580 | ; eax x beginning |
4580 | ; eax x beginning |
4581 | ; ebx y beginning |
4581 | ; ebx y beginning |
4582 | ; ecx x end |
4582 | ; ecx x end |
4583 | ; edx y end |
4583 | ; edx y end |
4584 | ; edi color |
4584 | ; edi color |
4585 | ;__sys_drawbar: |
4585 | ;__sys_drawbar: |
4586 | ; mov esi, [current_slot] |
4586 | ; mov esi, [current_slot] |
4587 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4587 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4588 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4588 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4589 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4589 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4590 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4590 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4591 | ;-------------------------------------- |
4591 | ;-------------------------------------- |
4592 | ;align 4 |
4592 | ;align 4 |
4593 | ;.forced: |
4593 | ;.forced: |
4594 | ; call vesa20_drawbar |
4594 | ; call vesa20_drawbar |
4595 | ; call [draw_pointer] |
4595 | ; call [draw_pointer] |
4596 | ; ret |
4596 | ; ret |
4597 | ;----------------------------------------------------------------------------- |
4597 | ;----------------------------------------------------------------------------- |
4598 | align 4 |
4598 | align 4 |
4599 | kb_write_wait_ack: |
4599 | kb_write_wait_ack: |
4600 | 4600 | ||
4601 | push ecx edx |
4601 | push ecx edx |
4602 | 4602 | ||
4603 | mov dl, al |
4603 | mov dl, al |
4604 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4604 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4605 | .wait_output_ready: |
4605 | .wait_output_ready: |
4606 | in al, 0x64 |
4606 | in al, 0x64 |
4607 | test al, 2 |
4607 | test al, 2 |
4608 | jz @f |
4608 | jz @f |
4609 | loop .wait_output_ready |
4609 | loop .wait_output_ready |
4610 | mov ah, 1 |
4610 | mov ah, 1 |
4611 | jmp .nothing |
4611 | jmp .nothing |
4612 | @@: |
4612 | @@: |
4613 | mov al, dl |
4613 | mov al, dl |
4614 | out 0x60, al |
4614 | out 0x60, al |
4615 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4615 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4616 | .wait_ack: |
4616 | .wait_ack: |
4617 | in al, 0x64 |
4617 | in al, 0x64 |
4618 | test al, 1 |
4618 | test al, 1 |
4619 | jnz @f |
4619 | jnz @f |
4620 | loop .wait_ack |
4620 | loop .wait_ack |
4621 | mov ah, 1 |
4621 | mov ah, 1 |
4622 | jmp .nothing |
4622 | jmp .nothing |
4623 | @@: |
4623 | @@: |
4624 | in al, 0x60 |
4624 | in al, 0x60 |
4625 | xor ah, ah |
4625 | xor ah, ah |
4626 | 4626 | ||
4627 | .nothing: |
4627 | .nothing: |
4628 | pop edx ecx |
4628 | pop edx ecx |
4629 | 4629 | ||
4630 | ret |
4630 | ret |
4631 | ;----------------------------------------------------------------------------- |
4631 | ;----------------------------------------------------------------------------- |
4632 | 4632 | ||
4633 | setmouse: ; set mousepicture -pointer |
4633 | setmouse: ; set mousepicture -pointer |
4634 | ; ps2 mouse enable |
4634 | ; ps2 mouse enable |
4635 | 4635 | ||
4636 | ; mov [MOUSE_PICTURE], dword mousepointer |
4636 | ; mov [MOUSE_PICTURE], dword mousepointer |
4637 | 4637 | ||
4638 | cli |
4638 | cli |
4639 | 4639 | ||
4640 | ret |
4640 | ret |
4641 | 4641 | ||
4642 | if used _rdtsc |
4642 | if used _rdtsc |
4643 | _rdtsc: |
4643 | _rdtsc: |
4644 | bt [cpu_caps], CAPS_TSC |
4644 | bt [cpu_caps], CAPS_TSC |
4645 | jnc ret_rdtsc |
4645 | jnc ret_rdtsc |
4646 | rdtsc |
4646 | rdtsc |
4647 | ret |
4647 | ret |
4648 | ret_rdtsc: |
4648 | ret_rdtsc: |
4649 | mov edx, 0xffffffff |
4649 | mov edx, 0xffffffff |
4650 | mov eax, 0xffffffff |
4650 | mov eax, 0xffffffff |
4651 | ret |
4651 | ret |
4652 | end if |
4652 | end if |
4653 | 4653 | ||
4654 | sys_msg_board_str: |
4654 | sys_msg_board_str: |
4655 | 4655 | ||
4656 | pushad |
4656 | pushad |
4657 | @@: |
4657 | @@: |
4658 | cmp [esi], byte 0 |
4658 | cmp [esi], byte 0 |
4659 | je @f |
4659 | je @f |
4660 | mov ebx, 1 |
4660 | mov ebx, 1 |
4661 | movzx ecx, byte [esi] |
4661 | movzx ecx, byte [esi] |
4662 | call sys_msg_board |
4662 | call sys_msg_board |
4663 | inc esi |
4663 | inc esi |
4664 | jmp @b |
4664 | jmp @b |
4665 | @@: |
4665 | @@: |
4666 | popad |
4666 | popad |
4667 | ret |
4667 | ret |
4668 | 4668 | ||
4669 | sys_msg_board_byte: |
4669 | sys_msg_board_byte: |
4670 | ; in: al = byte to display |
4670 | ; in: al = byte to display |
4671 | ; out: nothing |
4671 | ; out: nothing |
4672 | ; destroys: nothing |
4672 | ; destroys: nothing |
4673 | pushad |
4673 | pushad |
4674 | mov ecx, 2 |
4674 | mov ecx, 2 |
4675 | shl eax, 24 |
4675 | shl eax, 24 |
4676 | jmp @f |
4676 | jmp @f |
4677 | 4677 | ||
4678 | sys_msg_board_word: |
4678 | sys_msg_board_word: |
4679 | ; in: ax = word to display |
4679 | ; in: ax = word to display |
4680 | ; out: nothing |
4680 | ; out: nothing |
4681 | ; destroys: nothing |
4681 | ; destroys: nothing |
4682 | pushad |
4682 | pushad |
4683 | mov ecx, 4 |
4683 | mov ecx, 4 |
4684 | shl eax, 16 |
4684 | shl eax, 16 |
4685 | jmp @f |
4685 | jmp @f |
4686 | 4686 | ||
4687 | sys_msg_board_dword: |
4687 | sys_msg_board_dword: |
4688 | ; in: eax = dword to display |
4688 | ; in: eax = dword to display |
4689 | ; out: nothing |
4689 | ; out: nothing |
4690 | ; destroys: nothing |
4690 | ; destroys: nothing |
4691 | pushad |
4691 | pushad |
4692 | mov ecx, 8 |
4692 | mov ecx, 8 |
4693 | @@: |
4693 | @@: |
4694 | push ecx |
4694 | push ecx |
4695 | rol eax, 4 |
4695 | rol eax, 4 |
4696 | push eax |
4696 | push eax |
4697 | and al, 0xF |
4697 | and al, 0xF |
4698 | cmp al, 10 |
4698 | cmp al, 10 |
4699 | sbb al, 69h |
4699 | sbb al, 69h |
4700 | das |
4700 | das |
4701 | mov cl, al |
4701 | mov cl, al |
4702 | xor ebx, ebx |
4702 | xor ebx, ebx |
4703 | inc ebx |
4703 | inc ebx |
4704 | call sys_msg_board |
4704 | call sys_msg_board |
4705 | pop eax |
4705 | pop eax |
4706 | pop ecx |
4706 | pop ecx |
4707 | loop @b |
4707 | loop @b |
4708 | popad |
4708 | popad |
4709 | ret |
4709 | ret |
4710 | 4710 | ||
4711 | msg_board_data_size = 65536 ; Must be power of two |
4711 | msg_board_data_size = 65536 ; Must be power of two |
4712 | 4712 | ||
4713 | uglobal |
4713 | uglobal |
4714 | msg_board_data rb msg_board_data_size |
4714 | msg_board_data rb msg_board_data_size |
4715 | msg_board_count dd 0x0 |
4715 | msg_board_count dd 0x0 |
4716 | endg |
4716 | endg |
4717 | 4717 | ||
4718 | sys_msg_board: |
4718 | sys_msg_board: |
4719 | 4719 | ||
4720 | ; ebx=1 : write : bl byte to write |
4720 | ; ebx=1 : write : bl byte to write |
4721 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4721 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4722 | 4722 | ||
4723 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4723 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4724 | mov eax, ebx |
4724 | mov eax, ebx |
4725 | mov ebx, ecx |
4725 | mov ebx, ecx |
4726 | 4726 | ||
4727 | mov ecx, [msg_board_count] |
4727 | mov ecx, [msg_board_count] |
4728 | cmp eax, 1 |
4728 | cmp eax, 1 |
4729 | jne .smbl1 |
4729 | jne .smbl1 |
4730 | 4730 | ||
4731 | if defined debug_com_base |
4731 | if defined debug_com_base |
4732 | 4732 | ||
4733 | push dx ax |
4733 | push dx ax |
4734 | 4734 | ||
4735 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4735 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4736 | mov dx, debug_com_base+5 |
4736 | mov dx, debug_com_base+5 |
4737 | in al, dx |
4737 | in al, dx |
4738 | test al, 1 shl 5 |
4738 | test al, 1 shl 5 |
4739 | jz @r |
4739 | jz @r |
4740 | 4740 | ||
4741 | mov dx, debug_com_base ; Output the byte |
4741 | mov dx, debug_com_base ; Output the byte |
4742 | mov al, bl |
4742 | mov al, bl |
4743 | out dx, al |
4743 | out dx, al |
4744 | 4744 | ||
4745 | pop ax dx |
4745 | pop ax dx |
4746 | 4746 | ||
4747 | end if |
4747 | end if |
4748 | 4748 | ||
4749 | mov [msg_board_data+ecx], bl |
4749 | mov [msg_board_data+ecx], bl |
4750 | ; // if debug_direct_print == 1 |
4750 | ; // if debug_direct_print == 1 |
4751 | cmp byte [debug_direct_print], 1 |
4751 | cmp byte [debug_direct_print], 1 |
4752 | jnz @f |
4752 | jnz @f |
4753 | pusha |
4753 | pusha |
4754 | iglobal |
4754 | iglobal |
4755 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4755 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4756 | endg |
4756 | endg |
4757 | lea edx, [msg_board_data+ecx] |
4757 | lea edx, [msg_board_data+ecx] |
4758 | mov ecx, 0x40FFFFFF |
4758 | mov ecx, 0x40FFFFFF |
4759 | mov ebx, [msg_board_pos] |
4759 | mov ebx, [msg_board_pos] |
4760 | mov edi, 1 |
4760 | mov edi, 1 |
4761 | mov esi, 1 |
4761 | mov esi, 1 |
4762 | call dtext |
4762 | call dtext |
4763 | popa |
4763 | popa |
4764 | add word [msg_board_pos+2], 6 |
4764 | add word [msg_board_pos+2], 6 |
4765 | cmp bl, 10 |
4765 | cmp bl, 10 |
4766 | jnz @f |
4766 | jnz @f |
4767 | mov word [msg_board_pos+2], (42*6) |
4767 | mov word [msg_board_pos+2], (42*6) |
4768 | add word [msg_board_pos], 10 |
4768 | add word [msg_board_pos], 10 |
4769 | mov ax, word [Screen_Max_Y] |
4769 | mov ax, word [Screen_Max_Y] |
4770 | cmp word [msg_board_pos], ax |
4770 | cmp word [msg_board_pos], ax |
4771 | jbe @f |
4771 | jbe @f |
4772 | mov word [msg_board_pos], 10 |
4772 | mov word [msg_board_pos], 10 |
4773 | @@: |
4773 | @@: |
4774 | ; // end if |
4774 | ; // end if |
4775 | 4775 | ||
4776 | if 0 |
4776 | if 0 |
4777 | pusha |
4777 | pusha |
4778 | mov al, bl |
4778 | mov al, bl |
4779 | mov edx, 402h |
4779 | mov edx, 402h |
4780 | out dx, al |
4780 | out dx, al |
4781 | popa |
4781 | popa |
4782 | end if |
4782 | end if |
4783 | inc ecx |
4783 | inc ecx |
4784 | and ecx, msg_board_data_size - 1 |
4784 | and ecx, msg_board_data_size - 1 |
4785 | mov [msg_board_count], ecx |
4785 | mov [msg_board_count], ecx |
4786 | 4786 | ||
4787 | pop ebx eax |
4787 | pop ebx eax |
4788 | ret |
4788 | ret |
4789 | .smbl1: |
4789 | .smbl1: |
4790 | cmp eax, 2 |
4790 | cmp eax, 2 |
4791 | jne .smbl2 |
4791 | jne .smbl2 |
4792 | test ecx, ecx |
4792 | test ecx, ecx |
4793 | jz .smbl21 |
4793 | jz .smbl21 |
4794 | 4794 | ||
4795 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4795 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4796 | mov eax, msg_board_data+1 |
4796 | mov eax, msg_board_data+1 |
4797 | mov ebx, msg_board_data |
4797 | mov ebx, msg_board_data |
4798 | movzx edx, byte [ebx] |
4798 | movzx edx, byte [ebx] |
4799 | call memmove |
4799 | call memmove |
4800 | dec [msg_board_count] |
4800 | dec [msg_board_count] |
4801 | mov [esp + 32], edx ;eax |
4801 | mov [esp + 32], edx ;eax |
4802 | mov [esp + 20], dword 1 |
4802 | mov [esp + 20], dword 1 |
4803 | ret |
4803 | ret |
4804 | .smbl21: |
4804 | .smbl21: |
4805 | mov [esp+32], ecx |
4805 | mov [esp+32], ecx |
4806 | mov [esp+20], ecx |
4806 | mov [esp+20], ecx |
4807 | .smbl2: |
4807 | .smbl2: |
4808 | pop ebx eax |
4808 | pop ebx eax |
4809 | ret |
4809 | ret |
4810 | 4810 | ||
4811 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4811 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4812 | ;; 66 sys function. ;; |
4812 | ;; 66 sys function. ;; |
4813 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4813 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4814 | ;; out eax ;; |
4814 | ;; out eax ;; |
4815 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4815 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4816 | iglobal |
4816 | iglobal |
4817 | align 4 |
4817 | align 4 |
4818 | f66call: |
4818 | f66call: |
4819 | dd sys_process_def.1 ; 1 = set keyboard mode |
4819 | dd sys_process_def.1 ; 1 = set keyboard mode |
4820 | dd sys_process_def.2 ; 2 = get keyboard mode |
4820 | dd sys_process_def.2 ; 2 = get keyboard mode |
4821 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4821 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4822 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4822 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4823 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4823 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4824 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4824 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4825 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4825 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4826 | endg |
4826 | endg |
4827 | ;----------------------------------------------------------------------------- |
4827 | ;----------------------------------------------------------------------------- |
4828 | align 4 |
4828 | align 4 |
4829 | sys_process_def: |
4829 | sys_process_def: |
4830 | dec ebx |
4830 | dec ebx |
4831 | cmp ebx, 7 |
4831 | cmp ebx, 7 |
4832 | jae .not_support ;if >=8 then or eax,-1 |
4832 | jae .not_support ;if >=8 then or eax,-1 |
4833 | 4833 | ||
4834 | mov edi, [CURRENT_TASK] |
4834 | mov edi, [CURRENT_TASK] |
4835 | jmp dword [f66call+ebx*4] |
4835 | jmp dword [f66call+ebx*4] |
4836 | 4836 | ||
4837 | .not_support: |
4837 | .not_support: |
4838 | or eax, -1 |
4838 | or eax, -1 |
4839 | ret |
4839 | ret |
4840 | ;----------------------------------------------------------------------------- |
4840 | ;----------------------------------------------------------------------------- |
4841 | align 4 |
4841 | align 4 |
4842 | .1: |
4842 | .1: |
4843 | shl edi, 8 |
4843 | shl edi, 8 |
4844 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4844 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4845 | 4845 | ||
4846 | ret |
4846 | ret |
4847 | ;----------------------------------------------------------------------------- |
4847 | ;----------------------------------------------------------------------------- |
4848 | align 4 |
4848 | align 4 |
4849 | .2: ; 2 = get keyboard mode |
4849 | .2: ; 2 = get keyboard mode |
4850 | shl edi, 8 |
4850 | shl edi, 8 |
4851 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4851 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4852 | mov [esp+32], eax |
4852 | mov [esp+32], eax |
4853 | ret |
4853 | ret |
4854 | ;----------------------------------------------------------------------------- |
4854 | ;----------------------------------------------------------------------------- |
4855 | align 4 |
4855 | align 4 |
4856 | .3: ;3 = get keyboard ctrl, alt, shift |
4856 | .3: ;3 = get keyboard ctrl, alt, shift |
4857 | mov eax, [kb_state] |
4857 | mov eax, [kb_state] |
4858 | mov [esp+32], eax |
4858 | mov [esp+32], eax |
4859 | ret |
4859 | ret |
4860 | ;----------------------------------------------------------------------------- |
4860 | ;----------------------------------------------------------------------------- |
4861 | align 4 |
4861 | align 4 |
4862 | .4: |
4862 | .4: |
4863 | mov eax, hotkey_list |
4863 | mov eax, hotkey_list |
4864 | @@: |
4864 | @@: |
4865 | cmp dword [eax+8], 0 |
4865 | cmp dword [eax+8], 0 |
4866 | jz .found_free |
4866 | jz .found_free |
4867 | add eax, 16 |
4867 | add eax, 16 |
4868 | cmp eax, hotkey_list+16*256 |
4868 | cmp eax, hotkey_list+16*256 |
4869 | jb @b |
4869 | jb @b |
4870 | mov dword [esp+32], 1 |
4870 | mov dword [esp+32], 1 |
4871 | ret |
4871 | ret |
4872 | .found_free: |
4872 | .found_free: |
4873 | mov [eax+8], edi |
4873 | mov [eax+8], edi |
4874 | mov [eax+4], edx |
4874 | mov [eax+4], edx |
4875 | movzx ecx, cl |
4875 | movzx ecx, cl |
4876 | lea ecx, [hotkey_scancodes+ecx*4] |
4876 | lea ecx, [hotkey_scancodes+ecx*4] |
4877 | mov edx, [ecx] |
4877 | mov edx, [ecx] |
4878 | mov [eax], edx |
4878 | mov [eax], edx |
4879 | mov [ecx], eax |
4879 | mov [ecx], eax |
4880 | mov [eax+12], ecx |
4880 | mov [eax+12], ecx |
4881 | test edx, edx |
4881 | test edx, edx |
4882 | jz @f |
4882 | jz @f |
4883 | mov [edx+12], eax |
4883 | mov [edx+12], eax |
4884 | @@: |
4884 | @@: |
4885 | and dword [esp+32], 0 |
4885 | and dword [esp+32], 0 |
4886 | ret |
4886 | ret |
4887 | ;----------------------------------------------------------------------------- |
4887 | ;----------------------------------------------------------------------------- |
4888 | align 4 |
4888 | align 4 |
4889 | .5: |
4889 | .5: |
4890 | movzx ebx, cl |
4890 | movzx ebx, cl |
4891 | lea ebx, [hotkey_scancodes+ebx*4] |
4891 | lea ebx, [hotkey_scancodes+ebx*4] |
4892 | mov eax, [ebx] |
4892 | mov eax, [ebx] |
4893 | .scan: |
4893 | .scan: |
4894 | test eax, eax |
4894 | test eax, eax |
4895 | jz .notfound |
4895 | jz .notfound |
4896 | cmp [eax+8], edi |
4896 | cmp [eax+8], edi |
4897 | jnz .next |
4897 | jnz .next |
4898 | cmp [eax+4], edx |
4898 | cmp [eax+4], edx |
4899 | jz .found |
4899 | jz .found |
4900 | .next: |
4900 | .next: |
4901 | mov eax, [eax] |
4901 | mov eax, [eax] |
4902 | jmp .scan |
4902 | jmp .scan |
4903 | .notfound: |
4903 | .notfound: |
4904 | mov dword [esp+32], 1 |
4904 | mov dword [esp+32], 1 |
4905 | ret |
4905 | ret |
4906 | .found: |
4906 | .found: |
4907 | mov ecx, [eax] |
4907 | mov ecx, [eax] |
4908 | jecxz @f |
4908 | jecxz @f |
4909 | mov edx, [eax+12] |
4909 | mov edx, [eax+12] |
4910 | mov [ecx+12], edx |
4910 | mov [ecx+12], edx |
4911 | @@: |
4911 | @@: |
4912 | mov ecx, [eax+12] |
4912 | mov ecx, [eax+12] |
4913 | mov edx, [eax] |
4913 | mov edx, [eax] |
4914 | mov [ecx], edx |
4914 | mov [ecx], edx |
4915 | xor edx, edx |
4915 | xor edx, edx |
4916 | mov [eax+4], edx |
4916 | mov [eax+4], edx |
4917 | mov [eax+8], edx |
4917 | mov [eax+8], edx |
4918 | mov [eax+12], edx |
4918 | mov [eax+12], edx |
4919 | mov [eax], edx |
4919 | mov [eax], edx |
4920 | mov [esp+32], edx |
4920 | mov [esp+32], edx |
4921 | ret |
4921 | ret |
4922 | ;----------------------------------------------------------------------------- |
4922 | ;----------------------------------------------------------------------------- |
4923 | align 4 |
4923 | align 4 |
4924 | .6: |
4924 | .6: |
4925 | pushfd |
4925 | pushfd |
4926 | cli |
4926 | cli |
4927 | mov eax, [PID_lock_input] |
4927 | mov eax, [PID_lock_input] |
4928 | test eax, eax |
4928 | test eax, eax |
4929 | jnz @f |
4929 | jnz @f |
4930 | ; get current PID |
4930 | ; get current PID |
4931 | mov eax, [CURRENT_TASK] |
4931 | mov eax, [CURRENT_TASK] |
4932 | shl eax, 5 |
4932 | shl eax, 5 |
4933 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4933 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4934 | ; set current PID for lock input |
4934 | ; set current PID for lock input |
4935 | mov [PID_lock_input], eax |
4935 | mov [PID_lock_input], eax |
4936 | @@: |
4936 | @@: |
4937 | popfd |
4937 | popfd |
4938 | ret |
4938 | ret |
4939 | ;----------------------------------------------------------------------------- |
4939 | ;----------------------------------------------------------------------------- |
4940 | align 4 |
4940 | align 4 |
4941 | .7: |
4941 | .7: |
4942 | mov eax, [PID_lock_input] |
4942 | mov eax, [PID_lock_input] |
4943 | test eax, eax |
4943 | test eax, eax |
4944 | jz @f |
4944 | jz @f |
4945 | ; get current PID |
4945 | ; get current PID |
4946 | mov ebx, [CURRENT_TASK] |
4946 | mov ebx, [CURRENT_TASK] |
4947 | shl ebx, 5 |
4947 | shl ebx, 5 |
4948 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4948 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4949 | ; compare current lock input with current PID |
4949 | ; compare current lock input with current PID |
4950 | cmp ebx, eax |
4950 | cmp ebx, eax |
4951 | jne @f |
4951 | jne @f |
4952 | 4952 | ||
4953 | xor eax, eax |
4953 | xor eax, eax |
4954 | mov [PID_lock_input], eax |
4954 | mov [PID_lock_input], eax |
4955 | @@: |
4955 | @@: |
4956 | ret |
4956 | ret |
4957 | ;----------------------------------------------------------------------------- |
4957 | ;----------------------------------------------------------------------------- |
4958 | uglobal |
4958 | uglobal |
4959 | PID_lock_input dd 0x0 |
4959 | PID_lock_input dd 0x0 |
4960 | endg |
4960 | endg |
4961 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4961 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4962 | ;; 61 sys function. ;; |
4962 | ;; 61 sys function. ;; |
4963 | ;; in eax=61,ebx in [1..3] ;; |
4963 | ;; in eax=61,ebx in [1..3] ;; |
4964 | ;; out eax ;; |
4964 | ;; out eax ;; |
4965 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4965 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4966 | iglobal |
4966 | iglobal |
4967 | align 4 |
4967 | align 4 |
4968 | f61call: |
4968 | f61call: |
4969 | dd sys_gs.1 ; resolution |
4969 | dd sys_gs.1 ; resolution |
4970 | dd sys_gs.2 ; bits per pixel |
4970 | dd sys_gs.2 ; bits per pixel |
4971 | dd sys_gs.3 ; bytes per scanline |
4971 | dd sys_gs.3 ; bytes per scanline |
4972 | endg |
4972 | endg |
4973 | 4973 | ||
4974 | 4974 | ||
4975 | align 4 |
4975 | align 4 |
4976 | 4976 | ||
4977 | sys_gs: ; direct screen access |
4977 | sys_gs: ; direct screen access |
4978 | dec ebx |
4978 | dec ebx |
4979 | cmp ebx, 2 |
4979 | cmp ebx, 2 |
4980 | ja .not_support |
4980 | ja .not_support |
4981 | jmp dword [f61call+ebx*4] |
4981 | jmp dword [f61call+ebx*4] |
4982 | .not_support: |
4982 | .not_support: |
4983 | or [esp+32], dword -1 |
4983 | or [esp+32], dword -1 |
4984 | ret |
4984 | ret |
4985 | 4985 | ||
4986 | 4986 | ||
4987 | .1: ; resolution |
4987 | .1: ; resolution |
4988 | mov eax, [Screen_Max_X] |
4988 | mov eax, [Screen_Max_X] |
4989 | shl eax, 16 |
4989 | shl eax, 16 |
4990 | mov ax, word [Screen_Max_Y] |
4990 | mov ax, word [Screen_Max_Y] |
4991 | add eax, 0x00010001 |
4991 | add eax, 0x00010001 |
4992 | mov [esp+32], eax |
4992 | mov [esp+32], eax |
4993 | ret |
4993 | ret |
4994 | .2: ; bits per pixel |
4994 | .2: ; bits per pixel |
4995 | mov eax, [_display.bpp] |
4995 | mov eax, [_display.bpp] |
4996 | mov [esp+32], eax |
4996 | mov [esp+32], eax |
4997 | ret |
4997 | ret |
4998 | .3: ; bytes per scanline |
4998 | .3: ; bytes per scanline |
4999 | mov eax, [_display.pitch] |
4999 | mov eax, [_display.pitch] |
5000 | mov [esp+32], eax |
5000 | mov [esp+32], eax |
5001 | ret |
5001 | ret |
5002 | 5002 | ||
5003 | align 4 ; system functions |
5003 | align 4 ; system functions |
5004 | 5004 | ||
5005 | syscall_setpixel: ; SetPixel |
5005 | syscall_setpixel: ; SetPixel |
5006 | 5006 | ||
5007 | mov eax, ebx |
5007 | mov eax, ebx |
5008 | mov ebx, ecx |
5008 | mov ebx, ecx |
5009 | mov ecx, edx |
5009 | mov ecx, edx |
5010 | mov edx, [TASK_BASE] |
5010 | mov edx, [TASK_BASE] |
5011 | add eax, [edx-twdw+WDATA.box.left] |
5011 | add eax, [edx-twdw+WDATA.box.left] |
5012 | add ebx, [edx-twdw+WDATA.box.top] |
5012 | add ebx, [edx-twdw+WDATA.box.top] |
5013 | mov edi, [current_slot] |
5013 | mov edi, [current_slot] |
5014 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5014 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5015 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5015 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5016 | xor edi, edi ; no force |
5016 | xor edi, edi ; no force |
5017 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5017 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5018 | ; jmp [putpixel] |
5018 | ; jmp [putpixel] |
5019 | jmp __sys_putpixel |
5019 | jmp __sys_putpixel |
5020 | 5020 | ||
5021 | align 4 |
5021 | align 4 |
5022 | 5022 | ||
5023 | syscall_writetext: ; WriteText |
5023 | syscall_writetext: ; WriteText |
5024 | 5024 | ||
5025 | mov eax, [TASK_BASE] |
5025 | mov eax, [TASK_BASE] |
5026 | mov ebp, [eax-twdw+WDATA.box.left] |
5026 | mov ebp, [eax-twdw+WDATA.box.left] |
5027 | push esi |
5027 | push esi |
5028 | mov esi, [current_slot] |
5028 | mov esi, [current_slot] |
5029 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5029 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5030 | shl ebp, 16 |
5030 | shl ebp, 16 |
5031 | add ebp, [eax-twdw+WDATA.box.top] |
5031 | add ebp, [eax-twdw+WDATA.box.top] |
5032 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5032 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5033 | pop esi |
5033 | pop esi |
5034 | test ecx, 0x08000000 ; redirect the output to the user area |
5034 | test ecx, 0x08000000 ; redirect the output to the user area |
5035 | jnz @f |
5035 | jnz @f |
5036 | add ebx, ebp |
5036 | add ebx, ebp |
5037 | align 4 |
5037 | align 4 |
5038 | @@: |
5038 | @@: |
5039 | mov eax, edi |
5039 | mov eax, edi |
5040 | test ecx, 0x08000000 ; redirect the output to the user area |
5040 | test ecx, 0x08000000 ; redirect the output to the user area |
5041 | jnz dtext |
5041 | jnz dtext |
5042 | xor edi, edi |
5042 | xor edi, edi |
5043 | jmp dtext |
5043 | jmp dtext |
5044 | 5044 | ||
5045 | align 4 |
5045 | align 4 |
5046 | 5046 | ||
5047 | syscall_drawrect: ; DrawRect |
5047 | syscall_drawrect: ; DrawRect |
5048 | 5048 | ||
5049 | mov edi, edx ; color + gradient |
5049 | mov edi, edx ; color + gradient |
5050 | and edi, 0x80FFFFFF |
5050 | and edi, 0x80FFFFFF |
5051 | test bx, bx ; x.size |
5051 | test bx, bx ; x.size |
5052 | je .drectr |
5052 | je .drectr |
5053 | test cx, cx ; y.size |
5053 | test cx, cx ; y.size |
5054 | je .drectr |
5054 | je .drectr |
5055 | 5055 | ||
5056 | mov eax, ebx ; bad idea |
5056 | mov eax, ebx ; bad idea |
5057 | mov ebx, ecx |
5057 | mov ebx, ecx |
5058 | 5058 | ||
5059 | movzx ecx, ax ; ecx - x.size |
5059 | movzx ecx, ax ; ecx - x.size |
5060 | shr eax, 16 ; eax - x.coord |
5060 | shr eax, 16 ; eax - x.coord |
5061 | movzx edx, bx ; edx - y.size |
5061 | movzx edx, bx ; edx - y.size |
5062 | shr ebx, 16 ; ebx - y.coord |
5062 | shr ebx, 16 ; ebx - y.coord |
5063 | mov esi, [current_slot] |
5063 | mov esi, [current_slot] |
5064 | 5064 | ||
5065 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5065 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5066 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5066 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5067 | add ecx, eax |
5067 | add ecx, eax |
5068 | add edx, ebx |
5068 | add edx, ebx |
5069 | ; jmp [drawbar] |
5069 | ; jmp [drawbar] |
5070 | jmp vesa20_drawbar |
5070 | jmp vesa20_drawbar |
5071 | .drectr: |
5071 | .drectr: |
5072 | ret |
5072 | ret |
5073 | 5073 | ||
5074 | align 4 |
5074 | align 4 |
5075 | syscall_getscreensize: ; GetScreenSize |
5075 | syscall_getscreensize: ; GetScreenSize |
5076 | mov ax, word [Screen_Max_X] |
5076 | mov ax, word [Screen_Max_X] |
5077 | shl eax, 16 |
5077 | shl eax, 16 |
5078 | mov ax, word [Screen_Max_Y] |
5078 | mov ax, word [Screen_Max_Y] |
5079 | mov [esp + 32], eax |
5079 | mov [esp + 32], eax |
5080 | ret |
5080 | ret |
5081 | ;----------------------------------------------------------------------------- |
5081 | ;----------------------------------------------------------------------------- |
5082 | align 4 |
5082 | align 4 |
5083 | syscall_cdaudio: |
5083 | syscall_cdaudio: |
5084 | ; ECX - position of CD/DVD-drive |
5084 | ; ECX - position of CD/DVD-drive |
5085 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5085 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5086 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5086 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5087 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5087 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5088 | cmp ecx, 11 |
5088 | cmp ecx, 11 |
5089 | ja .exit |
5089 | ja .exit |
5090 | 5090 | ||
5091 | mov eax, ecx |
5091 | mov eax, ecx |
5092 | shr eax, 2 |
5092 | shr eax, 2 |
5093 | lea eax, [eax*5] |
5093 | lea eax, [eax*5] |
5094 | mov al, [eax+DRIVE_DATA+1] |
5094 | mov al, [eax+DRIVE_DATA+1] |
5095 | 5095 | ||
5096 | push ecx ebx |
5096 | push ecx ebx |
5097 | mov ebx, ecx |
5097 | mov ebx, ecx |
5098 | and ebx, 11b |
5098 | and ebx, 11b |
5099 | shl ebx, 1 |
5099 | shl ebx, 1 |
5100 | mov cl, 6 |
5100 | mov cl, 6 |
5101 | sub cl, bl |
5101 | sub cl, bl |
5102 | shr al, cl |
5102 | shr al, cl |
5103 | test al, 2 ; it's not an ATAPI device |
5103 | test al, 2 ; it's not an ATAPI device |
5104 | pop ebx ecx |
5104 | pop ebx ecx |
5105 | 5105 | ||
5106 | jz .exit |
5106 | jz .exit |
5107 | 5107 | ||
5108 | cmp ebx, 4 |
5108 | cmp ebx, 4 |
5109 | je .eject |
5109 | je .eject |
5110 | 5110 | ||
5111 | cmp ebx, 5 |
5111 | cmp ebx, 5 |
5112 | je .load |
5112 | je .load |
5113 | ;-------------------------------------- |
5113 | ;-------------------------------------- |
5114 | .exit: |
5114 | .exit: |
5115 | ret |
5115 | ret |
5116 | ;-------------------------------------- |
5116 | ;-------------------------------------- |
5117 | .load: |
5117 | .load: |
5118 | call .reserve |
5118 | call .reserve |
5119 | call LoadMedium |
5119 | call LoadMedium |
5120 | jmp .free |
5120 | jmp .free |
5121 | ;-------------------------------------- |
5121 | ;-------------------------------------- |
5122 | .eject: |
5122 | .eject: |
5123 | call .reserve |
5123 | call .reserve |
5124 | call clear_CD_cache |
5124 | call clear_CD_cache |
5125 | call allow_medium_removal |
5125 | call allow_medium_removal |
5126 | call EjectMedium |
5126 | call EjectMedium |
5127 | jmp .free |
5127 | jmp .free |
5128 | ;-------------------------------------- |
5128 | ;-------------------------------------- |
5129 | .reserve: |
5129 | .reserve: |
5130 | call reserve_cd |
5130 | call reserve_cd |
5131 | 5131 | ||
5132 | mov ebx, ecx |
5132 | mov ebx, ecx |
5133 | inc ebx |
5133 | inc ebx |
5134 | mov [cdpos], ebx |
5134 | mov [cdpos], ebx |
5135 | 5135 | ||
5136 | mov eax, ecx |
5136 | mov eax, ecx |
5137 | shr eax, 1 |
5137 | shr eax, 1 |
5138 | and eax, 1 |
5138 | and eax, 1 |
5139 | inc eax |
5139 | inc eax |
5140 | mov [ChannelNumber], ax |
5140 | mov [ChannelNumber], ax |
5141 | mov eax, ecx |
5141 | mov eax, ecx |
5142 | and eax, 1 |
5142 | and eax, 1 |
5143 | mov [DiskNumber], al |
5143 | mov [DiskNumber], al |
5144 | call reserve_cd_channel |
5144 | call reserve_cd_channel |
5145 | ret |
5145 | ret |
5146 | ;-------------------------------------- |
5146 | ;-------------------------------------- |
5147 | .free: |
5147 | .free: |
5148 | call free_cd_channel |
5148 | call free_cd_channel |
5149 | and [cd_status], 0 |
5149 | and [cd_status], 0 |
5150 | ret |
5150 | ret |
5151 | ;----------------------------------------------------------------------------- |
5151 | ;----------------------------------------------------------------------------- |
5152 | align 4 |
5152 | align 4 |
5153 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5153 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5154 | cmp ebx, [Screen_Max_X] |
5154 | cmp ebx, [Screen_Max_X] |
5155 | jbe @f |
5155 | jbe @f |
5156 | cmp ecx, [Screen_Max_Y] |
5156 | cmp ecx, [Screen_Max_Y] |
5157 | jbe @f |
5157 | jbe @f |
5158 | xor eax, eax |
5158 | xor eax, eax |
5159 | jmp .store |
5159 | jmp .store |
5160 | ;-------------------------------------- |
5160 | ;-------------------------------------- |
5161 | align 4 |
5161 | align 4 |
5162 | @@: |
5162 | @@: |
5163 | mov eax, [d_width_calc_area + ecx*4] |
5163 | mov eax, [d_width_calc_area + ecx*4] |
5164 | add eax, [_WinMapAddress] |
5164 | add eax, [_WinMapAddress] |
5165 | movzx eax, byte[eax+ebx] ; get value for current point |
5165 | movzx eax, byte[eax+ebx] ; get value for current point |
5166 | ;-------------------------------------- |
5166 | ;-------------------------------------- |
5167 | align 4 |
5167 | align 4 |
5168 | .store: |
5168 | .store: |
5169 | mov [esp + 32], eax |
5169 | mov [esp + 32], eax |
5170 | ret |
5170 | ret |
5171 | ;----------------------------------------------------------------------------- |
5171 | ;----------------------------------------------------------------------------- |
5172 | align 4 |
5172 | align 4 |
5173 | syscall_getpixel: ; GetPixel |
5173 | syscall_getpixel: ; GetPixel |
5174 | mov ecx, [Screen_Max_X] |
5174 | mov ecx, [Screen_Max_X] |
5175 | inc ecx |
5175 | inc ecx |
5176 | xor edx, edx |
5176 | xor edx, edx |
5177 | mov eax, ebx |
5177 | mov eax, ebx |
5178 | div ecx |
5178 | div ecx |
5179 | mov ebx, edx |
5179 | mov ebx, edx |
5180 | xchg eax, ebx |
5180 | xchg eax, ebx |
5181 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5181 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5182 | call dword [GETPIXEL]; eax - x, ebx - y |
5182 | call dword [GETPIXEL]; eax - x, ebx - y |
5183 | mov [esp + 32], ecx |
5183 | mov [esp + 32], ecx |
5184 | ret |
5184 | ret |
5185 | ;----------------------------------------------------------------------------- |
5185 | ;----------------------------------------------------------------------------- |
5186 | align 4 |
5186 | align 4 |
5187 | syscall_getarea: |
5187 | syscall_getarea: |
5188 | ;eax = 36 |
5188 | ;eax = 36 |
5189 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5189 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5190 | ;ecx = [size x]*65536 + [size y] |
5190 | ;ecx = [size x]*65536 + [size y] |
5191 | ;edx = [start x]*65536 + [start y] |
5191 | ;edx = [start x]*65536 + [start y] |
5192 | pushad |
5192 | pushad |
5193 | mov edi, ebx |
5193 | mov edi, ebx |
5194 | mov eax, edx |
5194 | mov eax, edx |
5195 | shr eax, 16 |
5195 | shr eax, 16 |
5196 | mov ebx, edx |
5196 | mov ebx, edx |
5197 | and ebx, 0xffff |
5197 | and ebx, 0xffff |
5198 | dec eax |
5198 | dec eax |
5199 | dec ebx |
5199 | dec ebx |
5200 | ; eax - x, ebx - y |
5200 | ; eax - x, ebx - y |
5201 | mov edx, ecx |
5201 | mov edx, ecx |
5202 | 5202 | ||
5203 | shr ecx, 16 |
5203 | shr ecx, 16 |
5204 | and edx, 0xffff |
5204 | and edx, 0xffff |
5205 | mov esi, ecx |
5205 | mov esi, ecx |
5206 | ; ecx - size x, edx - size y |
5206 | ; ecx - size x, edx - size y |
5207 | 5207 | ||
5208 | mov ebp, edx |
5208 | mov ebp, edx |
5209 | dec ebp |
5209 | dec ebp |
5210 | lea ebp, [ebp*3] |
5210 | lea ebp, [ebp*3] |
5211 | 5211 | ||
5212 | imul ebp, esi |
5212 | imul ebp, esi |
5213 | 5213 | ||
5214 | mov esi, ecx |
5214 | mov esi, ecx |
5215 | dec esi |
5215 | dec esi |
5216 | lea esi, [esi*3] |
5216 | lea esi, [esi*3] |
5217 | 5217 | ||
5218 | add ebp, esi |
5218 | add ebp, esi |
5219 | add ebp, edi |
5219 | add ebp, edi |
5220 | 5220 | ||
5221 | add ebx, edx |
5221 | add ebx, edx |
5222 | ;-------------------------------------- |
5222 | ;-------------------------------------- |
5223 | align 4 |
5223 | align 4 |
5224 | .start_y: |
5224 | .start_y: |
5225 | push ecx edx |
5225 | push ecx edx |
5226 | ;-------------------------------------- |
5226 | ;-------------------------------------- |
5227 | align 4 |
5227 | align 4 |
5228 | .start_x: |
5228 | .start_x: |
5229 | push eax ebx ecx |
5229 | push eax ebx ecx |
5230 | add eax, ecx |
5230 | add eax, ecx |
5231 | 5231 | ||
5232 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5232 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5233 | call dword [GETPIXEL]; eax - x, ebx - y |
5233 | call dword [GETPIXEL]; eax - x, ebx - y |
5234 | 5234 | ||
5235 | mov [ebp], cx |
5235 | mov [ebp], cx |
5236 | shr ecx, 16 |
5236 | shr ecx, 16 |
5237 | mov [ebp+2], cl |
5237 | mov [ebp+2], cl |
5238 | 5238 | ||
5239 | pop ecx ebx eax |
5239 | pop ecx ebx eax |
5240 | sub ebp, 3 |
5240 | sub ebp, 3 |
5241 | dec ecx |
5241 | dec ecx |
5242 | jnz .start_x |
5242 | jnz .start_x |
5243 | pop edx ecx |
5243 | pop edx ecx |
5244 | dec ebx |
5244 | dec ebx |
5245 | dec edx |
5245 | dec edx |
5246 | jnz .start_y |
5246 | jnz .start_y |
5247 | popad |
5247 | popad |
5248 | ret |
5248 | ret |
5249 | ;----------------------------------------------------------------------------- |
5249 | ;----------------------------------------------------------------------------- |
5250 | align 4 |
5250 | align 4 |
5251 | syscall_putarea_backgr: |
5251 | syscall_putarea_backgr: |
5252 | ;eax = 25 |
5252 | ;eax = 25 |
5253 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5253 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5254 | ;ecx = [size x]*65536 + [size y] |
5254 | ;ecx = [size x]*65536 + [size y] |
5255 | ;edx = [start x]*65536 + [start y] |
5255 | ;edx = [start x]*65536 + [start y] |
5256 | pushad |
5256 | pushad |
5257 | mov edi, ebx |
5257 | mov edi, ebx |
5258 | mov eax, edx |
5258 | mov eax, edx |
5259 | shr eax, 16 |
5259 | shr eax, 16 |
5260 | mov ebx, edx |
5260 | mov ebx, edx |
5261 | and ebx, 0xffff |
5261 | and ebx, 0xffff |
5262 | dec eax |
5262 | dec eax |
5263 | dec ebx |
5263 | dec ebx |
5264 | ; eax - x, ebx - y |
5264 | ; eax - x, ebx - y |
5265 | mov edx, ecx |
5265 | mov edx, ecx |
5266 | shr ecx, 16 |
5266 | shr ecx, 16 |
5267 | and edx, 0xffff |
5267 | and edx, 0xffff |
5268 | mov esi, ecx |
5268 | mov esi, ecx |
5269 | ; ecx - size x, edx - size y |
5269 | ; ecx - size x, edx - size y |
5270 | mov ebp, edx |
5270 | mov ebp, edx |
5271 | dec ebp |
5271 | dec ebp |
5272 | shl ebp, 2 |
5272 | shl ebp, 2 |
5273 | 5273 | ||
5274 | imul ebp, esi |
5274 | imul ebp, esi |
5275 | 5275 | ||
5276 | mov esi, ecx |
5276 | mov esi, ecx |
5277 | dec esi |
5277 | dec esi |
5278 | shl esi, 2 |
5278 | shl esi, 2 |
5279 | 5279 | ||
5280 | add ebp, esi |
5280 | add ebp, esi |
5281 | add ebp, edi |
5281 | add ebp, edi |
5282 | 5282 | ||
5283 | add ebx, edx |
5283 | add ebx, edx |
5284 | ;-------------------------------------- |
5284 | ;-------------------------------------- |
5285 | align 4 |
5285 | align 4 |
5286 | .start_y: |
5286 | .start_y: |
5287 | push ecx edx |
5287 | push ecx edx |
5288 | ;-------------------------------------- |
5288 | ;-------------------------------------- |
5289 | align 4 |
5289 | align 4 |
5290 | .start_x: |
5290 | .start_x: |
5291 | push eax ecx |
5291 | push eax ecx |
5292 | add eax, ecx |
5292 | add eax, ecx |
5293 | 5293 | ||
5294 | mov ecx, [ebp] |
5294 | mov ecx, [ebp] |
5295 | rol ecx, 8 |
5295 | rol ecx, 8 |
5296 | test cl, cl ; transparensy = 0 |
5296 | test cl, cl ; transparensy = 0 |
5297 | jz .no_put |
5297 | jz .no_put |
5298 | 5298 | ||
5299 | xor cl, cl |
5299 | xor cl, cl |
5300 | ror ecx, 8 |
5300 | ror ecx, 8 |
5301 | 5301 | ||
5302 | pushad |
5302 | pushad |
5303 | mov edx, [d_width_calc_area + ebx*4] |
5303 | mov edx, [d_width_calc_area + ebx*4] |
5304 | add edx, [_WinMapAddress] |
5304 | add edx, [_WinMapAddress] |
5305 | movzx edx, byte [eax+edx] |
5305 | movzx edx, byte [eax+edx] |
5306 | cmp dl, byte 1 |
5306 | cmp dl, byte 1 |
5307 | jne @f |
5307 | jne @f |
5308 | 5308 | ||
5309 | call dword [PUTPIXEL]; eax - x, ebx - y |
5309 | call dword [PUTPIXEL]; eax - x, ebx - y |
5310 | ;-------------------------------------- |
5310 | ;-------------------------------------- |
5311 | align 4 |
5311 | align 4 |
5312 | @@: |
5312 | @@: |
5313 | popad |
5313 | popad |
5314 | ;-------------------------------------- |
5314 | ;-------------------------------------- |
5315 | align 4 |
5315 | align 4 |
5316 | .no_put: |
5316 | .no_put: |
5317 | pop ecx eax |
5317 | pop ecx eax |
5318 | 5318 | ||
5319 | sub ebp, 4 |
5319 | sub ebp, 4 |
5320 | dec ecx |
5320 | dec ecx |
5321 | jnz .start_x |
5321 | jnz .start_x |
5322 | 5322 | ||
5323 | pop edx ecx |
5323 | pop edx ecx |
5324 | dec ebx |
5324 | dec ebx |
5325 | dec edx |
5325 | dec edx |
5326 | jnz .start_y |
5326 | jnz .start_y |
5327 | 5327 | ||
5328 | popad |
5328 | popad |
5329 | ret |
5329 | ret |
5330 | ;----------------------------------------------------------------------------- |
5330 | ;----------------------------------------------------------------------------- |
5331 | align 4 |
5331 | align 4 |
5332 | syscall_drawline: ; DrawLine |
5332 | syscall_drawline: ; DrawLine |
5333 | 5333 | ||
5334 | mov edi, [TASK_BASE] |
5334 | mov edi, [TASK_BASE] |
5335 | movzx eax, word[edi-twdw+WDATA.box.left] |
5335 | movzx eax, word[edi-twdw+WDATA.box.left] |
5336 | mov ebp, eax |
5336 | mov ebp, eax |
5337 | mov esi, [current_slot] |
5337 | mov esi, [current_slot] |
5338 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5338 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5339 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5339 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5340 | add ebp, ebx |
5340 | add ebp, ebx |
5341 | shl eax, 16 |
5341 | shl eax, 16 |
5342 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5342 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5343 | add eax, ebp |
5343 | add eax, ebp |
5344 | mov ebp, ebx |
5344 | mov ebp, ebx |
5345 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5345 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5346 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5346 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5347 | add ebp, ecx |
5347 | add ebp, ecx |
5348 | shl ebx, 16 |
5348 | shl ebx, 16 |
5349 | xor edi, edi |
5349 | xor edi, edi |
5350 | add ebx, ebp |
5350 | add ebx, ebp |
5351 | mov ecx, edx |
5351 | mov ecx, edx |
5352 | ; jmp [draw_line] |
5352 | ; jmp [draw_line] |
5353 | jmp __sys_draw_line |
5353 | jmp __sys_draw_line |
5354 | 5354 | ||
5355 | 5355 | ||
5356 | align 4 |
5356 | align 4 |
5357 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5357 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5358 | 5358 | ||
5359 | call r_f_port_area |
5359 | call r_f_port_area |
5360 | mov [esp+32], eax |
5360 | mov [esp+32], eax |
5361 | ret |
5361 | ret |
5362 | 5362 | ||
5363 | align 4 |
5363 | align 4 |
5364 | syscall_threads: ; CreateThreads |
5364 | syscall_threads: ; CreateThreads |
5365 | ; |
5365 | ; |
5366 | ; ecx=thread entry point |
5366 | ; ecx=thread entry point |
5367 | ; edx=thread stack pointer |
5367 | ; edx=thread stack pointer |
5368 | ; |
5368 | ; |
5369 | ; on return : eax = pid |
5369 | ; on return : eax = pid |
5370 | 5370 | ||
5371 | xor ebx, ebx |
5371 | xor ebx, ebx |
5372 | call new_sys_threads |
5372 | call new_sys_threads |
5373 | 5373 | ||
5374 | mov [esp+32], eax |
5374 | mov [esp+32], eax |
5375 | ret |
5375 | ret |
5376 | 5376 | ||
5377 | align 4 |
5377 | align 4 |
5378 | 5378 | ||
5379 | paleholder: |
5379 | paleholder: |
5380 | ret |
5380 | ret |
5381 | ;------------------------------------------------------------------------------ |
5381 | ;------------------------------------------------------------------------------ |
5382 | align 4 |
5382 | align 4 |
5383 | calculate_fast_getting_offset_for_WinMapAddress: |
5383 | calculate_fast_getting_offset_for_WinMapAddress: |
5384 | ; calculate data area for fast getting offset to _WinMapAddress |
5384 | ; calculate data area for fast getting offset to _WinMapAddress |
5385 | xor eax, eax |
5385 | xor eax, eax |
5386 | mov ecx, [_display.height] |
5386 | mov ecx, [_display.height] |
5387 | mov edi, d_width_calc_area |
5387 | mov edi, d_width_calc_area |
5388 | cld |
5388 | cld |
5389 | @@: |
5389 | @@: |
5390 | stosd |
5390 | stosd |
5391 | add eax, [_display.width] |
5391 | add eax, [_display.width] |
5392 | dec ecx |
5392 | dec ecx |
5393 | jnz @r |
5393 | jnz @r |
5394 | ret |
5394 | ret |
5395 | ;------------------------------------------------------------------------------ |
5395 | ;------------------------------------------------------------------------------ |
5396 | align 4 |
5396 | align 4 |
5397 | calculate_fast_getting_offset_for_LFB: |
5397 | calculate_fast_getting_offset_for_LFB: |
5398 | ; calculate data area for fast getting offset to LFB |
5398 | ; calculate data area for fast getting offset to LFB |
5399 | xor eax, eax |
5399 | xor eax, eax |
5400 | mov ecx, [_display.height] |
5400 | mov ecx, [_display.height] |
5401 | mov edi, BPSLine_calc_area |
5401 | mov edi, BPSLine_calc_area |
5402 | cld |
5402 | cld |
5403 | @@: |
5403 | @@: |
5404 | stosd |
5404 | stosd |
5405 | add eax, [_display.pitch] |
5405 | add eax, [_display.pitch] |
5406 | dec ecx |
5406 | dec ecx |
5407 | jnz @r |
5407 | jnz @r |
5408 | ret |
5408 | ret |
5409 | ;------------------------------------------------------------------------------ |
5409 | ;------------------------------------------------------------------------------ |
5410 | align 4 |
5410 | align 4 |
5411 | set_screen: |
5411 | set_screen: |
5412 | ; in: |
5412 | ; in: |
5413 | ; eax - new Screen_Max_X |
5413 | ; eax - new Screen_Max_X |
5414 | ; ecx - new BytesPerScanLine |
5414 | ; ecx - new BytesPerScanLine |
5415 | ; edx - new Screen_Max_Y |
5415 | ; edx - new Screen_Max_Y |
5416 | 5416 | ||
5417 | pushfd |
5417 | pushfd |
5418 | cli |
5418 | cli |
5419 | 5419 | ||
5420 | mov [Screen_Max_X], eax |
5420 | mov [Screen_Max_X], eax |
5421 | mov [Screen_Max_Y], edx |
5421 | mov [Screen_Max_Y], edx |
5422 | mov [_display.pitch], ecx |
5422 | mov [_display.pitch], ecx |
5423 | 5423 | ||
5424 | mov [screen_workarea.right], eax |
5424 | mov [screen_workarea.right], eax |
5425 | mov [screen_workarea.bottom], edx |
5425 | mov [screen_workarea.bottom], edx |
5426 | 5426 | ||
5427 | push ebx |
5427 | push ebx |
5428 | push esi |
5428 | push esi |
5429 | push edi |
5429 | push edi |
5430 | 5430 | ||
5431 | pushad |
5431 | pushad |
5432 | 5432 | ||
5433 | cmp [do_not_touch_winmap], 1 |
5433 | cmp [do_not_touch_winmap], 1 |
5434 | je @f |
5434 | je @f |
5435 | 5435 | ||
5436 | stdcall kernel_free, [_WinMapAddress] |
5436 | stdcall kernel_free, [_WinMapAddress] |
5437 | 5437 | ||
5438 | mov eax, [_display.width] |
5438 | mov eax, [_display.width] |
5439 | mul [_display.height] |
5439 | mul [_display.height] |
5440 | mov [_WinMapSize], eax |
5440 | mov [_WinMapSize], eax |
5441 | 5441 | ||
5442 | stdcall kernel_alloc, eax |
5442 | stdcall kernel_alloc, eax |
5443 | mov [_WinMapAddress], eax |
5443 | mov [_WinMapAddress], eax |
5444 | test eax, eax |
5444 | test eax, eax |
5445 | jz .epic_fail |
5445 | jz .epic_fail |
5446 | ; store for f.18.24 |
5446 | ; store for f.18.24 |
5447 | mov eax, [_display.width] |
5447 | mov eax, [_display.width] |
5448 | mov [display_width_standard], eax |
5448 | mov [display_width_standard], eax |
5449 | 5449 | ||
5450 | mov eax, [_display.height] |
5450 | mov eax, [_display.height] |
5451 | mov [display_height_standard], eax |
5451 | mov [display_height_standard], eax |
5452 | @@: |
5452 | @@: |
5453 | call calculate_fast_getting_offset_for_WinMapAddress |
5453 | call calculate_fast_getting_offset_for_WinMapAddress |
5454 | ; for Qemu or non standart video cards |
5454 | ; for Qemu or non standart video cards |
5455 | ; Unfortunately [BytesPerScanLine] does not always |
5455 | ; Unfortunately [BytesPerScanLine] does not always |
5456 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5456 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5457 | call calculate_fast_getting_offset_for_LFB |
5457 | call calculate_fast_getting_offset_for_LFB |
5458 | popad |
5458 | popad |
5459 | 5459 | ||
5460 | call repos_windows |
5460 | call repos_windows |
5461 | xor eax, eax |
5461 | xor eax, eax |
5462 | xor ebx, ebx |
5462 | xor ebx, ebx |
5463 | mov ecx, [Screen_Max_X] |
5463 | mov ecx, [Screen_Max_X] |
5464 | mov edx, [Screen_Max_Y] |
5464 | mov edx, [Screen_Max_Y] |
5465 | call calculatescreen |
5465 | call calculatescreen |
5466 | pop edi |
5466 | pop edi |
5467 | pop esi |
5467 | pop esi |
5468 | pop ebx |
5468 | pop ebx |
5469 | 5469 | ||
5470 | popfd |
5470 | popfd |
5471 | ret |
5471 | ret |
5472 | 5472 | ||
5473 | .epic_fail: |
5473 | .epic_fail: |
5474 | hlt ; Houston, we've had a problem |
5474 | hlt ; Houston, we've had a problem |
5475 | 5475 | ||
5476 | ; --------------- APM --------------------- |
5476 | ; --------------- APM --------------------- |
5477 | uglobal |
5477 | uglobal |
5478 | apm_entry dp 0 |
5478 | apm_entry dp 0 |
5479 | apm_vf dd 0 |
5479 | apm_vf dd 0 |
5480 | endg |
5480 | endg |
5481 | 5481 | ||
5482 | align 4 |
5482 | align 4 |
5483 | sys_apm: |
5483 | sys_apm: |
5484 | xor eax, eax |
5484 | xor eax, eax |
5485 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5485 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5486 | jne @f |
5486 | jne @f |
5487 | inc eax |
5487 | inc eax |
5488 | or dword [esp + 44], eax ; error |
5488 | or dword [esp + 44], eax ; error |
5489 | add eax, 7 |
5489 | add eax, 7 |
5490 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5490 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5491 | ret |
5491 | ret |
5492 | 5492 | ||
5493 | @@: |
5493 | @@: |
5494 | ; xchg eax, ecx |
5494 | ; xchg eax, ecx |
5495 | ; xchg ebx, ecx |
5495 | ; xchg ebx, ecx |
5496 | 5496 | ||
5497 | cmp dx, 3 |
5497 | cmp dx, 3 |
5498 | ja @f |
5498 | ja @f |
5499 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5499 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5500 | mov eax, [apm_vf] |
5500 | mov eax, [apm_vf] |
5501 | mov [esp + 32], eax |
5501 | mov [esp + 32], eax |
5502 | shr eax, 16 |
5502 | shr eax, 16 |
5503 | mov [esp + 28], eax |
5503 | mov [esp + 28], eax |
5504 | ret |
5504 | ret |
5505 | 5505 | ||
5506 | @@: |
5506 | @@: |
5507 | 5507 | ||
5508 | mov esi, [master_tab+(OS_BASE shr 20)] |
5508 | mov esi, [master_tab+(OS_BASE shr 20)] |
5509 | xchg [master_tab], esi |
5509 | xchg [master_tab], esi |
5510 | push esi |
5510 | push esi |
5511 | mov edi, cr3 |
5511 | mov edi, cr3 |
5512 | mov cr3, edi ;flush TLB |
5512 | mov cr3, edi ;flush TLB |
5513 | 5513 | ||
5514 | call pword [apm_entry] ;call APM BIOS |
5514 | call pword [apm_entry] ;call APM BIOS |
5515 | 5515 | ||
5516 | xchg eax, [esp] |
5516 | xchg eax, [esp] |
5517 | mov [master_tab], eax |
5517 | mov [master_tab], eax |
5518 | mov eax, cr3 |
5518 | mov eax, cr3 |
5519 | mov cr3, eax |
5519 | mov cr3, eax |
5520 | pop eax |
5520 | pop eax |
5521 | 5521 | ||
5522 | mov [esp + 4 ], edi |
5522 | mov [esp + 4 ], edi |
5523 | mov [esp + 8], esi |
5523 | mov [esp + 8], esi |
5524 | mov [esp + 20], ebx |
5524 | mov [esp + 20], ebx |
5525 | mov [esp + 24], edx |
5525 | mov [esp + 24], edx |
5526 | mov [esp + 28], ecx |
5526 | mov [esp + 28], ecx |
5527 | mov [esp + 32], eax |
5527 | mov [esp + 32], eax |
5528 | setc al |
5528 | setc al |
5529 | and [esp + 44], byte 0xfe |
5529 | and [esp + 44], byte 0xfe |
5530 | or [esp + 44], al |
5530 | or [esp + 44], al |
5531 | ret |
5531 | ret |
5532 | ; ----------------------------------------- |
5532 | ; ----------------------------------------- |
5533 | 5533 | ||
5534 | align 4 |
5534 | align 4 |
5535 | 5535 | ||
5536 | undefined_syscall: ; Undefined system call |
5536 | undefined_syscall: ; Undefined system call |
5537 | mov [esp + 32], dword -1 |
5537 | mov [esp + 32], dword -1 |
5538 | ret |
5538 | ret |
5539 | 5539 | ||
5540 | align 4 |
5540 | align 4 |
5541 | system_shutdown: ; shut down the system |
5541 | system_shutdown: ; shut down the system |
5542 | 5542 | ||
5543 | cmp byte [BOOT_VARS+0x9030], 1 |
5543 | cmp byte [BOOT_VARS+0x9030], 1 |
5544 | jne @F |
5544 | jne @F |
5545 | ret |
5545 | ret |
5546 | @@: |
5546 | @@: |
5547 | call stop_all_services |
5547 | call stop_all_services |
5548 | 5548 | ||
5549 | yes_shutdown_param: |
5549 | yes_shutdown_param: |
5550 | ; Shutdown other CPUs, if initialized |
5550 | ; Shutdown other CPUs, if initialized |
5551 | cmp [ap_initialized], 0 |
5551 | cmp [ap_initialized], 0 |
5552 | jz .no_shutdown_cpus |
5552 | jz .no_shutdown_cpus |
5553 | mov edi, [LAPIC_BASE] |
5553 | mov edi, [LAPIC_BASE] |
5554 | add edi, 300h |
5554 | add edi, 300h |
5555 | mov esi, smpt+4 |
5555 | mov esi, smpt+4 |
5556 | mov ebx, [cpu_count] |
5556 | mov ebx, [cpu_count] |
5557 | dec ebx |
5557 | dec ebx |
5558 | .shutdown_cpus_loop: |
5558 | .shutdown_cpus_loop: |
5559 | lodsd |
5559 | lodsd |
5560 | shl eax, 24 |
5560 | shl eax, 24 |
5561 | mov [edi+10h], eax |
5561 | mov [edi+10h], eax |
5562 | ; assert INIT IPI |
5562 | ; assert INIT IPI |
5563 | mov dword [edi], 0C500h |
5563 | mov dword [edi], 0C500h |
5564 | @@: |
5564 | @@: |
5565 | test dword [edi], 1000h |
5565 | test dword [edi], 1000h |
5566 | jnz @b |
5566 | jnz @b |
5567 | ; deassert INIT IPI |
5567 | ; deassert INIT IPI |
5568 | mov dword [edi], 8500h |
5568 | mov dword [edi], 8500h |
5569 | @@: |
5569 | @@: |
5570 | test dword [edi], 1000h |
5570 | test dword [edi], 1000h |
5571 | jnz @b |
5571 | jnz @b |
5572 | ; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
5572 | ; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
5573 | dec ebx |
5573 | dec ebx |
5574 | jnz .shutdown_cpus_loop |
5574 | jnz .shutdown_cpus_loop |
5575 | .no_shutdown_cpus: |
5575 | .no_shutdown_cpus: |
5576 | 5576 | ||
5577 | cli |
5577 | cli |
5578 | 5578 | ||
5579 | if ~ defined extended_primary_loader |
5579 | if ~ defined extended_primary_loader |
5580 | ; load kernel.mnt to 0x7000:0 |
5580 | ; load kernel.mnt to 0x7000:0 |
5581 | mov ebx, kernel_file_load |
5581 | mov ebx, kernel_file_load |
5582 | pushad |
5582 | pushad |
5583 | call file_system_lfn |
5583 | call file_system_lfn |
5584 | popad |
5584 | popad |
5585 | 5585 | ||
5586 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5586 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5587 | mov edi, OS_BASE+0x40000 |
5587 | mov edi, OS_BASE+0x40000 |
5588 | mov ecx, 1000 |
5588 | mov ecx, 1000 |
5589 | rep movsb |
5589 | rep movsb |
5590 | end if |
5590 | end if |
5591 | 5591 | ||
5592 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5592 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5593 | ; mov edi, OS_BASE |
5593 | ; mov edi, OS_BASE |
5594 | ; mov ecx, 0x10000/4 |
5594 | ; mov ecx, 0x10000/4 |
5595 | ; cld |
5595 | ; cld |
5596 | ; rep movsd |
5596 | ; rep movsd |
5597 | 5597 | ||
5598 | call IRQ_mask_all |
5598 | call IRQ_mask_all |
5599 | 5599 | ||
5600 | cmp byte [OS_BASE + 0x9030], 2 |
5600 | cmp byte [OS_BASE + 0x9030], 2 |
5601 | jnz no_acpi_power_off |
5601 | jnz no_acpi_power_off |
5602 | 5602 | ||
5603 | ; scan for RSDP |
5603 | ; scan for RSDP |
5604 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5604 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5605 | movzx eax, word [OS_BASE + 0x40E] |
5605 | movzx eax, word [OS_BASE + 0x40E] |
5606 | shl eax, 4 |
5606 | shl eax, 4 |
5607 | jz @f |
5607 | jz @f |
5608 | mov ecx, 1024/16 |
5608 | mov ecx, 1024/16 |
5609 | call scan_rsdp |
5609 | call scan_rsdp |
5610 | jnc .rsdp_found |
5610 | jnc .rsdp_found |
5611 | @@: |
5611 | @@: |
5612 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5612 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5613 | mov eax, 0xE0000 |
5613 | mov eax, 0xE0000 |
5614 | mov ecx, 0x2000 |
5614 | mov ecx, 0x2000 |
5615 | call scan_rsdp |
5615 | call scan_rsdp |
5616 | jc no_acpi_power_off |
5616 | jc no_acpi_power_off |
5617 | .rsdp_found: |
5617 | .rsdp_found: |
5618 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5618 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5619 | mov ebp, [ipc_tmp] |
5619 | mov ebp, [ipc_tmp] |
5620 | stdcall map_page, ebp, esi, PG_MAP |
5620 | stdcall map_page, ebp, esi, PG_MAP |
5621 | lea eax, [esi+1000h] |
5621 | lea eax, [esi+1000h] |
5622 | lea edx, [ebp+1000h] |
5622 | lea edx, [ebp+1000h] |
5623 | stdcall map_page, edx, eax, PG_MAP |
5623 | stdcall map_page, edx, eax, PG_MAP |
5624 | and esi, 0xFFF |
5624 | and esi, 0xFFF |
5625 | add esi, ebp |
5625 | add esi, ebp |
5626 | cmp dword [esi], 'RSDT' |
5626 | cmp dword [esi], 'RSDT' |
5627 | jnz no_acpi_power_off |
5627 | jnz no_acpi_power_off |
5628 | mov ecx, [esi+4] |
5628 | mov ecx, [esi+4] |
5629 | sub ecx, 24h |
5629 | sub ecx, 24h |
5630 | jbe no_acpi_power_off |
5630 | jbe no_acpi_power_off |
5631 | shr ecx, 2 |
5631 | shr ecx, 2 |
5632 | add esi, 24h |
5632 | add esi, 24h |
5633 | .scan_fadt: |
5633 | .scan_fadt: |
5634 | lodsd |
5634 | lodsd |
5635 | mov ebx, eax |
5635 | mov ebx, eax |
5636 | lea eax, [ebp+2000h] |
5636 | lea eax, [ebp+2000h] |
5637 | stdcall map_page, eax, ebx, PG_MAP |
5637 | stdcall map_page, eax, ebx, PG_MAP |
5638 | lea eax, [ebp+3000h] |
5638 | lea eax, [ebp+3000h] |
5639 | add ebx, 0x1000 |
5639 | add ebx, 0x1000 |
5640 | stdcall map_page, eax, ebx, PG_MAP |
5640 | stdcall map_page, eax, ebx, PG_MAP |
5641 | and ebx, 0xFFF |
5641 | and ebx, 0xFFF |
5642 | lea ebx, [ebx+ebp+2000h] |
5642 | lea ebx, [ebx+ebp+2000h] |
5643 | cmp dword [ebx], 'FACP' |
5643 | cmp dword [ebx], 'FACP' |
5644 | jz .fadt_found |
5644 | jz .fadt_found |
5645 | loop .scan_fadt |
5645 | loop .scan_fadt |
5646 | jmp no_acpi_power_off |
5646 | jmp no_acpi_power_off |
5647 | .fadt_found: |
5647 | .fadt_found: |
5648 | ; ebx is linear address of FADT |
5648 | ; ebx is linear address of FADT |
5649 | mov edi, [ebx+40] ; physical address of the DSDT |
5649 | mov edi, [ebx+40] ; physical address of the DSDT |
5650 | lea eax, [ebp+4000h] |
5650 | lea eax, [ebp+4000h] |
5651 | stdcall map_page, eax, edi, PG_MAP |
5651 | stdcall map_page, eax, edi, PG_MAP |
5652 | lea eax, [ebp+5000h] |
5652 | lea eax, [ebp+5000h] |
5653 | lea esi, [edi+0x1000] |
5653 | lea esi, [edi+0x1000] |
5654 | stdcall map_page, eax, esi, PG_MAP |
5654 | stdcall map_page, eax, esi, PG_MAP |
5655 | and esi, 0xFFF |
5655 | and esi, 0xFFF |
5656 | sub edi, esi |
5656 | sub edi, esi |
5657 | cmp dword [esi+ebp+4000h], 'DSDT' |
5657 | cmp dword [esi+ebp+4000h], 'DSDT' |
5658 | jnz no_acpi_power_off |
5658 | jnz no_acpi_power_off |
5659 | mov eax, [esi+ebp+4004h] ; DSDT length |
5659 | mov eax, [esi+ebp+4004h] ; DSDT length |
5660 | sub eax, 36+4 |
5660 | sub eax, 36+4 |
5661 | jbe no_acpi_power_off |
5661 | jbe no_acpi_power_off |
5662 | add esi, 36 |
5662 | add esi, 36 |
5663 | .scan_dsdt: |
5663 | .scan_dsdt: |
5664 | cmp dword [esi+ebp+4000h], '_S5_' |
5664 | cmp dword [esi+ebp+4000h], '_S5_' |
5665 | jnz .scan_dsdt_cont |
5665 | jnz .scan_dsdt_cont |
5666 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5666 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5667 | jnz .scan_dsdt_cont |
5667 | jnz .scan_dsdt_cont |
5668 | mov dl, [esi+ebp+4000h+6] |
5668 | mov dl, [esi+ebp+4000h+6] |
5669 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5669 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5670 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5670 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5671 | ja .scan_dsdt_cont |
5671 | ja .scan_dsdt_cont |
5672 | cmp dl, 1 |
5672 | cmp dl, 1 |
5673 | jb .scan_dsdt_cont |
5673 | jb .scan_dsdt_cont |
5674 | lea esi, [esi+ebp+4000h+7] |
5674 | lea esi, [esi+ebp+4000h+7] |
5675 | xor ecx, ecx |
5675 | xor ecx, ecx |
5676 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5676 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5677 | jz @f |
5677 | jz @f |
5678 | cmp byte [esi], 0xA |
5678 | cmp byte [esi], 0xA |
5679 | jnz no_acpi_power_off |
5679 | jnz no_acpi_power_off |
5680 | inc esi |
5680 | inc esi |
5681 | mov cl, [esi] |
5681 | mov cl, [esi] |
5682 | @@: |
5682 | @@: |
5683 | inc esi |
5683 | inc esi |
5684 | cmp dl, 2 |
5684 | cmp dl, 2 |
5685 | jb @f |
5685 | jb @f |
5686 | cmp byte [esi], 0 |
5686 | cmp byte [esi], 0 |
5687 | jz @f |
5687 | jz @f |
5688 | cmp byte [esi], 0xA |
5688 | cmp byte [esi], 0xA |
5689 | jnz no_acpi_power_off |
5689 | jnz no_acpi_power_off |
5690 | inc esi |
5690 | inc esi |
5691 | mov ch, [esi] |
5691 | mov ch, [esi] |
5692 | @@: |
5692 | @@: |
5693 | jmp do_acpi_power_off |
5693 | jmp do_acpi_power_off |
5694 | .scan_dsdt_cont: |
5694 | .scan_dsdt_cont: |
5695 | inc esi |
5695 | inc esi |
5696 | cmp esi, 0x1000 |
5696 | cmp esi, 0x1000 |
5697 | jb @f |
5697 | jb @f |
5698 | sub esi, 0x1000 |
5698 | sub esi, 0x1000 |
5699 | add edi, 0x1000 |
5699 | add edi, 0x1000 |
5700 | push eax |
5700 | push eax |
5701 | lea eax, [ebp+4000h] |
5701 | lea eax, [ebp+4000h] |
5702 | stdcall map_page, eax, edi, PG_MAP |
5702 | stdcall map_page, eax, edi, PG_MAP |
5703 | push PG_MAP |
5703 | push PG_MAP |
5704 | lea eax, [edi+1000h] |
5704 | lea eax, [edi+1000h] |
5705 | push eax |
5705 | push eax |
5706 | lea eax, [ebp+5000h] |
5706 | lea eax, [ebp+5000h] |
5707 | push eax |
5707 | push eax |
5708 | stdcall map_page |
5708 | stdcall map_page |
5709 | pop eax |
5709 | pop eax |
5710 | @@: |
5710 | @@: |
5711 | dec eax |
5711 | dec eax |
5712 | jnz .scan_dsdt |
5712 | jnz .scan_dsdt |
5713 | jmp no_acpi_power_off |
5713 | jmp no_acpi_power_off |
5714 | do_acpi_power_off: |
5714 | do_acpi_power_off: |
5715 | mov edx, [ebx+48] |
5715 | mov edx, [ebx+48] |
5716 | test edx, edx |
5716 | test edx, edx |
5717 | jz .nosmi |
5717 | jz .nosmi |
5718 | mov al, [ebx+52] |
5718 | mov al, [ebx+52] |
5719 | out dx, al |
5719 | out dx, al |
5720 | mov edx, [ebx+64] |
5720 | mov edx, [ebx+64] |
5721 | @@: |
5721 | @@: |
5722 | in ax, dx |
5722 | in ax, dx |
5723 | test al, 1 |
5723 | test al, 1 |
5724 | jz @b |
5724 | jz @b |
5725 | .nosmi: |
5725 | .nosmi: |
5726 | and cx, 0x0707 |
5726 | and cx, 0x0707 |
5727 | shl cx, 2 |
5727 | shl cx, 2 |
5728 | or cx, 0x2020 |
5728 | or cx, 0x2020 |
5729 | mov edx, [ebx+64] |
5729 | mov edx, [ebx+64] |
5730 | in ax, dx |
5730 | in ax, dx |
5731 | and ax, 203h |
5731 | and ax, 203h |
5732 | or ah, cl |
5732 | or ah, cl |
5733 | out dx, ax |
5733 | out dx, ax |
5734 | mov edx, [ebx+68] |
5734 | mov edx, [ebx+68] |
5735 | test edx, edx |
5735 | test edx, edx |
5736 | jz @f |
5736 | jz @f |
5737 | in ax, dx |
5737 | in ax, dx |
5738 | and ax, 203h |
5738 | and ax, 203h |
5739 | or ah, ch |
5739 | or ah, ch |
5740 | out dx, ax |
5740 | out dx, ax |
5741 | @@: |
5741 | @@: |
5742 | jmp $ |
5742 | jmp $ |
5743 | 5743 | ||
5744 | 5744 | ||
5745 | scan_rsdp: |
5745 | scan_rsdp: |
5746 | add eax, OS_BASE |
5746 | add eax, OS_BASE |
5747 | .s: |
5747 | .s: |
5748 | cmp dword [eax], 'RSD ' |
5748 | cmp dword [eax], 'RSD ' |
5749 | jnz .n |
5749 | jnz .n |
5750 | cmp dword [eax+4], 'PTR ' |
5750 | cmp dword [eax+4], 'PTR ' |
5751 | jnz .n |
5751 | jnz .n |
5752 | xor edx, edx |
5752 | xor edx, edx |
5753 | xor esi, esi |
5753 | xor esi, esi |
5754 | @@: |
5754 | @@: |
5755 | add dl, [eax+esi] |
5755 | add dl, [eax+esi] |
5756 | inc esi |
5756 | inc esi |
5757 | cmp esi, 20 |
5757 | cmp esi, 20 |
5758 | jnz @b |
5758 | jnz @b |
5759 | test dl, dl |
5759 | test dl, dl |
5760 | jz .ok |
5760 | jz .ok |
5761 | .n: |
5761 | .n: |
5762 | add eax, 10h |
5762 | add eax, 10h |
5763 | loop .s |
5763 | loop .s |
5764 | stc |
5764 | stc |
5765 | .ok: |
5765 | .ok: |
5766 | ret |
5766 | ret |
5767 | 5767 | ||
5768 | no_acpi_power_off: |
5768 | no_acpi_power_off: |
5769 | call create_trampoline_pgmap |
5769 | call create_trampoline_pgmap |
5770 | mov cr3, eax |
5770 | mov cr3, eax |
5771 | jmp become_real+0x10000 |
5771 | jmp become_real+0x10000 |
5772 | iglobal |
5772 | iglobal |
5773 | align 4 |
5773 | align 4 |
5774 | realmode_gdt: |
5774 | realmode_gdt: |
5775 | ; selector 0 - not used |
5775 | ; selector 0 - not used |
5776 | dw 23 |
5776 | dw 23 |
5777 | dd realmode_gdt-OS_BASE |
5777 | dd realmode_gdt-OS_BASE |
5778 | dw 0 |
5778 | dw 0 |
5779 | ; selector 8 - code from 1000:0000 to 1000:FFFF |
5779 | ; selector 8 - code from 1000:0000 to 1000:FFFF |
5780 | dw 0FFFFh |
5780 | dw 0FFFFh |
5781 | dw 0 |
5781 | dw 0 |
5782 | db 1 |
5782 | db 1 |
5783 | db 10011011b |
5783 | db 10011011b |
5784 | db 00000000b |
5784 | db 00000000b |
5785 | db 0 |
5785 | db 0 |
5786 | ; selector 10h - data from 1000:0000 to 1000:FFFF |
5786 | ; selector 10h - data from 1000:0000 to 1000:FFFF |
5787 | dw 0FFFFh |
5787 | dw 0FFFFh |
5788 | dw 0 |
5788 | dw 0 |
5789 | db 1 |
5789 | db 1 |
5790 | db 10010011b |
5790 | db 10010011b |
5791 | db 00000000b |
5791 | db 00000000b |
5792 | db 0 |
5792 | db 0 |
5793 | endg |
5793 | endg |
5794 | 5794 | ||
5795 | if ~ lang eq sp |
5795 | if ~ lang eq sp |
5796 | diff16 "end of .text segment",0,$ |
5796 | diff16 "end of .text segment",0,$ |
5797 | end if |
5797 | end if |
5798 | 5798 | ||
5799 | include "data32.inc" |
5799 | include "data32.inc" |
5800 | 5800 | ||
5801 | __REV__ = __REV |
5801 | __REV__ = __REV |
5802 | 5802 | ||
5803 | if ~ lang eq sp |
5803 | if ~ lang eq sp |
5804 | diff16 "end of kernel code",0,$ |
5804 | diff16 "end of kernel code",0,$ |
5805 | end if=> |
5805 | end if=> |