Rev 5359 | Rev 5363 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5359 | Rev 5360 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2014. 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: 5359 $ |
74 | $Revision: 5360 $ |
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_proc-OS_BASE+PROC.pdt_0 |
294 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
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 | ||
- | 354 | xor eax, eax |
|
- | 355 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
|
- | 356 | bt [cpu_caps], CAPS_PAT |
|
- | 357 | setc al |
|
- | 358 | shl eax, 7 |
|
- | 359 | or ebx, eax |
|
353 | 360 | ||
354 | mov eax, PG_GLOBAL |
361 | mov eax, PG_GLOBAL |
355 | bt [cpu_caps], CAPS_PGE |
362 | bt [cpu_caps], CAPS_PGE |
356 | jnc @F |
363 | jnc @F |
357 | 364 | ||
358 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
365 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
359 | or [pte_valid_mask], eax |
366 | or ebx, eax |
360 | 367 | ||
361 | mov ebx, cr4 |
368 | mov eax, cr4 |
362 | or ebx, CR4_PGE |
369 | or eax, CR4_PGE |
363 | mov cr4, ebx |
370 | mov cr4, eax |
- | 371 | @@: |
|
- | 372 | mov [pte_valid_mask], ebx |
|
364 | @@: |
373 | |
365 | xor eax, eax |
374 | xor eax, eax |
366 | mov dword [sys_proc+PROC.pdt_0], eax |
375 | mov dword [sys_proc+PROC.pdt_0], eax |
367 | mov dword [sys_proc+PROC.pdt_0+4], eax |
376 | mov dword [sys_proc+PROC.pdt_0+4], eax |
368 | 377 | ||
369 | mov eax, cr3 |
378 | mov eax, cr3 |
370 | mov cr3, eax ; flush TLB |
379 | mov cr3, eax ; flush TLB |
371 | 380 | ||
372 | mov ecx, pg_data.mutex |
381 | mov ecx, pg_data.mutex |
373 | call mutex_init |
382 | call mutex_init |
374 | 383 | ||
375 | mov ecx, disk_list_mutex |
384 | mov ecx, disk_list_mutex |
376 | call mutex_init |
385 | call mutex_init |
377 | 386 | ||
378 | mov ecx, keyboard_list_mutex |
387 | mov ecx, keyboard_list_mutex |
379 | call mutex_init |
388 | call mutex_init |
380 | 389 | ||
381 | mov ecx, unpack_mutex |
390 | mov ecx, unpack_mutex |
382 | call mutex_init |
391 | call mutex_init |
383 | 392 | ||
384 | mov ecx, application_table_mutex |
393 | mov ecx, application_table_mutex |
385 | call mutex_init |
394 | call mutex_init |
386 | 395 | ||
387 | mov ecx, ide_mutex |
396 | mov ecx, ide_mutex |
388 | call mutex_init |
397 | call mutex_init |
389 | mov ecx, ide_channel1_mutex |
398 | mov ecx, ide_channel1_mutex |
390 | call mutex_init |
399 | call mutex_init |
391 | mov ecx, ide_channel2_mutex |
400 | mov ecx, ide_channel2_mutex |
392 | call mutex_init |
401 | call mutex_init |
393 | mov ecx, ide_channel3_mutex |
402 | mov ecx, ide_channel3_mutex |
394 | call mutex_init |
403 | call mutex_init |
395 | mov ecx, ide_channel4_mutex |
404 | mov ecx, ide_channel4_mutex |
396 | call mutex_init |
405 | call mutex_init |
397 | mov ecx, ide_channel5_mutex |
406 | mov ecx, ide_channel5_mutex |
398 | call mutex_init |
407 | call mutex_init |
399 | mov ecx, ide_channel6_mutex |
408 | mov ecx, ide_channel6_mutex |
400 | call mutex_init |
409 | call mutex_init |
401 | ;----------------------------------------------------------------------------- |
410 | ;----------------------------------------------------------------------------- |
402 | ; SAVE REAL MODE VARIABLES |
411 | ; SAVE REAL MODE VARIABLES |
403 | ;----------------------------------------------------------------------------- |
412 | ;----------------------------------------------------------------------------- |
404 | ; --------------- APM --------------------- |
413 | ; --------------- APM --------------------- |
405 | 414 | ||
406 | ; init selectors |
415 | ; init selectors |
407 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
416 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
408 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
417 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
409 | ; protected-mode 32-bit code segment |
418 | ; protected-mode 32-bit code segment |
410 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
419 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
411 | ; protected-mode 16-bit code segment |
420 | ; protected-mode 16-bit code segment |
412 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
421 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
413 | ; protected-mode 16-bit data segment |
422 | ; protected-mode 16-bit data segment |
414 | 423 | ||
415 | shl eax, 4 |
424 | shl eax, 4 |
416 | mov [dword apm_code_32 + 2], ax |
425 | mov [dword apm_code_32 + 2], ax |
417 | shr eax, 16 |
426 | shr eax, 16 |
418 | mov [dword apm_code_32 + 4], al |
427 | mov [dword apm_code_32 + 4], al |
419 | 428 | ||
420 | shl ecx, 4 |
429 | shl ecx, 4 |
421 | mov [dword apm_code_16 + 2], cx |
430 | mov [dword apm_code_16 + 2], cx |
422 | shr ecx, 16 |
431 | shr ecx, 16 |
423 | mov [dword apm_code_16 + 4], cl |
432 | mov [dword apm_code_16 + 4], cl |
424 | 433 | ||
425 | shl edx, 4 |
434 | shl edx, 4 |
426 | mov [dword apm_data_16 + 2], dx |
435 | mov [dword apm_data_16 + 2], dx |
427 | shr edx, 16 |
436 | shr edx, 16 |
428 | mov [dword apm_data_16 + 4], dl |
437 | mov [dword apm_data_16 + 4], dl |
429 | 438 | ||
430 | mov dword[apm_entry], ebx |
439 | mov dword[apm_entry], ebx |
431 | mov word [apm_entry + 4], apm_code_32 - gdts |
440 | mov word [apm_entry + 4], apm_code_32 - gdts |
432 | 441 | ||
433 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
442 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
434 | mov [apm_vf], eax |
443 | mov [apm_vf], eax |
435 | ; ----------------------------------------- |
444 | ; ----------------------------------------- |
436 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
445 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
437 | mov [allow_dma_access], al |
446 | mov [allow_dma_access], al |
438 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
447 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
439 | mov [_display.bits_per_pixel], eax |
448 | mov [_display.bits_per_pixel], eax |
440 | mov [_display.vrefresh], 60 |
449 | mov [_display.vrefresh], 60 |
441 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
450 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
442 | mov [debug_direct_print], al |
451 | mov [debug_direct_print], al |
443 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
452 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
444 | mov [launcher_start], al |
453 | mov [launcher_start], al |
445 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
454 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
446 | mov [_display.width], eax |
455 | mov [_display.width], eax |
447 | mov [display_width_standard], eax |
456 | mov [display_width_standard], eax |
448 | dec eax |
457 | dec eax |
449 | mov [screen_workarea.right], eax |
458 | mov [screen_workarea.right], eax |
450 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
459 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
451 | mov [_display.height], eax |
460 | mov [_display.height], eax |
452 | mov [display_height_standard], eax |
461 | mov [display_height_standard], eax |
453 | dec eax |
462 | dec eax |
454 | mov [screen_workarea.bottom], eax |
463 | mov [screen_workarea.bottom], eax |
455 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
464 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
456 | mov dword [SCR_MODE], eax |
465 | mov dword [SCR_MODE], eax |
457 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
466 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
458 | ; mov [BANK_SWITCH], eax |
467 | ; mov [BANK_SWITCH], eax |
459 | mov eax, 640 *4 ; Bytes PerScanLine |
468 | mov eax, 640 *4 ; Bytes PerScanLine |
460 | cmp [SCR_MODE], word 0x13 ; 320x200 |
469 | cmp [SCR_MODE], word 0x13 ; 320x200 |
461 | je @f |
470 | je @f |
462 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
471 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
463 | je @f |
472 | je @f |
464 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
473 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
465 | @@: |
474 | @@: |
466 | mov [_display.lfb_pitch], eax |
475 | mov [_display.lfb_pitch], eax |
467 | mov eax, [_display.width] |
476 | mov eax, [_display.width] |
468 | mul [_display.height] |
477 | mul [_display.height] |
469 | mov [_display.win_map_size], eax |
478 | mov [_display.win_map_size], eax |
470 | 479 | ||
471 | call calculate_fast_getting_offset_for_WinMapAddress |
480 | call calculate_fast_getting_offset_for_WinMapAddress |
472 | ; for Qemu or non standart video cards |
481 | ; for Qemu or non standart video cards |
473 | ; Unfortunately [BytesPerScanLine] does not always |
482 | ; Unfortunately [BytesPerScanLine] does not always |
474 | ; equal to [_display.width] * [ScreenBPP] / 8 |
483 | ; equal to [_display.width] * [ScreenBPP] / 8 |
475 | call calculate_fast_getting_offset_for_LFB |
484 | call calculate_fast_getting_offset_for_LFB |
476 | 485 | ||
477 | mov esi, BOOT_VARS+0x9080 |
486 | mov esi, BOOT_VARS+0x9080 |
478 | movzx ecx, byte [esi-1] |
487 | movzx ecx, byte [esi-1] |
479 | mov [NumBiosDisks], ecx |
488 | mov [NumBiosDisks], ecx |
480 | mov edi, BiosDisksData |
489 | mov edi, BiosDisksData |
481 | rep movsd |
490 | rep movsd |
482 | 491 | ||
483 | setvideomode: |
492 | setvideomode: |
484 | 493 | ||
485 | mov eax, [BOOT_VARS+BOOT_LFB] |
494 | mov eax, [BOOT_VARS+BOOT_LFB] |
486 | mov [LFBAddress], eax |
495 | mov [LFBAddress], eax |
487 | 496 | ||
488 | cmp word [SCR_MODE], 0x0012 ; VGA (640x480 16 colors) |
497 | cmp word [SCR_MODE], 0x0012 ; VGA (640x480 16 colors) |
489 | je .vga |
498 | je .vga |
490 | cmp word [SCR_MODE], 0x0013 ; MCGA (320*200 256 colors) |
499 | cmp word [SCR_MODE], 0x0013 ; MCGA (320*200 256 colors) |
491 | je .32bpp |
500 | je .32bpp |
492 | cmp byte [_display.bits_per_pixel], 32 |
501 | cmp byte [_display.bits_per_pixel], 32 |
493 | je .32bpp |
502 | je .32bpp |
494 | cmp byte [_display.bits_per_pixel], 24 |
503 | cmp byte [_display.bits_per_pixel], 24 |
495 | je .24bpp |
504 | je .24bpp |
496 | cmp byte [_display.bits_per_pixel], 16 |
505 | cmp byte [_display.bits_per_pixel], 16 |
497 | je .16bpp |
506 | je .16bpp |
498 | ; cmp byte [_display.bits_per_pixel], 15 |
507 | ; cmp byte [_display.bits_per_pixel], 15 |
499 | ; je .15bpp |
508 | ; je .15bpp |
500 | 509 | ||
501 | .vga: |
510 | .vga: |
502 | mov [PUTPIXEL], VGA_putpixel |
511 | mov [PUTPIXEL], VGA_putpixel |
503 | mov [GETPIXEL], Vesa20_getpixel32 ; Conversion buffer is 32 bpp |
512 | mov [GETPIXEL], Vesa20_getpixel32 ; Conversion buffer is 32 bpp |
504 | mov [_display.bytes_per_pixel], 4 ; Conversion buffer is 32 bpp |
513 | mov [_display.bytes_per_pixel], 4 ; Conversion buffer is 32 bpp |
505 | jmp .finish |
514 | jmp .finish |
506 | 515 | ||
507 | ; .15bpp: |
516 | ; .15bpp: |
508 | ; mov [PUTPIXEL], Vesa20_putpixel15 |
517 | ; mov [PUTPIXEL], Vesa20_putpixel15 |
509 | ; mov [GETPIXEL], Vesa20_getpixel15 |
518 | ; mov [GETPIXEL], Vesa20_getpixel15 |
510 | ; mov [_display.bytes_per_pixel], 2 |
519 | ; mov [_display.bytes_per_pixel], 2 |
511 | ; jmp .finish |
520 | ; jmp .finish |
512 | 521 | ||
513 | .16bpp: |
522 | .16bpp: |
514 | mov [PUTPIXEL], Vesa20_putpixel16 |
523 | mov [PUTPIXEL], Vesa20_putpixel16 |
515 | mov [GETPIXEL], Vesa20_getpixel16 |
524 | mov [GETPIXEL], Vesa20_getpixel16 |
516 | mov [_display.bytes_per_pixel], 2 |
525 | mov [_display.bytes_per_pixel], 2 |
517 | jmp .finish |
526 | jmp .finish |
518 | 527 | ||
519 | .24bpp: |
528 | .24bpp: |
520 | mov [PUTPIXEL], Vesa20_putpixel24 |
529 | mov [PUTPIXEL], Vesa20_putpixel24 |
521 | mov [GETPIXEL], Vesa20_getpixel24 |
530 | mov [GETPIXEL], Vesa20_getpixel24 |
522 | mov [_display.bytes_per_pixel], 3 |
531 | mov [_display.bytes_per_pixel], 3 |
523 | jmp .finish |
532 | jmp .finish |
524 | 533 | ||
525 | .32bpp: |
534 | .32bpp: |
526 | mov [PUTPIXEL], Vesa20_putpixel32 |
535 | mov [PUTPIXEL], Vesa20_putpixel32 |
527 | mov [GETPIXEL], Vesa20_getpixel32 |
536 | mov [GETPIXEL], Vesa20_getpixel32 |
528 | mov [_display.bytes_per_pixel], 4 |
537 | mov [_display.bytes_per_pixel], 4 |
529 | ; jmp .finish |
538 | ; jmp .finish |
530 | 539 | ||
531 | .finish: |
540 | .finish: |
532 | mov [MOUSE_PICTURE], mousepointer |
541 | mov [MOUSE_PICTURE], mousepointer |
533 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
542 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
534 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
543 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
535 | 544 | ||
536 | ; -------- Fast System Call init ---------- |
545 | ; -------- Fast System Call init ---------- |
537 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
546 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
538 | bt [cpu_caps], CAPS_SEP |
547 | bt [cpu_caps], CAPS_SEP |
539 | jnc .SEnP ; SysEnter not Present |
548 | jnc .SEnP ; SysEnter not Present |
540 | xor edx, edx |
549 | xor edx, edx |
541 | mov ecx, MSR_SYSENTER_CS |
550 | mov ecx, MSR_SYSENTER_CS |
542 | mov eax, os_code |
551 | mov eax, os_code |
543 | wrmsr |
552 | wrmsr |
544 | mov ecx, MSR_SYSENTER_ESP |
553 | mov ecx, MSR_SYSENTER_ESP |
545 | ; mov eax, sysenter_stack ; Check it |
554 | ; mov eax, sysenter_stack ; Check it |
546 | xor eax, eax |
555 | xor eax, eax |
547 | wrmsr |
556 | wrmsr |
548 | mov ecx, MSR_SYSENTER_EIP |
557 | mov ecx, MSR_SYSENTER_EIP |
549 | mov eax, sysenter_entry |
558 | mov eax, sysenter_entry |
550 | wrmsr |
559 | wrmsr |
551 | .SEnP: |
560 | .SEnP: |
552 | ; AMD SYSCALL/SYSRET |
561 | ; AMD SYSCALL/SYSRET |
553 | cmp byte[cpu_vendor], 'A' |
562 | cmp byte[cpu_vendor], 'A' |
554 | jne .noSYSCALL |
563 | jne .noSYSCALL |
555 | mov eax, 0x80000001 |
564 | mov eax, 0x80000001 |
556 | cpuid |
565 | cpuid |
557 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
566 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
558 | jz .noSYSCALL |
567 | jz .noSYSCALL |
559 | mov ecx, MSR_AMD_EFER |
568 | mov ecx, MSR_AMD_EFER |
560 | rdmsr |
569 | rdmsr |
561 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
570 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
562 | wrmsr |
571 | wrmsr |
563 | 572 | ||
564 | ; !!!! It`s dirty hack, fix it !!! |
573 | ; !!!! It`s dirty hack, fix it !!! |
565 | ; Bits of EDX : |
574 | ; Bits of EDX : |
566 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
575 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
567 | ; and the contents of this field, plus 8, are copied into the SS register. |
576 | ; and the contents of this field, plus 8, are copied into the SS register. |
568 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
577 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
569 | ; and the contents of this field, plus 8, are copied into the SS register. |
578 | ; and the contents of this field, plus 8, are copied into the SS register. |
570 | 579 | ||
571 | ; mov edx, (os_code + 16) * 65536 + os_code |
580 | ; mov edx, (os_code + 16) * 65536 + os_code |
572 | mov edx, 0x1B0008 |
581 | mov edx, 0x1B0008 |
573 | 582 | ||
574 | mov eax, syscall_entry |
583 | mov eax, syscall_entry |
575 | mov ecx, MSR_AMD_STAR |
584 | mov ecx, MSR_AMD_STAR |
576 | wrmsr |
585 | wrmsr |
577 | .noSYSCALL: |
586 | .noSYSCALL: |
578 | ; ----------------------------------------- |
587 | ; ----------------------------------------- |
579 | stdcall alloc_page |
588 | stdcall alloc_page |
580 | stdcall map_page, tss-0xF80, eax, PG_SWR |
589 | stdcall map_page, tss-0xF80, eax, PG_SWR |
581 | stdcall alloc_page |
590 | stdcall alloc_page |
582 | stdcall map_page, tss+0x80, eax, PG_SWR |
591 | stdcall map_page, tss+0x80, eax, PG_SWR |
583 | stdcall alloc_page |
592 | stdcall alloc_page |
584 | stdcall map_page, tss+0x1080, eax, PG_SWR |
593 | stdcall map_page, tss+0x1080, eax, PG_SWR |
585 | 594 | ||
586 | ; LOAD IDT |
595 | ; LOAD IDT |
587 | 596 | ||
588 | call build_interrupt_table ;lidt is executed |
597 | call build_interrupt_table ;lidt is executed |
589 | ;lidt [idtreg] |
598 | ;lidt [idtreg] |
590 | 599 | ||
591 | call init_kernel_heap |
600 | call init_kernel_heap |
592 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
601 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
593 | mov [os_stack_seg], eax |
602 | mov [os_stack_seg], eax |
594 | 603 | ||
595 | lea esp, [eax+RING0_STACK_SIZE] |
604 | lea esp, [eax+RING0_STACK_SIZE] |
596 | 605 | ||
597 | mov [tss._ss0], os_stack |
606 | mov [tss._ss0], os_stack |
598 | mov [tss._esp0], esp |
607 | mov [tss._esp0], esp |
599 | mov [tss._esp], esp |
608 | mov [tss._esp], esp |
600 | mov [tss._cs], os_code |
609 | mov [tss._cs], os_code |
601 | mov [tss._ss], os_stack |
610 | mov [tss._ss], os_stack |
602 | mov [tss._ds], app_data |
611 | mov [tss._ds], app_data |
603 | mov [tss._es], app_data |
612 | mov [tss._es], app_data |
604 | mov [tss._fs], app_data |
613 | mov [tss._fs], app_data |
605 | mov [tss._gs], app_data |
614 | mov [tss._gs], app_data |
606 | mov [tss._io], 128 |
615 | mov [tss._io], 128 |
607 | ;Add IO access table - bit array of permitted ports |
616 | ;Add IO access table - bit array of permitted ports |
608 | mov edi, tss._io_map_0 |
617 | mov edi, tss._io_map_0 |
609 | xor eax, eax |
618 | xor eax, eax |
610 | not eax |
619 | not eax |
611 | mov ecx, 8192/4 |
620 | mov ecx, 8192/4 |
612 | rep stosd ; access to 4096*8=65536 ports |
621 | rep stosd ; access to 4096*8=65536 ports |
613 | 622 | ||
614 | mov ax, tss0 |
623 | mov ax, tss0 |
615 | ltr ax |
624 | ltr ax |
616 | 625 | ||
617 | mov [LFBSize], 0xC00000 |
626 | mov [LFBSize], 0xC00000 |
618 | call init_LFB |
627 | call init_LFB |
619 | call init_fpu |
628 | call init_fpu |
620 | call init_malloc |
629 | call init_malloc |
621 | 630 | ||
622 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
631 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
623 | mov [default_io_map], eax |
632 | mov [default_io_map], eax |
624 | 633 | ||
625 | add eax, 0x2000 |
634 | add eax, 0x2000 |
626 | mov [ipc_tmp], eax |
635 | mov [ipc_tmp], eax |
627 | mov ebx, 0x1000 |
636 | mov ebx, 0x1000 |
628 | 637 | ||
629 | add eax, 0x40000 |
638 | add eax, 0x40000 |
630 | mov [proc_mem_map], eax |
639 | mov [proc_mem_map], eax |
631 | 640 | ||
632 | add eax, 0x8000 |
641 | add eax, 0x8000 |
633 | mov [proc_mem_pdir], eax |
642 | mov [proc_mem_pdir], eax |
634 | 643 | ||
635 | add eax, ebx |
644 | add eax, ebx |
636 | mov [proc_mem_tab], eax |
645 | mov [proc_mem_tab], eax |
637 | 646 | ||
638 | add eax, ebx |
647 | add eax, ebx |
639 | mov [tmp_task_ptab], eax |
648 | mov [tmp_task_ptab], eax |
640 | 649 | ||
641 | add eax, ebx |
650 | add eax, ebx |
642 | mov [ipc_pdir], eax |
651 | mov [ipc_pdir], eax |
643 | 652 | ||
644 | add eax, ebx |
653 | add eax, ebx |
645 | mov [ipc_ptab], eax |
654 | mov [ipc_ptab], eax |
646 | 655 | ||
647 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
656 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
648 | (unpack.lc+unpack.lp)))*4 |
657 | (unpack.lc+unpack.lp)))*4 |
649 | 658 | ||
650 | mov [unpack.p], eax |
659 | mov [unpack.p], eax |
651 | 660 | ||
652 | call init_events |
661 | call init_events |
653 | mov eax, srv.fd-SRV.fd |
662 | mov eax, srv.fd-SRV.fd |
654 | mov [srv.fd], eax |
663 | mov [srv.fd], eax |
655 | mov [srv.bk], eax |
664 | mov [srv.bk], eax |
656 | 665 | ||
657 | ;Set base of graphic segment to linear address of LFB |
666 | ;Set base of graphic segment to linear address of LFB |
658 | mov eax, [LFBAddress] ; set for gs |
667 | mov eax, [LFBAddress] ; set for gs |
659 | mov [graph_data_l+2], ax |
668 | mov [graph_data_l+2], ax |
660 | shr eax, 16 |
669 | shr eax, 16 |
661 | mov [graph_data_l+4], al |
670 | mov [graph_data_l+4], al |
662 | mov [graph_data_l+7], ah |
671 | mov [graph_data_l+7], ah |
663 | 672 | ||
664 | stdcall kernel_alloc, [_display.win_map_size] |
673 | stdcall kernel_alloc, [_display.win_map_size] |
665 | mov [_display.win_map], eax |
674 | mov [_display.win_map], eax |
666 | 675 | ||
667 | xor eax, eax |
676 | xor eax, eax |
668 | inc eax |
677 | inc eax |
669 | 678 | ||
670 | ; set background |
679 | ; set background |
671 | 680 | ||
672 | mov [BgrDrawMode], eax |
681 | mov [BgrDrawMode], eax |
673 | mov [BgrDataWidth], eax |
682 | mov [BgrDataWidth], eax |
674 | mov [BgrDataHeight], eax |
683 | mov [BgrDataHeight], eax |
675 | mov [mem_BACKGROUND], 4 |
684 | mov [mem_BACKGROUND], 4 |
676 | mov [img_background], static_background_data |
685 | mov [img_background], static_background_data |
677 | 686 | ||
678 | ; set clipboard |
687 | ; set clipboard |
679 | 688 | ||
680 | xor eax, eax |
689 | xor eax, eax |
681 | mov [clipboard_slots], eax |
690 | mov [clipboard_slots], eax |
682 | mov [clipboard_write_lock], eax |
691 | mov [clipboard_write_lock], eax |
683 | stdcall kernel_alloc, 4096 |
692 | stdcall kernel_alloc, 4096 |
684 | test eax, eax |
693 | test eax, eax |
685 | jnz @f |
694 | jnz @f |
686 | 695 | ||
687 | dec eax |
696 | dec eax |
688 | @@: |
697 | @@: |
689 | mov [clipboard_main_list], eax |
698 | mov [clipboard_main_list], eax |
690 | 699 | ||
691 | ; SET UP OS TASK |
700 | ; SET UP OS TASK |
692 | 701 | ||
693 | mov esi, boot_setostask |
702 | mov esi, boot_setostask |
694 | call boot_log |
703 | call boot_log |
695 | 704 | ||
696 | mov edi, sys_proc |
705 | mov edi, sys_proc |
697 | list_init edi |
706 | list_init edi |
698 | lea ecx, [edi+PROC.thr_list] |
707 | lea ecx, [edi+PROC.thr_list] |
699 | list_init ecx |
708 | list_init ecx |
700 | mov [edi+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
709 | mov [edi+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
701 | 710 | ||
702 | mov eax, -1 |
711 | mov eax, -1 |
703 | mov edi, thr_slot_map+4 |
712 | mov edi, thr_slot_map+4 |
704 | mov [edi-4], dword 0xFFFFFFF8 |
713 | mov [edi-4], dword 0xFFFFFFF8 |
705 | stosd |
714 | stosd |
706 | stosd |
715 | stosd |
707 | stosd |
716 | stosd |
708 | stosd |
717 | stosd |
709 | stosd |
718 | stosd |
710 | stosd |
719 | stosd |
711 | stosd |
720 | stosd |
712 | 721 | ||
713 | mov [current_process], sys_proc |
722 | mov [current_process], sys_proc |
714 | 723 | ||
715 | mov edx, SLOT_BASE+256*1 |
724 | mov edx, SLOT_BASE+256*1 |
716 | mov ebx, [os_stack_seg] |
725 | mov ebx, [os_stack_seg] |
717 | add ebx, 0x2000 |
726 | add ebx, 0x2000 |
718 | call setup_os_slot |
727 | call setup_os_slot |
719 | mov dword [edx], 'IDLE' |
728 | mov dword [edx], 'IDLE' |
720 | sub [edx+APPDATA.saved_esp], 4 |
729 | sub [edx+APPDATA.saved_esp], 4 |
721 | mov eax, [edx+APPDATA.saved_esp] |
730 | mov eax, [edx+APPDATA.saved_esp] |
722 | mov dword [eax], idle_thread |
731 | mov dword [eax], idle_thread |
723 | mov ecx, IDLE_PRIORITY |
732 | mov ecx, IDLE_PRIORITY |
724 | call scheduler_add_thread |
733 | call scheduler_add_thread |
725 | 734 | ||
726 | mov edx, SLOT_BASE+256*2 |
735 | mov edx, SLOT_BASE+256*2 |
727 | mov ebx, [os_stack_seg] |
736 | mov ebx, [os_stack_seg] |
728 | call setup_os_slot |
737 | call setup_os_slot |
729 | mov dword [edx], 'OS' |
738 | mov dword [edx], 'OS' |
730 | xor ecx, ecx |
739 | xor ecx, ecx |
731 | call scheduler_add_thread |
740 | call scheduler_add_thread |
732 | 741 | ||
733 | mov dword [CURRENT_TASK], 2 |
742 | mov dword [CURRENT_TASK], 2 |
734 | mov dword [TASK_COUNT], 2 |
743 | mov dword [TASK_COUNT], 2 |
735 | mov dword [current_slot], SLOT_BASE + 256*2 |
744 | mov dword [current_slot], SLOT_BASE + 256*2 |
736 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
745 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
737 | 746 | ||
738 | ; Move other CPUs to deep sleep, if it is useful |
747 | ; Move other CPUs to deep sleep, if it is useful |
739 | uglobal |
748 | uglobal |
740 | use_mwait_for_idle db 0 |
749 | use_mwait_for_idle db 0 |
741 | endg |
750 | endg |
742 | cmp [cpu_vendor+8], 'ntel' |
751 | cmp [cpu_vendor+8], 'ntel' |
743 | jnz .no_wake_cpus |
752 | jnz .no_wake_cpus |
744 | bt [cpu_caps+4], CAPS_MONITOR-32 |
753 | bt [cpu_caps+4], CAPS_MONITOR-32 |
745 | jnc .no_wake_cpus |
754 | jnc .no_wake_cpus |
746 | dbgstr 'using mwait for idle loop' |
755 | dbgstr 'using mwait for idle loop' |
747 | inc [use_mwait_for_idle] |
756 | inc [use_mwait_for_idle] |
748 | mov ebx, [cpu_count] |
757 | mov ebx, [cpu_count] |
749 | cmp ebx, 1 |
758 | cmp ebx, 1 |
750 | jbe .no_wake_cpus |
759 | jbe .no_wake_cpus |
751 | call create_trampoline_pgmap |
760 | call create_trampoline_pgmap |
752 | mov [cr3_ap+OS_BASE], eax |
761 | mov [cr3_ap+OS_BASE], eax |
753 | mov eax, cr4 |
762 | mov eax, cr4 |
754 | mov [cr4_ap+OS_BASE], eax |
763 | mov [cr4_ap+OS_BASE], eax |
755 | mov esi, OS_BASE + ap_init16 |
764 | mov esi, OS_BASE + ap_init16 |
756 | mov edi, OS_BASE + 8000h |
765 | mov edi, OS_BASE + 8000h |
757 | mov ecx, (ap_init16_size + 3) / 4 |
766 | mov ecx, (ap_init16_size + 3) / 4 |
758 | rep movsd |
767 | rep movsd |
759 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
768 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
760 | mov [LAPIC_BASE], eax |
769 | mov [LAPIC_BASE], eax |
761 | lea edi, [eax+300h] |
770 | lea edi, [eax+300h] |
762 | mov esi, smpt+4 |
771 | mov esi, smpt+4 |
763 | dec ebx |
772 | dec ebx |
764 | .wake_cpus_loop: |
773 | .wake_cpus_loop: |
765 | lodsd |
774 | lodsd |
766 | push esi |
775 | push esi |
767 | xor esi, esi |
776 | xor esi, esi |
768 | inc esi |
777 | inc esi |
769 | shl eax, 24 |
778 | shl eax, 24 |
770 | mov [edi+10h], eax |
779 | mov [edi+10h], eax |
771 | ; assert INIT IPI |
780 | ; assert INIT IPI |
772 | mov dword [edi], 0C500h |
781 | mov dword [edi], 0C500h |
773 | call delay_ms |
782 | call delay_ms |
774 | @@: |
783 | @@: |
775 | test dword [edi], 1000h |
784 | test dword [edi], 1000h |
776 | jnz @b |
785 | jnz @b |
777 | ; deassert INIT IPI |
786 | ; deassert INIT IPI |
778 | mov dword [edi], 8500h |
787 | mov dword [edi], 8500h |
779 | call delay_ms |
788 | call delay_ms |
780 | @@: |
789 | @@: |
781 | test dword [edi], 1000h |
790 | test dword [edi], 1000h |
782 | jnz @b |
791 | jnz @b |
783 | ; send STARTUP IPI |
792 | ; send STARTUP IPI |
784 | mov dword [edi], 600h + (8000h shr 12) |
793 | mov dword [edi], 600h + (8000h shr 12) |
785 | call delay_ms |
794 | call delay_ms |
786 | @@: |
795 | @@: |
787 | test dword [edi], 1000h |
796 | test dword [edi], 1000h |
788 | jnz @b |
797 | jnz @b |
789 | pop esi |
798 | pop esi |
790 | dec ebx |
799 | dec ebx |
791 | jnz .wake_cpus_loop |
800 | jnz .wake_cpus_loop |
792 | mov eax, [cpu_count] |
801 | mov eax, [cpu_count] |
793 | dec eax |
802 | dec eax |
794 | @@: |
803 | @@: |
795 | cmp [ap_initialized], eax |
804 | cmp [ap_initialized], eax |
796 | jnz @b |
805 | jnz @b |
797 | mov eax, [cr3_ap+OS_BASE] |
806 | mov eax, [cr3_ap+OS_BASE] |
798 | call free_page |
807 | call free_page |
799 | .no_wake_cpus: |
808 | .no_wake_cpus: |
800 | 809 | ||
801 | 810 | ||
802 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
811 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
803 | mov esi, boot_initirq |
812 | mov esi, boot_initirq |
804 | call boot_log |
813 | call boot_log |
805 | call init_irqs |
814 | call init_irqs |
806 | 815 | ||
807 | mov esi, boot_picinit |
816 | mov esi, boot_picinit |
808 | call boot_log |
817 | call boot_log |
809 | call PIC_init |
818 | call PIC_init |
810 | 819 | ||
811 | mov esi, boot_v86machine |
820 | mov esi, boot_v86machine |
812 | call boot_log |
821 | call boot_log |
813 | ; Initialize system V86 machine |
822 | ; Initialize system V86 machine |
814 | call init_sys_v86 |
823 | call init_sys_v86 |
815 | 824 | ||
816 | mov esi, boot_inittimer |
825 | mov esi, boot_inittimer |
817 | call boot_log |
826 | call boot_log |
818 | ; Initialize system timer (IRQ0) |
827 | ; Initialize system timer (IRQ0) |
819 | call PIT_init |
828 | call PIT_init |
820 | 829 | ||
821 | ; Register ramdisk file system |
830 | ; Register ramdisk file system |
822 | cmp [boot_dev+OS_BASE+0x10000], 1 |
831 | cmp [boot_dev+OS_BASE+0x10000], 1 |
823 | je @f |
832 | je @f |
824 | 833 | ||
825 | call register_ramdisk |
834 | call register_ramdisk |
826 | ;-------------------------------------- |
835 | ;-------------------------------------- |
827 | @@: |
836 | @@: |
828 | mov esi, boot_initapic |
837 | mov esi, boot_initapic |
829 | call boot_log |
838 | call boot_log |
830 | ; Try to Initialize APIC |
839 | ; Try to Initialize APIC |
831 | call APIC_init |
840 | call APIC_init |
832 | 841 | ||
833 | mov esi, boot_enableirq |
842 | mov esi, boot_enableirq |
834 | call boot_log |
843 | call boot_log |
835 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
844 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
836 | ; they are used: when partitions are scanned, hd_read relies on timer |
845 | ; they are used: when partitions are scanned, hd_read relies on timer |
837 | call unmask_timer |
846 | call unmask_timer |
838 | stdcall enable_irq, 2 ; @#$%! PIC |
847 | stdcall enable_irq, 2 ; @#$%! PIC |
839 | stdcall enable_irq, 13 ; co-processor |
848 | stdcall enable_irq, 13 ; co-processor |
840 | 849 | ||
841 | ; Setup serial output console (if enabled) |
850 | ; Setup serial output console (if enabled) |
842 | if defined debug_com_base |
851 | if defined debug_com_base |
843 | 852 | ||
844 | ; reserve port so nobody else will use it |
853 | ; reserve port so nobody else will use it |
845 | xor ebx, ebx |
854 | xor ebx, ebx |
846 | mov ecx, debug_com_base |
855 | mov ecx, debug_com_base |
847 | mov edx, debug_com_base+7 |
856 | mov edx, debug_com_base+7 |
848 | call r_f_port_area |
857 | call r_f_port_area |
849 | 858 | ||
850 | ; enable Divisor latch |
859 | ; enable Divisor latch |
851 | mov dx, debug_com_base+3 |
860 | mov dx, debug_com_base+3 |
852 | mov al, 1 shl 7 |
861 | mov al, 1 shl 7 |
853 | out dx, al |
862 | out dx, al |
854 | 863 | ||
855 | ; Set speed to 115200 baud (max speed) |
864 | ; Set speed to 115200 baud (max speed) |
856 | mov dx, debug_com_base |
865 | mov dx, debug_com_base |
857 | mov al, 0x01 |
866 | mov al, 0x01 |
858 | out dx, al |
867 | out dx, al |
859 | 868 | ||
860 | mov dx, debug_com_base+1 |
869 | mov dx, debug_com_base+1 |
861 | mov al, 0x00 |
870 | mov al, 0x00 |
862 | out dx, al |
871 | out dx, al |
863 | 872 | ||
864 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
873 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
865 | mov dx, debug_com_base+3 |
874 | mov dx, debug_com_base+3 |
866 | mov al, 3 |
875 | mov al, 3 |
867 | out dx, al |
876 | out dx, al |
868 | 877 | ||
869 | ; disable interrupts |
878 | ; disable interrupts |
870 | mov dx, debug_com_base+1 |
879 | mov dx, debug_com_base+1 |
871 | mov al, 0 |
880 | mov al, 0 |
872 | out dx, al |
881 | out dx, al |
873 | 882 | ||
874 | ; clear + enable fifo (64 bits) |
883 | ; clear + enable fifo (64 bits) |
875 | mov dx, debug_com_base+2 |
884 | mov dx, debug_com_base+2 |
876 | mov al, 0x7 + 1 shl 5 |
885 | mov al, 0x7 + 1 shl 5 |
877 | out dx, al |
886 | out dx, al |
878 | 887 | ||
879 | end if |
888 | end if |
880 | 889 | ||
881 | 890 | ||
882 | ;----------------------------------------------------------------------------- |
891 | ;----------------------------------------------------------------------------- |
883 | ; show SVN version of kernel on the message board |
892 | ; show SVN version of kernel on the message board |
884 | ;----------------------------------------------------------------------------- |
893 | ;----------------------------------------------------------------------------- |
885 | mov eax, [version_inf.rev] |
894 | mov eax, [version_inf.rev] |
886 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
895 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
887 | ;----------------------------------------------------------------------------- |
896 | ;----------------------------------------------------------------------------- |
888 | ; show CPU count on the message board |
897 | ; show CPU count on the message board |
889 | ;----------------------------------------------------------------------------- |
898 | ;----------------------------------------------------------------------------- |
890 | mov eax, [cpu_count] |
899 | mov eax, [cpu_count] |
891 | test eax, eax |
900 | test eax, eax |
892 | jnz @F |
901 | jnz @F |
893 | mov al, 1 ; at least one CPU |
902 | mov al, 1 ; at least one CPU |
894 | @@: |
903 | @@: |
895 | DEBUGF 1, "K : %d CPU detected\n", eax |
904 | DEBUGF 1, "K : %d CPU detected\n", eax |
896 | ;----------------------------------------------------------------------------- |
905 | ;----------------------------------------------------------------------------- |
897 | ; detect Floppy drives |
906 | ; detect Floppy drives |
898 | ;----------------------------------------------------------------------------- |
907 | ;----------------------------------------------------------------------------- |
899 | mov esi, boot_detectfloppy |
908 | mov esi, boot_detectfloppy |
900 | call boot_log |
909 | call boot_log |
901 | include 'detect/dev_fd.inc' |
910 | include 'detect/dev_fd.inc' |
902 | ;----------------------------------------------------------------------------- |
911 | ;----------------------------------------------------------------------------- |
903 | ; create pci-devices list |
912 | ; create pci-devices list |
904 | ;----------------------------------------------------------------------------- |
913 | ;----------------------------------------------------------------------------- |
905 | mov [pci_access_enabled], 1 |
914 | mov [pci_access_enabled], 1 |
906 | call pci_enum |
915 | call pci_enum |
907 | ;----------------------------------------------------------------------------- |
916 | ;----------------------------------------------------------------------------- |
908 | ; initialisation IDE ATA code |
917 | ; initialisation IDE ATA code |
909 | ;----------------------------------------------------------------------------- |
918 | ;----------------------------------------------------------------------------- |
910 | include 'detect/init_ata.inc' |
919 | include 'detect/init_ata.inc' |
911 | ;----------------------------------------------------------------------------- |
920 | ;----------------------------------------------------------------------------- |
912 | if 0 |
921 | if 0 |
913 | mov ax, [OS_BASE+0x10000+bx_from_load] |
922 | mov ax, [OS_BASE+0x10000+bx_from_load] |
914 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
923 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
915 | je no_lib_load |
924 | je no_lib_load |
916 | 925 | ||
917 | mov esi, boot_loadlibs |
926 | mov esi, boot_loadlibs |
918 | call boot_log |
927 | call boot_log |
919 | ; LOADING LIBRARES |
928 | ; LOADING LIBRARES |
920 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
929 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
921 | call load_file_parse_table ; prepare file parse table |
930 | call load_file_parse_table ; prepare file parse table |
922 | call set_kernel_conf ; configure devices and gui |
931 | call set_kernel_conf ; configure devices and gui |
923 | no_lib_load: |
932 | no_lib_load: |
924 | end if |
933 | end if |
925 | 934 | ||
926 | ; Display APIC status |
935 | ; Display APIC status |
927 | mov esi, boot_APIC_found |
936 | mov esi, boot_APIC_found |
928 | cmp [irq_mode], IRQ_APIC |
937 | cmp [irq_mode], IRQ_APIC |
929 | je @f |
938 | je @f |
930 | mov esi, boot_APIC_nfound |
939 | mov esi, boot_APIC_nfound |
931 | @@: |
940 | @@: |
932 | call boot_log |
941 | call boot_log |
933 | 942 | ||
934 | ; PRINT AMOUNT OF MEMORY |
943 | ; PRINT AMOUNT OF MEMORY |
935 | mov esi, boot_memdetect |
944 | mov esi, boot_memdetect |
936 | call boot_log |
945 | call boot_log |
937 | 946 | ||
938 | movzx ecx, word [boot_y] |
947 | movzx ecx, word [boot_y] |
939 | if lang eq ru |
948 | if lang eq ru |
940 | or ecx, (10+30*6) shl 16 |
949 | or ecx, (10+30*6) shl 16 |
941 | else if lang eq sp |
950 | else if lang eq sp |
942 | or ecx, (10+33*6) shl 16 |
951 | or ecx, (10+33*6) shl 16 |
943 | else |
952 | else |
944 | or ecx, (10+29*6) shl 16 |
953 | or ecx, (10+29*6) shl 16 |
945 | end if |
954 | end if |
946 | sub ecx, 10 |
955 | sub ecx, 10 |
947 | mov edx, 0xFFFFFF |
956 | mov edx, 0xFFFFFF |
948 | mov ebx, [MEM_AMOUNT] |
957 | mov ebx, [MEM_AMOUNT] |
949 | shr ebx, 20 |
958 | shr ebx, 20 |
950 | xor edi, edi |
959 | xor edi, edi |
951 | mov eax, 0x00040000 |
960 | mov eax, 0x00040000 |
952 | inc edi |
961 | inc edi |
953 | call display_number_force |
962 | call display_number_force |
954 | 963 | ||
955 | ; BUILD SCHEDULER |
964 | ; BUILD SCHEDULER |
956 | 965 | ||
957 | ; call build_scheduler; sys32.inc |
966 | ; call build_scheduler; sys32.inc |
958 | 967 | ||
959 | ; mov esi, boot_devices |
968 | ; mov esi, boot_devices |
960 | ; call boot_log |
969 | ; call boot_log |
961 | 970 | ||
962 | call clear_pci_ide_interrupts |
971 | call clear_pci_ide_interrupts |
963 | 972 | ||
964 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
973 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
965 | 974 | ||
966 | stdcall load_pe_driver, szVidintel, 0 |
975 | stdcall load_pe_driver, szVidintel, 0 |
967 | 976 | ||
968 | call usb_init |
977 | call usb_init |
969 | 978 | ||
970 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
979 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
971 | 980 | ||
972 | mov esi, boot_windefs |
981 | mov esi, boot_windefs |
973 | call boot_log |
982 | call boot_log |
974 | call set_window_defaults |
983 | call set_window_defaults |
975 | 984 | ||
976 | ; SET BACKGROUND DEFAULTS |
985 | ; SET BACKGROUND DEFAULTS |
977 | 986 | ||
978 | mov esi, boot_bgr |
987 | mov esi, boot_bgr |
979 | call boot_log |
988 | call boot_log |
980 | call init_background |
989 | call init_background |
981 | call calculatebackground |
990 | call calculatebackground |
982 | 991 | ||
983 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
992 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
984 | 993 | ||
985 | mov esi, boot_resirqports |
994 | mov esi, boot_resirqports |
986 | call boot_log |
995 | call boot_log |
987 | call reserve_irqs_ports |
996 | call reserve_irqs_ports |
988 | 997 | ||
989 | call init_display |
998 | call init_display |
990 | mov eax, [def_cursor] |
999 | mov eax, [def_cursor] |
991 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
1000 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
992 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
1001 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
993 | 1002 | ||
994 | ; PRINT CPU FREQUENCY |
1003 | ; PRINT CPU FREQUENCY |
995 | 1004 | ||
996 | mov esi, boot_cpufreq |
1005 | mov esi, boot_cpufreq |
997 | call boot_log |
1006 | call boot_log |
998 | 1007 | ||
999 | cli ;FIXME check IF |
1008 | cli ;FIXME check IF |
1000 | rdtsc |
1009 | rdtsc |
1001 | mov ecx, eax |
1010 | mov ecx, eax |
1002 | mov esi, 250 ; wait 1/4 a second |
1011 | mov esi, 250 ; wait 1/4 a second |
1003 | call delay_ms |
1012 | call delay_ms |
1004 | rdtsc |
1013 | rdtsc |
1005 | sti |
1014 | sti |
1006 | 1015 | ||
1007 | sub eax, ecx |
1016 | sub eax, ecx |
1008 | xor edx, edx |
1017 | xor edx, edx |
1009 | shld edx, eax, 2 |
1018 | shld edx, eax, 2 |
1010 | shl eax, 2 |
1019 | shl eax, 2 |
1011 | mov dword [cpu_freq], eax |
1020 | mov dword [cpu_freq], eax |
1012 | mov dword [cpu_freq+4], edx |
1021 | mov dword [cpu_freq+4], edx |
1013 | mov ebx, 1000000 |
1022 | mov ebx, 1000000 |
1014 | div ebx |
1023 | div ebx |
1015 | mov ebx, eax |
1024 | mov ebx, eax |
1016 | 1025 | ||
1017 | movzx ecx, word [boot_y] |
1026 | movzx ecx, word [boot_y] |
1018 | if lang eq ru |
1027 | if lang eq ru |
1019 | add ecx, (10+19*6) shl 16 - 10 |
1028 | add ecx, (10+19*6) shl 16 - 10 |
1020 | else if lang eq sp |
1029 | else if lang eq sp |
1021 | add ecx, (10+25*6) shl 16 - 10 |
1030 | add ecx, (10+25*6) shl 16 - 10 |
1022 | else |
1031 | else |
1023 | add ecx, (10+17*6) shl 16 - 10 |
1032 | add ecx, (10+17*6) shl 16 - 10 |
1024 | end if |
1033 | end if |
1025 | 1034 | ||
1026 | mov edx, 0xFFFFFF |
1035 | mov edx, 0xFFFFFF |
1027 | xor edi, edi |
1036 | xor edi, edi |
1028 | mov eax, 0x00040000 |
1037 | mov eax, 0x00040000 |
1029 | inc edi |
1038 | inc edi |
1030 | call display_number_force |
1039 | call display_number_force |
1031 | 1040 | ||
1032 | ; SET VARIABLES |
1041 | ; SET VARIABLES |
1033 | 1042 | ||
1034 | call set_variables |
1043 | call set_variables |
1035 | 1044 | ||
1036 | ; STACK AND FDC |
1045 | ; STACK AND FDC |
1037 | 1046 | ||
1038 | call stack_init |
1047 | call stack_init |
1039 | call fdc_init |
1048 | call fdc_init |
1040 | 1049 | ||
1041 | ; PALETTE FOR 320x200 and 640x480 16 col |
1050 | ; PALETTE FOR 320x200 and 640x480 16 col |
1042 | 1051 | ||
1043 | cmp [SCR_MODE], word 0x12 |
1052 | cmp [SCR_MODE], word 0x12 |
1044 | jne no_pal_vga |
1053 | jne no_pal_vga |
1045 | mov esi, boot_pal_vga |
1054 | mov esi, boot_pal_vga |
1046 | call boot_log |
1055 | call boot_log |
1047 | call paletteVGA |
1056 | call paletteVGA |
1048 | no_pal_vga: |
1057 | no_pal_vga: |
1049 | 1058 | ||
1050 | cmp [SCR_MODE], word 0x13 |
1059 | cmp [SCR_MODE], word 0x13 |
1051 | jne no_pal_ega |
1060 | jne no_pal_ega |
1052 | mov esi, boot_pal_ega |
1061 | mov esi, boot_pal_ega |
1053 | call boot_log |
1062 | call boot_log |
1054 | call palette320x200 |
1063 | call palette320x200 |
1055 | no_pal_ega: |
1064 | no_pal_ega: |
1056 | 1065 | ||
1057 | ; LOAD DEFAULT SKIN |
1066 | ; LOAD DEFAULT SKIN |
1058 | 1067 | ||
1059 | call load_default_skin |
1068 | call load_default_skin |
1060 | 1069 | ||
1061 | ;protect io permission map |
1070 | ;protect io permission map |
1062 | 1071 | ||
1063 | mov esi, [default_io_map] |
1072 | mov esi, [default_io_map] |
1064 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1073 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1065 | add esi, 0x1000 |
1074 | add esi, 0x1000 |
1066 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1075 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1067 | 1076 | ||
1068 | stdcall map_page, tss._io_map_0, \ |
1077 | stdcall map_page, tss._io_map_0, \ |
1069 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1078 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1070 | stdcall map_page, tss._io_map_1, \ |
1079 | stdcall map_page, tss._io_map_1, \ |
1071 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1080 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1072 | 1081 | ||
1073 | ; SET KEYBOARD PARAMETERS |
1082 | ; SET KEYBOARD PARAMETERS |
1074 | mov al, 0xf6 ; reset keyboard, scan enabled |
1083 | mov al, 0xf6 ; reset keyboard, scan enabled |
1075 | call kb_write_wait_ack |
1084 | call kb_write_wait_ack |
1076 | test ah, ah |
1085 | test ah, ah |
1077 | jnz .no_keyboard |
1086 | jnz .no_keyboard |
1078 | 1087 | ||
1079 | iglobal |
1088 | iglobal |
1080 | align 4 |
1089 | align 4 |
1081 | ps2_keyboard_functions: |
1090 | ps2_keyboard_functions: |
1082 | dd .end - $ |
1091 | dd .end - $ |
1083 | dd 0 ; no close |
1092 | dd 0 ; no close |
1084 | dd ps2_set_lights |
1093 | dd ps2_set_lights |
1085 | .end: |
1094 | .end: |
1086 | endg |
1095 | endg |
1087 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1096 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1088 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1097 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1089 | ; call kb_write_wait_ack |
1098 | ; call kb_write_wait_ack |
1090 | ; mov al, 111b |
1099 | ; mov al, 111b |
1091 | ; call kb_write_wait_ack |
1100 | ; call kb_write_wait_ack |
1092 | 1101 | ||
1093 | mov al, 0xF3 ; set repeat rate & delay |
1102 | mov al, 0xF3 ; set repeat rate & delay |
1094 | call kb_write_wait_ack |
1103 | call kb_write_wait_ack |
1095 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1104 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1096 | call kb_write_wait_ack |
1105 | call kb_write_wait_ack |
1097 | ;// mike.dld [ |
1106 | ;// mike.dld [ |
1098 | call set_lights |
1107 | call set_lights |
1099 | ;// mike.dld ] |
1108 | ;// mike.dld ] |
1100 | stdcall attach_int_handler, 1, irq1, 0 |
1109 | stdcall attach_int_handler, 1, irq1, 0 |
1101 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1110 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1102 | .no_keyboard: |
1111 | .no_keyboard: |
1103 | 1112 | ||
1104 | ; Load PS/2 mouse driver |
1113 | ; Load PS/2 mouse driver |
1105 | 1114 | ||
1106 | stdcall load_pe_driver, szPS2MDriver, 0 |
1115 | stdcall load_pe_driver, szPS2MDriver, 0 |
1107 | 1116 | ||
1108 | mov esi, boot_setmouse |
1117 | mov esi, boot_setmouse |
1109 | call boot_log |
1118 | call boot_log |
1110 | call setmouse |
1119 | call setmouse |
1111 | 1120 | ||
1112 | ; LOAD FIRST APPLICATION |
1121 | ; LOAD FIRST APPLICATION |
1113 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1122 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1114 | jnz first_app_found |
1123 | jnz first_app_found |
1115 | 1124 | ||
1116 | cli |
1125 | cli |
1117 | mov ebp, firstapp |
1126 | mov ebp, firstapp |
1118 | call fs_execute_from_sysdir |
1127 | call fs_execute_from_sysdir |
1119 | test eax, eax |
1128 | test eax, eax |
1120 | jns first_app_found |
1129 | jns first_app_found |
1121 | 1130 | ||
1122 | mov esi, boot_failed |
1131 | mov esi, boot_failed |
1123 | call boot_log |
1132 | call boot_log |
1124 | 1133 | ||
1125 | mov eax, 0xDEADBEEF ; otherwise halt |
1134 | mov eax, 0xDEADBEEF ; otherwise halt |
1126 | hlt |
1135 | hlt |
1127 | 1136 | ||
1128 | first_app_found: |
1137 | first_app_found: |
1129 | 1138 | ||
1130 | ; START MULTITASKING |
1139 | ; START MULTITASKING |
1131 | 1140 | ||
1132 | ; A 'All set - press ESC to start' messages if need |
1141 | ; A 'All set - press ESC to start' messages if need |
1133 | if preboot_blogesc |
1142 | if preboot_blogesc |
1134 | mov esi, boot_tasking |
1143 | mov esi, boot_tasking |
1135 | call boot_log |
1144 | call boot_log |
1136 | .bll1: |
1145 | .bll1: |
1137 | in al, 0x60 ; wait for ESC key press |
1146 | in al, 0x60 ; wait for ESC key press |
1138 | cmp al, 129 |
1147 | cmp al, 129 |
1139 | jne .bll1 |
1148 | jne .bll1 |
1140 | end if |
1149 | end if |
1141 | 1150 | ||
1142 | mov [timer_ticks_enable], 1 ; for cd driver |
1151 | mov [timer_ticks_enable], 1 ; for cd driver |
1143 | 1152 | ||
1144 | sti |
1153 | sti |
1145 | 1154 | ||
1146 | call mtrr_validate |
1155 | call mtrr_validate |
1147 | 1156 | ||
1148 | jmp osloop |
1157 | jmp osloop |
1149 | 1158 | ||
1150 | 1159 | ||
1151 | ; Fly :) |
1160 | ; Fly :) |
1152 | 1161 | ||
1153 | uglobal |
1162 | uglobal |
1154 | align 4 |
1163 | align 4 |
1155 | ap_initialized dd 0 |
1164 | ap_initialized dd 0 |
1156 | endg |
1165 | endg |
1157 | 1166 | ||
1158 | ap_init_high: |
1167 | ap_init_high: |
1159 | mov ax, os_stack |
1168 | mov ax, os_stack |
1160 | mov bx, app_data |
1169 | mov bx, app_data |
1161 | mov cx, app_tls |
1170 | mov cx, app_tls |
1162 | mov ss, ax |
1171 | mov ss, ax |
1163 | mov ds, bx |
1172 | mov ds, bx |
1164 | mov es, bx |
1173 | mov es, bx |
1165 | mov fs, cx |
1174 | mov fs, cx |
1166 | mov gs, bx |
1175 | mov gs, bx |
1167 | xor esp, esp |
1176 | xor esp, esp |
1168 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1177 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1169 | mov cr3, eax |
1178 | mov cr3, eax |
1170 | lock inc [ap_initialized] |
1179 | lock inc [ap_initialized] |
1171 | jmp idle_loop |
1180 | jmp idle_loop |
1172 | 1181 | ||
1173 | 1182 | ||
1174 | include 'unpacker.inc' |
1183 | include 'unpacker.inc' |
1175 | 1184 | ||
1176 | align 4 |
1185 | align 4 |
1177 | boot_log: |
1186 | boot_log: |
1178 | pushad |
1187 | pushad |
1179 | 1188 | ||
1180 | mov ebx, 10*65536 |
1189 | mov ebx, 10*65536 |
1181 | mov bx, word [boot_y] |
1190 | mov bx, word [boot_y] |
1182 | add [boot_y], dword 10 |
1191 | add [boot_y], dword 10 |
1183 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1192 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1184 | xor edi, edi |
1193 | xor edi, edi |
1185 | mov edx, esi |
1194 | mov edx, esi |
1186 | inc edi |
1195 | inc edi |
1187 | call dtext |
1196 | call dtext |
1188 | 1197 | ||
1189 | mov [novesachecksum], 1000 |
1198 | mov [novesachecksum], 1000 |
1190 | call checkVga_N13 |
1199 | call checkVga_N13 |
1191 | 1200 | ||
1192 | popad |
1201 | popad |
1193 | 1202 | ||
1194 | ret |
1203 | ret |
1195 | 1204 | ||
1196 | ; in: edx -> APPDATA for OS/IDLE slot |
1205 | ; in: edx -> APPDATA for OS/IDLE slot |
1197 | ; in: ebx = stack base |
1206 | ; in: ebx = stack base |
1198 | proc setup_os_slot |
1207 | proc setup_os_slot |
1199 | xor eax, eax |
1208 | xor eax, eax |
1200 | mov ecx, 256/4 |
1209 | mov ecx, 256/4 |
1201 | mov edi, edx |
1210 | mov edi, edx |
1202 | rep stosd |
1211 | rep stosd |
1203 | 1212 | ||
1204 | mov eax, tss+0x80 |
1213 | mov eax, tss+0x80 |
1205 | call get_pg_addr |
1214 | call get_pg_addr |
1206 | inc eax |
1215 | inc eax |
1207 | mov [edx+APPDATA.io_map], eax |
1216 | mov [edx+APPDATA.io_map], eax |
1208 | mov eax, tss+0x1080 |
1217 | mov eax, tss+0x1080 |
1209 | call get_pg_addr |
1218 | call get_pg_addr |
1210 | inc eax |
1219 | inc eax |
1211 | mov [edx+APPDATA.io_map+4], eax |
1220 | mov [edx+APPDATA.io_map+4], eax |
1212 | 1221 | ||
1213 | mov dword [edx+APPDATA.pl0_stack], ebx |
1222 | mov dword [edx+APPDATA.pl0_stack], ebx |
1214 | lea edi, [ebx+0x2000-512] |
1223 | lea edi, [ebx+0x2000-512] |
1215 | mov dword [edx+APPDATA.fpu_state], edi |
1224 | mov dword [edx+APPDATA.fpu_state], edi |
1216 | mov dword [edx+APPDATA.saved_esp0], edi |
1225 | mov dword [edx+APPDATA.saved_esp0], edi |
1217 | mov dword [edx+APPDATA.saved_esp], edi |
1226 | mov dword [edx+APPDATA.saved_esp], edi |
1218 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1227 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1219 | 1228 | ||
1220 | mov esi, fpu_data |
1229 | mov esi, fpu_data |
1221 | mov ecx, 512/4 |
1230 | mov ecx, 512/4 |
1222 | cld |
1231 | cld |
1223 | rep movsd |
1232 | rep movsd |
1224 | 1233 | ||
1225 | lea eax, [edx+APP_OBJ_OFFSET] |
1234 | lea eax, [edx+APP_OBJ_OFFSET] |
1226 | mov dword [edx+APPDATA.fd_obj], eax |
1235 | mov dword [edx+APPDATA.fd_obj], eax |
1227 | mov dword [edx+APPDATA.bk_obj], eax |
1236 | mov dword [edx+APPDATA.bk_obj], eax |
1228 | 1237 | ||
1229 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1238 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1230 | 1239 | ||
1231 | mov [edx + APPDATA.process], sys_proc |
1240 | mov [edx + APPDATA.process], sys_proc |
1232 | 1241 | ||
1233 | lea ebx, [edx+APPDATA.list] |
1242 | lea ebx, [edx+APPDATA.list] |
1234 | lea ecx, [sys_proc+PROC.thr_list] |
1243 | lea ecx, [sys_proc+PROC.thr_list] |
1235 | list_add_tail ebx, ecx |
1244 | list_add_tail ebx, ecx |
1236 | 1245 | ||
1237 | mov eax, edx |
1246 | mov eax, edx |
1238 | shr eax, 3 |
1247 | shr eax, 3 |
1239 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1248 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1240 | mov [eax+TASKDATA.wnd_number], dh |
1249 | mov [eax+TASKDATA.wnd_number], dh |
1241 | mov byte [eax+TASKDATA.pid], dh |
1250 | mov byte [eax+TASKDATA.pid], dh |
1242 | 1251 | ||
1243 | ret |
1252 | ret |
1244 | endp |
1253 | endp |
1245 | 1254 | ||
1246 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1255 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1247 | ; ; |
1256 | ; ; |
1248 | ; MAIN OS LOOP START ; |
1257 | ; MAIN OS LOOP START ; |
1249 | ; ; |
1258 | ; ; |
1250 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1259 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1251 | align 32 |
1260 | align 32 |
1252 | osloop: |
1261 | osloop: |
1253 | mov edx, osloop_has_work? |
1262 | mov edx, osloop_has_work? |
1254 | xor ecx, ecx |
1263 | xor ecx, ecx |
1255 | call Wait_events |
1264 | call Wait_events |
1256 | xor eax, eax |
1265 | xor eax, eax |
1257 | xchg eax, [osloop_nonperiodic_work] |
1266 | xchg eax, [osloop_nonperiodic_work] |
1258 | test eax, eax |
1267 | test eax, eax |
1259 | jz .no_periodic |
1268 | jz .no_periodic |
1260 | 1269 | ||
1261 | call __sys_draw_pointer |
1270 | call __sys_draw_pointer |
1262 | call window_check_events |
1271 | call window_check_events |
1263 | call mouse_check_events |
1272 | call mouse_check_events |
1264 | call checkmisc |
1273 | call checkmisc |
1265 | call checkVga_N13 |
1274 | call checkVga_N13 |
1266 | ;-------------------------------------- |
1275 | ;-------------------------------------- |
1267 | .no_periodic: |
1276 | .no_periodic: |
1268 | call stack_handler |
1277 | call stack_handler |
1269 | call check_fdd_motor_status |
1278 | call check_fdd_motor_status |
1270 | call check_ATAPI_device_event |
1279 | call check_ATAPI_device_event |
1271 | call check_lights_state |
1280 | call check_lights_state |
1272 | call check_timers |
1281 | call check_timers |
1273 | 1282 | ||
1274 | jmp osloop |
1283 | jmp osloop |
1275 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1284 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1276 | ; ; |
1285 | ; ; |
1277 | ; MAIN OS LOOP END ; |
1286 | ; MAIN OS LOOP END ; |
1278 | ; ; |
1287 | ; ; |
1279 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1288 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1280 | proc osloop_has_work? |
1289 | proc osloop_has_work? |
1281 | cmp [osloop_nonperiodic_work], 0 |
1290 | cmp [osloop_nonperiodic_work], 0 |
1282 | jnz .yes |
1291 | jnz .yes |
1283 | call stack_handler_has_work? |
1292 | call stack_handler_has_work? |
1284 | jnz .yes |
1293 | jnz .yes |
1285 | call check_fdd_motor_status_has_work? |
1294 | call check_fdd_motor_status_has_work? |
1286 | jnz .yes |
1295 | jnz .yes |
1287 | call check_ATAPI_device_event_has_work? |
1296 | call check_ATAPI_device_event_has_work? |
1288 | jnz .yes |
1297 | jnz .yes |
1289 | call check_lights_state_has_work? |
1298 | call check_lights_state_has_work? |
1290 | jnz .yes |
1299 | jnz .yes |
1291 | call check_timers_has_work? |
1300 | call check_timers_has_work? |
1292 | jnz .yes |
1301 | jnz .yes |
1293 | .no: |
1302 | .no: |
1294 | xor eax, eax |
1303 | xor eax, eax |
1295 | ret |
1304 | ret |
1296 | .yes: |
1305 | .yes: |
1297 | xor eax, eax |
1306 | xor eax, eax |
1298 | inc eax |
1307 | inc eax |
1299 | ret |
1308 | ret |
1300 | endp |
1309 | endp |
1301 | 1310 | ||
1302 | proc wakeup_osloop |
1311 | proc wakeup_osloop |
1303 | mov [osloop_nonperiodic_work], 1 |
1312 | mov [osloop_nonperiodic_work], 1 |
1304 | ret |
1313 | ret |
1305 | endp |
1314 | endp |
1306 | 1315 | ||
1307 | uglobal |
1316 | uglobal |
1308 | align 4 |
1317 | align 4 |
1309 | osloop_nonperiodic_work dd ? |
1318 | osloop_nonperiodic_work dd ? |
1310 | endg |
1319 | endg |
1311 | 1320 | ||
1312 | uglobal |
1321 | uglobal |
1313 | align 64 |
1322 | align 64 |
1314 | idle_addr rb 64 |
1323 | idle_addr rb 64 |
1315 | endg |
1324 | endg |
1316 | 1325 | ||
1317 | idle_thread: |
1326 | idle_thread: |
1318 | sti |
1327 | sti |
1319 | 1328 | ||
1320 | ; The following code can be executed by all CPUs in the system. |
1329 | ; The following code can be executed by all CPUs in the system. |
1321 | ; All other parts of the kernel do not expect multi-CPU. |
1330 | ; All other parts of the kernel do not expect multi-CPU. |
1322 | ; Also, APs don't even have a stack here. |
1331 | ; Also, APs don't even have a stack here. |
1323 | ; Beware. Don't do anything here. Anything at all. |
1332 | ; Beware. Don't do anything here. Anything at all. |
1324 | idle_loop: |
1333 | idle_loop: |
1325 | cmp [use_mwait_for_idle], 0 |
1334 | cmp [use_mwait_for_idle], 0 |
1326 | jnz idle_loop_mwait |
1335 | jnz idle_loop_mwait |
1327 | 1336 | ||
1328 | idle_loop_hlt: |
1337 | idle_loop_hlt: |
1329 | hlt |
1338 | hlt |
1330 | jmp idle_loop_hlt |
1339 | jmp idle_loop_hlt |
1331 | 1340 | ||
1332 | idle_loop_mwait: |
1341 | idle_loop_mwait: |
1333 | mov eax, idle_addr |
1342 | mov eax, idle_addr |
1334 | xor ecx, ecx |
1343 | xor ecx, ecx |
1335 | xor edx, edx |
1344 | xor edx, edx |
1336 | monitor |
1345 | monitor |
1337 | xor ecx, ecx |
1346 | xor ecx, ecx |
1338 | mov eax, 20h ; or 10h |
1347 | mov eax, 20h ; or 10h |
1339 | mwait |
1348 | mwait |
1340 | jmp idle_loop_mwait |
1349 | jmp idle_loop_mwait |
1341 | 1350 | ||
1342 | 1351 | ||
1343 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1352 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1344 | ; ; |
1353 | ; ; |
1345 | ; INCLUDED SYSTEM FILES ; |
1354 | ; INCLUDED SYSTEM FILES ; |
1346 | ; ; |
1355 | ; ; |
1347 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1356 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1348 | 1357 | ||
1349 | 1358 | ||
1350 | include "kernel32.inc" |
1359 | include "kernel32.inc" |
1351 | 1360 | ||
1352 | 1361 | ||
1353 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1362 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1354 | ; ; |
1363 | ; ; |
1355 | ; KERNEL FUNCTIONS ; |
1364 | ; KERNEL FUNCTIONS ; |
1356 | ; ; |
1365 | ; ; |
1357 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1366 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1358 | 1367 | ||
1359 | reserve_irqs_ports: |
1368 | reserve_irqs_ports: |
1360 | 1369 | ||
1361 | 1370 | ||
1362 | ; RESERVE PORTS |
1371 | ; RESERVE PORTS |
1363 | mov eax, RESERVED_PORTS |
1372 | mov eax, RESERVED_PORTS |
1364 | mov ecx, 1 |
1373 | mov ecx, 1 |
1365 | 1374 | ||
1366 | mov [eax], dword 4 |
1375 | mov [eax], dword 4 |
1367 | 1376 | ||
1368 | mov [eax+16], ecx |
1377 | mov [eax+16], ecx |
1369 | mov [eax+16+4], dword 0 |
1378 | mov [eax+16+4], dword 0 |
1370 | mov [eax+16+8], dword 0x2D |
1379 | mov [eax+16+8], dword 0x2D |
1371 | 1380 | ||
1372 | mov [eax+32], ecx |
1381 | mov [eax+32], ecx |
1373 | mov [eax+32+4], dword 0x30 |
1382 | mov [eax+32+4], dword 0x30 |
1374 | mov [eax+32+8], dword 0x4D |
1383 | mov [eax+32+8], dword 0x4D |
1375 | 1384 | ||
1376 | mov [eax+48], ecx |
1385 | mov [eax+48], ecx |
1377 | mov [eax+48+4], dword 0x50 |
1386 | mov [eax+48+4], dword 0x50 |
1378 | mov [eax+48+8], dword 0xDF |
1387 | mov [eax+48+8], dword 0xDF |
1379 | 1388 | ||
1380 | mov [eax+64], ecx |
1389 | mov [eax+64], ecx |
1381 | mov [eax+64+4], dword 0xE5 |
1390 | mov [eax+64+4], dword 0xE5 |
1382 | mov [eax+64+8], dword 0xFF |
1391 | mov [eax+64+8], dword 0xFF |
1383 | 1392 | ||
1384 | ret |
1393 | ret |
1385 | 1394 | ||
1386 | 1395 | ||
1387 | iglobal |
1396 | iglobal |
1388 | process_number dd 0x2 |
1397 | process_number dd 0x2 |
1389 | endg |
1398 | endg |
1390 | 1399 | ||
1391 | set_variables: |
1400 | set_variables: |
1392 | 1401 | ||
1393 | mov ecx, 0x16 ; flush port 0x60 |
1402 | mov ecx, 0x16 ; flush port 0x60 |
1394 | .fl60: |
1403 | .fl60: |
1395 | in al, 0x60 |
1404 | in al, 0x60 |
1396 | loop .fl60 |
1405 | loop .fl60 |
1397 | push eax |
1406 | push eax |
1398 | 1407 | ||
1399 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1408 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1400 | shr ax, 1 |
1409 | shr ax, 1 |
1401 | shl eax, 16 |
1410 | shl eax, 16 |
1402 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1411 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1403 | shr ax, 1 |
1412 | shr ax, 1 |
1404 | mov [MOUSE_X], eax |
1413 | mov [MOUSE_X], eax |
1405 | call wakeup_osloop |
1414 | call wakeup_osloop |
1406 | 1415 | ||
1407 | xor eax, eax |
1416 | xor eax, eax |
1408 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1417 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1409 | 1418 | ||
1410 | mov byte [KEY_COUNT], al ; keyboard buffer |
1419 | mov byte [KEY_COUNT], al ; keyboard buffer |
1411 | mov byte [BTN_COUNT], al ; button buffer |
1420 | mov byte [BTN_COUNT], al ; button buffer |
1412 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1421 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1413 | 1422 | ||
1414 | pop eax |
1423 | pop eax |
1415 | ret |
1424 | ret |
1416 | 1425 | ||
1417 | align 4 |
1426 | align 4 |
1418 | ;input eax=43,bl-byte of output, ecx - number of port |
1427 | ;input eax=43,bl-byte of output, ecx - number of port |
1419 | sys_outport: |
1428 | sys_outport: |
1420 | 1429 | ||
1421 | mov edi, ecx ; separate flag for read / write |
1430 | mov edi, ecx ; separate flag for read / write |
1422 | and ecx, 65535 |
1431 | and ecx, 65535 |
1423 | 1432 | ||
1424 | mov eax, [RESERVED_PORTS] |
1433 | mov eax, [RESERVED_PORTS] |
1425 | test eax, eax |
1434 | test eax, eax |
1426 | jnz .sopl8 |
1435 | jnz .sopl8 |
1427 | inc eax |
1436 | inc eax |
1428 | mov [esp+32], eax |
1437 | mov [esp+32], eax |
1429 | ret |
1438 | ret |
1430 | 1439 | ||
1431 | .sopl8: |
1440 | .sopl8: |
1432 | mov edx, [TASK_BASE] |
1441 | mov edx, [TASK_BASE] |
1433 | mov edx, [edx+0x4] |
1442 | mov edx, [edx+0x4] |
1434 | ;and ecx,65535 |
1443 | ;and ecx,65535 |
1435 | ;cld - set on interrupt 0x40 |
1444 | ;cld - set on interrupt 0x40 |
1436 | .sopl1: |
1445 | .sopl1: |
1437 | 1446 | ||
1438 | mov esi, eax |
1447 | mov esi, eax |
1439 | shl esi, 4 |
1448 | shl esi, 4 |
1440 | add esi, RESERVED_PORTS |
1449 | add esi, RESERVED_PORTS |
1441 | cmp edx, [esi+0] |
1450 | cmp edx, [esi+0] |
1442 | jne .sopl2 |
1451 | jne .sopl2 |
1443 | cmp ecx, [esi+4] |
1452 | cmp ecx, [esi+4] |
1444 | jb .sopl2 |
1453 | jb .sopl2 |
1445 | cmp ecx, [esi+8] |
1454 | cmp ecx, [esi+8] |
1446 | jg .sopl2 |
1455 | jg .sopl2 |
1447 | .sopl3: |
1456 | .sopl3: |
1448 | 1457 | ||
1449 | test edi, 0x80000000; read ? |
1458 | test edi, 0x80000000; read ? |
1450 | jnz .sopl4 |
1459 | jnz .sopl4 |
1451 | 1460 | ||
1452 | mov eax, ebx |
1461 | mov eax, ebx |
1453 | mov dx, cx ; write |
1462 | mov dx, cx ; write |
1454 | out dx, al |
1463 | out dx, al |
1455 | and [esp+32], dword 0 |
1464 | and [esp+32], dword 0 |
1456 | ret |
1465 | ret |
1457 | 1466 | ||
1458 | .sopl2: |
1467 | .sopl2: |
1459 | 1468 | ||
1460 | dec eax |
1469 | dec eax |
1461 | jnz .sopl1 |
1470 | jnz .sopl1 |
1462 | inc eax |
1471 | inc eax |
1463 | mov [esp+32], eax |
1472 | mov [esp+32], eax |
1464 | ret |
1473 | ret |
1465 | 1474 | ||
1466 | 1475 | ||
1467 | .sopl4: |
1476 | .sopl4: |
1468 | 1477 | ||
1469 | mov dx, cx ; read |
1478 | mov dx, cx ; read |
1470 | in al, dx |
1479 | in al, dx |
1471 | and eax, 0xff |
1480 | and eax, 0xff |
1472 | and [esp+32], dword 0 |
1481 | and [esp+32], dword 0 |
1473 | mov [esp+20], eax |
1482 | mov [esp+20], eax |
1474 | ret |
1483 | ret |
1475 | 1484 | ||
1476 | display_number: |
1485 | display_number: |
1477 | ;It is not optimization |
1486 | ;It is not optimization |
1478 | mov eax, ebx |
1487 | mov eax, ebx |
1479 | mov ebx, ecx |
1488 | mov ebx, ecx |
1480 | mov ecx, edx |
1489 | mov ecx, edx |
1481 | mov edx, esi |
1490 | mov edx, esi |
1482 | mov esi, edi |
1491 | mov esi, edi |
1483 | ; eax = print type, al=0 -> ebx is number |
1492 | ; eax = print type, al=0 -> ebx is number |
1484 | ; al=1 -> ebx is pointer |
1493 | ; al=1 -> ebx is pointer |
1485 | ; ah=0 -> display decimal |
1494 | ; ah=0 -> display decimal |
1486 | ; ah=1 -> display hexadecimal |
1495 | ; ah=1 -> display hexadecimal |
1487 | ; ah=2 -> display binary |
1496 | ; ah=2 -> display binary |
1488 | ; eax bits 16-21 = number of digits to display (0-32) |
1497 | ; eax bits 16-21 = number of digits to display (0-32) |
1489 | ; eax bits 22-31 = reserved |
1498 | ; eax bits 22-31 = reserved |
1490 | ; |
1499 | ; |
1491 | ; ebx = number or pointer |
1500 | ; ebx = number or pointer |
1492 | ; ecx = x shl 16 + y |
1501 | ; ecx = x shl 16 + y |
1493 | ; edx = color |
1502 | ; edx = color |
1494 | xor edi, edi |
1503 | xor edi, edi |
1495 | display_number_force: |
1504 | display_number_force: |
1496 | push eax |
1505 | push eax |
1497 | and eax, 0x3fffffff |
1506 | and eax, 0x3fffffff |
1498 | cmp eax, 0xffff ; length > 0 ? |
1507 | cmp eax, 0xffff ; length > 0 ? |
1499 | pop eax |
1508 | pop eax |
1500 | jge cont_displ |
1509 | jge cont_displ |
1501 | ret |
1510 | ret |
1502 | cont_displ: |
1511 | cont_displ: |
1503 | push eax |
1512 | push eax |
1504 | and eax, 0x3fffffff |
1513 | and eax, 0x3fffffff |
1505 | cmp eax, 61*0x10000 ; length <= 60 ? |
1514 | cmp eax, 61*0x10000 ; length <= 60 ? |
1506 | pop eax |
1515 | pop eax |
1507 | jb cont_displ2 |
1516 | jb cont_displ2 |
1508 | ret |
1517 | ret |
1509 | cont_displ2: |
1518 | cont_displ2: |
1510 | 1519 | ||
1511 | pushad |
1520 | pushad |
1512 | 1521 | ||
1513 | cmp al, 1 ; ecx is a pointer ? |
1522 | cmp al, 1 ; ecx is a pointer ? |
1514 | jne displnl1 |
1523 | jne displnl1 |
1515 | mov ebp, ebx |
1524 | mov ebp, ebx |
1516 | add ebp, 4 |
1525 | add ebp, 4 |
1517 | mov ebp, [ebp+std_application_base_address] |
1526 | mov ebp, [ebp+std_application_base_address] |
1518 | mov ebx, [ebx+std_application_base_address] |
1527 | mov ebx, [ebx+std_application_base_address] |
1519 | displnl1: |
1528 | displnl1: |
1520 | sub esp, 64 |
1529 | sub esp, 64 |
1521 | 1530 | ||
1522 | test ah, ah ; DECIMAL |
1531 | test ah, ah ; DECIMAL |
1523 | jnz no_display_desnum |
1532 | jnz no_display_desnum |
1524 | shr eax, 16 |
1533 | shr eax, 16 |
1525 | and eax, 0xC03f |
1534 | and eax, 0xC03f |
1526 | ; and eax,0x3f |
1535 | ; and eax,0x3f |
1527 | push eax |
1536 | push eax |
1528 | and eax, 0x3f |
1537 | and eax, 0x3f |
1529 | mov edi, esp |
1538 | mov edi, esp |
1530 | add edi, 4+64-1 |
1539 | add edi, 4+64-1 |
1531 | mov ecx, eax |
1540 | mov ecx, eax |
1532 | mov eax, ebx |
1541 | mov eax, ebx |
1533 | mov ebx, 10 |
1542 | mov ebx, 10 |
1534 | d_desnum: |
1543 | d_desnum: |
1535 | xor edx, edx |
1544 | xor edx, edx |
1536 | call division_64_bits |
1545 | call division_64_bits |
1537 | div ebx |
1546 | div ebx |
1538 | add dl, 48 |
1547 | add dl, 48 |
1539 | mov [edi], dl |
1548 | mov [edi], dl |
1540 | dec edi |
1549 | dec edi |
1541 | loop d_desnum |
1550 | loop d_desnum |
1542 | pop eax |
1551 | pop eax |
1543 | call normalize_number |
1552 | call normalize_number |
1544 | call draw_num_text |
1553 | call draw_num_text |
1545 | add esp, 64 |
1554 | add esp, 64 |
1546 | popad |
1555 | popad |
1547 | ret |
1556 | ret |
1548 | no_display_desnum: |
1557 | no_display_desnum: |
1549 | 1558 | ||
1550 | cmp ah, 0x01 ; HEXADECIMAL |
1559 | cmp ah, 0x01 ; HEXADECIMAL |
1551 | jne no_display_hexnum |
1560 | jne no_display_hexnum |
1552 | shr eax, 16 |
1561 | shr eax, 16 |
1553 | and eax, 0xC03f |
1562 | and eax, 0xC03f |
1554 | ; and eax,0x3f |
1563 | ; and eax,0x3f |
1555 | push eax |
1564 | push eax |
1556 | and eax, 0x3f |
1565 | and eax, 0x3f |
1557 | mov edi, esp |
1566 | mov edi, esp |
1558 | add edi, 4+64-1 |
1567 | add edi, 4+64-1 |
1559 | mov ecx, eax |
1568 | mov ecx, eax |
1560 | mov eax, ebx |
1569 | mov eax, ebx |
1561 | mov ebx, 16 |
1570 | mov ebx, 16 |
1562 | d_hexnum: |
1571 | d_hexnum: |
1563 | xor edx, edx |
1572 | xor edx, edx |
1564 | call division_64_bits |
1573 | call division_64_bits |
1565 | div ebx |
1574 | div ebx |
1566 | hexletters = __fdo_hexdigits |
1575 | hexletters = __fdo_hexdigits |
1567 | add edx, hexletters |
1576 | add edx, hexletters |
1568 | mov dl, [edx] |
1577 | mov dl, [edx] |
1569 | mov [edi], dl |
1578 | mov [edi], dl |
1570 | dec edi |
1579 | dec edi |
1571 | loop d_hexnum |
1580 | loop d_hexnum |
1572 | pop eax |
1581 | pop eax |
1573 | call normalize_number |
1582 | call normalize_number |
1574 | call draw_num_text |
1583 | call draw_num_text |
1575 | add esp, 64 |
1584 | add esp, 64 |
1576 | popad |
1585 | popad |
1577 | ret |
1586 | ret |
1578 | no_display_hexnum: |
1587 | no_display_hexnum: |
1579 | 1588 | ||
1580 | cmp ah, 0x02 ; BINARY |
1589 | cmp ah, 0x02 ; BINARY |
1581 | jne no_display_binnum |
1590 | jne no_display_binnum |
1582 | shr eax, 16 |
1591 | shr eax, 16 |
1583 | and eax, 0xC03f |
1592 | and eax, 0xC03f |
1584 | ; and eax,0x3f |
1593 | ; and eax,0x3f |
1585 | push eax |
1594 | push eax |
1586 | and eax, 0x3f |
1595 | and eax, 0x3f |
1587 | mov edi, esp |
1596 | mov edi, esp |
1588 | add edi, 4+64-1 |
1597 | add edi, 4+64-1 |
1589 | mov ecx, eax |
1598 | mov ecx, eax |
1590 | mov eax, ebx |
1599 | mov eax, ebx |
1591 | mov ebx, 2 |
1600 | mov ebx, 2 |
1592 | d_binnum: |
1601 | d_binnum: |
1593 | xor edx, edx |
1602 | xor edx, edx |
1594 | call division_64_bits |
1603 | call division_64_bits |
1595 | div ebx |
1604 | div ebx |
1596 | add dl, 48 |
1605 | add dl, 48 |
1597 | mov [edi], dl |
1606 | mov [edi], dl |
1598 | dec edi |
1607 | dec edi |
1599 | loop d_binnum |
1608 | loop d_binnum |
1600 | pop eax |
1609 | pop eax |
1601 | call normalize_number |
1610 | call normalize_number |
1602 | call draw_num_text |
1611 | call draw_num_text |
1603 | add esp, 64 |
1612 | add esp, 64 |
1604 | popad |
1613 | popad |
1605 | ret |
1614 | ret |
1606 | no_display_binnum: |
1615 | no_display_binnum: |
1607 | 1616 | ||
1608 | add esp, 64 |
1617 | add esp, 64 |
1609 | popad |
1618 | popad |
1610 | ret |
1619 | ret |
1611 | 1620 | ||
1612 | normalize_number: |
1621 | normalize_number: |
1613 | test ah, 0x80 |
1622 | test ah, 0x80 |
1614 | jz .continue |
1623 | jz .continue |
1615 | mov ecx, 48 |
1624 | mov ecx, 48 |
1616 | and eax, 0x3f |
1625 | and eax, 0x3f |
1617 | @@: |
1626 | @@: |
1618 | inc edi |
1627 | inc edi |
1619 | cmp [edi], cl |
1628 | cmp [edi], cl |
1620 | jne .continue |
1629 | jne .continue |
1621 | dec eax |
1630 | dec eax |
1622 | cmp eax, 1 |
1631 | cmp eax, 1 |
1623 | ja @r |
1632 | ja @r |
1624 | mov al, 1 |
1633 | mov al, 1 |
1625 | .continue: |
1634 | .continue: |
1626 | and eax, 0x3f |
1635 | and eax, 0x3f |
1627 | ret |
1636 | ret |
1628 | 1637 | ||
1629 | division_64_bits: |
1638 | division_64_bits: |
1630 | test [esp+1+4], byte 0x40 |
1639 | test [esp+1+4], byte 0x40 |
1631 | jz .continue |
1640 | jz .continue |
1632 | push eax |
1641 | push eax |
1633 | mov eax, ebp |
1642 | mov eax, ebp |
1634 | div ebx |
1643 | div ebx |
1635 | mov ebp, eax |
1644 | mov ebp, eax |
1636 | pop eax |
1645 | pop eax |
1637 | .continue: |
1646 | .continue: |
1638 | ret |
1647 | ret |
1639 | 1648 | ||
1640 | draw_num_text: |
1649 | draw_num_text: |
1641 | mov esi, eax |
1650 | mov esi, eax |
1642 | mov edx, 64+4 |
1651 | mov edx, 64+4 |
1643 | sub edx, eax |
1652 | sub edx, eax |
1644 | add edx, esp |
1653 | add edx, esp |
1645 | mov ebx, [esp+64+32-8+4] |
1654 | mov ebx, [esp+64+32-8+4] |
1646 | ; add window start x & y |
1655 | ; add window start x & y |
1647 | mov ecx, [TASK_BASE] |
1656 | mov ecx, [TASK_BASE] |
1648 | 1657 | ||
1649 | mov edi, [CURRENT_TASK] |
1658 | mov edi, [CURRENT_TASK] |
1650 | shl edi, 8 |
1659 | shl edi, 8 |
1651 | 1660 | ||
1652 | mov eax, [ecx-twdw+WDATA.box.left] |
1661 | mov eax, [ecx-twdw+WDATA.box.left] |
1653 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1662 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1654 | shl eax, 16 |
1663 | shl eax, 16 |
1655 | add eax, [ecx-twdw+WDATA.box.top] |
1664 | add eax, [ecx-twdw+WDATA.box.top] |
1656 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1665 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1657 | add ebx, eax |
1666 | add ebx, eax |
1658 | mov ecx, [esp+64+32-12+4] |
1667 | mov ecx, [esp+64+32-12+4] |
1659 | and ecx, not 0x80000000 ; force counted string |
1668 | and ecx, not 0x80000000 ; force counted string |
1660 | mov eax, [esp+64+8] ; background color (if given) |
1669 | mov eax, [esp+64+8] ; background color (if given) |
1661 | mov edi, [esp+64+4] |
1670 | mov edi, [esp+64+4] |
1662 | jmp dtext |
1671 | jmp dtext |
1663 | ;----------------------------------------------------------------------------- |
1672 | ;----------------------------------------------------------------------------- |
1664 | iglobal |
1673 | iglobal |
1665 | midi_base dw 0 |
1674 | midi_base dw 0 |
1666 | endg |
1675 | endg |
1667 | ;----------------------------------------------------------------------------- |
1676 | ;----------------------------------------------------------------------------- |
1668 | align 4 |
1677 | align 4 |
1669 | sys_setup: |
1678 | sys_setup: |
1670 | ; 1 = roland mpu midi base , base io address |
1679 | ; 1 = roland mpu midi base , base io address |
1671 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1680 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1672 | ; 3 = not used |
1681 | ; 3 = not used |
1673 | ; 4 = not used |
1682 | ; 4 = not used |
1674 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1683 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1675 | ; 6 = not used |
1684 | ; 6 = not used |
1676 | ; 7 = not used |
1685 | ; 7 = not used |
1677 | ; 8 = not used |
1686 | ; 8 = not used |
1678 | ; 9 = not used |
1687 | ; 9 = not used |
1679 | ; 10 = not used |
1688 | ; 10 = not used |
1680 | ; 11 = enable lba read |
1689 | ; 11 = enable lba read |
1681 | ; 12 = enable pci access |
1690 | ; 12 = enable pci access |
1682 | ;----------------------------------------------------------------------------- |
1691 | ;----------------------------------------------------------------------------- |
1683 | and [esp+32], dword 0 |
1692 | and [esp+32], dword 0 |
1684 | ; F.21.1 - set MPU MIDI base port |
1693 | ; F.21.1 - set MPU MIDI base port |
1685 | dec ebx |
1694 | dec ebx |
1686 | jnz @f |
1695 | jnz @f |
1687 | 1696 | ||
1688 | cmp ecx, 0x100 |
1697 | cmp ecx, 0x100 |
1689 | jb @f |
1698 | jb @f |
1690 | 1699 | ||
1691 | mov esi, 65535 |
1700 | mov esi, 65535 |
1692 | cmp esi, ecx |
1701 | cmp esi, ecx |
1693 | jb @f |
1702 | jb @f |
1694 | 1703 | ||
1695 | mov [midi_base], cx |
1704 | mov [midi_base], cx |
1696 | mov word [mididp], cx |
1705 | mov word [mididp], cx |
1697 | inc cx |
1706 | inc cx |
1698 | mov word [midisp], cx |
1707 | mov word [midisp], cx |
1699 | ret |
1708 | ret |
1700 | ;-------------------------------------- |
1709 | ;-------------------------------------- |
1701 | @@: |
1710 | @@: |
1702 | ; F.21.2 - set keyboard layout |
1711 | ; F.21.2 - set keyboard layout |
1703 | dec ebx |
1712 | dec ebx |
1704 | jnz @f |
1713 | jnz @f |
1705 | 1714 | ||
1706 | mov edi, [TASK_BASE] |
1715 | mov edi, [TASK_BASE] |
1707 | mov eax, [edi+TASKDATA.mem_start] |
1716 | mov eax, [edi+TASKDATA.mem_start] |
1708 | add eax, edx |
1717 | add eax, edx |
1709 | ; 1 = normal layout |
1718 | ; 1 = normal layout |
1710 | dec ecx |
1719 | dec ecx |
1711 | jnz .shift |
1720 | jnz .shift |
1712 | 1721 | ||
1713 | mov ebx, keymap |
1722 | mov ebx, keymap |
1714 | mov ecx, 128 |
1723 | mov ecx, 128 |
1715 | call memmove |
1724 | call memmove |
1716 | ret |
1725 | ret |
1717 | ;-------------------------------------- |
1726 | ;-------------------------------------- |
1718 | .shift: |
1727 | .shift: |
1719 | ; 2 = layout at pressed Shift |
1728 | ; 2 = layout at pressed Shift |
1720 | dec ecx |
1729 | dec ecx |
1721 | jnz .alt |
1730 | jnz .alt |
1722 | 1731 | ||
1723 | mov ebx, keymap_shift |
1732 | mov ebx, keymap_shift |
1724 | mov ecx, 128 |
1733 | mov ecx, 128 |
1725 | call memmove |
1734 | call memmove |
1726 | ret |
1735 | ret |
1727 | ;-------------------------------------- |
1736 | ;-------------------------------------- |
1728 | .alt: |
1737 | .alt: |
1729 | ; 3 = layout at pressed Alt |
1738 | ; 3 = layout at pressed Alt |
1730 | dec ecx |
1739 | dec ecx |
1731 | jnz .country |
1740 | jnz .country |
1732 | 1741 | ||
1733 | mov ebx, keymap_alt |
1742 | mov ebx, keymap_alt |
1734 | mov ecx, 128 |
1743 | mov ecx, 128 |
1735 | call memmove |
1744 | call memmove |
1736 | ret |
1745 | ret |
1737 | ;-------------------------------------- |
1746 | ;-------------------------------------- |
1738 | .country: |
1747 | .country: |
1739 | ; country identifier |
1748 | ; country identifier |
1740 | sub ecx, 6 |
1749 | sub ecx, 6 |
1741 | jnz .error |
1750 | jnz .error |
1742 | 1751 | ||
1743 | mov word [keyboard], dx |
1752 | mov word [keyboard], dx |
1744 | ret |
1753 | ret |
1745 | ;-------------------------------------- |
1754 | ;-------------------------------------- |
1746 | @@: |
1755 | @@: |
1747 | ; F.21.5 - set system language |
1756 | ; F.21.5 - set system language |
1748 | sub ebx, 3 |
1757 | sub ebx, 3 |
1749 | jnz @f |
1758 | jnz @f |
1750 | 1759 | ||
1751 | mov [syslang], ecx |
1760 | mov [syslang], ecx |
1752 | ret |
1761 | ret |
1753 | ;-------------------------------------- |
1762 | ;-------------------------------------- |
1754 | @@: |
1763 | @@: |
1755 | ; F.21.11 - enable/disable low-level access to HD |
1764 | ; F.21.11 - enable/disable low-level access to HD |
1756 | and ecx, 1 |
1765 | and ecx, 1 |
1757 | sub ebx, 6 |
1766 | sub ebx, 6 |
1758 | jnz @f |
1767 | jnz @f |
1759 | 1768 | ||
1760 | mov [lba_read_enabled], ecx |
1769 | mov [lba_read_enabled], ecx |
1761 | ret |
1770 | ret |
1762 | ;-------------------------------------- |
1771 | ;-------------------------------------- |
1763 | @@: |
1772 | @@: |
1764 | ; F.21.12 - enable/disable low-level access to PCI |
1773 | ; F.21.12 - enable/disable low-level access to PCI |
1765 | dec ebx |
1774 | dec ebx |
1766 | jnz .error |
1775 | jnz .error |
1767 | 1776 | ||
1768 | mov [pci_access_enabled], ecx |
1777 | mov [pci_access_enabled], ecx |
1769 | ret |
1778 | ret |
1770 | ;-------------------------------------- |
1779 | ;-------------------------------------- |
1771 | .error: |
1780 | .error: |
1772 | or [esp+32], dword -1 |
1781 | or [esp+32], dword -1 |
1773 | ret |
1782 | ret |
1774 | ;----------------------------------------------------------------------------- |
1783 | ;----------------------------------------------------------------------------- |
1775 | align 4 |
1784 | align 4 |
1776 | sys_getsetup: |
1785 | sys_getsetup: |
1777 | ; 1 = roland mpu midi base , base io address |
1786 | ; 1 = roland mpu midi base , base io address |
1778 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1787 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1779 | ; 3 = not used |
1788 | ; 3 = not used |
1780 | ; 4 = not used |
1789 | ; 4 = not used |
1781 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1790 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1782 | ; 6 = not used |
1791 | ; 6 = not used |
1783 | ; 7 = not used |
1792 | ; 7 = not used |
1784 | ; 8 = not used |
1793 | ; 8 = not used |
1785 | ; 9 = get hs timer tic |
1794 | ; 9 = get hs timer tic |
1786 | ; 10 = not used |
1795 | ; 10 = not used |
1787 | ; 11 = get the state "lba read" |
1796 | ; 11 = get the state "lba read" |
1788 | ; 12 = get the state "pci access" |
1797 | ; 12 = get the state "pci access" |
1789 | ;----------------------------------------------------------------------------- |
1798 | ;----------------------------------------------------------------------------- |
1790 | ; F.26.1 - get MPU MIDI base port |
1799 | ; F.26.1 - get MPU MIDI base port |
1791 | dec ebx |
1800 | dec ebx |
1792 | jnz @f |
1801 | jnz @f |
1793 | 1802 | ||
1794 | movzx eax, [midi_base] |
1803 | movzx eax, [midi_base] |
1795 | mov [esp+32], eax |
1804 | mov [esp+32], eax |
1796 | ret |
1805 | ret |
1797 | ;-------------------------------------- |
1806 | ;-------------------------------------- |
1798 | @@: |
1807 | @@: |
1799 | ; F.26.2 - get keyboard layout |
1808 | ; F.26.2 - get keyboard layout |
1800 | dec ebx |
1809 | dec ebx |
1801 | jnz @f |
1810 | jnz @f |
1802 | 1811 | ||
1803 | mov edi, [TASK_BASE] |
1812 | mov edi, [TASK_BASE] |
1804 | mov ebx, [edi+TASKDATA.mem_start] |
1813 | mov ebx, [edi+TASKDATA.mem_start] |
1805 | add ebx, edx |
1814 | add ebx, edx |
1806 | ; 1 = normal layout |
1815 | ; 1 = normal layout |
1807 | dec ecx |
1816 | dec ecx |
1808 | jnz .shift |
1817 | jnz .shift |
1809 | 1818 | ||
1810 | mov eax, keymap |
1819 | mov eax, keymap |
1811 | mov ecx, 128 |
1820 | mov ecx, 128 |
1812 | call memmove |
1821 | call memmove |
1813 | ret |
1822 | ret |
1814 | ;-------------------------------------- |
1823 | ;-------------------------------------- |
1815 | .shift: |
1824 | .shift: |
1816 | ; 2 = layout with pressed Shift |
1825 | ; 2 = layout with pressed Shift |
1817 | dec ecx |
1826 | dec ecx |
1818 | jnz .alt |
1827 | jnz .alt |
1819 | 1828 | ||
1820 | mov eax, keymap_shift |
1829 | mov eax, keymap_shift |
1821 | mov ecx, 128 |
1830 | mov ecx, 128 |
1822 | call memmove |
1831 | call memmove |
1823 | ret |
1832 | ret |
1824 | ;-------------------------------------- |
1833 | ;-------------------------------------- |
1825 | .alt: |
1834 | .alt: |
1826 | ; 3 = layout with pressed Alt |
1835 | ; 3 = layout with pressed Alt |
1827 | dec ecx |
1836 | dec ecx |
1828 | jne .country |
1837 | jne .country |
1829 | 1838 | ||
1830 | mov eax, keymap_alt |
1839 | mov eax, keymap_alt |
1831 | mov ecx, 128 |
1840 | mov ecx, 128 |
1832 | call memmove |
1841 | call memmove |
1833 | ret |
1842 | ret |
1834 | ;-------------------------------------- |
1843 | ;-------------------------------------- |
1835 | .country: |
1844 | .country: |
1836 | ; 9 = country identifier |
1845 | ; 9 = country identifier |
1837 | sub ecx, 6 |
1846 | sub ecx, 6 |
1838 | jnz .error |
1847 | jnz .error |
1839 | 1848 | ||
1840 | movzx eax, word [keyboard] |
1849 | movzx eax, word [keyboard] |
1841 | mov [esp+32], eax |
1850 | mov [esp+32], eax |
1842 | ret |
1851 | ret |
1843 | ;-------------------------------------- |
1852 | ;-------------------------------------- |
1844 | @@: |
1853 | @@: |
1845 | ; F.26.5 - get system language |
1854 | ; F.26.5 - get system language |
1846 | sub ebx, 3 |
1855 | sub ebx, 3 |
1847 | jnz @f |
1856 | jnz @f |
1848 | 1857 | ||
1849 | mov eax, [syslang] |
1858 | mov eax, [syslang] |
1850 | mov [esp+32], eax |
1859 | mov [esp+32], eax |
1851 | ret |
1860 | ret |
1852 | ;-------------------------------------- |
1861 | ;-------------------------------------- |
1853 | @@: |
1862 | @@: |
1854 | ; F.26.9 - get the value of the time counter |
1863 | ; F.26.9 - get the value of the time counter |
1855 | sub ebx, 4 |
1864 | sub ebx, 4 |
1856 | jnz @f |
1865 | jnz @f |
1857 | 1866 | ||
1858 | mov eax, [timer_ticks] |
1867 | mov eax, [timer_ticks] |
1859 | mov [esp+32], eax |
1868 | mov [esp+32], eax |
1860 | ret |
1869 | ret |
1861 | ;-------------------------------------- |
1870 | ;-------------------------------------- |
1862 | @@: |
1871 | @@: |
1863 | ; F.26.11 - Find out whether low-level HD access is enabled |
1872 | ; F.26.11 - Find out whether low-level HD access is enabled |
1864 | sub ebx, 2 |
1873 | sub ebx, 2 |
1865 | jnz @f |
1874 | jnz @f |
1866 | 1875 | ||
1867 | mov eax, [lba_read_enabled] |
1876 | mov eax, [lba_read_enabled] |
1868 | mov [esp+32], eax |
1877 | mov [esp+32], eax |
1869 | ret |
1878 | ret |
1870 | ;-------------------------------------- |
1879 | ;-------------------------------------- |
1871 | @@: |
1880 | @@: |
1872 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1881 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1873 | dec ebx |
1882 | dec ebx |
1874 | jnz .error |
1883 | jnz .error |
1875 | 1884 | ||
1876 | mov eax, [pci_access_enabled] |
1885 | mov eax, [pci_access_enabled] |
1877 | mov [esp+32], eax |
1886 | mov [esp+32], eax |
1878 | ret |
1887 | ret |
1879 | ;-------------------------------------- |
1888 | ;-------------------------------------- |
1880 | .error: |
1889 | .error: |
1881 | or [esp+32], dword -1 |
1890 | or [esp+32], dword -1 |
1882 | ret |
1891 | ret |
1883 | ;----------------------------------------------------------------------------- |
1892 | ;----------------------------------------------------------------------------- |
1884 | get_timer_ticks: |
1893 | get_timer_ticks: |
1885 | mov eax, [timer_ticks] |
1894 | mov eax, [timer_ticks] |
1886 | ret |
1895 | ret |
1887 | ;----------------------------------------------------------------------------- |
1896 | ;----------------------------------------------------------------------------- |
1888 | iglobal |
1897 | iglobal |
1889 | align 4 |
1898 | align 4 |
1890 | mousefn dd msscreen, mswin, msbutton, msset |
1899 | mousefn dd msscreen, mswin, msbutton, msset |
1891 | dd app_load_cursor |
1900 | dd app_load_cursor |
1892 | dd app_set_cursor |
1901 | dd app_set_cursor |
1893 | dd app_delete_cursor |
1902 | dd app_delete_cursor |
1894 | dd msz |
1903 | dd msz |
1895 | endg |
1904 | endg |
1896 | ;----------------------------------------------------------------------------- |
1905 | ;----------------------------------------------------------------------------- |
1897 | readmousepos: |
1906 | readmousepos: |
1898 | 1907 | ||
1899 | ; eax=0 screen relative |
1908 | ; eax=0 screen relative |
1900 | ; eax=1 window relative |
1909 | ; eax=1 window relative |
1901 | ; eax=2 buttons pressed |
1910 | ; eax=2 buttons pressed |
1902 | ; eax=3 set mouse pos ; reserved |
1911 | ; eax=3 set mouse pos ; reserved |
1903 | ; eax=4 load cursor |
1912 | ; eax=4 load cursor |
1904 | ; eax=5 set cursor |
1913 | ; eax=5 set cursor |
1905 | ; eax=6 delete cursor ; reserved |
1914 | ; eax=6 delete cursor ; reserved |
1906 | ; eax=7 get mouse_z |
1915 | ; eax=7 get mouse_z |
1907 | 1916 | ||
1908 | cmp ebx, 7 |
1917 | cmp ebx, 7 |
1909 | ja msset |
1918 | ja msset |
1910 | jmp [mousefn+ebx*4] |
1919 | jmp [mousefn+ebx*4] |
1911 | msscreen: |
1920 | msscreen: |
1912 | mov eax, [MOUSE_X] |
1921 | mov eax, [MOUSE_X] |
1913 | shl eax, 16 |
1922 | shl eax, 16 |
1914 | mov ax, [MOUSE_Y] |
1923 | mov ax, [MOUSE_Y] |
1915 | mov [esp+36-4], eax |
1924 | mov [esp+36-4], eax |
1916 | ret |
1925 | ret |
1917 | mswin: |
1926 | mswin: |
1918 | mov eax, [MOUSE_X] |
1927 | mov eax, [MOUSE_X] |
1919 | shl eax, 16 |
1928 | shl eax, 16 |
1920 | mov ax, [MOUSE_Y] |
1929 | mov ax, [MOUSE_Y] |
1921 | mov esi, [TASK_BASE] |
1930 | mov esi, [TASK_BASE] |
1922 | mov bx, word [esi-twdw+WDATA.box.left] |
1931 | mov bx, word [esi-twdw+WDATA.box.left] |
1923 | shl ebx, 16 |
1932 | shl ebx, 16 |
1924 | mov bx, word [esi-twdw+WDATA.box.top] |
1933 | mov bx, word [esi-twdw+WDATA.box.top] |
1925 | sub eax, ebx |
1934 | sub eax, ebx |
1926 | 1935 | ||
1927 | mov edi, [CURRENT_TASK] |
1936 | mov edi, [CURRENT_TASK] |
1928 | shl edi, 8 |
1937 | shl edi, 8 |
1929 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1938 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1930 | rol eax, 16 |
1939 | rol eax, 16 |
1931 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1940 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1932 | rol eax, 16 |
1941 | rol eax, 16 |
1933 | mov [esp+36-4], eax |
1942 | mov [esp+36-4], eax |
1934 | ret |
1943 | ret |
1935 | msbutton: |
1944 | msbutton: |
1936 | movzx eax, byte [BTN_DOWN] |
1945 | movzx eax, byte [BTN_DOWN] |
1937 | mov [esp+36-4], eax |
1946 | mov [esp+36-4], eax |
1938 | ret |
1947 | ret |
1939 | msz: |
1948 | msz: |
1940 | mov edi, [TASK_COUNT] |
1949 | mov edi, [TASK_COUNT] |
1941 | movzx edi, word [WIN_POS + edi*2] |
1950 | movzx edi, word [WIN_POS + edi*2] |
1942 | cmp edi, [CURRENT_TASK] |
1951 | cmp edi, [CURRENT_TASK] |
1943 | jne @f |
1952 | jne @f |
1944 | mov ax, [MOUSE_SCROLL_H] |
1953 | mov ax, [MOUSE_SCROLL_H] |
1945 | shl eax, 16 |
1954 | shl eax, 16 |
1946 | mov ax, [MOUSE_SCROLL_V] |
1955 | mov ax, [MOUSE_SCROLL_V] |
1947 | mov [esp+36-4], eax |
1956 | mov [esp+36-4], eax |
1948 | and [MOUSE_SCROLL_H], word 0 |
1957 | and [MOUSE_SCROLL_H], word 0 |
1949 | and [MOUSE_SCROLL_V], word 0 |
1958 | and [MOUSE_SCROLL_V], word 0 |
1950 | ret |
1959 | ret |
1951 | @@: |
1960 | @@: |
1952 | and [esp+36-4], dword 0 |
1961 | and [esp+36-4], dword 0 |
1953 | ; ret |
1962 | ; ret |
1954 | msset: |
1963 | msset: |
1955 | ret |
1964 | ret |
1956 | 1965 | ||
1957 | app_load_cursor: |
1966 | app_load_cursor: |
1958 | cmp ecx, OS_BASE |
1967 | cmp ecx, OS_BASE |
1959 | jae msset |
1968 | jae msset |
1960 | stdcall load_cursor, ecx, edx |
1969 | stdcall load_cursor, ecx, edx |
1961 | mov [esp+36-4], eax |
1970 | mov [esp+36-4], eax |
1962 | ret |
1971 | ret |
1963 | 1972 | ||
1964 | app_set_cursor: |
1973 | app_set_cursor: |
1965 | stdcall set_cursor, ecx |
1974 | stdcall set_cursor, ecx |
1966 | mov [esp+36-4], eax |
1975 | mov [esp+36-4], eax |
1967 | ret |
1976 | ret |
1968 | 1977 | ||
1969 | app_delete_cursor: |
1978 | app_delete_cursor: |
1970 | stdcall delete_cursor, ecx |
1979 | stdcall delete_cursor, ecx |
1971 | mov [esp+36-4], eax |
1980 | mov [esp+36-4], eax |
1972 | ret |
1981 | ret |
1973 | 1982 | ||
1974 | is_input: |
1983 | is_input: |
1975 | 1984 | ||
1976 | push edx |
1985 | push edx |
1977 | mov dx, word [midisp] |
1986 | mov dx, word [midisp] |
1978 | in al, dx |
1987 | in al, dx |
1979 | and al, 0x80 |
1988 | and al, 0x80 |
1980 | pop edx |
1989 | pop edx |
1981 | ret |
1990 | ret |
1982 | 1991 | ||
1983 | is_output: |
1992 | is_output: |
1984 | 1993 | ||
1985 | push edx |
1994 | push edx |
1986 | mov dx, word [midisp] |
1995 | mov dx, word [midisp] |
1987 | in al, dx |
1996 | in al, dx |
1988 | and al, 0x40 |
1997 | and al, 0x40 |
1989 | pop edx |
1998 | pop edx |
1990 | ret |
1999 | ret |
1991 | 2000 | ||
1992 | 2001 | ||
1993 | get_mpu_in: |
2002 | get_mpu_in: |
1994 | 2003 | ||
1995 | push edx |
2004 | push edx |
1996 | mov dx, word [mididp] |
2005 | mov dx, word [mididp] |
1997 | in al, dx |
2006 | in al, dx |
1998 | pop edx |
2007 | pop edx |
1999 | ret |
2008 | ret |
2000 | 2009 | ||
2001 | 2010 | ||
2002 | put_mpu_out: |
2011 | put_mpu_out: |
2003 | 2012 | ||
2004 | push edx |
2013 | push edx |
2005 | mov dx, word [mididp] |
2014 | mov dx, word [mididp] |
2006 | out dx, al |
2015 | out dx, al |
2007 | pop edx |
2016 | pop edx |
2008 | ret |
2017 | ret |
2009 | 2018 | ||
2010 | 2019 | ||
2011 | 2020 | ||
2012 | align 4 |
2021 | align 4 |
2013 | 2022 | ||
2014 | sys_midi: |
2023 | sys_midi: |
2015 | cmp [mididp], 0 |
2024 | cmp [mididp], 0 |
2016 | jnz sm0 |
2025 | jnz sm0 |
2017 | mov [esp+36], dword 1 |
2026 | mov [esp+36], dword 1 |
2018 | ret |
2027 | ret |
2019 | sm0: |
2028 | sm0: |
2020 | and [esp+36], dword 0 |
2029 | and [esp+36], dword 0 |
2021 | dec ebx |
2030 | dec ebx |
2022 | jnz smn1 |
2031 | jnz smn1 |
2023 | ; call setuart |
2032 | ; call setuart |
2024 | su1: |
2033 | su1: |
2025 | call is_output |
2034 | call is_output |
2026 | test al, al |
2035 | test al, al |
2027 | jnz su1 |
2036 | jnz su1 |
2028 | mov dx, word [midisp] |
2037 | mov dx, word [midisp] |
2029 | mov al, 0xff |
2038 | mov al, 0xff |
2030 | out dx, al |
2039 | out dx, al |
2031 | su2: |
2040 | su2: |
2032 | mov dx, word [midisp] |
2041 | mov dx, word [midisp] |
2033 | mov al, 0xff |
2042 | mov al, 0xff |
2034 | out dx, al |
2043 | out dx, al |
2035 | call is_input |
2044 | call is_input |
2036 | test al, al |
2045 | test al, al |
2037 | jnz su2 |
2046 | jnz su2 |
2038 | call get_mpu_in |
2047 | call get_mpu_in |
2039 | cmp al, 0xfe |
2048 | cmp al, 0xfe |
2040 | jnz su2 |
2049 | jnz su2 |
2041 | su3: |
2050 | su3: |
2042 | call is_output |
2051 | call is_output |
2043 | test al, al |
2052 | test al, al |
2044 | jnz su3 |
2053 | jnz su3 |
2045 | mov dx, word [midisp] |
2054 | mov dx, word [midisp] |
2046 | mov al, 0x3f |
2055 | mov al, 0x3f |
2047 | out dx, al |
2056 | out dx, al |
2048 | ret |
2057 | ret |
2049 | smn1: |
2058 | smn1: |
2050 | dec ebx |
2059 | dec ebx |
2051 | jnz smn2 |
2060 | jnz smn2 |
2052 | sm10: |
2061 | sm10: |
2053 | call get_mpu_in |
2062 | call get_mpu_in |
2054 | call is_output |
2063 | call is_output |
2055 | test al, al |
2064 | test al, al |
2056 | jnz sm10 |
2065 | jnz sm10 |
2057 | mov al, bl |
2066 | mov al, bl |
2058 | call put_mpu_out |
2067 | call put_mpu_out |
2059 | smn2: |
2068 | smn2: |
2060 | ret |
2069 | ret |
2061 | 2070 | ||
2062 | detect_devices: |
2071 | detect_devices: |
2063 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2072 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2064 | ;include 'detect/commouse.inc' |
2073 | ;include 'detect/commouse.inc' |
2065 | ;include 'detect/ps2mouse.inc' |
2074 | ;include 'detect/ps2mouse.inc' |
2066 | ;include 'detect/dev_fd.inc' |
2075 | ;include 'detect/dev_fd.inc' |
2067 | ;include 'detect/dev_hdcd.inc' |
2076 | ;include 'detect/dev_hdcd.inc' |
2068 | ;include 'detect/sear_par.inc' |
2077 | ;include 'detect/sear_par.inc' |
2069 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2078 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2070 | ret |
2079 | ret |
2071 | 2080 | ||
2072 | sys_end: |
2081 | sys_end: |
2073 | ;-------------------------------------- |
2082 | ;-------------------------------------- |
2074 | cmp [_display.select_cursor], 0 |
2083 | cmp [_display.select_cursor], 0 |
2075 | je @f |
2084 | je @f |
2076 | ; restore default cursor before killing |
2085 | ; restore default cursor before killing |
2077 | pusha |
2086 | pusha |
2078 | mov ecx, [current_slot] |
2087 | mov ecx, [current_slot] |
2079 | call restore_default_cursor_before_killing |
2088 | call restore_default_cursor_before_killing |
2080 | popa |
2089 | popa |
2081 | @@: |
2090 | @@: |
2082 | ;-------------------------------------- |
2091 | ;-------------------------------------- |
2083 | ; kill all sockets this process owns |
2092 | ; kill all sockets this process owns |
2084 | pusha |
2093 | pusha |
2085 | mov edx, [TASK_BASE] |
2094 | mov edx, [TASK_BASE] |
2086 | mov edx, [edx+TASKDATA.pid] |
2095 | mov edx, [edx+TASKDATA.pid] |
2087 | call SOCKET_process_end |
2096 | call SOCKET_process_end |
2088 | popa |
2097 | popa |
2089 | ;-------------------------------------- |
2098 | ;-------------------------------------- |
2090 | mov ecx, [current_slot] |
2099 | mov ecx, [current_slot] |
2091 | mov eax, [ecx+APPDATA.tls_base] |
2100 | mov eax, [ecx+APPDATA.tls_base] |
2092 | test eax, eax |
2101 | test eax, eax |
2093 | jz @F |
2102 | jz @F |
2094 | 2103 | ||
2095 | stdcall user_free, eax |
2104 | stdcall user_free, eax |
2096 | @@: |
2105 | @@: |
2097 | 2106 | ||
2098 | mov eax, [TASK_BASE] |
2107 | mov eax, [TASK_BASE] |
2099 | mov [eax+TASKDATA.state], 3; terminate this program |
2108 | mov [eax+TASKDATA.state], 3; terminate this program |
2100 | call wakeup_osloop |
2109 | call wakeup_osloop |
2101 | 2110 | ||
2102 | .waitterm: ; wait here for termination |
2111 | .waitterm: ; wait here for termination |
2103 | call change_task |
2112 | call change_task |
2104 | jmp .waitterm |
2113 | jmp .waitterm |
2105 | ;------------------------------------------------------------------------------ |
2114 | ;------------------------------------------------------------------------------ |
2106 | align 4 |
2115 | align 4 |
2107 | restore_default_cursor_before_killing: |
2116 | restore_default_cursor_before_killing: |
2108 | pushfd |
2117 | pushfd |
2109 | cli |
2118 | cli |
2110 | mov eax, [def_cursor] |
2119 | mov eax, [def_cursor] |
2111 | mov [ecx+APPDATA.cursor], eax |
2120 | mov [ecx+APPDATA.cursor], eax |
2112 | 2121 | ||
2113 | movzx eax, word [MOUSE_Y] |
2122 | movzx eax, word [MOUSE_Y] |
2114 | movzx ebx, word [MOUSE_X] |
2123 | movzx ebx, word [MOUSE_X] |
2115 | mov eax, [d_width_calc_area + eax*4] |
2124 | mov eax, [d_width_calc_area + eax*4] |
2116 | 2125 | ||
2117 | add eax, [_display.win_map] |
2126 | add eax, [_display.win_map] |
2118 | movzx edx, byte [ebx+eax] |
2127 | movzx edx, byte [ebx+eax] |
2119 | shl edx, 8 |
2128 | shl edx, 8 |
2120 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2129 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2121 | 2130 | ||
2122 | cmp esi, [current_cursor] |
2131 | cmp esi, [current_cursor] |
2123 | je @f |
2132 | je @f |
2124 | 2133 | ||
2125 | push esi |
2134 | push esi |
2126 | call [_display.select_cursor] |
2135 | call [_display.select_cursor] |
2127 | mov [current_cursor], esi |
2136 | mov [current_cursor], esi |
2128 | @@: |
2137 | @@: |
2129 | mov [redrawmouse_unconditional], 1 |
2138 | mov [redrawmouse_unconditional], 1 |
2130 | call wakeup_osloop |
2139 | call wakeup_osloop |
2131 | popfd |
2140 | popfd |
2132 | ret |
2141 | ret |
2133 | ;------------------------------------------------------------------------------ |
2142 | ;------------------------------------------------------------------------------ |
2134 | iglobal |
2143 | iglobal |
2135 | align 4 |
2144 | align 4 |
2136 | sys_system_table: |
2145 | sys_system_table: |
2137 | dd sysfn_deactivate ; 1 = deactivate window |
2146 | dd sysfn_deactivate ; 1 = deactivate window |
2138 | dd sysfn_terminate ; 2 = terminate thread |
2147 | dd sysfn_terminate ; 2 = terminate thread |
2139 | dd sysfn_activate ; 3 = activate window |
2148 | dd sysfn_activate ; 3 = activate window |
2140 | dd sysfn_getidletime ; 4 = get idle time |
2149 | dd sysfn_getidletime ; 4 = get idle time |
2141 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2150 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2142 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2151 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2143 | dd sysfn_getactive ; 7 = get active window |
2152 | dd sysfn_getactive ; 7 = get active window |
2144 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2153 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2145 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2154 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2146 | dd sysfn_minimize ; 10 = minimize window |
2155 | dd sysfn_minimize ; 10 = minimize window |
2147 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2156 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2148 | dd sysfn_lastkey ; 12 = get last pressed key |
2157 | dd sysfn_lastkey ; 12 = get last pressed key |
2149 | dd sysfn_getversion ; 13 = get kernel version |
2158 | dd sysfn_getversion ; 13 = get kernel version |
2150 | dd sysfn_waitretrace ; 14 = wait retrace |
2159 | dd sysfn_waitretrace ; 14 = wait retrace |
2151 | dd sysfn_centermouse ; 15 = center mouse cursor |
2160 | dd sysfn_centermouse ; 15 = center mouse cursor |
2152 | dd sysfn_getfreemem ; 16 = get free memory size |
2161 | dd sysfn_getfreemem ; 16 = get free memory size |
2153 | dd sysfn_getallmem ; 17 = get total memory size |
2162 | dd sysfn_getallmem ; 17 = get total memory size |
2154 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2163 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2155 | ; instead of slot |
2164 | ; instead of slot |
2156 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2165 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2157 | dd sysfn_meminfo ; 20 = get extended memory info |
2166 | dd sysfn_meminfo ; 20 = get extended memory info |
2158 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2167 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2159 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2168 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2160 | dd sysfn_min_windows ; 23 = minimize all windows |
2169 | dd sysfn_min_windows ; 23 = minimize all windows |
2161 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2170 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2162 | sysfn_num = ($ - sys_system_table)/4 |
2171 | sysfn_num = ($ - sys_system_table)/4 |
2163 | endg |
2172 | endg |
2164 | ;------------------------------------------------------------------------------ |
2173 | ;------------------------------------------------------------------------------ |
2165 | sys_system: |
2174 | sys_system: |
2166 | dec ebx |
2175 | dec ebx |
2167 | cmp ebx, sysfn_num |
2176 | cmp ebx, sysfn_num |
2168 | jae @f |
2177 | jae @f |
2169 | jmp dword [sys_system_table + ebx*4] |
2178 | jmp dword [sys_system_table + ebx*4] |
2170 | @@: |
2179 | @@: |
2171 | ret |
2180 | ret |
2172 | ;------------------------------------------------------------------------------ |
2181 | ;------------------------------------------------------------------------------ |
2173 | sysfn_shutdown: ; 18.9 = system shutdown |
2182 | sysfn_shutdown: ; 18.9 = system shutdown |
2174 | cmp ecx, 1 |
2183 | cmp ecx, 1 |
2175 | jl exit_for_anyone |
2184 | jl exit_for_anyone |
2176 | cmp ecx, 4 |
2185 | cmp ecx, 4 |
2177 | jg exit_for_anyone |
2186 | jg exit_for_anyone |
2178 | mov [BOOT_VARS+0x9030], cl |
2187 | mov [BOOT_VARS+0x9030], cl |
2179 | 2188 | ||
2180 | mov eax, [TASK_COUNT] |
2189 | mov eax, [TASK_COUNT] |
2181 | mov [SYS_SHUTDOWN], al |
2190 | mov [SYS_SHUTDOWN], al |
2182 | mov [shutdown_processes], eax |
2191 | mov [shutdown_processes], eax |
2183 | call wakeup_osloop |
2192 | call wakeup_osloop |
2184 | and dword [esp+32], 0 |
2193 | and dword [esp+32], 0 |
2185 | exit_for_anyone: |
2194 | exit_for_anyone: |
2186 | ret |
2195 | ret |
2187 | uglobal |
2196 | uglobal |
2188 | shutdown_processes: |
2197 | shutdown_processes: |
2189 | dd 0x0 |
2198 | dd 0x0 |
2190 | endg |
2199 | endg |
2191 | ;------------------------------------------------------------------------------ |
2200 | ;------------------------------------------------------------------------------ |
2192 | sysfn_terminate: ; 18.2 = TERMINATE |
2201 | sysfn_terminate: ; 18.2 = TERMINATE |
2193 | push ecx |
2202 | push ecx |
2194 | cmp ecx, 2 |
2203 | cmp ecx, 2 |
2195 | jb noprocessterminate |
2204 | jb noprocessterminate |
2196 | mov edx, [TASK_COUNT] |
2205 | mov edx, [TASK_COUNT] |
2197 | cmp ecx, edx |
2206 | cmp ecx, edx |
2198 | ja noprocessterminate |
2207 | ja noprocessterminate |
2199 | mov eax, [TASK_COUNT] |
2208 | mov eax, [TASK_COUNT] |
2200 | shl ecx, 5 |
2209 | shl ecx, 5 |
2201 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2210 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2202 | add ecx, CURRENT_TASK+TASKDATA.state |
2211 | add ecx, CURRENT_TASK+TASKDATA.state |
2203 | cmp byte [ecx], 9 |
2212 | cmp byte [ecx], 9 |
2204 | jz noprocessterminate |
2213 | jz noprocessterminate |
2205 | push ecx edx |
2214 | push ecx edx |
2206 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2215 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2207 | call request_terminate |
2216 | call request_terminate |
2208 | pop edx ecx |
2217 | pop edx ecx |
2209 | test eax, eax |
2218 | test eax, eax |
2210 | jz noprocessterminate |
2219 | jz noprocessterminate |
2211 | ;-------------------------------------- |
2220 | ;-------------------------------------- |
2212 | ; terminate all network sockets it used |
2221 | ; terminate all network sockets it used |
2213 | pusha |
2222 | pusha |
2214 | mov eax, edx |
2223 | mov eax, edx |
2215 | call SOCKET_process_end |
2224 | call SOCKET_process_end |
2216 | popa |
2225 | popa |
2217 | ;-------------------------------------- |
2226 | ;-------------------------------------- |
2218 | cmp [_display.select_cursor], 0 |
2227 | cmp [_display.select_cursor], 0 |
2219 | je .restore_end |
2228 | je .restore_end |
2220 | ; restore default cursor before killing |
2229 | ; restore default cursor before killing |
2221 | pusha |
2230 | pusha |
2222 | mov ecx, [esp+32] |
2231 | mov ecx, [esp+32] |
2223 | shl ecx, 8 |
2232 | shl ecx, 8 |
2224 | add ecx, SLOT_BASE |
2233 | add ecx, SLOT_BASE |
2225 | mov eax, [def_cursor] |
2234 | mov eax, [def_cursor] |
2226 | cmp [ecx+APPDATA.cursor], eax |
2235 | cmp [ecx+APPDATA.cursor], eax |
2227 | je @f |
2236 | je @f |
2228 | call restore_default_cursor_before_killing |
2237 | call restore_default_cursor_before_killing |
2229 | @@: |
2238 | @@: |
2230 | popa |
2239 | popa |
2231 | .restore_end: |
2240 | .restore_end: |
2232 | ;-------------------------------------- |
2241 | ;-------------------------------------- |
2233 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2242 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2234 | mov [ecx], byte 3; clear possible i40's |
2243 | mov [ecx], byte 3; clear possible i40's |
2235 | call wakeup_osloop |
2244 | call wakeup_osloop |
2236 | ;call MEM_Heap_UnLock |
2245 | ;call MEM_Heap_UnLock |
2237 | 2246 | ||
2238 | cmp edx, [application_table_owner]; clear app table stat |
2247 | cmp edx, [application_table_owner]; clear app table stat |
2239 | jne noatsc |
2248 | jne noatsc |
2240 | call unlock_application_table |
2249 | call unlock_application_table |
2241 | noatsc: |
2250 | noatsc: |
2242 | noprocessterminate: |
2251 | noprocessterminate: |
2243 | add esp, 4 |
2252 | add esp, 4 |
2244 | ret |
2253 | ret |
2245 | ;------------------------------------------------------------------------------ |
2254 | ;------------------------------------------------------------------------------ |
2246 | sysfn_terminate2: |
2255 | sysfn_terminate2: |
2247 | ;lock application_table_status mutex |
2256 | ;lock application_table_status mutex |
2248 | .table_status: |
2257 | .table_status: |
2249 | call lock_application_table |
2258 | call lock_application_table |
2250 | mov eax, ecx |
2259 | mov eax, ecx |
2251 | call pid_to_slot |
2260 | call pid_to_slot |
2252 | test eax, eax |
2261 | test eax, eax |
2253 | jz .not_found |
2262 | jz .not_found |
2254 | mov ecx, eax |
2263 | mov ecx, eax |
2255 | cli |
2264 | cli |
2256 | call sysfn_terminate |
2265 | call sysfn_terminate |
2257 | call unlock_application_table |
2266 | call unlock_application_table |
2258 | sti |
2267 | sti |
2259 | and dword [esp+32], 0 |
2268 | and dword [esp+32], 0 |
2260 | ret |
2269 | ret |
2261 | .not_found: |
2270 | .not_found: |
2262 | call unlock_application_table |
2271 | call unlock_application_table |
2263 | or dword [esp+32], -1 |
2272 | or dword [esp+32], -1 |
2264 | ret |
2273 | ret |
2265 | ;------------------------------------------------------------------------------ |
2274 | ;------------------------------------------------------------------------------ |
2266 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2275 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2267 | cmp ecx, 2 |
2276 | cmp ecx, 2 |
2268 | jb .nowindowdeactivate |
2277 | jb .nowindowdeactivate |
2269 | cmp ecx, [TASK_COUNT] |
2278 | cmp ecx, [TASK_COUNT] |
2270 | ja .nowindowdeactivate |
2279 | ja .nowindowdeactivate |
2271 | 2280 | ||
2272 | movzx esi, word [WIN_STACK + ecx*2] |
2281 | movzx esi, word [WIN_STACK + ecx*2] |
2273 | cmp esi, 1 |
2282 | cmp esi, 1 |
2274 | je .nowindowdeactivate ; already deactive |
2283 | je .nowindowdeactivate ; already deactive |
2275 | 2284 | ||
2276 | mov edi, ecx |
2285 | mov edi, ecx |
2277 | shl edi, 5 |
2286 | shl edi, 5 |
2278 | add edi, window_data |
2287 | add edi, window_data |
2279 | movzx esi, word [WIN_STACK + ecx * 2] |
2288 | movzx esi, word [WIN_STACK + ecx * 2] |
2280 | lea esi, [WIN_POS + esi * 2] |
2289 | lea esi, [WIN_POS + esi * 2] |
2281 | call window._.window_deactivate |
2290 | call window._.window_deactivate |
2282 | 2291 | ||
2283 | call syscall_display_settings._.calculate_whole_screen |
2292 | call syscall_display_settings._.calculate_whole_screen |
2284 | call syscall_display_settings._.redraw_whole_screen |
2293 | call syscall_display_settings._.redraw_whole_screen |
2285 | .nowindowdeactivate: |
2294 | .nowindowdeactivate: |
2286 | ret |
2295 | ret |
2287 | ;------------------------------------------------------------------------------ |
2296 | ;------------------------------------------------------------------------------ |
2288 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2297 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2289 | cmp ecx, 2 |
2298 | cmp ecx, 2 |
2290 | jb .nowindowactivate |
2299 | jb .nowindowactivate |
2291 | cmp ecx, [TASK_COUNT] |
2300 | cmp ecx, [TASK_COUNT] |
2292 | ja .nowindowactivate |
2301 | ja .nowindowactivate |
2293 | ;------------------------------------- |
2302 | ;------------------------------------- |
2294 | @@: |
2303 | @@: |
2295 | ; If the window is captured and moved by the user, |
2304 | ; If the window is captured and moved by the user, |
2296 | ; then you can't change the position in window stack!!! |
2305 | ; then you can't change the position in window stack!!! |
2297 | mov al, [mouse.active_sys_window.action] |
2306 | mov al, [mouse.active_sys_window.action] |
2298 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2307 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2299 | test al, al |
2308 | test al, al |
2300 | jz @f |
2309 | jz @f |
2301 | call change_task |
2310 | call change_task |
2302 | jmp @b |
2311 | jmp @b |
2303 | @@: |
2312 | @@: |
2304 | ;------------------------------------- |
2313 | ;------------------------------------- |
2305 | mov [window_minimize], 2; restore window if minimized |
2314 | mov [window_minimize], 2; restore window if minimized |
2306 | call wakeup_osloop |
2315 | call wakeup_osloop |
2307 | 2316 | ||
2308 | movzx esi, word [WIN_STACK + ecx*2] |
2317 | movzx esi, word [WIN_STACK + ecx*2] |
2309 | cmp esi, [TASK_COUNT] |
2318 | cmp esi, [TASK_COUNT] |
2310 | je .nowindowactivate; already active |
2319 | je .nowindowactivate; already active |
2311 | 2320 | ||
2312 | mov edi, ecx |
2321 | mov edi, ecx |
2313 | shl edi, 5 |
2322 | shl edi, 5 |
2314 | add edi, window_data |
2323 | add edi, window_data |
2315 | movzx esi, word [WIN_STACK + ecx * 2] |
2324 | movzx esi, word [WIN_STACK + ecx * 2] |
2316 | lea esi, [WIN_POS + esi * 2] |
2325 | lea esi, [WIN_POS + esi * 2] |
2317 | call waredraw |
2326 | call waredraw |
2318 | .nowindowactivate: |
2327 | .nowindowactivate: |
2319 | ret |
2328 | ret |
2320 | ;------------------------------------------------------------------------------ |
2329 | ;------------------------------------------------------------------------------ |
2321 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2330 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2322 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2331 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2323 | mov [esp+32], eax |
2332 | mov [esp+32], eax |
2324 | ret |
2333 | ret |
2325 | ;------------------------------------------------------------------------------ |
2334 | ;------------------------------------------------------------------------------ |
2326 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2335 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2327 | mov eax, dword [cpu_freq] |
2336 | mov eax, dword [cpu_freq] |
2328 | mov [esp+32], eax |
2337 | mov [esp+32], eax |
2329 | ret |
2338 | ret |
2330 | ;------------------------------------------------------------------------------ |
2339 | ;------------------------------------------------------------------------------ |
2331 | get_cpu_freq: |
2340 | get_cpu_freq: |
2332 | mov eax, dword [cpu_freq] |
2341 | mov eax, dword [cpu_freq] |
2333 | mov edx, dword [cpu_freq+4] |
2342 | mov edx, dword [cpu_freq+4] |
2334 | ret |
2343 | ret |
2335 | ; SAVE ramdisk to /hd/1/menuet.img |
2344 | ; SAVE ramdisk to /hd/1/menuet.img |
2336 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2345 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2337 | include 'blkdev/rdsave.inc' |
2346 | include 'blkdev/rdsave.inc' |
2338 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2347 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2339 | ;------------------------------------------------------------------------------ |
2348 | ;------------------------------------------------------------------------------ |
2340 | align 4 |
2349 | align 4 |
2341 | sysfn_getactive: ; 18.7 = get active window |
2350 | sysfn_getactive: ; 18.7 = get active window |
2342 | mov eax, [TASK_COUNT] |
2351 | mov eax, [TASK_COUNT] |
2343 | movzx eax, word [WIN_POS + eax*2] |
2352 | movzx eax, word [WIN_POS + eax*2] |
2344 | mov [esp+32], eax |
2353 | mov [esp+32], eax |
2345 | ret |
2354 | ret |
2346 | ;------------------------------------------------------------------------------ |
2355 | ;------------------------------------------------------------------------------ |
2347 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2356 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2348 | ; cmp ecx,1 |
2357 | ; cmp ecx,1 |
2349 | dec ecx |
2358 | dec ecx |
2350 | jnz nogetsoundflag |
2359 | jnz nogetsoundflag |
2351 | movzx eax, byte [sound_flag]; get sound_flag |
2360 | movzx eax, byte [sound_flag]; get sound_flag |
2352 | mov [esp+32], eax |
2361 | mov [esp+32], eax |
2353 | ret |
2362 | ret |
2354 | nogetsoundflag: |
2363 | nogetsoundflag: |
2355 | ; cmp ecx,2 |
2364 | ; cmp ecx,2 |
2356 | dec ecx |
2365 | dec ecx |
2357 | jnz nosoundflag |
2366 | jnz nosoundflag |
2358 | xor byte [sound_flag], 1 |
2367 | xor byte [sound_flag], 1 |
2359 | nosoundflag: |
2368 | nosoundflag: |
2360 | ret |
2369 | ret |
2361 | ;------------------------------------------------------------------------------ |
2370 | ;------------------------------------------------------------------------------ |
2362 | sysfn_minimize: ; 18.10 = minimize window |
2371 | sysfn_minimize: ; 18.10 = minimize window |
2363 | mov [window_minimize], 1 |
2372 | mov [window_minimize], 1 |
2364 | call wakeup_osloop |
2373 | call wakeup_osloop |
2365 | ret |
2374 | ret |
2366 | ;------------------------------------------------------------------------------ |
2375 | ;------------------------------------------------------------------------------ |
2367 | align 4 |
2376 | align 4 |
2368 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2377 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2369 | dec ecx |
2378 | dec ecx |
2370 | jnz .exit |
2379 | jnz .exit |
2371 | .small_table: |
2380 | .small_table: |
2372 | mov edi, edx |
2381 | mov edi, edx |
2373 | mov esi, DRIVE_DATA |
2382 | mov esi, DRIVE_DATA |
2374 | mov ecx, DRIVE_DATA_SIZE ;10 |
2383 | mov ecx, DRIVE_DATA_SIZE ;10 |
2375 | cld |
2384 | cld |
2376 | rep movsb |
2385 | rep movsb |
2377 | .exit: |
2386 | .exit: |
2378 | ret |
2387 | ret |
2379 | ;------------------------------------------------------------------------------ |
2388 | ;------------------------------------------------------------------------------ |
2380 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2389 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2381 | and dword [esp+32], 0 |
2390 | and dword [esp+32], 0 |
2382 | ret |
2391 | ret |
2383 | ;------------------------------------------------------------------------------ |
2392 | ;------------------------------------------------------------------------------ |
2384 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2393 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2385 | mov edi, ecx |
2394 | mov edi, ecx |
2386 | mov esi, version_inf |
2395 | mov esi, version_inf |
2387 | mov ecx, version_end-version_inf |
2396 | mov ecx, version_end-version_inf |
2388 | rep movsb |
2397 | rep movsb |
2389 | ret |
2398 | ret |
2390 | ;------------------------------------------------------------------------------ |
2399 | ;------------------------------------------------------------------------------ |
2391 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2400 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2392 | ;wait retrace functions |
2401 | ;wait retrace functions |
2393 | sys_wait_retrace: |
2402 | sys_wait_retrace: |
2394 | mov edx, 0x3da |
2403 | mov edx, 0x3da |
2395 | WaitRetrace_loop: |
2404 | WaitRetrace_loop: |
2396 | in al, dx |
2405 | in al, dx |
2397 | test al, 1000b |
2406 | test al, 1000b |
2398 | jz WaitRetrace_loop |
2407 | jz WaitRetrace_loop |
2399 | and [esp+32], dword 0 |
2408 | and [esp+32], dword 0 |
2400 | ret |
2409 | ret |
2401 | ;------------------------------------------------------------------------------ |
2410 | ;------------------------------------------------------------------------------ |
2402 | align 4 |
2411 | align 4 |
2403 | sysfn_centermouse: ; 18.15 = mouse centered |
2412 | sysfn_centermouse: ; 18.15 = mouse centered |
2404 | ; removed here by |
2413 | ; removed here by |
2405 | ; call mouse_centered |
2414 | ; call mouse_centered |
2406 | ;* mouse centered - start code- Mario79 |
2415 | ;* mouse centered - start code- Mario79 |
2407 | ;mouse_centered: |
2416 | ;mouse_centered: |
2408 | ; push eax |
2417 | ; push eax |
2409 | mov eax, [_display.width] |
2418 | mov eax, [_display.width] |
2410 | shr eax, 1 |
2419 | shr eax, 1 |
2411 | mov [MOUSE_X], ax |
2420 | mov [MOUSE_X], ax |
2412 | mov eax, [_display.height] |
2421 | mov eax, [_display.height] |
2413 | shr eax, 1 |
2422 | shr eax, 1 |
2414 | mov [MOUSE_Y], ax |
2423 | mov [MOUSE_Y], ax |
2415 | call wakeup_osloop |
2424 | call wakeup_osloop |
2416 | ; ret |
2425 | ; ret |
2417 | ;* mouse centered - end code- Mario79 |
2426 | ;* mouse centered - end code- Mario79 |
2418 | xor eax, eax |
2427 | xor eax, eax |
2419 | and [esp+32], eax |
2428 | and [esp+32], eax |
2420 | ; pop eax |
2429 | ; pop eax |
2421 | ret |
2430 | ret |
2422 | ;------------------------------------------------------------------------------ |
2431 | ;------------------------------------------------------------------------------ |
2423 | align 4 |
2432 | align 4 |
2424 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2433 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2425 | test ecx, ecx; get mouse speed factor |
2434 | test ecx, ecx; get mouse speed factor |
2426 | jnz .set_mouse_acceleration |
2435 | jnz .set_mouse_acceleration |
2427 | xor eax, eax |
2436 | xor eax, eax |
2428 | mov ax, [mouse_speed_factor] |
2437 | mov ax, [mouse_speed_factor] |
2429 | mov [esp+32], eax |
2438 | mov [esp+32], eax |
2430 | ret |
2439 | ret |
2431 | .set_mouse_acceleration: |
2440 | .set_mouse_acceleration: |
2432 | ; cmp ecx,1 ; set mouse speed factor |
2441 | ; cmp ecx,1 ; set mouse speed factor |
2433 | dec ecx |
2442 | dec ecx |
2434 | jnz .get_mouse_delay |
2443 | jnz .get_mouse_delay |
2435 | mov [mouse_speed_factor], dx |
2444 | mov [mouse_speed_factor], dx |
2436 | ret |
2445 | ret |
2437 | .get_mouse_delay: |
2446 | .get_mouse_delay: |
2438 | ; cmp ecx,2 ; get mouse delay |
2447 | ; cmp ecx,2 ; get mouse delay |
2439 | dec ecx |
2448 | dec ecx |
2440 | jnz .set_mouse_delay |
2449 | jnz .set_mouse_delay |
2441 | mov eax, [mouse_delay] |
2450 | mov eax, [mouse_delay] |
2442 | mov [esp+32], eax |
2451 | mov [esp+32], eax |
2443 | ret |
2452 | ret |
2444 | .set_mouse_delay: |
2453 | .set_mouse_delay: |
2445 | ; cmp ecx,3 ; set mouse delay |
2454 | ; cmp ecx,3 ; set mouse delay |
2446 | dec ecx |
2455 | dec ecx |
2447 | jnz .set_pointer_position |
2456 | jnz .set_pointer_position |
2448 | mov [mouse_delay], edx |
2457 | mov [mouse_delay], edx |
2449 | ret |
2458 | ret |
2450 | .set_pointer_position: |
2459 | .set_pointer_position: |
2451 | ; cmp ecx,4 ; set mouse pointer position |
2460 | ; cmp ecx,4 ; set mouse pointer position |
2452 | dec ecx |
2461 | dec ecx |
2453 | jnz .set_mouse_button |
2462 | jnz .set_mouse_button |
2454 | cmp dx, word[_display.height] |
2463 | cmp dx, word[_display.height] |
2455 | jae .end |
2464 | jae .end |
2456 | rol edx, 16 |
2465 | rol edx, 16 |
2457 | cmp dx, word[_display.width] |
2466 | cmp dx, word[_display.width] |
2458 | jae .end |
2467 | jae .end |
2459 | mov [MOUSE_X], edx |
2468 | mov [MOUSE_X], edx |
2460 | mov [mouse_active], 1 |
2469 | mov [mouse_active], 1 |
2461 | call wakeup_osloop |
2470 | call wakeup_osloop |
2462 | ret |
2471 | ret |
2463 | .set_mouse_button: |
2472 | .set_mouse_button: |
2464 | ; cmp ecx,5 ; set mouse button features |
2473 | ; cmp ecx,5 ; set mouse button features |
2465 | dec ecx |
2474 | dec ecx |
2466 | jnz .end |
2475 | jnz .end |
2467 | mov [BTN_DOWN], dl |
2476 | mov [BTN_DOWN], dl |
2468 | mov [mouse_active], 1 |
2477 | mov [mouse_active], 1 |
2469 | call wakeup_osloop |
2478 | call wakeup_osloop |
2470 | .end: |
2479 | .end: |
2471 | ret |
2480 | ret |
2472 | ;------------------------------------------------------------------------------ |
2481 | ;------------------------------------------------------------------------------ |
2473 | sysfn_getfreemem: |
2482 | sysfn_getfreemem: |
2474 | mov eax, [pg_data.pages_free] |
2483 | mov eax, [pg_data.pages_free] |
2475 | shl eax, 2 |
2484 | shl eax, 2 |
2476 | mov [esp+32], eax |
2485 | mov [esp+32], eax |
2477 | ret |
2486 | ret |
2478 | ;------------------------------------------------------------------------------ |
2487 | ;------------------------------------------------------------------------------ |
2479 | sysfn_getallmem: |
2488 | sysfn_getallmem: |
2480 | mov eax, [MEM_AMOUNT] |
2489 | mov eax, [MEM_AMOUNT] |
2481 | shr eax, 10 |
2490 | shr eax, 10 |
2482 | mov [esp+32], eax |
2491 | mov [esp+32], eax |
2483 | ret |
2492 | ret |
2484 | ;------------------------------------------------------------------------------ |
2493 | ;------------------------------------------------------------------------------ |
2485 | sysfn_pid_to_slot: |
2494 | sysfn_pid_to_slot: |
2486 | mov eax, ecx |
2495 | mov eax, ecx |
2487 | call pid_to_slot |
2496 | call pid_to_slot |
2488 | mov [esp+32], eax |
2497 | mov [esp+32], eax |
2489 | ret |
2498 | ret |
2490 | ;------------------------------------------------------------------------------ |
2499 | ;------------------------------------------------------------------------------ |
2491 | sysfn_min_rest_window: |
2500 | sysfn_min_rest_window: |
2492 | pushad |
2501 | pushad |
2493 | mov eax, edx ; ebx - operating |
2502 | mov eax, edx ; ebx - operating |
2494 | shr ecx, 1 |
2503 | shr ecx, 1 |
2495 | jnc @f |
2504 | jnc @f |
2496 | call pid_to_slot |
2505 | call pid_to_slot |
2497 | @@: |
2506 | @@: |
2498 | or eax, eax ; eax - number of slot |
2507 | or eax, eax ; eax - number of slot |
2499 | jz .error |
2508 | jz .error |
2500 | cmp eax, 255 ; varify maximal slot number |
2509 | cmp eax, 255 ; varify maximal slot number |
2501 | ja .error |
2510 | ja .error |
2502 | movzx eax, word [WIN_STACK + eax*2] |
2511 | movzx eax, word [WIN_STACK + eax*2] |
2503 | shr ecx, 1 |
2512 | shr ecx, 1 |
2504 | jc .restore |
2513 | jc .restore |
2505 | ; .minimize: |
2514 | ; .minimize: |
2506 | call minimize_window |
2515 | call minimize_window |
2507 | jmp .exit |
2516 | jmp .exit |
2508 | .restore: |
2517 | .restore: |
2509 | call restore_minimized_window |
2518 | call restore_minimized_window |
2510 | .exit: |
2519 | .exit: |
2511 | popad |
2520 | popad |
2512 | xor eax, eax |
2521 | xor eax, eax |
2513 | mov [esp+32], eax |
2522 | mov [esp+32], eax |
2514 | ret |
2523 | ret |
2515 | .error: |
2524 | .error: |
2516 | popad |
2525 | popad |
2517 | xor eax, eax |
2526 | xor eax, eax |
2518 | dec eax |
2527 | dec eax |
2519 | mov [esp+32], eax |
2528 | mov [esp+32], eax |
2520 | ret |
2529 | ret |
2521 | ;------------------------------------------------------------------------------ |
2530 | ;------------------------------------------------------------------------------ |
2522 | sysfn_min_windows: |
2531 | sysfn_min_windows: |
2523 | call minimize_all_window |
2532 | call minimize_all_window |
2524 | mov [esp+32], eax |
2533 | mov [esp+32], eax |
2525 | call change_task |
2534 | call change_task |
2526 | ret |
2535 | ret |
2527 | ;------------------------------------------------------------------------------ |
2536 | ;------------------------------------------------------------------------------ |
2528 | sysfn_set_screen_sizes: |
2537 | sysfn_set_screen_sizes: |
2529 | cmp [SCR_MODE], word 0x13 |
2538 | cmp [SCR_MODE], word 0x13 |
2530 | jbe .exit |
2539 | jbe .exit |
2531 | 2540 | ||
2532 | cmp [_display.select_cursor], select_cursor |
2541 | cmp [_display.select_cursor], select_cursor |
2533 | jne .exit |
2542 | jne .exit |
2534 | 2543 | ||
2535 | cmp ecx, [display_width_standard] |
2544 | cmp ecx, [display_width_standard] |
2536 | ja .exit |
2545 | ja .exit |
2537 | 2546 | ||
2538 | cmp edx, [display_height_standard] |
2547 | cmp edx, [display_height_standard] |
2539 | ja .exit |
2548 | ja .exit |
2540 | 2549 | ||
2541 | pushfd |
2550 | pushfd |
2542 | cli |
2551 | cli |
2543 | mov eax, ecx |
2552 | mov eax, ecx |
2544 | mov ecx, [_display.lfb_pitch] |
2553 | mov ecx, [_display.lfb_pitch] |
2545 | mov [_display.width], eax |
2554 | mov [_display.width], eax |
2546 | dec eax |
2555 | dec eax |
2547 | mov [_display.height], edx |
2556 | mov [_display.height], edx |
2548 | dec edx |
2557 | dec edx |
2549 | ; eax - new Screen_Max_X |
2558 | ; eax - new Screen_Max_X |
2550 | ; edx - new Screen_Max_Y |
2559 | ; edx - new Screen_Max_Y |
2551 | mov [do_not_touch_winmap], 1 |
2560 | mov [do_not_touch_winmap], 1 |
2552 | call set_screen |
2561 | call set_screen |
2553 | mov [do_not_touch_winmap], 0 |
2562 | mov [do_not_touch_winmap], 0 |
2554 | popfd |
2563 | popfd |
2555 | call change_task |
2564 | call change_task |
2556 | .exit: |
2565 | .exit: |
2557 | ret |
2566 | ret |
2558 | ;------------------------------------------------------------------------------ |
2567 | ;------------------------------------------------------------------------------ |
2559 | uglobal |
2568 | uglobal |
2560 | screen_workarea RECT |
2569 | screen_workarea RECT |
2561 | display_width_standard dd 0 |
2570 | display_width_standard dd 0 |
2562 | display_height_standard dd 0 |
2571 | display_height_standard dd 0 |
2563 | do_not_touch_winmap db 0 |
2572 | do_not_touch_winmap db 0 |
2564 | window_minimize db 0 |
2573 | window_minimize db 0 |
2565 | sound_flag db 0 |
2574 | sound_flag db 0 |
2566 | 2575 | ||
2567 | endg |
2576 | endg |
2568 | 2577 | ||
2569 | UID_NONE=0 |
2578 | UID_NONE=0 |
2570 | UID_MENUETOS=1 ;official |
2579 | UID_MENUETOS=1 ;official |
2571 | UID_KOLIBRI=2 ;russian |
2580 | UID_KOLIBRI=2 ;russian |
2572 | 2581 | ||
2573 | iglobal |
2582 | iglobal |
2574 | version_inf: |
2583 | version_inf: |
2575 | db 0,7,7,0 ; version 0.7.7.0 |
2584 | db 0,7,7,0 ; version 0.7.7.0 |
2576 | db 0 |
2585 | db 0 |
2577 | .rev dd __REV__ |
2586 | .rev dd __REV__ |
2578 | version_end: |
2587 | version_end: |
2579 | endg |
2588 | endg |
2580 | ;------------------------------------------------------------------------------ |
2589 | ;------------------------------------------------------------------------------ |
2581 | align 4 |
2590 | align 4 |
2582 | sys_cachetodiskette: |
2591 | sys_cachetodiskette: |
2583 | cmp ebx, 1 |
2592 | cmp ebx, 1 |
2584 | jb .no_floppy_save |
2593 | jb .no_floppy_save |
2585 | cmp ebx, 2 |
2594 | cmp ebx, 2 |
2586 | ja .no_floppy_save |
2595 | ja .no_floppy_save |
2587 | call save_image |
2596 | call save_image |
2588 | mov [esp + 32], eax |
2597 | mov [esp + 32], eax |
2589 | ret |
2598 | ret |
2590 | .no_floppy_save: |
2599 | .no_floppy_save: |
2591 | mov [esp + 32], dword 1 |
2600 | mov [esp + 32], dword 1 |
2592 | ret |
2601 | ret |
2593 | ;------------------------------------------------------------------------------ |
2602 | ;------------------------------------------------------------------------------ |
2594 | uglobal |
2603 | uglobal |
2595 | ; bgrchanged dd 0x0 |
2604 | ; bgrchanged dd 0x0 |
2596 | align 4 |
2605 | align 4 |
2597 | bgrlockpid dd 0 |
2606 | bgrlockpid dd 0 |
2598 | bgrlock db 0 |
2607 | bgrlock db 0 |
2599 | endg |
2608 | endg |
2600 | ;------------------------------------------------------------------------------ |
2609 | ;------------------------------------------------------------------------------ |
2601 | align 4 |
2610 | align 4 |
2602 | sys_background: |
2611 | sys_background: |
2603 | cmp ebx, 1 ; BACKGROUND SIZE |
2612 | cmp ebx, 1 ; BACKGROUND SIZE |
2604 | jnz nosb1 |
2613 | jnz nosb1 |
2605 | test ecx, ecx |
2614 | test ecx, ecx |
2606 | jz sbgrr |
2615 | jz sbgrr |
2607 | 2616 | ||
2608 | test edx, edx |
2617 | test edx, edx |
2609 | jz sbgrr |
2618 | jz sbgrr |
2610 | ;-------------------------------------- |
2619 | ;-------------------------------------- |
2611 | align 4 |
2620 | align 4 |
2612 | @@: |
2621 | @@: |
2613 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2622 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2614 | bts dword [bgrlock], 0 |
2623 | bts dword [bgrlock], 0 |
2615 | jnc @f |
2624 | jnc @f |
2616 | call change_task |
2625 | call change_task |
2617 | jmp @b |
2626 | jmp @b |
2618 | ;-------------------------------------- |
2627 | ;-------------------------------------- |
2619 | align 4 |
2628 | align 4 |
2620 | @@: |
2629 | @@: |
2621 | mov [BgrDataWidth], ecx |
2630 | mov [BgrDataWidth], ecx |
2622 | mov [BgrDataHeight], edx |
2631 | mov [BgrDataHeight], edx |
2623 | ; mov [bgrchanged],1 |
2632 | ; mov [bgrchanged],1 |
2624 | 2633 | ||
2625 | pushad |
2634 | pushad |
2626 | ; return memory for old background |
2635 | ; return memory for old background |
2627 | mov eax, [img_background] |
2636 | mov eax, [img_background] |
2628 | cmp eax, static_background_data |
2637 | cmp eax, static_background_data |
2629 | jz @f |
2638 | jz @f |
2630 | stdcall kernel_free, eax |
2639 | stdcall kernel_free, eax |
2631 | ;-------------------------------------- |
2640 | ;-------------------------------------- |
2632 | align 4 |
2641 | align 4 |
2633 | @@: |
2642 | @@: |
2634 | ; calculate RAW size |
2643 | ; calculate RAW size |
2635 | xor eax, eax |
2644 | xor eax, eax |
2636 | inc eax |
2645 | inc eax |
2637 | cmp [BgrDataWidth], eax |
2646 | cmp [BgrDataWidth], eax |
2638 | jae @f |
2647 | jae @f |
2639 | mov [BgrDataWidth], eax |
2648 | mov [BgrDataWidth], eax |
2640 | ;-------------------------------------- |
2649 | ;-------------------------------------- |
2641 | align 4 |
2650 | align 4 |
2642 | @@: |
2651 | @@: |
2643 | cmp [BgrDataHeight], eax |
2652 | cmp [BgrDataHeight], eax |
2644 | jae @f |
2653 | jae @f |
2645 | mov [BgrDataHeight], eax |
2654 | mov [BgrDataHeight], eax |
2646 | ;-------------------------------------- |
2655 | ;-------------------------------------- |
2647 | align 4 |
2656 | align 4 |
2648 | @@: |
2657 | @@: |
2649 | mov eax, [BgrDataWidth] |
2658 | mov eax, [BgrDataWidth] |
2650 | imul eax, [BgrDataHeight] |
2659 | imul eax, [BgrDataHeight] |
2651 | lea eax, [eax*3] |
2660 | lea eax, [eax*3] |
2652 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2661 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2653 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2662 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2654 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2663 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2655 | shr eax, 12 |
2664 | shr eax, 12 |
2656 | inc eax |
2665 | inc eax |
2657 | shl eax, 12 |
2666 | shl eax, 12 |
2658 | mov [mem_BACKGROUND], eax |
2667 | mov [mem_BACKGROUND], eax |
2659 | ; get memory for new background |
2668 | ; get memory for new background |
2660 | stdcall kernel_alloc, eax |
2669 | stdcall kernel_alloc, eax |
2661 | test eax, eax |
2670 | test eax, eax |
2662 | jz .memfailed |
2671 | jz .memfailed |
2663 | mov [img_background], eax |
2672 | mov [img_background], eax |
2664 | jmp .exit |
2673 | jmp .exit |
2665 | ;-------------------------------------- |
2674 | ;-------------------------------------- |
2666 | align 4 |
2675 | align 4 |
2667 | .memfailed: |
2676 | .memfailed: |
2668 | ; revert to static monotone data |
2677 | ; revert to static monotone data |
2669 | mov [img_background], static_background_data |
2678 | mov [img_background], static_background_data |
2670 | xor eax, eax |
2679 | xor eax, eax |
2671 | inc eax |
2680 | inc eax |
2672 | mov [BgrDataWidth], eax |
2681 | mov [BgrDataWidth], eax |
2673 | mov [BgrDataHeight], eax |
2682 | mov [BgrDataHeight], eax |
2674 | mov [mem_BACKGROUND], 4 |
2683 | mov [mem_BACKGROUND], 4 |
2675 | ;-------------------------------------- |
2684 | ;-------------------------------------- |
2676 | align 4 |
2685 | align 4 |
2677 | .exit: |
2686 | .exit: |
2678 | popad |
2687 | popad |
2679 | mov [bgrlock], 0 |
2688 | mov [bgrlock], 0 |
2680 | ;-------------------------------------- |
2689 | ;-------------------------------------- |
2681 | align 4 |
2690 | align 4 |
2682 | sbgrr: |
2691 | sbgrr: |
2683 | ret |
2692 | ret |
2684 | ;------------------------------------------------------------------------------ |
2693 | ;------------------------------------------------------------------------------ |
2685 | align 4 |
2694 | align 4 |
2686 | nosb1: |
2695 | nosb1: |
2687 | cmp ebx, 2 ; SET PIXEL |
2696 | cmp ebx, 2 ; SET PIXEL |
2688 | jnz nosb2 |
2697 | jnz nosb2 |
2689 | 2698 | ||
2690 | mov eax, [img_background] |
2699 | mov eax, [img_background] |
2691 | test ecx, ecx |
2700 | test ecx, ecx |
2692 | jz @f |
2701 | jz @f |
2693 | cmp eax, static_background_data |
2702 | cmp eax, static_background_data |
2694 | jz .ret |
2703 | jz .ret |
2695 | ;-------------------------------------- |
2704 | ;-------------------------------------- |
2696 | align 4 |
2705 | align 4 |
2697 | @@: |
2706 | @@: |
2698 | mov ebx, [mem_BACKGROUND] |
2707 | mov ebx, [mem_BACKGROUND] |
2699 | add ebx, 4095 |
2708 | add ebx, 4095 |
2700 | and ebx, -4096 |
2709 | and ebx, -4096 |
2701 | sub ebx, 4 |
2710 | sub ebx, 4 |
2702 | cmp ecx, ebx |
2711 | cmp ecx, ebx |
2703 | ja .ret |
2712 | ja .ret |
2704 | 2713 | ||
2705 | mov ebx, [eax+ecx] |
2714 | mov ebx, [eax+ecx] |
2706 | and ebx, 0xFF000000;255*256*256*256 |
2715 | and ebx, 0xFF000000;255*256*256*256 |
2707 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2716 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2708 | add edx, ebx |
2717 | add edx, ebx |
2709 | mov [eax+ecx], edx |
2718 | mov [eax+ecx], edx |
2710 | ;-------------------------------------- |
2719 | ;-------------------------------------- |
2711 | align 4 |
2720 | align 4 |
2712 | .ret: |
2721 | .ret: |
2713 | ret |
2722 | ret |
2714 | ;------------------------------------------------------------------------------ |
2723 | ;------------------------------------------------------------------------------ |
2715 | align 4 |
2724 | align 4 |
2716 | nosb2: |
2725 | nosb2: |
2717 | cmp ebx, 3 ; DRAW BACKGROUND |
2726 | cmp ebx, 3 ; DRAW BACKGROUND |
2718 | jnz nosb3 |
2727 | jnz nosb3 |
2719 | ;-------------------------------------- |
2728 | ;-------------------------------------- |
2720 | align 4 |
2729 | align 4 |
2721 | draw_background_temp: |
2730 | draw_background_temp: |
2722 | mov [background_defined], 1 |
2731 | mov [background_defined], 1 |
2723 | call force_redraw_background |
2732 | call force_redraw_background |
2724 | ;-------------------------------------- |
2733 | ;-------------------------------------- |
2725 | align 4 |
2734 | align 4 |
2726 | nosb31: |
2735 | nosb31: |
2727 | ret |
2736 | ret |
2728 | ;------------------------------------------------------------------------------ |
2737 | ;------------------------------------------------------------------------------ |
2729 | align 4 |
2738 | align 4 |
2730 | nosb3: |
2739 | nosb3: |
2731 | cmp ebx, 4 ; TILED / STRETCHED |
2740 | cmp ebx, 4 ; TILED / STRETCHED |
2732 | jnz nosb4 |
2741 | jnz nosb4 |
2733 | cmp ecx, [BgrDrawMode] |
2742 | cmp ecx, [BgrDrawMode] |
2734 | je nosb41 |
2743 | je nosb41 |
2735 | mov [BgrDrawMode], ecx |
2744 | mov [BgrDrawMode], ecx |
2736 | ;-------------------------------------- |
2745 | ;-------------------------------------- |
2737 | align 4 |
2746 | align 4 |
2738 | nosb41: |
2747 | nosb41: |
2739 | ret |
2748 | ret |
2740 | ;------------------------------------------------------------------------------ |
2749 | ;------------------------------------------------------------------------------ |
2741 | align 4 |
2750 | align 4 |
2742 | nosb4: |
2751 | nosb4: |
2743 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2752 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2744 | jnz nosb5 |
2753 | jnz nosb5 |
2745 | cmp [img_background], static_background_data |
2754 | cmp [img_background], static_background_data |
2746 | jnz @f |
2755 | jnz @f |
2747 | test edx, edx |
2756 | test edx, edx |
2748 | jnz .fin |
2757 | jnz .fin |
2749 | cmp esi, 4 |
2758 | cmp esi, 4 |
2750 | ja .fin |
2759 | ja .fin |
2751 | ;-------------------------------------- |
2760 | ;-------------------------------------- |
2752 | align 4 |
2761 | align 4 |
2753 | @@: |
2762 | @@: |
2754 | ; bughere |
2763 | ; bughere |
2755 | mov eax, ecx |
2764 | mov eax, ecx |
2756 | mov ebx, edx |
2765 | mov ebx, edx |
2757 | add ebx, [img_background];IMG_BACKGROUND |
2766 | add ebx, [img_background];IMG_BACKGROUND |
2758 | mov ecx, esi |
2767 | mov ecx, esi |
2759 | call memmove |
2768 | call memmove |
2760 | ;-------------------------------------- |
2769 | ;-------------------------------------- |
2761 | align 4 |
2770 | align 4 |
2762 | .fin: |
2771 | .fin: |
2763 | ret |
2772 | ret |
2764 | ;------------------------------------------------------------------------------ |
2773 | ;------------------------------------------------------------------------------ |
2765 | align 4 |
2774 | align 4 |
2766 | nosb5: |
2775 | nosb5: |
2767 | cmp ebx, 6 |
2776 | cmp ebx, 6 |
2768 | jnz nosb6 |
2777 | jnz nosb6 |
2769 | ;-------------------------------------- |
2778 | ;-------------------------------------- |
2770 | align 4 |
2779 | align 4 |
2771 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2780 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2772 | @@: |
2781 | @@: |
2773 | bts dword [bgrlock], 0 |
2782 | bts dword [bgrlock], 0 |
2774 | jnc @f |
2783 | jnc @f |
2775 | call change_task |
2784 | call change_task |
2776 | jmp @b |
2785 | jmp @b |
2777 | ;-------------------------------------- |
2786 | ;-------------------------------------- |
2778 | align 4 |
2787 | align 4 |
2779 | @@: |
2788 | @@: |
2780 | mov eax, [CURRENT_TASK] |
2789 | mov eax, [CURRENT_TASK] |
2781 | mov [bgrlockpid], eax |
2790 | mov [bgrlockpid], eax |
2782 | cmp [img_background], static_background_data |
2791 | cmp [img_background], static_background_data |
2783 | jz .nomem |
2792 | jz .nomem |
2784 | stdcall user_alloc, [mem_BACKGROUND] |
2793 | stdcall user_alloc, [mem_BACKGROUND] |
2785 | mov [esp+32], eax |
2794 | mov [esp+32], eax |
2786 | test eax, eax |
2795 | test eax, eax |
2787 | jz .nomem |
2796 | jz .nomem |
2788 | mov ebx, eax |
2797 | mov ebx, eax |
2789 | shr ebx, 12 |
2798 | shr ebx, 12 |
2790 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2799 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2791 | mov esi, [img_background] |
2800 | mov esi, [img_background] |
2792 | shr esi, 12 |
2801 | shr esi, 12 |
2793 | mov ecx, [mem_BACKGROUND] |
2802 | mov ecx, [mem_BACKGROUND] |
2794 | add ecx, 0xFFF |
2803 | add ecx, 0xFFF |
2795 | shr ecx, 12 |
2804 | shr ecx, 12 |
2796 | ;-------------------------------------- |
2805 | ;-------------------------------------- |
2797 | align 4 |
2806 | align 4 |
2798 | .z: |
2807 | .z: |
2799 | mov eax, [page_tabs+ebx*4] |
2808 | mov eax, [page_tabs+ebx*4] |
2800 | test al, 1 |
2809 | test al, 1 |
2801 | jz @f |
2810 | jz @f |
2802 | call free_page |
2811 | call free_page |
2803 | ;-------------------------------------- |
2812 | ;-------------------------------------- |
2804 | align 4 |
2813 | align 4 |
2805 | @@: |
2814 | @@: |
2806 | mov eax, [page_tabs+esi*4] |
2815 | mov eax, [page_tabs+esi*4] |
2807 | or al, PG_UWR |
2816 | or al, PG_UWR |
2808 | mov [page_tabs+ebx*4], eax |
2817 | mov [page_tabs+ebx*4], eax |
2809 | mov eax, ebx |
2818 | mov eax, ebx |
2810 | shl eax, 12 |
2819 | shl eax, 12 |
2811 | invlpg [eax] |
2820 | invlpg [eax] |
2812 | inc ebx |
2821 | inc ebx |
2813 | inc esi |
2822 | inc esi |
2814 | loop .z |
2823 | loop .z |
2815 | ret |
2824 | ret |
2816 | ;-------------------------------------- |
2825 | ;-------------------------------------- |
2817 | align 4 |
2826 | align 4 |
2818 | .nomem: |
2827 | .nomem: |
2819 | and [bgrlockpid], 0 |
2828 | and [bgrlockpid], 0 |
2820 | mov [bgrlock], 0 |
2829 | mov [bgrlock], 0 |
2821 | ;------------------------------------------------------------------------------ |
2830 | ;------------------------------------------------------------------------------ |
2822 | align 4 |
2831 | align 4 |
2823 | nosb6: |
2832 | nosb6: |
2824 | cmp ebx, 7 |
2833 | cmp ebx, 7 |
2825 | jnz nosb7 |
2834 | jnz nosb7 |
2826 | cmp [bgrlock], 0 |
2835 | cmp [bgrlock], 0 |
2827 | jz .err |
2836 | jz .err |
2828 | mov eax, [CURRENT_TASK] |
2837 | mov eax, [CURRENT_TASK] |
2829 | cmp [bgrlockpid], eax |
2838 | cmp [bgrlockpid], eax |
2830 | jnz .err |
2839 | jnz .err |
2831 | mov eax, ecx |
2840 | mov eax, ecx |
2832 | mov ebx, ecx |
2841 | mov ebx, ecx |
2833 | shr eax, 12 |
2842 | shr eax, 12 |
2834 | mov ecx, [page_tabs+(eax-1)*4] |
2843 | mov ecx, [page_tabs+(eax-1)*4] |
2835 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2844 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2836 | jz .err |
2845 | jz .err |
2837 | jnp .err |
2846 | jnp .err |
2838 | push eax |
2847 | push eax |
2839 | shr ecx, 12 |
2848 | shr ecx, 12 |
2840 | dec ecx |
2849 | dec ecx |
2841 | ;-------------------------------------- |
2850 | ;-------------------------------------- |
2842 | align 4 |
2851 | align 4 |
2843 | @@: |
2852 | @@: |
2844 | and dword [page_tabs+eax*4], 0 |
2853 | and dword [page_tabs+eax*4], 0 |
2845 | mov edx, eax |
2854 | mov edx, eax |
2846 | shl edx, 12 |
2855 | shl edx, 12 |
2847 | push eax |
2856 | push eax |
2848 | invlpg [edx] |
2857 | invlpg [edx] |
2849 | pop eax |
2858 | pop eax |
2850 | inc eax |
2859 | inc eax |
2851 | loop @b |
2860 | loop @b |
2852 | pop eax |
2861 | pop eax |
2853 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2862 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2854 | stdcall user_free, ebx |
2863 | stdcall user_free, ebx |
2855 | mov [esp+32], eax |
2864 | mov [esp+32], eax |
2856 | and [bgrlockpid], 0 |
2865 | and [bgrlockpid], 0 |
2857 | mov [bgrlock], 0 |
2866 | mov [bgrlock], 0 |
2858 | ret |
2867 | ret |
2859 | ;-------------------------------------- |
2868 | ;-------------------------------------- |
2860 | align 4 |
2869 | align 4 |
2861 | .err: |
2870 | .err: |
2862 | and dword [esp+32], 0 |
2871 | and dword [esp+32], 0 |
2863 | ret |
2872 | ret |
2864 | ;------------------------------------------------------------------------------ |
2873 | ;------------------------------------------------------------------------------ |
2865 | align 4 |
2874 | align 4 |
2866 | nosb7: |
2875 | nosb7: |
2867 | cmp ebx, 8 |
2876 | cmp ebx, 8 |
2868 | jnz nosb8 |
2877 | jnz nosb8 |
2869 | 2878 | ||
2870 | mov ecx, [current_slot] |
2879 | mov ecx, [current_slot] |
2871 | xor eax, eax |
2880 | xor eax, eax |
2872 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2881 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2873 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2882 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2874 | xor eax, eax |
2883 | xor eax, eax |
2875 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2884 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2876 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2885 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2877 | ret |
2886 | ret |
2878 | ;------------------------------------------------------------------------------ |
2887 | ;------------------------------------------------------------------------------ |
2879 | align 4 |
2888 | align 4 |
2880 | nosb8: |
2889 | nosb8: |
2881 | cmp ebx, 9 |
2890 | cmp ebx, 9 |
2882 | jnz nosb9 |
2891 | jnz nosb9 |
2883 | ; ecx = [left]*65536 + [right] |
2892 | ; ecx = [left]*65536 + [right] |
2884 | ; edx = [top]*65536 + [bottom] |
2893 | ; edx = [top]*65536 + [bottom] |
2885 | mov eax, [_display.width] |
2894 | mov eax, [_display.width] |
2886 | mov ebx, [_display.height] |
2895 | mov ebx, [_display.height] |
2887 | dec eax |
2896 | dec eax |
2888 | dec ebx |
2897 | dec ebx |
2889 | ; check [right] |
2898 | ; check [right] |
2890 | cmp cx, ax |
2899 | cmp cx, ax |
2891 | ja .exit |
2900 | ja .exit |
2892 | ; check [left] |
2901 | ; check [left] |
2893 | ror ecx, 16 |
2902 | ror ecx, 16 |
2894 | cmp cx, ax |
2903 | cmp cx, ax |
2895 | ja .exit |
2904 | ja .exit |
2896 | ; check [bottom] |
2905 | ; check [bottom] |
2897 | cmp dx, bx |
2906 | cmp dx, bx |
2898 | ja .exit |
2907 | ja .exit |
2899 | ; check [top] |
2908 | ; check [top] |
2900 | ror edx, 16 |
2909 | ror edx, 16 |
2901 | cmp dx, bx |
2910 | cmp dx, bx |
2902 | ja .exit |
2911 | ja .exit |
2903 | 2912 | ||
2904 | movzx eax, cx ; [left] |
2913 | movzx eax, cx ; [left] |
2905 | movzx ebx, dx ; [top] |
2914 | movzx ebx, dx ; [top] |
2906 | 2915 | ||
2907 | shr ecx, 16 ; [right] |
2916 | shr ecx, 16 ; [right] |
2908 | shr edx, 16 ; [bottom] |
2917 | shr edx, 16 ; [bottom] |
2909 | 2918 | ||
2910 | mov [background_defined], 1 |
2919 | mov [background_defined], 1 |
2911 | 2920 | ||
2912 | mov [draw_data+32 + RECT.left], eax |
2921 | mov [draw_data+32 + RECT.left], eax |
2913 | mov [draw_data+32 + RECT.top], ebx |
2922 | mov [draw_data+32 + RECT.top], ebx |
2914 | 2923 | ||
2915 | mov [draw_data+32 + RECT.right], ecx |
2924 | mov [draw_data+32 + RECT.right], ecx |
2916 | mov [draw_data+32 + RECT.bottom], edx |
2925 | mov [draw_data+32 + RECT.bottom], edx |
2917 | 2926 | ||
2918 | inc byte[REDRAW_BACKGROUND] |
2927 | inc byte[REDRAW_BACKGROUND] |
2919 | call wakeup_osloop |
2928 | call wakeup_osloop |
2920 | ;-------------------------------------- |
2929 | ;-------------------------------------- |
2921 | align 4 |
2930 | align 4 |
2922 | .exit: |
2931 | .exit: |
2923 | ret |
2932 | ret |
2924 | ;------------------------------------------------------------------------------ |
2933 | ;------------------------------------------------------------------------------ |
2925 | align 4 |
2934 | align 4 |
2926 | nosb9: |
2935 | nosb9: |
2927 | ret |
2936 | ret |
2928 | ;------------------------------------------------------------------------------ |
2937 | ;------------------------------------------------------------------------------ |
2929 | align 4 |
2938 | align 4 |
2930 | uglobal |
2939 | uglobal |
2931 | BG_Rect_X_left_right dd 0x0 |
2940 | BG_Rect_X_left_right dd 0x0 |
2932 | BG_Rect_Y_top_bottom dd 0x0 |
2941 | BG_Rect_Y_top_bottom dd 0x0 |
2933 | endg |
2942 | endg |
2934 | ;------------------------------------------------------------------------------ |
2943 | ;------------------------------------------------------------------------------ |
2935 | align 4 |
2944 | align 4 |
2936 | force_redraw_background: |
2945 | force_redraw_background: |
2937 | and [draw_data+32 + RECT.left], 0 |
2946 | and [draw_data+32 + RECT.left], 0 |
2938 | and [draw_data+32 + RECT.top], 0 |
2947 | and [draw_data+32 + RECT.top], 0 |
2939 | push eax ebx |
2948 | push eax ebx |
2940 | mov eax, [_display.width] |
2949 | mov eax, [_display.width] |
2941 | mov ebx, [_display.height] |
2950 | mov ebx, [_display.height] |
2942 | dec eax |
2951 | dec eax |
2943 | dec ebx |
2952 | dec ebx |
2944 | mov [draw_data+32 + RECT.right], eax |
2953 | mov [draw_data+32 + RECT.right], eax |
2945 | mov [draw_data+32 + RECT.bottom], ebx |
2954 | mov [draw_data+32 + RECT.bottom], ebx |
2946 | pop ebx eax |
2955 | pop ebx eax |
2947 | inc byte[REDRAW_BACKGROUND] |
2956 | inc byte[REDRAW_BACKGROUND] |
2948 | call wakeup_osloop |
2957 | call wakeup_osloop |
2949 | ret |
2958 | ret |
2950 | ;------------------------------------------------------------------------------ |
2959 | ;------------------------------------------------------------------------------ |
2951 | align 4 |
2960 | align 4 |
2952 | sys_getbackground: |
2961 | sys_getbackground: |
2953 | ; cmp eax,1 ; SIZE |
2962 | ; cmp eax,1 ; SIZE |
2954 | dec ebx |
2963 | dec ebx |
2955 | jnz nogb1 |
2964 | jnz nogb1 |
2956 | mov eax, [BgrDataWidth] |
2965 | mov eax, [BgrDataWidth] |
2957 | shl eax, 16 |
2966 | shl eax, 16 |
2958 | mov ax, word [BgrDataHeight] |
2967 | mov ax, word [BgrDataHeight] |
2959 | mov [esp+32], eax |
2968 | mov [esp+32], eax |
2960 | ret |
2969 | ret |
2961 | ;------------------------------------------------------------------------------ |
2970 | ;------------------------------------------------------------------------------ |
2962 | align 4 |
2971 | align 4 |
2963 | nogb1: |
2972 | nogb1: |
2964 | ; cmp eax,2 ; PIXEL |
2973 | ; cmp eax,2 ; PIXEL |
2965 | dec ebx |
2974 | dec ebx |
2966 | jnz nogb2 |
2975 | jnz nogb2 |
2967 | 2976 | ||
2968 | mov eax, [img_background] |
2977 | mov eax, [img_background] |
2969 | test ecx, ecx |
2978 | test ecx, ecx |
2970 | jz @f |
2979 | jz @f |
2971 | cmp eax, static_background_data |
2980 | cmp eax, static_background_data |
2972 | jz .ret |
2981 | jz .ret |
2973 | ;-------------------------------------- |
2982 | ;-------------------------------------- |
2974 | align 4 |
2983 | align 4 |
2975 | @@: |
2984 | @@: |
2976 | mov ebx, [mem_BACKGROUND] |
2985 | mov ebx, [mem_BACKGROUND] |
2977 | add ebx, 4095 |
2986 | add ebx, 4095 |
2978 | and ebx, -4096 |
2987 | and ebx, -4096 |
2979 | sub ebx, 4 |
2988 | sub ebx, 4 |
2980 | cmp ecx, ebx |
2989 | cmp ecx, ebx |
2981 | ja .ret |
2990 | ja .ret |
2982 | 2991 | ||
2983 | mov eax, [ecx+eax] |
2992 | mov eax, [ecx+eax] |
2984 | 2993 | ||
2985 | and eax, 0xFFFFFF |
2994 | and eax, 0xFFFFFF |
2986 | mov [esp+32], eax |
2995 | mov [esp+32], eax |
2987 | ;-------------------------------------- |
2996 | ;-------------------------------------- |
2988 | align 4 |
2997 | align 4 |
2989 | .ret: |
2998 | .ret: |
2990 | ret |
2999 | ret |
2991 | ;------------------------------------------------------------------------------ |
3000 | ;------------------------------------------------------------------------------ |
2992 | align 4 |
3001 | align 4 |
2993 | nogb2: |
3002 | nogb2: |
2994 | 3003 | ||
2995 | ; cmp eax,4 ; TILED / STRETCHED |
3004 | ; cmp eax,4 ; TILED / STRETCHED |
2996 | dec ebx |
3005 | dec ebx |
2997 | dec ebx |
3006 | dec ebx |
2998 | jnz nogb4 |
3007 | jnz nogb4 |
2999 | mov eax, [BgrDrawMode] |
3008 | mov eax, [BgrDrawMode] |
3000 | ;-------------------------------------- |
3009 | ;-------------------------------------- |
3001 | align 4 |
3010 | align 4 |
3002 | nogb4: |
3011 | nogb4: |
3003 | mov [esp+32], eax |
3012 | mov [esp+32], eax |
3004 | ret |
3013 | ret |
3005 | ;------------------------------------------------------------------------------ |
3014 | ;------------------------------------------------------------------------------ |
3006 | align 4 |
3015 | align 4 |
3007 | sys_getkey: |
3016 | sys_getkey: |
3008 | mov [esp + 32], dword 1 |
3017 | mov [esp + 32], dword 1 |
3009 | ; test main buffer |
3018 | ; test main buffer |
3010 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3019 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3011 | movzx ecx, word [WIN_STACK + ebx * 2] |
3020 | movzx ecx, word [WIN_STACK + ebx * 2] |
3012 | mov edx, [TASK_COUNT] |
3021 | mov edx, [TASK_COUNT] |
3013 | cmp ecx, edx |
3022 | cmp ecx, edx |
3014 | jne .finish |
3023 | jne .finish |
3015 | cmp [KEY_COUNT], byte 0 |
3024 | cmp [KEY_COUNT], byte 0 |
3016 | je .finish |
3025 | je .finish |
3017 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3026 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3018 | shl eax, 8 |
3027 | shl eax, 8 |
3019 | mov al, byte [KEY_BUFF] |
3028 | mov al, byte [KEY_BUFF] |
3020 | shl eax, 8 |
3029 | shl eax, 8 |
3021 | push eax |
3030 | push eax |
3022 | dec byte [KEY_COUNT] |
3031 | dec byte [KEY_COUNT] |
3023 | and byte [KEY_COUNT], 127 |
3032 | and byte [KEY_COUNT], 127 |
3024 | movzx ecx, byte [KEY_COUNT] |
3033 | movzx ecx, byte [KEY_COUNT] |
3025 | add ecx, 2 |
3034 | add ecx, 2 |
3026 | mov eax, KEY_BUFF + 1 |
3035 | mov eax, KEY_BUFF + 1 |
3027 | mov ebx, KEY_BUFF |
3036 | mov ebx, KEY_BUFF |
3028 | call memmove |
3037 | call memmove |
3029 | add eax, 120 + 2 |
3038 | add eax, 120 + 2 |
3030 | add ebx, 120 + 2 |
3039 | add ebx, 120 + 2 |
3031 | call memmove |
3040 | call memmove |
3032 | pop eax |
3041 | pop eax |
3033 | ;-------------------------------------- |
3042 | ;-------------------------------------- |
3034 | align 4 |
3043 | align 4 |
3035 | .ret_eax: |
3044 | .ret_eax: |
3036 | mov [esp + 32], eax |
3045 | mov [esp + 32], eax |
3037 | ret |
3046 | ret |
3038 | ;-------------------------------------- |
3047 | ;-------------------------------------- |
3039 | align 4 |
3048 | align 4 |
3040 | .finish: |
3049 | .finish: |
3041 | ; test hotkeys buffer |
3050 | ; test hotkeys buffer |
3042 | mov ecx, hotkey_buffer |
3051 | mov ecx, hotkey_buffer |
3043 | ;-------------------------------------- |
3052 | ;-------------------------------------- |
3044 | align 4 |
3053 | align 4 |
3045 | @@: |
3054 | @@: |
3046 | cmp [ecx], ebx |
3055 | cmp [ecx], ebx |
3047 | jz .found |
3056 | jz .found |
3048 | add ecx, 8 |
3057 | add ecx, 8 |
3049 | cmp ecx, hotkey_buffer + 120 * 8 |
3058 | cmp ecx, hotkey_buffer + 120 * 8 |
3050 | jb @b |
3059 | jb @b |
3051 | ret |
3060 | ret |
3052 | ;-------------------------------------- |
3061 | ;-------------------------------------- |
3053 | align 4 |
3062 | align 4 |
3054 | .found: |
3063 | .found: |
3055 | mov ax, [ecx + 6] |
3064 | mov ax, [ecx + 6] |
3056 | shl eax, 16 |
3065 | shl eax, 16 |
3057 | mov ah, [ecx + 4] |
3066 | mov ah, [ecx + 4] |
3058 | mov al, 2 |
3067 | mov al, 2 |
3059 | and dword [ecx + 4], 0 |
3068 | and dword [ecx + 4], 0 |
3060 | and dword [ecx], 0 |
3069 | and dword [ecx], 0 |
3061 | jmp .ret_eax |
3070 | jmp .ret_eax |
3062 | ;------------------------------------------------------------------------------ |
3071 | ;------------------------------------------------------------------------------ |
3063 | align 4 |
3072 | align 4 |
3064 | sys_getbutton: |
3073 | sys_getbutton: |
3065 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3074 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3066 | mov [esp + 32], dword 1 |
3075 | mov [esp + 32], dword 1 |
3067 | movzx ecx, word [WIN_STACK + ebx * 2] |
3076 | movzx ecx, word [WIN_STACK + ebx * 2] |
3068 | mov edx, [TASK_COUNT] ; less than 256 processes |
3077 | mov edx, [TASK_COUNT] ; less than 256 processes |
3069 | cmp ecx, edx |
3078 | cmp ecx, edx |
3070 | jne .exit |
3079 | jne .exit |
3071 | movzx eax, byte [BTN_COUNT] |
3080 | movzx eax, byte [BTN_COUNT] |
3072 | test eax, eax |
3081 | test eax, eax |
3073 | jz .exit |
3082 | jz .exit |
3074 | mov eax, [BTN_BUFF] |
3083 | mov eax, [BTN_BUFF] |
3075 | and al, 0xFE ; delete left button bit |
3084 | and al, 0xFE ; delete left button bit |
3076 | mov [BTN_COUNT], byte 0 |
3085 | mov [BTN_COUNT], byte 0 |
3077 | mov [esp + 32], eax |
3086 | mov [esp + 32], eax |
3078 | ;-------------------------------------- |
3087 | ;-------------------------------------- |
3079 | align 4 |
3088 | align 4 |
3080 | .exit: |
3089 | .exit: |
3081 | ret |
3090 | ret |
3082 | ;------------------------------------------------------------------------------ |
3091 | ;------------------------------------------------------------------------------ |
3083 | align 4 |
3092 | align 4 |
3084 | sys_cpuusage: |
3093 | sys_cpuusage: |
3085 | 3094 | ||
3086 | ; RETURN: |
3095 | ; RETURN: |
3087 | ; |
3096 | ; |
3088 | ; +00 dword process cpu usage |
3097 | ; +00 dword process cpu usage |
3089 | ; +04 word position in windowing stack |
3098 | ; +04 word position in windowing stack |
3090 | ; +06 word windowing stack value at current position (cpu nro) |
3099 | ; +06 word windowing stack value at current position (cpu nro) |
3091 | ; +10 12 bytes name |
3100 | ; +10 12 bytes name |
3092 | ; +22 dword start in mem |
3101 | ; +22 dword start in mem |
3093 | ; +26 dword used mem |
3102 | ; +26 dword used mem |
3094 | ; +30 dword PID , process idenfification number |
3103 | ; +30 dword PID , process idenfification number |
3095 | ; |
3104 | ; |
3096 | 3105 | ||
3097 | cmp ecx, -1 ; who am I ? |
3106 | cmp ecx, -1 ; who am I ? |
3098 | jne .no_who_am_i |
3107 | jne .no_who_am_i |
3099 | mov ecx, [CURRENT_TASK] |
3108 | mov ecx, [CURRENT_TASK] |
3100 | .no_who_am_i: |
3109 | .no_who_am_i: |
3101 | cmp ecx, max_processes |
3110 | cmp ecx, max_processes |
3102 | ja .nofillbuf |
3111 | ja .nofillbuf |
3103 | 3112 | ||
3104 | ; +4: word: position of the window of thread in the window stack |
3113 | ; +4: word: position of the window of thread in the window stack |
3105 | mov ax, [WIN_STACK + ecx * 2] |
3114 | mov ax, [WIN_STACK + ecx * 2] |
3106 | mov [ebx+4], ax |
3115 | mov [ebx+4], ax |
3107 | ; +6: word: number of the thread slot, which window has in the window stack |
3116 | ; +6: word: number of the thread slot, which window has in the window stack |
3108 | ; position ecx (has no relation to the specific thread) |
3117 | ; position ecx (has no relation to the specific thread) |
3109 | mov ax, [WIN_POS + ecx * 2] |
3118 | mov ax, [WIN_POS + ecx * 2] |
3110 | mov [ebx+6], ax |
3119 | mov [ebx+6], ax |
3111 | 3120 | ||
3112 | shl ecx, 5 |
3121 | shl ecx, 5 |
3113 | 3122 | ||
3114 | ; +0: dword: memory usage |
3123 | ; +0: dword: memory usage |
3115 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3124 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3116 | mov [ebx], eax |
3125 | mov [ebx], eax |
3117 | ; +10: 11 bytes: name of the process |
3126 | ; +10: 11 bytes: name of the process |
3118 | push ecx |
3127 | push ecx |
3119 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3128 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3120 | add ebx, 10 |
3129 | add ebx, 10 |
3121 | mov ecx, 11 |
3130 | mov ecx, 11 |
3122 | call memmove |
3131 | call memmove |
3123 | pop ecx |
3132 | pop ecx |
3124 | 3133 | ||
3125 | ; +22: address of the process in memory |
3134 | ; +22: address of the process in memory |
3126 | ; +26: size of used memory - 1 |
3135 | ; +26: size of used memory - 1 |
3127 | push edi |
3136 | push edi |
3128 | lea edi, [ebx+12] |
3137 | lea edi, [ebx+12] |
3129 | xor eax, eax |
3138 | xor eax, eax |
3130 | mov edx, 0x100000*16 |
3139 | mov edx, 0x100000*16 |
3131 | cmp ecx, 1 shl 5 |
3140 | cmp ecx, 1 shl 5 |
3132 | je .os_mem |
3141 | je .os_mem |
3133 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3142 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3134 | mov edx, [edx+PROC.mem_used] |
3143 | mov edx, [edx+PROC.mem_used] |
3135 | mov eax, std_application_base_address |
3144 | mov eax, std_application_base_address |
3136 | .os_mem: |
3145 | .os_mem: |
3137 | stosd |
3146 | stosd |
3138 | lea eax, [edx-1] |
3147 | lea eax, [edx-1] |
3139 | stosd |
3148 | stosd |
3140 | 3149 | ||
3141 | ; +30: PID/TID |
3150 | ; +30: PID/TID |
3142 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3151 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3143 | stosd |
3152 | stosd |
3144 | 3153 | ||
3145 | ; window position and size |
3154 | ; window position and size |
3146 | push esi |
3155 | push esi |
3147 | lea esi, [ecx + window_data + WDATA.box] |
3156 | lea esi, [ecx + window_data + WDATA.box] |
3148 | movsd |
3157 | movsd |
3149 | movsd |
3158 | movsd |
3150 | movsd |
3159 | movsd |
3151 | movsd |
3160 | movsd |
3152 | 3161 | ||
3153 | ; Process state (+50) |
3162 | ; Process state (+50) |
3154 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3163 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3155 | stosd |
3164 | stosd |
3156 | 3165 | ||
3157 | ; Window client area box |
3166 | ; Window client area box |
3158 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3167 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3159 | movsd |
3168 | movsd |
3160 | movsd |
3169 | movsd |
3161 | movsd |
3170 | movsd |
3162 | movsd |
3171 | movsd |
3163 | 3172 | ||
3164 | ; Window state |
3173 | ; Window state |
3165 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3174 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3166 | stosb |
3175 | stosb |
3167 | 3176 | ||
3168 | ; Event mask (+71) |
3177 | ; Event mask (+71) |
3169 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3178 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3170 | stosd |
3179 | stosd |
3171 | 3180 | ||
3172 | ; Keyboard mode (+75) |
3181 | ; Keyboard mode (+75) |
3173 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3182 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3174 | stosb |
3183 | stosb |
3175 | 3184 | ||
3176 | pop esi |
3185 | pop esi |
3177 | pop edi |
3186 | pop edi |
3178 | 3187 | ||
3179 | .nofillbuf: |
3188 | .nofillbuf: |
3180 | ; return number of processes |
3189 | ; return number of processes |
3181 | 3190 | ||
3182 | mov eax, [TASK_COUNT] |
3191 | mov eax, [TASK_COUNT] |
3183 | mov [esp+32], eax |
3192 | mov [esp+32], eax |
3184 | ret |
3193 | ret |
3185 | 3194 | ||
3186 | align 4 |
3195 | align 4 |
3187 | sys_clock: |
3196 | sys_clock: |
3188 | cli |
3197 | cli |
3189 | ; Mikhail Lisovin xx Jan 2005 |
3198 | ; Mikhail Lisovin xx Jan 2005 |
3190 | @@: |
3199 | @@: |
3191 | mov al, 10 |
3200 | mov al, 10 |
3192 | out 0x70, al |
3201 | out 0x70, al |
3193 | in al, 0x71 |
3202 | in al, 0x71 |
3194 | test al, al |
3203 | test al, al |
3195 | jns @f |
3204 | jns @f |
3196 | mov esi, 1 |
3205 | mov esi, 1 |
3197 | call delay_ms |
3206 | call delay_ms |
3198 | jmp @b |
3207 | jmp @b |
3199 | @@: |
3208 | @@: |
3200 | ; end Lisovin's fix |
3209 | ; end Lisovin's fix |
3201 | 3210 | ||
3202 | xor al, al ; seconds |
3211 | xor al, al ; seconds |
3203 | out 0x70, al |
3212 | out 0x70, al |
3204 | in al, 0x71 |
3213 | in al, 0x71 |
3205 | movzx ecx, al |
3214 | movzx ecx, al |
3206 | mov al, 02 ; minutes |
3215 | mov al, 02 ; minutes |
3207 | shl ecx, 16 |
3216 | shl ecx, 16 |
3208 | out 0x70, al |
3217 | out 0x70, al |
3209 | in al, 0x71 |
3218 | in al, 0x71 |
3210 | movzx edx, al |
3219 | movzx edx, al |
3211 | mov al, 04 ; hours |
3220 | mov al, 04 ; hours |
3212 | shl edx, 8 |
3221 | shl edx, 8 |
3213 | out 0x70, al |
3222 | out 0x70, al |
3214 | in al, 0x71 |
3223 | in al, 0x71 |
3215 | add ecx, edx |
3224 | add ecx, edx |
3216 | movzx edx, al |
3225 | movzx edx, al |
3217 | add ecx, edx |
3226 | add ecx, edx |
3218 | sti |
3227 | sti |
3219 | mov [esp + 32], ecx |
3228 | mov [esp + 32], ecx |
3220 | ret |
3229 | ret |
3221 | 3230 | ||
3222 | 3231 | ||
3223 | align 4 |
3232 | align 4 |
3224 | 3233 | ||
3225 | sys_date: |
3234 | sys_date: |
3226 | 3235 | ||
3227 | cli |
3236 | cli |
3228 | @@: |
3237 | @@: |
3229 | mov al, 10 |
3238 | mov al, 10 |
3230 | out 0x70, al |
3239 | out 0x70, al |
3231 | in al, 0x71 |
3240 | in al, 0x71 |
3232 | test al, al |
3241 | test al, al |
3233 | jns @f |
3242 | jns @f |
3234 | mov esi, 1 |
3243 | mov esi, 1 |
3235 | call delay_ms |
3244 | call delay_ms |
3236 | jmp @b |
3245 | jmp @b |
3237 | @@: |
3246 | @@: |
3238 | 3247 | ||
3239 | mov ch, 0 |
3248 | mov ch, 0 |
3240 | mov al, 7 ; date |
3249 | mov al, 7 ; date |
3241 | out 0x70, al |
3250 | out 0x70, al |
3242 | in al, 0x71 |
3251 | in al, 0x71 |
3243 | mov cl, al |
3252 | mov cl, al |
3244 | mov al, 8 ; month |
3253 | mov al, 8 ; month |
3245 | shl ecx, 16 |
3254 | shl ecx, 16 |
3246 | out 0x70, al |
3255 | out 0x70, al |
3247 | in al, 0x71 |
3256 | in al, 0x71 |
3248 | mov ch, al |
3257 | mov ch, al |
3249 | mov al, 9 ; year |
3258 | mov al, 9 ; year |
3250 | out 0x70, al |
3259 | out 0x70, al |
3251 | in al, 0x71 |
3260 | in al, 0x71 |
3252 | mov cl, al |
3261 | mov cl, al |
3253 | sti |
3262 | sti |
3254 | mov [esp+32], ecx |
3263 | mov [esp+32], ecx |
3255 | ret |
3264 | ret |
3256 | 3265 | ||
3257 | 3266 | ||
3258 | ; redraw status |
3267 | ; redraw status |
3259 | 3268 | ||
3260 | sys_redrawstat: |
3269 | sys_redrawstat: |
3261 | cmp ebx, 1 |
3270 | cmp ebx, 1 |
3262 | jne no_widgets_away |
3271 | jne no_widgets_away |
3263 | ; buttons away |
3272 | ; buttons away |
3264 | mov ecx, [CURRENT_TASK] |
3273 | mov ecx, [CURRENT_TASK] |
3265 | sys_newba2: |
3274 | sys_newba2: |
3266 | mov edi, [BTN_ADDR] |
3275 | mov edi, [BTN_ADDR] |
3267 | cmp [edi], dword 0 ; empty button list ? |
3276 | cmp [edi], dword 0 ; empty button list ? |
3268 | je end_of_buttons_away |
3277 | je end_of_buttons_away |
3269 | movzx ebx, word [edi] |
3278 | movzx ebx, word [edi] |
3270 | inc ebx |
3279 | inc ebx |
3271 | mov eax, edi |
3280 | mov eax, edi |
3272 | sys_newba: |
3281 | sys_newba: |
3273 | dec ebx |
3282 | dec ebx |
3274 | jz end_of_buttons_away |
3283 | jz end_of_buttons_away |
3275 | 3284 | ||
3276 | add eax, 0x10 |
3285 | add eax, 0x10 |
3277 | cmp cx, [eax] |
3286 | cmp cx, [eax] |
3278 | jnz sys_newba |
3287 | jnz sys_newba |
3279 | 3288 | ||
3280 | push eax ebx ecx |
3289 | push eax ebx ecx |
3281 | mov ecx, ebx |
3290 | mov ecx, ebx |
3282 | inc ecx |
3291 | inc ecx |
3283 | shl ecx, 4 |
3292 | shl ecx, 4 |
3284 | mov ebx, eax |
3293 | mov ebx, eax |
3285 | add eax, 0x10 |
3294 | add eax, 0x10 |
3286 | call memmove |
3295 | call memmove |
3287 | dec dword [edi] |
3296 | dec dword [edi] |
3288 | pop ecx ebx eax |
3297 | pop ecx ebx eax |
3289 | 3298 | ||
3290 | jmp sys_newba2 |
3299 | jmp sys_newba2 |
3291 | 3300 | ||
3292 | end_of_buttons_away: |
3301 | end_of_buttons_away: |
3293 | 3302 | ||
3294 | ret |
3303 | ret |
3295 | 3304 | ||
3296 | no_widgets_away: |
3305 | no_widgets_away: |
3297 | 3306 | ||
3298 | cmp ebx, 2 |
3307 | cmp ebx, 2 |
3299 | jnz srl1 |
3308 | jnz srl1 |
3300 | 3309 | ||
3301 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3310 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3302 | add edx, draw_data - CURRENT_TASK |
3311 | add edx, draw_data - CURRENT_TASK |
3303 | mov [edx + RECT.left], 0 |
3312 | mov [edx + RECT.left], 0 |
3304 | mov [edx + RECT.top], 0 |
3313 | mov [edx + RECT.top], 0 |
3305 | mov eax, [_display.width] |
3314 | mov eax, [_display.width] |
3306 | dec eax |
3315 | dec eax |
3307 | mov [edx + RECT.right], eax |
3316 | mov [edx + RECT.right], eax |
3308 | mov eax, [_display.height] |
3317 | mov eax, [_display.height] |
3309 | dec eax |
3318 | dec eax |
3310 | mov [edx + RECT.bottom], eax |
3319 | mov [edx + RECT.bottom], eax |
3311 | 3320 | ||
3312 | srl1: |
3321 | srl1: |
3313 | ret |
3322 | ret |
3314 | 3323 | ||
3315 | ;ok - 100% work |
3324 | ;ok - 100% work |
3316 | ;nt - not tested |
3325 | ;nt - not tested |
3317 | ;--------------------------------------------------------------------------------------------- |
3326 | ;--------------------------------------------------------------------------------------------- |
3318 | ;eax |
3327 | ;eax |
3319 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3328 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3320 | ;1 - change task. Ret nothing. Block. ok. |
3329 | ;1 - change task. Ret nothing. Block. ok. |
3321 | ;2 - performance control |
3330 | ;2 - performance control |
3322 | ; ebx |
3331 | ; ebx |
3323 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3332 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3324 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3333 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3325 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3334 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3326 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3335 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3327 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3336 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3328 | ;eax |
3337 | ;eax |
3329 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3338 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3330 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3339 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3331 | ;--------------------------------------------------------------------------------------------- |
3340 | ;--------------------------------------------------------------------------------------------- |
3332 | iglobal |
3341 | iglobal |
3333 | align 4 |
3342 | align 4 |
3334 | sheduler: |
3343 | sheduler: |
3335 | dd sys_sheduler.00 |
3344 | dd sys_sheduler.00 |
3336 | dd change_task |
3345 | dd change_task |
3337 | dd sys_sheduler.02 |
3346 | dd sys_sheduler.02 |
3338 | dd sys_sheduler.03 |
3347 | dd sys_sheduler.03 |
3339 | dd sys_sheduler.04 |
3348 | dd sys_sheduler.04 |
3340 | endg |
3349 | endg |
3341 | sys_sheduler: |
3350 | sys_sheduler: |
3342 | ;rewritten by |
3351 | ;rewritten by |
3343 | jmp dword [sheduler+ebx*4] |
3352 | jmp dword [sheduler+ebx*4] |
3344 | ;.shed_counter: |
3353 | ;.shed_counter: |
3345 | .00: |
3354 | .00: |
3346 | mov eax, [context_counter] |
3355 | mov eax, [context_counter] |
3347 | mov [esp+32], eax |
3356 | mov [esp+32], eax |
3348 | ret |
3357 | ret |
3349 | 3358 | ||
3350 | .02: |
3359 | .02: |
3351 | ;.perf_control: |
3360 | ;.perf_control: |
3352 | inc ebx ;before ebx=2, ebx=3 |
3361 | inc ebx ;before ebx=2, ebx=3 |
3353 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3362 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3354 | jz cache_disable |
3363 | jz cache_disable |
3355 | 3364 | ||
3356 | dec ebx ;ebx=2 |
3365 | dec ebx ;ebx=2 |
3357 | cmp ebx, ecx ; |
3366 | cmp ebx, ecx ; |
3358 | jz cache_enable ;if ecx=2 and ebx=2 |
3367 | jz cache_enable ;if ecx=2 and ebx=2 |
3359 | 3368 | ||
3360 | dec ebx ;ebx=1 |
3369 | dec ebx ;ebx=1 |
3361 | cmp ebx, ecx |
3370 | cmp ebx, ecx |
3362 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3371 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3363 | 3372 | ||
3364 | dec ebx |
3373 | dec ebx |
3365 | test ebx, ecx ;ebx=0 and ecx=0 |
3374 | test ebx, ecx ;ebx=0 and ecx=0 |
3366 | jz modify_pce ;if ecx=0 |
3375 | jz modify_pce ;if ecx=0 |
3367 | 3376 | ||
3368 | ret |
3377 | ret |
3369 | 3378 | ||
3370 | .03: |
3379 | .03: |
3371 | ;.rdmsr_instr: |
3380 | ;.rdmsr_instr: |
3372 | ;now counter in ecx |
3381 | ;now counter in ecx |
3373 | ;(edx:eax) esi:edi => edx:esi |
3382 | ;(edx:eax) esi:edi => edx:esi |
3374 | mov eax, esi |
3383 | mov eax, esi |
3375 | mov ecx, edx |
3384 | mov ecx, edx |
3376 | rdmsr |
3385 | rdmsr |
3377 | mov [esp+32], eax |
3386 | mov [esp+32], eax |
3378 | mov [esp+20], edx ;ret in ebx? |
3387 | mov [esp+20], edx ;ret in ebx? |
3379 | ret |
3388 | ret |
3380 | 3389 | ||
3381 | .04: |
3390 | .04: |
3382 | ;.wrmsr_instr: |
3391 | ;.wrmsr_instr: |
3383 | ;now counter in ecx |
3392 | ;now counter in ecx |
3384 | ;(edx:eax) esi:edi => edx:esi |
3393 | ;(edx:eax) esi:edi => edx:esi |
3385 | ; Fast Call MSR can't be destroy |
3394 | ; Fast Call MSR can't be destroy |
3386 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3395 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3387 | ; включаются/выключаются расширенные возможности |
3396 | ; включаются/выключаются расширенные возможности |
3388 | cmp edx, MSR_SYSENTER_CS |
3397 | cmp edx, MSR_SYSENTER_CS |
3389 | je @f |
3398 | je @f |
3390 | cmp edx, MSR_SYSENTER_ESP |
3399 | cmp edx, MSR_SYSENTER_ESP |
3391 | je @f |
3400 | je @f |
3392 | cmp edx, MSR_SYSENTER_EIP |
3401 | cmp edx, MSR_SYSENTER_EIP |
3393 | je @f |
3402 | je @f |
3394 | cmp edx, MSR_AMD_STAR |
3403 | cmp edx, MSR_AMD_STAR |
3395 | je @f |
3404 | je @f |
3396 | 3405 | ||
3397 | mov eax, esi |
3406 | mov eax, esi |
3398 | mov ecx, edx |
3407 | mov ecx, edx |
3399 | wrmsr |
3408 | wrmsr |
3400 | ; mov [esp + 32], eax |
3409 | ; mov [esp + 32], eax |
3401 | ; mov [esp + 20], edx ;ret in ebx? |
3410 | ; mov [esp + 20], edx ;ret in ebx? |
3402 | @@: |
3411 | @@: |
3403 | ret |
3412 | ret |
3404 | 3413 | ||
3405 | cache_disable: |
3414 | cache_disable: |
3406 | mov eax, cr0 |
3415 | mov eax, cr0 |
3407 | or eax, 01100000000000000000000000000000b |
3416 | or eax, 01100000000000000000000000000000b |
3408 | mov cr0, eax |
3417 | mov cr0, eax |
3409 | wbinvd ;set MESI |
3418 | wbinvd ;set MESI |
3410 | ret |
3419 | ret |
3411 | 3420 | ||
3412 | cache_enable: |
3421 | cache_enable: |
3413 | mov eax, cr0 |
3422 | mov eax, cr0 |
3414 | and eax, 10011111111111111111111111111111b |
3423 | and eax, 10011111111111111111111111111111b |
3415 | mov cr0, eax |
3424 | mov cr0, eax |
3416 | ret |
3425 | ret |
3417 | 3426 | ||
3418 | is_cache_enabled: |
3427 | is_cache_enabled: |
3419 | mov eax, cr0 |
3428 | mov eax, cr0 |
3420 | mov ebx, eax |
3429 | mov ebx, eax |
3421 | and eax, 01100000000000000000000000000000b |
3430 | and eax, 01100000000000000000000000000000b |
3422 | jz cache_disabled |
3431 | jz cache_disabled |
3423 | mov [esp+32], ebx |
3432 | mov [esp+32], ebx |
3424 | cache_disabled: |
3433 | cache_disabled: |
3425 | mov dword [esp+32], eax;0 |
3434 | mov dword [esp+32], eax;0 |
3426 | ret |
3435 | ret |
3427 | 3436 | ||
3428 | modify_pce: |
3437 | modify_pce: |
3429 | mov eax, cr4 |
3438 | mov eax, cr4 |
3430 | ; mov ebx,0 |
3439 | ; mov ebx,0 |
3431 | ; or bx,100000000b ;pce |
3440 | ; or bx,100000000b ;pce |
3432 | ; xor eax,ebx ;invert pce |
3441 | ; xor eax,ebx ;invert pce |
3433 | bts eax, 8;pce=cr4[8] |
3442 | bts eax, 8;pce=cr4[8] |
3434 | mov cr4, eax |
3443 | mov cr4, eax |
3435 | mov [esp+32], eax |
3444 | mov [esp+32], eax |
3436 | ret |
3445 | ret |
3437 | ;--------------------------------------------------------------------------------------------- |
3446 | ;--------------------------------------------------------------------------------------------- |
3438 | 3447 | ||
3439 | 3448 | ||
3440 | iglobal |
3449 | iglobal |
3441 | cpustring db 'CPU',0 |
3450 | cpustring db 'CPU',0 |
3442 | endg |
3451 | endg |
3443 | 3452 | ||
3444 | uglobal |
3453 | uglobal |
3445 | background_defined db 0 ; diamond, 11.04.2006 |
3454 | background_defined db 0 ; diamond, 11.04.2006 |
3446 | endg |
3455 | endg |
3447 | ;----------------------------------------------------------------------------- |
3456 | ;----------------------------------------------------------------------------- |
3448 | align 4 |
3457 | align 4 |
3449 | checkmisc: |
3458 | checkmisc: |
3450 | cmp [ctrl_alt_del], 1 |
3459 | cmp [ctrl_alt_del], 1 |
3451 | jne nocpustart |
3460 | jne nocpustart |
3452 | 3461 | ||
3453 | mov ebp, cpustring |
3462 | mov ebp, cpustring |
3454 | call fs_execute_from_sysdir |
3463 | call fs_execute_from_sysdir |
3455 | 3464 | ||
3456 | mov [ctrl_alt_del], 0 |
3465 | mov [ctrl_alt_del], 0 |
3457 | ;-------------------------------------- |
3466 | ;-------------------------------------- |
3458 | align 4 |
3467 | align 4 |
3459 | nocpustart: |
3468 | nocpustart: |
3460 | cmp [mouse_active], 1 |
3469 | cmp [mouse_active], 1 |
3461 | jne mouse_not_active |
3470 | jne mouse_not_active |
3462 | mov [mouse_active], 0 |
3471 | mov [mouse_active], 0 |
3463 | 3472 | ||
3464 | xor edi, edi |
3473 | xor edi, edi |
3465 | mov ebx, CURRENT_TASK |
3474 | mov ebx, CURRENT_TASK |
3466 | 3475 | ||
3467 | mov ecx, [TASK_COUNT] |
3476 | mov ecx, [TASK_COUNT] |
3468 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3477 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3469 | shl eax, 8 |
3478 | shl eax, 8 |
3470 | push eax |
3479 | push eax |
3471 | 3480 | ||
3472 | movzx eax, word [MOUSE_X] |
3481 | movzx eax, word [MOUSE_X] |
3473 | movzx edx, word [MOUSE_Y] |
3482 | movzx edx, word [MOUSE_Y] |
3474 | ;-------------------------------------- |
3483 | ;-------------------------------------- |
3475 | align 4 |
3484 | align 4 |
3476 | .set_mouse_event: |
3485 | .set_mouse_event: |
3477 | add edi, 256 |
3486 | add edi, 256 |
3478 | add ebx, 32 |
3487 | add ebx, 32 |
3479 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3488 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3480 | jz .pos_filter |
3489 | jz .pos_filter |
3481 | 3490 | ||
3482 | cmp edi, [esp] ; skip if filtration active |
3491 | cmp edi, [esp] ; skip if filtration active |
3483 | jne .skip |
3492 | jne .skip |
3484 | ;-------------------------------------- |
3493 | ;-------------------------------------- |
3485 | align 4 |
3494 | align 4 |
3486 | .pos_filter: |
3495 | .pos_filter: |
3487 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3496 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3488 | jz .set |
3497 | jz .set |
3489 | 3498 | ||
3490 | mov esi, [ebx-twdw+WDATA.box.left] |
3499 | mov esi, [ebx-twdw+WDATA.box.left] |
3491 | cmp eax, esi |
3500 | cmp eax, esi |
3492 | jb .skip |
3501 | jb .skip |
3493 | add esi, [ebx-twdw+WDATA.box.width] |
3502 | add esi, [ebx-twdw+WDATA.box.width] |
3494 | cmp eax, esi |
3503 | cmp eax, esi |
3495 | ja .skip |
3504 | ja .skip |
3496 | 3505 | ||
3497 | mov esi, [ebx-twdw+WDATA.box.top] |
3506 | mov esi, [ebx-twdw+WDATA.box.top] |
3498 | cmp edx, esi |
3507 | cmp edx, esi |
3499 | jb .skip |
3508 | jb .skip |
3500 | add esi, [ebx-twdw+WDATA.box.height] |
3509 | add esi, [ebx-twdw+WDATA.box.height] |
3501 | cmp edx, esi |
3510 | cmp edx, esi |
3502 | ja .skip |
3511 | ja .skip |
3503 | ;-------------------------------------- |
3512 | ;-------------------------------------- |
3504 | align 4 |
3513 | align 4 |
3505 | .set: |
3514 | .set: |
3506 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3515 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3507 | ;-------------------------------------- |
3516 | ;-------------------------------------- |
3508 | align 4 |
3517 | align 4 |
3509 | .skip: |
3518 | .skip: |
3510 | loop .set_mouse_event |
3519 | loop .set_mouse_event |
3511 | 3520 | ||
3512 | pop eax |
3521 | pop eax |
3513 | ;-------------------------------------- |
3522 | ;-------------------------------------- |
3514 | align 4 |
3523 | align 4 |
3515 | mouse_not_active: |
3524 | mouse_not_active: |
3516 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3525 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3517 | jz nobackgr |
3526 | jz nobackgr |
3518 | 3527 | ||
3519 | cmp [background_defined], 0 |
3528 | cmp [background_defined], 0 |
3520 | jz nobackgr |
3529 | jz nobackgr |
3521 | ;-------------------------------------- |
3530 | ;-------------------------------------- |
3522 | align 4 |
3531 | align 4 |
3523 | backgr: |
3532 | backgr: |
3524 | mov eax, [draw_data+32 + RECT.left] |
3533 | mov eax, [draw_data+32 + RECT.left] |
3525 | shl eax, 16 |
3534 | shl eax, 16 |
3526 | add eax, [draw_data+32 + RECT.right] |
3535 | add eax, [draw_data+32 + RECT.right] |
3527 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3536 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3528 | 3537 | ||
3529 | mov eax, [draw_data+32 + RECT.top] |
3538 | mov eax, [draw_data+32 + RECT.top] |
3530 | shl eax, 16 |
3539 | shl eax, 16 |
3531 | add eax, [draw_data+32 + RECT.bottom] |
3540 | add eax, [draw_data+32 + RECT.bottom] |
3532 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3541 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3533 | 3542 | ||
3534 | call drawbackground |
3543 | call drawbackground |
3535 | ; DEBUGF 1, "K : drawbackground\n" |
3544 | ; DEBUGF 1, "K : drawbackground\n" |
3536 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3545 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3537 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3546 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3538 | ;--------- set event 5 start ---------- |
3547 | ;--------- set event 5 start ---------- |
3539 | push ecx edi |
3548 | push ecx edi |
3540 | xor edi, edi |
3549 | xor edi, edi |
3541 | mov ecx, [TASK_COUNT] |
3550 | mov ecx, [TASK_COUNT] |
3542 | ;-------------------------------------- |
3551 | ;-------------------------------------- |
3543 | align 4 |
3552 | align 4 |
3544 | set_bgr_event: |
3553 | set_bgr_event: |
3545 | add edi, 256 |
3554 | add edi, 256 |
3546 | mov eax, [BG_Rect_X_left_right] |
3555 | mov eax, [BG_Rect_X_left_right] |
3547 | mov edx, [BG_Rect_Y_top_bottom] |
3556 | mov edx, [BG_Rect_Y_top_bottom] |
3548 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3557 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3549 | jz .set |
3558 | jz .set |
3550 | .join: |
3559 | .join: |
3551 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3560 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3552 | jae @f |
3561 | jae @f |
3553 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3562 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3554 | @@: |
3563 | @@: |
3555 | shr eax, 16 |
3564 | shr eax, 16 |
3556 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3565 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3557 | jbe @f |
3566 | jbe @f |
3558 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3567 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3559 | @@: |
3568 | @@: |
3560 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3569 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3561 | jae @f |
3570 | jae @f |
3562 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3571 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3563 | @@: |
3572 | @@: |
3564 | shr edx, 16 |
3573 | shr edx, 16 |
3565 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3574 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3566 | jbe @f |
3575 | jbe @f |
3567 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3576 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3568 | @@: |
3577 | @@: |
3569 | jmp .common |
3578 | jmp .common |
3570 | .set: |
3579 | .set: |
3571 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3580 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3572 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3581 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3573 | .common: |
3582 | .common: |
3574 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3583 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3575 | loop set_bgr_event |
3584 | loop set_bgr_event |
3576 | pop edi ecx |
3585 | pop edi ecx |
3577 | ;--------- set event 5 stop ----------- |
3586 | ;--------- set event 5 stop ----------- |
3578 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3587 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3579 | jnz backgr |
3588 | jnz backgr |
3580 | 3589 | ||
3581 | xor eax, eax |
3590 | xor eax, eax |
3582 | mov [draw_data+32 + RECT.left], eax |
3591 | mov [draw_data+32 + RECT.left], eax |
3583 | mov [draw_data+32 + RECT.top], eax |
3592 | mov [draw_data+32 + RECT.top], eax |
3584 | mov [draw_data+32 + RECT.right], eax |
3593 | mov [draw_data+32 + RECT.right], eax |
3585 | mov [draw_data+32 + RECT.bottom], eax |
3594 | mov [draw_data+32 + RECT.bottom], eax |
3586 | ;-------------------------------------- |
3595 | ;-------------------------------------- |
3587 | align 4 |
3596 | align 4 |
3588 | nobackgr: |
3597 | nobackgr: |
3589 | ; system shutdown request |
3598 | ; system shutdown request |
3590 | cmp [SYS_SHUTDOWN], byte 0 |
3599 | cmp [SYS_SHUTDOWN], byte 0 |
3591 | je noshutdown |
3600 | je noshutdown |
3592 | 3601 | ||
3593 | mov edx, [shutdown_processes] |
3602 | mov edx, [shutdown_processes] |
3594 | 3603 | ||
3595 | cmp [SYS_SHUTDOWN], dl |
3604 | cmp [SYS_SHUTDOWN], dl |
3596 | jne noshutdown |
3605 | jne noshutdown |
3597 | 3606 | ||
3598 | lea ecx, [edx-1] |
3607 | lea ecx, [edx-1] |
3599 | mov edx, OS_BASE+0x3040 |
3608 | mov edx, OS_BASE+0x3040 |
3600 | jecxz no_mark_system_shutdown |
3609 | jecxz no_mark_system_shutdown |
3601 | ;-------------------------------------- |
3610 | ;-------------------------------------- |
3602 | align 4 |
3611 | align 4 |
3603 | markz: |
3612 | markz: |
3604 | push ecx edx |
3613 | push ecx edx |
3605 | cmp [edx+TASKDATA.state], 9 |
3614 | cmp [edx+TASKDATA.state], 9 |
3606 | jz .nokill |
3615 | jz .nokill |
3607 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3616 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3608 | cmp [edx+APPDATA.process], sys_proc |
3617 | cmp [edx+APPDATA.process], sys_proc |
3609 | jz .nokill |
3618 | jz .nokill |
3610 | call request_terminate |
3619 | call request_terminate |
3611 | jmp .common |
3620 | jmp .common |
3612 | .nokill: |
3621 | .nokill: |
3613 | dec byte [SYS_SHUTDOWN] |
3622 | dec byte [SYS_SHUTDOWN] |
3614 | xor eax, eax |
3623 | xor eax, eax |
3615 | .common: |
3624 | .common: |
3616 | pop edx ecx |
3625 | pop edx ecx |
3617 | test eax, eax |
3626 | test eax, eax |
3618 | jz @f |
3627 | jz @f |
3619 | mov [edx+TASKDATA.state], byte 3 |
3628 | mov [edx+TASKDATA.state], byte 3 |
3620 | @@: |
3629 | @@: |
3621 | add edx, 0x20 |
3630 | add edx, 0x20 |
3622 | loop markz |
3631 | loop markz |
3623 | call wakeup_osloop |
3632 | call wakeup_osloop |
3624 | ;-------------------------------------- |
3633 | ;-------------------------------------- |
3625 | align 4 |
3634 | align 4 |
3626 | @@: |
3635 | @@: |
3627 | no_mark_system_shutdown: |
3636 | no_mark_system_shutdown: |
3628 | dec byte [SYS_SHUTDOWN] |
3637 | dec byte [SYS_SHUTDOWN] |
3629 | je system_shutdown |
3638 | je system_shutdown |
3630 | ;-------------------------------------- |
3639 | ;-------------------------------------- |
3631 | align 4 |
3640 | align 4 |
3632 | noshutdown: |
3641 | noshutdown: |
3633 | mov eax, [TASK_COUNT] ; termination |
3642 | mov eax, [TASK_COUNT] ; termination |
3634 | mov ebx, TASK_DATA+TASKDATA.state |
3643 | mov ebx, TASK_DATA+TASKDATA.state |
3635 | mov esi, 1 |
3644 | mov esi, 1 |
3636 | ;-------------------------------------- |
3645 | ;-------------------------------------- |
3637 | align 4 |
3646 | align 4 |
3638 | newct: |
3647 | newct: |
3639 | mov cl, [ebx] |
3648 | mov cl, [ebx] |
3640 | cmp cl, byte 3 |
3649 | cmp cl, byte 3 |
3641 | jz .terminate |
3650 | jz .terminate |
3642 | 3651 | ||
3643 | cmp cl, byte 4 |
3652 | cmp cl, byte 4 |
3644 | jnz .noterminate |
3653 | jnz .noterminate |
3645 | .terminate: |
3654 | .terminate: |
3646 | pushad |
3655 | pushad |
3647 | mov ecx, eax |
3656 | mov ecx, eax |
3648 | shl ecx, 8 |
3657 | shl ecx, 8 |
3649 | add ecx, SLOT_BASE |
3658 | add ecx, SLOT_BASE |
3650 | call restore_default_cursor_before_killing |
3659 | call restore_default_cursor_before_killing |
3651 | popad |
3660 | popad |
3652 | 3661 | ||
3653 | pushad |
3662 | pushad |
3654 | call terminate |
3663 | call terminate |
3655 | popad |
3664 | popad |
3656 | cmp byte [SYS_SHUTDOWN], 0 |
3665 | cmp byte [SYS_SHUTDOWN], 0 |
3657 | jz .noterminate |
3666 | jz .noterminate |
3658 | dec byte [SYS_SHUTDOWN] |
3667 | dec byte [SYS_SHUTDOWN] |
3659 | je system_shutdown |
3668 | je system_shutdown |
3660 | 3669 | ||
3661 | .noterminate: |
3670 | .noterminate: |
3662 | add ebx, 0x20 |
3671 | add ebx, 0x20 |
3663 | inc esi |
3672 | inc esi |
3664 | dec eax |
3673 | dec eax |
3665 | jnz newct |
3674 | jnz newct |
3666 | ret |
3675 | ret |
3667 | ;----------------------------------------------------------------------------- |
3676 | ;----------------------------------------------------------------------------- |
3668 | align 4 |
3677 | align 4 |
3669 | redrawscreen: |
3678 | redrawscreen: |
3670 | ; eax , if process window_data base is eax, do not set flag/limits |
3679 | ; eax , if process window_data base is eax, do not set flag/limits |
3671 | 3680 | ||
3672 | pushad |
3681 | pushad |
3673 | push eax |
3682 | push eax |
3674 | 3683 | ||
3675 | ;;; mov ebx,2 |
3684 | ;;; mov ebx,2 |
3676 | ;;; call delay_hs |
3685 | ;;; call delay_hs |
3677 | 3686 | ||
3678 | ;mov ecx,0 ; redraw flags for apps |
3687 | ;mov ecx,0 ; redraw flags for apps |
3679 | xor ecx, ecx |
3688 | xor ecx, ecx |
3680 | ;-------------------------------------- |
3689 | ;-------------------------------------- |
3681 | align 4 |
3690 | align 4 |
3682 | newdw2: |
3691 | newdw2: |
3683 | inc ecx |
3692 | inc ecx |
3684 | push ecx |
3693 | push ecx |
3685 | 3694 | ||
3686 | mov eax, ecx |
3695 | mov eax, ecx |
3687 | shl eax, 5 |
3696 | shl eax, 5 |
3688 | add eax, window_data |
3697 | add eax, window_data |
3689 | 3698 | ||
3690 | cmp eax, [esp+4] |
3699 | cmp eax, [esp+4] |
3691 | je not_this_task |
3700 | je not_this_task |
3692 | ; check if window in redraw area |
3701 | ; check if window in redraw area |
3693 | mov edi, eax |
3702 | mov edi, eax |
3694 | 3703 | ||
3695 | cmp ecx, 1 ; limit for background |
3704 | cmp ecx, 1 ; limit for background |
3696 | jz bgli |
3705 | jz bgli |
3697 | 3706 | ||
3698 | mov eax, [edi + WDATA.box.left] |
3707 | mov eax, [edi + WDATA.box.left] |
3699 | mov ebx, [edi + WDATA.box.top] |
3708 | mov ebx, [edi + WDATA.box.top] |
3700 | 3709 | ||
3701 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3710 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3702 | cmp ecx, ebx |
3711 | cmp ecx, ebx |
3703 | jb ricino |
3712 | jb ricino |
3704 | 3713 | ||
3705 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3714 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3706 | cmp ecx, eax |
3715 | cmp ecx, eax |
3707 | jb ricino |
3716 | jb ricino |
3708 | 3717 | ||
3709 | mov eax, [edi + WDATA.box.left] |
3718 | mov eax, [edi + WDATA.box.left] |
3710 | mov ebx, [edi + WDATA.box.top] |
3719 | mov ebx, [edi + WDATA.box.top] |
3711 | mov ecx, [edi + WDATA.box.width] |
3720 | mov ecx, [edi + WDATA.box.width] |
3712 | mov edx, [edi + WDATA.box.height] |
3721 | mov edx, [edi + WDATA.box.height] |
3713 | add ecx, eax |
3722 | add ecx, eax |
3714 | add edx, ebx |
3723 | add edx, ebx |
3715 | 3724 | ||
3716 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3725 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3717 | cmp edx, eax |
3726 | cmp edx, eax |
3718 | jb ricino |
3727 | jb ricino |
3719 | 3728 | ||
3720 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3729 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3721 | cmp ecx, eax |
3730 | cmp ecx, eax |
3722 | jb ricino |
3731 | jb ricino |
3723 | ;-------------------------------------- |
3732 | ;-------------------------------------- |
3724 | align 4 |
3733 | align 4 |
3725 | bgli: |
3734 | bgli: |
3726 | cmp dword[esp], 1 |
3735 | cmp dword[esp], 1 |
3727 | jnz .az |
3736 | jnz .az |
3728 | 3737 | ||
3729 | cmp byte[REDRAW_BACKGROUND], 0 |
3738 | cmp byte[REDRAW_BACKGROUND], 0 |
3730 | jz .az |
3739 | jz .az |
3731 | 3740 | ||
3732 | mov dl, 0 |
3741 | mov dl, 0 |
3733 | lea eax, [edi+draw_data-window_data] |
3742 | lea eax, [edi+draw_data-window_data] |
3734 | mov ebx, [draw_limits.left] |
3743 | mov ebx, [draw_limits.left] |
3735 | cmp ebx, [eax+RECT.left] |
3744 | cmp ebx, [eax+RECT.left] |
3736 | jae @f |
3745 | jae @f |
3737 | 3746 | ||
3738 | mov [eax+RECT.left], ebx |
3747 | mov [eax+RECT.left], ebx |
3739 | mov dl, 1 |
3748 | mov dl, 1 |
3740 | ;-------------------------------------- |
3749 | ;-------------------------------------- |
3741 | align 4 |
3750 | align 4 |
3742 | @@: |
3751 | @@: |
3743 | mov ebx, [draw_limits.top] |
3752 | mov ebx, [draw_limits.top] |
3744 | cmp ebx, [eax+RECT.top] |
3753 | cmp ebx, [eax+RECT.top] |
3745 | jae @f |
3754 | jae @f |
3746 | 3755 | ||
3747 | mov [eax+RECT.top], ebx |
3756 | mov [eax+RECT.top], ebx |
3748 | mov dl, 1 |
3757 | mov dl, 1 |
3749 | ;-------------------------------------- |
3758 | ;-------------------------------------- |
3750 | align 4 |
3759 | align 4 |
3751 | @@: |
3760 | @@: |
3752 | mov ebx, [draw_limits.right] |
3761 | mov ebx, [draw_limits.right] |
3753 | cmp ebx, [eax+RECT.right] |
3762 | cmp ebx, [eax+RECT.right] |
3754 | jbe @f |
3763 | jbe @f |
3755 | 3764 | ||
3756 | mov [eax+RECT.right], ebx |
3765 | mov [eax+RECT.right], ebx |
3757 | mov dl, 1 |
3766 | mov dl, 1 |
3758 | ;-------------------------------------- |
3767 | ;-------------------------------------- |
3759 | align 4 |
3768 | align 4 |
3760 | @@: |
3769 | @@: |
3761 | mov ebx, [draw_limits.bottom] |
3770 | mov ebx, [draw_limits.bottom] |
3762 | cmp ebx, [eax+RECT.bottom] |
3771 | cmp ebx, [eax+RECT.bottom] |
3763 | jbe @f |
3772 | jbe @f |
3764 | 3773 | ||
3765 | mov [eax+RECT.bottom], ebx |
3774 | mov [eax+RECT.bottom], ebx |
3766 | mov dl, 1 |
3775 | mov dl, 1 |
3767 | ;-------------------------------------- |
3776 | ;-------------------------------------- |
3768 | align 4 |
3777 | align 4 |
3769 | @@: |
3778 | @@: |
3770 | add byte[REDRAW_BACKGROUND], dl |
3779 | add byte[REDRAW_BACKGROUND], dl |
3771 | call wakeup_osloop |
3780 | call wakeup_osloop |
3772 | jmp newdw8 |
3781 | jmp newdw8 |
3773 | ;-------------------------------------- |
3782 | ;-------------------------------------- |
3774 | align 4 |
3783 | align 4 |
3775 | .az: |
3784 | .az: |
3776 | mov eax, edi |
3785 | mov eax, edi |
3777 | add eax, draw_data-window_data |
3786 | add eax, draw_data-window_data |
3778 | 3787 | ||
3779 | mov ebx, [draw_limits.left] ; set limits |
3788 | mov ebx, [draw_limits.left] ; set limits |
3780 | mov [eax + RECT.left], ebx |
3789 | mov [eax + RECT.left], ebx |
3781 | mov ebx, [draw_limits.top] |
3790 | mov ebx, [draw_limits.top] |
3782 | mov [eax + RECT.top], ebx |
3791 | mov [eax + RECT.top], ebx |
3783 | mov ebx, [draw_limits.right] |
3792 | mov ebx, [draw_limits.right] |
3784 | mov [eax + RECT.right], ebx |
3793 | mov [eax + RECT.right], ebx |
3785 | mov ebx, [draw_limits.bottom] |
3794 | mov ebx, [draw_limits.bottom] |
3786 | mov [eax + RECT.bottom], ebx |
3795 | mov [eax + RECT.bottom], ebx |
3787 | 3796 | ||
3788 | sub eax, draw_data-window_data |
3797 | sub eax, draw_data-window_data |
3789 | 3798 | ||
3790 | cmp dword [esp], 1 |
3799 | cmp dword [esp], 1 |
3791 | jne nobgrd |
3800 | jne nobgrd |
3792 | inc byte[REDRAW_BACKGROUND] |
3801 | inc byte[REDRAW_BACKGROUND] |
3793 | call wakeup_osloop |
3802 | call wakeup_osloop |
3794 | ;-------------------------------------- |
3803 | ;-------------------------------------- |
3795 | align 4 |
3804 | align 4 |
3796 | newdw8: |
3805 | newdw8: |
3797 | nobgrd: |
3806 | nobgrd: |
3798 | ;-------------------------------------- |
3807 | ;-------------------------------------- |
3799 | push eax edi ebp |
3808 | push eax edi ebp |
3800 | mov edi, [esp+12] |
3809 | mov edi, [esp+12] |
3801 | cmp edi, 1 |
3810 | cmp edi, 1 |
3802 | je .found |
3811 | je .found |
3803 | 3812 | ||
3804 | mov eax, [draw_limits.left] |
3813 | mov eax, [draw_limits.left] |
3805 | mov ebx, [draw_limits.top] |
3814 | mov ebx, [draw_limits.top] |
3806 | mov ecx, [draw_limits.right] |
3815 | mov ecx, [draw_limits.right] |
3807 | sub ecx, eax |
3816 | sub ecx, eax |
3808 | test ecx, ecx |
3817 | test ecx, ecx |
3809 | jz .not_found |
3818 | jz .not_found |
3810 | 3819 | ||
3811 | mov edx, [draw_limits.bottom] |
3820 | mov edx, [draw_limits.bottom] |
3812 | sub edx, ebx |
3821 | sub edx, ebx |
3813 | test edx, edx |
3822 | test edx, edx |
3814 | jz .not_found |
3823 | jz .not_found |
3815 | 3824 | ||
3816 | ; eax - x, ebx - y |
3825 | ; eax - x, ebx - y |
3817 | ; ecx - size x, edx - size y |
3826 | ; ecx - size x, edx - size y |
3818 | add ebx, edx |
3827 | add ebx, edx |
3819 | ;-------------------------------------- |
3828 | ;-------------------------------------- |
3820 | align 4 |
3829 | align 4 |
3821 | .start_y: |
3830 | .start_y: |
3822 | push ecx |
3831 | push ecx |
3823 | ;-------------------------------------- |
3832 | ;-------------------------------------- |
3824 | align 4 |
3833 | align 4 |
3825 | .start_x: |
3834 | .start_x: |
3826 | add eax, ecx |
3835 | add eax, ecx |
3827 | mov ebp, [d_width_calc_area + ebx*4] |
3836 | mov ebp, [d_width_calc_area + ebx*4] |
3828 | add ebp, [_display.win_map] |
3837 | add ebp, [_display.win_map] |
3829 | movzx ebp, byte[eax+ebp] ; get value for current point |
3838 | movzx ebp, byte[eax+ebp] ; get value for current point |
3830 | cmp ebp, edi |
3839 | cmp ebp, edi |
3831 | jne @f |
3840 | jne @f |
3832 | 3841 | ||
3833 | pop ecx |
3842 | pop ecx |
3834 | jmp .found |
3843 | jmp .found |
3835 | ;-------------------------------------- |
3844 | ;-------------------------------------- |
3836 | align 4 |
3845 | align 4 |
3837 | @@: |
3846 | @@: |
3838 | sub eax, ecx |
3847 | sub eax, ecx |
3839 | 3848 | ||
3840 | dec ecx |
3849 | dec ecx |
3841 | jnz .start_x |
3850 | jnz .start_x |
3842 | 3851 | ||
3843 | pop ecx |
3852 | pop ecx |
3844 | dec ebx |
3853 | dec ebx |
3845 | dec edx |
3854 | dec edx |
3846 | jnz .start_y |
3855 | jnz .start_y |
3847 | ;-------------------------------------- |
3856 | ;-------------------------------------- |
3848 | align 4 |
3857 | align 4 |
3849 | .not_found: |
3858 | .not_found: |
3850 | pop ebp edi eax |
3859 | pop ebp edi eax |
3851 | jmp ricino |
3860 | jmp ricino |
3852 | ;-------------------------------------- |
3861 | ;-------------------------------------- |
3853 | align 4 |
3862 | align 4 |
3854 | .found: |
3863 | .found: |
3855 | pop ebp edi eax |
3864 | pop ebp edi eax |
3856 | 3865 | ||
3857 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3866 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3858 | ;-------------------------------------- |
3867 | ;-------------------------------------- |
3859 | align 4 |
3868 | align 4 |
3860 | ricino: |
3869 | ricino: |
3861 | not_this_task: |
3870 | not_this_task: |
3862 | pop ecx |
3871 | pop ecx |
3863 | 3872 | ||
3864 | cmp ecx, [TASK_COUNT] |
3873 | cmp ecx, [TASK_COUNT] |
3865 | jle newdw2 |
3874 | jle newdw2 |
3866 | 3875 | ||
3867 | pop eax |
3876 | pop eax |
3868 | popad |
3877 | popad |
3869 | ret |
3878 | ret |
3870 | ;----------------------------------------------------------------------------- |
3879 | ;----------------------------------------------------------------------------- |
3871 | align 4 |
3880 | align 4 |
3872 | calculatebackground: ; background |
3881 | calculatebackground: ; background |
3873 | mov edi, [_display.win_map] ; set os to use all pixels |
3882 | mov edi, [_display.win_map] ; set os to use all pixels |
3874 | mov eax, 0x01010101 |
3883 | mov eax, 0x01010101 |
3875 | mov ecx, [_display.win_map_size] |
3884 | mov ecx, [_display.win_map_size] |
3876 | shr ecx, 2 |
3885 | shr ecx, 2 |
3877 | rep stosd |
3886 | rep stosd |
3878 | 3887 | ||
3879 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3888 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3880 | ret |
3889 | ret |
3881 | ;----------------------------------------------------------------------------- |
3890 | ;----------------------------------------------------------------------------- |
3882 | uglobal |
3891 | uglobal |
3883 | imax dd 0x0 |
3892 | imax dd 0x0 |
3884 | endg |
3893 | endg |
3885 | ;----------------------------------------------------------------------------- |
3894 | ;----------------------------------------------------------------------------- |
3886 | align 4 |
3895 | align 4 |
3887 | delay_ms: ; delay in 1/1000 sec |
3896 | delay_ms: ; delay in 1/1000 sec |
3888 | push eax |
3897 | push eax |
3889 | push ecx |
3898 | push ecx |
3890 | 3899 | ||
3891 | mov ecx, esi |
3900 | mov ecx, esi |
3892 | ; |
3901 | ; |
3893 | imul ecx, 33941 |
3902 | imul ecx, 33941 |
3894 | shr ecx, 9 |
3903 | shr ecx, 9 |
3895 | ; |
3904 | ; |
3896 | 3905 | ||
3897 | in al, 0x61 |
3906 | in al, 0x61 |
3898 | and al, 0x10 |
3907 | and al, 0x10 |
3899 | mov ah, al |
3908 | mov ah, al |
3900 | cld |
3909 | cld |
3901 | ;-------------------------------------- |
3910 | ;-------------------------------------- |
3902 | align 4 |
3911 | align 4 |
3903 | cnt1: |
3912 | cnt1: |
3904 | in al, 0x61 |
3913 | in al, 0x61 |
3905 | and al, 0x10 |
3914 | and al, 0x10 |
3906 | cmp al, ah |
3915 | cmp al, ah |
3907 | jz cnt1 |
3916 | jz cnt1 |
3908 | 3917 | ||
3909 | mov ah, al |
3918 | mov ah, al |
3910 | loop cnt1 |
3919 | loop cnt1 |
3911 | 3920 | ||
3912 | pop ecx |
3921 | pop ecx |
3913 | pop eax |
3922 | pop eax |
3914 | ret |
3923 | ret |
3915 | ;----------------------------------------------------------------------------- |
3924 | ;----------------------------------------------------------------------------- |
3916 | align 4 |
3925 | align 4 |
3917 | set_app_param: |
3926 | set_app_param: |
3918 | mov edi, [TASK_BASE] |
3927 | mov edi, [TASK_BASE] |
3919 | mov eax, ebx |
3928 | mov eax, ebx |
3920 | btr eax, 3 ; move MOUSE_FILTRATION |
3929 | btr eax, 3 ; move MOUSE_FILTRATION |
3921 | mov ebx, [current_slot] ; bit into event_filter |
3930 | mov ebx, [current_slot] ; bit into event_filter |
3922 | setc byte [ebx+APPDATA.event_filter] |
3931 | setc byte [ebx+APPDATA.event_filter] |
3923 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3932 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3924 | mov [esp+32], eax ; return old mask value |
3933 | mov [esp+32], eax ; return old mask value |
3925 | ret |
3934 | ret |
3926 | ;----------------------------------------------------------------------------- |
3935 | ;----------------------------------------------------------------------------- |
3927 | 3936 | ||
3928 | ; this is for syscall |
3937 | ; this is for syscall |
3929 | proc delay_hs_unprotected |
3938 | proc delay_hs_unprotected |
3930 | call unprotect_from_terminate |
3939 | call unprotect_from_terminate |
3931 | call delay_hs |
3940 | call delay_hs |
3932 | call protect_from_terminate |
3941 | call protect_from_terminate |
3933 | ret |
3942 | ret |
3934 | endp |
3943 | endp |
3935 | 3944 | ||
3936 | if 1 |
3945 | if 1 |
3937 | align 4 |
3946 | align 4 |
3938 | delay_hs: ; delay in 1/100 secs |
3947 | delay_hs: ; delay in 1/100 secs |
3939 | ; ebx = delay time |
3948 | ; ebx = delay time |
3940 | 3949 | ||
3941 | pushad |
3950 | pushad |
3942 | push ebx |
3951 | push ebx |
3943 | xor esi, esi |
3952 | xor esi, esi |
3944 | mov ecx, MANUAL_DESTROY |
3953 | mov ecx, MANUAL_DESTROY |
3945 | call create_event |
3954 | call create_event |
3946 | test eax, eax |
3955 | test eax, eax |
3947 | jz .done |
3956 | jz .done |
3948 | 3957 | ||
3949 | mov ebx, edx |
3958 | mov ebx, edx |
3950 | mov ecx, [esp] |
3959 | mov ecx, [esp] |
3951 | push edx |
3960 | push edx |
3952 | push eax |
3961 | push eax |
3953 | call wait_event_timeout |
3962 | call wait_event_timeout |
3954 | pop eax |
3963 | pop eax |
3955 | pop ebx |
3964 | pop ebx |
3956 | call destroy_event |
3965 | call destroy_event |
3957 | .done: |
3966 | .done: |
3958 | add esp, 4 |
3967 | add esp, 4 |
3959 | popad |
3968 | popad |
3960 | ret |
3969 | ret |
3961 | 3970 | ||
3962 | else |
3971 | else |
3963 | 3972 | ||
3964 | align 4 |
3973 | align 4 |
3965 | delay_hs: ; delay in 1/100 secs |
3974 | delay_hs: ; delay in 1/100 secs |
3966 | ; ebx = delay time |
3975 | ; ebx = delay time |
3967 | push ecx |
3976 | push ecx |
3968 | push edx |
3977 | push edx |
3969 | 3978 | ||
3970 | mov edx, [timer_ticks] |
3979 | mov edx, [timer_ticks] |
3971 | ;-------------------------------------- |
3980 | ;-------------------------------------- |
3972 | align 4 |
3981 | align 4 |
3973 | newtic: |
3982 | newtic: |
3974 | mov ecx, [timer_ticks] |
3983 | mov ecx, [timer_ticks] |
3975 | sub ecx, edx |
3984 | sub ecx, edx |
3976 | cmp ecx, ebx |
3985 | cmp ecx, ebx |
3977 | jae zerodelay |
3986 | jae zerodelay |
3978 | 3987 | ||
3979 | call change_task |
3988 | call change_task |
3980 | 3989 | ||
3981 | jmp newtic |
3990 | jmp newtic |
3982 | ;-------------------------------------- |
3991 | ;-------------------------------------- |
3983 | align 4 |
3992 | align 4 |
3984 | zerodelay: |
3993 | zerodelay: |
3985 | pop edx |
3994 | pop edx |
3986 | pop ecx |
3995 | pop ecx |
3987 | ret |
3996 | ret |
3988 | end if |
3997 | end if |
3989 | 3998 | ||
3990 | ;----------------------------------------------------------------------------- |
3999 | ;----------------------------------------------------------------------------- |
3991 | align 16 ;very often call this subrutine |
4000 | align 16 ;very often call this subrutine |
3992 | memmove: ; memory move in bytes |
4001 | memmove: ; memory move in bytes |
3993 | ; eax = from |
4002 | ; eax = from |
3994 | ; ebx = to |
4003 | ; ebx = to |
3995 | ; ecx = no of bytes |
4004 | ; ecx = no of bytes |
3996 | test ecx, ecx |
4005 | test ecx, ecx |
3997 | jle .ret |
4006 | jle .ret |
3998 | 4007 | ||
3999 | push esi edi ecx |
4008 | push esi edi ecx |
4000 | 4009 | ||
4001 | mov edi, ebx |
4010 | mov edi, ebx |
4002 | mov esi, eax |
4011 | mov esi, eax |
4003 | 4012 | ||
4004 | test ecx, not 11b |
4013 | test ecx, not 11b |
4005 | jz @f |
4014 | jz @f |
4006 | 4015 | ||
4007 | push ecx |
4016 | push ecx |
4008 | shr ecx, 2 |
4017 | shr ecx, 2 |
4009 | rep movsd |
4018 | rep movsd |
4010 | pop ecx |
4019 | pop ecx |
4011 | and ecx, 11b |
4020 | and ecx, 11b |
4012 | jz .finish |
4021 | jz .finish |
4013 | ;-------------------------------------- |
4022 | ;-------------------------------------- |
4014 | align 4 |
4023 | align 4 |
4015 | @@: |
4024 | @@: |
4016 | rep movsb |
4025 | rep movsb |
4017 | ;-------------------------------------- |
4026 | ;-------------------------------------- |
4018 | align 4 |
4027 | align 4 |
4019 | .finish: |
4028 | .finish: |
4020 | pop ecx edi esi |
4029 | pop ecx edi esi |
4021 | ;-------------------------------------- |
4030 | ;-------------------------------------- |
4022 | align 4 |
4031 | align 4 |
4023 | .ret: |
4032 | .ret: |
4024 | ret |
4033 | ret |
4025 | ;----------------------------------------------------------------------------- |
4034 | ;----------------------------------------------------------------------------- |
4026 | ; |
4035 | ; |
4027 | ;align 4 |
4036 | ;align 4 |
4028 | ; |
4037 | ; |
4029 | ;read_floppy_file: |
4038 | ;read_floppy_file: |
4030 | ; |
4039 | ; |
4031 | ;; as input |
4040 | ;; as input |
4032 | ;; |
4041 | ;; |
4033 | ;; eax pointer to file |
4042 | ;; eax pointer to file |
4034 | ;; ebx file lenght |
4043 | ;; ebx file lenght |
4035 | ;; ecx start 512 byte block number |
4044 | ;; ecx start 512 byte block number |
4036 | ;; edx number of blocks to read |
4045 | ;; edx number of blocks to read |
4037 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4046 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4038 | ;; |
4047 | ;; |
4039 | ;; |
4048 | ;; |
4040 | ;; on return |
4049 | ;; on return |
4041 | ;; |
4050 | ;; |
4042 | ;; eax = 0 command succesful |
4051 | ;; eax = 0 command succesful |
4043 | ;; 1 no fd base and/or partition defined |
4052 | ;; 1 no fd base and/or partition defined |
4044 | ;; 2 yet unsupported FS |
4053 | ;; 2 yet unsupported FS |
4045 | ;; 3 unknown FS |
4054 | ;; 3 unknown FS |
4046 | ;; 4 partition not defined at hd |
4055 | ;; 4 partition not defined at hd |
4047 | ;; 5 file not found |
4056 | ;; 5 file not found |
4048 | ;; ebx = size of file |
4057 | ;; ebx = size of file |
4049 | ; |
4058 | ; |
4050 | ; mov edi,[TASK_BASE] |
4059 | ; mov edi,[TASK_BASE] |
4051 | ; add edi,0x10 |
4060 | ; add edi,0x10 |
4052 | ; add esi,[edi] |
4061 | ; add esi,[edi] |
4053 | ; add eax,[edi] |
4062 | ; add eax,[edi] |
4054 | ; |
4063 | ; |
4055 | ; pushad |
4064 | ; pushad |
4056 | ; mov edi,esi |
4065 | ; mov edi,esi |
4057 | ; add edi,1024 |
4066 | ; add edi,1024 |
4058 | ; mov esi,0x100000+19*512 |
4067 | ; mov esi,0x100000+19*512 |
4059 | ; sub ecx,1 |
4068 | ; sub ecx,1 |
4060 | ; shl ecx,9 |
4069 | ; shl ecx,9 |
4061 | ; add esi,ecx |
4070 | ; add esi,ecx |
4062 | ; shl edx,9 |
4071 | ; shl edx,9 |
4063 | ; mov ecx,edx |
4072 | ; mov ecx,edx |
4064 | ; cld |
4073 | ; cld |
4065 | ; rep movsb |
4074 | ; rep movsb |
4066 | ; popad |
4075 | ; popad |
4067 | ; |
4076 | ; |
4068 | ; mov [esp+36],eax |
4077 | ; mov [esp+36],eax |
4069 | ; mov [esp+24],ebx |
4078 | ; mov [esp+24],ebx |
4070 | ; ret |
4079 | ; ret |
4071 | 4080 | ||
4072 | 4081 | ||
4073 | 4082 | ||
4074 | align 4 |
4083 | align 4 |
4075 | set_io_access_rights: |
4084 | set_io_access_rights: |
4076 | push edi eax |
4085 | push edi eax |
4077 | mov edi, tss._io_map_0 |
4086 | mov edi, tss._io_map_0 |
4078 | ; mov ecx,eax |
4087 | ; mov ecx,eax |
4079 | ; and ecx,7 ; offset in byte |
4088 | ; and ecx,7 ; offset in byte |
4080 | ; shr eax,3 ; number of byte |
4089 | ; shr eax,3 ; number of byte |
4081 | ; add edi,eax |
4090 | ; add edi,eax |
4082 | ; mov ebx,1 |
4091 | ; mov ebx,1 |
4083 | ; shl ebx,cl |
4092 | ; shl ebx,cl |
4084 | test ebp, ebp |
4093 | test ebp, ebp |
4085 | ; cmp ebp,0 ; enable access - ebp = 0 |
4094 | ; cmp ebp,0 ; enable access - ebp = 0 |
4086 | jnz .siar1 |
4095 | jnz .siar1 |
4087 | ; not ebx |
4096 | ; not ebx |
4088 | ; and [edi],byte bl |
4097 | ; and [edi],byte bl |
4089 | btr [edi], eax |
4098 | btr [edi], eax |
4090 | pop eax edi |
4099 | pop eax edi |
4091 | ret |
4100 | ret |
4092 | .siar1: |
4101 | .siar1: |
4093 | bts [edi], eax |
4102 | bts [edi], eax |
4094 | ; or [edi],byte bl ; disable access - ebp = 1 |
4103 | ; or [edi],byte bl ; disable access - ebp = 1 |
4095 | pop eax edi |
4104 | pop eax edi |
4096 | ret |
4105 | ret |
4097 | ;reserve/free group of ports |
4106 | ;reserve/free group of ports |
4098 | ; * eax = 46 - number function |
4107 | ; * eax = 46 - number function |
4099 | ; * ebx = 0 - reserve, 1 - free |
4108 | ; * ebx = 0 - reserve, 1 - free |
4100 | ; * ecx = number start arrea of ports |
4109 | ; * ecx = number start arrea of ports |
4101 | ; * edx = number end arrea of ports (include last number of port) |
4110 | ; * edx = number end arrea of ports (include last number of port) |
4102 | ;Return value: |
4111 | ;Return value: |
4103 | ; * eax = 0 - succesful |
4112 | ; * eax = 0 - succesful |
4104 | ; * eax = 1 - error |
4113 | ; * eax = 1 - error |
4105 | ; * The system has reserve this ports: |
4114 | ; * The system has reserve this ports: |
4106 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4115 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4107 | ;destroys eax,ebx, ebp |
4116 | ;destroys eax,ebx, ebp |
4108 | r_f_port_area: |
4117 | r_f_port_area: |
4109 | 4118 | ||
4110 | test ebx, ebx |
4119 | test ebx, ebx |
4111 | jnz free_port_area |
4120 | jnz free_port_area |
4112 | ; je r_port_area |
4121 | ; je r_port_area |
4113 | ; jmp free_port_area |
4122 | ; jmp free_port_area |
4114 | 4123 | ||
4115 | ; r_port_area: |
4124 | ; r_port_area: |
4116 | 4125 | ||
4117 | ; pushad |
4126 | ; pushad |
4118 | 4127 | ||
4119 | cmp ecx, edx ; beginning > end ? |
4128 | cmp ecx, edx ; beginning > end ? |
4120 | ja rpal1 |
4129 | ja rpal1 |
4121 | cmp edx, 65536 |
4130 | cmp edx, 65536 |
4122 | jae rpal1 |
4131 | jae rpal1 |
4123 | mov eax, [RESERVED_PORTS] |
4132 | mov eax, [RESERVED_PORTS] |
4124 | test eax, eax ; no reserved areas ? |
4133 | test eax, eax ; no reserved areas ? |
4125 | je rpal2 |
4134 | je rpal2 |
4126 | cmp eax, 255 ; max reserved |
4135 | cmp eax, 255 ; max reserved |
4127 | jae rpal1 |
4136 | jae rpal1 |
4128 | rpal3: |
4137 | rpal3: |
4129 | mov ebx, eax |
4138 | mov ebx, eax |
4130 | shl ebx, 4 |
4139 | shl ebx, 4 |
4131 | add ebx, RESERVED_PORTS |
4140 | add ebx, RESERVED_PORTS |
4132 | cmp ecx, [ebx+8] |
4141 | cmp ecx, [ebx+8] |
4133 | ja rpal4 |
4142 | ja rpal4 |
4134 | cmp edx, [ebx+4] |
4143 | cmp edx, [ebx+4] |
4135 | jae rpal1 |
4144 | jae rpal1 |
4136 | ; jb rpal4 |
4145 | ; jb rpal4 |
4137 | ; jmp rpal1 |
4146 | ; jmp rpal1 |
4138 | rpal4: |
4147 | rpal4: |
4139 | dec eax |
4148 | dec eax |
4140 | jnz rpal3 |
4149 | jnz rpal3 |
4141 | jmp rpal2 |
4150 | jmp rpal2 |
4142 | rpal1: |
4151 | rpal1: |
4143 | ; popad |
4152 | ; popad |
4144 | ; mov eax,1 |
4153 | ; mov eax,1 |
4145 | xor eax, eax |
4154 | xor eax, eax |
4146 | inc eax |
4155 | inc eax |
4147 | ret |
4156 | ret |
4148 | rpal2: |
4157 | rpal2: |
4149 | ; popad |
4158 | ; popad |
4150 | ; enable port access at port IO map |
4159 | ; enable port access at port IO map |
4151 | cli |
4160 | cli |
4152 | pushad ; start enable io map |
4161 | pushad ; start enable io map |
4153 | 4162 | ||
4154 | cmp edx, 65536;16384 |
4163 | cmp edx, 65536;16384 |
4155 | jae no_unmask_io; jge |
4164 | jae no_unmask_io; jge |
4156 | mov eax, ecx |
4165 | mov eax, ecx |
4157 | ; push ebp |
4166 | ; push ebp |
4158 | xor ebp, ebp ; enable - eax = port |
4167 | xor ebp, ebp ; enable - eax = port |
4159 | new_port_access: |
4168 | new_port_access: |
4160 | ; pushad |
4169 | ; pushad |
4161 | call set_io_access_rights |
4170 | call set_io_access_rights |
4162 | ; popad |
4171 | ; popad |
4163 | inc eax |
4172 | inc eax |
4164 | cmp eax, edx |
4173 | cmp eax, edx |
4165 | jbe new_port_access |
4174 | jbe new_port_access |
4166 | ; pop ebp |
4175 | ; pop ebp |
4167 | no_unmask_io: |
4176 | no_unmask_io: |
4168 | popad ; end enable io map |
4177 | popad ; end enable io map |
4169 | sti |
4178 | sti |
4170 | 4179 | ||
4171 | mov eax, [RESERVED_PORTS] |
4180 | mov eax, [RESERVED_PORTS] |
4172 | add eax, 1 |
4181 | add eax, 1 |
4173 | mov [RESERVED_PORTS], eax |
4182 | mov [RESERVED_PORTS], eax |
4174 | shl eax, 4 |
4183 | shl eax, 4 |
4175 | add eax, RESERVED_PORTS |
4184 | add eax, RESERVED_PORTS |
4176 | mov ebx, [TASK_BASE] |
4185 | mov ebx, [TASK_BASE] |
4177 | mov ebx, [ebx+TASKDATA.pid] |
4186 | mov ebx, [ebx+TASKDATA.pid] |
4178 | mov [eax], ebx |
4187 | mov [eax], ebx |
4179 | mov [eax+4], ecx |
4188 | mov [eax+4], ecx |
4180 | mov [eax+8], edx |
4189 | mov [eax+8], edx |
4181 | 4190 | ||
4182 | xor eax, eax |
4191 | xor eax, eax |
4183 | ret |
4192 | ret |
4184 | 4193 | ||
4185 | free_port_area: |
4194 | free_port_area: |
4186 | 4195 | ||
4187 | ; pushad |
4196 | ; pushad |
4188 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4197 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4189 | test eax, eax |
4198 | test eax, eax |
4190 | jz frpal2 |
4199 | jz frpal2 |
4191 | mov ebx, [TASK_BASE] |
4200 | mov ebx, [TASK_BASE] |
4192 | mov ebx, [ebx+TASKDATA.pid] |
4201 | mov ebx, [ebx+TASKDATA.pid] |
4193 | frpal3: |
4202 | frpal3: |
4194 | mov edi, eax |
4203 | mov edi, eax |
4195 | shl edi, 4 |
4204 | shl edi, 4 |
4196 | add edi, RESERVED_PORTS |
4205 | add edi, RESERVED_PORTS |
4197 | cmp ebx, [edi] |
4206 | cmp ebx, [edi] |
4198 | jne frpal4 |
4207 | jne frpal4 |
4199 | cmp ecx, [edi+4] |
4208 | cmp ecx, [edi+4] |
4200 | jne frpal4 |
4209 | jne frpal4 |
4201 | cmp edx, [edi+8] |
4210 | cmp edx, [edi+8] |
4202 | jne frpal4 |
4211 | jne frpal4 |
4203 | jmp frpal1 |
4212 | jmp frpal1 |
4204 | frpal4: |
4213 | frpal4: |
4205 | dec eax |
4214 | dec eax |
4206 | jnz frpal3 |
4215 | jnz frpal3 |
4207 | frpal2: |
4216 | frpal2: |
4208 | ; popad |
4217 | ; popad |
4209 | inc eax |
4218 | inc eax |
4210 | ret |
4219 | ret |
4211 | frpal1: |
4220 | frpal1: |
4212 | push ecx |
4221 | push ecx |
4213 | mov ecx, 256 |
4222 | mov ecx, 256 |
4214 | sub ecx, eax |
4223 | sub ecx, eax |
4215 | shl ecx, 4 |
4224 | shl ecx, 4 |
4216 | mov esi, edi |
4225 | mov esi, edi |
4217 | add esi, 16 |
4226 | add esi, 16 |
4218 | cld |
4227 | cld |
4219 | rep movsb |
4228 | rep movsb |
4220 | 4229 | ||
4221 | dec dword [RESERVED_PORTS] |
4230 | dec dword [RESERVED_PORTS] |
4222 | ;popad |
4231 | ;popad |
4223 | ;disable port access at port IO map |
4232 | ;disable port access at port IO map |
4224 | 4233 | ||
4225 | ; pushad ; start disable io map |
4234 | ; pushad ; start disable io map |
4226 | pop eax ;start port |
4235 | pop eax ;start port |
4227 | cmp edx, 65536;16384 |
4236 | cmp edx, 65536;16384 |
4228 | jge no_mask_io |
4237 | jge no_mask_io |
4229 | 4238 | ||
4230 | ; mov eax,ecx |
4239 | ; mov eax,ecx |
4231 | xor ebp, ebp |
4240 | xor ebp, ebp |
4232 | inc ebp |
4241 | inc ebp |
4233 | new_port_access_disable: |
4242 | new_port_access_disable: |
4234 | ; pushad |
4243 | ; pushad |
4235 | ; mov ebp,1 ; disable - eax = port |
4244 | ; mov ebp,1 ; disable - eax = port |
4236 | call set_io_access_rights |
4245 | call set_io_access_rights |
4237 | ; popad |
4246 | ; popad |
4238 | inc eax |
4247 | inc eax |
4239 | cmp eax, edx |
4248 | cmp eax, edx |
4240 | jbe new_port_access_disable |
4249 | jbe new_port_access_disable |
4241 | no_mask_io: |
4250 | no_mask_io: |
4242 | ; popad ; end disable io map |
4251 | ; popad ; end disable io map |
4243 | xor eax, eax |
4252 | xor eax, eax |
4244 | ret |
4253 | ret |
4245 | ;----------------------------------------------------------------------------- |
4254 | ;----------------------------------------------------------------------------- |
4246 | align 4 |
4255 | align 4 |
4247 | drawbackground: |
4256 | drawbackground: |
4248 | dbrv20: |
4257 | dbrv20: |
4249 | cmp [BgrDrawMode], dword 1 |
4258 | cmp [BgrDrawMode], dword 1 |
4250 | jne bgrstr |
4259 | jne bgrstr |
4251 | call vesa20_drawbackground_tiled |
4260 | call vesa20_drawbackground_tiled |
4252 | ; call [draw_pointer] |
4261 | ; call [draw_pointer] |
4253 | call __sys_draw_pointer |
4262 | call __sys_draw_pointer |
4254 | ret |
4263 | ret |
4255 | ;-------------------------------------- |
4264 | ;-------------------------------------- |
4256 | align 4 |
4265 | align 4 |
4257 | bgrstr: |
4266 | bgrstr: |
4258 | call vesa20_drawbackground_stretch |
4267 | call vesa20_drawbackground_stretch |
4259 | ; call [draw_pointer] |
4268 | ; call [draw_pointer] |
4260 | call __sys_draw_pointer |
4269 | call __sys_draw_pointer |
4261 | ret |
4270 | ret |
4262 | ;----------------------------------------------------------------------------- |
4271 | ;----------------------------------------------------------------------------- |
4263 | align 4 |
4272 | align 4 |
4264 | syscall_putimage: ; PutImage |
4273 | syscall_putimage: ; PutImage |
4265 | sys_putimage: |
4274 | sys_putimage: |
4266 | test ecx, 0x80008000 |
4275 | test ecx, 0x80008000 |
4267 | jnz .exit |
4276 | jnz .exit |
4268 | test ecx, 0x0000FFFF |
4277 | test ecx, 0x0000FFFF |
4269 | jz .exit |
4278 | jz .exit |
4270 | test ecx, 0xFFFF0000 |
4279 | test ecx, 0xFFFF0000 |
4271 | jnz @f |
4280 | jnz @f |
4272 | ;-------------------------------------- |
4281 | ;-------------------------------------- |
4273 | align 4 |
4282 | align 4 |
4274 | .exit: |
4283 | .exit: |
4275 | ret |
4284 | ret |
4276 | ;-------------------------------------- |
4285 | ;-------------------------------------- |
4277 | align 4 |
4286 | align 4 |
4278 | @@: |
4287 | @@: |
4279 | mov edi, [current_slot] |
4288 | mov edi, [current_slot] |
4280 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4289 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4281 | rol edx, 16 |
4290 | rol edx, 16 |
4282 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4291 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4283 | rol edx, 16 |
4292 | rol edx, 16 |
4284 | ;-------------------------------------- |
4293 | ;-------------------------------------- |
4285 | align 4 |
4294 | align 4 |
4286 | .forced: |
4295 | .forced: |
4287 | push ebp esi 0 |
4296 | push ebp esi 0 |
4288 | mov ebp, putimage_get24bpp |
4297 | mov ebp, putimage_get24bpp |
4289 | mov esi, putimage_init24bpp |
4298 | mov esi, putimage_init24bpp |
4290 | ;-------------------------------------- |
4299 | ;-------------------------------------- |
4291 | align 4 |
4300 | align 4 |
4292 | sys_putimage_bpp: |
4301 | sys_putimage_bpp: |
4293 | call vesa20_putimage |
4302 | call vesa20_putimage |
4294 | pop ebp esi ebp |
4303 | pop ebp esi ebp |
4295 | ret |
4304 | ret |
4296 | ; jmp [draw_pointer] |
4305 | ; jmp [draw_pointer] |
4297 | ;----------------------------------------------------------------------------- |
4306 | ;----------------------------------------------------------------------------- |
4298 | align 4 |
4307 | align 4 |
4299 | sys_putimage_palette: |
4308 | sys_putimage_palette: |
4300 | ; ebx = pointer to image |
4309 | ; ebx = pointer to image |
4301 | ; ecx = [xsize]*65536 + [ysize] |
4310 | ; ecx = [xsize]*65536 + [ysize] |
4302 | ; edx = [xstart]*65536 + [ystart] |
4311 | ; edx = [xstart]*65536 + [ystart] |
4303 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4312 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4304 | ; edi = pointer to palette |
4313 | ; edi = pointer to palette |
4305 | ; ebp = row delta |
4314 | ; ebp = row delta |
4306 | mov eax, [CURRENT_TASK] |
4315 | mov eax, [CURRENT_TASK] |
4307 | shl eax, 8 |
4316 | shl eax, 8 |
4308 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4317 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4309 | rol edx, 16 |
4318 | rol edx, 16 |
4310 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4319 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4311 | rol edx, 16 |
4320 | rol edx, 16 |
4312 | ;-------------------------------------- |
4321 | ;-------------------------------------- |
4313 | align 4 |
4322 | align 4 |
4314 | .forced: |
4323 | .forced: |
4315 | cmp esi, 1 |
4324 | cmp esi, 1 |
4316 | jnz @f |
4325 | jnz @f |
4317 | push edi |
4326 | push edi |
4318 | mov eax, [edi+4] |
4327 | mov eax, [edi+4] |
4319 | sub eax, [edi] |
4328 | sub eax, [edi] |
4320 | push eax |
4329 | push eax |
4321 | push dword [edi] |
4330 | push dword [edi] |
4322 | push 0ffffff80h |
4331 | push 0ffffff80h |
4323 | mov edi, esp |
4332 | mov edi, esp |
4324 | call put_mono_image |
4333 | call put_mono_image |
4325 | add esp, 12 |
4334 | add esp, 12 |
4326 | pop edi |
4335 | pop edi |
4327 | ret |
4336 | ret |
4328 | ;-------------------------------------- |
4337 | ;-------------------------------------- |
4329 | align 4 |
4338 | align 4 |
4330 | @@: |
4339 | @@: |
4331 | cmp esi, 2 |
4340 | cmp esi, 2 |
4332 | jnz @f |
4341 | jnz @f |
4333 | push edi |
4342 | push edi |
4334 | push 0ffffff80h |
4343 | push 0ffffff80h |
4335 | mov edi, esp |
4344 | mov edi, esp |
4336 | call put_2bit_image |
4345 | call put_2bit_image |
4337 | pop eax |
4346 | pop eax |
4338 | pop edi |
4347 | pop edi |
4339 | ret |
4348 | ret |
4340 | ;-------------------------------------- |
4349 | ;-------------------------------------- |
4341 | align 4 |
4350 | align 4 |
4342 | @@: |
4351 | @@: |
4343 | cmp esi, 4 |
4352 | cmp esi, 4 |
4344 | jnz @f |
4353 | jnz @f |
4345 | push edi |
4354 | push edi |
4346 | push 0ffffff80h |
4355 | push 0ffffff80h |
4347 | mov edi, esp |
4356 | mov edi, esp |
4348 | call put_4bit_image |
4357 | call put_4bit_image |
4349 | pop eax |
4358 | pop eax |
4350 | pop edi |
4359 | pop edi |
4351 | ret |
4360 | ret |
4352 | ;-------------------------------------- |
4361 | ;-------------------------------------- |
4353 | align 4 |
4362 | align 4 |
4354 | @@: |
4363 | @@: |
4355 | push ebp esi ebp |
4364 | push ebp esi ebp |
4356 | cmp esi, 8 |
4365 | cmp esi, 8 |
4357 | jnz @f |
4366 | jnz @f |
4358 | mov ebp, putimage_get8bpp |
4367 | mov ebp, putimage_get8bpp |
4359 | mov esi, putimage_init8bpp |
4368 | mov esi, putimage_init8bpp |
4360 | jmp sys_putimage_bpp |
4369 | jmp sys_putimage_bpp |
4361 | ;-------------------------------------- |
4370 | ;-------------------------------------- |
4362 | align 4 |
4371 | align 4 |
4363 | @@: |
4372 | @@: |
4364 | cmp esi, 9 |
4373 | cmp esi, 9 |
4365 | jnz @f |
4374 | jnz @f |
4366 | mov ebp, putimage_get9bpp |
4375 | mov ebp, putimage_get9bpp |
4367 | mov esi, putimage_init9bpp |
4376 | mov esi, putimage_init9bpp |
4368 | jmp sys_putimage_bpp |
4377 | jmp sys_putimage_bpp |
4369 | ;-------------------------------------- |
4378 | ;-------------------------------------- |
4370 | align 4 |
4379 | align 4 |
4371 | @@: |
4380 | @@: |
4372 | cmp esi, 15 |
4381 | cmp esi, 15 |
4373 | jnz @f |
4382 | jnz @f |
4374 | mov ebp, putimage_get15bpp |
4383 | mov ebp, putimage_get15bpp |
4375 | mov esi, putimage_init15bpp |
4384 | mov esi, putimage_init15bpp |
4376 | jmp sys_putimage_bpp |
4385 | jmp sys_putimage_bpp |
4377 | ;-------------------------------------- |
4386 | ;-------------------------------------- |
4378 | align 4 |
4387 | align 4 |
4379 | @@: |
4388 | @@: |
4380 | cmp esi, 16 |
4389 | cmp esi, 16 |
4381 | jnz @f |
4390 | jnz @f |
4382 | mov ebp, putimage_get16bpp |
4391 | mov ebp, putimage_get16bpp |
4383 | mov esi, putimage_init16bpp |
4392 | mov esi, putimage_init16bpp |
4384 | jmp sys_putimage_bpp |
4393 | jmp sys_putimage_bpp |
4385 | ;-------------------------------------- |
4394 | ;-------------------------------------- |
4386 | align 4 |
4395 | align 4 |
4387 | @@: |
4396 | @@: |
4388 | cmp esi, 24 |
4397 | cmp esi, 24 |
4389 | jnz @f |
4398 | jnz @f |
4390 | mov ebp, putimage_get24bpp |
4399 | mov ebp, putimage_get24bpp |
4391 | mov esi, putimage_init24bpp |
4400 | mov esi, putimage_init24bpp |
4392 | jmp sys_putimage_bpp |
4401 | jmp sys_putimage_bpp |
4393 | ;-------------------------------------- |
4402 | ;-------------------------------------- |
4394 | align 4 |
4403 | align 4 |
4395 | @@: |
4404 | @@: |
4396 | cmp esi, 32 |
4405 | cmp esi, 32 |
4397 | jnz @f |
4406 | jnz @f |
4398 | mov ebp, putimage_get32bpp |
4407 | mov ebp, putimage_get32bpp |
4399 | mov esi, putimage_init32bpp |
4408 | mov esi, putimage_init32bpp |
4400 | jmp sys_putimage_bpp |
4409 | jmp sys_putimage_bpp |
4401 | ;-------------------------------------- |
4410 | ;-------------------------------------- |
4402 | align 4 |
4411 | align 4 |
4403 | @@: |
4412 | @@: |
4404 | pop ebp esi ebp |
4413 | pop ebp esi ebp |
4405 | ret |
4414 | ret |
4406 | ;----------------------------------------------------------------------------- |
4415 | ;----------------------------------------------------------------------------- |
4407 | align 4 |
4416 | align 4 |
4408 | put_mono_image: |
4417 | put_mono_image: |
4409 | push ebp esi ebp |
4418 | push ebp esi ebp |
4410 | mov ebp, putimage_get1bpp |
4419 | mov ebp, putimage_get1bpp |
4411 | mov esi, putimage_init1bpp |
4420 | mov esi, putimage_init1bpp |
4412 | jmp sys_putimage_bpp |
4421 | jmp sys_putimage_bpp |
4413 | ;----------------------------------------------------------------------------- |
4422 | ;----------------------------------------------------------------------------- |
4414 | align 4 |
4423 | align 4 |
4415 | put_2bit_image: |
4424 | put_2bit_image: |
4416 | push ebp esi ebp |
4425 | push ebp esi ebp |
4417 | mov ebp, putimage_get2bpp |
4426 | mov ebp, putimage_get2bpp |
4418 | mov esi, putimage_init2bpp |
4427 | mov esi, putimage_init2bpp |
4419 | jmp sys_putimage_bpp |
4428 | jmp sys_putimage_bpp |
4420 | ;----------------------------------------------------------------------------- |
4429 | ;----------------------------------------------------------------------------- |
4421 | align 4 |
4430 | align 4 |
4422 | put_4bit_image: |
4431 | put_4bit_image: |
4423 | push ebp esi ebp |
4432 | push ebp esi ebp |
4424 | mov ebp, putimage_get4bpp |
4433 | mov ebp, putimage_get4bpp |
4425 | mov esi, putimage_init4bpp |
4434 | mov esi, putimage_init4bpp |
4426 | jmp sys_putimage_bpp |
4435 | jmp sys_putimage_bpp |
4427 | ;----------------------------------------------------------------------------- |
4436 | ;----------------------------------------------------------------------------- |
4428 | align 4 |
4437 | align 4 |
4429 | putimage_init24bpp: |
4438 | putimage_init24bpp: |
4430 | lea eax, [eax*3] |
4439 | lea eax, [eax*3] |
4431 | putimage_init8bpp: |
4440 | putimage_init8bpp: |
4432 | putimage_init9bpp: |
4441 | putimage_init9bpp: |
4433 | ret |
4442 | ret |
4434 | ;----------------------------------------------------------------------------- |
4443 | ;----------------------------------------------------------------------------- |
4435 | align 16 |
4444 | align 16 |
4436 | putimage_get24bpp: |
4445 | putimage_get24bpp: |
4437 | movzx eax, byte [esi+2] |
4446 | movzx eax, byte [esi+2] |
4438 | shl eax, 16 |
4447 | shl eax, 16 |
4439 | mov ax, [esi] |
4448 | mov ax, [esi] |
4440 | add esi, 3 |
4449 | add esi, 3 |
4441 | ret 4 |
4450 | ret 4 |
4442 | ;----------------------------------------------------------------------------- |
4451 | ;----------------------------------------------------------------------------- |
4443 | align 16 |
4452 | align 16 |
4444 | putimage_get8bpp: |
4453 | putimage_get8bpp: |
4445 | movzx eax, byte [esi] |
4454 | movzx eax, byte [esi] |
4446 | push edx |
4455 | push edx |
4447 | mov edx, [esp+8] |
4456 | mov edx, [esp+8] |
4448 | mov eax, [edx+eax*4] |
4457 | mov eax, [edx+eax*4] |
4449 | pop edx |
4458 | pop edx |
4450 | inc esi |
4459 | inc esi |
4451 | ret 4 |
4460 | ret 4 |
4452 | ;----------------------------------------------------------------------------- |
4461 | ;----------------------------------------------------------------------------- |
4453 | align 16 |
4462 | align 16 |
4454 | putimage_get9bpp: |
4463 | putimage_get9bpp: |
4455 | lodsb |
4464 | lodsb |
4456 | mov ah, al |
4465 | mov ah, al |
4457 | shl eax, 8 |
4466 | shl eax, 8 |
4458 | mov al, ah |
4467 | mov al, ah |
4459 | ret 4 |
4468 | ret 4 |
4460 | ;----------------------------------------------------------------------------- |
4469 | ;----------------------------------------------------------------------------- |
4461 | align 4 |
4470 | align 4 |
4462 | putimage_init1bpp: |
4471 | putimage_init1bpp: |
4463 | add eax, ecx |
4472 | add eax, ecx |
4464 | push ecx |
4473 | push ecx |
4465 | add eax, 7 |
4474 | add eax, 7 |
4466 | add ecx, 7 |
4475 | add ecx, 7 |
4467 | shr eax, 3 |
4476 | shr eax, 3 |
4468 | shr ecx, 3 |
4477 | shr ecx, 3 |
4469 | sub eax, ecx |
4478 | sub eax, ecx |
4470 | pop ecx |
4479 | pop ecx |
4471 | ret |
4480 | ret |
4472 | ;----------------------------------------------------------------------------- |
4481 | ;----------------------------------------------------------------------------- |
4473 | align 16 |
4482 | align 16 |
4474 | putimage_get1bpp: |
4483 | putimage_get1bpp: |
4475 | push edx |
4484 | push edx |
4476 | mov edx, [esp+8] |
4485 | mov edx, [esp+8] |
4477 | mov al, [edx] |
4486 | mov al, [edx] |
4478 | add al, al |
4487 | add al, al |
4479 | jnz @f |
4488 | jnz @f |
4480 | lodsb |
4489 | lodsb |
4481 | adc al, al |
4490 | adc al, al |
4482 | @@: |
4491 | @@: |
4483 | mov [edx], al |
4492 | mov [edx], al |
4484 | sbb eax, eax |
4493 | sbb eax, eax |
4485 | and eax, [edx+8] |
4494 | and eax, [edx+8] |
4486 | add eax, [edx+4] |
4495 | add eax, [edx+4] |
4487 | pop edx |
4496 | pop edx |
4488 | ret 4 |
4497 | ret 4 |
4489 | ;----------------------------------------------------------------------------- |
4498 | ;----------------------------------------------------------------------------- |
4490 | align 4 |
4499 | align 4 |
4491 | putimage_init2bpp: |
4500 | putimage_init2bpp: |
4492 | add eax, ecx |
4501 | add eax, ecx |
4493 | push ecx |
4502 | push ecx |
4494 | add ecx, 3 |
4503 | add ecx, 3 |
4495 | add eax, 3 |
4504 | add eax, 3 |
4496 | shr ecx, 2 |
4505 | shr ecx, 2 |
4497 | shr eax, 2 |
4506 | shr eax, 2 |
4498 | sub eax, ecx |
4507 | sub eax, ecx |
4499 | pop ecx |
4508 | pop ecx |
4500 | ret |
4509 | ret |
4501 | ;----------------------------------------------------------------------------- |
4510 | ;----------------------------------------------------------------------------- |
4502 | align 16 |
4511 | align 16 |
4503 | putimage_get2bpp: |
4512 | putimage_get2bpp: |
4504 | push edx |
4513 | push edx |
4505 | mov edx, [esp+8] |
4514 | mov edx, [esp+8] |
4506 | mov al, [edx] |
4515 | mov al, [edx] |
4507 | mov ah, al |
4516 | mov ah, al |
4508 | shr al, 6 |
4517 | shr al, 6 |
4509 | shl ah, 2 |
4518 | shl ah, 2 |
4510 | jnz .nonewbyte |
4519 | jnz .nonewbyte |
4511 | lodsb |
4520 | lodsb |
4512 | mov ah, al |
4521 | mov ah, al |
4513 | shr al, 6 |
4522 | shr al, 6 |
4514 | shl ah, 2 |
4523 | shl ah, 2 |
4515 | add ah, 1 |
4524 | add ah, 1 |
4516 | .nonewbyte: |
4525 | .nonewbyte: |
4517 | mov [edx], ah |
4526 | mov [edx], ah |
4518 | mov edx, [edx+4] |
4527 | mov edx, [edx+4] |
4519 | movzx eax, al |
4528 | movzx eax, al |
4520 | mov eax, [edx+eax*4] |
4529 | mov eax, [edx+eax*4] |
4521 | pop edx |
4530 | pop edx |
4522 | ret 4 |
4531 | ret 4 |
4523 | ;----------------------------------------------------------------------------- |
4532 | ;----------------------------------------------------------------------------- |
4524 | align 4 |
4533 | align 4 |
4525 | putimage_init4bpp: |
4534 | putimage_init4bpp: |
4526 | add eax, ecx |
4535 | add eax, ecx |
4527 | push ecx |
4536 | push ecx |
4528 | add ecx, 1 |
4537 | add ecx, 1 |
4529 | add eax, 1 |
4538 | add eax, 1 |
4530 | shr ecx, 1 |
4539 | shr ecx, 1 |
4531 | shr eax, 1 |
4540 | shr eax, 1 |
4532 | sub eax, ecx |
4541 | sub eax, ecx |
4533 | pop ecx |
4542 | pop ecx |
4534 | ret |
4543 | ret |
4535 | ;----------------------------------------------------------------------------- |
4544 | ;----------------------------------------------------------------------------- |
4536 | align 16 |
4545 | align 16 |
4537 | putimage_get4bpp: |
4546 | putimage_get4bpp: |
4538 | push edx |
4547 | push edx |
4539 | mov edx, [esp+8] |
4548 | mov edx, [esp+8] |
4540 | add byte [edx], 80h |
4549 | add byte [edx], 80h |
4541 | jc @f |
4550 | jc @f |
4542 | movzx eax, byte [edx+1] |
4551 | movzx eax, byte [edx+1] |
4543 | mov edx, [edx+4] |
4552 | mov edx, [edx+4] |
4544 | and eax, 0x0F |
4553 | and eax, 0x0F |
4545 | mov eax, [edx+eax*4] |
4554 | mov eax, [edx+eax*4] |
4546 | pop edx |
4555 | pop edx |
4547 | ret 4 |
4556 | ret 4 |
4548 | @@: |
4557 | @@: |
4549 | movzx eax, byte [esi] |
4558 | movzx eax, byte [esi] |
4550 | add esi, 1 |
4559 | add esi, 1 |
4551 | mov [edx+1], al |
4560 | mov [edx+1], al |
4552 | shr eax, 4 |
4561 | shr eax, 4 |
4553 | mov edx, [edx+4] |
4562 | mov edx, [edx+4] |
4554 | mov eax, [edx+eax*4] |
4563 | mov eax, [edx+eax*4] |
4555 | pop edx |
4564 | pop edx |
4556 | ret 4 |
4565 | ret 4 |
4557 | ;----------------------------------------------------------------------------- |
4566 | ;----------------------------------------------------------------------------- |
4558 | align 4 |
4567 | align 4 |
4559 | putimage_init32bpp: |
4568 | putimage_init32bpp: |
4560 | shl eax, 2 |
4569 | shl eax, 2 |
4561 | ret |
4570 | ret |
4562 | ;----------------------------------------------------------------------------- |
4571 | ;----------------------------------------------------------------------------- |
4563 | align 16 |
4572 | align 16 |
4564 | putimage_get32bpp: |
4573 | putimage_get32bpp: |
4565 | lodsd |
4574 | lodsd |
4566 | ret 4 |
4575 | ret 4 |
4567 | ;----------------------------------------------------------------------------- |
4576 | ;----------------------------------------------------------------------------- |
4568 | align 4 |
4577 | align 4 |
4569 | putimage_init15bpp: |
4578 | putimage_init15bpp: |
4570 | putimage_init16bpp: |
4579 | putimage_init16bpp: |
4571 | add eax, eax |
4580 | add eax, eax |
4572 | ret |
4581 | ret |
4573 | ;----------------------------------------------------------------------------- |
4582 | ;----------------------------------------------------------------------------- |
4574 | align 16 |
4583 | align 16 |
4575 | putimage_get15bpp: |
4584 | putimage_get15bpp: |
4576 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4585 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4577 | push ecx edx |
4586 | push ecx edx |
4578 | movzx eax, word [esi] |
4587 | movzx eax, word [esi] |
4579 | add esi, 2 |
4588 | add esi, 2 |
4580 | mov ecx, eax |
4589 | mov ecx, eax |
4581 | mov edx, eax |
4590 | mov edx, eax |
4582 | and eax, 0x1F |
4591 | and eax, 0x1F |
4583 | and ecx, 0x1F shl 5 |
4592 | and ecx, 0x1F shl 5 |
4584 | and edx, 0x1F shl 10 |
4593 | and edx, 0x1F shl 10 |
4585 | shl eax, 3 |
4594 | shl eax, 3 |
4586 | shl ecx, 6 |
4595 | shl ecx, 6 |
4587 | shl edx, 9 |
4596 | shl edx, 9 |
4588 | or eax, ecx |
4597 | or eax, ecx |
4589 | or eax, edx |
4598 | or eax, edx |
4590 | pop edx ecx |
4599 | pop edx ecx |
4591 | ret 4 |
4600 | ret 4 |
4592 | ;----------------------------------------------------------------------------- |
4601 | ;----------------------------------------------------------------------------- |
4593 | align 16 |
4602 | align 16 |
4594 | putimage_get16bpp: |
4603 | putimage_get16bpp: |
4595 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4604 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4596 | push ecx edx |
4605 | push ecx edx |
4597 | movzx eax, word [esi] |
4606 | movzx eax, word [esi] |
4598 | add esi, 2 |
4607 | add esi, 2 |
4599 | mov ecx, eax |
4608 | mov ecx, eax |
4600 | mov edx, eax |
4609 | mov edx, eax |
4601 | and eax, 0x1F |
4610 | and eax, 0x1F |
4602 | and ecx, 0x3F shl 5 |
4611 | and ecx, 0x3F shl 5 |
4603 | and edx, 0x1F shl 11 |
4612 | and edx, 0x1F shl 11 |
4604 | shl eax, 3 |
4613 | shl eax, 3 |
4605 | shl ecx, 5 |
4614 | shl ecx, 5 |
4606 | shl edx, 8 |
4615 | shl edx, 8 |
4607 | or eax, ecx |
4616 | or eax, ecx |
4608 | or eax, edx |
4617 | or eax, edx |
4609 | pop edx ecx |
4618 | pop edx ecx |
4610 | ret 4 |
4619 | ret 4 |
4611 | ;----------------------------------------------------------------------------- |
4620 | ;----------------------------------------------------------------------------- |
4612 | ;align 4 |
4621 | ;align 4 |
4613 | ; eax x beginning |
4622 | ; eax x beginning |
4614 | ; ebx y beginning |
4623 | ; ebx y beginning |
4615 | ; ecx x end |
4624 | ; ecx x end |
4616 | ; edx y end |
4625 | ; edx y end |
4617 | ; edi color |
4626 | ; edi color |
4618 | ;__sys_drawbar: |
4627 | ;__sys_drawbar: |
4619 | ; mov esi, [current_slot] |
4628 | ; mov esi, [current_slot] |
4620 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4629 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4621 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4630 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4622 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4631 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4623 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4632 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4624 | ;-------------------------------------- |
4633 | ;-------------------------------------- |
4625 | ;align 4 |
4634 | ;align 4 |
4626 | ;.forced: |
4635 | ;.forced: |
4627 | ; call vesa20_drawbar |
4636 | ; call vesa20_drawbar |
4628 | ; call [draw_pointer] |
4637 | ; call [draw_pointer] |
4629 | ; ret |
4638 | ; ret |
4630 | ;----------------------------------------------------------------------------- |
4639 | ;----------------------------------------------------------------------------- |
4631 | align 4 |
4640 | align 4 |
4632 | kb_write_wait_ack: |
4641 | kb_write_wait_ack: |
4633 | 4642 | ||
4634 | push ecx edx |
4643 | push ecx edx |
4635 | 4644 | ||
4636 | mov dl, al |
4645 | mov dl, al |
4637 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4646 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4638 | .wait_output_ready: |
4647 | .wait_output_ready: |
4639 | in al, 0x64 |
4648 | in al, 0x64 |
4640 | test al, 2 |
4649 | test al, 2 |
4641 | jz @f |
4650 | jz @f |
4642 | loop .wait_output_ready |
4651 | loop .wait_output_ready |
4643 | mov ah, 1 |
4652 | mov ah, 1 |
4644 | jmp .nothing |
4653 | jmp .nothing |
4645 | @@: |
4654 | @@: |
4646 | mov al, dl |
4655 | mov al, dl |
4647 | out 0x60, al |
4656 | out 0x60, al |
4648 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4657 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4649 | .wait_ack: |
4658 | .wait_ack: |
4650 | in al, 0x64 |
4659 | in al, 0x64 |
4651 | test al, 1 |
4660 | test al, 1 |
4652 | jnz @f |
4661 | jnz @f |
4653 | loop .wait_ack |
4662 | loop .wait_ack |
4654 | mov ah, 1 |
4663 | mov ah, 1 |
4655 | jmp .nothing |
4664 | jmp .nothing |
4656 | @@: |
4665 | @@: |
4657 | in al, 0x60 |
4666 | in al, 0x60 |
4658 | xor ah, ah |
4667 | xor ah, ah |
4659 | 4668 | ||
4660 | .nothing: |
4669 | .nothing: |
4661 | pop edx ecx |
4670 | pop edx ecx |
4662 | 4671 | ||
4663 | ret |
4672 | ret |
4664 | ;----------------------------------------------------------------------------- |
4673 | ;----------------------------------------------------------------------------- |
4665 | 4674 | ||
4666 | setmouse: ; set mousepicture -pointer |
4675 | setmouse: ; set mousepicture -pointer |
4667 | ; ps2 mouse enable |
4676 | ; ps2 mouse enable |
4668 | 4677 | ||
4669 | ; mov [MOUSE_PICTURE], dword mousepointer |
4678 | ; mov [MOUSE_PICTURE], dword mousepointer |
4670 | 4679 | ||
4671 | cli |
4680 | cli |
4672 | 4681 | ||
4673 | ret |
4682 | ret |
4674 | 4683 | ||
4675 | if used _rdtsc |
4684 | if used _rdtsc |
4676 | _rdtsc: |
4685 | _rdtsc: |
4677 | bt [cpu_caps], CAPS_TSC |
4686 | bt [cpu_caps], CAPS_TSC |
4678 | jnc ret_rdtsc |
4687 | jnc ret_rdtsc |
4679 | rdtsc |
4688 | rdtsc |
4680 | ret |
4689 | ret |
4681 | ret_rdtsc: |
4690 | ret_rdtsc: |
4682 | mov edx, 0xffffffff |
4691 | mov edx, 0xffffffff |
4683 | mov eax, 0xffffffff |
4692 | mov eax, 0xffffffff |
4684 | ret |
4693 | ret |
4685 | end if |
4694 | end if |
4686 | 4695 | ||
4687 | sys_msg_board_str: |
4696 | sys_msg_board_str: |
4688 | 4697 | ||
4689 | pushad |
4698 | pushad |
4690 | @@: |
4699 | @@: |
4691 | cmp [esi], byte 0 |
4700 | cmp [esi], byte 0 |
4692 | je @f |
4701 | je @f |
4693 | mov ebx, 1 |
4702 | mov ebx, 1 |
4694 | movzx ecx, byte [esi] |
4703 | movzx ecx, byte [esi] |
4695 | call sys_msg_board |
4704 | call sys_msg_board |
4696 | inc esi |
4705 | inc esi |
4697 | jmp @b |
4706 | jmp @b |
4698 | @@: |
4707 | @@: |
4699 | popad |
4708 | popad |
4700 | ret |
4709 | ret |
4701 | 4710 | ||
4702 | sys_msg_board_byte: |
4711 | sys_msg_board_byte: |
4703 | ; in: al = byte to display |
4712 | ; in: al = byte to display |
4704 | ; out: nothing |
4713 | ; out: nothing |
4705 | ; destroys: nothing |
4714 | ; destroys: nothing |
4706 | pushad |
4715 | pushad |
4707 | mov ecx, 2 |
4716 | mov ecx, 2 |
4708 | shl eax, 24 |
4717 | shl eax, 24 |
4709 | jmp @f |
4718 | jmp @f |
4710 | 4719 | ||
4711 | sys_msg_board_word: |
4720 | sys_msg_board_word: |
4712 | ; in: ax = word to display |
4721 | ; in: ax = word to display |
4713 | ; out: nothing |
4722 | ; out: nothing |
4714 | ; destroys: nothing |
4723 | ; destroys: nothing |
4715 | pushad |
4724 | pushad |
4716 | mov ecx, 4 |
4725 | mov ecx, 4 |
4717 | shl eax, 16 |
4726 | shl eax, 16 |
4718 | jmp @f |
4727 | jmp @f |
4719 | 4728 | ||
4720 | sys_msg_board_dword: |
4729 | sys_msg_board_dword: |
4721 | ; in: eax = dword to display |
4730 | ; in: eax = dword to display |
4722 | ; out: nothing |
4731 | ; out: nothing |
4723 | ; destroys: nothing |
4732 | ; destroys: nothing |
4724 | pushad |
4733 | pushad |
4725 | mov ecx, 8 |
4734 | mov ecx, 8 |
4726 | @@: |
4735 | @@: |
4727 | push ecx |
4736 | push ecx |
4728 | rol eax, 4 |
4737 | rol eax, 4 |
4729 | push eax |
4738 | push eax |
4730 | and al, 0xF |
4739 | and al, 0xF |
4731 | cmp al, 10 |
4740 | cmp al, 10 |
4732 | sbb al, 69h |
4741 | sbb al, 69h |
4733 | das |
4742 | das |
4734 | mov cl, al |
4743 | mov cl, al |
4735 | xor ebx, ebx |
4744 | xor ebx, ebx |
4736 | inc ebx |
4745 | inc ebx |
4737 | call sys_msg_board |
4746 | call sys_msg_board |
4738 | pop eax |
4747 | pop eax |
4739 | pop ecx |
4748 | pop ecx |
4740 | loop @b |
4749 | loop @b |
4741 | popad |
4750 | popad |
4742 | ret |
4751 | ret |
4743 | 4752 | ||
4744 | msg_board_data_size = 65536 ; Must be power of two |
4753 | msg_board_data_size = 65536 ; Must be power of two |
4745 | 4754 | ||
4746 | uglobal |
4755 | uglobal |
4747 | msg_board_data rb msg_board_data_size |
4756 | msg_board_data rb msg_board_data_size |
4748 | msg_board_count dd 0x0 |
4757 | msg_board_count dd 0x0 |
4749 | endg |
4758 | endg |
4750 | 4759 | ||
4751 | sys_msg_board: |
4760 | sys_msg_board: |
4752 | 4761 | ||
4753 | ; ebx=1 : write : bl byte to write |
4762 | ; ebx=1 : write : bl byte to write |
4754 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4763 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4755 | 4764 | ||
4756 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4765 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4757 | mov eax, ebx |
4766 | mov eax, ebx |
4758 | mov ebx, ecx |
4767 | mov ebx, ecx |
4759 | 4768 | ||
4760 | mov ecx, [msg_board_count] |
4769 | mov ecx, [msg_board_count] |
4761 | cmp eax, 1 |
4770 | cmp eax, 1 |
4762 | jne .smbl1 |
4771 | jne .smbl1 |
4763 | 4772 | ||
4764 | if defined debug_com_base |
4773 | if defined debug_com_base |
4765 | 4774 | ||
4766 | push dx ax |
4775 | push dx ax |
4767 | 4776 | ||
4768 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4777 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4769 | mov dx, debug_com_base+5 |
4778 | mov dx, debug_com_base+5 |
4770 | in al, dx |
4779 | in al, dx |
4771 | test al, 1 shl 5 |
4780 | test al, 1 shl 5 |
4772 | jz @r |
4781 | jz @r |
4773 | 4782 | ||
4774 | mov dx, debug_com_base ; Output the byte |
4783 | mov dx, debug_com_base ; Output the byte |
4775 | mov al, bl |
4784 | mov al, bl |
4776 | out dx, al |
4785 | out dx, al |
4777 | 4786 | ||
4778 | pop ax dx |
4787 | pop ax dx |
4779 | 4788 | ||
4780 | end if |
4789 | end if |
4781 | 4790 | ||
4782 | mov [msg_board_data+ecx], bl |
4791 | mov [msg_board_data+ecx], bl |
4783 | ; // if debug_direct_print == 1 |
4792 | ; // if debug_direct_print == 1 |
4784 | cmp byte [debug_direct_print], 1 |
4793 | cmp byte [debug_direct_print], 1 |
4785 | jnz @f |
4794 | jnz @f |
4786 | pusha |
4795 | pusha |
4787 | iglobal |
4796 | iglobal |
4788 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4797 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4789 | endg |
4798 | endg |
4790 | lea edx, [msg_board_data+ecx] |
4799 | lea edx, [msg_board_data+ecx] |
4791 | mov ecx, 0x40FFFFFF |
4800 | mov ecx, 0x40FFFFFF |
4792 | mov ebx, [msg_board_pos] |
4801 | mov ebx, [msg_board_pos] |
4793 | mov edi, 1 |
4802 | mov edi, 1 |
4794 | mov esi, 1 |
4803 | mov esi, 1 |
4795 | call dtext |
4804 | call dtext |
4796 | popa |
4805 | popa |
4797 | add word [msg_board_pos+2], 6 |
4806 | add word [msg_board_pos+2], 6 |
4798 | cmp bl, 10 |
4807 | cmp bl, 10 |
4799 | jnz @f |
4808 | jnz @f |
4800 | mov word [msg_board_pos+2], (42*6) |
4809 | mov word [msg_board_pos+2], (42*6) |
4801 | add word [msg_board_pos], 10 |
4810 | add word [msg_board_pos], 10 |
4802 | mov ax, word [_display.width] |
4811 | mov ax, word [_display.width] |
4803 | cmp word [msg_board_pos], ax |
4812 | cmp word [msg_board_pos], ax |
4804 | jb @f |
4813 | jb @f |
4805 | mov word [msg_board_pos], 10 |
4814 | mov word [msg_board_pos], 10 |
4806 | @@: |
4815 | @@: |
4807 | ; // end if |
4816 | ; // end if |
4808 | 4817 | ||
4809 | if 0 |
4818 | if 0 |
4810 | pusha |
4819 | pusha |
4811 | mov al, bl |
4820 | mov al, bl |
4812 | mov edx, 402h |
4821 | mov edx, 402h |
4813 | out dx, al |
4822 | out dx, al |
4814 | popa |
4823 | popa |
4815 | end if |
4824 | end if |
4816 | inc ecx |
4825 | inc ecx |
4817 | and ecx, msg_board_data_size - 1 |
4826 | and ecx, msg_board_data_size - 1 |
4818 | mov [msg_board_count], ecx |
4827 | mov [msg_board_count], ecx |
4819 | 4828 | ||
4820 | pop ebx eax |
4829 | pop ebx eax |
4821 | ret |
4830 | ret |
4822 | .smbl1: |
4831 | .smbl1: |
4823 | cmp eax, 2 |
4832 | cmp eax, 2 |
4824 | jne .smbl2 |
4833 | jne .smbl2 |
4825 | test ecx, ecx |
4834 | test ecx, ecx |
4826 | jz .smbl21 |
4835 | jz .smbl21 |
4827 | 4836 | ||
4828 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4837 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4829 | mov eax, msg_board_data+1 |
4838 | mov eax, msg_board_data+1 |
4830 | mov ebx, msg_board_data |
4839 | mov ebx, msg_board_data |
4831 | movzx edx, byte [ebx] |
4840 | movzx edx, byte [ebx] |
4832 | call memmove |
4841 | call memmove |
4833 | dec [msg_board_count] |
4842 | dec [msg_board_count] |
4834 | mov [esp + 32], edx ;eax |
4843 | mov [esp + 32], edx ;eax |
4835 | mov [esp + 20], dword 1 |
4844 | mov [esp + 20], dword 1 |
4836 | ret |
4845 | ret |
4837 | .smbl21: |
4846 | .smbl21: |
4838 | mov [esp+32], ecx |
4847 | mov [esp+32], ecx |
4839 | mov [esp+20], ecx |
4848 | mov [esp+20], ecx |
4840 | .smbl2: |
4849 | .smbl2: |
4841 | pop ebx eax |
4850 | pop ebx eax |
4842 | ret |
4851 | ret |
4843 | 4852 | ||
4844 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4853 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4845 | ;; 66 sys function. ;; |
4854 | ;; 66 sys function. ;; |
4846 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4855 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4847 | ;; out eax ;; |
4856 | ;; out eax ;; |
4848 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4857 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4849 | iglobal |
4858 | iglobal |
4850 | align 4 |
4859 | align 4 |
4851 | f66call: |
4860 | f66call: |
4852 | dd sys_process_def.1 ; 1 = set keyboard mode |
4861 | dd sys_process_def.1 ; 1 = set keyboard mode |
4853 | dd sys_process_def.2 ; 2 = get keyboard mode |
4862 | dd sys_process_def.2 ; 2 = get keyboard mode |
4854 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4863 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4855 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4864 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4856 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4865 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4857 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4866 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4858 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4867 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4859 | endg |
4868 | endg |
4860 | ;----------------------------------------------------------------------------- |
4869 | ;----------------------------------------------------------------------------- |
4861 | align 4 |
4870 | align 4 |
4862 | sys_process_def: |
4871 | sys_process_def: |
4863 | dec ebx |
4872 | dec ebx |
4864 | cmp ebx, 7 |
4873 | cmp ebx, 7 |
4865 | jae .not_support ;if >=8 then or eax,-1 |
4874 | jae .not_support ;if >=8 then or eax,-1 |
4866 | 4875 | ||
4867 | mov edi, [CURRENT_TASK] |
4876 | mov edi, [CURRENT_TASK] |
4868 | jmp dword [f66call+ebx*4] |
4877 | jmp dword [f66call+ebx*4] |
4869 | 4878 | ||
4870 | .not_support: |
4879 | .not_support: |
4871 | or eax, -1 |
4880 | or eax, -1 |
4872 | ret |
4881 | ret |
4873 | ;----------------------------------------------------------------------------- |
4882 | ;----------------------------------------------------------------------------- |
4874 | align 4 |
4883 | align 4 |
4875 | .1: |
4884 | .1: |
4876 | shl edi, 8 |
4885 | shl edi, 8 |
4877 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4886 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4878 | 4887 | ||
4879 | ret |
4888 | ret |
4880 | ;----------------------------------------------------------------------------- |
4889 | ;----------------------------------------------------------------------------- |
4881 | align 4 |
4890 | align 4 |
4882 | .2: ; 2 = get keyboard mode |
4891 | .2: ; 2 = get keyboard mode |
4883 | shl edi, 8 |
4892 | shl edi, 8 |
4884 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4893 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4885 | mov [esp+32], eax |
4894 | mov [esp+32], eax |
4886 | ret |
4895 | ret |
4887 | ;----------------------------------------------------------------------------- |
4896 | ;----------------------------------------------------------------------------- |
4888 | align 4 |
4897 | align 4 |
4889 | .3: ;3 = get keyboard ctrl, alt, shift |
4898 | .3: ;3 = get keyboard ctrl, alt, shift |
4890 | mov eax, [kb_state] |
4899 | mov eax, [kb_state] |
4891 | mov [esp+32], eax |
4900 | mov [esp+32], eax |
4892 | ret |
4901 | ret |
4893 | ;----------------------------------------------------------------------------- |
4902 | ;----------------------------------------------------------------------------- |
4894 | align 4 |
4903 | align 4 |
4895 | .4: |
4904 | .4: |
4896 | mov eax, hotkey_list |
4905 | mov eax, hotkey_list |
4897 | @@: |
4906 | @@: |
4898 | cmp dword [eax+8], 0 |
4907 | cmp dword [eax+8], 0 |
4899 | jz .found_free |
4908 | jz .found_free |
4900 | add eax, 16 |
4909 | add eax, 16 |
4901 | cmp eax, hotkey_list+16*256 |
4910 | cmp eax, hotkey_list+16*256 |
4902 | jb @b |
4911 | jb @b |
4903 | mov dword [esp+32], 1 |
4912 | mov dword [esp+32], 1 |
4904 | ret |
4913 | ret |
4905 | .found_free: |
4914 | .found_free: |
4906 | mov [eax+8], edi |
4915 | mov [eax+8], edi |
4907 | mov [eax+4], edx |
4916 | mov [eax+4], edx |
4908 | movzx ecx, cl |
4917 | movzx ecx, cl |
4909 | lea ecx, [hotkey_scancodes+ecx*4] |
4918 | lea ecx, [hotkey_scancodes+ecx*4] |
4910 | mov edx, [ecx] |
4919 | mov edx, [ecx] |
4911 | mov [eax], edx |
4920 | mov [eax], edx |
4912 | mov [ecx], eax |
4921 | mov [ecx], eax |
4913 | mov [eax+12], ecx |
4922 | mov [eax+12], ecx |
4914 | test edx, edx |
4923 | test edx, edx |
4915 | jz @f |
4924 | jz @f |
4916 | mov [edx+12], eax |
4925 | mov [edx+12], eax |
4917 | @@: |
4926 | @@: |
4918 | and dword [esp+32], 0 |
4927 | and dword [esp+32], 0 |
4919 | ret |
4928 | ret |
4920 | ;----------------------------------------------------------------------------- |
4929 | ;----------------------------------------------------------------------------- |
4921 | align 4 |
4930 | align 4 |
4922 | .5: |
4931 | .5: |
4923 | movzx ebx, cl |
4932 | movzx ebx, cl |
4924 | lea ebx, [hotkey_scancodes+ebx*4] |
4933 | lea ebx, [hotkey_scancodes+ebx*4] |
4925 | mov eax, [ebx] |
4934 | mov eax, [ebx] |
4926 | .scan: |
4935 | .scan: |
4927 | test eax, eax |
4936 | test eax, eax |
4928 | jz .notfound |
4937 | jz .notfound |
4929 | cmp [eax+8], edi |
4938 | cmp [eax+8], edi |
4930 | jnz .next |
4939 | jnz .next |
4931 | cmp [eax+4], edx |
4940 | cmp [eax+4], edx |
4932 | jz .found |
4941 | jz .found |
4933 | .next: |
4942 | .next: |
4934 | mov eax, [eax] |
4943 | mov eax, [eax] |
4935 | jmp .scan |
4944 | jmp .scan |
4936 | .notfound: |
4945 | .notfound: |
4937 | mov dword [esp+32], 1 |
4946 | mov dword [esp+32], 1 |
4938 | ret |
4947 | ret |
4939 | .found: |
4948 | .found: |
4940 | mov ecx, [eax] |
4949 | mov ecx, [eax] |
4941 | jecxz @f |
4950 | jecxz @f |
4942 | mov edx, [eax+12] |
4951 | mov edx, [eax+12] |
4943 | mov [ecx+12], edx |
4952 | mov [ecx+12], edx |
4944 | @@: |
4953 | @@: |
4945 | mov ecx, [eax+12] |
4954 | mov ecx, [eax+12] |
4946 | mov edx, [eax] |
4955 | mov edx, [eax] |
4947 | mov [ecx], edx |
4956 | mov [ecx], edx |
4948 | xor edx, edx |
4957 | xor edx, edx |
4949 | mov [eax+4], edx |
4958 | mov [eax+4], edx |
4950 | mov [eax+8], edx |
4959 | mov [eax+8], edx |
4951 | mov [eax+12], edx |
4960 | mov [eax+12], edx |
4952 | mov [eax], edx |
4961 | mov [eax], edx |
4953 | mov [esp+32], edx |
4962 | mov [esp+32], edx |
4954 | ret |
4963 | ret |
4955 | ;----------------------------------------------------------------------------- |
4964 | ;----------------------------------------------------------------------------- |
4956 | align 4 |
4965 | align 4 |
4957 | .6: |
4966 | .6: |
4958 | pushfd |
4967 | pushfd |
4959 | cli |
4968 | cli |
4960 | mov eax, [PID_lock_input] |
4969 | mov eax, [PID_lock_input] |
4961 | test eax, eax |
4970 | test eax, eax |
4962 | jnz @f |
4971 | jnz @f |
4963 | ; get current PID |
4972 | ; get current PID |
4964 | mov eax, [CURRENT_TASK] |
4973 | mov eax, [CURRENT_TASK] |
4965 | shl eax, 5 |
4974 | shl eax, 5 |
4966 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4975 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4967 | ; set current PID for lock input |
4976 | ; set current PID for lock input |
4968 | mov [PID_lock_input], eax |
4977 | mov [PID_lock_input], eax |
4969 | @@: |
4978 | @@: |
4970 | popfd |
4979 | popfd |
4971 | ret |
4980 | ret |
4972 | ;----------------------------------------------------------------------------- |
4981 | ;----------------------------------------------------------------------------- |
4973 | align 4 |
4982 | align 4 |
4974 | .7: |
4983 | .7: |
4975 | mov eax, [PID_lock_input] |
4984 | mov eax, [PID_lock_input] |
4976 | test eax, eax |
4985 | test eax, eax |
4977 | jz @f |
4986 | jz @f |
4978 | ; get current PID |
4987 | ; get current PID |
4979 | mov ebx, [CURRENT_TASK] |
4988 | mov ebx, [CURRENT_TASK] |
4980 | shl ebx, 5 |
4989 | shl ebx, 5 |
4981 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4990 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4982 | ; compare current lock input with current PID |
4991 | ; compare current lock input with current PID |
4983 | cmp ebx, eax |
4992 | cmp ebx, eax |
4984 | jne @f |
4993 | jne @f |
4985 | 4994 | ||
4986 | xor eax, eax |
4995 | xor eax, eax |
4987 | mov [PID_lock_input], eax |
4996 | mov [PID_lock_input], eax |
4988 | @@: |
4997 | @@: |
4989 | ret |
4998 | ret |
4990 | ;----------------------------------------------------------------------------- |
4999 | ;----------------------------------------------------------------------------- |
4991 | uglobal |
5000 | uglobal |
4992 | PID_lock_input dd 0x0 |
5001 | PID_lock_input dd 0x0 |
4993 | endg |
5002 | endg |
4994 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5003 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4995 | ;; 61 sys function. ;; |
5004 | ;; 61 sys function. ;; |
4996 | ;; in eax=61,ebx in [1..3] ;; |
5005 | ;; in eax=61,ebx in [1..3] ;; |
4997 | ;; out eax ;; |
5006 | ;; out eax ;; |
4998 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5007 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4999 | iglobal |
5008 | iglobal |
5000 | align 4 |
5009 | align 4 |
5001 | f61call: |
5010 | f61call: |
5002 | dd sys_gs.1 ; resolution |
5011 | dd sys_gs.1 ; resolution |
5003 | dd sys_gs.2 ; bits per pixel |
5012 | dd sys_gs.2 ; bits per pixel |
5004 | dd sys_gs.3 ; bytes per scanline |
5013 | dd sys_gs.3 ; bytes per scanline |
5005 | endg |
5014 | endg |
5006 | 5015 | ||
5007 | 5016 | ||
5008 | align 4 |
5017 | align 4 |
5009 | 5018 | ||
5010 | sys_gs: ; direct screen access |
5019 | sys_gs: ; direct screen access |
5011 | dec ebx |
5020 | dec ebx |
5012 | cmp ebx, 2 |
5021 | cmp ebx, 2 |
5013 | ja .not_support |
5022 | ja .not_support |
5014 | jmp dword [f61call+ebx*4] |
5023 | jmp dword [f61call+ebx*4] |
5015 | .not_support: |
5024 | .not_support: |
5016 | or [esp+32], dword -1 |
5025 | or [esp+32], dword -1 |
5017 | ret |
5026 | ret |
5018 | 5027 | ||
5019 | 5028 | ||
5020 | .1: ; resolution |
5029 | .1: ; resolution |
5021 | mov eax, [_display.width] |
5030 | mov eax, [_display.width] |
5022 | shl eax, 16 |
5031 | shl eax, 16 |
5023 | mov ax, word [_display.height] |
5032 | mov ax, word [_display.height] |
5024 | mov [esp+32], eax |
5033 | mov [esp+32], eax |
5025 | ret |
5034 | ret |
5026 | .2: ; bits per pixel |
5035 | .2: ; bits per pixel |
5027 | mov eax, [_display.bits_per_pixel] |
5036 | mov eax, [_display.bits_per_pixel] |
5028 | mov [esp+32], eax |
5037 | mov [esp+32], eax |
5029 | ret |
5038 | ret |
5030 | .3: ; bytes per scanline |
5039 | .3: ; bytes per scanline |
5031 | mov eax, [_display.lfb_pitch] |
5040 | mov eax, [_display.lfb_pitch] |
5032 | mov [esp+32], eax |
5041 | mov [esp+32], eax |
5033 | ret |
5042 | ret |
5034 | 5043 | ||
5035 | align 4 ; system functions |
5044 | align 4 ; system functions |
5036 | 5045 | ||
5037 | syscall_setpixel: ; SetPixel |
5046 | syscall_setpixel: ; SetPixel |
5038 | 5047 | ||
5039 | mov eax, ebx |
5048 | mov eax, ebx |
5040 | mov ebx, ecx |
5049 | mov ebx, ecx |
5041 | mov ecx, edx |
5050 | mov ecx, edx |
5042 | mov edx, [TASK_BASE] |
5051 | mov edx, [TASK_BASE] |
5043 | add eax, [edx-twdw+WDATA.box.left] |
5052 | add eax, [edx-twdw+WDATA.box.left] |
5044 | add ebx, [edx-twdw+WDATA.box.top] |
5053 | add ebx, [edx-twdw+WDATA.box.top] |
5045 | mov edi, [current_slot] |
5054 | mov edi, [current_slot] |
5046 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5055 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5047 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5056 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5048 | xor edi, edi ; no force |
5057 | xor edi, edi ; no force |
5049 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5058 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5050 | ; jmp [putpixel] |
5059 | ; jmp [putpixel] |
5051 | jmp __sys_putpixel |
5060 | jmp __sys_putpixel |
5052 | 5061 | ||
5053 | align 4 |
5062 | align 4 |
5054 | 5063 | ||
5055 | syscall_writetext: ; WriteText |
5064 | syscall_writetext: ; WriteText |
5056 | 5065 | ||
5057 | mov eax, [TASK_BASE] |
5066 | mov eax, [TASK_BASE] |
5058 | mov ebp, [eax-twdw+WDATA.box.left] |
5067 | mov ebp, [eax-twdw+WDATA.box.left] |
5059 | push esi |
5068 | push esi |
5060 | mov esi, [current_slot] |
5069 | mov esi, [current_slot] |
5061 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5070 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5062 | shl ebp, 16 |
5071 | shl ebp, 16 |
5063 | add ebp, [eax-twdw+WDATA.box.top] |
5072 | add ebp, [eax-twdw+WDATA.box.top] |
5064 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5073 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5065 | pop esi |
5074 | pop esi |
5066 | test ecx, 0x08000000 ; redirect the output to the user area |
5075 | test ecx, 0x08000000 ; redirect the output to the user area |
5067 | jnz @f |
5076 | jnz @f |
5068 | add ebx, ebp |
5077 | add ebx, ebp |
5069 | align 4 |
5078 | align 4 |
5070 | @@: |
5079 | @@: |
5071 | mov eax, edi |
5080 | mov eax, edi |
5072 | test ecx, 0x08000000 ; redirect the output to the user area |
5081 | test ecx, 0x08000000 ; redirect the output to the user area |
5073 | jnz dtext |
5082 | jnz dtext |
5074 | xor edi, edi |
5083 | xor edi, edi |
5075 | jmp dtext |
5084 | jmp dtext |
5076 | 5085 | ||
5077 | align 4 |
5086 | align 4 |
5078 | 5087 | ||
5079 | syscall_drawrect: ; DrawRect |
5088 | syscall_drawrect: ; DrawRect |
5080 | 5089 | ||
5081 | mov edi, edx ; color + gradient |
5090 | mov edi, edx ; color + gradient |
5082 | and edi, 0x80FFFFFF |
5091 | and edi, 0x80FFFFFF |
5083 | test bx, bx ; x.size |
5092 | test bx, bx ; x.size |
5084 | je .drectr |
5093 | je .drectr |
5085 | test cx, cx ; y.size |
5094 | test cx, cx ; y.size |
5086 | je .drectr |
5095 | je .drectr |
5087 | 5096 | ||
5088 | mov eax, ebx ; bad idea |
5097 | mov eax, ebx ; bad idea |
5089 | mov ebx, ecx |
5098 | mov ebx, ecx |
5090 | 5099 | ||
5091 | movzx ecx, ax ; ecx - x.size |
5100 | movzx ecx, ax ; ecx - x.size |
5092 | shr eax, 16 ; eax - x.coord |
5101 | shr eax, 16 ; eax - x.coord |
5093 | movzx edx, bx ; edx - y.size |
5102 | movzx edx, bx ; edx - y.size |
5094 | shr ebx, 16 ; ebx - y.coord |
5103 | shr ebx, 16 ; ebx - y.coord |
5095 | mov esi, [current_slot] |
5104 | mov esi, [current_slot] |
5096 | 5105 | ||
5097 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5106 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5098 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5107 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5099 | add ecx, eax |
5108 | add ecx, eax |
5100 | add edx, ebx |
5109 | add edx, ebx |
5101 | ; jmp [drawbar] |
5110 | ; jmp [drawbar] |
5102 | jmp vesa20_drawbar |
5111 | jmp vesa20_drawbar |
5103 | .drectr: |
5112 | .drectr: |
5104 | ret |
5113 | ret |
5105 | 5114 | ||
5106 | align 4 |
5115 | align 4 |
5107 | syscall_getscreensize: ; GetScreenSize |
5116 | syscall_getscreensize: ; GetScreenSize |
5108 | mov ax, word [_display.width] |
5117 | mov ax, word [_display.width] |
5109 | dec ax |
5118 | dec ax |
5110 | shl eax, 16 |
5119 | shl eax, 16 |
5111 | mov ax, word [_display.height] |
5120 | mov ax, word [_display.height] |
5112 | dec ax |
5121 | dec ax |
5113 | mov [esp + 32], eax |
5122 | mov [esp + 32], eax |
5114 | ret |
5123 | ret |
5115 | ;----------------------------------------------------------------------------- |
5124 | ;----------------------------------------------------------------------------- |
5116 | align 4 |
5125 | align 4 |
5117 | syscall_cdaudio: |
5126 | syscall_cdaudio: |
5118 | ; ECX - position of CD/DVD-drive |
5127 | ; ECX - position of CD/DVD-drive |
5119 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5128 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5120 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5129 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5121 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5130 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5122 | cmp ecx, 11 |
5131 | cmp ecx, 11 |
5123 | ja .exit |
5132 | ja .exit |
5124 | 5133 | ||
5125 | mov eax, ecx |
5134 | mov eax, ecx |
5126 | shr eax, 2 |
5135 | shr eax, 2 |
5127 | lea eax, [eax*5] |
5136 | lea eax, [eax*5] |
5128 | mov al, [eax+DRIVE_DATA+1] |
5137 | mov al, [eax+DRIVE_DATA+1] |
5129 | 5138 | ||
5130 | push ecx ebx |
5139 | push ecx ebx |
5131 | mov ebx, ecx |
5140 | mov ebx, ecx |
5132 | and ebx, 11b |
5141 | and ebx, 11b |
5133 | shl ebx, 1 |
5142 | shl ebx, 1 |
5134 | mov cl, 6 |
5143 | mov cl, 6 |
5135 | sub cl, bl |
5144 | sub cl, bl |
5136 | shr al, cl |
5145 | shr al, cl |
5137 | test al, 2 ; it's not an ATAPI device |
5146 | test al, 2 ; it's not an ATAPI device |
5138 | pop ebx ecx |
5147 | pop ebx ecx |
5139 | 5148 | ||
5140 | jz .exit |
5149 | jz .exit |
5141 | 5150 | ||
5142 | cmp ebx, 4 |
5151 | cmp ebx, 4 |
5143 | je .eject |
5152 | je .eject |
5144 | 5153 | ||
5145 | cmp ebx, 5 |
5154 | cmp ebx, 5 |
5146 | je .load |
5155 | je .load |
5147 | ;-------------------------------------- |
5156 | ;-------------------------------------- |
5148 | .exit: |
5157 | .exit: |
5149 | ret |
5158 | ret |
5150 | ;-------------------------------------- |
5159 | ;-------------------------------------- |
5151 | .load: |
5160 | .load: |
5152 | call .reserve |
5161 | call .reserve |
5153 | call LoadMedium |
5162 | call LoadMedium |
5154 | jmp .free |
5163 | jmp .free |
5155 | ;-------------------------------------- |
5164 | ;-------------------------------------- |
5156 | .eject: |
5165 | .eject: |
5157 | call .reserve |
5166 | call .reserve |
5158 | call clear_CD_cache |
5167 | call clear_CD_cache |
5159 | call allow_medium_removal |
5168 | call allow_medium_removal |
5160 | call EjectMedium |
5169 | call EjectMedium |
5161 | jmp .free |
5170 | jmp .free |
5162 | ;-------------------------------------- |
5171 | ;-------------------------------------- |
5163 | .reserve: |
5172 | .reserve: |
5164 | call reserve_cd |
5173 | call reserve_cd |
5165 | 5174 | ||
5166 | mov ebx, ecx |
5175 | mov ebx, ecx |
5167 | inc ebx |
5176 | inc ebx |
5168 | mov [cdpos], ebx |
5177 | mov [cdpos], ebx |
5169 | 5178 | ||
5170 | mov eax, ecx |
5179 | mov eax, ecx |
5171 | shr eax, 1 |
5180 | shr eax, 1 |
5172 | and eax, 1 |
5181 | and eax, 1 |
5173 | inc eax |
5182 | inc eax |
5174 | mov [ChannelNumber], ax |
5183 | mov [ChannelNumber], ax |
5175 | mov eax, ecx |
5184 | mov eax, ecx |
5176 | and eax, 1 |
5185 | and eax, 1 |
5177 | mov [DiskNumber], al |
5186 | mov [DiskNumber], al |
5178 | call reserve_cd_channel |
5187 | call reserve_cd_channel |
5179 | ret |
5188 | ret |
5180 | ;-------------------------------------- |
5189 | ;-------------------------------------- |
5181 | .free: |
5190 | .free: |
5182 | call free_cd_channel |
5191 | call free_cd_channel |
5183 | and [cd_status], 0 |
5192 | and [cd_status], 0 |
5184 | ret |
5193 | ret |
5185 | ;----------------------------------------------------------------------------- |
5194 | ;----------------------------------------------------------------------------- |
5186 | align 4 |
5195 | align 4 |
5187 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5196 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5188 | cmp ebx, [_display.width] |
5197 | cmp ebx, [_display.width] |
5189 | jb @f |
5198 | jb @f |
5190 | cmp ecx, [_display.height] |
5199 | cmp ecx, [_display.height] |
5191 | jb @f |
5200 | jb @f |
5192 | xor eax, eax |
5201 | xor eax, eax |
5193 | jmp .store |
5202 | jmp .store |
5194 | ;-------------------------------------- |
5203 | ;-------------------------------------- |
5195 | align 4 |
5204 | align 4 |
5196 | @@: |
5205 | @@: |
5197 | mov eax, [d_width_calc_area + ecx*4] |
5206 | mov eax, [d_width_calc_area + ecx*4] |
5198 | add eax, [_display.win_map] |
5207 | add eax, [_display.win_map] |
5199 | movzx eax, byte[eax+ebx] ; get value for current point |
5208 | movzx eax, byte[eax+ebx] ; get value for current point |
5200 | ;-------------------------------------- |
5209 | ;-------------------------------------- |
5201 | align 4 |
5210 | align 4 |
5202 | .store: |
5211 | .store: |
5203 | mov [esp + 32], eax |
5212 | mov [esp + 32], eax |
5204 | ret |
5213 | ret |
5205 | ;----------------------------------------------------------------------------- |
5214 | ;----------------------------------------------------------------------------- |
5206 | align 4 |
5215 | align 4 |
5207 | syscall_getpixel: ; GetPixel |
5216 | syscall_getpixel: ; GetPixel |
5208 | mov ecx, [_display.width] |
5217 | mov ecx, [_display.width] |
5209 | xor edx, edx |
5218 | xor edx, edx |
5210 | mov eax, ebx |
5219 | mov eax, ebx |
5211 | div ecx |
5220 | div ecx |
5212 | mov ebx, edx |
5221 | mov ebx, edx |
5213 | xchg eax, ebx |
5222 | xchg eax, ebx |
5214 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5223 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5215 | call dword [GETPIXEL]; eax - x, ebx - y |
5224 | call dword [GETPIXEL]; eax - x, ebx - y |
5216 | mov [esp + 32], ecx |
5225 | mov [esp + 32], ecx |
5217 | ret |
5226 | ret |
5218 | ;----------------------------------------------------------------------------- |
5227 | ;----------------------------------------------------------------------------- |
5219 | align 4 |
5228 | align 4 |
5220 | syscall_getarea: |
5229 | syscall_getarea: |
5221 | ;eax = 36 |
5230 | ;eax = 36 |
5222 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5231 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5223 | ;ecx = [size x]*65536 + [size y] |
5232 | ;ecx = [size x]*65536 + [size y] |
5224 | ;edx = [start x]*65536 + [start y] |
5233 | ;edx = [start x]*65536 + [start y] |
5225 | pushad |
5234 | pushad |
5226 | mov edi, ebx |
5235 | mov edi, ebx |
5227 | mov eax, edx |
5236 | mov eax, edx |
5228 | shr eax, 16 |
5237 | shr eax, 16 |
5229 | mov ebx, edx |
5238 | mov ebx, edx |
5230 | and ebx, 0xffff |
5239 | and ebx, 0xffff |
5231 | dec eax |
5240 | dec eax |
5232 | dec ebx |
5241 | dec ebx |
5233 | ; eax - x, ebx - y |
5242 | ; eax - x, ebx - y |
5234 | mov edx, ecx |
5243 | mov edx, ecx |
5235 | 5244 | ||
5236 | shr ecx, 16 |
5245 | shr ecx, 16 |
5237 | and edx, 0xffff |
5246 | and edx, 0xffff |
5238 | mov esi, ecx |
5247 | mov esi, ecx |
5239 | ; ecx - size x, edx - size y |
5248 | ; ecx - size x, edx - size y |
5240 | 5249 | ||
5241 | mov ebp, edx |
5250 | mov ebp, edx |
5242 | dec ebp |
5251 | dec ebp |
5243 | lea ebp, [ebp*3] |
5252 | lea ebp, [ebp*3] |
5244 | 5253 | ||
5245 | imul ebp, esi |
5254 | imul ebp, esi |
5246 | 5255 | ||
5247 | mov esi, ecx |
5256 | mov esi, ecx |
5248 | dec esi |
5257 | dec esi |
5249 | lea esi, [esi*3] |
5258 | lea esi, [esi*3] |
5250 | 5259 | ||
5251 | add ebp, esi |
5260 | add ebp, esi |
5252 | add ebp, edi |
5261 | add ebp, edi |
5253 | 5262 | ||
5254 | add ebx, edx |
5263 | add ebx, edx |
5255 | ;-------------------------------------- |
5264 | ;-------------------------------------- |
5256 | align 4 |
5265 | align 4 |
5257 | .start_y: |
5266 | .start_y: |
5258 | push ecx edx |
5267 | push ecx edx |
5259 | ;-------------------------------------- |
5268 | ;-------------------------------------- |
5260 | align 4 |
5269 | align 4 |
5261 | .start_x: |
5270 | .start_x: |
5262 | push eax ebx ecx |
5271 | push eax ebx ecx |
5263 | add eax, ecx |
5272 | add eax, ecx |
5264 | 5273 | ||
5265 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5274 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5266 | call dword [GETPIXEL]; eax - x, ebx - y |
5275 | call dword [GETPIXEL]; eax - x, ebx - y |
5267 | 5276 | ||
5268 | mov [ebp], cx |
5277 | mov [ebp], cx |
5269 | shr ecx, 16 |
5278 | shr ecx, 16 |
5270 | mov [ebp+2], cl |
5279 | mov [ebp+2], cl |
5271 | 5280 | ||
5272 | pop ecx ebx eax |
5281 | pop ecx ebx eax |
5273 | sub ebp, 3 |
5282 | sub ebp, 3 |
5274 | dec ecx |
5283 | dec ecx |
5275 | jnz .start_x |
5284 | jnz .start_x |
5276 | pop edx ecx |
5285 | pop edx ecx |
5277 | dec ebx |
5286 | dec ebx |
5278 | dec edx |
5287 | dec edx |
5279 | jnz .start_y |
5288 | jnz .start_y |
5280 | popad |
5289 | popad |
5281 | ret |
5290 | ret |
5282 | ;----------------------------------------------------------------------------- |
5291 | ;----------------------------------------------------------------------------- |
5283 | align 4 |
5292 | align 4 |
5284 | syscall_putarea_backgr: |
5293 | syscall_putarea_backgr: |
5285 | ;eax = 25 |
5294 | ;eax = 25 |
5286 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5295 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5287 | ;ecx = [size x]*65536 + [size y] |
5296 | ;ecx = [size x]*65536 + [size y] |
5288 | ;edx = [start x]*65536 + [start y] |
5297 | ;edx = [start x]*65536 + [start y] |
5289 | pushad |
5298 | pushad |
5290 | mov edi, ebx |
5299 | mov edi, ebx |
5291 | mov eax, edx |
5300 | mov eax, edx |
5292 | shr eax, 16 |
5301 | shr eax, 16 |
5293 | mov ebx, edx |
5302 | mov ebx, edx |
5294 | and ebx, 0xffff |
5303 | and ebx, 0xffff |
5295 | dec eax |
5304 | dec eax |
5296 | dec ebx |
5305 | dec ebx |
5297 | ; eax - x, ebx - y |
5306 | ; eax - x, ebx - y |
5298 | mov edx, ecx |
5307 | mov edx, ecx |
5299 | shr ecx, 16 |
5308 | shr ecx, 16 |
5300 | and edx, 0xffff |
5309 | and edx, 0xffff |
5301 | mov esi, ecx |
5310 | mov esi, ecx |
5302 | ; ecx - size x, edx - size y |
5311 | ; ecx - size x, edx - size y |
5303 | mov ebp, edx |
5312 | mov ebp, edx |
5304 | dec ebp |
5313 | dec ebp |
5305 | shl ebp, 2 |
5314 | shl ebp, 2 |
5306 | 5315 | ||
5307 | imul ebp, esi |
5316 | imul ebp, esi |
5308 | 5317 | ||
5309 | mov esi, ecx |
5318 | mov esi, ecx |
5310 | dec esi |
5319 | dec esi |
5311 | shl esi, 2 |
5320 | shl esi, 2 |
5312 | 5321 | ||
5313 | add ebp, esi |
5322 | add ebp, esi |
5314 | add ebp, edi |
5323 | add ebp, edi |
5315 | 5324 | ||
5316 | add ebx, edx |
5325 | add ebx, edx |
5317 | ;-------------------------------------- |
5326 | ;-------------------------------------- |
5318 | align 4 |
5327 | align 4 |
5319 | .start_y: |
5328 | .start_y: |
5320 | push ecx edx |
5329 | push ecx edx |
5321 | ;-------------------------------------- |
5330 | ;-------------------------------------- |
5322 | align 4 |
5331 | align 4 |
5323 | .start_x: |
5332 | .start_x: |
5324 | push eax ecx |
5333 | push eax ecx |
5325 | add eax, ecx |
5334 | add eax, ecx |
5326 | 5335 | ||
5327 | mov ecx, [ebp] |
5336 | mov ecx, [ebp] |
5328 | rol ecx, 8 |
5337 | rol ecx, 8 |
5329 | test cl, cl ; transparensy = 0 |
5338 | test cl, cl ; transparensy = 0 |
5330 | jz .no_put |
5339 | jz .no_put |
5331 | 5340 | ||
5332 | xor cl, cl |
5341 | xor cl, cl |
5333 | ror ecx, 8 |
5342 | ror ecx, 8 |
5334 | 5343 | ||
5335 | pushad |
5344 | pushad |
5336 | mov edx, [d_width_calc_area + ebx*4] |
5345 | mov edx, [d_width_calc_area + ebx*4] |
5337 | add edx, [_display.win_map] |
5346 | add edx, [_display.win_map] |
5338 | movzx edx, byte [eax+edx] |
5347 | movzx edx, byte [eax+edx] |
5339 | cmp dl, byte 1 |
5348 | cmp dl, byte 1 |
5340 | jne @f |
5349 | jne @f |
5341 | 5350 | ||
5342 | call dword [PUTPIXEL]; eax - x, ebx - y |
5351 | call dword [PUTPIXEL]; eax - x, ebx - y |
5343 | ;-------------------------------------- |
5352 | ;-------------------------------------- |
5344 | align 4 |
5353 | align 4 |
5345 | @@: |
5354 | @@: |
5346 | popad |
5355 | popad |
5347 | ;-------------------------------------- |
5356 | ;-------------------------------------- |
5348 | align 4 |
5357 | align 4 |
5349 | .no_put: |
5358 | .no_put: |
5350 | pop ecx eax |
5359 | pop ecx eax |
5351 | 5360 | ||
5352 | sub ebp, 4 |
5361 | sub ebp, 4 |
5353 | dec ecx |
5362 | dec ecx |
5354 | jnz .start_x |
5363 | jnz .start_x |
5355 | 5364 | ||
5356 | pop edx ecx |
5365 | pop edx ecx |
5357 | dec ebx |
5366 | dec ebx |
5358 | dec edx |
5367 | dec edx |
5359 | jnz .start_y |
5368 | jnz .start_y |
5360 | 5369 | ||
5361 | popad |
5370 | popad |
5362 | ret |
5371 | ret |
5363 | ;----------------------------------------------------------------------------- |
5372 | ;----------------------------------------------------------------------------- |
5364 | align 4 |
5373 | align 4 |
5365 | syscall_drawline: ; DrawLine |
5374 | syscall_drawline: ; DrawLine |
5366 | 5375 | ||
5367 | mov edi, [TASK_BASE] |
5376 | mov edi, [TASK_BASE] |
5368 | movzx eax, word[edi-twdw+WDATA.box.left] |
5377 | movzx eax, word[edi-twdw+WDATA.box.left] |
5369 | mov ebp, eax |
5378 | mov ebp, eax |
5370 | mov esi, [current_slot] |
5379 | mov esi, [current_slot] |
5371 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5380 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5372 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5381 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5373 | add ebp, ebx |
5382 | add ebp, ebx |
5374 | shl eax, 16 |
5383 | shl eax, 16 |
5375 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5384 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5376 | add eax, ebp |
5385 | add eax, ebp |
5377 | mov ebp, ebx |
5386 | mov ebp, ebx |
5378 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5387 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5379 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5388 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5380 | add ebp, ecx |
5389 | add ebp, ecx |
5381 | shl ebx, 16 |
5390 | shl ebx, 16 |
5382 | xor edi, edi |
5391 | xor edi, edi |
5383 | add ebx, ebp |
5392 | add ebx, ebp |
5384 | mov ecx, edx |
5393 | mov ecx, edx |
5385 | ; jmp [draw_line] |
5394 | ; jmp [draw_line] |
5386 | jmp __sys_draw_line |
5395 | jmp __sys_draw_line |
5387 | 5396 | ||
5388 | 5397 | ||
5389 | align 4 |
5398 | align 4 |
5390 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5399 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5391 | 5400 | ||
5392 | call r_f_port_area |
5401 | call r_f_port_area |
5393 | mov [esp+32], eax |
5402 | mov [esp+32], eax |
5394 | ret |
5403 | ret |
5395 | 5404 | ||
5396 | align 4 |
5405 | align 4 |
5397 | syscall_threads: ; CreateThreads |
5406 | syscall_threads: ; CreateThreads |
5398 | ; |
5407 | ; |
5399 | ; ecx=thread entry point |
5408 | ; ecx=thread entry point |
5400 | ; edx=thread stack pointer |
5409 | ; edx=thread stack pointer |
5401 | ; |
5410 | ; |
5402 | ; on return : eax = pid |
5411 | ; on return : eax = pid |
5403 | 5412 | ||
5404 | xor ebx, ebx |
5413 | xor ebx, ebx |
5405 | call new_sys_threads |
5414 | call new_sys_threads |
5406 | 5415 | ||
5407 | mov [esp+32], eax |
5416 | mov [esp+32], eax |
5408 | ret |
5417 | ret |
5409 | 5418 | ||
5410 | align 4 |
5419 | align 4 |
5411 | 5420 | ||
5412 | paleholder: |
5421 | paleholder: |
5413 | ret |
5422 | ret |
5414 | ;------------------------------------------------------------------------------ |
5423 | ;------------------------------------------------------------------------------ |
5415 | align 4 |
5424 | align 4 |
5416 | calculate_fast_getting_offset_for_WinMapAddress: |
5425 | calculate_fast_getting_offset_for_WinMapAddress: |
5417 | ; calculate data area for fast getting offset to _WinMapAddress |
5426 | ; calculate data area for fast getting offset to _WinMapAddress |
5418 | xor eax, eax |
5427 | xor eax, eax |
5419 | mov ecx, [_display.height] |
5428 | mov ecx, [_display.height] |
5420 | mov edi, d_width_calc_area |
5429 | mov edi, d_width_calc_area |
5421 | cld |
5430 | cld |
5422 | @@: |
5431 | @@: |
5423 | stosd |
5432 | stosd |
5424 | add eax, [_display.width] |
5433 | add eax, [_display.width] |
5425 | dec ecx |
5434 | dec ecx |
5426 | jnz @r |
5435 | jnz @r |
5427 | ret |
5436 | ret |
5428 | ;------------------------------------------------------------------------------ |
5437 | ;------------------------------------------------------------------------------ |
5429 | align 4 |
5438 | align 4 |
5430 | calculate_fast_getting_offset_for_LFB: |
5439 | calculate_fast_getting_offset_for_LFB: |
5431 | ; calculate data area for fast getting offset to LFB |
5440 | ; calculate data area for fast getting offset to LFB |
5432 | xor eax, eax |
5441 | xor eax, eax |
5433 | mov ecx, [_display.height] |
5442 | mov ecx, [_display.height] |
5434 | mov edi, BPSLine_calc_area |
5443 | mov edi, BPSLine_calc_area |
5435 | cld |
5444 | cld |
5436 | @@: |
5445 | @@: |
5437 | stosd |
5446 | stosd |
5438 | add eax, [_display.lfb_pitch] |
5447 | add eax, [_display.lfb_pitch] |
5439 | dec ecx |
5448 | dec ecx |
5440 | jnz @r |
5449 | jnz @r |
5441 | ret |
5450 | ret |
5442 | ;------------------------------------------------------------------------------ |
5451 | ;------------------------------------------------------------------------------ |
5443 | align 4 |
5452 | align 4 |
5444 | set_screen: |
5453 | set_screen: |
5445 | ; in: |
5454 | ; in: |
5446 | ; eax - new Screen_Max_X |
5455 | ; eax - new Screen_Max_X |
5447 | ; ecx - new BytesPerScanLine |
5456 | ; ecx - new BytesPerScanLine |
5448 | ; edx - new Screen_Max_Y |
5457 | ; edx - new Screen_Max_Y |
5449 | 5458 | ||
5450 | pushfd |
5459 | pushfd |
5451 | cli |
5460 | cli |
5452 | 5461 | ||
5453 | mov [_display.lfb_pitch], ecx |
5462 | mov [_display.lfb_pitch], ecx |
5454 | 5463 | ||
5455 | mov [screen_workarea.right], eax |
5464 | mov [screen_workarea.right], eax |
5456 | mov [screen_workarea.bottom], edx |
5465 | mov [screen_workarea.bottom], edx |
5457 | 5466 | ||
5458 | push ebx |
5467 | push ebx |
5459 | push esi |
5468 | push esi |
5460 | push edi |
5469 | push edi |
5461 | 5470 | ||
5462 | pushad |
5471 | pushad |
5463 | 5472 | ||
5464 | cmp [do_not_touch_winmap], 1 |
5473 | cmp [do_not_touch_winmap], 1 |
5465 | je @f |
5474 | je @f |
5466 | 5475 | ||
5467 | stdcall kernel_free, [_display.win_map] |
5476 | stdcall kernel_free, [_display.win_map] |
5468 | 5477 | ||
5469 | mov eax, [_display.width] |
5478 | mov eax, [_display.width] |
5470 | mul [_display.height] |
5479 | mul [_display.height] |
5471 | mov [_display.win_map_size], eax |
5480 | mov [_display.win_map_size], eax |
5472 | 5481 | ||
5473 | stdcall kernel_alloc, eax |
5482 | stdcall kernel_alloc, eax |
5474 | mov [_display.win_map], eax |
5483 | mov [_display.win_map], eax |
5475 | test eax, eax |
5484 | test eax, eax |
5476 | jz .epic_fail |
5485 | jz .epic_fail |
5477 | ; store for f.18.24 |
5486 | ; store for f.18.24 |
5478 | mov eax, [_display.width] |
5487 | mov eax, [_display.width] |
5479 | mov [display_width_standard], eax |
5488 | mov [display_width_standard], eax |
5480 | 5489 | ||
5481 | mov eax, [_display.height] |
5490 | mov eax, [_display.height] |
5482 | mov [display_height_standard], eax |
5491 | mov [display_height_standard], eax |
5483 | @@: |
5492 | @@: |
5484 | call calculate_fast_getting_offset_for_WinMapAddress |
5493 | call calculate_fast_getting_offset_for_WinMapAddress |
5485 | ; for Qemu or non standart video cards |
5494 | ; for Qemu or non standart video cards |
5486 | ; Unfortunately [BytesPerScanLine] does not always |
5495 | ; Unfortunately [BytesPerScanLine] does not always |
5487 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5496 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5488 | call calculate_fast_getting_offset_for_LFB |
5497 | call calculate_fast_getting_offset_for_LFB |
5489 | popad |
5498 | popad |
5490 | 5499 | ||
5491 | call repos_windows |
5500 | call repos_windows |
5492 | xor eax, eax |
5501 | xor eax, eax |
5493 | xor ebx, ebx |
5502 | xor ebx, ebx |
5494 | mov ecx, [_display.width] |
5503 | mov ecx, [_display.width] |
5495 | mov edx, [_display.height] |
5504 | mov edx, [_display.height] |
5496 | dec ecx |
5505 | dec ecx |
5497 | dec edx |
5506 | dec edx |
5498 | call calculatescreen |
5507 | call calculatescreen |
5499 | pop edi |
5508 | pop edi |
5500 | pop esi |
5509 | pop esi |
5501 | pop ebx |
5510 | pop ebx |
5502 | 5511 | ||
5503 | popfd |
5512 | popfd |
5504 | ret |
5513 | ret |
5505 | 5514 | ||
5506 | .epic_fail: |
5515 | .epic_fail: |
5507 | hlt ; Houston, we've had a problem |
5516 | hlt ; Houston, we've had a problem |
5508 | 5517 | ||
5509 | ; --------------- APM --------------------- |
5518 | ; --------------- APM --------------------- |
5510 | uglobal |
5519 | uglobal |
5511 | apm_entry dp 0 |
5520 | apm_entry dp 0 |
5512 | apm_vf dd 0 |
5521 | apm_vf dd 0 |
5513 | endg |
5522 | endg |
5514 | 5523 | ||
5515 | align 4 |
5524 | align 4 |
5516 | sys_apm: |
5525 | sys_apm: |
5517 | xor eax, eax |
5526 | xor eax, eax |
5518 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5527 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5519 | jne @f |
5528 | jne @f |
5520 | inc eax |
5529 | inc eax |
5521 | or dword [esp + 44], eax ; error |
5530 | or dword [esp + 44], eax ; error |
5522 | add eax, 7 |
5531 | add eax, 7 |
5523 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5532 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5524 | ret |
5533 | ret |
5525 | 5534 | ||
5526 | @@: |
5535 | @@: |
5527 | ; xchg eax, ecx |
5536 | ; xchg eax, ecx |
5528 | ; xchg ebx, ecx |
5537 | ; xchg ebx, ecx |
5529 | 5538 | ||
5530 | cmp dx, 3 |
5539 | cmp dx, 3 |
5531 | ja @f |
5540 | ja @f |
5532 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5541 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5533 | mov eax, [apm_vf] |
5542 | mov eax, [apm_vf] |
5534 | mov [esp + 32], eax |
5543 | mov [esp + 32], eax |
5535 | shr eax, 16 |
5544 | shr eax, 16 |
5536 | mov [esp + 28], eax |
5545 | mov [esp + 28], eax |
5537 | ret |
5546 | ret |
5538 | 5547 | ||
5539 | @@: |
5548 | @@: |
5540 | 5549 | ||
5541 | mov esi, [master_tab+(OS_BASE shr 20)] |
5550 | mov esi, [master_tab+(OS_BASE shr 20)] |
5542 | xchg [master_tab], esi |
5551 | xchg [master_tab], esi |
5543 | push esi |
5552 | push esi |
5544 | mov edi, cr3 |
5553 | mov edi, cr3 |
5545 | mov cr3, edi ;flush TLB |
5554 | mov cr3, edi ;flush TLB |
5546 | 5555 | ||
5547 | call pword [apm_entry] ;call APM BIOS |
5556 | call pword [apm_entry] ;call APM BIOS |
5548 | 5557 | ||
5549 | xchg eax, [esp] |
5558 | xchg eax, [esp] |
5550 | mov [master_tab], eax |
5559 | mov [master_tab], eax |
5551 | mov eax, cr3 |
5560 | mov eax, cr3 |
5552 | mov cr3, eax |
5561 | mov cr3, eax |
5553 | pop eax |
5562 | pop eax |
5554 | 5563 | ||
5555 | mov [esp + 4 ], edi |
5564 | mov [esp + 4 ], edi |
5556 | mov [esp + 8], esi |
5565 | mov [esp + 8], esi |
5557 | mov [esp + 20], ebx |
5566 | mov [esp + 20], ebx |
5558 | mov [esp + 24], edx |
5567 | mov [esp + 24], edx |
5559 | mov [esp + 28], ecx |
5568 | mov [esp + 28], ecx |
5560 | mov [esp + 32], eax |
5569 | mov [esp + 32], eax |
5561 | setc al |
5570 | setc al |
5562 | and [esp + 44], byte 0xfe |
5571 | and [esp + 44], byte 0xfe |
5563 | or [esp + 44], al |
5572 | or [esp + 44], al |
5564 | ret |
5573 | ret |
5565 | ; ----------------------------------------- |
5574 | ; ----------------------------------------- |
5566 | 5575 | ||
5567 | align 4 |
5576 | align 4 |
5568 | 5577 | ||
5569 | undefined_syscall: ; Undefined system call |
5578 | undefined_syscall: ; Undefined system call |
5570 | mov [esp + 32], dword -1 |
5579 | mov [esp + 32], dword -1 |
5571 | ret |
5580 | ret |
5572 | 5581 | ||
5573 | align 4 |
5582 | align 4 |
5574 | system_shutdown: ; shut down the system |
5583 | system_shutdown: ; shut down the system |
5575 | 5584 | ||
5576 | cmp byte [BOOT_VARS+0x9030], 1 |
5585 | cmp byte [BOOT_VARS+0x9030], 1 |
5577 | jne @F |
5586 | jne @F |
5578 | ret |
5587 | ret |
5579 | @@: |
5588 | @@: |
5580 | call stop_all_services |
5589 | call stop_all_services |
5581 | 5590 | ||
5582 | yes_shutdown_param: |
5591 | yes_shutdown_param: |
5583 | ; Shutdown other CPUs, if initialized |
5592 | ; Shutdown other CPUs, if initialized |
5584 | cmp [ap_initialized], 0 |
5593 | cmp [ap_initialized], 0 |
5585 | jz .no_shutdown_cpus |
5594 | jz .no_shutdown_cpus |
5586 | mov edi, [LAPIC_BASE] |
5595 | mov edi, [LAPIC_BASE] |
5587 | add edi, 300h |
5596 | add edi, 300h |
5588 | mov esi, smpt+4 |
5597 | mov esi, smpt+4 |
5589 | mov ebx, [cpu_count] |
5598 | mov ebx, [cpu_count] |
5590 | dec ebx |
5599 | dec ebx |
5591 | .shutdown_cpus_loop: |
5600 | .shutdown_cpus_loop: |
5592 | lodsd |
5601 | lodsd |
5593 | push esi |
5602 | push esi |
5594 | xor esi, esi |
5603 | xor esi, esi |
5595 | inc esi |
5604 | inc esi |
5596 | shl eax, 24 |
5605 | shl eax, 24 |
5597 | mov [edi+10h], eax |
5606 | mov [edi+10h], eax |
5598 | ; assert INIT IPI |
5607 | ; assert INIT IPI |
5599 | mov dword [edi], 0C500h |
5608 | mov dword [edi], 0C500h |
5600 | call delay_ms |
5609 | call delay_ms |
5601 | @@: |
5610 | @@: |
5602 | test dword [edi], 1000h |
5611 | test dword [edi], 1000h |
5603 | jnz @b |
5612 | jnz @b |
5604 | ; deassert INIT IPI |
5613 | ; deassert INIT IPI |
5605 | mov dword [edi], 8500h |
5614 | mov dword [edi], 8500h |
5606 | call delay_ms |
5615 | call delay_ms |
5607 | @@: |
5616 | @@: |
5608 | test dword [edi], 1000h |
5617 | test dword [edi], 1000h |
5609 | jnz @b |
5618 | jnz @b |
5610 | ; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
5619 | ; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
5611 | pop esi |
5620 | pop esi |
5612 | dec ebx |
5621 | dec ebx |
5613 | jnz .shutdown_cpus_loop |
5622 | jnz .shutdown_cpus_loop |
5614 | .no_shutdown_cpus: |
5623 | .no_shutdown_cpus: |
5615 | 5624 | ||
5616 | cli |
5625 | cli |
5617 | 5626 | ||
5618 | if ~ defined extended_primary_loader |
5627 | if ~ defined extended_primary_loader |
5619 | ; load kernel.mnt to 0x7000:0 |
5628 | ; load kernel.mnt to 0x7000:0 |
5620 | mov ebx, kernel_file_load |
5629 | mov ebx, kernel_file_load |
5621 | pushad |
5630 | pushad |
5622 | call file_system_lfn |
5631 | call file_system_lfn |
5623 | popad |
5632 | popad |
5624 | 5633 | ||
5625 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5634 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5626 | mov edi, OS_BASE+0x40000 |
5635 | mov edi, OS_BASE+0x40000 |
5627 | mov ecx, 1000 |
5636 | mov ecx, 1000 |
5628 | rep movsb |
5637 | rep movsb |
5629 | end if |
5638 | end if |
5630 | 5639 | ||
5631 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5640 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5632 | ; mov edi, OS_BASE |
5641 | ; mov edi, OS_BASE |
5633 | ; mov ecx, 0x10000/4 |
5642 | ; mov ecx, 0x10000/4 |
5634 | ; cld |
5643 | ; cld |
5635 | ; rep movsd |
5644 | ; rep movsd |
5636 | 5645 | ||
5637 | call IRQ_mask_all |
5646 | call IRQ_mask_all |
5638 | 5647 | ||
5639 | cmp byte [OS_BASE + 0x9030], 2 |
5648 | cmp byte [OS_BASE + 0x9030], 2 |
5640 | jnz no_acpi_power_off |
5649 | jnz no_acpi_power_off |
5641 | 5650 | ||
5642 | ; scan for RSDP |
5651 | ; scan for RSDP |
5643 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5652 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5644 | movzx eax, word [OS_BASE + 0x40E] |
5653 | movzx eax, word [OS_BASE + 0x40E] |
5645 | shl eax, 4 |
5654 | shl eax, 4 |
5646 | jz @f |
5655 | jz @f |
5647 | mov ecx, 1024/16 |
5656 | mov ecx, 1024/16 |
5648 | call scan_rsdp |
5657 | call scan_rsdp |
5649 | jnc .rsdp_found |
5658 | jnc .rsdp_found |
5650 | @@: |
5659 | @@: |
5651 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5660 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5652 | mov eax, 0xE0000 |
5661 | mov eax, 0xE0000 |
5653 | mov ecx, 0x2000 |
5662 | mov ecx, 0x2000 |
5654 | call scan_rsdp |
5663 | call scan_rsdp |
5655 | jc no_acpi_power_off |
5664 | jc no_acpi_power_off |
5656 | .rsdp_found: |
5665 | .rsdp_found: |
5657 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5666 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5658 | mov ebp, [ipc_tmp] |
5667 | mov ebp, [ipc_tmp] |
5659 | stdcall map_page, ebp, esi, PG_READ |
5668 | stdcall map_page, ebp, esi, PG_READ |
5660 | lea eax, [esi+1000h] |
5669 | lea eax, [esi+1000h] |
5661 | lea edx, [ebp+1000h] |
5670 | lea edx, [ebp+1000h] |
5662 | stdcall map_page, edx, eax, PG_READ |
5671 | stdcall map_page, edx, eax, PG_READ |
5663 | and esi, 0xFFF |
5672 | and esi, 0xFFF |
5664 | add esi, ebp |
5673 | add esi, ebp |
5665 | cmp dword [esi], 'RSDT' |
5674 | cmp dword [esi], 'RSDT' |
5666 | jnz no_acpi_power_off |
5675 | jnz no_acpi_power_off |
5667 | mov ecx, [esi+4] |
5676 | mov ecx, [esi+4] |
5668 | sub ecx, 24h |
5677 | sub ecx, 24h |
5669 | jbe no_acpi_power_off |
5678 | jbe no_acpi_power_off |
5670 | shr ecx, 2 |
5679 | shr ecx, 2 |
5671 | add esi, 24h |
5680 | add esi, 24h |
5672 | .scan_fadt: |
5681 | .scan_fadt: |
5673 | lodsd |
5682 | lodsd |
5674 | mov ebx, eax |
5683 | mov ebx, eax |
5675 | lea eax, [ebp+2000h] |
5684 | lea eax, [ebp+2000h] |
5676 | stdcall map_page, eax, ebx, PG_READ |
5685 | stdcall map_page, eax, ebx, PG_READ |
5677 | lea eax, [ebp+3000h] |
5686 | lea eax, [ebp+3000h] |
5678 | add ebx, 0x1000 |
5687 | add ebx, 0x1000 |
5679 | stdcall map_page, eax, ebx, PG_READ |
5688 | stdcall map_page, eax, ebx, PG_READ |
5680 | and ebx, 0xFFF |
5689 | and ebx, 0xFFF |
5681 | lea ebx, [ebx+ebp+2000h] |
5690 | lea ebx, [ebx+ebp+2000h] |
5682 | cmp dword [ebx], 'FACP' |
5691 | cmp dword [ebx], 'FACP' |
5683 | jz .fadt_found |
5692 | jz .fadt_found |
5684 | loop .scan_fadt |
5693 | loop .scan_fadt |
5685 | jmp no_acpi_power_off |
5694 | jmp no_acpi_power_off |
5686 | .fadt_found: |
5695 | .fadt_found: |
5687 | ; ebx is linear address of FADT |
5696 | ; ebx is linear address of FADT |
5688 | mov edi, [ebx+40] ; physical address of the DSDT |
5697 | mov edi, [ebx+40] ; physical address of the DSDT |
5689 | lea eax, [ebp+4000h] |
5698 | lea eax, [ebp+4000h] |
5690 | stdcall map_page, eax, edi, PG_READ |
5699 | stdcall map_page, eax, edi, PG_READ |
5691 | lea eax, [ebp+5000h] |
5700 | lea eax, [ebp+5000h] |
5692 | lea esi, [edi+0x1000] |
5701 | lea esi, [edi+0x1000] |
5693 | stdcall map_page, eax, esi, PG_READ |
5702 | stdcall map_page, eax, esi, PG_READ |
5694 | and esi, 0xFFF |
5703 | and esi, 0xFFF |
5695 | sub edi, esi |
5704 | sub edi, esi |
5696 | cmp dword [esi+ebp+4000h], 'DSDT' |
5705 | cmp dword [esi+ebp+4000h], 'DSDT' |
5697 | jnz no_acpi_power_off |
5706 | jnz no_acpi_power_off |
5698 | mov eax, [esi+ebp+4004h] ; DSDT length |
5707 | mov eax, [esi+ebp+4004h] ; DSDT length |
5699 | sub eax, 36+4 |
5708 | sub eax, 36+4 |
5700 | jbe no_acpi_power_off |
5709 | jbe no_acpi_power_off |
5701 | add esi, 36 |
5710 | add esi, 36 |
5702 | .scan_dsdt: |
5711 | .scan_dsdt: |
5703 | cmp dword [esi+ebp+4000h], '_S5_' |
5712 | cmp dword [esi+ebp+4000h], '_S5_' |
5704 | jnz .scan_dsdt_cont |
5713 | jnz .scan_dsdt_cont |
5705 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5714 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5706 | jnz .scan_dsdt_cont |
5715 | jnz .scan_dsdt_cont |
5707 | mov dl, [esi+ebp+4000h+6] |
5716 | mov dl, [esi+ebp+4000h+6] |
5708 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5717 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5709 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5718 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5710 | ja .scan_dsdt_cont |
5719 | ja .scan_dsdt_cont |
5711 | cmp dl, 1 |
5720 | cmp dl, 1 |
5712 | jb .scan_dsdt_cont |
5721 | jb .scan_dsdt_cont |
5713 | lea esi, [esi+ebp+4000h+7] |
5722 | lea esi, [esi+ebp+4000h+7] |
5714 | xor ecx, ecx |
5723 | xor ecx, ecx |
5715 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5724 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5716 | jz @f |
5725 | jz @f |
5717 | cmp byte [esi], 0xA |
5726 | cmp byte [esi], 0xA |
5718 | jnz no_acpi_power_off |
5727 | jnz no_acpi_power_off |
5719 | inc esi |
5728 | inc esi |
5720 | mov cl, [esi] |
5729 | mov cl, [esi] |
5721 | @@: |
5730 | @@: |
5722 | inc esi |
5731 | inc esi |
5723 | cmp dl, 2 |
5732 | cmp dl, 2 |
5724 | jb @f |
5733 | jb @f |
5725 | cmp byte [esi], 0 |
5734 | cmp byte [esi], 0 |
5726 | jz @f |
5735 | jz @f |
5727 | cmp byte [esi], 0xA |
5736 | cmp byte [esi], 0xA |
5728 | jnz no_acpi_power_off |
5737 | jnz no_acpi_power_off |
5729 | inc esi |
5738 | inc esi |
5730 | mov ch, [esi] |
5739 | mov ch, [esi] |
5731 | @@: |
5740 | @@: |
5732 | jmp do_acpi_power_off |
5741 | jmp do_acpi_power_off |
5733 | .scan_dsdt_cont: |
5742 | .scan_dsdt_cont: |
5734 | inc esi |
5743 | inc esi |
5735 | cmp esi, 0x1000 |
5744 | cmp esi, 0x1000 |
5736 | jb @f |
5745 | jb @f |
5737 | sub esi, 0x1000 |
5746 | sub esi, 0x1000 |
5738 | add edi, 0x1000 |
5747 | add edi, 0x1000 |
5739 | push eax |
5748 | push eax |
5740 | lea eax, [ebp+4000h] |
5749 | lea eax, [ebp+4000h] |
5741 | stdcall map_page, eax, edi, PG_READ |
5750 | stdcall map_page, eax, edi, PG_READ |
5742 | push PG_READ |
5751 | push PG_READ |
5743 | lea eax, [edi+1000h] |
5752 | lea eax, [edi+1000h] |
5744 | push eax |
5753 | push eax |
5745 | lea eax, [ebp+5000h] |
5754 | lea eax, [ebp+5000h] |
5746 | push eax |
5755 | push eax |
5747 | stdcall map_page |
5756 | stdcall map_page |
5748 | pop eax |
5757 | pop eax |
5749 | @@: |
5758 | @@: |
5750 | dec eax |
5759 | dec eax |
5751 | jnz .scan_dsdt |
5760 | jnz .scan_dsdt |
5752 | jmp no_acpi_power_off |
5761 | jmp no_acpi_power_off |
5753 | do_acpi_power_off: |
5762 | do_acpi_power_off: |
5754 | mov edx, [ebx+48] |
5763 | mov edx, [ebx+48] |
5755 | test edx, edx |
5764 | test edx, edx |
5756 | jz .nosmi |
5765 | jz .nosmi |
5757 | mov al, [ebx+52] |
5766 | mov al, [ebx+52] |
5758 | out dx, al |
5767 | out dx, al |
5759 | mov edx, [ebx+64] |
5768 | mov edx, [ebx+64] |
5760 | @@: |
5769 | @@: |
5761 | in ax, dx |
5770 | in ax, dx |
5762 | test al, 1 |
5771 | test al, 1 |
5763 | jz @b |
5772 | jz @b |
5764 | .nosmi: |
5773 | .nosmi: |
5765 | and cx, 0x0707 |
5774 | and cx, 0x0707 |
5766 | shl cx, 2 |
5775 | shl cx, 2 |
5767 | or cx, 0x2020 |
5776 | or cx, 0x2020 |
5768 | mov edx, [ebx+64] |
5777 | mov edx, [ebx+64] |
5769 | in ax, dx |
5778 | in ax, dx |
5770 | and ax, 203h |
5779 | and ax, 203h |
5771 | or ah, cl |
5780 | or ah, cl |
5772 | out dx, ax |
5781 | out dx, ax |
5773 | mov edx, [ebx+68] |
5782 | mov edx, [ebx+68] |
5774 | test edx, edx |
5783 | test edx, edx |
5775 | jz @f |
5784 | jz @f |
5776 | in ax, dx |
5785 | in ax, dx |
5777 | and ax, 203h |
5786 | and ax, 203h |
5778 | or ah, ch |
5787 | or ah, ch |
5779 | out dx, ax |
5788 | out dx, ax |
5780 | @@: |
5789 | @@: |
5781 | jmp $ |
5790 | jmp $ |
5782 | 5791 | ||
5783 | 5792 | ||
5784 | scan_rsdp: |
5793 | scan_rsdp: |
5785 | add eax, OS_BASE |
5794 | add eax, OS_BASE |
5786 | .s: |
5795 | .s: |
5787 | cmp dword [eax], 'RSD ' |
5796 | cmp dword [eax], 'RSD ' |
5788 | jnz .n |
5797 | jnz .n |
5789 | cmp dword [eax+4], 'PTR ' |
5798 | cmp dword [eax+4], 'PTR ' |
5790 | jnz .n |
5799 | jnz .n |
5791 | xor edx, edx |
5800 | xor edx, edx |
5792 | xor esi, esi |
5801 | xor esi, esi |
5793 | @@: |
5802 | @@: |
5794 | add dl, [eax+esi] |
5803 | add dl, [eax+esi] |
5795 | inc esi |
5804 | inc esi |
5796 | cmp esi, 20 |
5805 | cmp esi, 20 |
5797 | jnz @b |
5806 | jnz @b |
5798 | test dl, dl |
5807 | test dl, dl |
5799 | jz .ok |
5808 | jz .ok |
5800 | .n: |
5809 | .n: |
5801 | add eax, 10h |
5810 | add eax, 10h |
5802 | loop .s |
5811 | loop .s |
5803 | stc |
5812 | stc |
5804 | .ok: |
5813 | .ok: |
5805 | ret |
5814 | ret |
5806 | 5815 | ||
5807 | no_acpi_power_off: |
5816 | no_acpi_power_off: |
5808 | call create_trampoline_pgmap |
5817 | call create_trampoline_pgmap |
5809 | mov cr3, eax |
5818 | mov cr3, eax |
5810 | jmp become_real+0x10000 |
5819 | jmp become_real+0x10000 |
5811 | iglobal |
5820 | iglobal |
5812 | align 4 |
5821 | align 4 |
5813 | realmode_gdt: |
5822 | realmode_gdt: |
5814 | ; selector 0 - not used |
5823 | ; selector 0 - not used |
5815 | dw 23 |
5824 | dw 23 |
5816 | dd realmode_gdt-OS_BASE |
5825 | dd realmode_gdt-OS_BASE |
5817 | dw 0 |
5826 | dw 0 |
5818 | ; selector 8 - code from 1000:0000 to 1000:FFFF |
5827 | ; selector 8 - code from 1000:0000 to 1000:FFFF |
5819 | dw 0FFFFh |
5828 | dw 0FFFFh |
5820 | dw 0 |
5829 | dw 0 |
5821 | db 1 |
5830 | db 1 |
5822 | db 10011011b |
5831 | db 10011011b |
5823 | db 00000000b |
5832 | db 00000000b |
5824 | db 0 |
5833 | db 0 |
5825 | ; selector 10h - data from 1000:0000 to 1000:FFFF |
5834 | ; selector 10h - data from 1000:0000 to 1000:FFFF |
5826 | dw 0FFFFh |
5835 | dw 0FFFFh |
5827 | dw 0 |
5836 | dw 0 |
5828 | db 1 |
5837 | db 1 |
5829 | db 10010011b |
5838 | db 10010011b |
5830 | db 00000000b |
5839 | db 00000000b |
5831 | db 0 |
5840 | db 0 |
5832 | endg |
5841 | endg |
5833 | 5842 | ||
5834 | if ~ lang eq sp |
5843 | if ~ lang eq sp |
5835 | diff16 "end of .text segment",0,$ |
5844 | diff16 "end of .text segment",0,$ |
5836 | end if |
5845 | end if |
5837 | 5846 | ||
5838 | include "data32.inc" |
5847 | include "data32.inc" |
5839 | 5848 | ||
5840 | __REV__ = __REV |
5849 | __REV__ = __REV |
5841 | 5850 | ||
5842 | if ~ lang eq sp |
5851 | if ~ lang eq sp |
5843 | diff16 "end of kernel code",0,$ |
5852 | diff16 "end of kernel code",0,$ |
5844 | end if=> |
5853 | end if=> |