Rev 5675 | Rev 5792 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5675 | Rev 5787 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2015. 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: 5675 $ |
74 | $Revision: 5787 $ |
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_hpet |
|
286 | call init_BIOS32 |
287 | call init_BIOS32 |
287 | ; MEMORY MODEL |
288 | ; MEMORY MODEL |
288 | call mem_test |
289 | call mem_test |
289 | call init_mem |
290 | call init_mem |
290 | call init_page_map |
291 | call init_page_map |
291 | 292 | ||
292 | ; ENABLE PAGING |
293 | ; ENABLE PAGING |
293 | 294 | ||
294 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
295 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
295 | mov cr3, eax |
296 | mov cr3, eax |
296 | 297 | ||
297 | mov eax, cr0 |
298 | mov eax, cr0 |
298 | or eax, CR0_PG+CR0_WP |
299 | or eax, CR0_PG+CR0_WP |
299 | mov cr0, eax |
300 | mov cr0, eax |
300 | 301 | ||
301 | lgdt [gdts] |
302 | lgdt [gdts] |
302 | jmp pword os_code:high_code |
303 | jmp pword os_code:high_code |
303 | 304 | ||
304 | align 4 |
305 | align 4 |
305 | bios32_entry dd ? |
306 | bios32_entry dd ? |
306 | tmp_page_tabs dd ? |
307 | tmp_page_tabs dd ? |
307 | 308 | ||
308 | use16 |
309 | use16 |
309 | org $-0x10000 |
310 | org $-0x10000 |
310 | include "boot/shutdown.inc" ; shutdown or restart |
311 | include "boot/shutdown.inc" ; shutdown or restart |
311 | org $+0x10000 |
312 | org $+0x10000 |
312 | 313 | ||
313 | ap_init16: |
314 | ap_init16: |
314 | cli |
315 | cli |
315 | lgdt [cs:gdts_ap-ap_init16] |
316 | lgdt [cs:gdts_ap-ap_init16] |
316 | mov eax, [cs:cr3_ap-ap_init16] |
317 | mov eax, [cs:cr3_ap-ap_init16] |
317 | mov cr3, eax |
318 | mov cr3, eax |
318 | mov eax, [cs:cr4_ap-ap_init16] |
319 | mov eax, [cs:cr4_ap-ap_init16] |
319 | mov cr4, eax |
320 | mov cr4, eax |
320 | mov eax, CR0_PE+CR0_PG+CR0_WP |
321 | mov eax, CR0_PE+CR0_PG+CR0_WP |
321 | mov cr0, eax |
322 | mov cr0, eax |
322 | jmp pword os_code:ap_init_high |
323 | jmp pword os_code:ap_init_high |
323 | align 16 |
324 | align 16 |
324 | gdts_ap: |
325 | gdts_ap: |
325 | dw gdte-gdts-1 |
326 | dw gdte-gdts-1 |
326 | dd gdts |
327 | dd gdts |
327 | dw 0 |
328 | dw 0 |
328 | cr3_ap dd ? |
329 | cr3_ap dd ? |
329 | cr4_ap dd ? |
330 | cr4_ap dd ? |
330 | ap_init16_size = $ - ap_init16 |
331 | ap_init16_size = $ - ap_init16 |
331 | use32 |
332 | use32 |
332 | 333 | ||
333 | __DEBUG__ fix 1 |
334 | __DEBUG__ fix 1 |
334 | __DEBUG_LEVEL__ fix 1 |
335 | __DEBUG_LEVEL__ fix 1 |
335 | include 'init.inc' |
336 | include 'init.inc' |
336 | 337 | ||
337 | org OS_BASE+$ |
338 | org OS_BASE+$ |
338 | 339 | ||
339 | include 'fdo.inc' |
340 | include 'fdo.inc' |
340 | 341 | ||
341 | align 4 |
342 | align 4 |
342 | high_code: |
343 | high_code: |
343 | mov ax, os_stack |
344 | mov ax, os_stack |
344 | mov bx, app_data |
345 | mov bx, app_data |
345 | mov cx, app_tls |
346 | mov cx, app_tls |
346 | mov ss, ax |
347 | mov ss, ax |
347 | add esp, OS_BASE |
348 | add esp, OS_BASE |
348 | 349 | ||
349 | mov ds, bx |
350 | mov ds, bx |
350 | mov es, bx |
351 | mov es, bx |
351 | mov fs, cx |
352 | mov fs, cx |
352 | mov gs, bx |
353 | mov gs, bx |
353 | 354 | ||
354 | xor eax, eax |
355 | xor eax, eax |
355 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
356 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
356 | bt [cpu_caps], CAPS_PAT |
357 | bt [cpu_caps], CAPS_PAT |
357 | setc al |
358 | setc al |
358 | shl eax, 7 |
359 | shl eax, 7 |
359 | or ebx, eax |
360 | or ebx, eax |
360 | 361 | ||
361 | mov eax, PG_GLOBAL |
362 | mov eax, PG_GLOBAL |
362 | bt [cpu_caps], CAPS_PGE |
363 | bt [cpu_caps], CAPS_PGE |
363 | jnc @F |
364 | jnc @F |
364 | 365 | ||
365 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
366 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
366 | or ebx, eax |
367 | or ebx, eax |
367 | 368 | ||
368 | mov eax, cr4 |
369 | mov eax, cr4 |
369 | or eax, CR4_PGE |
370 | or eax, CR4_PGE |
370 | mov cr4, eax |
371 | mov cr4, eax |
371 | @@: |
372 | @@: |
372 | mov [pte_valid_mask], ebx |
373 | mov [pte_valid_mask], ebx |
373 | 374 | ||
374 | xor eax, eax |
375 | xor eax, eax |
375 | mov dword [sys_proc+PROC.pdt_0], eax |
376 | mov dword [sys_proc+PROC.pdt_0], eax |
376 | mov dword [sys_proc+PROC.pdt_0+4], eax |
377 | mov dword [sys_proc+PROC.pdt_0+4], eax |
377 | 378 | ||
378 | mov eax, cr3 |
379 | mov eax, cr3 |
379 | mov cr3, eax ; flush TLB |
380 | mov cr3, eax ; flush TLB |
380 | 381 | ||
381 | mov ecx, pg_data.mutex |
382 | mov ecx, pg_data.mutex |
382 | call mutex_init |
383 | call mutex_init |
383 | 384 | ||
384 | mov ecx, disk_list_mutex |
385 | mov ecx, disk_list_mutex |
385 | call mutex_init |
386 | call mutex_init |
386 | 387 | ||
387 | mov ecx, keyboard_list_mutex |
388 | mov ecx, keyboard_list_mutex |
388 | call mutex_init |
389 | call mutex_init |
389 | 390 | ||
390 | mov ecx, unpack_mutex |
391 | mov ecx, unpack_mutex |
391 | call mutex_init |
392 | call mutex_init |
392 | 393 | ||
393 | mov ecx, application_table_mutex |
394 | mov ecx, application_table_mutex |
394 | call mutex_init |
395 | call mutex_init |
395 | 396 | ||
396 | mov ecx, ide_mutex |
397 | mov ecx, ide_mutex |
397 | call mutex_init |
398 | call mutex_init |
398 | mov ecx, ide_channel1_mutex |
399 | mov ecx, ide_channel1_mutex |
399 | call mutex_init |
400 | call mutex_init |
400 | mov ecx, ide_channel2_mutex |
401 | mov ecx, ide_channel2_mutex |
401 | call mutex_init |
402 | call mutex_init |
402 | mov ecx, ide_channel3_mutex |
403 | mov ecx, ide_channel3_mutex |
403 | call mutex_init |
404 | call mutex_init |
404 | mov ecx, ide_channel4_mutex |
405 | mov ecx, ide_channel4_mutex |
405 | call mutex_init |
406 | call mutex_init |
406 | mov ecx, ide_channel5_mutex |
407 | mov ecx, ide_channel5_mutex |
407 | call mutex_init |
408 | call mutex_init |
408 | mov ecx, ide_channel6_mutex |
409 | mov ecx, ide_channel6_mutex |
409 | call mutex_init |
410 | call mutex_init |
410 | ;----------------------------------------------------------------------------- |
411 | ;----------------------------------------------------------------------------- |
411 | ; SAVE REAL MODE VARIABLES |
412 | ; SAVE REAL MODE VARIABLES |
412 | ;----------------------------------------------------------------------------- |
413 | ;----------------------------------------------------------------------------- |
413 | ; --------------- APM --------------------- |
414 | ; --------------- APM --------------------- |
414 | 415 | ||
415 | ; init selectors |
416 | ; init selectors |
416 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
417 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
417 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
418 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
418 | ; protected-mode 32-bit code segment |
419 | ; protected-mode 32-bit code segment |
419 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
420 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
420 | ; protected-mode 16-bit code segment |
421 | ; protected-mode 16-bit code segment |
421 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
422 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
422 | ; protected-mode 16-bit data segment |
423 | ; protected-mode 16-bit data segment |
423 | 424 | ||
424 | shl eax, 4 |
425 | shl eax, 4 |
425 | mov [dword apm_code_32 + 2], ax |
426 | mov [dword apm_code_32 + 2], ax |
426 | shr eax, 16 |
427 | shr eax, 16 |
427 | mov [dword apm_code_32 + 4], al |
428 | mov [dword apm_code_32 + 4], al |
428 | 429 | ||
429 | shl ecx, 4 |
430 | shl ecx, 4 |
430 | mov [dword apm_code_16 + 2], cx |
431 | mov [dword apm_code_16 + 2], cx |
431 | shr ecx, 16 |
432 | shr ecx, 16 |
432 | mov [dword apm_code_16 + 4], cl |
433 | mov [dword apm_code_16 + 4], cl |
433 | 434 | ||
434 | shl edx, 4 |
435 | shl edx, 4 |
435 | mov [dword apm_data_16 + 2], dx |
436 | mov [dword apm_data_16 + 2], dx |
436 | shr edx, 16 |
437 | shr edx, 16 |
437 | mov [dword apm_data_16 + 4], dl |
438 | mov [dword apm_data_16 + 4], dl |
438 | 439 | ||
439 | mov dword[apm_entry], ebx |
440 | mov dword[apm_entry], ebx |
440 | mov word [apm_entry + 4], apm_code_32 - gdts |
441 | mov word [apm_entry + 4], apm_code_32 - gdts |
441 | 442 | ||
442 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
443 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
443 | mov [apm_vf], eax |
444 | mov [apm_vf], eax |
444 | ; ----------------------------------------- |
445 | ; ----------------------------------------- |
445 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
446 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
446 | mov [allow_dma_access], al |
447 | mov [allow_dma_access], al |
447 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
448 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
448 | mov [_display.bits_per_pixel], eax |
449 | mov [_display.bits_per_pixel], eax |
449 | mov [_display.vrefresh], 60 |
450 | mov [_display.vrefresh], 60 |
450 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
451 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
451 | mov [debug_direct_print], al |
452 | mov [debug_direct_print], al |
452 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
453 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
453 | mov [launcher_start], al |
454 | mov [launcher_start], al |
454 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
455 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
455 | mov [_display.width], eax |
456 | mov [_display.width], eax |
456 | mov [display_width_standard], eax |
457 | mov [display_width_standard], eax |
457 | dec eax |
458 | dec eax |
458 | mov [screen_workarea.right], eax |
459 | mov [screen_workarea.right], eax |
459 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
460 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
460 | mov [_display.height], eax |
461 | mov [_display.height], eax |
461 | mov [display_height_standard], eax |
462 | mov [display_height_standard], eax |
462 | dec eax |
463 | dec eax |
463 | mov [screen_workarea.bottom], eax |
464 | mov [screen_workarea.bottom], eax |
464 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
465 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
465 | mov dword [SCR_MODE], eax |
466 | mov dword [SCR_MODE], eax |
466 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
467 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
467 | ; mov [BANK_SWITCH], eax |
468 | ; mov [BANK_SWITCH], eax |
468 | mov eax, 640 *4 ; Bytes PerScanLine |
469 | mov eax, 640 *4 ; Bytes PerScanLine |
469 | cmp [SCR_MODE], word 0x13 ; 320x200 |
470 | cmp [SCR_MODE], word 0x13 ; 320x200 |
470 | je @f |
471 | je @f |
471 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
472 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
472 | je @f |
473 | je @f |
473 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
474 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
474 | @@: |
475 | @@: |
475 | mov [_display.lfb_pitch], eax |
476 | mov [_display.lfb_pitch], eax |
476 | mov eax, [_display.width] |
477 | mov eax, [_display.width] |
477 | mul [_display.height] |
478 | mul [_display.height] |
478 | mov [_display.win_map_size], eax |
479 | mov [_display.win_map_size], eax |
479 | 480 | ||
480 | call calculate_fast_getting_offset_for_WinMapAddress |
481 | call calculate_fast_getting_offset_for_WinMapAddress |
481 | ; for Qemu or non standart video cards |
482 | ; for Qemu or non standart video cards |
482 | ; Unfortunately [BytesPerScanLine] does not always |
483 | ; Unfortunately [BytesPerScanLine] does not always |
483 | ; equal to [_display.width] * [ScreenBPP] / 8 |
484 | ; equal to [_display.width] * [ScreenBPP] / 8 |
484 | call calculate_fast_getting_offset_for_LFB |
485 | call calculate_fast_getting_offset_for_LFB |
485 | 486 | ||
486 | mov esi, BOOT_VARS+0x9080 |
487 | mov esi, BOOT_VARS+0x9080 |
487 | movzx ecx, byte [esi-1] |
488 | movzx ecx, byte [esi-1] |
488 | mov [NumBiosDisks], ecx |
489 | mov [NumBiosDisks], ecx |
489 | mov edi, BiosDisksData |
490 | mov edi, BiosDisksData |
490 | rep movsd |
491 | rep movsd |
491 | 492 | ||
492 | setvideomode: |
493 | setvideomode: |
493 | 494 | ||
494 | mov eax, [BOOT_VARS+BOOT_LFB] |
495 | mov eax, [BOOT_VARS+BOOT_LFB] |
495 | mov [LFBAddress], eax |
496 | mov [LFBAddress], eax |
496 | 497 | ||
497 | cmp word [SCR_MODE], 0x0012 ; VGA (640x480 16 colors) |
498 | cmp word [SCR_MODE], 0x0012 ; VGA (640x480 16 colors) |
498 | je .vga |
499 | je .vga |
499 | cmp word [SCR_MODE], 0x0013 ; MCGA (320*200 256 colors) |
500 | cmp word [SCR_MODE], 0x0013 ; MCGA (320*200 256 colors) |
500 | je .32bpp |
501 | je .32bpp |
501 | cmp byte [_display.bits_per_pixel], 32 |
502 | cmp byte [_display.bits_per_pixel], 32 |
502 | je .32bpp |
503 | je .32bpp |
503 | cmp byte [_display.bits_per_pixel], 24 |
504 | cmp byte [_display.bits_per_pixel], 24 |
504 | je .24bpp |
505 | je .24bpp |
505 | cmp byte [_display.bits_per_pixel], 16 |
506 | cmp byte [_display.bits_per_pixel], 16 |
506 | je .16bpp |
507 | je .16bpp |
507 | ; cmp byte [_display.bits_per_pixel], 15 |
508 | ; cmp byte [_display.bits_per_pixel], 15 |
508 | ; je .15bpp |
509 | ; je .15bpp |
509 | 510 | ||
510 | .vga: |
511 | .vga: |
511 | mov [PUTPIXEL], VGA_putpixel |
512 | mov [PUTPIXEL], VGA_putpixel |
512 | mov [GETPIXEL], Vesa20_getpixel32 ; Conversion buffer is 32 bpp |
513 | mov [GETPIXEL], Vesa20_getpixel32 ; Conversion buffer is 32 bpp |
513 | mov [_display.bytes_per_pixel], 4 ; Conversion buffer is 32 bpp |
514 | mov [_display.bytes_per_pixel], 4 ; Conversion buffer is 32 bpp |
514 | jmp .finish |
515 | jmp .finish |
515 | 516 | ||
516 | ; .15bpp: |
517 | ; .15bpp: |
517 | ; mov [PUTPIXEL], Vesa20_putpixel15 |
518 | ; mov [PUTPIXEL], Vesa20_putpixel15 |
518 | ; mov [GETPIXEL], Vesa20_getpixel15 |
519 | ; mov [GETPIXEL], Vesa20_getpixel15 |
519 | ; mov [_display.bytes_per_pixel], 2 |
520 | ; mov [_display.bytes_per_pixel], 2 |
520 | ; jmp .finish |
521 | ; jmp .finish |
521 | 522 | ||
522 | .16bpp: |
523 | .16bpp: |
523 | mov [PUTPIXEL], Vesa20_putpixel16 |
524 | mov [PUTPIXEL], Vesa20_putpixel16 |
524 | mov [GETPIXEL], Vesa20_getpixel16 |
525 | mov [GETPIXEL], Vesa20_getpixel16 |
525 | mov [_display.bytes_per_pixel], 2 |
526 | mov [_display.bytes_per_pixel], 2 |
526 | jmp .finish |
527 | jmp .finish |
527 | 528 | ||
528 | .24bpp: |
529 | .24bpp: |
529 | mov [PUTPIXEL], Vesa20_putpixel24 |
530 | mov [PUTPIXEL], Vesa20_putpixel24 |
530 | mov [GETPIXEL], Vesa20_getpixel24 |
531 | mov [GETPIXEL], Vesa20_getpixel24 |
531 | mov [_display.bytes_per_pixel], 3 |
532 | mov [_display.bytes_per_pixel], 3 |
532 | jmp .finish |
533 | jmp .finish |
533 | 534 | ||
534 | .32bpp: |
535 | .32bpp: |
535 | mov [PUTPIXEL], Vesa20_putpixel32 |
536 | mov [PUTPIXEL], Vesa20_putpixel32 |
536 | mov [GETPIXEL], Vesa20_getpixel32 |
537 | mov [GETPIXEL], Vesa20_getpixel32 |
537 | mov [_display.bytes_per_pixel], 4 |
538 | mov [_display.bytes_per_pixel], 4 |
538 | ; jmp .finish |
539 | ; jmp .finish |
539 | 540 | ||
540 | .finish: |
541 | .finish: |
541 | mov [MOUSE_PICTURE], mousepointer |
542 | mov [MOUSE_PICTURE], mousepointer |
542 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
543 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
543 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
544 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
544 | 545 | ||
545 | ; -------- Fast System Call init ---------- |
546 | ; -------- Fast System Call init ---------- |
546 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
547 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
547 | bt [cpu_caps], CAPS_SEP |
548 | bt [cpu_caps], CAPS_SEP |
548 | jnc .SEnP ; SysEnter not Present |
549 | jnc .SEnP ; SysEnter not Present |
549 | xor edx, edx |
550 | xor edx, edx |
550 | mov ecx, MSR_SYSENTER_CS |
551 | mov ecx, MSR_SYSENTER_CS |
551 | mov eax, os_code |
552 | mov eax, os_code |
552 | wrmsr |
553 | wrmsr |
553 | mov ecx, MSR_SYSENTER_ESP |
554 | mov ecx, MSR_SYSENTER_ESP |
554 | ; mov eax, sysenter_stack ; Check it |
555 | ; mov eax, sysenter_stack ; Check it |
555 | xor eax, eax |
556 | xor eax, eax |
556 | wrmsr |
557 | wrmsr |
557 | mov ecx, MSR_SYSENTER_EIP |
558 | mov ecx, MSR_SYSENTER_EIP |
558 | mov eax, sysenter_entry |
559 | mov eax, sysenter_entry |
559 | wrmsr |
560 | wrmsr |
560 | .SEnP: |
561 | .SEnP: |
561 | ; AMD SYSCALL/SYSRET |
562 | ; AMD SYSCALL/SYSRET |
562 | cmp byte[cpu_vendor], 'A' |
563 | cmp byte[cpu_vendor], 'A' |
563 | jne .noSYSCALL |
564 | jne .noSYSCALL |
564 | mov eax, 0x80000001 |
565 | mov eax, 0x80000001 |
565 | cpuid |
566 | cpuid |
566 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
567 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
567 | jz .noSYSCALL |
568 | jz .noSYSCALL |
568 | mov ecx, MSR_AMD_EFER |
569 | mov ecx, MSR_AMD_EFER |
569 | rdmsr |
570 | rdmsr |
570 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
571 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
571 | wrmsr |
572 | wrmsr |
572 | 573 | ||
573 | ; !!!! It`s dirty hack, fix it !!! |
574 | ; !!!! It`s dirty hack, fix it !!! |
574 | ; Bits of EDX : |
575 | ; Bits of EDX : |
575 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
576 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
576 | ; and the contents of this field, plus 8, are copied into the SS register. |
577 | ; and the contents of this field, plus 8, are copied into the SS register. |
577 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
578 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
578 | ; and the contents of this field, plus 8, are copied into the SS register. |
579 | ; and the contents of this field, plus 8, are copied into the SS register. |
579 | 580 | ||
580 | ; mov edx, (os_code + 16) * 65536 + os_code |
581 | ; mov edx, (os_code + 16) * 65536 + os_code |
581 | mov edx, 0x1B0008 |
582 | mov edx, 0x1B0008 |
582 | 583 | ||
583 | mov eax, syscall_entry |
584 | mov eax, syscall_entry |
584 | mov ecx, MSR_AMD_STAR |
585 | mov ecx, MSR_AMD_STAR |
585 | wrmsr |
586 | wrmsr |
586 | .noSYSCALL: |
587 | .noSYSCALL: |
587 | ; ----------------------------------------- |
588 | ; ----------------------------------------- |
588 | stdcall alloc_page |
589 | stdcall alloc_page |
589 | stdcall map_page, tss-0xF80, eax, PG_SWR |
590 | stdcall map_page, tss-0xF80, eax, PG_SWR |
590 | stdcall alloc_page |
591 | stdcall alloc_page |
591 | stdcall map_page, tss+0x80, eax, PG_SWR |
592 | stdcall map_page, tss+0x80, eax, PG_SWR |
592 | stdcall alloc_page |
593 | stdcall alloc_page |
593 | stdcall map_page, tss+0x1080, eax, PG_SWR |
594 | stdcall map_page, tss+0x1080, eax, PG_SWR |
594 | 595 | ||
595 | ; LOAD IDT |
596 | ; LOAD IDT |
596 | 597 | ||
597 | call build_interrupt_table ;lidt is executed |
598 | call build_interrupt_table ;lidt is executed |
598 | ;lidt [idtreg] |
599 | ;lidt [idtreg] |
599 | 600 | ||
600 | call init_kernel_heap |
601 | call init_kernel_heap |
601 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
602 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
602 | mov [os_stack_seg], eax |
603 | mov [os_stack_seg], eax |
603 | 604 | ||
604 | lea esp, [eax+RING0_STACK_SIZE] |
605 | lea esp, [eax+RING0_STACK_SIZE] |
605 | 606 | ||
606 | mov [tss._ss0], os_stack |
607 | mov [tss._ss0], os_stack |
607 | mov [tss._esp0], esp |
608 | mov [tss._esp0], esp |
608 | mov [tss._esp], esp |
609 | mov [tss._esp], esp |
609 | mov [tss._cs], os_code |
610 | mov [tss._cs], os_code |
610 | mov [tss._ss], os_stack |
611 | mov [tss._ss], os_stack |
611 | mov [tss._ds], app_data |
612 | mov [tss._ds], app_data |
612 | mov [tss._es], app_data |
613 | mov [tss._es], app_data |
613 | mov [tss._fs], app_data |
614 | mov [tss._fs], app_data |
614 | mov [tss._gs], app_data |
615 | mov [tss._gs], app_data |
615 | mov [tss._io], 128 |
616 | mov [tss._io], 128 |
616 | ;Add IO access table - bit array of permitted ports |
617 | ;Add IO access table - bit array of permitted ports |
617 | mov edi, tss._io_map_0 |
618 | mov edi, tss._io_map_0 |
618 | xor eax, eax |
619 | xor eax, eax |
619 | not eax |
620 | not eax |
620 | mov ecx, 8192/4 |
621 | mov ecx, 8192/4 |
621 | rep stosd ; access to 4096*8=65536 ports |
622 | rep stosd ; access to 4096*8=65536 ports |
622 | 623 | ||
623 | mov ax, tss0 |
624 | mov ax, tss0 |
624 | ltr ax |
625 | ltr ax |
625 | 626 | ||
626 | mov [LFBSize], 0xC00000 |
627 | mov [LFBSize], 0xC00000 |
627 | call init_LFB |
628 | call init_LFB |
628 | call init_fpu |
629 | call init_fpu |
629 | call init_malloc |
630 | call init_malloc |
630 | 631 | ||
631 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
632 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
632 | mov [default_io_map], eax |
633 | mov [default_io_map], eax |
633 | 634 | ||
634 | add eax, 0x2000 |
635 | add eax, 0x2000 |
635 | mov [ipc_tmp], eax |
636 | mov [ipc_tmp], eax |
636 | mov ebx, 0x1000 |
637 | mov ebx, 0x1000 |
637 | 638 | ||
638 | add eax, 0x40000 |
639 | add eax, 0x40000 |
639 | mov [proc_mem_map], eax |
640 | mov [proc_mem_map], eax |
640 | 641 | ||
641 | add eax, 0x8000 |
642 | add eax, 0x8000 |
642 | mov [proc_mem_pdir], eax |
643 | mov [proc_mem_pdir], eax |
643 | 644 | ||
644 | add eax, ebx |
645 | add eax, ebx |
645 | mov [proc_mem_tab], eax |
646 | mov [proc_mem_tab], eax |
646 | 647 | ||
647 | add eax, ebx |
648 | add eax, ebx |
648 | mov [tmp_task_ptab], eax |
649 | mov [tmp_task_ptab], eax |
649 | 650 | ||
650 | add eax, ebx |
651 | add eax, ebx |
651 | mov [ipc_pdir], eax |
652 | mov [ipc_pdir], eax |
652 | 653 | ||
653 | add eax, ebx |
654 | add eax, ebx |
654 | mov [ipc_ptab], eax |
655 | mov [ipc_ptab], eax |
655 | 656 | ||
656 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
657 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
657 | (unpack.lc+unpack.lp)))*4 |
658 | (unpack.lc+unpack.lp)))*4 |
658 | 659 | ||
659 | mov [unpack.p], eax |
660 | mov [unpack.p], eax |
660 | 661 | ||
661 | call init_events |
662 | call init_events |
662 | mov eax, srv.fd-SRV.fd |
663 | mov eax, srv.fd-SRV.fd |
663 | mov [srv.fd], eax |
664 | mov [srv.fd], eax |
664 | mov [srv.bk], eax |
665 | mov [srv.bk], eax |
665 | 666 | ||
666 | ;Set base of graphic segment to linear address of LFB |
667 | ;Set base of graphic segment to linear address of LFB |
667 | mov eax, [LFBAddress] ; set for gs |
668 | mov eax, [LFBAddress] ; set for gs |
668 | mov [graph_data_l+2], ax |
669 | mov [graph_data_l+2], ax |
669 | shr eax, 16 |
670 | shr eax, 16 |
670 | mov [graph_data_l+4], al |
671 | mov [graph_data_l+4], al |
671 | mov [graph_data_l+7], ah |
672 | mov [graph_data_l+7], ah |
672 | 673 | ||
673 | stdcall kernel_alloc, [_display.win_map_size] |
674 | stdcall kernel_alloc, [_display.win_map_size] |
674 | mov [_display.win_map], eax |
675 | mov [_display.win_map], eax |
675 | 676 | ||
676 | xor eax, eax |
677 | xor eax, eax |
677 | inc eax |
678 | inc eax |
678 | 679 | ||
679 | ; set background |
680 | ; set background |
680 | 681 | ||
681 | mov [BgrDrawMode], eax |
682 | mov [BgrDrawMode], eax |
682 | mov [BgrDataWidth], eax |
683 | mov [BgrDataWidth], eax |
683 | mov [BgrDataHeight], eax |
684 | mov [BgrDataHeight], eax |
684 | mov [mem_BACKGROUND], 4 |
685 | mov [mem_BACKGROUND], 4 |
685 | mov [img_background], static_background_data |
686 | mov [img_background], static_background_data |
686 | 687 | ||
687 | ; set clipboard |
688 | ; set clipboard |
688 | 689 | ||
689 | xor eax, eax |
690 | xor eax, eax |
690 | mov [clipboard_slots], eax |
691 | mov [clipboard_slots], eax |
691 | mov [clipboard_write_lock], eax |
692 | mov [clipboard_write_lock], eax |
692 | stdcall kernel_alloc, 4096 |
693 | stdcall kernel_alloc, 4096 |
693 | test eax, eax |
694 | test eax, eax |
694 | jnz @f |
695 | jnz @f |
695 | 696 | ||
696 | dec eax |
697 | dec eax |
697 | @@: |
698 | @@: |
698 | mov [clipboard_main_list], eax |
699 | mov [clipboard_main_list], eax |
- | 700 | ||
- | 701 | mov eax, [hpet_base] |
|
- | 702 | test eax, eax |
|
- | 703 | jz @F |
|
- | 704 | DEBUGF 1, "K : HPET base %x\n", eax |
|
- | 705 | mov eax, [hpet_period] |
|
- | 706 | DEBUGF 1, "K : HPET period %d\n", eax |
|
- | 707 | mov eax, [hpet_timers] |
|
- | 708 | DEBUGF 1, "K : HPET timers %d\n", eax |
|
- | 709 | ||
- | 710 | mov eax, [hpet_base] |
|
- | 711 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
|
- | 712 | mov [hpet_base], eax |
|
- | 713 | ||
- | 714 | mov eax, [eax] |
|
- | 715 | DEBUGF 1, "K : HPET caps %x\n", eax |
|
- | 716 | ||
699 | 717 | @@: |
|
700 | ; SET UP OS TASK |
718 | ; SET UP OS TASK |
701 | 719 | ||
702 | mov esi, boot_setostask |
720 | mov esi, boot_setostask |
703 | call boot_log |
721 | call boot_log |
704 | 722 | ||
705 | mov eax, sys_proc |
723 | mov eax, sys_proc |
706 | lea edi, [eax+PROC.heap_lock] |
724 | lea edi, [eax+PROC.heap_lock] |
707 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
725 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
708 | 726 | ||
709 | list_init eax |
727 | list_init eax |
710 | add eax, PROC.thr_list |
728 | add eax, PROC.thr_list |
711 | list_init eax |
729 | list_init eax |
712 | 730 | ||
713 | xor eax, eax |
731 | xor eax, eax |
714 | cld |
732 | cld |
715 | rep stosd |
733 | rep stosd |
716 | 734 | ||
717 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
735 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
718 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
736 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
719 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
737 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
720 | add edi, 8 |
738 | add edi, 8 |
721 | inc eax |
739 | inc eax |
722 | @@: |
740 | @@: |
723 | stosd |
741 | stosd |
724 | inc eax |
742 | inc eax |
725 | cmp eax, ecx |
743 | cmp eax, ecx |
726 | jbe @B |
744 | jbe @B |
727 | 745 | ||
728 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
746 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
729 | 747 | ||
730 | mov eax, -1 |
748 | mov eax, -1 |
731 | mov edi, thr_slot_map+4 |
749 | mov edi, thr_slot_map+4 |
732 | mov [edi-4], dword 0xFFFFFFF8 |
750 | mov [edi-4], dword 0xFFFFFFF8 |
733 | stosd |
751 | stosd |
734 | stosd |
752 | stosd |
735 | stosd |
753 | stosd |
736 | stosd |
754 | stosd |
737 | stosd |
755 | stosd |
738 | stosd |
756 | stosd |
739 | stosd |
757 | stosd |
740 | 758 | ||
741 | mov [current_process], sys_proc |
759 | mov [current_process], sys_proc |
742 | 760 | ||
743 | mov edx, SLOT_BASE+256*1 |
761 | mov edx, SLOT_BASE+256*1 |
744 | mov ebx, [os_stack_seg] |
762 | mov ebx, [os_stack_seg] |
745 | add ebx, 0x2000 |
763 | add ebx, 0x2000 |
746 | call setup_os_slot |
764 | call setup_os_slot |
747 | mov dword [edx], 'IDLE' |
765 | mov dword [edx], 'IDLE' |
748 | sub [edx+APPDATA.saved_esp], 4 |
766 | sub [edx+APPDATA.saved_esp], 4 |
749 | mov eax, [edx+APPDATA.saved_esp] |
767 | mov eax, [edx+APPDATA.saved_esp] |
750 | mov dword [eax], idle_thread |
768 | mov dword [eax], idle_thread |
751 | mov ecx, IDLE_PRIORITY |
769 | mov ecx, IDLE_PRIORITY |
752 | call scheduler_add_thread |
770 | call scheduler_add_thread |
753 | 771 | ||
754 | mov edx, SLOT_BASE+256*2 |
772 | mov edx, SLOT_BASE+256*2 |
755 | mov ebx, [os_stack_seg] |
773 | mov ebx, [os_stack_seg] |
756 | call setup_os_slot |
774 | call setup_os_slot |
757 | mov dword [edx], 'OS' |
775 | mov dword [edx], 'OS' |
758 | xor ecx, ecx |
776 | xor ecx, ecx |
759 | call scheduler_add_thread |
777 | call scheduler_add_thread |
760 | 778 | ||
761 | mov dword [CURRENT_TASK], 2 |
779 | mov dword [CURRENT_TASK], 2 |
762 | mov dword [TASK_COUNT], 2 |
780 | mov dword [TASK_COUNT], 2 |
763 | mov dword [current_slot], SLOT_BASE + 256*2 |
781 | mov dword [current_slot], SLOT_BASE + 256*2 |
764 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
782 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
765 | 783 | ||
766 | ; Move other CPUs to deep sleep, if it is useful |
784 | ; Move other CPUs to deep sleep, if it is useful |
767 | uglobal |
785 | uglobal |
768 | use_mwait_for_idle db 0 |
786 | use_mwait_for_idle db 0 |
769 | endg |
787 | endg |
770 | cmp [cpu_vendor+8], 'ntel' |
788 | cmp [cpu_vendor+8], 'ntel' |
771 | jnz .no_wake_cpus |
789 | jnz .no_wake_cpus |
772 | bt [cpu_caps+4], CAPS_MONITOR-32 |
790 | bt [cpu_caps+4], CAPS_MONITOR-32 |
773 | jnc .no_wake_cpus |
791 | jnc .no_wake_cpus |
774 | dbgstr 'using mwait for idle loop' |
792 | dbgstr 'using mwait for idle loop' |
775 | inc [use_mwait_for_idle] |
793 | inc [use_mwait_for_idle] |
776 | mov ebx, [cpu_count] |
794 | mov ebx, [cpu_count] |
777 | cmp ebx, 1 |
795 | cmp ebx, 1 |
778 | jbe .no_wake_cpus |
796 | jbe .no_wake_cpus |
779 | call create_trampoline_pgmap |
797 | call create_trampoline_pgmap |
780 | mov [cr3_ap+OS_BASE], eax |
798 | mov [cr3_ap+OS_BASE], eax |
781 | mov eax, cr4 |
799 | mov eax, cr4 |
782 | mov [cr4_ap+OS_BASE], eax |
800 | mov [cr4_ap+OS_BASE], eax |
783 | mov esi, OS_BASE + ap_init16 |
801 | mov esi, OS_BASE + ap_init16 |
784 | mov edi, OS_BASE + 8000h |
802 | mov edi, OS_BASE + 8000h |
785 | mov ecx, (ap_init16_size + 3) / 4 |
803 | mov ecx, (ap_init16_size + 3) / 4 |
786 | rep movsd |
804 | rep movsd |
787 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
805 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
788 | mov [LAPIC_BASE], eax |
806 | mov [LAPIC_BASE], eax |
789 | lea edi, [eax+300h] |
807 | lea edi, [eax+300h] |
790 | mov esi, smpt+4 |
808 | mov esi, smpt+4 |
791 | dec ebx |
809 | dec ebx |
792 | .wake_cpus_loop: |
810 | .wake_cpus_loop: |
793 | lodsd |
811 | lodsd |
794 | push esi |
812 | push esi |
795 | xor esi, esi |
813 | xor esi, esi |
796 | inc esi |
814 | inc esi |
797 | shl eax, 24 |
815 | shl eax, 24 |
798 | mov [edi+10h], eax |
816 | mov [edi+10h], eax |
799 | ; assert INIT IPI |
817 | ; assert INIT IPI |
800 | mov dword [edi], 0C500h |
818 | mov dword [edi], 0C500h |
801 | call delay_ms |
819 | call delay_ms |
802 | @@: |
820 | @@: |
803 | test dword [edi], 1000h |
821 | test dword [edi], 1000h |
804 | jnz @b |
822 | jnz @b |
805 | ; deassert INIT IPI |
823 | ; deassert INIT IPI |
806 | mov dword [edi], 8500h |
824 | mov dword [edi], 8500h |
807 | call delay_ms |
825 | call delay_ms |
808 | @@: |
826 | @@: |
809 | test dword [edi], 1000h |
827 | test dword [edi], 1000h |
810 | jnz @b |
828 | jnz @b |
811 | ; send STARTUP IPI |
829 | ; send STARTUP IPI |
812 | mov dword [edi], 600h + (8000h shr 12) |
830 | mov dword [edi], 600h + (8000h shr 12) |
813 | call delay_ms |
831 | call delay_ms |
814 | @@: |
832 | @@: |
815 | test dword [edi], 1000h |
833 | test dword [edi], 1000h |
816 | jnz @b |
834 | jnz @b |
817 | pop esi |
835 | pop esi |
818 | dec ebx |
836 | dec ebx |
819 | jnz .wake_cpus_loop |
837 | jnz .wake_cpus_loop |
820 | mov eax, [cpu_count] |
838 | mov eax, [cpu_count] |
821 | dec eax |
839 | dec eax |
822 | @@: |
840 | @@: |
823 | cmp [ap_initialized], eax |
841 | cmp [ap_initialized], eax |
824 | jnz @b |
842 | jnz @b |
825 | mov eax, [cr3_ap+OS_BASE] |
843 | mov eax, [cr3_ap+OS_BASE] |
826 | call free_page |
844 | call free_page |
827 | .no_wake_cpus: |
845 | .no_wake_cpus: |
828 | 846 | ||
829 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
847 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
830 | mov esi, boot_initirq |
848 | mov esi, boot_initirq |
831 | call boot_log |
849 | call boot_log |
832 | call init_irqs |
850 | call init_irqs |
833 | 851 | ||
834 | mov esi, boot_picinit |
852 | mov esi, boot_picinit |
835 | call boot_log |
853 | call boot_log |
836 | call PIC_init |
854 | call PIC_init |
837 | 855 | ||
838 | mov esi, boot_v86machine |
856 | mov esi, boot_v86machine |
839 | call boot_log |
857 | call boot_log |
840 | ; Initialize system V86 machine |
858 | ; Initialize system V86 machine |
841 | call init_sys_v86 |
859 | call init_sys_v86 |
842 | 860 | ||
843 | mov esi, boot_inittimer |
861 | mov esi, boot_inittimer |
844 | call boot_log |
862 | call boot_log |
845 | ; Initialize system timer (IRQ0) |
863 | ; Initialize system timer (IRQ0) |
846 | call PIT_init |
864 | call PIT_init |
847 | 865 | ||
848 | ; Register ramdisk file system |
866 | ; Register ramdisk file system |
849 | cmp [boot_dev+OS_BASE+0x10000], 1 |
867 | cmp [boot_dev+OS_BASE+0x10000], 1 |
850 | je @f |
868 | je @f |
851 | 869 | ||
852 | call register_ramdisk |
870 | call register_ramdisk |
853 | ;-------------------------------------- |
871 | ;-------------------------------------- |
854 | @@: |
872 | @@: |
855 | mov esi, boot_initapic |
873 | mov esi, boot_initapic |
856 | call boot_log |
874 | call boot_log |
857 | ; Try to Initialize APIC |
875 | ; Try to Initialize APIC |
858 | call APIC_init |
876 | call APIC_init |
859 | 877 | ||
860 | mov esi, boot_enableirq |
878 | mov esi, boot_enableirq |
861 | call boot_log |
879 | call boot_log |
862 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
880 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
863 | ; they are used: when partitions are scanned, hd_read relies on timer |
881 | ; they are used: when partitions are scanned, hd_read relies on timer |
864 | call unmask_timer |
882 | call unmask_timer |
865 | stdcall enable_irq, 2 ; @#$%! PIC |
883 | stdcall enable_irq, 2 ; @#$%! PIC |
866 | stdcall enable_irq, 13 ; co-processor |
884 | stdcall enable_irq, 13 ; co-processor |
867 | 885 | ||
868 | ; Setup serial output console (if enabled) |
886 | ; Setup serial output console (if enabled) |
869 | if defined debug_com_base |
887 | if defined debug_com_base |
870 | 888 | ||
871 | ; reserve port so nobody else will use it |
889 | ; reserve port so nobody else will use it |
872 | xor ebx, ebx |
890 | xor ebx, ebx |
873 | mov ecx, debug_com_base |
891 | mov ecx, debug_com_base |
874 | mov edx, debug_com_base+7 |
892 | mov edx, debug_com_base+7 |
875 | call r_f_port_area |
893 | call r_f_port_area |
876 | 894 | ||
877 | ; enable Divisor latch |
895 | ; enable Divisor latch |
878 | mov dx, debug_com_base+3 |
896 | mov dx, debug_com_base+3 |
879 | mov al, 1 shl 7 |
897 | mov al, 1 shl 7 |
880 | out dx, al |
898 | out dx, al |
881 | 899 | ||
882 | ; Set speed to 115200 baud (max speed) |
900 | ; Set speed to 115200 baud (max speed) |
883 | mov dx, debug_com_base |
901 | mov dx, debug_com_base |
884 | mov al, 0x01 |
902 | mov al, 0x01 |
885 | out dx, al |
903 | out dx, al |
886 | 904 | ||
887 | mov dx, debug_com_base+1 |
905 | mov dx, debug_com_base+1 |
888 | mov al, 0x00 |
906 | mov al, 0x00 |
889 | out dx, al |
907 | out dx, al |
890 | 908 | ||
891 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
909 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
892 | mov dx, debug_com_base+3 |
910 | mov dx, debug_com_base+3 |
893 | mov al, 3 |
911 | mov al, 3 |
894 | out dx, al |
912 | out dx, al |
895 | 913 | ||
896 | ; disable interrupts |
914 | ; disable interrupts |
897 | mov dx, debug_com_base+1 |
915 | mov dx, debug_com_base+1 |
898 | mov al, 0 |
916 | mov al, 0 |
899 | out dx, al |
917 | out dx, al |
900 | 918 | ||
901 | ; clear + enable fifo (64 bits) |
919 | ; clear + enable fifo (64 bits) |
902 | mov dx, debug_com_base+2 |
920 | mov dx, debug_com_base+2 |
903 | mov al, 0x7 + 1 shl 5 |
921 | mov al, 0x7 + 1 shl 5 |
904 | out dx, al |
922 | out dx, al |
905 | 923 | ||
906 | end if |
924 | end if |
907 | 925 | ||
908 | 926 | ||
909 | ;----------------------------------------------------------------------------- |
927 | ;----------------------------------------------------------------------------- |
910 | ; show SVN version of kernel on the message board |
928 | ; show SVN version of kernel on the message board |
911 | ;----------------------------------------------------------------------------- |
929 | ;----------------------------------------------------------------------------- |
912 | mov eax, [version_inf.rev] |
930 | mov eax, [version_inf.rev] |
913 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
931 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
914 | ;----------------------------------------------------------------------------- |
932 | ;----------------------------------------------------------------------------- |
915 | ; show CPU count on the message board |
933 | ; show CPU count on the message board |
916 | ;----------------------------------------------------------------------------- |
934 | ;----------------------------------------------------------------------------- |
917 | mov eax, [cpu_count] |
935 | mov eax, [cpu_count] |
918 | test eax, eax |
936 | test eax, eax |
919 | jnz @F |
937 | jnz @F |
920 | mov al, 1 ; at least one CPU |
938 | mov al, 1 ; at least one CPU |
921 | @@: |
939 | @@: |
922 | DEBUGF 1, "K : %d CPU detected\n", eax |
940 | DEBUGF 1, "K : %d CPU detected\n", eax |
923 | ;----------------------------------------------------------------------------- |
941 | ;----------------------------------------------------------------------------- |
924 | ; detect Floppy drives |
942 | ; detect Floppy drives |
925 | ;----------------------------------------------------------------------------- |
943 | ;----------------------------------------------------------------------------- |
926 | mov esi, boot_detectfloppy |
944 | mov esi, boot_detectfloppy |
927 | call boot_log |
945 | call boot_log |
928 | include 'detect/dev_fd.inc' |
946 | include 'detect/dev_fd.inc' |
929 | ;----------------------------------------------------------------------------- |
947 | ;----------------------------------------------------------------------------- |
930 | ; create pci-devices list |
948 | ; create pci-devices list |
931 | ;----------------------------------------------------------------------------- |
949 | ;----------------------------------------------------------------------------- |
932 | mov [pci_access_enabled], 1 |
950 | mov [pci_access_enabled], 1 |
933 | call pci_enum |
951 | call pci_enum |
934 | ;----------------------------------------------------------------------------- |
952 | ;----------------------------------------------------------------------------- |
935 | ; initialisation IDE ATA code |
953 | ; initialisation IDE ATA code |
936 | ;----------------------------------------------------------------------------- |
954 | ;----------------------------------------------------------------------------- |
937 | include 'detect/init_ata.inc' |
955 | include 'detect/init_ata.inc' |
938 | ;----------------------------------------------------------------------------- |
956 | ;----------------------------------------------------------------------------- |
939 | if 0 |
957 | if 0 |
940 | mov ax, [OS_BASE+0x10000+bx_from_load] |
958 | mov ax, [OS_BASE+0x10000+bx_from_load] |
941 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
959 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
942 | je no_lib_load |
960 | je no_lib_load |
943 | 961 | ||
944 | mov esi, boot_loadlibs |
962 | mov esi, boot_loadlibs |
945 | call boot_log |
963 | call boot_log |
946 | ; LOADING LIBRARES |
964 | ; LOADING LIBRARES |
947 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
965 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
948 | call load_file_parse_table ; prepare file parse table |
966 | call load_file_parse_table ; prepare file parse table |
949 | call set_kernel_conf ; configure devices and gui |
967 | call set_kernel_conf ; configure devices and gui |
950 | no_lib_load: |
968 | no_lib_load: |
951 | end if |
969 | end if |
952 | 970 | ||
953 | ; Display APIC status |
971 | ; Display APIC status |
954 | mov esi, boot_APIC_found |
972 | mov esi, boot_APIC_found |
955 | cmp [irq_mode], IRQ_APIC |
973 | cmp [irq_mode], IRQ_APIC |
956 | je @f |
974 | je @f |
957 | mov esi, boot_APIC_nfound |
975 | mov esi, boot_APIC_nfound |
958 | @@: |
976 | @@: |
959 | call boot_log |
977 | call boot_log |
960 | 978 | ||
961 | ; PRINT AMOUNT OF MEMORY |
979 | ; PRINT AMOUNT OF MEMORY |
962 | mov esi, boot_memdetect |
980 | mov esi, boot_memdetect |
963 | call boot_log |
981 | call boot_log |
964 | 982 | ||
965 | movzx ecx, word [boot_y] |
983 | movzx ecx, word [boot_y] |
966 | if lang eq ru |
984 | if lang eq ru |
967 | or ecx, (10+30*6) shl 16 |
985 | or ecx, (10+30*6) shl 16 |
968 | else if lang eq sp |
986 | else if lang eq sp |
969 | or ecx, (10+33*6) shl 16 |
987 | or ecx, (10+33*6) shl 16 |
970 | else |
988 | else |
971 | or ecx, (10+29*6) shl 16 |
989 | or ecx, (10+29*6) shl 16 |
972 | end if |
990 | end if |
973 | sub ecx, 10 |
991 | sub ecx, 10 |
974 | mov edx, 0xFFFFFF |
992 | mov edx, 0xFFFFFF |
975 | mov ebx, [MEM_AMOUNT] |
993 | mov ebx, [MEM_AMOUNT] |
976 | shr ebx, 20 |
994 | shr ebx, 20 |
977 | xor edi, edi |
995 | xor edi, edi |
978 | mov eax, 0x00040000 |
996 | mov eax, 0x00040000 |
979 | inc edi |
997 | inc edi |
980 | call display_number_force |
998 | call display_number_force |
981 | 999 | ||
982 | ; BUILD SCHEDULER |
1000 | ; BUILD SCHEDULER |
983 | 1001 | ||
984 | ; call build_scheduler; sys32.inc |
1002 | ; call build_scheduler; sys32.inc |
985 | 1003 | ||
986 | ; mov esi, boot_devices |
1004 | ; mov esi, boot_devices |
987 | ; call boot_log |
1005 | ; call boot_log |
988 | 1006 | ||
989 | call clear_pci_ide_interrupts |
1007 | call clear_pci_ide_interrupts |
990 | 1008 | ||
991 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
1009 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
992 | 1010 | ||
993 | stdcall load_pe_driver, szVidintel, 0 |
1011 | stdcall load_pe_driver, szVidintel, 0 |
994 | 1012 | ||
995 | call usb_init |
1013 | call usb_init |
996 | 1014 | ||
997 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
1015 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
998 | 1016 | ||
999 | mov esi, boot_windefs |
1017 | mov esi, boot_windefs |
1000 | call boot_log |
1018 | call boot_log |
1001 | call set_window_defaults |
1019 | call set_window_defaults |
1002 | 1020 | ||
1003 | ; SET BACKGROUND DEFAULTS |
1021 | ; SET BACKGROUND DEFAULTS |
1004 | 1022 | ||
1005 | mov esi, boot_bgr |
1023 | mov esi, boot_bgr |
1006 | call boot_log |
1024 | call boot_log |
1007 | call init_background |
1025 | call init_background |
1008 | call calculatebackground |
1026 | call calculatebackground |
1009 | 1027 | ||
1010 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
1028 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
1011 | 1029 | ||
1012 | mov esi, boot_resirqports |
1030 | mov esi, boot_resirqports |
1013 | call boot_log |
1031 | call boot_log |
1014 | call reserve_irqs_ports |
1032 | call reserve_irqs_ports |
1015 | 1033 | ||
1016 | call init_display |
1034 | call init_display |
1017 | mov eax, [def_cursor] |
1035 | mov eax, [def_cursor] |
1018 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
1036 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
1019 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
1037 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
1020 | 1038 | ||
1021 | ; PRINT CPU FREQUENCY |
1039 | ; PRINT CPU FREQUENCY |
1022 | 1040 | ||
1023 | mov esi, boot_cpufreq |
1041 | mov esi, boot_cpufreq |
1024 | call boot_log |
1042 | call boot_log |
1025 | 1043 | ||
1026 | cli ;FIXME check IF |
1044 | cli ;FIXME check IF |
1027 | rdtsc |
1045 | rdtsc |
1028 | mov ecx, eax |
1046 | mov ecx, eax |
1029 | mov esi, 250 ; wait 1/4 a second |
1047 | mov esi, 250 ; wait 1/4 a second |
1030 | call delay_ms |
1048 | call delay_ms |
1031 | rdtsc |
1049 | rdtsc |
1032 | sti |
1050 | sti |
1033 | 1051 | ||
1034 | sub eax, ecx |
1052 | sub eax, ecx |
1035 | xor edx, edx |
1053 | xor edx, edx |
1036 | shld edx, eax, 2 |
1054 | shld edx, eax, 2 |
1037 | shl eax, 2 |
1055 | shl eax, 2 |
1038 | mov dword [cpu_freq], eax |
1056 | mov dword [cpu_freq], eax |
1039 | mov dword [cpu_freq+4], edx |
1057 | mov dword [cpu_freq+4], edx |
1040 | mov ebx, 1000000 |
1058 | mov ebx, 1000000 |
1041 | div ebx |
1059 | div ebx |
1042 | mov ebx, eax |
1060 | mov ebx, eax |
1043 | 1061 | ||
1044 | movzx ecx, word [boot_y] |
1062 | movzx ecx, word [boot_y] |
1045 | if lang eq ru |
1063 | if lang eq ru |
1046 | add ecx, (10+19*6) shl 16 - 10 |
1064 | add ecx, (10+19*6) shl 16 - 10 |
1047 | else if lang eq sp |
1065 | else if lang eq sp |
1048 | add ecx, (10+25*6) shl 16 - 10 |
1066 | add ecx, (10+25*6) shl 16 - 10 |
1049 | else |
1067 | else |
1050 | add ecx, (10+17*6) shl 16 - 10 |
1068 | add ecx, (10+17*6) shl 16 - 10 |
1051 | end if |
1069 | end if |
1052 | 1070 | ||
1053 | mov edx, 0xFFFFFF |
1071 | mov edx, 0xFFFFFF |
1054 | xor edi, edi |
1072 | xor edi, edi |
1055 | mov eax, 0x00040000 |
1073 | mov eax, 0x00040000 |
1056 | inc edi |
1074 | inc edi |
1057 | call display_number_force |
1075 | call display_number_force |
1058 | 1076 | ||
1059 | ; SET VARIABLES |
1077 | ; SET VARIABLES |
1060 | 1078 | ||
1061 | call set_variables |
1079 | call set_variables |
1062 | 1080 | ||
1063 | ; STACK AND FDC |
1081 | ; STACK AND FDC |
1064 | 1082 | ||
1065 | call stack_init |
1083 | call stack_init |
1066 | call fdc_init |
1084 | call fdc_init |
1067 | 1085 | ||
1068 | ; PALETTE FOR 320x200 and 640x480 16 col |
1086 | ; PALETTE FOR 320x200 and 640x480 16 col |
1069 | 1087 | ||
1070 | cmp [SCR_MODE], word 0x12 |
1088 | cmp [SCR_MODE], word 0x12 |
1071 | jne no_pal_vga |
1089 | jne no_pal_vga |
1072 | mov esi, boot_pal_vga |
1090 | mov esi, boot_pal_vga |
1073 | call boot_log |
1091 | call boot_log |
1074 | call paletteVGA |
1092 | call paletteVGA |
1075 | no_pal_vga: |
1093 | no_pal_vga: |
1076 | 1094 | ||
1077 | cmp [SCR_MODE], word 0x13 |
1095 | cmp [SCR_MODE], word 0x13 |
1078 | jne no_pal_ega |
1096 | jne no_pal_ega |
1079 | mov esi, boot_pal_ega |
1097 | mov esi, boot_pal_ega |
1080 | call boot_log |
1098 | call boot_log |
1081 | call palette320x200 |
1099 | call palette320x200 |
1082 | no_pal_ega: |
1100 | no_pal_ega: |
1083 | 1101 | ||
1084 | ; LOAD DEFAULT SKIN |
1102 | ; LOAD DEFAULT SKIN |
1085 | 1103 | ||
1086 | call load_default_skin |
1104 | call load_default_skin |
1087 | 1105 | ||
1088 | ; Protect I/O permission map |
1106 | ; Protect I/O permission map |
1089 | 1107 | ||
1090 | mov esi, [default_io_map] |
1108 | mov esi, [default_io_map] |
1091 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1109 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1092 | add esi, 0x1000 |
1110 | add esi, 0x1000 |
1093 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1111 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1094 | 1112 | ||
1095 | stdcall map_page, tss._io_map_0, \ |
1113 | stdcall map_page, tss._io_map_0, \ |
1096 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1114 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
1097 | stdcall map_page, tss._io_map_1, \ |
1115 | stdcall map_page, tss._io_map_1, \ |
1098 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1116 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
1099 | 1117 | ||
1100 | ; SET KEYBOARD PARAMETERS |
1118 | ; SET KEYBOARD PARAMETERS |
1101 | mov al, 0xf6 ; reset keyboard, scan enabled |
1119 | mov al, 0xf6 ; reset keyboard, scan enabled |
1102 | call kb_write_wait_ack |
1120 | call kb_write_wait_ack |
1103 | test ah, ah |
1121 | test ah, ah |
1104 | jnz .no_keyboard |
1122 | jnz .no_keyboard |
1105 | 1123 | ||
1106 | iglobal |
1124 | iglobal |
1107 | align 4 |
1125 | align 4 |
1108 | ps2_keyboard_functions: |
1126 | ps2_keyboard_functions: |
1109 | dd .end - $ |
1127 | dd .end - $ |
1110 | dd 0 ; no close |
1128 | dd 0 ; no close |
1111 | dd ps2_set_lights |
1129 | dd ps2_set_lights |
1112 | .end: |
1130 | .end: |
1113 | endg |
1131 | endg |
1114 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1132 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1115 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1133 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1116 | ; call kb_write_wait_ack |
1134 | ; call kb_write_wait_ack |
1117 | ; mov al, 111b |
1135 | ; mov al, 111b |
1118 | ; call kb_write_wait_ack |
1136 | ; call kb_write_wait_ack |
1119 | 1137 | ||
1120 | mov al, 0xF3 ; set repeat rate & delay |
1138 | mov al, 0xF3 ; set repeat rate & delay |
1121 | call kb_write_wait_ack |
1139 | call kb_write_wait_ack |
1122 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1140 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1123 | call kb_write_wait_ack |
1141 | call kb_write_wait_ack |
1124 | ;// mike.dld [ |
1142 | ;// mike.dld [ |
1125 | call set_lights |
1143 | call set_lights |
1126 | ;// mike.dld ] |
1144 | ;// mike.dld ] |
1127 | stdcall attach_int_handler, 1, irq1, 0 |
1145 | stdcall attach_int_handler, 1, irq1, 0 |
1128 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1146 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1129 | .no_keyboard: |
1147 | .no_keyboard: |
1130 | 1148 | ||
1131 | ; Load PS/2 mouse driver |
1149 | ; Load PS/2 mouse driver |
1132 | 1150 | ||
1133 | stdcall load_pe_driver, szPS2MDriver, 0 |
1151 | stdcall load_pe_driver, szPS2MDriver, 0 |
1134 | 1152 | ||
1135 | mov esi, boot_setmouse |
1153 | mov esi, boot_setmouse |
1136 | call boot_log |
1154 | call boot_log |
1137 | call setmouse |
1155 | call setmouse |
1138 | 1156 | ||
1139 | ; LOAD FIRST APPLICATION |
1157 | ; LOAD FIRST APPLICATION |
1140 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1158 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1141 | jnz first_app_found |
1159 | jnz first_app_found |
1142 | 1160 | ||
1143 | cli |
1161 | cli |
1144 | mov ebp, firstapp |
1162 | mov ebp, firstapp |
1145 | call fs_execute_from_sysdir |
1163 | call fs_execute_from_sysdir |
1146 | test eax, eax |
1164 | test eax, eax |
1147 | jns first_app_found |
1165 | jns first_app_found |
1148 | 1166 | ||
1149 | mov esi, boot_failed |
1167 | mov esi, boot_failed |
1150 | call boot_log |
1168 | call boot_log |
1151 | 1169 | ||
1152 | mov eax, 0xDEADBEEF ; otherwise halt |
1170 | mov eax, 0xDEADBEEF ; otherwise halt |
1153 | hlt |
1171 | hlt |
1154 | 1172 | ||
1155 | first_app_found: |
1173 | first_app_found: |
1156 | 1174 | ||
1157 | ; START MULTITASKING |
1175 | ; START MULTITASKING |
1158 | 1176 | ||
1159 | ; A 'All set - press ESC to start' messages if need |
1177 | ; A 'All set - press ESC to start' messages if need |
1160 | if preboot_blogesc |
1178 | if preboot_blogesc |
1161 | mov esi, boot_tasking |
1179 | mov esi, boot_tasking |
1162 | call boot_log |
1180 | call boot_log |
1163 | .bll1: |
1181 | .bll1: |
1164 | in al, 0x60 ; wait for ESC key press |
1182 | in al, 0x60 ; wait for ESC key press |
1165 | cmp al, 129 |
1183 | cmp al, 129 |
1166 | jne .bll1 |
1184 | jne .bll1 |
1167 | end if |
1185 | end if |
1168 | 1186 | ||
1169 | mov [timer_ticks_enable], 1 ; for cd driver |
1187 | mov [timer_ticks_enable], 1 ; for cd driver |
1170 | 1188 | ||
1171 | sti |
1189 | sti |
1172 | 1190 | ||
1173 | call mtrr_validate |
1191 | call mtrr_validate |
1174 | 1192 | ||
1175 | jmp osloop |
1193 | jmp osloop |
1176 | 1194 | ||
1177 | 1195 | ||
1178 | ; Fly :) |
1196 | ; Fly :) |
1179 | 1197 | ||
1180 | uglobal |
1198 | uglobal |
1181 | align 4 |
1199 | align 4 |
1182 | ap_initialized dd 0 |
1200 | ap_initialized dd 0 |
1183 | endg |
1201 | endg |
1184 | 1202 | ||
1185 | ap_init_high: |
1203 | ap_init_high: |
1186 | mov ax, os_stack |
1204 | mov ax, os_stack |
1187 | mov bx, app_data |
1205 | mov bx, app_data |
1188 | mov cx, app_tls |
1206 | mov cx, app_tls |
1189 | mov ss, ax |
1207 | mov ss, ax |
1190 | mov ds, bx |
1208 | mov ds, bx |
1191 | mov es, bx |
1209 | mov es, bx |
1192 | mov fs, cx |
1210 | mov fs, cx |
1193 | mov gs, bx |
1211 | mov gs, bx |
1194 | xor esp, esp |
1212 | xor esp, esp |
1195 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1213 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1196 | mov cr3, eax |
1214 | mov cr3, eax |
1197 | lock inc [ap_initialized] |
1215 | lock inc [ap_initialized] |
1198 | jmp idle_loop |
1216 | jmp idle_loop |
1199 | 1217 | ||
1200 | 1218 | ||
1201 | include 'unpacker.inc' |
1219 | include 'unpacker.inc' |
1202 | 1220 | ||
1203 | align 4 |
1221 | align 4 |
1204 | boot_log: |
1222 | boot_log: |
1205 | pushad |
1223 | pushad |
1206 | 1224 | ||
1207 | mov ebx, 10*65536 |
1225 | mov ebx, 10*65536 |
1208 | mov bx, word [boot_y] |
1226 | mov bx, word [boot_y] |
1209 | add [boot_y], dword 10 |
1227 | add [boot_y], dword 10 |
1210 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1228 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1211 | xor edi, edi |
1229 | xor edi, edi |
1212 | mov edx, esi |
1230 | mov edx, esi |
1213 | inc edi |
1231 | inc edi |
1214 | call dtext |
1232 | call dtext |
1215 | 1233 | ||
1216 | mov [novesachecksum], 1000 |
1234 | mov [novesachecksum], 1000 |
1217 | call checkVga_N13 |
1235 | call checkVga_N13 |
1218 | 1236 | ||
1219 | popad |
1237 | popad |
1220 | 1238 | ||
1221 | ret |
1239 | ret |
1222 | 1240 | ||
1223 | ; in: edx -> APPDATA for OS/IDLE slot |
1241 | ; in: edx -> APPDATA for OS/IDLE slot |
1224 | ; in: ebx = stack base |
1242 | ; in: ebx = stack base |
1225 | proc setup_os_slot |
1243 | proc setup_os_slot |
1226 | xor eax, eax |
1244 | xor eax, eax |
1227 | mov ecx, 256/4 |
1245 | mov ecx, 256/4 |
1228 | mov edi, edx |
1246 | mov edi, edx |
1229 | rep stosd |
1247 | rep stosd |
1230 | 1248 | ||
1231 | mov eax, tss+0x80 |
1249 | mov eax, tss+0x80 |
1232 | call get_pg_addr |
1250 | call get_pg_addr |
1233 | inc eax |
1251 | inc eax |
1234 | mov [edx+APPDATA.io_map], eax |
1252 | mov [edx+APPDATA.io_map], eax |
1235 | mov eax, tss+0x1080 |
1253 | mov eax, tss+0x1080 |
1236 | call get_pg_addr |
1254 | call get_pg_addr |
1237 | inc eax |
1255 | inc eax |
1238 | mov [edx+APPDATA.io_map+4], eax |
1256 | mov [edx+APPDATA.io_map+4], eax |
1239 | 1257 | ||
1240 | mov dword [edx+APPDATA.pl0_stack], ebx |
1258 | mov dword [edx+APPDATA.pl0_stack], ebx |
1241 | lea edi, [ebx+0x2000-512] |
1259 | lea edi, [ebx+0x2000-512] |
1242 | mov dword [edx+APPDATA.fpu_state], edi |
1260 | mov dword [edx+APPDATA.fpu_state], edi |
1243 | mov dword [edx+APPDATA.saved_esp0], edi |
1261 | mov dword [edx+APPDATA.saved_esp0], edi |
1244 | mov dword [edx+APPDATA.saved_esp], edi |
1262 | mov dword [edx+APPDATA.saved_esp], edi |
1245 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1263 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1246 | 1264 | ||
1247 | mov esi, fpu_data |
1265 | mov esi, fpu_data |
1248 | mov ecx, 512/4 |
1266 | mov ecx, 512/4 |
1249 | cld |
1267 | cld |
1250 | rep movsd |
1268 | rep movsd |
1251 | 1269 | ||
1252 | lea eax, [edx+APP_OBJ_OFFSET] |
1270 | lea eax, [edx+APP_OBJ_OFFSET] |
1253 | mov dword [edx+APPDATA.fd_obj], eax |
1271 | mov dword [edx+APPDATA.fd_obj], eax |
1254 | mov dword [edx+APPDATA.bk_obj], eax |
1272 | mov dword [edx+APPDATA.bk_obj], eax |
1255 | 1273 | ||
1256 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1274 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1257 | 1275 | ||
1258 | mov [edx + APPDATA.process], sys_proc |
1276 | mov [edx + APPDATA.process], sys_proc |
1259 | 1277 | ||
1260 | lea ebx, [edx+APPDATA.list] |
1278 | lea ebx, [edx+APPDATA.list] |
1261 | lea ecx, [sys_proc+PROC.thr_list] |
1279 | lea ecx, [sys_proc+PROC.thr_list] |
1262 | list_add_tail ebx, ecx |
1280 | list_add_tail ebx, ecx |
1263 | 1281 | ||
1264 | mov eax, edx |
1282 | mov eax, edx |
1265 | shr eax, 3 |
1283 | shr eax, 3 |
1266 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1284 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1267 | mov [eax+TASKDATA.wnd_number], dh |
1285 | mov [eax+TASKDATA.wnd_number], dh |
1268 | mov byte [eax+TASKDATA.pid], dh |
1286 | mov byte [eax+TASKDATA.pid], dh |
1269 | 1287 | ||
1270 | ret |
1288 | ret |
1271 | endp |
1289 | endp |
1272 | 1290 | ||
1273 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1291 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1274 | ; ; |
1292 | ; ; |
1275 | ; MAIN OS LOOP START ; |
1293 | ; MAIN OS LOOP START ; |
1276 | ; ; |
1294 | ; ; |
1277 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1295 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1278 | align 32 |
1296 | align 32 |
1279 | osloop: |
1297 | osloop: |
1280 | mov edx, osloop_has_work? |
1298 | mov edx, osloop_has_work? |
1281 | xor ecx, ecx |
1299 | xor ecx, ecx |
1282 | call Wait_events |
1300 | call Wait_events |
1283 | xor eax, eax |
1301 | xor eax, eax |
1284 | xchg eax, [osloop_nonperiodic_work] |
1302 | xchg eax, [osloop_nonperiodic_work] |
1285 | test eax, eax |
1303 | test eax, eax |
1286 | jz .no_periodic |
1304 | jz .no_periodic |
1287 | 1305 | ||
1288 | call __sys_draw_pointer |
1306 | call __sys_draw_pointer |
1289 | call window_check_events |
1307 | call window_check_events |
1290 | call mouse_check_events |
1308 | call mouse_check_events |
1291 | call checkmisc |
1309 | call checkmisc |
1292 | call checkVga_N13 |
1310 | call checkVga_N13 |
1293 | ;-------------------------------------- |
1311 | ;-------------------------------------- |
1294 | .no_periodic: |
1312 | .no_periodic: |
1295 | call stack_handler |
1313 | call stack_handler |
1296 | call check_fdd_motor_status |
1314 | call check_fdd_motor_status |
1297 | call check_ATAPI_device_event |
1315 | call check_ATAPI_device_event |
1298 | call check_lights_state |
1316 | call check_lights_state |
1299 | call check_timers |
1317 | call check_timers |
1300 | 1318 | ||
1301 | jmp osloop |
1319 | jmp osloop |
1302 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1320 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1303 | ; ; |
1321 | ; ; |
1304 | ; MAIN OS LOOP END ; |
1322 | ; MAIN OS LOOP END ; |
1305 | ; ; |
1323 | ; ; |
1306 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1324 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1307 | proc osloop_has_work? |
1325 | proc osloop_has_work? |
1308 | cmp [osloop_nonperiodic_work], 0 |
1326 | cmp [osloop_nonperiodic_work], 0 |
1309 | jnz .yes |
1327 | jnz .yes |
1310 | call stack_handler_has_work? |
1328 | call stack_handler_has_work? |
1311 | jnz .yes |
1329 | jnz .yes |
1312 | call check_fdd_motor_status_has_work? |
1330 | call check_fdd_motor_status_has_work? |
1313 | jnz .yes |
1331 | jnz .yes |
1314 | call check_ATAPI_device_event_has_work? |
1332 | call check_ATAPI_device_event_has_work? |
1315 | jnz .yes |
1333 | jnz .yes |
1316 | call check_lights_state_has_work? |
1334 | call check_lights_state_has_work? |
1317 | jnz .yes |
1335 | jnz .yes |
1318 | call check_timers_has_work? |
1336 | call check_timers_has_work? |
1319 | jnz .yes |
1337 | jnz .yes |
1320 | .no: |
1338 | .no: |
1321 | xor eax, eax |
1339 | xor eax, eax |
1322 | ret |
1340 | ret |
1323 | .yes: |
1341 | .yes: |
1324 | xor eax, eax |
1342 | xor eax, eax |
1325 | inc eax |
1343 | inc eax |
1326 | ret |
1344 | ret |
1327 | endp |
1345 | endp |
1328 | 1346 | ||
1329 | proc wakeup_osloop |
1347 | proc wakeup_osloop |
1330 | mov [osloop_nonperiodic_work], 1 |
1348 | mov [osloop_nonperiodic_work], 1 |
1331 | ret |
1349 | ret |
1332 | endp |
1350 | endp |
1333 | 1351 | ||
1334 | uglobal |
1352 | uglobal |
1335 | align 4 |
1353 | align 4 |
1336 | osloop_nonperiodic_work dd ? |
1354 | osloop_nonperiodic_work dd ? |
1337 | endg |
1355 | endg |
1338 | 1356 | ||
1339 | uglobal |
1357 | uglobal |
1340 | align 64 |
1358 | align 64 |
1341 | idle_addr rb 64 |
1359 | idle_addr rb 64 |
1342 | endg |
1360 | endg |
1343 | 1361 | ||
1344 | idle_thread: |
1362 | idle_thread: |
1345 | sti |
1363 | sti |
1346 | 1364 | ||
1347 | ; The following code can be executed by all CPUs in the system. |
1365 | ; The following code can be executed by all CPUs in the system. |
1348 | ; All other parts of the kernel do not expect multi-CPU. |
1366 | ; All other parts of the kernel do not expect multi-CPU. |
1349 | ; Also, APs don't even have a stack here. |
1367 | ; Also, APs don't even have a stack here. |
1350 | ; Beware. Don't do anything here. Anything at all. |
1368 | ; Beware. Don't do anything here. Anything at all. |
1351 | idle_loop: |
1369 | idle_loop: |
1352 | cmp [use_mwait_for_idle], 0 |
1370 | cmp [use_mwait_for_idle], 0 |
1353 | jnz idle_loop_mwait |
1371 | jnz idle_loop_mwait |
1354 | 1372 | ||
1355 | idle_loop_hlt: |
1373 | idle_loop_hlt: |
1356 | hlt |
1374 | hlt |
1357 | jmp idle_loop_hlt |
1375 | jmp idle_loop_hlt |
1358 | 1376 | ||
1359 | idle_loop_mwait: |
1377 | idle_loop_mwait: |
1360 | mov eax, idle_addr |
1378 | mov eax, idle_addr |
1361 | xor ecx, ecx |
1379 | xor ecx, ecx |
1362 | xor edx, edx |
1380 | xor edx, edx |
1363 | monitor |
1381 | monitor |
1364 | xor ecx, ecx |
1382 | xor ecx, ecx |
1365 | mov eax, 20h ; or 10h |
1383 | mov eax, 20h ; or 10h |
1366 | mwait |
1384 | mwait |
1367 | jmp idle_loop_mwait |
1385 | jmp idle_loop_mwait |
1368 | 1386 | ||
1369 | 1387 | ||
1370 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1388 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1371 | ; ; |
1389 | ; ; |
1372 | ; INCLUDED SYSTEM FILES ; |
1390 | ; INCLUDED SYSTEM FILES ; |
1373 | ; ; |
1391 | ; ; |
1374 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1392 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1375 | 1393 | ||
1376 | 1394 | ||
1377 | include "kernel32.inc" |
1395 | include "kernel32.inc" |
1378 | 1396 | ||
1379 | 1397 | ||
1380 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1398 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1381 | ; ; |
1399 | ; ; |
1382 | ; KERNEL FUNCTIONS ; |
1400 | ; KERNEL FUNCTIONS ; |
1383 | ; ; |
1401 | ; ; |
1384 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1402 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1385 | 1403 | ||
1386 | reserve_irqs_ports: |
1404 | reserve_irqs_ports: |
1387 | 1405 | ||
1388 | 1406 | ||
1389 | ; RESERVE PORTS |
1407 | ; RESERVE PORTS |
1390 | mov eax, RESERVED_PORTS |
1408 | mov eax, RESERVED_PORTS |
1391 | mov ecx, 1 |
1409 | mov ecx, 1 |
1392 | 1410 | ||
1393 | mov [eax], dword 4 |
1411 | mov [eax], dword 4 |
1394 | 1412 | ||
1395 | mov [eax+16], ecx |
1413 | mov [eax+16], ecx |
1396 | mov [eax+16+4], dword 0 |
1414 | mov [eax+16+4], dword 0 |
1397 | mov [eax+16+8], dword 0x2D |
1415 | mov [eax+16+8], dword 0x2D |
1398 | 1416 | ||
1399 | mov [eax+32], ecx |
1417 | mov [eax+32], ecx |
1400 | mov [eax+32+4], dword 0x30 |
1418 | mov [eax+32+4], dword 0x30 |
1401 | mov [eax+32+8], dword 0x4D |
1419 | mov [eax+32+8], dword 0x4D |
1402 | 1420 | ||
1403 | mov [eax+48], ecx |
1421 | mov [eax+48], ecx |
1404 | mov [eax+48+4], dword 0x50 |
1422 | mov [eax+48+4], dword 0x50 |
1405 | mov [eax+48+8], dword 0xDF |
1423 | mov [eax+48+8], dword 0xDF |
1406 | 1424 | ||
1407 | mov [eax+64], ecx |
1425 | mov [eax+64], ecx |
1408 | mov [eax+64+4], dword 0xE5 |
1426 | mov [eax+64+4], dword 0xE5 |
1409 | mov [eax+64+8], dword 0xFF |
1427 | mov [eax+64+8], dword 0xFF |
1410 | 1428 | ||
1411 | ret |
1429 | ret |
1412 | 1430 | ||
1413 | 1431 | ||
1414 | iglobal |
1432 | iglobal |
1415 | process_number dd 0x2 |
1433 | process_number dd 0x2 |
1416 | endg |
1434 | endg |
1417 | 1435 | ||
1418 | set_variables: |
1436 | set_variables: |
1419 | 1437 | ||
1420 | mov ecx, 0x16 ; flush port 0x60 |
1438 | mov ecx, 0x16 ; flush port 0x60 |
1421 | .fl60: |
1439 | .fl60: |
1422 | in al, 0x60 |
1440 | in al, 0x60 |
1423 | loop .fl60 |
1441 | loop .fl60 |
1424 | push eax |
1442 | push eax |
1425 | 1443 | ||
1426 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1444 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1427 | shr ax, 1 |
1445 | shr ax, 1 |
1428 | shl eax, 16 |
1446 | shl eax, 16 |
1429 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1447 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1430 | shr ax, 1 |
1448 | shr ax, 1 |
1431 | mov [MOUSE_X], eax |
1449 | mov [MOUSE_X], eax |
1432 | call wakeup_osloop |
1450 | call wakeup_osloop |
1433 | 1451 | ||
1434 | xor eax, eax |
1452 | xor eax, eax |
1435 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1453 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1436 | 1454 | ||
1437 | mov byte [KEY_COUNT], al ; keyboard buffer |
1455 | mov byte [KEY_COUNT], al ; keyboard buffer |
1438 | mov byte [BTN_COUNT], al ; button buffer |
1456 | mov byte [BTN_COUNT], al ; button buffer |
1439 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1457 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1440 | 1458 | ||
1441 | pop eax |
1459 | pop eax |
1442 | ret |
1460 | ret |
1443 | 1461 | ||
1444 | align 4 |
1462 | align 4 |
1445 | ;input eax=43,bl-byte of output, ecx - number of port |
1463 | ;input eax=43,bl-byte of output, ecx - number of port |
1446 | sys_outport: |
1464 | sys_outport: |
1447 | 1465 | ||
1448 | mov edi, ecx ; separate flag for read / write |
1466 | mov edi, ecx ; separate flag for read / write |
1449 | and ecx, 65535 |
1467 | and ecx, 65535 |
1450 | 1468 | ||
1451 | mov eax, [RESERVED_PORTS] |
1469 | mov eax, [RESERVED_PORTS] |
1452 | test eax, eax |
1470 | test eax, eax |
1453 | jnz .sopl8 |
1471 | jnz .sopl8 |
1454 | inc eax |
1472 | inc eax |
1455 | mov [esp+32], eax |
1473 | mov [esp+32], eax |
1456 | ret |
1474 | ret |
1457 | 1475 | ||
1458 | .sopl8: |
1476 | .sopl8: |
1459 | mov edx, [TASK_BASE] |
1477 | mov edx, [TASK_BASE] |
1460 | mov edx, [edx+0x4] |
1478 | mov edx, [edx+0x4] |
1461 | ;and ecx,65535 |
1479 | ;and ecx,65535 |
1462 | ;cld - set on interrupt 0x40 |
1480 | ;cld - set on interrupt 0x40 |
1463 | .sopl1: |
1481 | .sopl1: |
1464 | 1482 | ||
1465 | mov esi, eax |
1483 | mov esi, eax |
1466 | shl esi, 4 |
1484 | shl esi, 4 |
1467 | add esi, RESERVED_PORTS |
1485 | add esi, RESERVED_PORTS |
1468 | cmp edx, [esi+0] |
1486 | cmp edx, [esi+0] |
1469 | jne .sopl2 |
1487 | jne .sopl2 |
1470 | cmp ecx, [esi+4] |
1488 | cmp ecx, [esi+4] |
1471 | jb .sopl2 |
1489 | jb .sopl2 |
1472 | cmp ecx, [esi+8] |
1490 | cmp ecx, [esi+8] |
1473 | jg .sopl2 |
1491 | jg .sopl2 |
1474 | .sopl3: |
1492 | .sopl3: |
1475 | 1493 | ||
1476 | test edi, 0x80000000; read ? |
1494 | test edi, 0x80000000; read ? |
1477 | jnz .sopl4 |
1495 | jnz .sopl4 |
1478 | 1496 | ||
1479 | mov eax, ebx |
1497 | mov eax, ebx |
1480 | mov dx, cx ; write |
1498 | mov dx, cx ; write |
1481 | out dx, al |
1499 | out dx, al |
1482 | and [esp+32], dword 0 |
1500 | and [esp+32], dword 0 |
1483 | ret |
1501 | ret |
1484 | 1502 | ||
1485 | .sopl2: |
1503 | .sopl2: |
1486 | 1504 | ||
1487 | dec eax |
1505 | dec eax |
1488 | jnz .sopl1 |
1506 | jnz .sopl1 |
1489 | inc eax |
1507 | inc eax |
1490 | mov [esp+32], eax |
1508 | mov [esp+32], eax |
1491 | ret |
1509 | ret |
1492 | 1510 | ||
1493 | 1511 | ||
1494 | .sopl4: |
1512 | .sopl4: |
1495 | 1513 | ||
1496 | mov dx, cx ; read |
1514 | mov dx, cx ; read |
1497 | in al, dx |
1515 | in al, dx |
1498 | and eax, 0xff |
1516 | and eax, 0xff |
1499 | and [esp+32], dword 0 |
1517 | and [esp+32], dword 0 |
1500 | mov [esp+20], eax |
1518 | mov [esp+20], eax |
1501 | ret |
1519 | ret |
1502 | 1520 | ||
1503 | display_number: |
1521 | display_number: |
1504 | ;It is not optimization |
1522 | ;It is not optimization |
1505 | mov eax, ebx |
1523 | mov eax, ebx |
1506 | mov ebx, ecx |
1524 | mov ebx, ecx |
1507 | mov ecx, edx |
1525 | mov ecx, edx |
1508 | mov edx, esi |
1526 | mov edx, esi |
1509 | mov esi, edi |
1527 | mov esi, edi |
1510 | ; eax = print type, al=0 -> ebx is number |
1528 | ; eax = print type, al=0 -> ebx is number |
1511 | ; al=1 -> ebx is pointer |
1529 | ; al=1 -> ebx is pointer |
1512 | ; ah=0 -> display decimal |
1530 | ; ah=0 -> display decimal |
1513 | ; ah=1 -> display hexadecimal |
1531 | ; ah=1 -> display hexadecimal |
1514 | ; ah=2 -> display binary |
1532 | ; ah=2 -> display binary |
1515 | ; eax bits 16-21 = number of digits to display (0-32) |
1533 | ; eax bits 16-21 = number of digits to display (0-32) |
1516 | ; eax bits 22-31 = reserved |
1534 | ; eax bits 22-31 = reserved |
1517 | ; |
1535 | ; |
1518 | ; ebx = number or pointer |
1536 | ; ebx = number or pointer |
1519 | ; ecx = x shl 16 + y |
1537 | ; ecx = x shl 16 + y |
1520 | ; edx = color |
1538 | ; edx = color |
1521 | xor edi, edi |
1539 | xor edi, edi |
1522 | display_number_force: |
1540 | display_number_force: |
1523 | push eax |
1541 | push eax |
1524 | and eax, 0x3fffffff |
1542 | and eax, 0x3fffffff |
1525 | cmp eax, 0xffff ; length > 0 ? |
1543 | cmp eax, 0xffff ; length > 0 ? |
1526 | pop eax |
1544 | pop eax |
1527 | jge cont_displ |
1545 | jge cont_displ |
1528 | ret |
1546 | ret |
1529 | cont_displ: |
1547 | cont_displ: |
1530 | push eax |
1548 | push eax |
1531 | and eax, 0x3fffffff |
1549 | and eax, 0x3fffffff |
1532 | cmp eax, 61*0x10000 ; length <= 60 ? |
1550 | cmp eax, 61*0x10000 ; length <= 60 ? |
1533 | pop eax |
1551 | pop eax |
1534 | jb cont_displ2 |
1552 | jb cont_displ2 |
1535 | ret |
1553 | ret |
1536 | cont_displ2: |
1554 | cont_displ2: |
1537 | 1555 | ||
1538 | pushad |
1556 | pushad |
1539 | 1557 | ||
1540 | cmp al, 1 ; ecx is a pointer ? |
1558 | cmp al, 1 ; ecx is a pointer ? |
1541 | jne displnl1 |
1559 | jne displnl1 |
1542 | mov ebp, ebx |
1560 | mov ebp, ebx |
1543 | add ebp, 4 |
1561 | add ebp, 4 |
1544 | mov ebp, [ebp+std_application_base_address] |
1562 | mov ebp, [ebp+std_application_base_address] |
1545 | mov ebx, [ebx+std_application_base_address] |
1563 | mov ebx, [ebx+std_application_base_address] |
1546 | displnl1: |
1564 | displnl1: |
1547 | sub esp, 64 |
1565 | sub esp, 64 |
1548 | 1566 | ||
1549 | test ah, ah ; DECIMAL |
1567 | test ah, ah ; DECIMAL |
1550 | jnz no_display_desnum |
1568 | jnz no_display_desnum |
1551 | shr eax, 16 |
1569 | shr eax, 16 |
1552 | and eax, 0xC03f |
1570 | and eax, 0xC03f |
1553 | ; and eax,0x3f |
1571 | ; and eax,0x3f |
1554 | push eax |
1572 | push eax |
1555 | and eax, 0x3f |
1573 | and eax, 0x3f |
1556 | mov edi, esp |
1574 | mov edi, esp |
1557 | add edi, 4+64-1 |
1575 | add edi, 4+64-1 |
1558 | mov ecx, eax |
1576 | mov ecx, eax |
1559 | mov eax, ebx |
1577 | mov eax, ebx |
1560 | mov ebx, 10 |
1578 | mov ebx, 10 |
1561 | d_desnum: |
1579 | d_desnum: |
1562 | xor edx, edx |
1580 | xor edx, edx |
1563 | call division_64_bits |
1581 | call division_64_bits |
1564 | div ebx |
1582 | div ebx |
1565 | add dl, 48 |
1583 | add dl, 48 |
1566 | mov [edi], dl |
1584 | mov [edi], dl |
1567 | dec edi |
1585 | dec edi |
1568 | loop d_desnum |
1586 | loop d_desnum |
1569 | pop eax |
1587 | pop eax |
1570 | call normalize_number |
1588 | call normalize_number |
1571 | call draw_num_text |
1589 | call draw_num_text |
1572 | add esp, 64 |
1590 | add esp, 64 |
1573 | popad |
1591 | popad |
1574 | ret |
1592 | ret |
1575 | no_display_desnum: |
1593 | no_display_desnum: |
1576 | 1594 | ||
1577 | cmp ah, 0x01 ; HEXADECIMAL |
1595 | cmp ah, 0x01 ; HEXADECIMAL |
1578 | jne no_display_hexnum |
1596 | jne no_display_hexnum |
1579 | shr eax, 16 |
1597 | shr eax, 16 |
1580 | and eax, 0xC03f |
1598 | and eax, 0xC03f |
1581 | ; and eax,0x3f |
1599 | ; and eax,0x3f |
1582 | push eax |
1600 | push eax |
1583 | and eax, 0x3f |
1601 | and eax, 0x3f |
1584 | mov edi, esp |
1602 | mov edi, esp |
1585 | add edi, 4+64-1 |
1603 | add edi, 4+64-1 |
1586 | mov ecx, eax |
1604 | mov ecx, eax |
1587 | mov eax, ebx |
1605 | mov eax, ebx |
1588 | mov ebx, 16 |
1606 | mov ebx, 16 |
1589 | d_hexnum: |
1607 | d_hexnum: |
1590 | xor edx, edx |
1608 | xor edx, edx |
1591 | call division_64_bits |
1609 | call division_64_bits |
1592 | div ebx |
1610 | div ebx |
1593 | hexletters = __fdo_hexdigits |
1611 | hexletters = __fdo_hexdigits |
1594 | add edx, hexletters |
1612 | add edx, hexletters |
1595 | mov dl, [edx] |
1613 | mov dl, [edx] |
1596 | mov [edi], dl |
1614 | mov [edi], dl |
1597 | dec edi |
1615 | dec edi |
1598 | loop d_hexnum |
1616 | loop d_hexnum |
1599 | pop eax |
1617 | pop eax |
1600 | call normalize_number |
1618 | call normalize_number |
1601 | call draw_num_text |
1619 | call draw_num_text |
1602 | add esp, 64 |
1620 | add esp, 64 |
1603 | popad |
1621 | popad |
1604 | ret |
1622 | ret |
1605 | no_display_hexnum: |
1623 | no_display_hexnum: |
1606 | 1624 | ||
1607 | cmp ah, 0x02 ; BINARY |
1625 | cmp ah, 0x02 ; BINARY |
1608 | jne no_display_binnum |
1626 | jne no_display_binnum |
1609 | shr eax, 16 |
1627 | shr eax, 16 |
1610 | and eax, 0xC03f |
1628 | and eax, 0xC03f |
1611 | ; and eax,0x3f |
1629 | ; and eax,0x3f |
1612 | push eax |
1630 | push eax |
1613 | and eax, 0x3f |
1631 | and eax, 0x3f |
1614 | mov edi, esp |
1632 | mov edi, esp |
1615 | add edi, 4+64-1 |
1633 | add edi, 4+64-1 |
1616 | mov ecx, eax |
1634 | mov ecx, eax |
1617 | mov eax, ebx |
1635 | mov eax, ebx |
1618 | mov ebx, 2 |
1636 | mov ebx, 2 |
1619 | d_binnum: |
1637 | d_binnum: |
1620 | xor edx, edx |
1638 | xor edx, edx |
1621 | call division_64_bits |
1639 | call division_64_bits |
1622 | div ebx |
1640 | div ebx |
1623 | add dl, 48 |
1641 | add dl, 48 |
1624 | mov [edi], dl |
1642 | mov [edi], dl |
1625 | dec edi |
1643 | dec edi |
1626 | loop d_binnum |
1644 | loop d_binnum |
1627 | pop eax |
1645 | pop eax |
1628 | call normalize_number |
1646 | call normalize_number |
1629 | call draw_num_text |
1647 | call draw_num_text |
1630 | add esp, 64 |
1648 | add esp, 64 |
1631 | popad |
1649 | popad |
1632 | ret |
1650 | ret |
1633 | no_display_binnum: |
1651 | no_display_binnum: |
1634 | 1652 | ||
1635 | add esp, 64 |
1653 | add esp, 64 |
1636 | popad |
1654 | popad |
1637 | ret |
1655 | ret |
1638 | 1656 | ||
1639 | normalize_number: |
1657 | normalize_number: |
1640 | test ah, 0x80 |
1658 | test ah, 0x80 |
1641 | jz .continue |
1659 | jz .continue |
1642 | mov ecx, 48 |
1660 | mov ecx, 48 |
1643 | and eax, 0x3f |
1661 | and eax, 0x3f |
1644 | @@: |
1662 | @@: |
1645 | inc edi |
1663 | inc edi |
1646 | cmp [edi], cl |
1664 | cmp [edi], cl |
1647 | jne .continue |
1665 | jne .continue |
1648 | dec eax |
1666 | dec eax |
1649 | cmp eax, 1 |
1667 | cmp eax, 1 |
1650 | ja @r |
1668 | ja @r |
1651 | mov al, 1 |
1669 | mov al, 1 |
1652 | .continue: |
1670 | .continue: |
1653 | and eax, 0x3f |
1671 | and eax, 0x3f |
1654 | ret |
1672 | ret |
1655 | 1673 | ||
1656 | division_64_bits: |
1674 | division_64_bits: |
1657 | test [esp+1+4], byte 0x40 |
1675 | test [esp+1+4], byte 0x40 |
1658 | jz .continue |
1676 | jz .continue |
1659 | push eax |
1677 | push eax |
1660 | mov eax, ebp |
1678 | mov eax, ebp |
1661 | div ebx |
1679 | div ebx |
1662 | mov ebp, eax |
1680 | mov ebp, eax |
1663 | pop eax |
1681 | pop eax |
1664 | .continue: |
1682 | .continue: |
1665 | ret |
1683 | ret |
1666 | 1684 | ||
1667 | draw_num_text: |
1685 | draw_num_text: |
1668 | mov esi, eax |
1686 | mov esi, eax |
1669 | mov edx, 64+4 |
1687 | mov edx, 64+4 |
1670 | sub edx, eax |
1688 | sub edx, eax |
1671 | add edx, esp |
1689 | add edx, esp |
1672 | mov ebx, [esp+64+32-8+4] |
1690 | mov ebx, [esp+64+32-8+4] |
1673 | ; add window start x & y |
1691 | ; add window start x & y |
1674 | mov ecx, [TASK_BASE] |
1692 | mov ecx, [TASK_BASE] |
1675 | 1693 | ||
1676 | mov edi, [CURRENT_TASK] |
1694 | mov edi, [CURRENT_TASK] |
1677 | shl edi, 8 |
1695 | shl edi, 8 |
1678 | 1696 | ||
1679 | mov eax, [ecx-twdw+WDATA.box.left] |
1697 | mov eax, [ecx-twdw+WDATA.box.left] |
1680 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1698 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1681 | shl eax, 16 |
1699 | shl eax, 16 |
1682 | add eax, [ecx-twdw+WDATA.box.top] |
1700 | add eax, [ecx-twdw+WDATA.box.top] |
1683 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1701 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1684 | add ebx, eax |
1702 | add ebx, eax |
1685 | mov ecx, [esp+64+32-12+4] |
1703 | mov ecx, [esp+64+32-12+4] |
1686 | and ecx, not 0x80000000 ; force counted string |
1704 | and ecx, not 0x80000000 ; force counted string |
1687 | mov eax, [esp+64+8] ; background color (if given) |
1705 | mov eax, [esp+64+8] ; background color (if given) |
1688 | mov edi, [esp+64+4] |
1706 | mov edi, [esp+64+4] |
1689 | jmp dtext |
1707 | jmp dtext |
1690 | ;----------------------------------------------------------------------------- |
1708 | ;----------------------------------------------------------------------------- |
1691 | iglobal |
1709 | iglobal |
1692 | midi_base dw 0 |
1710 | midi_base dw 0 |
1693 | endg |
1711 | endg |
1694 | ;----------------------------------------------------------------------------- |
1712 | ;----------------------------------------------------------------------------- |
1695 | align 4 |
1713 | align 4 |
1696 | sys_setup: |
1714 | sys_setup: |
1697 | ; 1 = roland mpu midi base , base io address |
1715 | ; 1 = roland mpu midi base , base io address |
1698 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1716 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1699 | ; 3 = not used |
1717 | ; 3 = not used |
1700 | ; 4 = not used |
1718 | ; 4 = not used |
1701 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1719 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1702 | ; 6 = not used |
1720 | ; 6 = not used |
1703 | ; 7 = not used |
1721 | ; 7 = not used |
1704 | ; 8 = not used |
1722 | ; 8 = not used |
1705 | ; 9 = not used |
1723 | ; 9 = not used |
1706 | ; 10 = not used |
1724 | ; 10 = not used |
1707 | ; 11 = enable lba read |
1725 | ; 11 = enable lba read |
1708 | ; 12 = enable pci access |
1726 | ; 12 = enable pci access |
1709 | ;----------------------------------------------------------------------------- |
1727 | ;----------------------------------------------------------------------------- |
1710 | and [esp+32], dword 0 |
1728 | and [esp+32], dword 0 |
1711 | ; F.21.1 - set MPU MIDI base port |
1729 | ; F.21.1 - set MPU MIDI base port |
1712 | dec ebx |
1730 | dec ebx |
1713 | jnz @f |
1731 | jnz @f |
1714 | 1732 | ||
1715 | cmp ecx, 0x100 |
1733 | cmp ecx, 0x100 |
1716 | jb @f |
1734 | jb @f |
1717 | 1735 | ||
1718 | mov esi, 65535 |
1736 | mov esi, 65535 |
1719 | cmp esi, ecx |
1737 | cmp esi, ecx |
1720 | jb @f |
1738 | jb @f |
1721 | 1739 | ||
1722 | mov [midi_base], cx |
1740 | mov [midi_base], cx |
1723 | mov word [mididp], cx |
1741 | mov word [mididp], cx |
1724 | inc cx |
1742 | inc cx |
1725 | mov word [midisp], cx |
1743 | mov word [midisp], cx |
1726 | ret |
1744 | ret |
1727 | ;-------------------------------------- |
1745 | ;-------------------------------------- |
1728 | @@: |
1746 | @@: |
1729 | ; F.21.2 - set keyboard layout |
1747 | ; F.21.2 - set keyboard layout |
1730 | dec ebx |
1748 | dec ebx |
1731 | jnz @f |
1749 | jnz @f |
1732 | 1750 | ||
1733 | mov edi, [TASK_BASE] |
1751 | mov edi, [TASK_BASE] |
1734 | mov eax, [edi+TASKDATA.mem_start] |
1752 | mov eax, [edi+TASKDATA.mem_start] |
1735 | add eax, edx |
1753 | add eax, edx |
1736 | ; 1 = normal layout |
1754 | ; 1 = normal layout |
1737 | dec ecx |
1755 | dec ecx |
1738 | jnz .shift |
1756 | jnz .shift |
1739 | 1757 | ||
1740 | mov ebx, keymap |
1758 | mov ebx, keymap |
1741 | mov ecx, 128 |
1759 | mov ecx, 128 |
1742 | call memmove |
1760 | call memmove |
1743 | ret |
1761 | ret |
1744 | ;-------------------------------------- |
1762 | ;-------------------------------------- |
1745 | .shift: |
1763 | .shift: |
1746 | ; 2 = layout at pressed Shift |
1764 | ; 2 = layout at pressed Shift |
1747 | dec ecx |
1765 | dec ecx |
1748 | jnz .alt |
1766 | jnz .alt |
1749 | 1767 | ||
1750 | mov ebx, keymap_shift |
1768 | mov ebx, keymap_shift |
1751 | mov ecx, 128 |
1769 | mov ecx, 128 |
1752 | call memmove |
1770 | call memmove |
1753 | ret |
1771 | ret |
1754 | ;-------------------------------------- |
1772 | ;-------------------------------------- |
1755 | .alt: |
1773 | .alt: |
1756 | ; 3 = layout at pressed Alt |
1774 | ; 3 = layout at pressed Alt |
1757 | dec ecx |
1775 | dec ecx |
1758 | jnz .country |
1776 | jnz .country |
1759 | 1777 | ||
1760 | mov ebx, keymap_alt |
1778 | mov ebx, keymap_alt |
1761 | mov ecx, 128 |
1779 | mov ecx, 128 |
1762 | call memmove |
1780 | call memmove |
1763 | ret |
1781 | ret |
1764 | ;-------------------------------------- |
1782 | ;-------------------------------------- |
1765 | .country: |
1783 | .country: |
1766 | ; country identifier |
1784 | ; country identifier |
1767 | sub ecx, 6 |
1785 | sub ecx, 6 |
1768 | jnz .error |
1786 | jnz .error |
1769 | 1787 | ||
1770 | mov word [keyboard], dx |
1788 | mov word [keyboard], dx |
1771 | ret |
1789 | ret |
1772 | ;-------------------------------------- |
1790 | ;-------------------------------------- |
1773 | @@: |
1791 | @@: |
1774 | ; F.21.5 - set system language |
1792 | ; F.21.5 - set system language |
1775 | sub ebx, 3 |
1793 | sub ebx, 3 |
1776 | jnz @f |
1794 | jnz @f |
1777 | 1795 | ||
1778 | mov [syslang], ecx |
1796 | mov [syslang], ecx |
1779 | ret |
1797 | ret |
1780 | ;-------------------------------------- |
1798 | ;-------------------------------------- |
1781 | @@: |
1799 | @@: |
1782 | ; F.21.11 - enable/disable low-level access to HD |
1800 | ; F.21.11 - enable/disable low-level access to HD |
1783 | and ecx, 1 |
1801 | and ecx, 1 |
1784 | sub ebx, 6 |
1802 | sub ebx, 6 |
1785 | jnz @f |
1803 | jnz @f |
1786 | 1804 | ||
1787 | mov [lba_read_enabled], ecx |
1805 | mov [lba_read_enabled], ecx |
1788 | ret |
1806 | ret |
1789 | ;-------------------------------------- |
1807 | ;-------------------------------------- |
1790 | @@: |
1808 | @@: |
1791 | ; F.21.12 - enable/disable low-level access to PCI |
1809 | ; F.21.12 - enable/disable low-level access to PCI |
1792 | dec ebx |
1810 | dec ebx |
1793 | jnz .error |
1811 | jnz .error |
1794 | 1812 | ||
1795 | mov [pci_access_enabled], ecx |
1813 | mov [pci_access_enabled], ecx |
1796 | ret |
1814 | ret |
1797 | ;-------------------------------------- |
1815 | ;-------------------------------------- |
1798 | .error: |
1816 | .error: |
1799 | or [esp+32], dword -1 |
1817 | or [esp+32], dword -1 |
1800 | ret |
1818 | ret |
1801 | ;----------------------------------------------------------------------------- |
1819 | ;----------------------------------------------------------------------------- |
1802 | align 4 |
1820 | align 4 |
1803 | sys_getsetup: |
1821 | sys_getsetup: |
1804 | ; 1 = roland mpu midi base , base io address |
1822 | ; 1 = roland mpu midi base , base io address |
1805 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1823 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1806 | ; 3 = not used |
1824 | ; 3 = not used |
1807 | ; 4 = not used |
1825 | ; 4 = not used |
1808 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1826 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1809 | ; 6 = not used |
1827 | ; 6 = not used |
1810 | ; 7 = not used |
1828 | ; 7 = not used |
1811 | ; 8 = not used |
1829 | ; 8 = not used |
1812 | ; 9 = get hs timer tic |
1830 | ; 9 = get hs timer tic |
1813 | ; 10 = not used |
1831 | ; 10 = not used |
1814 | ; 11 = get the state "lba read" |
1832 | ; 11 = get the state "lba read" |
1815 | ; 12 = get the state "pci access" |
1833 | ; 12 = get the state "pci access" |
1816 | ;----------------------------------------------------------------------------- |
1834 | ;----------------------------------------------------------------------------- |
1817 | ; F.26.1 - get MPU MIDI base port |
1835 | ; F.26.1 - get MPU MIDI base port |
1818 | dec ebx |
1836 | dec ebx |
1819 | jnz @f |
1837 | jnz @f |
1820 | 1838 | ||
1821 | movzx eax, [midi_base] |
1839 | movzx eax, [midi_base] |
1822 | mov [esp+32], eax |
1840 | mov [esp+32], eax |
1823 | ret |
1841 | ret |
1824 | ;-------------------------------------- |
1842 | ;-------------------------------------- |
1825 | @@: |
1843 | @@: |
1826 | ; F.26.2 - get keyboard layout |
1844 | ; F.26.2 - get keyboard layout |
1827 | dec ebx |
1845 | dec ebx |
1828 | jnz @f |
1846 | jnz @f |
1829 | 1847 | ||
1830 | mov edi, [TASK_BASE] |
1848 | mov edi, [TASK_BASE] |
1831 | mov ebx, [edi+TASKDATA.mem_start] |
1849 | mov ebx, [edi+TASKDATA.mem_start] |
1832 | add ebx, edx |
1850 | add ebx, edx |
1833 | ; 1 = normal layout |
1851 | ; 1 = normal layout |
1834 | dec ecx |
1852 | dec ecx |
1835 | jnz .shift |
1853 | jnz .shift |
1836 | 1854 | ||
1837 | mov eax, keymap |
1855 | mov eax, keymap |
1838 | mov ecx, 128 |
1856 | mov ecx, 128 |
1839 | call memmove |
1857 | call memmove |
1840 | ret |
1858 | ret |
1841 | ;-------------------------------------- |
1859 | ;-------------------------------------- |
1842 | .shift: |
1860 | .shift: |
1843 | ; 2 = layout with pressed Shift |
1861 | ; 2 = layout with pressed Shift |
1844 | dec ecx |
1862 | dec ecx |
1845 | jnz .alt |
1863 | jnz .alt |
1846 | 1864 | ||
1847 | mov eax, keymap_shift |
1865 | mov eax, keymap_shift |
1848 | mov ecx, 128 |
1866 | mov ecx, 128 |
1849 | call memmove |
1867 | call memmove |
1850 | ret |
1868 | ret |
1851 | ;-------------------------------------- |
1869 | ;-------------------------------------- |
1852 | .alt: |
1870 | .alt: |
1853 | ; 3 = layout with pressed Alt |
1871 | ; 3 = layout with pressed Alt |
1854 | dec ecx |
1872 | dec ecx |
1855 | jne .country |
1873 | jne .country |
1856 | 1874 | ||
1857 | mov eax, keymap_alt |
1875 | mov eax, keymap_alt |
1858 | mov ecx, 128 |
1876 | mov ecx, 128 |
1859 | call memmove |
1877 | call memmove |
1860 | ret |
1878 | ret |
1861 | ;-------------------------------------- |
1879 | ;-------------------------------------- |
1862 | .country: |
1880 | .country: |
1863 | ; 9 = country identifier |
1881 | ; 9 = country identifier |
1864 | sub ecx, 6 |
1882 | sub ecx, 6 |
1865 | jnz .error |
1883 | jnz .error |
1866 | 1884 | ||
1867 | movzx eax, word [keyboard] |
1885 | movzx eax, word [keyboard] |
1868 | mov [esp+32], eax |
1886 | mov [esp+32], eax |
1869 | ret |
1887 | ret |
1870 | ;-------------------------------------- |
1888 | ;-------------------------------------- |
1871 | @@: |
1889 | @@: |
1872 | ; F.26.5 - get system language |
1890 | ; F.26.5 - get system language |
1873 | sub ebx, 3 |
1891 | sub ebx, 3 |
1874 | jnz @f |
1892 | jnz @f |
1875 | 1893 | ||
1876 | mov eax, [syslang] |
1894 | mov eax, [syslang] |
1877 | mov [esp+32], eax |
1895 | mov [esp+32], eax |
1878 | ret |
1896 | ret |
1879 | ;-------------------------------------- |
1897 | ;-------------------------------------- |
1880 | @@: |
1898 | @@: |
1881 | ; F.26.9 - get the value of the time counter |
1899 | ; F.26.9 - get the value of the time counter |
1882 | sub ebx, 4 |
1900 | sub ebx, 4 |
1883 | jnz @f |
1901 | jnz @f |
1884 | 1902 | ||
1885 | mov eax, [timer_ticks] |
1903 | mov eax, [timer_ticks] |
1886 | mov [esp+32], eax |
1904 | mov [esp+32], eax |
1887 | ret |
1905 | ret |
1888 | ;-------------------------------------- |
1906 | ;-------------------------------------- |
1889 | @@: |
1907 | @@: |
1890 | ; F.26.11 - Find out whether low-level HD access is enabled |
1908 | ; F.26.11 - Find out whether low-level HD access is enabled |
1891 | sub ebx, 2 |
1909 | sub ebx, 2 |
1892 | jnz @f |
1910 | jnz @f |
1893 | 1911 | ||
1894 | mov eax, [lba_read_enabled] |
1912 | mov eax, [lba_read_enabled] |
1895 | mov [esp+32], eax |
1913 | mov [esp+32], eax |
1896 | ret |
1914 | ret |
1897 | ;-------------------------------------- |
1915 | ;-------------------------------------- |
1898 | @@: |
1916 | @@: |
1899 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1917 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1900 | dec ebx |
1918 | dec ebx |
1901 | jnz .error |
1919 | jnz .error |
1902 | 1920 | ||
1903 | mov eax, [pci_access_enabled] |
1921 | mov eax, [pci_access_enabled] |
1904 | mov [esp+32], eax |
1922 | mov [esp+32], eax |
1905 | ret |
1923 | ret |
1906 | ;-------------------------------------- |
1924 | ;-------------------------------------- |
1907 | .error: |
1925 | .error: |
1908 | or [esp+32], dword -1 |
1926 | or [esp+32], dword -1 |
1909 | ret |
1927 | ret |
1910 | ;----------------------------------------------------------------------------- |
1928 | ;----------------------------------------------------------------------------- |
1911 | get_timer_ticks: |
1929 | get_timer_ticks: |
1912 | mov eax, [timer_ticks] |
1930 | mov eax, [timer_ticks] |
1913 | ret |
1931 | ret |
1914 | ;----------------------------------------------------------------------------- |
1932 | ;----------------------------------------------------------------------------- |
1915 | iglobal |
1933 | iglobal |
1916 | align 4 |
1934 | align 4 |
1917 | mousefn dd msscreen, mswin, msbutton, msset |
1935 | mousefn dd msscreen, mswin, msbutton, msset |
1918 | dd app_load_cursor |
1936 | dd app_load_cursor |
1919 | dd app_set_cursor |
1937 | dd app_set_cursor |
1920 | dd app_delete_cursor |
1938 | dd app_delete_cursor |
1921 | dd msz |
1939 | dd msz |
1922 | endg |
1940 | endg |
1923 | ;----------------------------------------------------------------------------- |
1941 | ;----------------------------------------------------------------------------- |
1924 | readmousepos: |
1942 | readmousepos: |
1925 | 1943 | ||
1926 | ; eax=0 screen relative |
1944 | ; eax=0 screen relative |
1927 | ; eax=1 window relative |
1945 | ; eax=1 window relative |
1928 | ; eax=2 buttons pressed |
1946 | ; eax=2 buttons pressed |
1929 | ; eax=3 set mouse pos ; reserved |
1947 | ; eax=3 set mouse pos ; reserved |
1930 | ; eax=4 load cursor |
1948 | ; eax=4 load cursor |
1931 | ; eax=5 set cursor |
1949 | ; eax=5 set cursor |
1932 | ; eax=6 delete cursor ; reserved |
1950 | ; eax=6 delete cursor ; reserved |
1933 | ; eax=7 get mouse_z |
1951 | ; eax=7 get mouse_z |
1934 | 1952 | ||
1935 | cmp ebx, 7 |
1953 | cmp ebx, 7 |
1936 | ja msset |
1954 | ja msset |
1937 | jmp [mousefn+ebx*4] |
1955 | jmp [mousefn+ebx*4] |
1938 | msscreen: |
1956 | msscreen: |
1939 | mov eax, [MOUSE_X] |
1957 | mov eax, [MOUSE_X] |
1940 | shl eax, 16 |
1958 | shl eax, 16 |
1941 | mov ax, [MOUSE_Y] |
1959 | mov ax, [MOUSE_Y] |
1942 | mov [esp+36-4], eax |
1960 | mov [esp+36-4], eax |
1943 | ret |
1961 | ret |
1944 | mswin: |
1962 | mswin: |
1945 | mov eax, [MOUSE_X] |
1963 | mov eax, [MOUSE_X] |
1946 | shl eax, 16 |
1964 | shl eax, 16 |
1947 | mov ax, [MOUSE_Y] |
1965 | mov ax, [MOUSE_Y] |
1948 | mov esi, [TASK_BASE] |
1966 | mov esi, [TASK_BASE] |
1949 | mov bx, word [esi-twdw+WDATA.box.left] |
1967 | mov bx, word [esi-twdw+WDATA.box.left] |
1950 | shl ebx, 16 |
1968 | shl ebx, 16 |
1951 | mov bx, word [esi-twdw+WDATA.box.top] |
1969 | mov bx, word [esi-twdw+WDATA.box.top] |
1952 | sub eax, ebx |
1970 | sub eax, ebx |
1953 | 1971 | ||
1954 | mov edi, [CURRENT_TASK] |
1972 | mov edi, [CURRENT_TASK] |
1955 | shl edi, 8 |
1973 | shl edi, 8 |
1956 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1974 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1957 | rol eax, 16 |
1975 | rol eax, 16 |
1958 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1976 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1959 | rol eax, 16 |
1977 | rol eax, 16 |
1960 | mov [esp+36-4], eax |
1978 | mov [esp+36-4], eax |
1961 | ret |
1979 | ret |
1962 | msbutton: |
1980 | msbutton: |
1963 | movzx eax, byte [BTN_DOWN] |
1981 | movzx eax, byte [BTN_DOWN] |
1964 | mov [esp+36-4], eax |
1982 | mov [esp+36-4], eax |
1965 | ret |
1983 | ret |
1966 | msz: |
1984 | msz: |
1967 | mov edi, [TASK_COUNT] |
1985 | mov edi, [TASK_COUNT] |
1968 | movzx edi, word [WIN_POS + edi*2] |
1986 | movzx edi, word [WIN_POS + edi*2] |
1969 | cmp edi, [CURRENT_TASK] |
1987 | cmp edi, [CURRENT_TASK] |
1970 | jne @f |
1988 | jne @f |
1971 | mov ax, [MOUSE_SCROLL_H] |
1989 | mov ax, [MOUSE_SCROLL_H] |
1972 | shl eax, 16 |
1990 | shl eax, 16 |
1973 | mov ax, [MOUSE_SCROLL_V] |
1991 | mov ax, [MOUSE_SCROLL_V] |
1974 | mov [esp+36-4], eax |
1992 | mov [esp+36-4], eax |
1975 | and [MOUSE_SCROLL_H], word 0 |
1993 | and [MOUSE_SCROLL_H], word 0 |
1976 | and [MOUSE_SCROLL_V], word 0 |
1994 | and [MOUSE_SCROLL_V], word 0 |
1977 | ret |
1995 | ret |
1978 | @@: |
1996 | @@: |
1979 | and [esp+36-4], dword 0 |
1997 | and [esp+36-4], dword 0 |
1980 | ; ret |
1998 | ; ret |
1981 | msset: |
1999 | msset: |
1982 | ret |
2000 | ret |
1983 | 2001 | ||
1984 | app_load_cursor: |
2002 | app_load_cursor: |
1985 | cmp ecx, OS_BASE |
2003 | cmp ecx, OS_BASE |
1986 | jae msset |
2004 | jae msset |
1987 | stdcall load_cursor, ecx, edx |
2005 | stdcall load_cursor, ecx, edx |
1988 | mov [esp+36-4], eax |
2006 | mov [esp+36-4], eax |
1989 | ret |
2007 | ret |
1990 | 2008 | ||
1991 | app_set_cursor: |
2009 | app_set_cursor: |
1992 | stdcall set_cursor, ecx |
2010 | stdcall set_cursor, ecx |
1993 | mov [esp+36-4], eax |
2011 | mov [esp+36-4], eax |
1994 | ret |
2012 | ret |
1995 | 2013 | ||
1996 | app_delete_cursor: |
2014 | app_delete_cursor: |
1997 | stdcall delete_cursor, ecx |
2015 | stdcall delete_cursor, ecx |
1998 | mov [esp+36-4], eax |
2016 | mov [esp+36-4], eax |
1999 | ret |
2017 | ret |
2000 | 2018 | ||
2001 | is_input: |
2019 | is_input: |
2002 | 2020 | ||
2003 | push edx |
2021 | push edx |
2004 | mov dx, word [midisp] |
2022 | mov dx, word [midisp] |
2005 | in al, dx |
2023 | in al, dx |
2006 | and al, 0x80 |
2024 | and al, 0x80 |
2007 | pop edx |
2025 | pop edx |
2008 | ret |
2026 | ret |
2009 | 2027 | ||
2010 | is_output: |
2028 | is_output: |
2011 | 2029 | ||
2012 | push edx |
2030 | push edx |
2013 | mov dx, word [midisp] |
2031 | mov dx, word [midisp] |
2014 | in al, dx |
2032 | in al, dx |
2015 | and al, 0x40 |
2033 | and al, 0x40 |
2016 | pop edx |
2034 | pop edx |
2017 | ret |
2035 | ret |
2018 | 2036 | ||
2019 | 2037 | ||
2020 | get_mpu_in: |
2038 | get_mpu_in: |
2021 | 2039 | ||
2022 | push edx |
2040 | push edx |
2023 | mov dx, word [mididp] |
2041 | mov dx, word [mididp] |
2024 | in al, dx |
2042 | in al, dx |
2025 | pop edx |
2043 | pop edx |
2026 | ret |
2044 | ret |
2027 | 2045 | ||
2028 | 2046 | ||
2029 | put_mpu_out: |
2047 | put_mpu_out: |
2030 | 2048 | ||
2031 | push edx |
2049 | push edx |
2032 | mov dx, word [mididp] |
2050 | mov dx, word [mididp] |
2033 | out dx, al |
2051 | out dx, al |
2034 | pop edx |
2052 | pop edx |
2035 | ret |
2053 | ret |
2036 | 2054 | ||
2037 | 2055 | ||
2038 | 2056 | ||
2039 | align 4 |
2057 | align 4 |
2040 | 2058 | ||
2041 | sys_midi: |
2059 | sys_midi: |
2042 | cmp [mididp], 0 |
2060 | cmp [mididp], 0 |
2043 | jnz sm0 |
2061 | jnz sm0 |
2044 | mov [esp+36], dword 1 |
2062 | mov [esp+36], dword 1 |
2045 | ret |
2063 | ret |
2046 | sm0: |
2064 | sm0: |
2047 | and [esp+36], dword 0 |
2065 | and [esp+36], dword 0 |
2048 | dec ebx |
2066 | dec ebx |
2049 | jnz smn1 |
2067 | jnz smn1 |
2050 | ; call setuart |
2068 | ; call setuart |
2051 | su1: |
2069 | su1: |
2052 | call is_output |
2070 | call is_output |
2053 | test al, al |
2071 | test al, al |
2054 | jnz su1 |
2072 | jnz su1 |
2055 | mov dx, word [midisp] |
2073 | mov dx, word [midisp] |
2056 | mov al, 0xff |
2074 | mov al, 0xff |
2057 | out dx, al |
2075 | out dx, al |
2058 | su2: |
2076 | su2: |
2059 | mov dx, word [midisp] |
2077 | mov dx, word [midisp] |
2060 | mov al, 0xff |
2078 | mov al, 0xff |
2061 | out dx, al |
2079 | out dx, al |
2062 | call is_input |
2080 | call is_input |
2063 | test al, al |
2081 | test al, al |
2064 | jnz su2 |
2082 | jnz su2 |
2065 | call get_mpu_in |
2083 | call get_mpu_in |
2066 | cmp al, 0xfe |
2084 | cmp al, 0xfe |
2067 | jnz su2 |
2085 | jnz su2 |
2068 | su3: |
2086 | su3: |
2069 | call is_output |
2087 | call is_output |
2070 | test al, al |
2088 | test al, al |
2071 | jnz su3 |
2089 | jnz su3 |
2072 | mov dx, word [midisp] |
2090 | mov dx, word [midisp] |
2073 | mov al, 0x3f |
2091 | mov al, 0x3f |
2074 | out dx, al |
2092 | out dx, al |
2075 | ret |
2093 | ret |
2076 | smn1: |
2094 | smn1: |
2077 | dec ebx |
2095 | dec ebx |
2078 | jnz smn2 |
2096 | jnz smn2 |
2079 | sm10: |
2097 | sm10: |
2080 | call get_mpu_in |
2098 | call get_mpu_in |
2081 | call is_output |
2099 | call is_output |
2082 | test al, al |
2100 | test al, al |
2083 | jnz sm10 |
2101 | jnz sm10 |
2084 | mov al, bl |
2102 | mov al, bl |
2085 | call put_mpu_out |
2103 | call put_mpu_out |
2086 | smn2: |
2104 | smn2: |
2087 | ret |
2105 | ret |
2088 | 2106 | ||
2089 | detect_devices: |
2107 | detect_devices: |
2090 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2108 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2091 | ;include 'detect/commouse.inc' |
2109 | ;include 'detect/commouse.inc' |
2092 | ;include 'detect/ps2mouse.inc' |
2110 | ;include 'detect/ps2mouse.inc' |
2093 | ;include 'detect/dev_fd.inc' |
2111 | ;include 'detect/dev_fd.inc' |
2094 | ;include 'detect/dev_hdcd.inc' |
2112 | ;include 'detect/dev_hdcd.inc' |
2095 | ;include 'detect/sear_par.inc' |
2113 | ;include 'detect/sear_par.inc' |
2096 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2114 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2097 | ret |
2115 | ret |
2098 | 2116 | ||
2099 | sys_end: |
2117 | sys_end: |
2100 | ;-------------------------------------- |
2118 | ;-------------------------------------- |
2101 | cmp [_display.select_cursor], 0 |
2119 | cmp [_display.select_cursor], 0 |
2102 | je @f |
2120 | je @f |
2103 | ; restore default cursor before killing |
2121 | ; restore default cursor before killing |
2104 | pusha |
2122 | pusha |
2105 | mov ecx, [current_slot] |
2123 | mov ecx, [current_slot] |
2106 | call restore_default_cursor_before_killing |
2124 | call restore_default_cursor_before_killing |
2107 | popa |
2125 | popa |
2108 | @@: |
2126 | @@: |
2109 | ;-------------------------------------- |
2127 | ;-------------------------------------- |
2110 | ; kill all sockets this process owns |
2128 | ; kill all sockets this process owns |
2111 | pusha |
2129 | pusha |
2112 | mov edx, [TASK_BASE] |
2130 | mov edx, [TASK_BASE] |
2113 | mov edx, [edx+TASKDATA.pid] |
2131 | mov edx, [edx+TASKDATA.pid] |
2114 | call SOCKET_process_end |
2132 | call SOCKET_process_end |
2115 | popa |
2133 | popa |
2116 | ;-------------------------------------- |
2134 | ;-------------------------------------- |
2117 | mov ecx, [current_slot] |
2135 | mov ecx, [current_slot] |
2118 | mov eax, [ecx+APPDATA.tls_base] |
2136 | mov eax, [ecx+APPDATA.tls_base] |
2119 | test eax, eax |
2137 | test eax, eax |
2120 | jz @F |
2138 | jz @F |
2121 | 2139 | ||
2122 | stdcall user_free, eax |
2140 | stdcall user_free, eax |
2123 | @@: |
2141 | @@: |
2124 | 2142 | ||
2125 | mov eax, [TASK_BASE] |
2143 | mov eax, [TASK_BASE] |
2126 | mov [eax+TASKDATA.state], 3; terminate this program |
2144 | mov [eax+TASKDATA.state], 3; terminate this program |
2127 | call wakeup_osloop |
2145 | call wakeup_osloop |
2128 | 2146 | ||
2129 | .waitterm: ; wait here for termination |
2147 | .waitterm: ; wait here for termination |
2130 | call change_task |
2148 | call change_task |
2131 | jmp .waitterm |
2149 | jmp .waitterm |
2132 | ;------------------------------------------------------------------------------ |
2150 | ;------------------------------------------------------------------------------ |
2133 | align 4 |
2151 | align 4 |
2134 | restore_default_cursor_before_killing: |
2152 | restore_default_cursor_before_killing: |
2135 | pushfd |
2153 | pushfd |
2136 | cli |
2154 | cli |
2137 | mov eax, [def_cursor] |
2155 | mov eax, [def_cursor] |
2138 | mov [ecx+APPDATA.cursor], eax |
2156 | mov [ecx+APPDATA.cursor], eax |
2139 | 2157 | ||
2140 | movzx eax, word [MOUSE_Y] |
2158 | movzx eax, word [MOUSE_Y] |
2141 | movzx ebx, word [MOUSE_X] |
2159 | movzx ebx, word [MOUSE_X] |
2142 | mov eax, [d_width_calc_area + eax*4] |
2160 | mov eax, [d_width_calc_area + eax*4] |
2143 | 2161 | ||
2144 | add eax, [_display.win_map] |
2162 | add eax, [_display.win_map] |
2145 | movzx edx, byte [ebx+eax] |
2163 | movzx edx, byte [ebx+eax] |
2146 | shl edx, 8 |
2164 | shl edx, 8 |
2147 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2165 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2148 | 2166 | ||
2149 | cmp esi, [current_cursor] |
2167 | cmp esi, [current_cursor] |
2150 | je @f |
2168 | je @f |
2151 | 2169 | ||
2152 | push esi |
2170 | push esi |
2153 | call [_display.select_cursor] |
2171 | call [_display.select_cursor] |
2154 | mov [current_cursor], esi |
2172 | mov [current_cursor], esi |
2155 | @@: |
2173 | @@: |
2156 | mov [redrawmouse_unconditional], 1 |
2174 | mov [redrawmouse_unconditional], 1 |
2157 | call wakeup_osloop |
2175 | call wakeup_osloop |
2158 | popfd |
2176 | popfd |
2159 | ret |
2177 | ret |
2160 | ;------------------------------------------------------------------------------ |
2178 | ;------------------------------------------------------------------------------ |
2161 | iglobal |
2179 | iglobal |
2162 | align 4 |
2180 | align 4 |
2163 | sys_system_table: |
2181 | sys_system_table: |
2164 | dd sysfn_deactivate ; 1 = deactivate window |
2182 | dd sysfn_deactivate ; 1 = deactivate window |
2165 | dd sysfn_terminate ; 2 = terminate thread |
2183 | dd sysfn_terminate ; 2 = terminate thread |
2166 | dd sysfn_activate ; 3 = activate window |
2184 | dd sysfn_activate ; 3 = activate window |
2167 | dd sysfn_getidletime ; 4 = get idle time |
2185 | dd sysfn_getidletime ; 4 = get idle time |
2168 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2186 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2169 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2187 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2170 | dd sysfn_getactive ; 7 = get active window |
2188 | dd sysfn_getactive ; 7 = get active window |
2171 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2189 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2172 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2190 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2173 | dd sysfn_minimize ; 10 = minimize window |
2191 | dd sysfn_minimize ; 10 = minimize window |
2174 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2192 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2175 | dd sysfn_lastkey ; 12 = get last pressed key |
2193 | dd sysfn_lastkey ; 12 = get last pressed key |
2176 | dd sysfn_getversion ; 13 = get kernel version |
2194 | dd sysfn_getversion ; 13 = get kernel version |
2177 | dd sysfn_waitretrace ; 14 = wait retrace |
2195 | dd sysfn_waitretrace ; 14 = wait retrace |
2178 | dd sysfn_centermouse ; 15 = center mouse cursor |
2196 | dd sysfn_centermouse ; 15 = center mouse cursor |
2179 | dd sysfn_getfreemem ; 16 = get free memory size |
2197 | dd sysfn_getfreemem ; 16 = get free memory size |
2180 | dd sysfn_getallmem ; 17 = get total memory size |
2198 | dd sysfn_getallmem ; 17 = get total memory size |
2181 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2199 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2182 | ; instead of slot |
2200 | ; instead of slot |
2183 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2201 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2184 | dd sysfn_meminfo ; 20 = get extended memory info |
2202 | dd sysfn_meminfo ; 20 = get extended memory info |
2185 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2203 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2186 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2204 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2187 | dd sysfn_min_windows ; 23 = minimize all windows |
2205 | dd sysfn_min_windows ; 23 = minimize all windows |
2188 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2206 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2189 | sysfn_num = ($ - sys_system_table)/4 |
2207 | sysfn_num = ($ - sys_system_table)/4 |
2190 | endg |
2208 | endg |
2191 | ;------------------------------------------------------------------------------ |
2209 | ;------------------------------------------------------------------------------ |
2192 | sys_system: |
2210 | sys_system: |
2193 | dec ebx |
2211 | dec ebx |
2194 | cmp ebx, sysfn_num |
2212 | cmp ebx, sysfn_num |
2195 | jae @f |
2213 | jae @f |
2196 | jmp dword [sys_system_table + ebx*4] |
2214 | jmp dword [sys_system_table + ebx*4] |
2197 | @@: |
2215 | @@: |
2198 | ret |
2216 | ret |
2199 | ;------------------------------------------------------------------------------ |
2217 | ;------------------------------------------------------------------------------ |
2200 | sysfn_shutdown: ; 18.9 = system shutdown |
2218 | sysfn_shutdown: ; 18.9 = system shutdown |
2201 | cmp ecx, 1 |
2219 | cmp ecx, 1 |
2202 | jl exit_for_anyone |
2220 | jl exit_for_anyone |
2203 | cmp ecx, 4 |
2221 | cmp ecx, 4 |
2204 | jg exit_for_anyone |
2222 | jg exit_for_anyone |
2205 | mov [BOOT_VARS+0x9030], cl |
2223 | mov [BOOT_VARS+0x9030], cl |
2206 | 2224 | ||
2207 | mov eax, [TASK_COUNT] |
2225 | mov eax, [TASK_COUNT] |
2208 | mov [SYS_SHUTDOWN], al |
2226 | mov [SYS_SHUTDOWN], al |
2209 | mov [shutdown_processes], eax |
2227 | mov [shutdown_processes], eax |
2210 | call wakeup_osloop |
2228 | call wakeup_osloop |
2211 | and dword [esp+32], 0 |
2229 | and dword [esp+32], 0 |
2212 | exit_for_anyone: |
2230 | exit_for_anyone: |
2213 | ret |
2231 | ret |
2214 | uglobal |
2232 | uglobal |
2215 | shutdown_processes: |
2233 | shutdown_processes: |
2216 | dd 0x0 |
2234 | dd 0x0 |
2217 | endg |
2235 | endg |
2218 | ;------------------------------------------------------------------------------ |
2236 | ;------------------------------------------------------------------------------ |
2219 | sysfn_terminate: ; 18.2 = TERMINATE |
2237 | sysfn_terminate: ; 18.2 = TERMINATE |
2220 | push ecx |
2238 | push ecx |
2221 | cmp ecx, 2 |
2239 | cmp ecx, 2 |
2222 | jb noprocessterminate |
2240 | jb noprocessterminate |
2223 | mov edx, [TASK_COUNT] |
2241 | mov edx, [TASK_COUNT] |
2224 | cmp ecx, edx |
2242 | cmp ecx, edx |
2225 | ja noprocessterminate |
2243 | ja noprocessterminate |
2226 | mov eax, [TASK_COUNT] |
2244 | mov eax, [TASK_COUNT] |
2227 | shl ecx, 5 |
2245 | shl ecx, 5 |
2228 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2246 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2229 | add ecx, CURRENT_TASK+TASKDATA.state |
2247 | add ecx, CURRENT_TASK+TASKDATA.state |
2230 | cmp byte [ecx], 9 |
2248 | cmp byte [ecx], 9 |
2231 | jz noprocessterminate |
2249 | jz noprocessterminate |
2232 | push ecx edx |
2250 | push ecx edx |
2233 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2251 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2234 | call request_terminate |
2252 | call request_terminate |
2235 | pop edx ecx |
2253 | pop edx ecx |
2236 | test eax, eax |
2254 | test eax, eax |
2237 | jz noprocessterminate |
2255 | jz noprocessterminate |
2238 | ;-------------------------------------- |
2256 | ;-------------------------------------- |
2239 | ; terminate all network sockets it used |
2257 | ; terminate all network sockets it used |
2240 | pusha |
2258 | pusha |
2241 | mov eax, edx |
2259 | mov eax, edx |
2242 | call SOCKET_process_end |
2260 | call SOCKET_process_end |
2243 | popa |
2261 | popa |
2244 | ;-------------------------------------- |
2262 | ;-------------------------------------- |
2245 | cmp [_display.select_cursor], 0 |
2263 | cmp [_display.select_cursor], 0 |
2246 | je .restore_end |
2264 | je .restore_end |
2247 | ; restore default cursor before killing |
2265 | ; restore default cursor before killing |
2248 | pusha |
2266 | pusha |
2249 | mov ecx, [esp+32] |
2267 | mov ecx, [esp+32] |
2250 | shl ecx, 8 |
2268 | shl ecx, 8 |
2251 | add ecx, SLOT_BASE |
2269 | add ecx, SLOT_BASE |
2252 | mov eax, [def_cursor] |
2270 | mov eax, [def_cursor] |
2253 | cmp [ecx+APPDATA.cursor], eax |
2271 | cmp [ecx+APPDATA.cursor], eax |
2254 | je @f |
2272 | je @f |
2255 | call restore_default_cursor_before_killing |
2273 | call restore_default_cursor_before_killing |
2256 | @@: |
2274 | @@: |
2257 | popa |
2275 | popa |
2258 | .restore_end: |
2276 | .restore_end: |
2259 | ;-------------------------------------- |
2277 | ;-------------------------------------- |
2260 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2278 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2261 | mov [ecx], byte 3; clear possible i40's |
2279 | mov [ecx], byte 3; clear possible i40's |
2262 | call wakeup_osloop |
2280 | call wakeup_osloop |
2263 | ;call MEM_Heap_UnLock |
2281 | ;call MEM_Heap_UnLock |
2264 | 2282 | ||
2265 | cmp edx, [application_table_owner]; clear app table stat |
2283 | cmp edx, [application_table_owner]; clear app table stat |
2266 | jne noatsc |
2284 | jne noatsc |
2267 | call unlock_application_table |
2285 | call unlock_application_table |
2268 | noatsc: |
2286 | noatsc: |
2269 | noprocessterminate: |
2287 | noprocessterminate: |
2270 | add esp, 4 |
2288 | add esp, 4 |
2271 | ret |
2289 | ret |
2272 | ;------------------------------------------------------------------------------ |
2290 | ;------------------------------------------------------------------------------ |
2273 | sysfn_terminate2: |
2291 | sysfn_terminate2: |
2274 | ;lock application_table_status mutex |
2292 | ;lock application_table_status mutex |
2275 | .table_status: |
2293 | .table_status: |
2276 | call lock_application_table |
2294 | call lock_application_table |
2277 | mov eax, ecx |
2295 | mov eax, ecx |
2278 | call pid_to_slot |
2296 | call pid_to_slot |
2279 | test eax, eax |
2297 | test eax, eax |
2280 | jz .not_found |
2298 | jz .not_found |
2281 | mov ecx, eax |
2299 | mov ecx, eax |
2282 | cli |
2300 | cli |
2283 | call sysfn_terminate |
2301 | call sysfn_terminate |
2284 | call unlock_application_table |
2302 | call unlock_application_table |
2285 | sti |
2303 | sti |
2286 | and dword [esp+32], 0 |
2304 | and dword [esp+32], 0 |
2287 | ret |
2305 | ret |
2288 | .not_found: |
2306 | .not_found: |
2289 | call unlock_application_table |
2307 | call unlock_application_table |
2290 | or dword [esp+32], -1 |
2308 | or dword [esp+32], -1 |
2291 | ret |
2309 | ret |
2292 | ;------------------------------------------------------------------------------ |
2310 | ;------------------------------------------------------------------------------ |
2293 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2311 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2294 | cmp ecx, 2 |
2312 | cmp ecx, 2 |
2295 | jb .nowindowdeactivate |
2313 | jb .nowindowdeactivate |
2296 | cmp ecx, [TASK_COUNT] |
2314 | cmp ecx, [TASK_COUNT] |
2297 | ja .nowindowdeactivate |
2315 | ja .nowindowdeactivate |
2298 | 2316 | ||
2299 | movzx esi, word [WIN_STACK + ecx*2] |
2317 | movzx esi, word [WIN_STACK + ecx*2] |
2300 | cmp esi, 1 |
2318 | cmp esi, 1 |
2301 | je .nowindowdeactivate ; already deactive |
2319 | je .nowindowdeactivate ; already deactive |
2302 | 2320 | ||
2303 | mov edi, ecx |
2321 | mov edi, ecx |
2304 | shl edi, 5 |
2322 | shl edi, 5 |
2305 | add edi, window_data |
2323 | add edi, window_data |
2306 | movzx esi, word [WIN_STACK + ecx * 2] |
2324 | movzx esi, word [WIN_STACK + ecx * 2] |
2307 | lea esi, [WIN_POS + esi * 2] |
2325 | lea esi, [WIN_POS + esi * 2] |
2308 | call window._.window_deactivate |
2326 | call window._.window_deactivate |
2309 | 2327 | ||
2310 | call syscall_display_settings._.calculate_whole_screen |
2328 | call syscall_display_settings._.calculate_whole_screen |
2311 | call syscall_display_settings._.redraw_whole_screen |
2329 | call syscall_display_settings._.redraw_whole_screen |
2312 | .nowindowdeactivate: |
2330 | .nowindowdeactivate: |
2313 | ret |
2331 | ret |
2314 | ;------------------------------------------------------------------------------ |
2332 | ;------------------------------------------------------------------------------ |
2315 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2333 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2316 | cmp ecx, 2 |
2334 | cmp ecx, 2 |
2317 | jb .nowindowactivate |
2335 | jb .nowindowactivate |
2318 | cmp ecx, [TASK_COUNT] |
2336 | cmp ecx, [TASK_COUNT] |
2319 | ja .nowindowactivate |
2337 | ja .nowindowactivate |
2320 | ;------------------------------------- |
2338 | ;------------------------------------- |
2321 | @@: |
2339 | @@: |
2322 | ; If the window is captured and moved by the user, |
2340 | ; If the window is captured and moved by the user, |
2323 | ; then you can't change the position in window stack!!! |
2341 | ; then you can't change the position in window stack!!! |
2324 | mov al, [mouse.active_sys_window.action] |
2342 | mov al, [mouse.active_sys_window.action] |
2325 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2343 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2326 | test al, al |
2344 | test al, al |
2327 | jz @f |
2345 | jz @f |
2328 | call change_task |
2346 | call change_task |
2329 | jmp @b |
2347 | jmp @b |
2330 | @@: |
2348 | @@: |
2331 | ;------------------------------------- |
2349 | ;------------------------------------- |
2332 | mov [window_minimize], 2; restore window if minimized |
2350 | mov [window_minimize], 2; restore window if minimized |
2333 | call wakeup_osloop |
2351 | call wakeup_osloop |
2334 | 2352 | ||
2335 | movzx esi, word [WIN_STACK + ecx*2] |
2353 | movzx esi, word [WIN_STACK + ecx*2] |
2336 | cmp esi, [TASK_COUNT] |
2354 | cmp esi, [TASK_COUNT] |
2337 | je .nowindowactivate; already active |
2355 | je .nowindowactivate; already active |
2338 | 2356 | ||
2339 | mov edi, ecx |
2357 | mov edi, ecx |
2340 | shl edi, 5 |
2358 | shl edi, 5 |
2341 | add edi, window_data |
2359 | add edi, window_data |
2342 | movzx esi, word [WIN_STACK + ecx * 2] |
2360 | movzx esi, word [WIN_STACK + ecx * 2] |
2343 | lea esi, [WIN_POS + esi * 2] |
2361 | lea esi, [WIN_POS + esi * 2] |
2344 | call waredraw |
2362 | call waredraw |
2345 | .nowindowactivate: |
2363 | .nowindowactivate: |
2346 | ret |
2364 | ret |
2347 | ;------------------------------------------------------------------------------ |
2365 | ;------------------------------------------------------------------------------ |
2348 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2366 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2349 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2367 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2350 | mov [esp+32], eax |
2368 | mov [esp+32], eax |
2351 | ret |
2369 | ret |
2352 | ;------------------------------------------------------------------------------ |
2370 | ;------------------------------------------------------------------------------ |
2353 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2371 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2354 | mov eax, dword [cpu_freq] |
2372 | mov eax, dword [cpu_freq] |
2355 | mov [esp+32], eax |
2373 | mov [esp+32], eax |
2356 | ret |
2374 | ret |
2357 | ;------------------------------------------------------------------------------ |
2375 | ;------------------------------------------------------------------------------ |
2358 | get_cpu_freq: |
2376 | get_cpu_freq: |
2359 | mov eax, dword [cpu_freq] |
2377 | mov eax, dword [cpu_freq] |
2360 | mov edx, dword [cpu_freq+4] |
2378 | mov edx, dword [cpu_freq+4] |
2361 | ret |
2379 | ret |
2362 | ; SAVE ramdisk to /hd/1/menuet.img |
2380 | ; SAVE ramdisk to /hd/1/menuet.img |
2363 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2381 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2364 | include 'blkdev/rdsave.inc' |
2382 | include 'blkdev/rdsave.inc' |
2365 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2383 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2366 | ;------------------------------------------------------------------------------ |
2384 | ;------------------------------------------------------------------------------ |
2367 | align 4 |
2385 | align 4 |
2368 | sysfn_getactive: ; 18.7 = get active window |
2386 | sysfn_getactive: ; 18.7 = get active window |
2369 | mov eax, [TASK_COUNT] |
2387 | mov eax, [TASK_COUNT] |
2370 | movzx eax, word [WIN_POS + eax*2] |
2388 | movzx eax, word [WIN_POS + eax*2] |
2371 | mov [esp+32], eax |
2389 | mov [esp+32], eax |
2372 | ret |
2390 | ret |
2373 | ;------------------------------------------------------------------------------ |
2391 | ;------------------------------------------------------------------------------ |
2374 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2392 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2375 | ; cmp ecx,1 |
2393 | ; cmp ecx,1 |
2376 | dec ecx |
2394 | dec ecx |
2377 | jnz nogetsoundflag |
2395 | jnz nogetsoundflag |
2378 | movzx eax, byte [sound_flag]; get sound_flag |
2396 | movzx eax, byte [sound_flag]; get sound_flag |
2379 | mov [esp+32], eax |
2397 | mov [esp+32], eax |
2380 | ret |
2398 | ret |
2381 | nogetsoundflag: |
2399 | nogetsoundflag: |
2382 | ; cmp ecx,2 |
2400 | ; cmp ecx,2 |
2383 | dec ecx |
2401 | dec ecx |
2384 | jnz nosoundflag |
2402 | jnz nosoundflag |
2385 | xor byte [sound_flag], 1 |
2403 | xor byte [sound_flag], 1 |
2386 | nosoundflag: |
2404 | nosoundflag: |
2387 | ret |
2405 | ret |
2388 | ;------------------------------------------------------------------------------ |
2406 | ;------------------------------------------------------------------------------ |
2389 | sysfn_minimize: ; 18.10 = minimize window |
2407 | sysfn_minimize: ; 18.10 = minimize window |
2390 | mov [window_minimize], 1 |
2408 | mov [window_minimize], 1 |
2391 | call wakeup_osloop |
2409 | call wakeup_osloop |
2392 | ret |
2410 | ret |
2393 | ;------------------------------------------------------------------------------ |
2411 | ;------------------------------------------------------------------------------ |
2394 | align 4 |
2412 | align 4 |
2395 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2413 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2396 | dec ecx |
2414 | dec ecx |
2397 | jnz .exit |
2415 | jnz .exit |
2398 | .small_table: |
2416 | .small_table: |
2399 | mov edi, edx |
2417 | mov edi, edx |
2400 | mov esi, DRIVE_DATA |
2418 | mov esi, DRIVE_DATA |
2401 | mov ecx, DRIVE_DATA_SIZE ;10 |
2419 | mov ecx, DRIVE_DATA_SIZE ;10 |
2402 | cld |
2420 | cld |
2403 | rep movsb |
2421 | rep movsb |
2404 | .exit: |
2422 | .exit: |
2405 | ret |
2423 | ret |
2406 | ;------------------------------------------------------------------------------ |
2424 | ;------------------------------------------------------------------------------ |
2407 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2425 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2408 | and dword [esp+32], 0 |
2426 | and dword [esp+32], 0 |
2409 | ret |
2427 | ret |
2410 | ;------------------------------------------------------------------------------ |
2428 | ;------------------------------------------------------------------------------ |
2411 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2429 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2412 | mov edi, ecx |
2430 | mov edi, ecx |
2413 | mov esi, version_inf |
2431 | mov esi, version_inf |
2414 | mov ecx, version_end-version_inf |
2432 | mov ecx, version_end-version_inf |
2415 | rep movsb |
2433 | rep movsb |
2416 | ret |
2434 | ret |
2417 | ;------------------------------------------------------------------------------ |
2435 | ;------------------------------------------------------------------------------ |
2418 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2436 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2419 | ;wait retrace functions |
2437 | ;wait retrace functions |
2420 | sys_wait_retrace: |
2438 | sys_wait_retrace: |
2421 | mov edx, 0x3da |
2439 | mov edx, 0x3da |
2422 | WaitRetrace_loop: |
2440 | WaitRetrace_loop: |
2423 | in al, dx |
2441 | in al, dx |
2424 | test al, 1000b |
2442 | test al, 1000b |
2425 | jz WaitRetrace_loop |
2443 | jz WaitRetrace_loop |
2426 | and [esp+32], dword 0 |
2444 | and [esp+32], dword 0 |
2427 | ret |
2445 | ret |
2428 | ;------------------------------------------------------------------------------ |
2446 | ;------------------------------------------------------------------------------ |
2429 | align 4 |
2447 | align 4 |
2430 | sysfn_centermouse: ; 18.15 = mouse centered |
2448 | sysfn_centermouse: ; 18.15 = mouse centered |
2431 | ; removed here by |
2449 | ; removed here by |
2432 | ; call mouse_centered |
2450 | ; call mouse_centered |
2433 | ;* mouse centered - start code- Mario79 |
2451 | ;* mouse centered - start code- Mario79 |
2434 | ;mouse_centered: |
2452 | ;mouse_centered: |
2435 | ; push eax |
2453 | ; push eax |
2436 | mov eax, [_display.width] |
2454 | mov eax, [_display.width] |
2437 | shr eax, 1 |
2455 | shr eax, 1 |
2438 | mov [MOUSE_X], ax |
2456 | mov [MOUSE_X], ax |
2439 | mov eax, [_display.height] |
2457 | mov eax, [_display.height] |
2440 | shr eax, 1 |
2458 | shr eax, 1 |
2441 | mov [MOUSE_Y], ax |
2459 | mov [MOUSE_Y], ax |
2442 | call wakeup_osloop |
2460 | call wakeup_osloop |
2443 | ; ret |
2461 | ; ret |
2444 | ;* mouse centered - end code- Mario79 |
2462 | ;* mouse centered - end code- Mario79 |
2445 | xor eax, eax |
2463 | xor eax, eax |
2446 | and [esp+32], eax |
2464 | and [esp+32], eax |
2447 | ; pop eax |
2465 | ; pop eax |
2448 | ret |
2466 | ret |
2449 | ;------------------------------------------------------------------------------ |
2467 | ;------------------------------------------------------------------------------ |
2450 | align 4 |
2468 | align 4 |
2451 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2469 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2452 | test ecx, ecx; get mouse speed factor |
2470 | test ecx, ecx; get mouse speed factor |
2453 | jnz .set_mouse_acceleration |
2471 | jnz .set_mouse_acceleration |
2454 | xor eax, eax |
2472 | xor eax, eax |
2455 | mov ax, [mouse_speed_factor] |
2473 | mov ax, [mouse_speed_factor] |
2456 | mov [esp+32], eax |
2474 | mov [esp+32], eax |
2457 | ret |
2475 | ret |
2458 | .set_mouse_acceleration: |
2476 | .set_mouse_acceleration: |
2459 | ; cmp ecx,1 ; set mouse speed factor |
2477 | ; cmp ecx,1 ; set mouse speed factor |
2460 | dec ecx |
2478 | dec ecx |
2461 | jnz .get_mouse_delay |
2479 | jnz .get_mouse_delay |
2462 | mov [mouse_speed_factor], dx |
2480 | mov [mouse_speed_factor], dx |
2463 | ret |
2481 | ret |
2464 | .get_mouse_delay: |
2482 | .get_mouse_delay: |
2465 | ; cmp ecx,2 ; get mouse delay |
2483 | ; cmp ecx,2 ; get mouse delay |
2466 | dec ecx |
2484 | dec ecx |
2467 | jnz .set_mouse_delay |
2485 | jnz .set_mouse_delay |
2468 | mov eax, [mouse_delay] |
2486 | mov eax, [mouse_delay] |
2469 | mov [esp+32], eax |
2487 | mov [esp+32], eax |
2470 | ret |
2488 | ret |
2471 | .set_mouse_delay: |
2489 | .set_mouse_delay: |
2472 | ; cmp ecx,3 ; set mouse delay |
2490 | ; cmp ecx,3 ; set mouse delay |
2473 | dec ecx |
2491 | dec ecx |
2474 | jnz .set_pointer_position |
2492 | jnz .set_pointer_position |
2475 | mov [mouse_delay], edx |
2493 | mov [mouse_delay], edx |
2476 | ret |
2494 | ret |
2477 | .set_pointer_position: |
2495 | .set_pointer_position: |
2478 | ; cmp ecx,4 ; set mouse pointer position |
2496 | ; cmp ecx,4 ; set mouse pointer position |
2479 | dec ecx |
2497 | dec ecx |
2480 | jnz .set_mouse_button |
2498 | jnz .set_mouse_button |
2481 | cmp dx, word[_display.height] |
2499 | cmp dx, word[_display.height] |
2482 | jae .end |
2500 | jae .end |
2483 | rol edx, 16 |
2501 | rol edx, 16 |
2484 | cmp dx, word[_display.width] |
2502 | cmp dx, word[_display.width] |
2485 | jae .end |
2503 | jae .end |
2486 | mov [MOUSE_X], edx |
2504 | mov [MOUSE_X], edx |
2487 | mov [mouse_active], 1 |
2505 | mov [mouse_active], 1 |
2488 | call wakeup_osloop |
2506 | call wakeup_osloop |
2489 | ret |
2507 | ret |
2490 | .set_mouse_button: |
2508 | .set_mouse_button: |
2491 | ; cmp ecx,5 ; set mouse button features |
2509 | ; cmp ecx,5 ; set mouse button features |
2492 | dec ecx |
2510 | dec ecx |
2493 | jnz .end |
2511 | jnz .end |
2494 | mov [BTN_DOWN], dl |
2512 | mov [BTN_DOWN], dl |
2495 | mov [mouse_active], 1 |
2513 | mov [mouse_active], 1 |
2496 | call wakeup_osloop |
2514 | call wakeup_osloop |
2497 | .end: |
2515 | .end: |
2498 | ret |
2516 | ret |
2499 | ;------------------------------------------------------------------------------ |
2517 | ;------------------------------------------------------------------------------ |
2500 | sysfn_getfreemem: |
2518 | sysfn_getfreemem: |
2501 | mov eax, [pg_data.pages_free] |
2519 | mov eax, [pg_data.pages_free] |
2502 | shl eax, 2 |
2520 | shl eax, 2 |
2503 | mov [esp+32], eax |
2521 | mov [esp+32], eax |
2504 | ret |
2522 | ret |
2505 | ;------------------------------------------------------------------------------ |
2523 | ;------------------------------------------------------------------------------ |
2506 | sysfn_getallmem: |
2524 | sysfn_getallmem: |
2507 | mov eax, [MEM_AMOUNT] |
2525 | mov eax, [MEM_AMOUNT] |
2508 | shr eax, 10 |
2526 | shr eax, 10 |
2509 | mov [esp+32], eax |
2527 | mov [esp+32], eax |
2510 | ret |
2528 | ret |
2511 | ;------------------------------------------------------------------------------ |
2529 | ;------------------------------------------------------------------------------ |
2512 | sysfn_pid_to_slot: |
2530 | sysfn_pid_to_slot: |
2513 | mov eax, ecx |
2531 | mov eax, ecx |
2514 | call pid_to_slot |
2532 | call pid_to_slot |
2515 | mov [esp+32], eax |
2533 | mov [esp+32], eax |
2516 | ret |
2534 | ret |
2517 | ;------------------------------------------------------------------------------ |
2535 | ;------------------------------------------------------------------------------ |
2518 | sysfn_min_rest_window: |
2536 | sysfn_min_rest_window: |
2519 | pushad |
2537 | pushad |
2520 | mov eax, edx ; ebx - operating |
2538 | mov eax, edx ; ebx - operating |
2521 | shr ecx, 1 |
2539 | shr ecx, 1 |
2522 | jnc @f |
2540 | jnc @f |
2523 | call pid_to_slot |
2541 | call pid_to_slot |
2524 | @@: |
2542 | @@: |
2525 | or eax, eax ; eax - number of slot |
2543 | or eax, eax ; eax - number of slot |
2526 | jz .error |
2544 | jz .error |
2527 | cmp eax, 255 ; varify maximal slot number |
2545 | cmp eax, 255 ; varify maximal slot number |
2528 | ja .error |
2546 | ja .error |
2529 | movzx eax, word [WIN_STACK + eax*2] |
2547 | movzx eax, word [WIN_STACK + eax*2] |
2530 | shr ecx, 1 |
2548 | shr ecx, 1 |
2531 | jc .restore |
2549 | jc .restore |
2532 | ; .minimize: |
2550 | ; .minimize: |
2533 | call minimize_window |
2551 | call minimize_window |
2534 | jmp .exit |
2552 | jmp .exit |
2535 | .restore: |
2553 | .restore: |
2536 | call restore_minimized_window |
2554 | call restore_minimized_window |
2537 | .exit: |
2555 | .exit: |
2538 | popad |
2556 | popad |
2539 | xor eax, eax |
2557 | xor eax, eax |
2540 | mov [esp+32], eax |
2558 | mov [esp+32], eax |
2541 | ret |
2559 | ret |
2542 | .error: |
2560 | .error: |
2543 | popad |
2561 | popad |
2544 | xor eax, eax |
2562 | xor eax, eax |
2545 | dec eax |
2563 | dec eax |
2546 | mov [esp+32], eax |
2564 | mov [esp+32], eax |
2547 | ret |
2565 | ret |
2548 | ;------------------------------------------------------------------------------ |
2566 | ;------------------------------------------------------------------------------ |
2549 | sysfn_min_windows: |
2567 | sysfn_min_windows: |
2550 | call minimize_all_window |
2568 | call minimize_all_window |
2551 | mov [esp+32], eax |
2569 | mov [esp+32], eax |
2552 | call change_task |
2570 | call change_task |
2553 | ret |
2571 | ret |
2554 | ;------------------------------------------------------------------------------ |
2572 | ;------------------------------------------------------------------------------ |
2555 | sysfn_set_screen_sizes: |
2573 | sysfn_set_screen_sizes: |
2556 | cmp [SCR_MODE], word 0x13 |
2574 | cmp [SCR_MODE], word 0x13 |
2557 | jbe .exit |
2575 | jbe .exit |
2558 | 2576 | ||
2559 | cmp [_display.select_cursor], select_cursor |
2577 | cmp [_display.select_cursor], select_cursor |
2560 | jne .exit |
2578 | jne .exit |
2561 | 2579 | ||
2562 | cmp ecx, [display_width_standard] |
2580 | cmp ecx, [display_width_standard] |
2563 | ja .exit |
2581 | ja .exit |
2564 | 2582 | ||
2565 | cmp edx, [display_height_standard] |
2583 | cmp edx, [display_height_standard] |
2566 | ja .exit |
2584 | ja .exit |
2567 | 2585 | ||
2568 | pushfd |
2586 | pushfd |
2569 | cli |
2587 | cli |
2570 | mov eax, ecx |
2588 | mov eax, ecx |
2571 | mov ecx, [_display.lfb_pitch] |
2589 | mov ecx, [_display.lfb_pitch] |
2572 | mov [_display.width], eax |
2590 | mov [_display.width], eax |
2573 | dec eax |
2591 | dec eax |
2574 | mov [_display.height], edx |
2592 | mov [_display.height], edx |
2575 | dec edx |
2593 | dec edx |
2576 | ; eax - new Screen_Max_X |
2594 | ; eax - new Screen_Max_X |
2577 | ; edx - new Screen_Max_Y |
2595 | ; edx - new Screen_Max_Y |
2578 | mov [do_not_touch_winmap], 1 |
2596 | mov [do_not_touch_winmap], 1 |
2579 | call set_screen |
2597 | call set_screen |
2580 | mov [do_not_touch_winmap], 0 |
2598 | mov [do_not_touch_winmap], 0 |
2581 | popfd |
2599 | popfd |
2582 | call change_task |
2600 | call change_task |
2583 | .exit: |
2601 | .exit: |
2584 | ret |
2602 | ret |
2585 | ;------------------------------------------------------------------------------ |
2603 | ;------------------------------------------------------------------------------ |
2586 | uglobal |
2604 | uglobal |
2587 | screen_workarea RECT |
2605 | screen_workarea RECT |
2588 | display_width_standard dd 0 |
2606 | display_width_standard dd 0 |
2589 | display_height_standard dd 0 |
2607 | display_height_standard dd 0 |
2590 | do_not_touch_winmap db 0 |
2608 | do_not_touch_winmap db 0 |
2591 | window_minimize db 0 |
2609 | window_minimize db 0 |
2592 | sound_flag db 0 |
2610 | sound_flag db 0 |
2593 | 2611 | ||
2594 | endg |
2612 | endg |
2595 | 2613 | ||
2596 | UID_NONE=0 |
2614 | UID_NONE=0 |
2597 | UID_MENUETOS=1 ;official |
2615 | UID_MENUETOS=1 ;official |
2598 | UID_KOLIBRI=2 ;russian |
2616 | UID_KOLIBRI=2 ;russian |
2599 | 2617 | ||
2600 | iglobal |
2618 | iglobal |
2601 | version_inf: |
2619 | version_inf: |
2602 | db 0,7,7,0 ; version 0.7.7.0 |
2620 | db 0,7,7,0 ; version 0.7.7.0 |
2603 | db 0 |
2621 | db 0 |
2604 | .rev dd __REV__ |
2622 | .rev dd __REV__ |
2605 | version_end: |
2623 | version_end: |
2606 | endg |
2624 | endg |
2607 | ;------------------------------------------------------------------------------ |
2625 | ;------------------------------------------------------------------------------ |
2608 | align 4 |
2626 | align 4 |
2609 | sys_cachetodiskette: |
2627 | sys_cachetodiskette: |
2610 | cmp ebx, 1 |
2628 | cmp ebx, 1 |
2611 | jb .no_floppy_save |
2629 | jb .no_floppy_save |
2612 | cmp ebx, 2 |
2630 | cmp ebx, 2 |
2613 | ja .no_floppy_save |
2631 | ja .no_floppy_save |
2614 | call save_image |
2632 | call save_image |
2615 | mov [esp + 32], eax |
2633 | mov [esp + 32], eax |
2616 | ret |
2634 | ret |
2617 | .no_floppy_save: |
2635 | .no_floppy_save: |
2618 | mov [esp + 32], dword 1 |
2636 | mov [esp + 32], dword 1 |
2619 | ret |
2637 | ret |
2620 | ;------------------------------------------------------------------------------ |
2638 | ;------------------------------------------------------------------------------ |
2621 | uglobal |
2639 | uglobal |
2622 | ; bgrchanged dd 0x0 |
2640 | ; bgrchanged dd 0x0 |
2623 | align 4 |
2641 | align 4 |
2624 | bgrlockpid dd 0 |
2642 | bgrlockpid dd 0 |
2625 | bgrlock db 0 |
2643 | bgrlock db 0 |
2626 | endg |
2644 | endg |
2627 | ;------------------------------------------------------------------------------ |
2645 | ;------------------------------------------------------------------------------ |
2628 | align 4 |
2646 | align 4 |
2629 | sys_background: |
2647 | sys_background: |
2630 | cmp ebx, 1 ; BACKGROUND SIZE |
2648 | cmp ebx, 1 ; BACKGROUND SIZE |
2631 | jnz nosb1 |
2649 | jnz nosb1 |
2632 | test ecx, ecx |
2650 | test ecx, ecx |
2633 | jz sbgrr |
2651 | jz sbgrr |
2634 | 2652 | ||
2635 | test edx, edx |
2653 | test edx, edx |
2636 | jz sbgrr |
2654 | jz sbgrr |
2637 | ;-------------------------------------- |
2655 | ;-------------------------------------- |
2638 | align 4 |
2656 | align 4 |
2639 | @@: |
2657 | @@: |
2640 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2658 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2641 | bts dword [bgrlock], 0 |
2659 | bts dword [bgrlock], 0 |
2642 | jnc @f |
2660 | jnc @f |
2643 | call change_task |
2661 | call change_task |
2644 | jmp @b |
2662 | jmp @b |
2645 | ;-------------------------------------- |
2663 | ;-------------------------------------- |
2646 | align 4 |
2664 | align 4 |
2647 | @@: |
2665 | @@: |
2648 | mov [BgrDataWidth], ecx |
2666 | mov [BgrDataWidth], ecx |
2649 | mov [BgrDataHeight], edx |
2667 | mov [BgrDataHeight], edx |
2650 | ; mov [bgrchanged],1 |
2668 | ; mov [bgrchanged],1 |
2651 | 2669 | ||
2652 | pushad |
2670 | pushad |
2653 | ; return memory for old background |
2671 | ; return memory for old background |
2654 | mov eax, [img_background] |
2672 | mov eax, [img_background] |
2655 | cmp eax, static_background_data |
2673 | cmp eax, static_background_data |
2656 | jz @f |
2674 | jz @f |
2657 | stdcall kernel_free, eax |
2675 | stdcall kernel_free, eax |
2658 | ;-------------------------------------- |
2676 | ;-------------------------------------- |
2659 | align 4 |
2677 | align 4 |
2660 | @@: |
2678 | @@: |
2661 | ; calculate RAW size |
2679 | ; calculate RAW size |
2662 | xor eax, eax |
2680 | xor eax, eax |
2663 | inc eax |
2681 | inc eax |
2664 | cmp [BgrDataWidth], eax |
2682 | cmp [BgrDataWidth], eax |
2665 | jae @f |
2683 | jae @f |
2666 | mov [BgrDataWidth], eax |
2684 | mov [BgrDataWidth], eax |
2667 | ;-------------------------------------- |
2685 | ;-------------------------------------- |
2668 | align 4 |
2686 | align 4 |
2669 | @@: |
2687 | @@: |
2670 | cmp [BgrDataHeight], eax |
2688 | cmp [BgrDataHeight], eax |
2671 | jae @f |
2689 | jae @f |
2672 | mov [BgrDataHeight], eax |
2690 | mov [BgrDataHeight], eax |
2673 | ;-------------------------------------- |
2691 | ;-------------------------------------- |
2674 | align 4 |
2692 | align 4 |
2675 | @@: |
2693 | @@: |
2676 | mov eax, [BgrDataWidth] |
2694 | mov eax, [BgrDataWidth] |
2677 | imul eax, [BgrDataHeight] |
2695 | imul eax, [BgrDataHeight] |
2678 | lea eax, [eax*3] |
2696 | lea eax, [eax*3] |
2679 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2697 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2680 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2698 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2681 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2699 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2682 | shr eax, 12 |
2700 | shr eax, 12 |
2683 | inc eax |
2701 | inc eax |
2684 | shl eax, 12 |
2702 | shl eax, 12 |
2685 | mov [mem_BACKGROUND], eax |
2703 | mov [mem_BACKGROUND], eax |
2686 | ; get memory for new background |
2704 | ; get memory for new background |
2687 | stdcall kernel_alloc, eax |
2705 | stdcall kernel_alloc, eax |
2688 | test eax, eax |
2706 | test eax, eax |
2689 | jz .memfailed |
2707 | jz .memfailed |
2690 | mov [img_background], eax |
2708 | mov [img_background], eax |
2691 | jmp .exit |
2709 | jmp .exit |
2692 | ;-------------------------------------- |
2710 | ;-------------------------------------- |
2693 | align 4 |
2711 | align 4 |
2694 | .memfailed: |
2712 | .memfailed: |
2695 | ; revert to static monotone data |
2713 | ; revert to static monotone data |
2696 | mov [img_background], static_background_data |
2714 | mov [img_background], static_background_data |
2697 | xor eax, eax |
2715 | xor eax, eax |
2698 | inc eax |
2716 | inc eax |
2699 | mov [BgrDataWidth], eax |
2717 | mov [BgrDataWidth], eax |
2700 | mov [BgrDataHeight], eax |
2718 | mov [BgrDataHeight], eax |
2701 | mov [mem_BACKGROUND], 4 |
2719 | mov [mem_BACKGROUND], 4 |
2702 | ;-------------------------------------- |
2720 | ;-------------------------------------- |
2703 | align 4 |
2721 | align 4 |
2704 | .exit: |
2722 | .exit: |
2705 | popad |
2723 | popad |
2706 | mov [bgrlock], 0 |
2724 | mov [bgrlock], 0 |
2707 | ;-------------------------------------- |
2725 | ;-------------------------------------- |
2708 | align 4 |
2726 | align 4 |
2709 | sbgrr: |
2727 | sbgrr: |
2710 | ret |
2728 | ret |
2711 | ;------------------------------------------------------------------------------ |
2729 | ;------------------------------------------------------------------------------ |
2712 | align 4 |
2730 | align 4 |
2713 | nosb1: |
2731 | nosb1: |
2714 | cmp ebx, 2 ; SET PIXEL |
2732 | cmp ebx, 2 ; SET PIXEL |
2715 | jnz nosb2 |
2733 | jnz nosb2 |
2716 | 2734 | ||
2717 | mov eax, [img_background] |
2735 | mov eax, [img_background] |
2718 | test ecx, ecx |
2736 | test ecx, ecx |
2719 | jz @f |
2737 | jz @f |
2720 | cmp eax, static_background_data |
2738 | cmp eax, static_background_data |
2721 | jz .ret |
2739 | jz .ret |
2722 | ;-------------------------------------- |
2740 | ;-------------------------------------- |
2723 | align 4 |
2741 | align 4 |
2724 | @@: |
2742 | @@: |
2725 | mov ebx, [mem_BACKGROUND] |
2743 | mov ebx, [mem_BACKGROUND] |
2726 | add ebx, 4095 |
2744 | add ebx, 4095 |
2727 | and ebx, -4096 |
2745 | and ebx, -4096 |
2728 | sub ebx, 4 |
2746 | sub ebx, 4 |
2729 | cmp ecx, ebx |
2747 | cmp ecx, ebx |
2730 | ja .ret |
2748 | ja .ret |
2731 | 2749 | ||
2732 | mov ebx, [eax+ecx] |
2750 | mov ebx, [eax+ecx] |
2733 | and ebx, 0xFF000000;255*256*256*256 |
2751 | and ebx, 0xFF000000;255*256*256*256 |
2734 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2752 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2735 | add edx, ebx |
2753 | add edx, ebx |
2736 | mov [eax+ecx], edx |
2754 | mov [eax+ecx], edx |
2737 | ;-------------------------------------- |
2755 | ;-------------------------------------- |
2738 | align 4 |
2756 | align 4 |
2739 | .ret: |
2757 | .ret: |
2740 | ret |
2758 | ret |
2741 | ;------------------------------------------------------------------------------ |
2759 | ;------------------------------------------------------------------------------ |
2742 | align 4 |
2760 | align 4 |
2743 | nosb2: |
2761 | nosb2: |
2744 | cmp ebx, 3 ; DRAW BACKGROUND |
2762 | cmp ebx, 3 ; DRAW BACKGROUND |
2745 | jnz nosb3 |
2763 | jnz nosb3 |
2746 | ;-------------------------------------- |
2764 | ;-------------------------------------- |
2747 | align 4 |
2765 | align 4 |
2748 | draw_background_temp: |
2766 | draw_background_temp: |
2749 | mov [background_defined], 1 |
2767 | mov [background_defined], 1 |
2750 | call force_redraw_background |
2768 | call force_redraw_background |
2751 | ;-------------------------------------- |
2769 | ;-------------------------------------- |
2752 | align 4 |
2770 | align 4 |
2753 | nosb31: |
2771 | nosb31: |
2754 | ret |
2772 | ret |
2755 | ;------------------------------------------------------------------------------ |
2773 | ;------------------------------------------------------------------------------ |
2756 | align 4 |
2774 | align 4 |
2757 | nosb3: |
2775 | nosb3: |
2758 | cmp ebx, 4 ; TILED / STRETCHED |
2776 | cmp ebx, 4 ; TILED / STRETCHED |
2759 | jnz nosb4 |
2777 | jnz nosb4 |
2760 | cmp ecx, [BgrDrawMode] |
2778 | cmp ecx, [BgrDrawMode] |
2761 | je nosb41 |
2779 | je nosb41 |
2762 | mov [BgrDrawMode], ecx |
2780 | mov [BgrDrawMode], ecx |
2763 | ;-------------------------------------- |
2781 | ;-------------------------------------- |
2764 | align 4 |
2782 | align 4 |
2765 | nosb41: |
2783 | nosb41: |
2766 | ret |
2784 | ret |
2767 | ;------------------------------------------------------------------------------ |
2785 | ;------------------------------------------------------------------------------ |
2768 | align 4 |
2786 | align 4 |
2769 | nosb4: |
2787 | nosb4: |
2770 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2788 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2771 | jnz nosb5 |
2789 | jnz nosb5 |
2772 | cmp [img_background], static_background_data |
2790 | cmp [img_background], static_background_data |
2773 | jnz @f |
2791 | jnz @f |
2774 | test edx, edx |
2792 | test edx, edx |
2775 | jnz .fin |
2793 | jnz .fin |
2776 | cmp esi, 4 |
2794 | cmp esi, 4 |
2777 | ja .fin |
2795 | ja .fin |
2778 | ;-------------------------------------- |
2796 | ;-------------------------------------- |
2779 | align 4 |
2797 | align 4 |
2780 | @@: |
2798 | @@: |
2781 | ; bughere |
2799 | ; bughere |
2782 | mov eax, ecx |
2800 | mov eax, ecx |
2783 | mov ebx, edx |
2801 | mov ebx, edx |
2784 | add ebx, [img_background];IMG_BACKGROUND |
2802 | add ebx, [img_background];IMG_BACKGROUND |
2785 | mov ecx, esi |
2803 | mov ecx, esi |
2786 | call memmove |
2804 | call memmove |
2787 | ;-------------------------------------- |
2805 | ;-------------------------------------- |
2788 | align 4 |
2806 | align 4 |
2789 | .fin: |
2807 | .fin: |
2790 | ret |
2808 | ret |
2791 | ;------------------------------------------------------------------------------ |
2809 | ;------------------------------------------------------------------------------ |
2792 | align 4 |
2810 | align 4 |
2793 | nosb5: |
2811 | nosb5: |
2794 | cmp ebx, 6 |
2812 | cmp ebx, 6 |
2795 | jnz nosb6 |
2813 | jnz nosb6 |
2796 | ;-------------------------------------- |
2814 | ;-------------------------------------- |
2797 | align 4 |
2815 | align 4 |
2798 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2816 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2799 | @@: |
2817 | @@: |
2800 | bts dword [bgrlock], 0 |
2818 | bts dword [bgrlock], 0 |
2801 | jnc @f |
2819 | jnc @f |
2802 | call change_task |
2820 | call change_task |
2803 | jmp @b |
2821 | jmp @b |
2804 | ;-------------------------------------- |
2822 | ;-------------------------------------- |
2805 | align 4 |
2823 | align 4 |
2806 | @@: |
2824 | @@: |
2807 | mov eax, [CURRENT_TASK] |
2825 | mov eax, [CURRENT_TASK] |
2808 | mov [bgrlockpid], eax |
2826 | mov [bgrlockpid], eax |
2809 | cmp [img_background], static_background_data |
2827 | cmp [img_background], static_background_data |
2810 | jz .nomem |
2828 | jz .nomem |
2811 | stdcall user_alloc, [mem_BACKGROUND] |
2829 | stdcall user_alloc, [mem_BACKGROUND] |
2812 | mov [esp+32], eax |
2830 | mov [esp+32], eax |
2813 | test eax, eax |
2831 | test eax, eax |
2814 | jz .nomem |
2832 | jz .nomem |
2815 | mov ebx, eax |
2833 | mov ebx, eax |
2816 | shr ebx, 12 |
2834 | shr ebx, 12 |
2817 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2835 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2818 | mov esi, [img_background] |
2836 | mov esi, [img_background] |
2819 | shr esi, 12 |
2837 | shr esi, 12 |
2820 | mov ecx, [mem_BACKGROUND] |
2838 | mov ecx, [mem_BACKGROUND] |
2821 | add ecx, 0xFFF |
2839 | add ecx, 0xFFF |
2822 | shr ecx, 12 |
2840 | shr ecx, 12 |
2823 | ;-------------------------------------- |
2841 | ;-------------------------------------- |
2824 | align 4 |
2842 | align 4 |
2825 | .z: |
2843 | .z: |
2826 | mov eax, [page_tabs+ebx*4] |
2844 | mov eax, [page_tabs+ebx*4] |
2827 | test al, 1 |
2845 | test al, 1 |
2828 | jz @f |
2846 | jz @f |
2829 | call free_page |
2847 | call free_page |
2830 | ;-------------------------------------- |
2848 | ;-------------------------------------- |
2831 | align 4 |
2849 | align 4 |
2832 | @@: |
2850 | @@: |
2833 | mov eax, [page_tabs+esi*4] |
2851 | mov eax, [page_tabs+esi*4] |
2834 | or al, PG_UWR |
2852 | or al, PG_UWR |
2835 | mov [page_tabs+ebx*4], eax |
2853 | mov [page_tabs+ebx*4], eax |
2836 | mov eax, ebx |
2854 | mov eax, ebx |
2837 | shl eax, 12 |
2855 | shl eax, 12 |
2838 | invlpg [eax] |
2856 | invlpg [eax] |
2839 | inc ebx |
2857 | inc ebx |
2840 | inc esi |
2858 | inc esi |
2841 | loop .z |
2859 | loop .z |
2842 | ret |
2860 | ret |
2843 | ;-------------------------------------- |
2861 | ;-------------------------------------- |
2844 | align 4 |
2862 | align 4 |
2845 | .nomem: |
2863 | .nomem: |
2846 | and [bgrlockpid], 0 |
2864 | and [bgrlockpid], 0 |
2847 | mov [bgrlock], 0 |
2865 | mov [bgrlock], 0 |
2848 | ;------------------------------------------------------------------------------ |
2866 | ;------------------------------------------------------------------------------ |
2849 | align 4 |
2867 | align 4 |
2850 | nosb6: |
2868 | nosb6: |
2851 | cmp ebx, 7 |
2869 | cmp ebx, 7 |
2852 | jnz nosb7 |
2870 | jnz nosb7 |
2853 | cmp [bgrlock], 0 |
2871 | cmp [bgrlock], 0 |
2854 | jz .err |
2872 | jz .err |
2855 | mov eax, [CURRENT_TASK] |
2873 | mov eax, [CURRENT_TASK] |
2856 | cmp [bgrlockpid], eax |
2874 | cmp [bgrlockpid], eax |
2857 | jnz .err |
2875 | jnz .err |
2858 | mov eax, ecx |
2876 | mov eax, ecx |
2859 | mov ebx, ecx |
2877 | mov ebx, ecx |
2860 | shr eax, 12 |
2878 | shr eax, 12 |
2861 | mov ecx, [page_tabs+(eax-1)*4] |
2879 | mov ecx, [page_tabs+(eax-1)*4] |
2862 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2880 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2863 | jz .err |
2881 | jz .err |
2864 | jnp .err |
2882 | jnp .err |
2865 | push eax |
2883 | push eax |
2866 | shr ecx, 12 |
2884 | shr ecx, 12 |
2867 | dec ecx |
2885 | dec ecx |
2868 | ;-------------------------------------- |
2886 | ;-------------------------------------- |
2869 | align 4 |
2887 | align 4 |
2870 | @@: |
2888 | @@: |
2871 | and dword [page_tabs+eax*4], 0 |
2889 | and dword [page_tabs+eax*4], 0 |
2872 | mov edx, eax |
2890 | mov edx, eax |
2873 | shl edx, 12 |
2891 | shl edx, 12 |
2874 | push eax |
2892 | push eax |
2875 | invlpg [edx] |
2893 | invlpg [edx] |
2876 | pop eax |
2894 | pop eax |
2877 | inc eax |
2895 | inc eax |
2878 | loop @b |
2896 | loop @b |
2879 | pop eax |
2897 | pop eax |
2880 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2898 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2881 | stdcall user_free, ebx |
2899 | stdcall user_free, ebx |
2882 | mov [esp+32], eax |
2900 | mov [esp+32], eax |
2883 | and [bgrlockpid], 0 |
2901 | and [bgrlockpid], 0 |
2884 | mov [bgrlock], 0 |
2902 | mov [bgrlock], 0 |
2885 | ret |
2903 | ret |
2886 | ;-------------------------------------- |
2904 | ;-------------------------------------- |
2887 | align 4 |
2905 | align 4 |
2888 | .err: |
2906 | .err: |
2889 | and dword [esp+32], 0 |
2907 | and dword [esp+32], 0 |
2890 | ret |
2908 | ret |
2891 | ;------------------------------------------------------------------------------ |
2909 | ;------------------------------------------------------------------------------ |
2892 | align 4 |
2910 | align 4 |
2893 | nosb7: |
2911 | nosb7: |
2894 | cmp ebx, 8 |
2912 | cmp ebx, 8 |
2895 | jnz nosb8 |
2913 | jnz nosb8 |
2896 | 2914 | ||
2897 | mov ecx, [current_slot] |
2915 | mov ecx, [current_slot] |
2898 | xor eax, eax |
2916 | xor eax, eax |
2899 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2917 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2900 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2918 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2901 | xor eax, eax |
2919 | xor eax, eax |
2902 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2920 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2903 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2921 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2904 | ret |
2922 | ret |
2905 | ;------------------------------------------------------------------------------ |
2923 | ;------------------------------------------------------------------------------ |
2906 | align 4 |
2924 | align 4 |
2907 | nosb8: |
2925 | nosb8: |
2908 | cmp ebx, 9 |
2926 | cmp ebx, 9 |
2909 | jnz nosb9 |
2927 | jnz nosb9 |
2910 | ; ecx = [left]*65536 + [right] |
2928 | ; ecx = [left]*65536 + [right] |
2911 | ; edx = [top]*65536 + [bottom] |
2929 | ; edx = [top]*65536 + [bottom] |
2912 | mov eax, [_display.width] |
2930 | mov eax, [_display.width] |
2913 | mov ebx, [_display.height] |
2931 | mov ebx, [_display.height] |
2914 | dec eax |
2932 | dec eax |
2915 | dec ebx |
2933 | dec ebx |
2916 | ; check [right] |
2934 | ; check [right] |
2917 | cmp cx, ax |
2935 | cmp cx, ax |
2918 | ja .exit |
2936 | ja .exit |
2919 | ; check [left] |
2937 | ; check [left] |
2920 | ror ecx, 16 |
2938 | ror ecx, 16 |
2921 | cmp cx, ax |
2939 | cmp cx, ax |
2922 | ja .exit |
2940 | ja .exit |
2923 | ; check [bottom] |
2941 | ; check [bottom] |
2924 | cmp dx, bx |
2942 | cmp dx, bx |
2925 | ja .exit |
2943 | ja .exit |
2926 | ; check [top] |
2944 | ; check [top] |
2927 | ror edx, 16 |
2945 | ror edx, 16 |
2928 | cmp dx, bx |
2946 | cmp dx, bx |
2929 | ja .exit |
2947 | ja .exit |
2930 | 2948 | ||
2931 | movzx eax, cx ; [left] |
2949 | movzx eax, cx ; [left] |
2932 | movzx ebx, dx ; [top] |
2950 | movzx ebx, dx ; [top] |
2933 | 2951 | ||
2934 | shr ecx, 16 ; [right] |
2952 | shr ecx, 16 ; [right] |
2935 | shr edx, 16 ; [bottom] |
2953 | shr edx, 16 ; [bottom] |
2936 | 2954 | ||
2937 | mov [background_defined], 1 |
2955 | mov [background_defined], 1 |
2938 | 2956 | ||
2939 | mov [draw_data+32 + RECT.left], eax |
2957 | mov [draw_data+32 + RECT.left], eax |
2940 | mov [draw_data+32 + RECT.top], ebx |
2958 | mov [draw_data+32 + RECT.top], ebx |
2941 | 2959 | ||
2942 | mov [draw_data+32 + RECT.right], ecx |
2960 | mov [draw_data+32 + RECT.right], ecx |
2943 | mov [draw_data+32 + RECT.bottom], edx |
2961 | mov [draw_data+32 + RECT.bottom], edx |
2944 | 2962 | ||
2945 | inc byte[REDRAW_BACKGROUND] |
2963 | inc byte[REDRAW_BACKGROUND] |
2946 | call wakeup_osloop |
2964 | call wakeup_osloop |
2947 | ;-------------------------------------- |
2965 | ;-------------------------------------- |
2948 | align 4 |
2966 | align 4 |
2949 | .exit: |
2967 | .exit: |
2950 | ret |
2968 | ret |
2951 | ;------------------------------------------------------------------------------ |
2969 | ;------------------------------------------------------------------------------ |
2952 | align 4 |
2970 | align 4 |
2953 | nosb9: |
2971 | nosb9: |
2954 | ret |
2972 | ret |
2955 | ;------------------------------------------------------------------------------ |
2973 | ;------------------------------------------------------------------------------ |
2956 | align 4 |
2974 | align 4 |
2957 | uglobal |
2975 | uglobal |
2958 | BG_Rect_X_left_right dd 0x0 |
2976 | BG_Rect_X_left_right dd 0x0 |
2959 | BG_Rect_Y_top_bottom dd 0x0 |
2977 | BG_Rect_Y_top_bottom dd 0x0 |
2960 | endg |
2978 | endg |
2961 | ;------------------------------------------------------------------------------ |
2979 | ;------------------------------------------------------------------------------ |
2962 | align 4 |
2980 | align 4 |
2963 | force_redraw_background: |
2981 | force_redraw_background: |
2964 | and [draw_data+32 + RECT.left], 0 |
2982 | and [draw_data+32 + RECT.left], 0 |
2965 | and [draw_data+32 + RECT.top], 0 |
2983 | and [draw_data+32 + RECT.top], 0 |
2966 | push eax ebx |
2984 | push eax ebx |
2967 | mov eax, [_display.width] |
2985 | mov eax, [_display.width] |
2968 | mov ebx, [_display.height] |
2986 | mov ebx, [_display.height] |
2969 | dec eax |
2987 | dec eax |
2970 | dec ebx |
2988 | dec ebx |
2971 | mov [draw_data+32 + RECT.right], eax |
2989 | mov [draw_data+32 + RECT.right], eax |
2972 | mov [draw_data+32 + RECT.bottom], ebx |
2990 | mov [draw_data+32 + RECT.bottom], ebx |
2973 | pop ebx eax |
2991 | pop ebx eax |
2974 | inc byte[REDRAW_BACKGROUND] |
2992 | inc byte[REDRAW_BACKGROUND] |
2975 | call wakeup_osloop |
2993 | call wakeup_osloop |
2976 | ret |
2994 | ret |
2977 | ;------------------------------------------------------------------------------ |
2995 | ;------------------------------------------------------------------------------ |
2978 | align 4 |
2996 | align 4 |
2979 | sys_getbackground: |
2997 | sys_getbackground: |
2980 | ; cmp eax,1 ; SIZE |
2998 | ; cmp eax,1 ; SIZE |
2981 | dec ebx |
2999 | dec ebx |
2982 | jnz nogb1 |
3000 | jnz nogb1 |
2983 | mov eax, [BgrDataWidth] |
3001 | mov eax, [BgrDataWidth] |
2984 | shl eax, 16 |
3002 | shl eax, 16 |
2985 | mov ax, word [BgrDataHeight] |
3003 | mov ax, word [BgrDataHeight] |
2986 | mov [esp+32], eax |
3004 | mov [esp+32], eax |
2987 | ret |
3005 | ret |
2988 | ;------------------------------------------------------------------------------ |
3006 | ;------------------------------------------------------------------------------ |
2989 | align 4 |
3007 | align 4 |
2990 | nogb1: |
3008 | nogb1: |
2991 | ; cmp eax,2 ; PIXEL |
3009 | ; cmp eax,2 ; PIXEL |
2992 | dec ebx |
3010 | dec ebx |
2993 | jnz nogb2 |
3011 | jnz nogb2 |
2994 | 3012 | ||
2995 | mov eax, [img_background] |
3013 | mov eax, [img_background] |
2996 | test ecx, ecx |
3014 | test ecx, ecx |
2997 | jz @f |
3015 | jz @f |
2998 | cmp eax, static_background_data |
3016 | cmp eax, static_background_data |
2999 | jz .ret |
3017 | jz .ret |
3000 | ;-------------------------------------- |
3018 | ;-------------------------------------- |
3001 | align 4 |
3019 | align 4 |
3002 | @@: |
3020 | @@: |
3003 | mov ebx, [mem_BACKGROUND] |
3021 | mov ebx, [mem_BACKGROUND] |
3004 | add ebx, 4095 |
3022 | add ebx, 4095 |
3005 | and ebx, -4096 |
3023 | and ebx, -4096 |
3006 | sub ebx, 4 |
3024 | sub ebx, 4 |
3007 | cmp ecx, ebx |
3025 | cmp ecx, ebx |
3008 | ja .ret |
3026 | ja .ret |
3009 | 3027 | ||
3010 | mov eax, [ecx+eax] |
3028 | mov eax, [ecx+eax] |
3011 | 3029 | ||
3012 | and eax, 0xFFFFFF |
3030 | and eax, 0xFFFFFF |
3013 | mov [esp+32], eax |
3031 | mov [esp+32], eax |
3014 | ;-------------------------------------- |
3032 | ;-------------------------------------- |
3015 | align 4 |
3033 | align 4 |
3016 | .ret: |
3034 | .ret: |
3017 | ret |
3035 | ret |
3018 | ;------------------------------------------------------------------------------ |
3036 | ;------------------------------------------------------------------------------ |
3019 | align 4 |
3037 | align 4 |
3020 | nogb2: |
3038 | nogb2: |
3021 | 3039 | ||
3022 | ; cmp eax,4 ; TILED / STRETCHED |
3040 | ; cmp eax,4 ; TILED / STRETCHED |
3023 | dec ebx |
3041 | dec ebx |
3024 | dec ebx |
3042 | dec ebx |
3025 | jnz nogb4 |
3043 | jnz nogb4 |
3026 | mov eax, [BgrDrawMode] |
3044 | mov eax, [BgrDrawMode] |
3027 | ;-------------------------------------- |
3045 | ;-------------------------------------- |
3028 | align 4 |
3046 | align 4 |
3029 | nogb4: |
3047 | nogb4: |
3030 | mov [esp+32], eax |
3048 | mov [esp+32], eax |
3031 | ret |
3049 | ret |
3032 | ;------------------------------------------------------------------------------ |
3050 | ;------------------------------------------------------------------------------ |
3033 | align 4 |
3051 | align 4 |
3034 | sys_getkey: |
3052 | sys_getkey: |
3035 | mov [esp + 32], dword 1 |
3053 | mov [esp + 32], dword 1 |
3036 | ; test main buffer |
3054 | ; test main buffer |
3037 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3055 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3038 | movzx ecx, word [WIN_STACK + ebx * 2] |
3056 | movzx ecx, word [WIN_STACK + ebx * 2] |
3039 | mov edx, [TASK_COUNT] |
3057 | mov edx, [TASK_COUNT] |
3040 | cmp ecx, edx |
3058 | cmp ecx, edx |
3041 | jne .finish |
3059 | jne .finish |
3042 | cmp [KEY_COUNT], byte 0 |
3060 | cmp [KEY_COUNT], byte 0 |
3043 | je .finish |
3061 | je .finish |
3044 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3062 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3045 | shl eax, 8 |
3063 | shl eax, 8 |
3046 | mov al, byte [KEY_BUFF] |
3064 | mov al, byte [KEY_BUFF] |
3047 | shl eax, 8 |
3065 | shl eax, 8 |
3048 | push eax |
3066 | push eax |
3049 | dec byte [KEY_COUNT] |
3067 | dec byte [KEY_COUNT] |
3050 | and byte [KEY_COUNT], 127 |
3068 | and byte [KEY_COUNT], 127 |
3051 | movzx ecx, byte [KEY_COUNT] |
3069 | movzx ecx, byte [KEY_COUNT] |
3052 | add ecx, 2 |
3070 | add ecx, 2 |
3053 | mov eax, KEY_BUFF + 1 |
3071 | mov eax, KEY_BUFF + 1 |
3054 | mov ebx, KEY_BUFF |
3072 | mov ebx, KEY_BUFF |
3055 | call memmove |
3073 | call memmove |
3056 | add eax, 120 + 2 |
3074 | add eax, 120 + 2 |
3057 | add ebx, 120 + 2 |
3075 | add ebx, 120 + 2 |
3058 | call memmove |
3076 | call memmove |
3059 | pop eax |
3077 | pop eax |
3060 | ;-------------------------------------- |
3078 | ;-------------------------------------- |
3061 | align 4 |
3079 | align 4 |
3062 | .ret_eax: |
3080 | .ret_eax: |
3063 | mov [esp + 32], eax |
3081 | mov [esp + 32], eax |
3064 | ret |
3082 | ret |
3065 | ;-------------------------------------- |
3083 | ;-------------------------------------- |
3066 | align 4 |
3084 | align 4 |
3067 | .finish: |
3085 | .finish: |
3068 | ; test hotkeys buffer |
3086 | ; test hotkeys buffer |
3069 | mov ecx, hotkey_buffer |
3087 | mov ecx, hotkey_buffer |
3070 | ;-------------------------------------- |
3088 | ;-------------------------------------- |
3071 | align 4 |
3089 | align 4 |
3072 | @@: |
3090 | @@: |
3073 | cmp [ecx], ebx |
3091 | cmp [ecx], ebx |
3074 | jz .found |
3092 | jz .found |
3075 | add ecx, 8 |
3093 | add ecx, 8 |
3076 | cmp ecx, hotkey_buffer + 120 * 8 |
3094 | cmp ecx, hotkey_buffer + 120 * 8 |
3077 | jb @b |
3095 | jb @b |
3078 | ret |
3096 | ret |
3079 | ;-------------------------------------- |
3097 | ;-------------------------------------- |
3080 | align 4 |
3098 | align 4 |
3081 | .found: |
3099 | .found: |
3082 | mov ax, [ecx + 6] |
3100 | mov ax, [ecx + 6] |
3083 | shl eax, 16 |
3101 | shl eax, 16 |
3084 | mov ah, [ecx + 4] |
3102 | mov ah, [ecx + 4] |
3085 | mov al, 2 |
3103 | mov al, 2 |
3086 | and dword [ecx + 4], 0 |
3104 | and dword [ecx + 4], 0 |
3087 | and dword [ecx], 0 |
3105 | and dword [ecx], 0 |
3088 | jmp .ret_eax |
3106 | jmp .ret_eax |
3089 | ;------------------------------------------------------------------------------ |
3107 | ;------------------------------------------------------------------------------ |
3090 | align 4 |
3108 | align 4 |
3091 | sys_getbutton: |
3109 | sys_getbutton: |
3092 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3110 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3093 | mov [esp + 32], dword 1 |
3111 | mov [esp + 32], dword 1 |
3094 | movzx ecx, word [WIN_STACK + ebx * 2] |
3112 | movzx ecx, word [WIN_STACK + ebx * 2] |
3095 | mov edx, [TASK_COUNT] ; less than 256 processes |
3113 | mov edx, [TASK_COUNT] ; less than 256 processes |
3096 | cmp ecx, edx |
3114 | cmp ecx, edx |
3097 | jne .exit |
3115 | jne .exit |
3098 | movzx eax, byte [BTN_COUNT] |
3116 | movzx eax, byte [BTN_COUNT] |
3099 | test eax, eax |
3117 | test eax, eax |
3100 | jz .exit |
3118 | jz .exit |
3101 | mov eax, [BTN_BUFF] |
3119 | mov eax, [BTN_BUFF] |
3102 | and al, 0xFE ; delete left button bit |
3120 | and al, 0xFE ; delete left button bit |
3103 | mov [BTN_COUNT], byte 0 |
3121 | mov [BTN_COUNT], byte 0 |
3104 | mov [esp + 32], eax |
3122 | mov [esp + 32], eax |
3105 | ;-------------------------------------- |
3123 | ;-------------------------------------- |
3106 | align 4 |
3124 | align 4 |
3107 | .exit: |
3125 | .exit: |
3108 | ret |
3126 | ret |
3109 | ;------------------------------------------------------------------------------ |
3127 | ;------------------------------------------------------------------------------ |
3110 | align 4 |
3128 | align 4 |
3111 | sys_cpuusage: |
3129 | sys_cpuusage: |
3112 | 3130 | ||
3113 | ; RETURN: |
3131 | ; RETURN: |
3114 | ; |
3132 | ; |
3115 | ; +00 dword process cpu usage |
3133 | ; +00 dword process cpu usage |
3116 | ; +04 word position in windowing stack |
3134 | ; +04 word position in windowing stack |
3117 | ; +06 word windowing stack value at current position (cpu nro) |
3135 | ; +06 word windowing stack value at current position (cpu nro) |
3118 | ; +10 12 bytes name |
3136 | ; +10 12 bytes name |
3119 | ; +22 dword start in mem |
3137 | ; +22 dword start in mem |
3120 | ; +26 dword used mem |
3138 | ; +26 dword used mem |
3121 | ; +30 dword PID , process idenfification number |
3139 | ; +30 dword PID , process idenfification number |
3122 | ; |
3140 | ; |
3123 | 3141 | ||
3124 | cmp ecx, -1 ; who am I ? |
3142 | cmp ecx, -1 ; who am I ? |
3125 | jne .no_who_am_i |
3143 | jne .no_who_am_i |
3126 | mov ecx, [CURRENT_TASK] |
3144 | mov ecx, [CURRENT_TASK] |
3127 | .no_who_am_i: |
3145 | .no_who_am_i: |
3128 | cmp ecx, max_processes |
3146 | cmp ecx, max_processes |
3129 | ja .nofillbuf |
3147 | ja .nofillbuf |
3130 | 3148 | ||
3131 | ; +4: word: position of the window of thread in the window stack |
3149 | ; +4: word: position of the window of thread in the window stack |
3132 | mov ax, [WIN_STACK + ecx * 2] |
3150 | mov ax, [WIN_STACK + ecx * 2] |
3133 | mov [ebx+4], ax |
3151 | mov [ebx+4], ax |
3134 | ; +6: word: number of the thread slot, which window has in the window stack |
3152 | ; +6: word: number of the thread slot, which window has in the window stack |
3135 | ; position ecx (has no relation to the specific thread) |
3153 | ; position ecx (has no relation to the specific thread) |
3136 | mov ax, [WIN_POS + ecx * 2] |
3154 | mov ax, [WIN_POS + ecx * 2] |
3137 | mov [ebx+6], ax |
3155 | mov [ebx+6], ax |
3138 | 3156 | ||
3139 | shl ecx, 5 |
3157 | shl ecx, 5 |
3140 | 3158 | ||
3141 | ; +0: dword: memory usage |
3159 | ; +0: dword: memory usage |
3142 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3160 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3143 | mov [ebx], eax |
3161 | mov [ebx], eax |
3144 | ; +10: 11 bytes: name of the process |
3162 | ; +10: 11 bytes: name of the process |
3145 | push ecx |
3163 | push ecx |
3146 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3164 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3147 | add ebx, 10 |
3165 | add ebx, 10 |
3148 | mov ecx, 11 |
3166 | mov ecx, 11 |
3149 | call memmove |
3167 | call memmove |
3150 | pop ecx |
3168 | pop ecx |
3151 | 3169 | ||
3152 | ; +22: address of the process in memory |
3170 | ; +22: address of the process in memory |
3153 | ; +26: size of used memory - 1 |
3171 | ; +26: size of used memory - 1 |
3154 | push edi |
3172 | push edi |
3155 | lea edi, [ebx+12] |
3173 | lea edi, [ebx+12] |
3156 | xor eax, eax |
3174 | xor eax, eax |
3157 | mov edx, 0x100000*16 |
3175 | mov edx, 0x100000*16 |
3158 | cmp ecx, 1 shl 5 |
3176 | cmp ecx, 1 shl 5 |
3159 | je .os_mem |
3177 | je .os_mem |
3160 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3178 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3161 | mov edx, [edx+PROC.mem_used] |
3179 | mov edx, [edx+PROC.mem_used] |
3162 | mov eax, std_application_base_address |
3180 | mov eax, std_application_base_address |
3163 | .os_mem: |
3181 | .os_mem: |
3164 | stosd |
3182 | stosd |
3165 | lea eax, [edx-1] |
3183 | lea eax, [edx-1] |
3166 | stosd |
3184 | stosd |
3167 | 3185 | ||
3168 | ; +30: PID/TID |
3186 | ; +30: PID/TID |
3169 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3187 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3170 | stosd |
3188 | stosd |
3171 | 3189 | ||
3172 | ; window position and size |
3190 | ; window position and size |
3173 | push esi |
3191 | push esi |
3174 | lea esi, [ecx + window_data + WDATA.box] |
3192 | lea esi, [ecx + window_data + WDATA.box] |
3175 | movsd |
3193 | movsd |
3176 | movsd |
3194 | movsd |
3177 | movsd |
3195 | movsd |
3178 | movsd |
3196 | movsd |
3179 | 3197 | ||
3180 | ; Process state (+50) |
3198 | ; Process state (+50) |
3181 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3199 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3182 | stosd |
3200 | stosd |
3183 | 3201 | ||
3184 | ; Window client area box |
3202 | ; Window client area box |
3185 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3203 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3186 | movsd |
3204 | movsd |
3187 | movsd |
3205 | movsd |
3188 | movsd |
3206 | movsd |
3189 | movsd |
3207 | movsd |
3190 | 3208 | ||
3191 | ; Window state |
3209 | ; Window state |
3192 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3210 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3193 | stosb |
3211 | stosb |
3194 | 3212 | ||
3195 | ; Event mask (+71) |
3213 | ; Event mask (+71) |
3196 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3214 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3197 | stosd |
3215 | stosd |
3198 | 3216 | ||
3199 | ; Keyboard mode (+75) |
3217 | ; Keyboard mode (+75) |
3200 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3218 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3201 | stosb |
3219 | stosb |
3202 | 3220 | ||
3203 | pop esi |
3221 | pop esi |
3204 | pop edi |
3222 | pop edi |
3205 | 3223 | ||
3206 | .nofillbuf: |
3224 | .nofillbuf: |
3207 | ; return number of processes |
3225 | ; return number of processes |
3208 | 3226 | ||
3209 | mov eax, [TASK_COUNT] |
3227 | mov eax, [TASK_COUNT] |
3210 | mov [esp+32], eax |
3228 | mov [esp+32], eax |
3211 | ret |
3229 | ret |
3212 | 3230 | ||
3213 | align 4 |
3231 | align 4 |
3214 | sys_clock: |
3232 | sys_clock: |
3215 | cli |
3233 | cli |
3216 | ; Mikhail Lisovin xx Jan 2005 |
3234 | ; Mikhail Lisovin xx Jan 2005 |
3217 | @@: |
3235 | @@: |
3218 | mov al, 10 |
3236 | mov al, 10 |
3219 | out 0x70, al |
3237 | out 0x70, al |
3220 | in al, 0x71 |
3238 | in al, 0x71 |
3221 | test al, al |
3239 | test al, al |
3222 | jns @f |
3240 | jns @f |
3223 | mov esi, 1 |
3241 | mov esi, 1 |
3224 | call delay_ms |
3242 | call delay_ms |
3225 | jmp @b |
3243 | jmp @b |
3226 | @@: |
3244 | @@: |
3227 | ; end Lisovin's fix |
3245 | ; end Lisovin's fix |
3228 | 3246 | ||
3229 | xor al, al ; seconds |
3247 | xor al, al ; seconds |
3230 | out 0x70, al |
3248 | out 0x70, al |
3231 | in al, 0x71 |
3249 | in al, 0x71 |
3232 | movzx ecx, al |
3250 | movzx ecx, al |
3233 | mov al, 02 ; minutes |
3251 | mov al, 02 ; minutes |
3234 | shl ecx, 16 |
3252 | shl ecx, 16 |
3235 | out 0x70, al |
3253 | out 0x70, al |
3236 | in al, 0x71 |
3254 | in al, 0x71 |
3237 | movzx edx, al |
3255 | movzx edx, al |
3238 | mov al, 04 ; hours |
3256 | mov al, 04 ; hours |
3239 | shl edx, 8 |
3257 | shl edx, 8 |
3240 | out 0x70, al |
3258 | out 0x70, al |
3241 | in al, 0x71 |
3259 | in al, 0x71 |
3242 | add ecx, edx |
3260 | add ecx, edx |
3243 | movzx edx, al |
3261 | movzx edx, al |
3244 | add ecx, edx |
3262 | add ecx, edx |
3245 | sti |
3263 | sti |
3246 | mov [esp + 32], ecx |
3264 | mov [esp + 32], ecx |
3247 | ret |
3265 | ret |
3248 | 3266 | ||
3249 | 3267 | ||
3250 | align 4 |
3268 | align 4 |
3251 | 3269 | ||
3252 | sys_date: |
3270 | sys_date: |
3253 | 3271 | ||
3254 | cli |
3272 | cli |
3255 | @@: |
3273 | @@: |
3256 | mov al, 10 |
3274 | mov al, 10 |
3257 | out 0x70, al |
3275 | out 0x70, al |
3258 | in al, 0x71 |
3276 | in al, 0x71 |
3259 | test al, al |
3277 | test al, al |
3260 | jns @f |
3278 | jns @f |
3261 | mov esi, 1 |
3279 | mov esi, 1 |
3262 | call delay_ms |
3280 | call delay_ms |
3263 | jmp @b |
3281 | jmp @b |
3264 | @@: |
3282 | @@: |
3265 | 3283 | ||
3266 | mov ch, 0 |
3284 | mov ch, 0 |
3267 | mov al, 7 ; date |
3285 | mov al, 7 ; date |
3268 | out 0x70, al |
3286 | out 0x70, al |
3269 | in al, 0x71 |
3287 | in al, 0x71 |
3270 | mov cl, al |
3288 | mov cl, al |
3271 | mov al, 8 ; month |
3289 | mov al, 8 ; month |
3272 | shl ecx, 16 |
3290 | shl ecx, 16 |
3273 | out 0x70, al |
3291 | out 0x70, al |
3274 | in al, 0x71 |
3292 | in al, 0x71 |
3275 | mov ch, al |
3293 | mov ch, al |
3276 | mov al, 9 ; year |
3294 | mov al, 9 ; year |
3277 | out 0x70, al |
3295 | out 0x70, al |
3278 | in al, 0x71 |
3296 | in al, 0x71 |
3279 | mov cl, al |
3297 | mov cl, al |
3280 | sti |
3298 | sti |
3281 | mov [esp+32], ecx |
3299 | mov [esp+32], ecx |
3282 | ret |
3300 | ret |
3283 | 3301 | ||
3284 | 3302 | ||
3285 | ; redraw status |
3303 | ; redraw status |
3286 | 3304 | ||
3287 | sys_redrawstat: |
3305 | sys_redrawstat: |
3288 | cmp ebx, 1 |
3306 | cmp ebx, 1 |
3289 | jne no_widgets_away |
3307 | jne no_widgets_away |
3290 | ; buttons away |
3308 | ; buttons away |
3291 | mov ecx, [CURRENT_TASK] |
3309 | mov ecx, [CURRENT_TASK] |
3292 | sys_newba2: |
3310 | sys_newba2: |
3293 | mov edi, [BTN_ADDR] |
3311 | mov edi, [BTN_ADDR] |
3294 | cmp [edi], dword 0 ; empty button list ? |
3312 | cmp [edi], dword 0 ; empty button list ? |
3295 | je end_of_buttons_away |
3313 | je end_of_buttons_away |
3296 | movzx ebx, word [edi] |
3314 | movzx ebx, word [edi] |
3297 | inc ebx |
3315 | inc ebx |
3298 | mov eax, edi |
3316 | mov eax, edi |
3299 | sys_newba: |
3317 | sys_newba: |
3300 | dec ebx |
3318 | dec ebx |
3301 | jz end_of_buttons_away |
3319 | jz end_of_buttons_away |
3302 | 3320 | ||
3303 | add eax, 0x10 |
3321 | add eax, 0x10 |
3304 | cmp cx, [eax] |
3322 | cmp cx, [eax] |
3305 | jnz sys_newba |
3323 | jnz sys_newba |
3306 | 3324 | ||
3307 | push eax ebx ecx |
3325 | push eax ebx ecx |
3308 | mov ecx, ebx |
3326 | mov ecx, ebx |
3309 | inc ecx |
3327 | inc ecx |
3310 | shl ecx, 4 |
3328 | shl ecx, 4 |
3311 | mov ebx, eax |
3329 | mov ebx, eax |
3312 | add eax, 0x10 |
3330 | add eax, 0x10 |
3313 | call memmove |
3331 | call memmove |
3314 | dec dword [edi] |
3332 | dec dword [edi] |
3315 | pop ecx ebx eax |
3333 | pop ecx ebx eax |
3316 | 3334 | ||
3317 | jmp sys_newba2 |
3335 | jmp sys_newba2 |
3318 | 3336 | ||
3319 | end_of_buttons_away: |
3337 | end_of_buttons_away: |
3320 | 3338 | ||
3321 | ret |
3339 | ret |
3322 | 3340 | ||
3323 | no_widgets_away: |
3341 | no_widgets_away: |
3324 | 3342 | ||
3325 | cmp ebx, 2 |
3343 | cmp ebx, 2 |
3326 | jnz srl1 |
3344 | jnz srl1 |
3327 | 3345 | ||
3328 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3346 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3329 | add edx, draw_data - CURRENT_TASK |
3347 | add edx, draw_data - CURRENT_TASK |
3330 | mov [edx + RECT.left], 0 |
3348 | mov [edx + RECT.left], 0 |
3331 | mov [edx + RECT.top], 0 |
3349 | mov [edx + RECT.top], 0 |
3332 | mov eax, [_display.width] |
3350 | mov eax, [_display.width] |
3333 | dec eax |
3351 | dec eax |
3334 | mov [edx + RECT.right], eax |
3352 | mov [edx + RECT.right], eax |
3335 | mov eax, [_display.height] |
3353 | mov eax, [_display.height] |
3336 | dec eax |
3354 | dec eax |
3337 | mov [edx + RECT.bottom], eax |
3355 | mov [edx + RECT.bottom], eax |
3338 | 3356 | ||
3339 | srl1: |
3357 | srl1: |
3340 | ret |
3358 | ret |
3341 | 3359 | ||
3342 | ;ok - 100% work |
3360 | ;ok - 100% work |
3343 | ;nt - not tested |
3361 | ;nt - not tested |
3344 | ;--------------------------------------------------------------------------------------------- |
3362 | ;--------------------------------------------------------------------------------------------- |
3345 | ;eax |
3363 | ;eax |
3346 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3364 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3347 | ;1 - change task. Ret nothing. Block. ok. |
3365 | ;1 - change task. Ret nothing. Block. ok. |
3348 | ;2 - performance control |
3366 | ;2 - performance control |
3349 | ; ebx |
3367 | ; ebx |
3350 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3368 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3351 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3369 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3352 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3370 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3353 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3371 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3354 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3372 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3355 | ;eax |
3373 | ;eax |
3356 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3374 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3357 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3375 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3358 | ;--------------------------------------------------------------------------------------------- |
3376 | ;--------------------------------------------------------------------------------------------- |
3359 | iglobal |
3377 | iglobal |
3360 | align 4 |
3378 | align 4 |
3361 | sheduler: |
3379 | sheduler: |
3362 | dd sys_sheduler.00 |
3380 | dd sys_sheduler.00 |
3363 | dd change_task |
3381 | dd change_task |
3364 | dd sys_sheduler.02 |
3382 | dd sys_sheduler.02 |
3365 | dd sys_sheduler.03 |
3383 | dd sys_sheduler.03 |
3366 | dd sys_sheduler.04 |
3384 | dd sys_sheduler.04 |
3367 | endg |
3385 | endg |
3368 | sys_sheduler: |
3386 | sys_sheduler: |
3369 | ;rewritten by |
3387 | ;rewritten by |
3370 | jmp dword [sheduler+ebx*4] |
3388 | jmp dword [sheduler+ebx*4] |
3371 | ;.shed_counter: |
3389 | ;.shed_counter: |
3372 | .00: |
3390 | .00: |
3373 | mov eax, [context_counter] |
3391 | mov eax, [context_counter] |
3374 | mov [esp+32], eax |
3392 | mov [esp+32], eax |
3375 | ret |
3393 | ret |
3376 | 3394 | ||
3377 | .02: |
3395 | .02: |
3378 | ;.perf_control: |
3396 | ;.perf_control: |
3379 | inc ebx ;before ebx=2, ebx=3 |
3397 | inc ebx ;before ebx=2, ebx=3 |
3380 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3398 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3381 | jz cache_disable |
3399 | jz cache_disable |
3382 | 3400 | ||
3383 | dec ebx ;ebx=2 |
3401 | dec ebx ;ebx=2 |
3384 | cmp ebx, ecx ; |
3402 | cmp ebx, ecx ; |
3385 | jz cache_enable ;if ecx=2 and ebx=2 |
3403 | jz cache_enable ;if ecx=2 and ebx=2 |
3386 | 3404 | ||
3387 | dec ebx ;ebx=1 |
3405 | dec ebx ;ebx=1 |
3388 | cmp ebx, ecx |
3406 | cmp ebx, ecx |
3389 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3407 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3390 | 3408 | ||
3391 | dec ebx |
3409 | dec ebx |
3392 | test ebx, ecx ;ebx=0 and ecx=0 |
3410 | test ebx, ecx ;ebx=0 and ecx=0 |
3393 | jz modify_pce ;if ecx=0 |
3411 | jz modify_pce ;if ecx=0 |
3394 | 3412 | ||
3395 | ret |
3413 | ret |
3396 | 3414 | ||
3397 | .03: |
3415 | .03: |
3398 | ;.rdmsr_instr: |
3416 | ;.rdmsr_instr: |
3399 | ;now counter in ecx |
3417 | ;now counter in ecx |
3400 | ;(edx:eax) esi:edi => edx:esi |
3418 | ;(edx:eax) esi:edi => edx:esi |
3401 | mov eax, esi |
3419 | mov eax, esi |
3402 | mov ecx, edx |
3420 | mov ecx, edx |
3403 | rdmsr |
3421 | rdmsr |
3404 | mov [esp+32], eax |
3422 | mov [esp+32], eax |
3405 | mov [esp+20], edx ;ret in ebx? |
3423 | mov [esp+20], edx ;ret in ebx? |
3406 | ret |
3424 | ret |
3407 | 3425 | ||
3408 | .04: |
3426 | .04: |
3409 | ;.wrmsr_instr: |
3427 | ;.wrmsr_instr: |
3410 | ;now counter in ecx |
3428 | ;now counter in ecx |
3411 | ;(edx:eax) esi:edi => edx:esi |
3429 | ;(edx:eax) esi:edi => edx:esi |
3412 | ; Fast Call MSR can't be destroy |
3430 | ; Fast Call MSR can't be destroy |
3413 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3431 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3414 | ; включаются/выключаются расширенные возможности |
3432 | ; включаются/выключаются расширенные возможности |
3415 | cmp edx, MSR_SYSENTER_CS |
3433 | cmp edx, MSR_SYSENTER_CS |
3416 | je @f |
3434 | je @f |
3417 | cmp edx, MSR_SYSENTER_ESP |
3435 | cmp edx, MSR_SYSENTER_ESP |
3418 | je @f |
3436 | je @f |
3419 | cmp edx, MSR_SYSENTER_EIP |
3437 | cmp edx, MSR_SYSENTER_EIP |
3420 | je @f |
3438 | je @f |
3421 | cmp edx, MSR_AMD_STAR |
3439 | cmp edx, MSR_AMD_STAR |
3422 | je @f |
3440 | je @f |
3423 | 3441 | ||
3424 | mov eax, esi |
3442 | mov eax, esi |
3425 | mov ecx, edx |
3443 | mov ecx, edx |
3426 | wrmsr |
3444 | wrmsr |
3427 | ; mov [esp + 32], eax |
3445 | ; mov [esp + 32], eax |
3428 | ; mov [esp + 20], edx ;ret in ebx? |
3446 | ; mov [esp + 20], edx ;ret in ebx? |
3429 | @@: |
3447 | @@: |
3430 | ret |
3448 | ret |
3431 | 3449 | ||
3432 | cache_disable: |
3450 | cache_disable: |
3433 | mov eax, cr0 |
3451 | mov eax, cr0 |
3434 | or eax, 01100000000000000000000000000000b |
3452 | or eax, 01100000000000000000000000000000b |
3435 | mov cr0, eax |
3453 | mov cr0, eax |
3436 | wbinvd ;set MESI |
3454 | wbinvd ;set MESI |
3437 | ret |
3455 | ret |
3438 | 3456 | ||
3439 | cache_enable: |
3457 | cache_enable: |
3440 | mov eax, cr0 |
3458 | mov eax, cr0 |
3441 | and eax, 10011111111111111111111111111111b |
3459 | and eax, 10011111111111111111111111111111b |
3442 | mov cr0, eax |
3460 | mov cr0, eax |
3443 | ret |
3461 | ret |
3444 | 3462 | ||
3445 | is_cache_enabled: |
3463 | is_cache_enabled: |
3446 | mov eax, cr0 |
3464 | mov eax, cr0 |
3447 | mov ebx, eax |
3465 | mov ebx, eax |
3448 | and eax, 01100000000000000000000000000000b |
3466 | and eax, 01100000000000000000000000000000b |
3449 | jz cache_disabled |
3467 | jz cache_disabled |
3450 | mov [esp+32], ebx |
3468 | mov [esp+32], ebx |
3451 | cache_disabled: |
3469 | cache_disabled: |
3452 | mov dword [esp+32], eax;0 |
3470 | mov dword [esp+32], eax;0 |
3453 | ret |
3471 | ret |
3454 | 3472 | ||
3455 | modify_pce: |
3473 | modify_pce: |
3456 | mov eax, cr4 |
3474 | mov eax, cr4 |
3457 | ; mov ebx,0 |
3475 | ; mov ebx,0 |
3458 | ; or bx,100000000b ;pce |
3476 | ; or bx,100000000b ;pce |
3459 | ; xor eax,ebx ;invert pce |
3477 | ; xor eax,ebx ;invert pce |
3460 | bts eax, 8;pce=cr4[8] |
3478 | bts eax, 8;pce=cr4[8] |
3461 | mov cr4, eax |
3479 | mov cr4, eax |
3462 | mov [esp+32], eax |
3480 | mov [esp+32], eax |
3463 | ret |
3481 | ret |
3464 | ;--------------------------------------------------------------------------------------------- |
3482 | ;--------------------------------------------------------------------------------------------- |
3465 | 3483 | ||
3466 | 3484 | ||
3467 | iglobal |
3485 | iglobal |
3468 | cpustring db 'CPU',0 |
3486 | cpustring db 'CPU',0 |
3469 | endg |
3487 | endg |
3470 | 3488 | ||
3471 | uglobal |
3489 | uglobal |
3472 | background_defined db 0 ; diamond, 11.04.2006 |
3490 | background_defined db 0 ; diamond, 11.04.2006 |
3473 | endg |
3491 | endg |
3474 | ;----------------------------------------------------------------------------- |
3492 | ;----------------------------------------------------------------------------- |
3475 | align 4 |
3493 | align 4 |
3476 | checkmisc: |
3494 | checkmisc: |
3477 | cmp [ctrl_alt_del], 1 |
3495 | cmp [ctrl_alt_del], 1 |
3478 | jne nocpustart |
3496 | jne nocpustart |
3479 | 3497 | ||
3480 | mov ebp, cpustring |
3498 | mov ebp, cpustring |
3481 | call fs_execute_from_sysdir |
3499 | call fs_execute_from_sysdir |
3482 | 3500 | ||
3483 | mov [ctrl_alt_del], 0 |
3501 | mov [ctrl_alt_del], 0 |
3484 | ;-------------------------------------- |
3502 | ;-------------------------------------- |
3485 | align 4 |
3503 | align 4 |
3486 | nocpustart: |
3504 | nocpustart: |
3487 | cmp [mouse_active], 1 |
3505 | cmp [mouse_active], 1 |
3488 | jne mouse_not_active |
3506 | jne mouse_not_active |
3489 | mov [mouse_active], 0 |
3507 | mov [mouse_active], 0 |
3490 | 3508 | ||
3491 | xor edi, edi |
3509 | xor edi, edi |
3492 | mov ebx, CURRENT_TASK |
3510 | mov ebx, CURRENT_TASK |
3493 | 3511 | ||
3494 | mov ecx, [TASK_COUNT] |
3512 | mov ecx, [TASK_COUNT] |
3495 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3513 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3496 | shl eax, 8 |
3514 | shl eax, 8 |
3497 | push eax |
3515 | push eax |
3498 | 3516 | ||
3499 | movzx eax, word [MOUSE_X] |
3517 | movzx eax, word [MOUSE_X] |
3500 | movzx edx, word [MOUSE_Y] |
3518 | movzx edx, word [MOUSE_Y] |
3501 | ;-------------------------------------- |
3519 | ;-------------------------------------- |
3502 | align 4 |
3520 | align 4 |
3503 | .set_mouse_event: |
3521 | .set_mouse_event: |
3504 | add edi, 256 |
3522 | add edi, 256 |
3505 | add ebx, 32 |
3523 | add ebx, 32 |
3506 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3524 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3507 | jz .pos_filter |
3525 | jz .pos_filter |
3508 | 3526 | ||
3509 | cmp edi, [esp] ; skip if filtration active |
3527 | cmp edi, [esp] ; skip if filtration active |
3510 | jne .skip |
3528 | jne .skip |
3511 | ;-------------------------------------- |
3529 | ;-------------------------------------- |
3512 | align 4 |
3530 | align 4 |
3513 | .pos_filter: |
3531 | .pos_filter: |
3514 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3532 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3515 | jz .set |
3533 | jz .set |
3516 | 3534 | ||
3517 | mov esi, [ebx-twdw+WDATA.box.left] |
3535 | mov esi, [ebx-twdw+WDATA.box.left] |
3518 | cmp eax, esi |
3536 | cmp eax, esi |
3519 | jb .skip |
3537 | jb .skip |
3520 | add esi, [ebx-twdw+WDATA.box.width] |
3538 | add esi, [ebx-twdw+WDATA.box.width] |
3521 | cmp eax, esi |
3539 | cmp eax, esi |
3522 | ja .skip |
3540 | ja .skip |
3523 | 3541 | ||
3524 | mov esi, [ebx-twdw+WDATA.box.top] |
3542 | mov esi, [ebx-twdw+WDATA.box.top] |
3525 | cmp edx, esi |
3543 | cmp edx, esi |
3526 | jb .skip |
3544 | jb .skip |
3527 | add esi, [ebx-twdw+WDATA.box.height] |
3545 | add esi, [ebx-twdw+WDATA.box.height] |
3528 | cmp edx, esi |
3546 | cmp edx, esi |
3529 | ja .skip |
3547 | ja .skip |
3530 | ;-------------------------------------- |
3548 | ;-------------------------------------- |
3531 | align 4 |
3549 | align 4 |
3532 | .set: |
3550 | .set: |
3533 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3551 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3534 | ;-------------------------------------- |
3552 | ;-------------------------------------- |
3535 | align 4 |
3553 | align 4 |
3536 | .skip: |
3554 | .skip: |
3537 | loop .set_mouse_event |
3555 | loop .set_mouse_event |
3538 | 3556 | ||
3539 | pop eax |
3557 | pop eax |
3540 | ;-------------------------------------- |
3558 | ;-------------------------------------- |
3541 | align 4 |
3559 | align 4 |
3542 | mouse_not_active: |
3560 | mouse_not_active: |
3543 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3561 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3544 | jz nobackgr |
3562 | jz nobackgr |
3545 | 3563 | ||
3546 | cmp [background_defined], 0 |
3564 | cmp [background_defined], 0 |
3547 | jz nobackgr |
3565 | jz nobackgr |
3548 | ;-------------------------------------- |
3566 | ;-------------------------------------- |
3549 | align 4 |
3567 | align 4 |
3550 | backgr: |
3568 | backgr: |
3551 | mov eax, [draw_data+32 + RECT.left] |
3569 | mov eax, [draw_data+32 + RECT.left] |
3552 | shl eax, 16 |
3570 | shl eax, 16 |
3553 | add eax, [draw_data+32 + RECT.right] |
3571 | add eax, [draw_data+32 + RECT.right] |
3554 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3572 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3555 | 3573 | ||
3556 | mov eax, [draw_data+32 + RECT.top] |
3574 | mov eax, [draw_data+32 + RECT.top] |
3557 | shl eax, 16 |
3575 | shl eax, 16 |
3558 | add eax, [draw_data+32 + RECT.bottom] |
3576 | add eax, [draw_data+32 + RECT.bottom] |
3559 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3577 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3560 | 3578 | ||
3561 | call drawbackground |
3579 | call drawbackground |
3562 | ; DEBUGF 1, "K : drawbackground\n" |
3580 | ; DEBUGF 1, "K : drawbackground\n" |
3563 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3581 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3564 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3582 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3565 | ;--------- set event 5 start ---------- |
3583 | ;--------- set event 5 start ---------- |
3566 | push ecx edi |
3584 | push ecx edi |
3567 | xor edi, edi |
3585 | xor edi, edi |
3568 | mov ecx, [TASK_COUNT] |
3586 | mov ecx, [TASK_COUNT] |
3569 | ;-------------------------------------- |
3587 | ;-------------------------------------- |
3570 | align 4 |
3588 | align 4 |
3571 | set_bgr_event: |
3589 | set_bgr_event: |
3572 | add edi, 256 |
3590 | add edi, 256 |
3573 | mov eax, [BG_Rect_X_left_right] |
3591 | mov eax, [BG_Rect_X_left_right] |
3574 | mov edx, [BG_Rect_Y_top_bottom] |
3592 | mov edx, [BG_Rect_Y_top_bottom] |
3575 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3593 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3576 | jz .set |
3594 | jz .set |
3577 | .join: |
3595 | .join: |
3578 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3596 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3579 | jae @f |
3597 | jae @f |
3580 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3598 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3581 | @@: |
3599 | @@: |
3582 | shr eax, 16 |
3600 | shr eax, 16 |
3583 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3601 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3584 | jbe @f |
3602 | jbe @f |
3585 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3603 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3586 | @@: |
3604 | @@: |
3587 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3605 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3588 | jae @f |
3606 | jae @f |
3589 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3607 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3590 | @@: |
3608 | @@: |
3591 | shr edx, 16 |
3609 | shr edx, 16 |
3592 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3610 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3593 | jbe @f |
3611 | jbe @f |
3594 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3612 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3595 | @@: |
3613 | @@: |
3596 | jmp .common |
3614 | jmp .common |
3597 | .set: |
3615 | .set: |
3598 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3616 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3599 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3617 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3600 | .common: |
3618 | .common: |
3601 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3619 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3602 | loop set_bgr_event |
3620 | loop set_bgr_event |
3603 | pop edi ecx |
3621 | pop edi ecx |
3604 | ;--------- set event 5 stop ----------- |
3622 | ;--------- set event 5 stop ----------- |
3605 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3623 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3606 | jnz backgr |
3624 | jnz backgr |
3607 | 3625 | ||
3608 | xor eax, eax |
3626 | xor eax, eax |
3609 | mov [draw_data+32 + RECT.left], eax |
3627 | mov [draw_data+32 + RECT.left], eax |
3610 | mov [draw_data+32 + RECT.top], eax |
3628 | mov [draw_data+32 + RECT.top], eax |
3611 | mov [draw_data+32 + RECT.right], eax |
3629 | mov [draw_data+32 + RECT.right], eax |
3612 | mov [draw_data+32 + RECT.bottom], eax |
3630 | mov [draw_data+32 + RECT.bottom], eax |
3613 | ;-------------------------------------- |
3631 | ;-------------------------------------- |
3614 | align 4 |
3632 | align 4 |
3615 | nobackgr: |
3633 | nobackgr: |
3616 | ; system shutdown request |
3634 | ; system shutdown request |
3617 | cmp [SYS_SHUTDOWN], byte 0 |
3635 | cmp [SYS_SHUTDOWN], byte 0 |
3618 | je noshutdown |
3636 | je noshutdown |
3619 | 3637 | ||
3620 | mov edx, [shutdown_processes] |
3638 | mov edx, [shutdown_processes] |
3621 | 3639 | ||
3622 | cmp [SYS_SHUTDOWN], dl |
3640 | cmp [SYS_SHUTDOWN], dl |
3623 | jne noshutdown |
3641 | jne noshutdown |
3624 | 3642 | ||
3625 | lea ecx, [edx-1] |
3643 | lea ecx, [edx-1] |
3626 | mov edx, OS_BASE+0x3040 |
3644 | mov edx, OS_BASE+0x3040 |
3627 | jecxz no_mark_system_shutdown |
3645 | jecxz no_mark_system_shutdown |
3628 | ;-------------------------------------- |
3646 | ;-------------------------------------- |
3629 | align 4 |
3647 | align 4 |
3630 | markz: |
3648 | markz: |
3631 | push ecx edx |
3649 | push ecx edx |
3632 | cmp [edx+TASKDATA.state], 9 |
3650 | cmp [edx+TASKDATA.state], 9 |
3633 | jz .nokill |
3651 | jz .nokill |
3634 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3652 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3635 | cmp [edx+APPDATA.process], sys_proc |
3653 | cmp [edx+APPDATA.process], sys_proc |
3636 | jz .nokill |
3654 | jz .nokill |
3637 | call request_terminate |
3655 | call request_terminate |
3638 | jmp .common |
3656 | jmp .common |
3639 | .nokill: |
3657 | .nokill: |
3640 | dec byte [SYS_SHUTDOWN] |
3658 | dec byte [SYS_SHUTDOWN] |
3641 | xor eax, eax |
3659 | xor eax, eax |
3642 | .common: |
3660 | .common: |
3643 | pop edx ecx |
3661 | pop edx ecx |
3644 | test eax, eax |
3662 | test eax, eax |
3645 | jz @f |
3663 | jz @f |
3646 | mov [edx+TASKDATA.state], byte 3 |
3664 | mov [edx+TASKDATA.state], byte 3 |
3647 | @@: |
3665 | @@: |
3648 | add edx, 0x20 |
3666 | add edx, 0x20 |
3649 | loop markz |
3667 | loop markz |
3650 | call wakeup_osloop |
3668 | call wakeup_osloop |
3651 | ;-------------------------------------- |
3669 | ;-------------------------------------- |
3652 | align 4 |
3670 | align 4 |
3653 | @@: |
3671 | @@: |
3654 | no_mark_system_shutdown: |
3672 | no_mark_system_shutdown: |
3655 | dec byte [SYS_SHUTDOWN] |
3673 | dec byte [SYS_SHUTDOWN] |
3656 | je system_shutdown |
3674 | je system_shutdown |
3657 | ;-------------------------------------- |
3675 | ;-------------------------------------- |
3658 | align 4 |
3676 | align 4 |
3659 | noshutdown: |
3677 | noshutdown: |
3660 | mov eax, [TASK_COUNT] ; termination |
3678 | mov eax, [TASK_COUNT] ; termination |
3661 | mov ebx, TASK_DATA+TASKDATA.state |
3679 | mov ebx, TASK_DATA+TASKDATA.state |
3662 | mov esi, 1 |
3680 | mov esi, 1 |
3663 | ;-------------------------------------- |
3681 | ;-------------------------------------- |
3664 | align 4 |
3682 | align 4 |
3665 | newct: |
3683 | newct: |
3666 | mov cl, [ebx] |
3684 | mov cl, [ebx] |
3667 | cmp cl, byte 3 |
3685 | cmp cl, byte 3 |
3668 | jz .terminate |
3686 | jz .terminate |
3669 | 3687 | ||
3670 | cmp cl, byte 4 |
3688 | cmp cl, byte 4 |
3671 | jnz .noterminate |
3689 | jnz .noterminate |
3672 | .terminate: |
3690 | .terminate: |
3673 | pushad |
3691 | pushad |
3674 | mov ecx, eax |
3692 | mov ecx, eax |
3675 | shl ecx, 8 |
3693 | shl ecx, 8 |
3676 | add ecx, SLOT_BASE |
3694 | add ecx, SLOT_BASE |
3677 | call restore_default_cursor_before_killing |
3695 | call restore_default_cursor_before_killing |
3678 | popad |
3696 | popad |
3679 | 3697 | ||
3680 | pushad |
3698 | pushad |
3681 | call terminate |
3699 | call terminate |
3682 | popad |
3700 | popad |
3683 | cmp byte [SYS_SHUTDOWN], 0 |
3701 | cmp byte [SYS_SHUTDOWN], 0 |
3684 | jz .noterminate |
3702 | jz .noterminate |
3685 | dec byte [SYS_SHUTDOWN] |
3703 | dec byte [SYS_SHUTDOWN] |
3686 | je system_shutdown |
3704 | je system_shutdown |
3687 | 3705 | ||
3688 | .noterminate: |
3706 | .noterminate: |
3689 | add ebx, 0x20 |
3707 | add ebx, 0x20 |
3690 | inc esi |
3708 | inc esi |
3691 | dec eax |
3709 | dec eax |
3692 | jnz newct |
3710 | jnz newct |
3693 | ret |
3711 | ret |
3694 | ;----------------------------------------------------------------------------- |
3712 | ;----------------------------------------------------------------------------- |
3695 | align 4 |
3713 | align 4 |
3696 | redrawscreen: |
3714 | redrawscreen: |
3697 | ; eax , if process window_data base is eax, do not set flag/limits |
3715 | ; eax , if process window_data base is eax, do not set flag/limits |
3698 | 3716 | ||
3699 | pushad |
3717 | pushad |
3700 | push eax |
3718 | push eax |
3701 | 3719 | ||
3702 | ;;; mov ebx,2 |
3720 | ;;; mov ebx,2 |
3703 | ;;; call delay_hs |
3721 | ;;; call delay_hs |
3704 | 3722 | ||
3705 | ;mov ecx,0 ; redraw flags for apps |
3723 | ;mov ecx,0 ; redraw flags for apps |
3706 | xor ecx, ecx |
3724 | xor ecx, ecx |
3707 | ;-------------------------------------- |
3725 | ;-------------------------------------- |
3708 | align 4 |
3726 | align 4 |
3709 | newdw2: |
3727 | newdw2: |
3710 | inc ecx |
3728 | inc ecx |
3711 | push ecx |
3729 | push ecx |
3712 | 3730 | ||
3713 | mov eax, ecx |
3731 | mov eax, ecx |
3714 | shl eax, 5 |
3732 | shl eax, 5 |
3715 | add eax, window_data |
3733 | add eax, window_data |
3716 | 3734 | ||
3717 | cmp eax, [esp+4] |
3735 | cmp eax, [esp+4] |
3718 | je not_this_task |
3736 | je not_this_task |
3719 | ; check if window in redraw area |
3737 | ; check if window in redraw area |
3720 | mov edi, eax |
3738 | mov edi, eax |
3721 | 3739 | ||
3722 | cmp ecx, 1 ; limit for background |
3740 | cmp ecx, 1 ; limit for background |
3723 | jz bgli |
3741 | jz bgli |
3724 | 3742 | ||
3725 | mov eax, [edi + WDATA.box.left] |
3743 | mov eax, [edi + WDATA.box.left] |
3726 | mov ebx, [edi + WDATA.box.top] |
3744 | mov ebx, [edi + WDATA.box.top] |
3727 | 3745 | ||
3728 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3746 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3729 | cmp ecx, ebx |
3747 | cmp ecx, ebx |
3730 | jb ricino |
3748 | jb ricino |
3731 | 3749 | ||
3732 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3750 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3733 | cmp ecx, eax |
3751 | cmp ecx, eax |
3734 | jb ricino |
3752 | jb ricino |
3735 | 3753 | ||
3736 | mov eax, [edi + WDATA.box.left] |
3754 | mov eax, [edi + WDATA.box.left] |
3737 | mov ebx, [edi + WDATA.box.top] |
3755 | mov ebx, [edi + WDATA.box.top] |
3738 | mov ecx, [edi + WDATA.box.width] |
3756 | mov ecx, [edi + WDATA.box.width] |
3739 | mov edx, [edi + WDATA.box.height] |
3757 | mov edx, [edi + WDATA.box.height] |
3740 | add ecx, eax |
3758 | add ecx, eax |
3741 | add edx, ebx |
3759 | add edx, ebx |
3742 | 3760 | ||
3743 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3761 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3744 | cmp edx, eax |
3762 | cmp edx, eax |
3745 | jb ricino |
3763 | jb ricino |
3746 | 3764 | ||
3747 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3765 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3748 | cmp ecx, eax |
3766 | cmp ecx, eax |
3749 | jb ricino |
3767 | jb ricino |
3750 | ;-------------------------------------- |
3768 | ;-------------------------------------- |
3751 | align 4 |
3769 | align 4 |
3752 | bgli: |
3770 | bgli: |
3753 | cmp dword[esp], 1 |
3771 | cmp dword[esp], 1 |
3754 | jnz .az |
3772 | jnz .az |
3755 | 3773 | ||
3756 | cmp byte[REDRAW_BACKGROUND], 0 |
3774 | cmp byte[REDRAW_BACKGROUND], 0 |
3757 | jz .az |
3775 | jz .az |
3758 | 3776 | ||
3759 | mov dl, 0 |
3777 | mov dl, 0 |
3760 | lea eax, [edi+draw_data-window_data] |
3778 | lea eax, [edi+draw_data-window_data] |
3761 | mov ebx, [draw_limits.left] |
3779 | mov ebx, [draw_limits.left] |
3762 | cmp ebx, [eax+RECT.left] |
3780 | cmp ebx, [eax+RECT.left] |
3763 | jae @f |
3781 | jae @f |
3764 | 3782 | ||
3765 | mov [eax+RECT.left], ebx |
3783 | mov [eax+RECT.left], ebx |
3766 | mov dl, 1 |
3784 | mov dl, 1 |
3767 | ;-------------------------------------- |
3785 | ;-------------------------------------- |
3768 | align 4 |
3786 | align 4 |
3769 | @@: |
3787 | @@: |
3770 | mov ebx, [draw_limits.top] |
3788 | mov ebx, [draw_limits.top] |
3771 | cmp ebx, [eax+RECT.top] |
3789 | cmp ebx, [eax+RECT.top] |
3772 | jae @f |
3790 | jae @f |
3773 | 3791 | ||
3774 | mov [eax+RECT.top], ebx |
3792 | mov [eax+RECT.top], ebx |
3775 | mov dl, 1 |
3793 | mov dl, 1 |
3776 | ;-------------------------------------- |
3794 | ;-------------------------------------- |
3777 | align 4 |
3795 | align 4 |
3778 | @@: |
3796 | @@: |
3779 | mov ebx, [draw_limits.right] |
3797 | mov ebx, [draw_limits.right] |
3780 | cmp ebx, [eax+RECT.right] |
3798 | cmp ebx, [eax+RECT.right] |
3781 | jbe @f |
3799 | jbe @f |
3782 | 3800 | ||
3783 | mov [eax+RECT.right], ebx |
3801 | mov [eax+RECT.right], ebx |
3784 | mov dl, 1 |
3802 | mov dl, 1 |
3785 | ;-------------------------------------- |
3803 | ;-------------------------------------- |
3786 | align 4 |
3804 | align 4 |
3787 | @@: |
3805 | @@: |
3788 | mov ebx, [draw_limits.bottom] |
3806 | mov ebx, [draw_limits.bottom] |
3789 | cmp ebx, [eax+RECT.bottom] |
3807 | cmp ebx, [eax+RECT.bottom] |
3790 | jbe @f |
3808 | jbe @f |
3791 | 3809 | ||
3792 | mov [eax+RECT.bottom], ebx |
3810 | mov [eax+RECT.bottom], ebx |
3793 | mov dl, 1 |
3811 | mov dl, 1 |
3794 | ;-------------------------------------- |
3812 | ;-------------------------------------- |
3795 | align 4 |
3813 | align 4 |
3796 | @@: |
3814 | @@: |
3797 | add byte[REDRAW_BACKGROUND], dl |
3815 | add byte[REDRAW_BACKGROUND], dl |
3798 | call wakeup_osloop |
3816 | call wakeup_osloop |
3799 | jmp newdw8 |
3817 | jmp newdw8 |
3800 | ;-------------------------------------- |
3818 | ;-------------------------------------- |
3801 | align 4 |
3819 | align 4 |
3802 | .az: |
3820 | .az: |
3803 | mov eax, edi |
3821 | mov eax, edi |
3804 | add eax, draw_data-window_data |
3822 | add eax, draw_data-window_data |
3805 | 3823 | ||
3806 | mov ebx, [draw_limits.left] ; set limits |
3824 | mov ebx, [draw_limits.left] ; set limits |
3807 | mov [eax + RECT.left], ebx |
3825 | mov [eax + RECT.left], ebx |
3808 | mov ebx, [draw_limits.top] |
3826 | mov ebx, [draw_limits.top] |
3809 | mov [eax + RECT.top], ebx |
3827 | mov [eax + RECT.top], ebx |
3810 | mov ebx, [draw_limits.right] |
3828 | mov ebx, [draw_limits.right] |
3811 | mov [eax + RECT.right], ebx |
3829 | mov [eax + RECT.right], ebx |
3812 | mov ebx, [draw_limits.bottom] |
3830 | mov ebx, [draw_limits.bottom] |
3813 | mov [eax + RECT.bottom], ebx |
3831 | mov [eax + RECT.bottom], ebx |
3814 | 3832 | ||
3815 | sub eax, draw_data-window_data |
3833 | sub eax, draw_data-window_data |
3816 | 3834 | ||
3817 | cmp dword [esp], 1 |
3835 | cmp dword [esp], 1 |
3818 | jne nobgrd |
3836 | jne nobgrd |
3819 | inc byte[REDRAW_BACKGROUND] |
3837 | inc byte[REDRAW_BACKGROUND] |
3820 | call wakeup_osloop |
3838 | call wakeup_osloop |
3821 | ;-------------------------------------- |
3839 | ;-------------------------------------- |
3822 | align 4 |
3840 | align 4 |
3823 | newdw8: |
3841 | newdw8: |
3824 | nobgrd: |
3842 | nobgrd: |
3825 | ;-------------------------------------- |
3843 | ;-------------------------------------- |
3826 | push eax edi ebp |
3844 | push eax edi ebp |
3827 | mov edi, [esp+12] |
3845 | mov edi, [esp+12] |
3828 | cmp edi, 1 |
3846 | cmp edi, 1 |
3829 | je .found |
3847 | je .found |
3830 | 3848 | ||
3831 | mov eax, [draw_limits.left] |
3849 | mov eax, [draw_limits.left] |
3832 | mov ebx, [draw_limits.top] |
3850 | mov ebx, [draw_limits.top] |
3833 | mov ecx, [draw_limits.right] |
3851 | mov ecx, [draw_limits.right] |
3834 | sub ecx, eax |
3852 | sub ecx, eax |
3835 | test ecx, ecx |
3853 | test ecx, ecx |
3836 | jz .not_found |
3854 | jz .not_found |
3837 | 3855 | ||
3838 | mov edx, [draw_limits.bottom] |
3856 | mov edx, [draw_limits.bottom] |
3839 | sub edx, ebx |
3857 | sub edx, ebx |
3840 | test edx, edx |
3858 | test edx, edx |
3841 | jz .not_found |
3859 | jz .not_found |
3842 | 3860 | ||
3843 | ; eax - x, ebx - y |
3861 | ; eax - x, ebx - y |
3844 | ; ecx - size x, edx - size y |
3862 | ; ecx - size x, edx - size y |
3845 | add ebx, edx |
3863 | add ebx, edx |
3846 | ;-------------------------------------- |
3864 | ;-------------------------------------- |
3847 | align 4 |
3865 | align 4 |
3848 | .start_y: |
3866 | .start_y: |
3849 | push ecx |
3867 | push ecx |
3850 | ;-------------------------------------- |
3868 | ;-------------------------------------- |
3851 | align 4 |
3869 | align 4 |
3852 | .start_x: |
3870 | .start_x: |
3853 | add eax, ecx |
3871 | add eax, ecx |
3854 | mov ebp, [d_width_calc_area + ebx*4] |
3872 | mov ebp, [d_width_calc_area + ebx*4] |
3855 | add ebp, [_display.win_map] |
3873 | add ebp, [_display.win_map] |
3856 | movzx ebp, byte[eax+ebp] ; get value for current point |
3874 | movzx ebp, byte[eax+ebp] ; get value for current point |
3857 | cmp ebp, edi |
3875 | cmp ebp, edi |
3858 | jne @f |
3876 | jne @f |
3859 | 3877 | ||
3860 | pop ecx |
3878 | pop ecx |
3861 | jmp .found |
3879 | jmp .found |
3862 | ;-------------------------------------- |
3880 | ;-------------------------------------- |
3863 | align 4 |
3881 | align 4 |
3864 | @@: |
3882 | @@: |
3865 | sub eax, ecx |
3883 | sub eax, ecx |
3866 | 3884 | ||
3867 | dec ecx |
3885 | dec ecx |
3868 | jnz .start_x |
3886 | jnz .start_x |
3869 | 3887 | ||
3870 | pop ecx |
3888 | pop ecx |
3871 | dec ebx |
3889 | dec ebx |
3872 | dec edx |
3890 | dec edx |
3873 | jnz .start_y |
3891 | jnz .start_y |
3874 | ;-------------------------------------- |
3892 | ;-------------------------------------- |
3875 | align 4 |
3893 | align 4 |
3876 | .not_found: |
3894 | .not_found: |
3877 | pop ebp edi eax |
3895 | pop ebp edi eax |
3878 | jmp ricino |
3896 | jmp ricino |
3879 | ;-------------------------------------- |
3897 | ;-------------------------------------- |
3880 | align 4 |
3898 | align 4 |
3881 | .found: |
3899 | .found: |
3882 | pop ebp edi eax |
3900 | pop ebp edi eax |
3883 | 3901 | ||
3884 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3902 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3885 | ;-------------------------------------- |
3903 | ;-------------------------------------- |
3886 | align 4 |
3904 | align 4 |
3887 | ricino: |
3905 | ricino: |
3888 | not_this_task: |
3906 | not_this_task: |
3889 | pop ecx |
3907 | pop ecx |
3890 | 3908 | ||
3891 | cmp ecx, [TASK_COUNT] |
3909 | cmp ecx, [TASK_COUNT] |
3892 | jle newdw2 |
3910 | jle newdw2 |
3893 | 3911 | ||
3894 | pop eax |
3912 | pop eax |
3895 | popad |
3913 | popad |
3896 | ret |
3914 | ret |
3897 | ;----------------------------------------------------------------------------- |
3915 | ;----------------------------------------------------------------------------- |
3898 | align 4 |
3916 | align 4 |
3899 | calculatebackground: ; background |
3917 | calculatebackground: ; background |
3900 | mov edi, [_display.win_map] ; set os to use all pixels |
3918 | mov edi, [_display.win_map] ; set os to use all pixels |
3901 | mov eax, 0x01010101 |
3919 | mov eax, 0x01010101 |
3902 | mov ecx, [_display.win_map_size] |
3920 | mov ecx, [_display.win_map_size] |
3903 | shr ecx, 2 |
3921 | shr ecx, 2 |
3904 | rep stosd |
3922 | rep stosd |
3905 | 3923 | ||
3906 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3924 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3907 | ret |
3925 | ret |
3908 | ;----------------------------------------------------------------------------- |
3926 | ;----------------------------------------------------------------------------- |
3909 | uglobal |
3927 | uglobal |
3910 | imax dd 0x0 |
3928 | imax dd 0x0 |
3911 | endg |
3929 | endg |
3912 | ;----------------------------------------------------------------------------- |
3930 | ;----------------------------------------------------------------------------- |
3913 | align 4 |
3931 | align 4 |
3914 | delay_ms: ; delay in 1/1000 sec |
3932 | delay_ms: ; delay in 1/1000 sec |
3915 | push eax |
3933 | push eax |
3916 | push ecx |
3934 | push ecx |
3917 | 3935 | ||
3918 | mov ecx, esi |
3936 | mov ecx, esi |
3919 | ; |
3937 | ; |
3920 | imul ecx, 33941 |
3938 | imul ecx, 33941 |
3921 | shr ecx, 9 |
3939 | shr ecx, 9 |
3922 | ; |
3940 | ; |
3923 | 3941 | ||
3924 | in al, 0x61 |
3942 | in al, 0x61 |
3925 | and al, 0x10 |
3943 | and al, 0x10 |
3926 | mov ah, al |
3944 | mov ah, al |
3927 | cld |
3945 | cld |
3928 | ;-------------------------------------- |
3946 | ;-------------------------------------- |
3929 | align 4 |
3947 | align 4 |
3930 | cnt1: |
3948 | cnt1: |
3931 | in al, 0x61 |
3949 | in al, 0x61 |
3932 | and al, 0x10 |
3950 | and al, 0x10 |
3933 | cmp al, ah |
3951 | cmp al, ah |
3934 | jz cnt1 |
3952 | jz cnt1 |
3935 | 3953 | ||
3936 | mov ah, al |
3954 | mov ah, al |
3937 | loop cnt1 |
3955 | loop cnt1 |
3938 | 3956 | ||
3939 | pop ecx |
3957 | pop ecx |
3940 | pop eax |
3958 | pop eax |
3941 | ret |
3959 | ret |
3942 | ;----------------------------------------------------------------------------- |
3960 | ;----------------------------------------------------------------------------- |
3943 | align 4 |
3961 | align 4 |
3944 | set_app_param: |
3962 | set_app_param: |
3945 | mov edi, [TASK_BASE] |
3963 | mov edi, [TASK_BASE] |
3946 | mov eax, ebx |
3964 | mov eax, ebx |
3947 | btr eax, 3 ; move MOUSE_FILTRATION |
3965 | btr eax, 3 ; move MOUSE_FILTRATION |
3948 | mov ebx, [current_slot] ; bit into event_filter |
3966 | mov ebx, [current_slot] ; bit into event_filter |
3949 | setc byte [ebx+APPDATA.event_filter] |
3967 | setc byte [ebx+APPDATA.event_filter] |
3950 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3968 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3951 | mov [esp+32], eax ; return old mask value |
3969 | mov [esp+32], eax ; return old mask value |
3952 | ret |
3970 | ret |
3953 | ;----------------------------------------------------------------------------- |
3971 | ;----------------------------------------------------------------------------- |
3954 | 3972 | ||
3955 | ; this is for syscall |
3973 | ; this is for syscall |
3956 | proc delay_hs_unprotected |
3974 | proc delay_hs_unprotected |
3957 | call unprotect_from_terminate |
3975 | call unprotect_from_terminate |
3958 | call delay_hs |
3976 | call delay_hs |
3959 | call protect_from_terminate |
3977 | call protect_from_terminate |
3960 | ret |
3978 | ret |
3961 | endp |
3979 | endp |
3962 | 3980 | ||
3963 | if 1 |
3981 | if 1 |
3964 | align 4 |
3982 | align 4 |
3965 | delay_hs: ; delay in 1/100 secs |
3983 | delay_hs: ; delay in 1/100 secs |
3966 | ; ebx = delay time |
3984 | ; ebx = delay time |
3967 | 3985 | ||
3968 | pushad |
3986 | pushad |
3969 | push ebx |
3987 | push ebx |
3970 | xor esi, esi |
3988 | xor esi, esi |
3971 | mov ecx, MANUAL_DESTROY |
3989 | mov ecx, MANUAL_DESTROY |
3972 | call create_event |
3990 | call create_event |
3973 | test eax, eax |
3991 | test eax, eax |
3974 | jz .done |
3992 | jz .done |
3975 | 3993 | ||
3976 | mov ebx, edx |
3994 | mov ebx, edx |
3977 | mov ecx, [esp] |
3995 | mov ecx, [esp] |
3978 | push edx |
3996 | push edx |
3979 | push eax |
3997 | push eax |
3980 | call wait_event_timeout |
3998 | call wait_event_timeout |
3981 | pop eax |
3999 | pop eax |
3982 | pop ebx |
4000 | pop ebx |
3983 | call destroy_event |
4001 | call destroy_event |
3984 | .done: |
4002 | .done: |
3985 | add esp, 4 |
4003 | add esp, 4 |
3986 | popad |
4004 | popad |
3987 | ret |
4005 | ret |
3988 | 4006 | ||
3989 | else |
4007 | else |
3990 | 4008 | ||
3991 | align 4 |
4009 | align 4 |
3992 | delay_hs: ; delay in 1/100 secs |
4010 | delay_hs: ; delay in 1/100 secs |
3993 | ; ebx = delay time |
4011 | ; ebx = delay time |
3994 | push ecx |
4012 | push ecx |
3995 | push edx |
4013 | push edx |
3996 | 4014 | ||
3997 | mov edx, [timer_ticks] |
4015 | mov edx, [timer_ticks] |
3998 | ;-------------------------------------- |
4016 | ;-------------------------------------- |
3999 | align 4 |
4017 | align 4 |
4000 | newtic: |
4018 | newtic: |
4001 | mov ecx, [timer_ticks] |
4019 | mov ecx, [timer_ticks] |
4002 | sub ecx, edx |
4020 | sub ecx, edx |
4003 | cmp ecx, ebx |
4021 | cmp ecx, ebx |
4004 | jae zerodelay |
4022 | jae zerodelay |
4005 | 4023 | ||
4006 | call change_task |
4024 | call change_task |
4007 | 4025 | ||
4008 | jmp newtic |
4026 | jmp newtic |
4009 | ;-------------------------------------- |
4027 | ;-------------------------------------- |
4010 | align 4 |
4028 | align 4 |
4011 | zerodelay: |
4029 | zerodelay: |
4012 | pop edx |
4030 | pop edx |
4013 | pop ecx |
4031 | pop ecx |
4014 | ret |
4032 | ret |
4015 | end if |
4033 | end if |
4016 | 4034 | ||
4017 | ;----------------------------------------------------------------------------- |
4035 | ;----------------------------------------------------------------------------- |
4018 | align 16 ;very often call this subrutine |
4036 | align 16 ;very often call this subrutine |
4019 | memmove: ; memory move in bytes |
4037 | memmove: ; memory move in bytes |
4020 | ; eax = from |
4038 | ; eax = from |
4021 | ; ebx = to |
4039 | ; ebx = to |
4022 | ; ecx = no of bytes |
4040 | ; ecx = no of bytes |
4023 | test ecx, ecx |
4041 | test ecx, ecx |
4024 | jle .ret |
4042 | jle .ret |
4025 | 4043 | ||
4026 | push esi edi ecx |
4044 | push esi edi ecx |
4027 | 4045 | ||
4028 | mov edi, ebx |
4046 | mov edi, ebx |
4029 | mov esi, eax |
4047 | mov esi, eax |
4030 | 4048 | ||
4031 | test ecx, not 11b |
4049 | test ecx, not 11b |
4032 | jz @f |
4050 | jz @f |
4033 | 4051 | ||
4034 | push ecx |
4052 | push ecx |
4035 | shr ecx, 2 |
4053 | shr ecx, 2 |
4036 | rep movsd |
4054 | rep movsd |
4037 | pop ecx |
4055 | pop ecx |
4038 | and ecx, 11b |
4056 | and ecx, 11b |
4039 | jz .finish |
4057 | jz .finish |
4040 | ;-------------------------------------- |
4058 | ;-------------------------------------- |
4041 | align 4 |
4059 | align 4 |
4042 | @@: |
4060 | @@: |
4043 | rep movsb |
4061 | rep movsb |
4044 | ;-------------------------------------- |
4062 | ;-------------------------------------- |
4045 | align 4 |
4063 | align 4 |
4046 | .finish: |
4064 | .finish: |
4047 | pop ecx edi esi |
4065 | pop ecx edi esi |
4048 | ;-------------------------------------- |
4066 | ;-------------------------------------- |
4049 | align 4 |
4067 | align 4 |
4050 | .ret: |
4068 | .ret: |
4051 | ret |
4069 | ret |
4052 | ;----------------------------------------------------------------------------- |
4070 | ;----------------------------------------------------------------------------- |
4053 | ; |
4071 | ; |
4054 | ;align 4 |
4072 | ;align 4 |
4055 | ; |
4073 | ; |
4056 | ;read_floppy_file: |
4074 | ;read_floppy_file: |
4057 | ; |
4075 | ; |
4058 | ;; as input |
4076 | ;; as input |
4059 | ;; |
4077 | ;; |
4060 | ;; eax pointer to file |
4078 | ;; eax pointer to file |
4061 | ;; ebx file lenght |
4079 | ;; ebx file lenght |
4062 | ;; ecx start 512 byte block number |
4080 | ;; ecx start 512 byte block number |
4063 | ;; edx number of blocks to read |
4081 | ;; edx number of blocks to read |
4064 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4082 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4065 | ;; |
4083 | ;; |
4066 | ;; |
4084 | ;; |
4067 | ;; on return |
4085 | ;; on return |
4068 | ;; |
4086 | ;; |
4069 | ;; eax = 0 command succesful |
4087 | ;; eax = 0 command succesful |
4070 | ;; 1 no fd base and/or partition defined |
4088 | ;; 1 no fd base and/or partition defined |
4071 | ;; 2 yet unsupported FS |
4089 | ;; 2 yet unsupported FS |
4072 | ;; 3 unknown FS |
4090 | ;; 3 unknown FS |
4073 | ;; 4 partition not defined at hd |
4091 | ;; 4 partition not defined at hd |
4074 | ;; 5 file not found |
4092 | ;; 5 file not found |
4075 | ;; ebx = size of file |
4093 | ;; ebx = size of file |
4076 | ; |
4094 | ; |
4077 | ; mov edi,[TASK_BASE] |
4095 | ; mov edi,[TASK_BASE] |
4078 | ; add edi,0x10 |
4096 | ; add edi,0x10 |
4079 | ; add esi,[edi] |
4097 | ; add esi,[edi] |
4080 | ; add eax,[edi] |
4098 | ; add eax,[edi] |
4081 | ; |
4099 | ; |
4082 | ; pushad |
4100 | ; pushad |
4083 | ; mov edi,esi |
4101 | ; mov edi,esi |
4084 | ; add edi,1024 |
4102 | ; add edi,1024 |
4085 | ; mov esi,0x100000+19*512 |
4103 | ; mov esi,0x100000+19*512 |
4086 | ; sub ecx,1 |
4104 | ; sub ecx,1 |
4087 | ; shl ecx,9 |
4105 | ; shl ecx,9 |
4088 | ; add esi,ecx |
4106 | ; add esi,ecx |
4089 | ; shl edx,9 |
4107 | ; shl edx,9 |
4090 | ; mov ecx,edx |
4108 | ; mov ecx,edx |
4091 | ; cld |
4109 | ; cld |
4092 | ; rep movsb |
4110 | ; rep movsb |
4093 | ; popad |
4111 | ; popad |
4094 | ; |
4112 | ; |
4095 | ; mov [esp+36],eax |
4113 | ; mov [esp+36],eax |
4096 | ; mov [esp+24],ebx |
4114 | ; mov [esp+24],ebx |
4097 | ; ret |
4115 | ; ret |
4098 | 4116 | ||
4099 | 4117 | ||
4100 | 4118 | ||
4101 | align 4 |
4119 | align 4 |
4102 | set_io_access_rights: |
4120 | set_io_access_rights: |
4103 | push edi eax |
4121 | push edi eax |
4104 | mov edi, tss._io_map_0 |
4122 | mov edi, tss._io_map_0 |
4105 | ; mov ecx,eax |
4123 | ; mov ecx,eax |
4106 | ; and ecx,7 ; offset in byte |
4124 | ; and ecx,7 ; offset in byte |
4107 | ; shr eax,3 ; number of byte |
4125 | ; shr eax,3 ; number of byte |
4108 | ; add edi,eax |
4126 | ; add edi,eax |
4109 | ; mov ebx,1 |
4127 | ; mov ebx,1 |
4110 | ; shl ebx,cl |
4128 | ; shl ebx,cl |
4111 | test ebp, ebp |
4129 | test ebp, ebp |
4112 | ; cmp ebp,0 ; enable access - ebp = 0 |
4130 | ; cmp ebp,0 ; enable access - ebp = 0 |
4113 | jnz .siar1 |
4131 | jnz .siar1 |
4114 | ; not ebx |
4132 | ; not ebx |
4115 | ; and [edi],byte bl |
4133 | ; and [edi],byte bl |
4116 | btr [edi], eax |
4134 | btr [edi], eax |
4117 | pop eax edi |
4135 | pop eax edi |
4118 | ret |
4136 | ret |
4119 | .siar1: |
4137 | .siar1: |
4120 | bts [edi], eax |
4138 | bts [edi], eax |
4121 | ; or [edi],byte bl ; disable access - ebp = 1 |
4139 | ; or [edi],byte bl ; disable access - ebp = 1 |
4122 | pop eax edi |
4140 | pop eax edi |
4123 | ret |
4141 | ret |
4124 | ;reserve/free group of ports |
4142 | ;reserve/free group of ports |
4125 | ; * eax = 46 - number function |
4143 | ; * eax = 46 - number function |
4126 | ; * ebx = 0 - reserve, 1 - free |
4144 | ; * ebx = 0 - reserve, 1 - free |
4127 | ; * ecx = number start arrea of ports |
4145 | ; * ecx = number start arrea of ports |
4128 | ; * edx = number end arrea of ports (include last number of port) |
4146 | ; * edx = number end arrea of ports (include last number of port) |
4129 | ;Return value: |
4147 | ;Return value: |
4130 | ; * eax = 0 - succesful |
4148 | ; * eax = 0 - succesful |
4131 | ; * eax = 1 - error |
4149 | ; * eax = 1 - error |
4132 | ; * The system has reserve this ports: |
4150 | ; * The system has reserve this ports: |
4133 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4151 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4134 | ;destroys eax,ebx, ebp |
4152 | ;destroys eax,ebx, ebp |
4135 | r_f_port_area: |
4153 | r_f_port_area: |
4136 | 4154 | ||
4137 | test ebx, ebx |
4155 | test ebx, ebx |
4138 | jnz free_port_area |
4156 | jnz free_port_area |
4139 | ; je r_port_area |
4157 | ; je r_port_area |
4140 | ; jmp free_port_area |
4158 | ; jmp free_port_area |
4141 | 4159 | ||
4142 | ; r_port_area: |
4160 | ; r_port_area: |
4143 | 4161 | ||
4144 | ; pushad |
4162 | ; pushad |
4145 | 4163 | ||
4146 | cmp ecx, edx ; beginning > end ? |
4164 | cmp ecx, edx ; beginning > end ? |
4147 | ja rpal1 |
4165 | ja rpal1 |
4148 | cmp edx, 65536 |
4166 | cmp edx, 65536 |
4149 | jae rpal1 |
4167 | jae rpal1 |
4150 | mov eax, [RESERVED_PORTS] |
4168 | mov eax, [RESERVED_PORTS] |
4151 | test eax, eax ; no reserved areas ? |
4169 | test eax, eax ; no reserved areas ? |
4152 | je rpal2 |
4170 | je rpal2 |
4153 | cmp eax, 255 ; max reserved |
4171 | cmp eax, 255 ; max reserved |
4154 | jae rpal1 |
4172 | jae rpal1 |
4155 | rpal3: |
4173 | rpal3: |
4156 | mov ebx, eax |
4174 | mov ebx, eax |
4157 | shl ebx, 4 |
4175 | shl ebx, 4 |
4158 | add ebx, RESERVED_PORTS |
4176 | add ebx, RESERVED_PORTS |
4159 | cmp ecx, [ebx+8] |
4177 | cmp ecx, [ebx+8] |
4160 | ja rpal4 |
4178 | ja rpal4 |
4161 | cmp edx, [ebx+4] |
4179 | cmp edx, [ebx+4] |
4162 | jae rpal1 |
4180 | jae rpal1 |
4163 | ; jb rpal4 |
4181 | ; jb rpal4 |
4164 | ; jmp rpal1 |
4182 | ; jmp rpal1 |
4165 | rpal4: |
4183 | rpal4: |
4166 | dec eax |
4184 | dec eax |
4167 | jnz rpal3 |
4185 | jnz rpal3 |
4168 | jmp rpal2 |
4186 | jmp rpal2 |
4169 | rpal1: |
4187 | rpal1: |
4170 | ; popad |
4188 | ; popad |
4171 | ; mov eax,1 |
4189 | ; mov eax,1 |
4172 | xor eax, eax |
4190 | xor eax, eax |
4173 | inc eax |
4191 | inc eax |
4174 | ret |
4192 | ret |
4175 | rpal2: |
4193 | rpal2: |
4176 | ; popad |
4194 | ; popad |
4177 | ; enable port access at port IO map |
4195 | ; enable port access at port IO map |
4178 | cli |
4196 | cli |
4179 | pushad ; start enable io map |
4197 | pushad ; start enable io map |
4180 | 4198 | ||
4181 | cmp edx, 65536;16384 |
4199 | cmp edx, 65536;16384 |
4182 | jae no_unmask_io; jge |
4200 | jae no_unmask_io; jge |
4183 | mov eax, ecx |
4201 | mov eax, ecx |
4184 | ; push ebp |
4202 | ; push ebp |
4185 | xor ebp, ebp ; enable - eax = port |
4203 | xor ebp, ebp ; enable - eax = port |
4186 | new_port_access: |
4204 | new_port_access: |
4187 | ; pushad |
4205 | ; pushad |
4188 | call set_io_access_rights |
4206 | call set_io_access_rights |
4189 | ; popad |
4207 | ; popad |
4190 | inc eax |
4208 | inc eax |
4191 | cmp eax, edx |
4209 | cmp eax, edx |
4192 | jbe new_port_access |
4210 | jbe new_port_access |
4193 | ; pop ebp |
4211 | ; pop ebp |
4194 | no_unmask_io: |
4212 | no_unmask_io: |
4195 | popad ; end enable io map |
4213 | popad ; end enable io map |
4196 | sti |
4214 | sti |
4197 | 4215 | ||
4198 | mov eax, [RESERVED_PORTS] |
4216 | mov eax, [RESERVED_PORTS] |
4199 | add eax, 1 |
4217 | add eax, 1 |
4200 | mov [RESERVED_PORTS], eax |
4218 | mov [RESERVED_PORTS], eax |
4201 | shl eax, 4 |
4219 | shl eax, 4 |
4202 | add eax, RESERVED_PORTS |
4220 | add eax, RESERVED_PORTS |
4203 | mov ebx, [TASK_BASE] |
4221 | mov ebx, [TASK_BASE] |
4204 | mov ebx, [ebx+TASKDATA.pid] |
4222 | mov ebx, [ebx+TASKDATA.pid] |
4205 | mov [eax], ebx |
4223 | mov [eax], ebx |
4206 | mov [eax+4], ecx |
4224 | mov [eax+4], ecx |
4207 | mov [eax+8], edx |
4225 | mov [eax+8], edx |
4208 | 4226 | ||
4209 | xor eax, eax |
4227 | xor eax, eax |
4210 | ret |
4228 | ret |
4211 | 4229 | ||
4212 | free_port_area: |
4230 | free_port_area: |
4213 | 4231 | ||
4214 | ; pushad |
4232 | ; pushad |
4215 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4233 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4216 | test eax, eax |
4234 | test eax, eax |
4217 | jz frpal2 |
4235 | jz frpal2 |
4218 | mov ebx, [TASK_BASE] |
4236 | mov ebx, [TASK_BASE] |
4219 | mov ebx, [ebx+TASKDATA.pid] |
4237 | mov ebx, [ebx+TASKDATA.pid] |
4220 | frpal3: |
4238 | frpal3: |
4221 | mov edi, eax |
4239 | mov edi, eax |
4222 | shl edi, 4 |
4240 | shl edi, 4 |
4223 | add edi, RESERVED_PORTS |
4241 | add edi, RESERVED_PORTS |
4224 | cmp ebx, [edi] |
4242 | cmp ebx, [edi] |
4225 | jne frpal4 |
4243 | jne frpal4 |
4226 | cmp ecx, [edi+4] |
4244 | cmp ecx, [edi+4] |
4227 | jne frpal4 |
4245 | jne frpal4 |
4228 | cmp edx, [edi+8] |
4246 | cmp edx, [edi+8] |
4229 | jne frpal4 |
4247 | jne frpal4 |
4230 | jmp frpal1 |
4248 | jmp frpal1 |
4231 | frpal4: |
4249 | frpal4: |
4232 | dec eax |
4250 | dec eax |
4233 | jnz frpal3 |
4251 | jnz frpal3 |
4234 | frpal2: |
4252 | frpal2: |
4235 | ; popad |
4253 | ; popad |
4236 | inc eax |
4254 | inc eax |
4237 | ret |
4255 | ret |
4238 | frpal1: |
4256 | frpal1: |
4239 | push ecx |
4257 | push ecx |
4240 | mov ecx, 256 |
4258 | mov ecx, 256 |
4241 | sub ecx, eax |
4259 | sub ecx, eax |
4242 | shl ecx, 4 |
4260 | shl ecx, 4 |
4243 | mov esi, edi |
4261 | mov esi, edi |
4244 | add esi, 16 |
4262 | add esi, 16 |
4245 | cld |
4263 | cld |
4246 | rep movsb |
4264 | rep movsb |
4247 | 4265 | ||
4248 | dec dword [RESERVED_PORTS] |
4266 | dec dword [RESERVED_PORTS] |
4249 | ;popad |
4267 | ;popad |
4250 | ;disable port access at port IO map |
4268 | ;disable port access at port IO map |
4251 | 4269 | ||
4252 | ; pushad ; start disable io map |
4270 | ; pushad ; start disable io map |
4253 | pop eax ;start port |
4271 | pop eax ;start port |
4254 | cmp edx, 65536;16384 |
4272 | cmp edx, 65536;16384 |
4255 | jge no_mask_io |
4273 | jge no_mask_io |
4256 | 4274 | ||
4257 | ; mov eax,ecx |
4275 | ; mov eax,ecx |
4258 | xor ebp, ebp |
4276 | xor ebp, ebp |
4259 | inc ebp |
4277 | inc ebp |
4260 | new_port_access_disable: |
4278 | new_port_access_disable: |
4261 | ; pushad |
4279 | ; pushad |
4262 | ; mov ebp,1 ; disable - eax = port |
4280 | ; mov ebp,1 ; disable - eax = port |
4263 | call set_io_access_rights |
4281 | call set_io_access_rights |
4264 | ; popad |
4282 | ; popad |
4265 | inc eax |
4283 | inc eax |
4266 | cmp eax, edx |
4284 | cmp eax, edx |
4267 | jbe new_port_access_disable |
4285 | jbe new_port_access_disable |
4268 | no_mask_io: |
4286 | no_mask_io: |
4269 | ; popad ; end disable io map |
4287 | ; popad ; end disable io map |
4270 | xor eax, eax |
4288 | xor eax, eax |
4271 | ret |
4289 | ret |
4272 | ;----------------------------------------------------------------------------- |
4290 | ;----------------------------------------------------------------------------- |
4273 | align 4 |
4291 | align 4 |
4274 | drawbackground: |
4292 | drawbackground: |
4275 | dbrv20: |
4293 | dbrv20: |
4276 | cmp [BgrDrawMode], dword 1 |
4294 | cmp [BgrDrawMode], dword 1 |
4277 | jne bgrstr |
4295 | jne bgrstr |
4278 | call vesa20_drawbackground_tiled |
4296 | call vesa20_drawbackground_tiled |
4279 | ; call [draw_pointer] |
4297 | ; call [draw_pointer] |
4280 | call __sys_draw_pointer |
4298 | call __sys_draw_pointer |
4281 | ret |
4299 | ret |
4282 | ;-------------------------------------- |
4300 | ;-------------------------------------- |
4283 | align 4 |
4301 | align 4 |
4284 | bgrstr: |
4302 | bgrstr: |
4285 | call vesa20_drawbackground_stretch |
4303 | call vesa20_drawbackground_stretch |
4286 | ; call [draw_pointer] |
4304 | ; call [draw_pointer] |
4287 | call __sys_draw_pointer |
4305 | call __sys_draw_pointer |
4288 | ret |
4306 | ret |
4289 | ;----------------------------------------------------------------------------- |
4307 | ;----------------------------------------------------------------------------- |
4290 | align 4 |
4308 | align 4 |
4291 | syscall_putimage: ; PutImage |
4309 | syscall_putimage: ; PutImage |
4292 | sys_putimage: |
4310 | sys_putimage: |
4293 | test ecx, 0x80008000 |
4311 | test ecx, 0x80008000 |
4294 | jnz .exit |
4312 | jnz .exit |
4295 | test ecx, 0x0000FFFF |
4313 | test ecx, 0x0000FFFF |
4296 | jz .exit |
4314 | jz .exit |
4297 | test ecx, 0xFFFF0000 |
4315 | test ecx, 0xFFFF0000 |
4298 | jnz @f |
4316 | jnz @f |
4299 | ;-------------------------------------- |
4317 | ;-------------------------------------- |
4300 | align 4 |
4318 | align 4 |
4301 | .exit: |
4319 | .exit: |
4302 | ret |
4320 | ret |
4303 | ;-------------------------------------- |
4321 | ;-------------------------------------- |
4304 | align 4 |
4322 | align 4 |
4305 | @@: |
4323 | @@: |
4306 | mov edi, [current_slot] |
4324 | mov edi, [current_slot] |
4307 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4325 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4308 | rol edx, 16 |
4326 | rol edx, 16 |
4309 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4327 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4310 | rol edx, 16 |
4328 | rol edx, 16 |
4311 | ;-------------------------------------- |
4329 | ;-------------------------------------- |
4312 | align 4 |
4330 | align 4 |
4313 | .forced: |
4331 | .forced: |
4314 | push ebp esi 0 |
4332 | push ebp esi 0 |
4315 | mov ebp, putimage_get24bpp |
4333 | mov ebp, putimage_get24bpp |
4316 | mov esi, putimage_init24bpp |
4334 | mov esi, putimage_init24bpp |
4317 | ;-------------------------------------- |
4335 | ;-------------------------------------- |
4318 | align 4 |
4336 | align 4 |
4319 | sys_putimage_bpp: |
4337 | sys_putimage_bpp: |
4320 | call vesa20_putimage |
4338 | call vesa20_putimage |
4321 | pop ebp esi ebp |
4339 | pop ebp esi ebp |
4322 | ret |
4340 | ret |
4323 | ; jmp [draw_pointer] |
4341 | ; jmp [draw_pointer] |
4324 | ;----------------------------------------------------------------------------- |
4342 | ;----------------------------------------------------------------------------- |
4325 | align 4 |
4343 | align 4 |
4326 | sys_putimage_palette: |
4344 | sys_putimage_palette: |
4327 | ; ebx = pointer to image |
4345 | ; ebx = pointer to image |
4328 | ; ecx = [xsize]*65536 + [ysize] |
4346 | ; ecx = [xsize]*65536 + [ysize] |
4329 | ; edx = [xstart]*65536 + [ystart] |
4347 | ; edx = [xstart]*65536 + [ystart] |
4330 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4348 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4331 | ; edi = pointer to palette |
4349 | ; edi = pointer to palette |
4332 | ; ebp = row delta |
4350 | ; ebp = row delta |
4333 | mov eax, [CURRENT_TASK] |
4351 | mov eax, [CURRENT_TASK] |
4334 | shl eax, 8 |
4352 | shl eax, 8 |
4335 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4353 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4336 | rol edx, 16 |
4354 | rol edx, 16 |
4337 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4355 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4338 | rol edx, 16 |
4356 | rol edx, 16 |
4339 | ;-------------------------------------- |
4357 | ;-------------------------------------- |
4340 | align 4 |
4358 | align 4 |
4341 | .forced: |
4359 | .forced: |
4342 | cmp esi, 1 |
4360 | cmp esi, 1 |
4343 | jnz @f |
4361 | jnz @f |
4344 | push edi |
4362 | push edi |
4345 | mov eax, [edi+4] |
4363 | mov eax, [edi+4] |
4346 | sub eax, [edi] |
4364 | sub eax, [edi] |
4347 | push eax |
4365 | push eax |
4348 | push dword [edi] |
4366 | push dword [edi] |
4349 | push 0ffffff80h |
4367 | push 0ffffff80h |
4350 | mov edi, esp |
4368 | mov edi, esp |
4351 | call put_mono_image |
4369 | call put_mono_image |
4352 | add esp, 12 |
4370 | add esp, 12 |
4353 | pop edi |
4371 | pop edi |
4354 | ret |
4372 | ret |
4355 | ;-------------------------------------- |
4373 | ;-------------------------------------- |
4356 | align 4 |
4374 | align 4 |
4357 | @@: |
4375 | @@: |
4358 | cmp esi, 2 |
4376 | cmp esi, 2 |
4359 | jnz @f |
4377 | jnz @f |
4360 | push edi |
4378 | push edi |
4361 | push 0ffffff80h |
4379 | push 0ffffff80h |
4362 | mov edi, esp |
4380 | mov edi, esp |
4363 | call put_2bit_image |
4381 | call put_2bit_image |
4364 | pop eax |
4382 | pop eax |
4365 | pop edi |
4383 | pop edi |
4366 | ret |
4384 | ret |
4367 | ;-------------------------------------- |
4385 | ;-------------------------------------- |
4368 | align 4 |
4386 | align 4 |
4369 | @@: |
4387 | @@: |
4370 | cmp esi, 4 |
4388 | cmp esi, 4 |
4371 | jnz @f |
4389 | jnz @f |
4372 | push edi |
4390 | push edi |
4373 | push 0ffffff80h |
4391 | push 0ffffff80h |
4374 | mov edi, esp |
4392 | mov edi, esp |
4375 | call put_4bit_image |
4393 | call put_4bit_image |
4376 | pop eax |
4394 | pop eax |
4377 | pop edi |
4395 | pop edi |
4378 | ret |
4396 | ret |
4379 | ;-------------------------------------- |
4397 | ;-------------------------------------- |
4380 | align 4 |
4398 | align 4 |
4381 | @@: |
4399 | @@: |
4382 | push ebp esi ebp |
4400 | push ebp esi ebp |
4383 | cmp esi, 8 |
4401 | cmp esi, 8 |
4384 | jnz @f |
4402 | jnz @f |
4385 | mov ebp, putimage_get8bpp |
4403 | mov ebp, putimage_get8bpp |
4386 | mov esi, putimage_init8bpp |
4404 | mov esi, putimage_init8bpp |
4387 | jmp sys_putimage_bpp |
4405 | jmp sys_putimage_bpp |
4388 | ;-------------------------------------- |
4406 | ;-------------------------------------- |
4389 | align 4 |
4407 | align 4 |
4390 | @@: |
4408 | @@: |
4391 | cmp esi, 9 |
4409 | cmp esi, 9 |
4392 | jnz @f |
4410 | jnz @f |
4393 | mov ebp, putimage_get9bpp |
4411 | mov ebp, putimage_get9bpp |
4394 | mov esi, putimage_init9bpp |
4412 | mov esi, putimage_init9bpp |
4395 | jmp sys_putimage_bpp |
4413 | jmp sys_putimage_bpp |
4396 | ;-------------------------------------- |
4414 | ;-------------------------------------- |
4397 | align 4 |
4415 | align 4 |
4398 | @@: |
4416 | @@: |
4399 | cmp esi, 15 |
4417 | cmp esi, 15 |
4400 | jnz @f |
4418 | jnz @f |
4401 | mov ebp, putimage_get15bpp |
4419 | mov ebp, putimage_get15bpp |
4402 | mov esi, putimage_init15bpp |
4420 | mov esi, putimage_init15bpp |
4403 | jmp sys_putimage_bpp |
4421 | jmp sys_putimage_bpp |
4404 | ;-------------------------------------- |
4422 | ;-------------------------------------- |
4405 | align 4 |
4423 | align 4 |
4406 | @@: |
4424 | @@: |
4407 | cmp esi, 16 |
4425 | cmp esi, 16 |
4408 | jnz @f |
4426 | jnz @f |
4409 | mov ebp, putimage_get16bpp |
4427 | mov ebp, putimage_get16bpp |
4410 | mov esi, putimage_init16bpp |
4428 | mov esi, putimage_init16bpp |
4411 | jmp sys_putimage_bpp |
4429 | jmp sys_putimage_bpp |
4412 | ;-------------------------------------- |
4430 | ;-------------------------------------- |
4413 | align 4 |
4431 | align 4 |
4414 | @@: |
4432 | @@: |
4415 | cmp esi, 24 |
4433 | cmp esi, 24 |
4416 | jnz @f |
4434 | jnz @f |
4417 | mov ebp, putimage_get24bpp |
4435 | mov ebp, putimage_get24bpp |
4418 | mov esi, putimage_init24bpp |
4436 | mov esi, putimage_init24bpp |
4419 | jmp sys_putimage_bpp |
4437 | jmp sys_putimage_bpp |
4420 | ;-------------------------------------- |
4438 | ;-------------------------------------- |
4421 | align 4 |
4439 | align 4 |
4422 | @@: |
4440 | @@: |
4423 | cmp esi, 32 |
4441 | cmp esi, 32 |
4424 | jnz @f |
4442 | jnz @f |
4425 | mov ebp, putimage_get32bpp |
4443 | mov ebp, putimage_get32bpp |
4426 | mov esi, putimage_init32bpp |
4444 | mov esi, putimage_init32bpp |
4427 | jmp sys_putimage_bpp |
4445 | jmp sys_putimage_bpp |
4428 | ;-------------------------------------- |
4446 | ;-------------------------------------- |
4429 | align 4 |
4447 | align 4 |
4430 | @@: |
4448 | @@: |
4431 | pop ebp esi ebp |
4449 | pop ebp esi ebp |
4432 | ret |
4450 | ret |
4433 | ;----------------------------------------------------------------------------- |
4451 | ;----------------------------------------------------------------------------- |
4434 | align 4 |
4452 | align 4 |
4435 | put_mono_image: |
4453 | put_mono_image: |
4436 | push ebp esi ebp |
4454 | push ebp esi ebp |
4437 | mov ebp, putimage_get1bpp |
4455 | mov ebp, putimage_get1bpp |
4438 | mov esi, putimage_init1bpp |
4456 | mov esi, putimage_init1bpp |
4439 | jmp sys_putimage_bpp |
4457 | jmp sys_putimage_bpp |
4440 | ;----------------------------------------------------------------------------- |
4458 | ;----------------------------------------------------------------------------- |
4441 | align 4 |
4459 | align 4 |
4442 | put_2bit_image: |
4460 | put_2bit_image: |
4443 | push ebp esi ebp |
4461 | push ebp esi ebp |
4444 | mov ebp, putimage_get2bpp |
4462 | mov ebp, putimage_get2bpp |
4445 | mov esi, putimage_init2bpp |
4463 | mov esi, putimage_init2bpp |
4446 | jmp sys_putimage_bpp |
4464 | jmp sys_putimage_bpp |
4447 | ;----------------------------------------------------------------------------- |
4465 | ;----------------------------------------------------------------------------- |
4448 | align 4 |
4466 | align 4 |
4449 | put_4bit_image: |
4467 | put_4bit_image: |
4450 | push ebp esi ebp |
4468 | push ebp esi ebp |
4451 | mov ebp, putimage_get4bpp |
4469 | mov ebp, putimage_get4bpp |
4452 | mov esi, putimage_init4bpp |
4470 | mov esi, putimage_init4bpp |
4453 | jmp sys_putimage_bpp |
4471 | jmp sys_putimage_bpp |
4454 | ;----------------------------------------------------------------------------- |
4472 | ;----------------------------------------------------------------------------- |
4455 | align 4 |
4473 | align 4 |
4456 | putimage_init24bpp: |
4474 | putimage_init24bpp: |
4457 | lea eax, [eax*3] |
4475 | lea eax, [eax*3] |
4458 | putimage_init8bpp: |
4476 | putimage_init8bpp: |
4459 | putimage_init9bpp: |
4477 | putimage_init9bpp: |
4460 | ret |
4478 | ret |
4461 | ;----------------------------------------------------------------------------- |
4479 | ;----------------------------------------------------------------------------- |
4462 | align 16 |
4480 | align 16 |
4463 | putimage_get24bpp: |
4481 | putimage_get24bpp: |
4464 | movzx eax, byte [esi+2] |
4482 | movzx eax, byte [esi+2] |
4465 | shl eax, 16 |
4483 | shl eax, 16 |
4466 | mov ax, [esi] |
4484 | mov ax, [esi] |
4467 | add esi, 3 |
4485 | add esi, 3 |
4468 | ret 4 |
4486 | ret 4 |
4469 | ;----------------------------------------------------------------------------- |
4487 | ;----------------------------------------------------------------------------- |
4470 | align 16 |
4488 | align 16 |
4471 | putimage_get8bpp: |
4489 | putimage_get8bpp: |
4472 | movzx eax, byte [esi] |
4490 | movzx eax, byte [esi] |
4473 | push edx |
4491 | push edx |
4474 | mov edx, [esp+8] |
4492 | mov edx, [esp+8] |
4475 | mov eax, [edx+eax*4] |
4493 | mov eax, [edx+eax*4] |
4476 | pop edx |
4494 | pop edx |
4477 | inc esi |
4495 | inc esi |
4478 | ret 4 |
4496 | ret 4 |
4479 | ;----------------------------------------------------------------------------- |
4497 | ;----------------------------------------------------------------------------- |
4480 | align 16 |
4498 | align 16 |
4481 | putimage_get9bpp: |
4499 | putimage_get9bpp: |
4482 | lodsb |
4500 | lodsb |
4483 | mov ah, al |
4501 | mov ah, al |
4484 | shl eax, 8 |
4502 | shl eax, 8 |
4485 | mov al, ah |
4503 | mov al, ah |
4486 | ret 4 |
4504 | ret 4 |
4487 | ;----------------------------------------------------------------------------- |
4505 | ;----------------------------------------------------------------------------- |
4488 | align 4 |
4506 | align 4 |
4489 | putimage_init1bpp: |
4507 | putimage_init1bpp: |
4490 | add eax, ecx |
4508 | add eax, ecx |
4491 | push ecx |
4509 | push ecx |
4492 | add eax, 7 |
4510 | add eax, 7 |
4493 | add ecx, 7 |
4511 | add ecx, 7 |
4494 | shr eax, 3 |
4512 | shr eax, 3 |
4495 | shr ecx, 3 |
4513 | shr ecx, 3 |
4496 | sub eax, ecx |
4514 | sub eax, ecx |
4497 | pop ecx |
4515 | pop ecx |
4498 | ret |
4516 | ret |
4499 | ;----------------------------------------------------------------------------- |
4517 | ;----------------------------------------------------------------------------- |
4500 | align 16 |
4518 | align 16 |
4501 | putimage_get1bpp: |
4519 | putimage_get1bpp: |
4502 | push edx |
4520 | push edx |
4503 | mov edx, [esp+8] |
4521 | mov edx, [esp+8] |
4504 | mov al, [edx] |
4522 | mov al, [edx] |
4505 | add al, al |
4523 | add al, al |
4506 | jnz @f |
4524 | jnz @f |
4507 | lodsb |
4525 | lodsb |
4508 | adc al, al |
4526 | adc al, al |
4509 | @@: |
4527 | @@: |
4510 | mov [edx], al |
4528 | mov [edx], al |
4511 | sbb eax, eax |
4529 | sbb eax, eax |
4512 | and eax, [edx+8] |
4530 | and eax, [edx+8] |
4513 | add eax, [edx+4] |
4531 | add eax, [edx+4] |
4514 | pop edx |
4532 | pop edx |
4515 | ret 4 |
4533 | ret 4 |
4516 | ;----------------------------------------------------------------------------- |
4534 | ;----------------------------------------------------------------------------- |
4517 | align 4 |
4535 | align 4 |
4518 | putimage_init2bpp: |
4536 | putimage_init2bpp: |
4519 | add eax, ecx |
4537 | add eax, ecx |
4520 | push ecx |
4538 | push ecx |
4521 | add ecx, 3 |
4539 | add ecx, 3 |
4522 | add eax, 3 |
4540 | add eax, 3 |
4523 | shr ecx, 2 |
4541 | shr ecx, 2 |
4524 | shr eax, 2 |
4542 | shr eax, 2 |
4525 | sub eax, ecx |
4543 | sub eax, ecx |
4526 | pop ecx |
4544 | pop ecx |
4527 | ret |
4545 | ret |
4528 | ;----------------------------------------------------------------------------- |
4546 | ;----------------------------------------------------------------------------- |
4529 | align 16 |
4547 | align 16 |
4530 | putimage_get2bpp: |
4548 | putimage_get2bpp: |
4531 | push edx |
4549 | push edx |
4532 | mov edx, [esp+8] |
4550 | mov edx, [esp+8] |
4533 | mov al, [edx] |
4551 | mov al, [edx] |
4534 | mov ah, al |
4552 | mov ah, al |
4535 | shr al, 6 |
4553 | shr al, 6 |
4536 | shl ah, 2 |
4554 | shl ah, 2 |
4537 | jnz .nonewbyte |
4555 | jnz .nonewbyte |
4538 | lodsb |
4556 | lodsb |
4539 | mov ah, al |
4557 | mov ah, al |
4540 | shr al, 6 |
4558 | shr al, 6 |
4541 | shl ah, 2 |
4559 | shl ah, 2 |
4542 | add ah, 1 |
4560 | add ah, 1 |
4543 | .nonewbyte: |
4561 | .nonewbyte: |
4544 | mov [edx], ah |
4562 | mov [edx], ah |
4545 | mov edx, [edx+4] |
4563 | mov edx, [edx+4] |
4546 | movzx eax, al |
4564 | movzx eax, al |
4547 | mov eax, [edx+eax*4] |
4565 | mov eax, [edx+eax*4] |
4548 | pop edx |
4566 | pop edx |
4549 | ret 4 |
4567 | ret 4 |
4550 | ;----------------------------------------------------------------------------- |
4568 | ;----------------------------------------------------------------------------- |
4551 | align 4 |
4569 | align 4 |
4552 | putimage_init4bpp: |
4570 | putimage_init4bpp: |
4553 | add eax, ecx |
4571 | add eax, ecx |
4554 | push ecx |
4572 | push ecx |
4555 | add ecx, 1 |
4573 | add ecx, 1 |
4556 | add eax, 1 |
4574 | add eax, 1 |
4557 | shr ecx, 1 |
4575 | shr ecx, 1 |
4558 | shr eax, 1 |
4576 | shr eax, 1 |
4559 | sub eax, ecx |
4577 | sub eax, ecx |
4560 | pop ecx |
4578 | pop ecx |
4561 | ret |
4579 | ret |
4562 | ;----------------------------------------------------------------------------- |
4580 | ;----------------------------------------------------------------------------- |
4563 | align 16 |
4581 | align 16 |
4564 | putimage_get4bpp: |
4582 | putimage_get4bpp: |
4565 | push edx |
4583 | push edx |
4566 | mov edx, [esp+8] |
4584 | mov edx, [esp+8] |
4567 | add byte [edx], 80h |
4585 | add byte [edx], 80h |
4568 | jc @f |
4586 | jc @f |
4569 | movzx eax, byte [edx+1] |
4587 | movzx eax, byte [edx+1] |
4570 | mov edx, [edx+4] |
4588 | mov edx, [edx+4] |
4571 | and eax, 0x0F |
4589 | and eax, 0x0F |
4572 | mov eax, [edx+eax*4] |
4590 | mov eax, [edx+eax*4] |
4573 | pop edx |
4591 | pop edx |
4574 | ret 4 |
4592 | ret 4 |
4575 | @@: |
4593 | @@: |
4576 | movzx eax, byte [esi] |
4594 | movzx eax, byte [esi] |
4577 | add esi, 1 |
4595 | add esi, 1 |
4578 | mov [edx+1], al |
4596 | mov [edx+1], al |
4579 | shr eax, 4 |
4597 | shr eax, 4 |
4580 | mov edx, [edx+4] |
4598 | mov edx, [edx+4] |
4581 | mov eax, [edx+eax*4] |
4599 | mov eax, [edx+eax*4] |
4582 | pop edx |
4600 | pop edx |
4583 | ret 4 |
4601 | ret 4 |
4584 | ;----------------------------------------------------------------------------- |
4602 | ;----------------------------------------------------------------------------- |
4585 | align 4 |
4603 | align 4 |
4586 | putimage_init32bpp: |
4604 | putimage_init32bpp: |
4587 | shl eax, 2 |
4605 | shl eax, 2 |
4588 | ret |
4606 | ret |
4589 | ;----------------------------------------------------------------------------- |
4607 | ;----------------------------------------------------------------------------- |
4590 | align 16 |
4608 | align 16 |
4591 | putimage_get32bpp: |
4609 | putimage_get32bpp: |
4592 | lodsd |
4610 | lodsd |
4593 | ret 4 |
4611 | ret 4 |
4594 | ;----------------------------------------------------------------------------- |
4612 | ;----------------------------------------------------------------------------- |
4595 | align 4 |
4613 | align 4 |
4596 | putimage_init15bpp: |
4614 | putimage_init15bpp: |
4597 | putimage_init16bpp: |
4615 | putimage_init16bpp: |
4598 | add eax, eax |
4616 | add eax, eax |
4599 | ret |
4617 | ret |
4600 | ;----------------------------------------------------------------------------- |
4618 | ;----------------------------------------------------------------------------- |
4601 | align 16 |
4619 | align 16 |
4602 | putimage_get15bpp: |
4620 | putimage_get15bpp: |
4603 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4621 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4604 | push ecx edx |
4622 | push ecx edx |
4605 | movzx eax, word [esi] |
4623 | movzx eax, word [esi] |
4606 | add esi, 2 |
4624 | add esi, 2 |
4607 | mov ecx, eax |
4625 | mov ecx, eax |
4608 | mov edx, eax |
4626 | mov edx, eax |
4609 | and eax, 0x1F |
4627 | and eax, 0x1F |
4610 | and ecx, 0x1F shl 5 |
4628 | and ecx, 0x1F shl 5 |
4611 | and edx, 0x1F shl 10 |
4629 | and edx, 0x1F shl 10 |
4612 | shl eax, 3 |
4630 | shl eax, 3 |
4613 | shl ecx, 6 |
4631 | shl ecx, 6 |
4614 | shl edx, 9 |
4632 | shl edx, 9 |
4615 | or eax, ecx |
4633 | or eax, ecx |
4616 | or eax, edx |
4634 | or eax, edx |
4617 | pop edx ecx |
4635 | pop edx ecx |
4618 | ret 4 |
4636 | ret 4 |
4619 | ;----------------------------------------------------------------------------- |
4637 | ;----------------------------------------------------------------------------- |
4620 | align 16 |
4638 | align 16 |
4621 | putimage_get16bpp: |
4639 | putimage_get16bpp: |
4622 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4640 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4623 | push ecx edx |
4641 | push ecx edx |
4624 | movzx eax, word [esi] |
4642 | movzx eax, word [esi] |
4625 | add esi, 2 |
4643 | add esi, 2 |
4626 | mov ecx, eax |
4644 | mov ecx, eax |
4627 | mov edx, eax |
4645 | mov edx, eax |
4628 | and eax, 0x1F |
4646 | and eax, 0x1F |
4629 | and ecx, 0x3F shl 5 |
4647 | and ecx, 0x3F shl 5 |
4630 | and edx, 0x1F shl 11 |
4648 | and edx, 0x1F shl 11 |
4631 | shl eax, 3 |
4649 | shl eax, 3 |
4632 | shl ecx, 5 |
4650 | shl ecx, 5 |
4633 | shl edx, 8 |
4651 | shl edx, 8 |
4634 | or eax, ecx |
4652 | or eax, ecx |
4635 | or eax, edx |
4653 | or eax, edx |
4636 | pop edx ecx |
4654 | pop edx ecx |
4637 | ret 4 |
4655 | ret 4 |
4638 | ;----------------------------------------------------------------------------- |
4656 | ;----------------------------------------------------------------------------- |
4639 | ;align 4 |
4657 | ;align 4 |
4640 | ; eax x beginning |
4658 | ; eax x beginning |
4641 | ; ebx y beginning |
4659 | ; ebx y beginning |
4642 | ; ecx x end |
4660 | ; ecx x end |
4643 | ; edx y end |
4661 | ; edx y end |
4644 | ; edi color |
4662 | ; edi color |
4645 | ;__sys_drawbar: |
4663 | ;__sys_drawbar: |
4646 | ; mov esi, [current_slot] |
4664 | ; mov esi, [current_slot] |
4647 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4665 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4648 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4666 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4649 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4667 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4650 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4668 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4651 | ;-------------------------------------- |
4669 | ;-------------------------------------- |
4652 | ;align 4 |
4670 | ;align 4 |
4653 | ;.forced: |
4671 | ;.forced: |
4654 | ; call vesa20_drawbar |
4672 | ; call vesa20_drawbar |
4655 | ; call [draw_pointer] |
4673 | ; call [draw_pointer] |
4656 | ; ret |
4674 | ; ret |
4657 | ;----------------------------------------------------------------------------- |
4675 | ;----------------------------------------------------------------------------- |
4658 | align 4 |
4676 | align 4 |
4659 | kb_write_wait_ack: |
4677 | kb_write_wait_ack: |
4660 | 4678 | ||
4661 | push ecx edx |
4679 | push ecx edx |
4662 | 4680 | ||
4663 | mov dl, al |
4681 | mov dl, al |
4664 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4682 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4665 | .wait_output_ready: |
4683 | .wait_output_ready: |
4666 | in al, 0x64 |
4684 | in al, 0x64 |
4667 | test al, 2 |
4685 | test al, 2 |
4668 | jz @f |
4686 | jz @f |
4669 | loop .wait_output_ready |
4687 | loop .wait_output_ready |
4670 | mov ah, 1 |
4688 | mov ah, 1 |
4671 | jmp .nothing |
4689 | jmp .nothing |
4672 | @@: |
4690 | @@: |
4673 | mov al, dl |
4691 | mov al, dl |
4674 | out 0x60, al |
4692 | out 0x60, al |
4675 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4693 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4676 | .wait_ack: |
4694 | .wait_ack: |
4677 | in al, 0x64 |
4695 | in al, 0x64 |
4678 | test al, 1 |
4696 | test al, 1 |
4679 | jnz @f |
4697 | jnz @f |
4680 | loop .wait_ack |
4698 | loop .wait_ack |
4681 | mov ah, 1 |
4699 | mov ah, 1 |
4682 | jmp .nothing |
4700 | jmp .nothing |
4683 | @@: |
4701 | @@: |
4684 | in al, 0x60 |
4702 | in al, 0x60 |
4685 | xor ah, ah |
4703 | xor ah, ah |
4686 | 4704 | ||
4687 | .nothing: |
4705 | .nothing: |
4688 | pop edx ecx |
4706 | pop edx ecx |
4689 | 4707 | ||
4690 | ret |
4708 | ret |
4691 | ;----------------------------------------------------------------------------- |
4709 | ;----------------------------------------------------------------------------- |
4692 | 4710 | ||
4693 | setmouse: ; set mousepicture -pointer |
4711 | setmouse: ; set mousepicture -pointer |
4694 | ; ps2 mouse enable |
4712 | ; ps2 mouse enable |
4695 | 4713 | ||
4696 | ; mov [MOUSE_PICTURE], dword mousepointer |
4714 | ; mov [MOUSE_PICTURE], dword mousepointer |
4697 | 4715 | ||
4698 | cli |
4716 | cli |
4699 | 4717 | ||
4700 | ret |
4718 | ret |
4701 | 4719 | ||
4702 | if used _rdtsc |
4720 | if used _rdtsc |
4703 | _rdtsc: |
4721 | _rdtsc: |
4704 | bt [cpu_caps], CAPS_TSC |
4722 | bt [cpu_caps], CAPS_TSC |
4705 | jnc ret_rdtsc |
4723 | jnc ret_rdtsc |
4706 | rdtsc |
4724 | rdtsc |
4707 | ret |
4725 | ret |
4708 | ret_rdtsc: |
4726 | ret_rdtsc: |
4709 | mov edx, 0xffffffff |
4727 | mov edx, 0xffffffff |
4710 | mov eax, 0xffffffff |
4728 | mov eax, 0xffffffff |
4711 | ret |
4729 | ret |
4712 | end if |
4730 | end if |
4713 | 4731 | ||
4714 | sys_msg_board_str: |
4732 | sys_msg_board_str: |
4715 | 4733 | ||
4716 | pushad |
4734 | pushad |
4717 | @@: |
4735 | @@: |
4718 | cmp [esi], byte 0 |
4736 | cmp [esi], byte 0 |
4719 | je @f |
4737 | je @f |
4720 | mov ebx, 1 |
4738 | mov ebx, 1 |
4721 | movzx ecx, byte [esi] |
4739 | movzx ecx, byte [esi] |
4722 | call sys_msg_board |
4740 | call sys_msg_board |
4723 | inc esi |
4741 | inc esi |
4724 | jmp @b |
4742 | jmp @b |
4725 | @@: |
4743 | @@: |
4726 | popad |
4744 | popad |
4727 | ret |
4745 | ret |
4728 | 4746 | ||
4729 | sys_msg_board_byte: |
4747 | sys_msg_board_byte: |
4730 | ; in: al = byte to display |
4748 | ; in: al = byte to display |
4731 | ; out: nothing |
4749 | ; out: nothing |
4732 | ; destroys: nothing |
4750 | ; destroys: nothing |
4733 | pushad |
4751 | pushad |
4734 | mov ecx, 2 |
4752 | mov ecx, 2 |
4735 | shl eax, 24 |
4753 | shl eax, 24 |
4736 | jmp @f |
4754 | jmp @f |
4737 | 4755 | ||
4738 | sys_msg_board_word: |
4756 | sys_msg_board_word: |
4739 | ; in: ax = word to display |
4757 | ; in: ax = word to display |
4740 | ; out: nothing |
4758 | ; out: nothing |
4741 | ; destroys: nothing |
4759 | ; destroys: nothing |
4742 | pushad |
4760 | pushad |
4743 | mov ecx, 4 |
4761 | mov ecx, 4 |
4744 | shl eax, 16 |
4762 | shl eax, 16 |
4745 | jmp @f |
4763 | jmp @f |
4746 | 4764 | ||
4747 | sys_msg_board_dword: |
4765 | sys_msg_board_dword: |
4748 | ; in: eax = dword to display |
4766 | ; in: eax = dword to display |
4749 | ; out: nothing |
4767 | ; out: nothing |
4750 | ; destroys: nothing |
4768 | ; destroys: nothing |
4751 | pushad |
4769 | pushad |
4752 | mov ecx, 8 |
4770 | mov ecx, 8 |
4753 | @@: |
4771 | @@: |
4754 | push ecx |
4772 | push ecx |
4755 | rol eax, 4 |
4773 | rol eax, 4 |
4756 | push eax |
4774 | push eax |
4757 | and al, 0xF |
4775 | and al, 0xF |
4758 | cmp al, 10 |
4776 | cmp al, 10 |
4759 | sbb al, 69h |
4777 | sbb al, 69h |
4760 | das |
4778 | das |
4761 | mov cl, al |
4779 | mov cl, al |
4762 | xor ebx, ebx |
4780 | xor ebx, ebx |
4763 | inc ebx |
4781 | inc ebx |
4764 | call sys_msg_board |
4782 | call sys_msg_board |
4765 | pop eax |
4783 | pop eax |
4766 | pop ecx |
4784 | pop ecx |
4767 | loop @b |
4785 | loop @b |
4768 | popad |
4786 | popad |
4769 | ret |
4787 | ret |
4770 | 4788 | ||
4771 | msg_board_data_size = 65536 ; Must be power of two |
4789 | msg_board_data_size = 65536 ; Must be power of two |
4772 | 4790 | ||
4773 | uglobal |
4791 | uglobal |
4774 | msg_board_data rb msg_board_data_size |
4792 | msg_board_data rb msg_board_data_size |
4775 | msg_board_count dd 0x0 |
4793 | msg_board_count dd 0x0 |
4776 | endg |
4794 | endg |
4777 | 4795 | ||
4778 | sys_msg_board: |
4796 | sys_msg_board: |
4779 | 4797 | ||
4780 | ; ebx=1 : write : bl byte to write |
4798 | ; ebx=1 : write : bl byte to write |
4781 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4799 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4782 | 4800 | ||
4783 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4801 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4784 | mov eax, ebx |
4802 | mov eax, ebx |
4785 | mov ebx, ecx |
4803 | mov ebx, ecx |
4786 | 4804 | ||
4787 | mov ecx, [msg_board_count] |
4805 | mov ecx, [msg_board_count] |
4788 | cmp eax, 1 |
4806 | cmp eax, 1 |
4789 | jne .smbl1 |
4807 | jne .smbl1 |
4790 | 4808 | ||
4791 | if defined debug_com_base |
4809 | if defined debug_com_base |
4792 | 4810 | ||
4793 | push dx ax |
4811 | push dx ax |
4794 | 4812 | ||
4795 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4813 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4796 | mov dx, debug_com_base+5 |
4814 | mov dx, debug_com_base+5 |
4797 | in al, dx |
4815 | in al, dx |
4798 | test al, 1 shl 5 |
4816 | test al, 1 shl 5 |
4799 | jz @r |
4817 | jz @r |
4800 | 4818 | ||
4801 | mov dx, debug_com_base ; Output the byte |
4819 | mov dx, debug_com_base ; Output the byte |
4802 | mov al, bl |
4820 | mov al, bl |
4803 | out dx, al |
4821 | out dx, al |
4804 | 4822 | ||
4805 | pop ax dx |
4823 | pop ax dx |
4806 | 4824 | ||
4807 | end if |
4825 | end if |
4808 | 4826 | ||
4809 | mov [msg_board_data+ecx], bl |
4827 | mov [msg_board_data+ecx], bl |
4810 | ; // if debug_direct_print == 1 |
4828 | ; // if debug_direct_print == 1 |
4811 | cmp byte [debug_direct_print], 1 |
4829 | cmp byte [debug_direct_print], 1 |
4812 | jnz @f |
4830 | jnz @f |
4813 | pusha |
4831 | pusha |
4814 | iglobal |
4832 | iglobal |
4815 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4833 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4816 | endg |
4834 | endg |
4817 | lea edx, [msg_board_data+ecx] |
4835 | lea edx, [msg_board_data+ecx] |
4818 | mov ecx, 0x40FFFFFF |
4836 | mov ecx, 0x40FFFFFF |
4819 | mov ebx, [msg_board_pos] |
4837 | mov ebx, [msg_board_pos] |
4820 | mov edi, 1 |
4838 | mov edi, 1 |
4821 | mov esi, 1 |
4839 | mov esi, 1 |
4822 | call dtext |
4840 | call dtext |
4823 | popa |
4841 | popa |
4824 | add word [msg_board_pos+2], 6 |
4842 | add word [msg_board_pos+2], 6 |
4825 | cmp bl, 10 |
4843 | cmp bl, 10 |
4826 | jnz @f |
4844 | jnz @f |
4827 | mov word [msg_board_pos+2], (42*6) |
4845 | mov word [msg_board_pos+2], (42*6) |
4828 | add word [msg_board_pos], 10 |
4846 | add word [msg_board_pos], 10 |
4829 | mov ax, word [_display.width] |
4847 | mov ax, word [_display.width] |
4830 | cmp word [msg_board_pos], ax |
4848 | cmp word [msg_board_pos], ax |
4831 | jb @f |
4849 | jb @f |
4832 | mov word [msg_board_pos], 10 |
4850 | mov word [msg_board_pos], 10 |
4833 | @@: |
4851 | @@: |
4834 | ; // end if |
4852 | ; // end if |
4835 | 4853 | ||
4836 | if 0 |
4854 | if 0 |
4837 | pusha |
4855 | pusha |
4838 | mov al, bl |
4856 | mov al, bl |
4839 | mov edx, 402h |
4857 | mov edx, 402h |
4840 | out dx, al |
4858 | out dx, al |
4841 | popa |
4859 | popa |
4842 | end if |
4860 | end if |
4843 | inc ecx |
4861 | inc ecx |
4844 | and ecx, msg_board_data_size - 1 |
4862 | and ecx, msg_board_data_size - 1 |
4845 | mov [msg_board_count], ecx |
4863 | mov [msg_board_count], ecx |
4846 | 4864 | ||
4847 | pop ebx eax |
4865 | pop ebx eax |
4848 | ret |
4866 | ret |
4849 | .smbl1: |
4867 | .smbl1: |
4850 | cmp eax, 2 |
4868 | cmp eax, 2 |
4851 | jne .smbl2 |
4869 | jne .smbl2 |
4852 | test ecx, ecx |
4870 | test ecx, ecx |
4853 | jz .smbl21 |
4871 | jz .smbl21 |
4854 | 4872 | ||
4855 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4873 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4856 | mov eax, msg_board_data+1 |
4874 | mov eax, msg_board_data+1 |
4857 | mov ebx, msg_board_data |
4875 | mov ebx, msg_board_data |
4858 | movzx edx, byte [ebx] |
4876 | movzx edx, byte [ebx] |
4859 | call memmove |
4877 | call memmove |
4860 | dec [msg_board_count] |
4878 | dec [msg_board_count] |
4861 | mov [esp + 32], edx ;eax |
4879 | mov [esp + 32], edx ;eax |
4862 | mov [esp + 20], dword 1 |
4880 | mov [esp + 20], dword 1 |
4863 | ret |
4881 | ret |
4864 | .smbl21: |
4882 | .smbl21: |
4865 | mov [esp+32], ecx |
4883 | mov [esp+32], ecx |
4866 | mov [esp+20], ecx |
4884 | mov [esp+20], ecx |
4867 | .smbl2: |
4885 | .smbl2: |
4868 | pop ebx eax |
4886 | pop ebx eax |
4869 | ret |
4887 | ret |
4870 | 4888 | ||
4871 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4889 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4872 | ;; 66 sys function. ;; |
4890 | ;; 66 sys function. ;; |
4873 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4891 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4874 | ;; out eax ;; |
4892 | ;; out eax ;; |
4875 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4893 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4876 | iglobal |
4894 | iglobal |
4877 | align 4 |
4895 | align 4 |
4878 | f66call: |
4896 | f66call: |
4879 | dd sys_process_def.1 ; 1 = set keyboard mode |
4897 | dd sys_process_def.1 ; 1 = set keyboard mode |
4880 | dd sys_process_def.2 ; 2 = get keyboard mode |
4898 | dd sys_process_def.2 ; 2 = get keyboard mode |
4881 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4899 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4882 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4900 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4883 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4901 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4884 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4902 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4885 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4903 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4886 | endg |
4904 | endg |
4887 | ;----------------------------------------------------------------------------- |
4905 | ;----------------------------------------------------------------------------- |
4888 | align 4 |
4906 | align 4 |
4889 | sys_process_def: |
4907 | sys_process_def: |
4890 | dec ebx |
4908 | dec ebx |
4891 | cmp ebx, 7 |
4909 | cmp ebx, 7 |
4892 | jae .not_support ;if >=8 then or eax,-1 |
4910 | jae .not_support ;if >=8 then or eax,-1 |
4893 | 4911 | ||
4894 | mov edi, [CURRENT_TASK] |
4912 | mov edi, [CURRENT_TASK] |
4895 | jmp dword [f66call+ebx*4] |
4913 | jmp dword [f66call+ebx*4] |
4896 | 4914 | ||
4897 | .not_support: |
4915 | .not_support: |
4898 | or eax, -1 |
4916 | or eax, -1 |
4899 | ret |
4917 | ret |
4900 | ;----------------------------------------------------------------------------- |
4918 | ;----------------------------------------------------------------------------- |
4901 | align 4 |
4919 | align 4 |
4902 | .1: |
4920 | .1: |
4903 | shl edi, 8 |
4921 | shl edi, 8 |
4904 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4922 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4905 | 4923 | ||
4906 | ret |
4924 | ret |
4907 | ;----------------------------------------------------------------------------- |
4925 | ;----------------------------------------------------------------------------- |
4908 | align 4 |
4926 | align 4 |
4909 | .2: ; 2 = get keyboard mode |
4927 | .2: ; 2 = get keyboard mode |
4910 | shl edi, 8 |
4928 | shl edi, 8 |
4911 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4929 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4912 | mov [esp+32], eax |
4930 | mov [esp+32], eax |
4913 | ret |
4931 | ret |
4914 | ;----------------------------------------------------------------------------- |
4932 | ;----------------------------------------------------------------------------- |
4915 | align 4 |
4933 | align 4 |
4916 | .3: ;3 = get keyboard ctrl, alt, shift |
4934 | .3: ;3 = get keyboard ctrl, alt, shift |
4917 | mov eax, [kb_state] |
4935 | mov eax, [kb_state] |
4918 | mov [esp+32], eax |
4936 | mov [esp+32], eax |
4919 | ret |
4937 | ret |
4920 | ;----------------------------------------------------------------------------- |
4938 | ;----------------------------------------------------------------------------- |
4921 | align 4 |
4939 | align 4 |
4922 | .4: |
4940 | .4: |
4923 | mov eax, hotkey_list |
4941 | mov eax, hotkey_list |
4924 | @@: |
4942 | @@: |
4925 | cmp dword [eax+8], 0 |
4943 | cmp dword [eax+8], 0 |
4926 | jz .found_free |
4944 | jz .found_free |
4927 | add eax, 16 |
4945 | add eax, 16 |
4928 | cmp eax, hotkey_list+16*256 |
4946 | cmp eax, hotkey_list+16*256 |
4929 | jb @b |
4947 | jb @b |
4930 | mov dword [esp+32], 1 |
4948 | mov dword [esp+32], 1 |
4931 | ret |
4949 | ret |
4932 | .found_free: |
4950 | .found_free: |
4933 | mov [eax+8], edi |
4951 | mov [eax+8], edi |
4934 | mov [eax+4], edx |
4952 | mov [eax+4], edx |
4935 | movzx ecx, cl |
4953 | movzx ecx, cl |
4936 | lea ecx, [hotkey_scancodes+ecx*4] |
4954 | lea ecx, [hotkey_scancodes+ecx*4] |
4937 | mov edx, [ecx] |
4955 | mov edx, [ecx] |
4938 | mov [eax], edx |
4956 | mov [eax], edx |
4939 | mov [ecx], eax |
4957 | mov [ecx], eax |
4940 | mov [eax+12], ecx |
4958 | mov [eax+12], ecx |
4941 | test edx, edx |
4959 | test edx, edx |
4942 | jz @f |
4960 | jz @f |
4943 | mov [edx+12], eax |
4961 | mov [edx+12], eax |
4944 | @@: |
4962 | @@: |
4945 | and dword [esp+32], 0 |
4963 | and dword [esp+32], 0 |
4946 | ret |
4964 | ret |
4947 | ;----------------------------------------------------------------------------- |
4965 | ;----------------------------------------------------------------------------- |
4948 | align 4 |
4966 | align 4 |
4949 | .5: |
4967 | .5: |
4950 | movzx ebx, cl |
4968 | movzx ebx, cl |
4951 | lea ebx, [hotkey_scancodes+ebx*4] |
4969 | lea ebx, [hotkey_scancodes+ebx*4] |
4952 | mov eax, [ebx] |
4970 | mov eax, [ebx] |
4953 | .scan: |
4971 | .scan: |
4954 | test eax, eax |
4972 | test eax, eax |
4955 | jz .notfound |
4973 | jz .notfound |
4956 | cmp [eax+8], edi |
4974 | cmp [eax+8], edi |
4957 | jnz .next |
4975 | jnz .next |
4958 | cmp [eax+4], edx |
4976 | cmp [eax+4], edx |
4959 | jz .found |
4977 | jz .found |
4960 | .next: |
4978 | .next: |
4961 | mov eax, [eax] |
4979 | mov eax, [eax] |
4962 | jmp .scan |
4980 | jmp .scan |
4963 | .notfound: |
4981 | .notfound: |
4964 | mov dword [esp+32], 1 |
4982 | mov dword [esp+32], 1 |
4965 | ret |
4983 | ret |
4966 | .found: |
4984 | .found: |
4967 | mov ecx, [eax] |
4985 | mov ecx, [eax] |
4968 | jecxz @f |
4986 | jecxz @f |
4969 | mov edx, [eax+12] |
4987 | mov edx, [eax+12] |
4970 | mov [ecx+12], edx |
4988 | mov [ecx+12], edx |
4971 | @@: |
4989 | @@: |
4972 | mov ecx, [eax+12] |
4990 | mov ecx, [eax+12] |
4973 | mov edx, [eax] |
4991 | mov edx, [eax] |
4974 | mov [ecx], edx |
4992 | mov [ecx], edx |
4975 | xor edx, edx |
4993 | xor edx, edx |
4976 | mov [eax+4], edx |
4994 | mov [eax+4], edx |
4977 | mov [eax+8], edx |
4995 | mov [eax+8], edx |
4978 | mov [eax+12], edx |
4996 | mov [eax+12], edx |
4979 | mov [eax], edx |
4997 | mov [eax], edx |
4980 | mov [esp+32], edx |
4998 | mov [esp+32], edx |
4981 | ret |
4999 | ret |
4982 | ;----------------------------------------------------------------------------- |
5000 | ;----------------------------------------------------------------------------- |
4983 | align 4 |
5001 | align 4 |
4984 | .6: |
5002 | .6: |
4985 | pushfd |
5003 | pushfd |
4986 | cli |
5004 | cli |
4987 | mov eax, [PID_lock_input] |
5005 | mov eax, [PID_lock_input] |
4988 | test eax, eax |
5006 | test eax, eax |
4989 | jnz @f |
5007 | jnz @f |
4990 | ; get current PID |
5008 | ; get current PID |
4991 | mov eax, [CURRENT_TASK] |
5009 | mov eax, [CURRENT_TASK] |
4992 | shl eax, 5 |
5010 | shl eax, 5 |
4993 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5011 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4994 | ; set current PID for lock input |
5012 | ; set current PID for lock input |
4995 | mov [PID_lock_input], eax |
5013 | mov [PID_lock_input], eax |
4996 | @@: |
5014 | @@: |
4997 | popfd |
5015 | popfd |
4998 | ret |
5016 | ret |
4999 | ;----------------------------------------------------------------------------- |
5017 | ;----------------------------------------------------------------------------- |
5000 | align 4 |
5018 | align 4 |
5001 | .7: |
5019 | .7: |
5002 | mov eax, [PID_lock_input] |
5020 | mov eax, [PID_lock_input] |
5003 | test eax, eax |
5021 | test eax, eax |
5004 | jz @f |
5022 | jz @f |
5005 | ; get current PID |
5023 | ; get current PID |
5006 | mov ebx, [CURRENT_TASK] |
5024 | mov ebx, [CURRENT_TASK] |
5007 | shl ebx, 5 |
5025 | shl ebx, 5 |
5008 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5026 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5009 | ; compare current lock input with current PID |
5027 | ; compare current lock input with current PID |
5010 | cmp ebx, eax |
5028 | cmp ebx, eax |
5011 | jne @f |
5029 | jne @f |
5012 | 5030 | ||
5013 | xor eax, eax |
5031 | xor eax, eax |
5014 | mov [PID_lock_input], eax |
5032 | mov [PID_lock_input], eax |
5015 | @@: |
5033 | @@: |
5016 | ret |
5034 | ret |
5017 | ;----------------------------------------------------------------------------- |
5035 | ;----------------------------------------------------------------------------- |
5018 | uglobal |
5036 | uglobal |
5019 | PID_lock_input dd 0x0 |
5037 | PID_lock_input dd 0x0 |
5020 | endg |
5038 | endg |
5021 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5039 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5022 | ;; 61 sys function. ;; |
5040 | ;; 61 sys function. ;; |
5023 | ;; in eax=61,ebx in [1..3] ;; |
5041 | ;; in eax=61,ebx in [1..3] ;; |
5024 | ;; out eax ;; |
5042 | ;; out eax ;; |
5025 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5043 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5026 | iglobal |
5044 | iglobal |
5027 | align 4 |
5045 | align 4 |
5028 | f61call: |
5046 | f61call: |
5029 | dd sys_gs.1 ; resolution |
5047 | dd sys_gs.1 ; resolution |
5030 | dd sys_gs.2 ; bits per pixel |
5048 | dd sys_gs.2 ; bits per pixel |
5031 | dd sys_gs.3 ; bytes per scanline |
5049 | dd sys_gs.3 ; bytes per scanline |
5032 | endg |
5050 | endg |
5033 | 5051 | ||
5034 | 5052 | ||
5035 | align 4 |
5053 | align 4 |
5036 | 5054 | ||
5037 | sys_gs: ; direct screen access |
5055 | sys_gs: ; direct screen access |
5038 | dec ebx |
5056 | dec ebx |
5039 | cmp ebx, 2 |
5057 | cmp ebx, 2 |
5040 | ja .not_support |
5058 | ja .not_support |
5041 | jmp dword [f61call+ebx*4] |
5059 | jmp dword [f61call+ebx*4] |
5042 | .not_support: |
5060 | .not_support: |
5043 | or [esp+32], dword -1 |
5061 | or [esp+32], dword -1 |
5044 | ret |
5062 | ret |
5045 | 5063 | ||
5046 | 5064 | ||
5047 | .1: ; resolution |
5065 | .1: ; resolution |
5048 | mov eax, [_display.width] |
5066 | mov eax, [_display.width] |
5049 | shl eax, 16 |
5067 | shl eax, 16 |
5050 | mov ax, word [_display.height] |
5068 | mov ax, word [_display.height] |
5051 | mov [esp+32], eax |
5069 | mov [esp+32], eax |
5052 | ret |
5070 | ret |
5053 | .2: ; bits per pixel |
5071 | .2: ; bits per pixel |
5054 | mov eax, [_display.bits_per_pixel] |
5072 | mov eax, [_display.bits_per_pixel] |
5055 | mov [esp+32], eax |
5073 | mov [esp+32], eax |
5056 | ret |
5074 | ret |
5057 | .3: ; bytes per scanline |
5075 | .3: ; bytes per scanline |
5058 | mov eax, [_display.lfb_pitch] |
5076 | mov eax, [_display.lfb_pitch] |
5059 | mov [esp+32], eax |
5077 | mov [esp+32], eax |
5060 | ret |
5078 | ret |
5061 | 5079 | ||
5062 | align 4 ; system functions |
5080 | align 4 ; system functions |
5063 | 5081 | ||
5064 | syscall_setpixel: ; SetPixel |
5082 | syscall_setpixel: ; SetPixel |
5065 | 5083 | ||
5066 | mov eax, ebx |
5084 | mov eax, ebx |
5067 | mov ebx, ecx |
5085 | mov ebx, ecx |
5068 | mov ecx, edx |
5086 | mov ecx, edx |
5069 | mov edx, [TASK_BASE] |
5087 | mov edx, [TASK_BASE] |
5070 | add eax, [edx-twdw+WDATA.box.left] |
5088 | add eax, [edx-twdw+WDATA.box.left] |
5071 | add ebx, [edx-twdw+WDATA.box.top] |
5089 | add ebx, [edx-twdw+WDATA.box.top] |
5072 | mov edi, [current_slot] |
5090 | mov edi, [current_slot] |
5073 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5091 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5074 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5092 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5075 | xor edi, edi ; no force |
5093 | xor edi, edi ; no force |
5076 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5094 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5077 | ; jmp [putpixel] |
5095 | ; jmp [putpixel] |
5078 | jmp __sys_putpixel |
5096 | jmp __sys_putpixel |
5079 | 5097 | ||
5080 | align 4 |
5098 | align 4 |
5081 | 5099 | ||
5082 | syscall_writetext: ; WriteText |
5100 | syscall_writetext: ; WriteText |
5083 | 5101 | ||
5084 | mov eax, [TASK_BASE] |
5102 | mov eax, [TASK_BASE] |
5085 | mov ebp, [eax-twdw+WDATA.box.left] |
5103 | mov ebp, [eax-twdw+WDATA.box.left] |
5086 | push esi |
5104 | push esi |
5087 | mov esi, [current_slot] |
5105 | mov esi, [current_slot] |
5088 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5106 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5089 | shl ebp, 16 |
5107 | shl ebp, 16 |
5090 | add ebp, [eax-twdw+WDATA.box.top] |
5108 | add ebp, [eax-twdw+WDATA.box.top] |
5091 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5109 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5092 | pop esi |
5110 | pop esi |
5093 | test ecx, 0x08000000 ; redirect the output to the user area |
5111 | test ecx, 0x08000000 ; redirect the output to the user area |
5094 | jnz @f |
5112 | jnz @f |
5095 | add ebx, ebp |
5113 | add ebx, ebp |
5096 | align 4 |
5114 | align 4 |
5097 | @@: |
5115 | @@: |
5098 | mov eax, edi |
5116 | mov eax, edi |
5099 | test ecx, 0x08000000 ; redirect the output to the user area |
5117 | test ecx, 0x08000000 ; redirect the output to the user area |
5100 | jnz dtext |
5118 | jnz dtext |
5101 | xor edi, edi |
5119 | xor edi, edi |
5102 | jmp dtext |
5120 | jmp dtext |
5103 | 5121 | ||
5104 | align 4 |
5122 | align 4 |
5105 | 5123 | ||
5106 | syscall_drawrect: ; DrawRect |
5124 | syscall_drawrect: ; DrawRect |
5107 | 5125 | ||
5108 | mov edi, edx ; color + gradient |
5126 | mov edi, edx ; color + gradient |
5109 | and edi, 0x80FFFFFF |
5127 | and edi, 0x80FFFFFF |
5110 | test bx, bx ; x.size |
5128 | test bx, bx ; x.size |
5111 | je .drectr |
5129 | je .drectr |
5112 | test cx, cx ; y.size |
5130 | test cx, cx ; y.size |
5113 | je .drectr |
5131 | je .drectr |
5114 | 5132 | ||
5115 | mov eax, ebx ; bad idea |
5133 | mov eax, ebx ; bad idea |
5116 | mov ebx, ecx |
5134 | mov ebx, ecx |
5117 | 5135 | ||
5118 | movzx ecx, ax ; ecx - x.size |
5136 | movzx ecx, ax ; ecx - x.size |
5119 | shr eax, 16 ; eax - x.coord |
5137 | shr eax, 16 ; eax - x.coord |
5120 | movzx edx, bx ; edx - y.size |
5138 | movzx edx, bx ; edx - y.size |
5121 | shr ebx, 16 ; ebx - y.coord |
5139 | shr ebx, 16 ; ebx - y.coord |
5122 | mov esi, [current_slot] |
5140 | mov esi, [current_slot] |
5123 | 5141 | ||
5124 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5142 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5125 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5143 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5126 | add ecx, eax |
5144 | add ecx, eax |
5127 | add edx, ebx |
5145 | add edx, ebx |
5128 | ; jmp [drawbar] |
5146 | ; jmp [drawbar] |
5129 | jmp vesa20_drawbar |
5147 | jmp vesa20_drawbar |
5130 | .drectr: |
5148 | .drectr: |
5131 | ret |
5149 | ret |
5132 | 5150 | ||
5133 | align 4 |
5151 | align 4 |
5134 | syscall_getscreensize: ; GetScreenSize |
5152 | syscall_getscreensize: ; GetScreenSize |
5135 | mov ax, word [_display.width] |
5153 | mov ax, word [_display.width] |
5136 | dec ax |
5154 | dec ax |
5137 | shl eax, 16 |
5155 | shl eax, 16 |
5138 | mov ax, word [_display.height] |
5156 | mov ax, word [_display.height] |
5139 | dec ax |
5157 | dec ax |
5140 | mov [esp + 32], eax |
5158 | mov [esp + 32], eax |
5141 | ret |
5159 | ret |
5142 | ;----------------------------------------------------------------------------- |
5160 | ;----------------------------------------------------------------------------- |
5143 | align 4 |
5161 | align 4 |
5144 | syscall_cdaudio: |
5162 | syscall_cdaudio: |
5145 | ; ECX - position of CD/DVD-drive |
5163 | ; ECX - position of CD/DVD-drive |
5146 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5164 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5147 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5165 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5148 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5166 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5149 | cmp ecx, 11 |
5167 | cmp ecx, 11 |
5150 | ja .exit |
5168 | ja .exit |
5151 | 5169 | ||
5152 | mov eax, ecx |
5170 | mov eax, ecx |
5153 | shr eax, 2 |
5171 | shr eax, 2 |
5154 | lea eax, [eax*5] |
5172 | lea eax, [eax*5] |
5155 | mov al, [eax+DRIVE_DATA+1] |
5173 | mov al, [eax+DRIVE_DATA+1] |
5156 | 5174 | ||
5157 | push ecx ebx |
5175 | push ecx ebx |
5158 | mov ebx, ecx |
5176 | mov ebx, ecx |
5159 | and ebx, 11b |
5177 | and ebx, 11b |
5160 | shl ebx, 1 |
5178 | shl ebx, 1 |
5161 | mov cl, 6 |
5179 | mov cl, 6 |
5162 | sub cl, bl |
5180 | sub cl, bl |
5163 | shr al, cl |
5181 | shr al, cl |
5164 | test al, 2 ; it's not an ATAPI device |
5182 | test al, 2 ; it's not an ATAPI device |
5165 | pop ebx ecx |
5183 | pop ebx ecx |
5166 | 5184 | ||
5167 | jz .exit |
5185 | jz .exit |
5168 | 5186 | ||
5169 | cmp ebx, 4 |
5187 | cmp ebx, 4 |
5170 | je .eject |
5188 | je .eject |
5171 | 5189 | ||
5172 | cmp ebx, 5 |
5190 | cmp ebx, 5 |
5173 | je .load |
5191 | je .load |
5174 | ;-------------------------------------- |
5192 | ;-------------------------------------- |
5175 | .exit: |
5193 | .exit: |
5176 | ret |
5194 | ret |
5177 | ;-------------------------------------- |
5195 | ;-------------------------------------- |
5178 | .load: |
5196 | .load: |
5179 | call .reserve |
5197 | call .reserve |
5180 | call LoadMedium |
5198 | call LoadMedium |
5181 | jmp .free |
5199 | jmp .free |
5182 | ;-------------------------------------- |
5200 | ;-------------------------------------- |
5183 | .eject: |
5201 | .eject: |
5184 | call .reserve |
5202 | call .reserve |
5185 | call clear_CD_cache |
5203 | call clear_CD_cache |
5186 | call allow_medium_removal |
5204 | call allow_medium_removal |
5187 | call EjectMedium |
5205 | call EjectMedium |
5188 | jmp .free |
5206 | jmp .free |
5189 | ;-------------------------------------- |
5207 | ;-------------------------------------- |
5190 | .reserve: |
5208 | .reserve: |
5191 | call reserve_cd |
5209 | call reserve_cd |
5192 | 5210 | ||
5193 | mov ebx, ecx |
5211 | mov ebx, ecx |
5194 | inc ebx |
5212 | inc ebx |
5195 | mov [cdpos], ebx |
5213 | mov [cdpos], ebx |
5196 | 5214 | ||
5197 | mov eax, ecx |
5215 | mov eax, ecx |
5198 | shr eax, 1 |
5216 | shr eax, 1 |
5199 | and eax, 1 |
5217 | and eax, 1 |
5200 | inc eax |
5218 | inc eax |
5201 | mov [ChannelNumber], ax |
5219 | mov [ChannelNumber], ax |
5202 | mov eax, ecx |
5220 | mov eax, ecx |
5203 | and eax, 1 |
5221 | and eax, 1 |
5204 | mov [DiskNumber], al |
5222 | mov [DiskNumber], al |
5205 | call reserve_cd_channel |
5223 | call reserve_cd_channel |
5206 | ret |
5224 | ret |
5207 | ;-------------------------------------- |
5225 | ;-------------------------------------- |
5208 | .free: |
5226 | .free: |
5209 | call free_cd_channel |
5227 | call free_cd_channel |
5210 | and [cd_status], 0 |
5228 | and [cd_status], 0 |
5211 | ret |
5229 | ret |
5212 | ;----------------------------------------------------------------------------- |
5230 | ;----------------------------------------------------------------------------- |
5213 | align 4 |
5231 | align 4 |
5214 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5232 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5215 | cmp ebx, [_display.width] |
5233 | cmp ebx, [_display.width] |
5216 | jb @f |
5234 | jb @f |
5217 | cmp ecx, [_display.height] |
5235 | cmp ecx, [_display.height] |
5218 | jb @f |
5236 | jb @f |
5219 | xor eax, eax |
5237 | xor eax, eax |
5220 | jmp .store |
5238 | jmp .store |
5221 | ;-------------------------------------- |
5239 | ;-------------------------------------- |
5222 | align 4 |
5240 | align 4 |
5223 | @@: |
5241 | @@: |
5224 | mov eax, [d_width_calc_area + ecx*4] |
5242 | mov eax, [d_width_calc_area + ecx*4] |
5225 | add eax, [_display.win_map] |
5243 | add eax, [_display.win_map] |
5226 | movzx eax, byte[eax+ebx] ; get value for current point |
5244 | movzx eax, byte[eax+ebx] ; get value for current point |
5227 | ;-------------------------------------- |
5245 | ;-------------------------------------- |
5228 | align 4 |
5246 | align 4 |
5229 | .store: |
5247 | .store: |
5230 | mov [esp + 32], eax |
5248 | mov [esp + 32], eax |
5231 | ret |
5249 | ret |
5232 | ;----------------------------------------------------------------------------- |
5250 | ;----------------------------------------------------------------------------- |
5233 | align 4 |
5251 | align 4 |
5234 | syscall_getpixel: ; GetPixel |
5252 | syscall_getpixel: ; GetPixel |
5235 | mov ecx, [_display.width] |
5253 | mov ecx, [_display.width] |
5236 | xor edx, edx |
5254 | xor edx, edx |
5237 | mov eax, ebx |
5255 | mov eax, ebx |
5238 | div ecx |
5256 | div ecx |
5239 | mov ebx, edx |
5257 | mov ebx, edx |
5240 | xchg eax, ebx |
5258 | xchg eax, ebx |
5241 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5259 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5242 | call dword [GETPIXEL]; eax - x, ebx - y |
5260 | call dword [GETPIXEL]; eax - x, ebx - y |
5243 | mov [esp + 32], ecx |
5261 | mov [esp + 32], ecx |
5244 | ret |
5262 | ret |
5245 | ;----------------------------------------------------------------------------- |
5263 | ;----------------------------------------------------------------------------- |
5246 | align 4 |
5264 | align 4 |
5247 | syscall_getarea: |
5265 | syscall_getarea: |
5248 | ;eax = 36 |
5266 | ;eax = 36 |
5249 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5267 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5250 | ;ecx = [size x]*65536 + [size y] |
5268 | ;ecx = [size x]*65536 + [size y] |
5251 | ;edx = [start x]*65536 + [start y] |
5269 | ;edx = [start x]*65536 + [start y] |
5252 | pushad |
5270 | pushad |
5253 | mov edi, ebx |
5271 | mov edi, ebx |
5254 | mov eax, edx |
5272 | mov eax, edx |
5255 | shr eax, 16 |
5273 | shr eax, 16 |
5256 | mov ebx, edx |
5274 | mov ebx, edx |
5257 | and ebx, 0xffff |
5275 | and ebx, 0xffff |
5258 | dec eax |
5276 | dec eax |
5259 | dec ebx |
5277 | dec ebx |
5260 | ; eax - x, ebx - y |
5278 | ; eax - x, ebx - y |
5261 | mov edx, ecx |
5279 | mov edx, ecx |
5262 | 5280 | ||
5263 | shr ecx, 16 |
5281 | shr ecx, 16 |
5264 | and edx, 0xffff |
5282 | and edx, 0xffff |
5265 | mov esi, ecx |
5283 | mov esi, ecx |
5266 | ; ecx - size x, edx - size y |
5284 | ; ecx - size x, edx - size y |
5267 | 5285 | ||
5268 | mov ebp, edx |
5286 | mov ebp, edx |
5269 | dec ebp |
5287 | dec ebp |
5270 | lea ebp, [ebp*3] |
5288 | lea ebp, [ebp*3] |
5271 | 5289 | ||
5272 | imul ebp, esi |
5290 | imul ebp, esi |
5273 | 5291 | ||
5274 | mov esi, ecx |
5292 | mov esi, ecx |
5275 | dec esi |
5293 | dec esi |
5276 | lea esi, [esi*3] |
5294 | lea esi, [esi*3] |
5277 | 5295 | ||
5278 | add ebp, esi |
5296 | add ebp, esi |
5279 | add ebp, edi |
5297 | add ebp, edi |
5280 | 5298 | ||
5281 | add ebx, edx |
5299 | add ebx, edx |
5282 | ;-------------------------------------- |
5300 | ;-------------------------------------- |
5283 | align 4 |
5301 | align 4 |
5284 | .start_y: |
5302 | .start_y: |
5285 | push ecx edx |
5303 | push ecx edx |
5286 | ;-------------------------------------- |
5304 | ;-------------------------------------- |
5287 | align 4 |
5305 | align 4 |
5288 | .start_x: |
5306 | .start_x: |
5289 | push eax ebx ecx |
5307 | push eax ebx ecx |
5290 | add eax, ecx |
5308 | add eax, ecx |
5291 | 5309 | ||
5292 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5310 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5293 | call dword [GETPIXEL]; eax - x, ebx - y |
5311 | call dword [GETPIXEL]; eax - x, ebx - y |
5294 | 5312 | ||
5295 | mov [ebp], cx |
5313 | mov [ebp], cx |
5296 | shr ecx, 16 |
5314 | shr ecx, 16 |
5297 | mov [ebp+2], cl |
5315 | mov [ebp+2], cl |
5298 | 5316 | ||
5299 | pop ecx ebx eax |
5317 | pop ecx ebx eax |
5300 | sub ebp, 3 |
5318 | sub ebp, 3 |
5301 | dec ecx |
5319 | dec ecx |
5302 | jnz .start_x |
5320 | jnz .start_x |
5303 | pop edx ecx |
5321 | pop edx ecx |
5304 | dec ebx |
5322 | dec ebx |
5305 | dec edx |
5323 | dec edx |
5306 | jnz .start_y |
5324 | jnz .start_y |
5307 | popad |
5325 | popad |
5308 | ret |
5326 | ret |
5309 | ;----------------------------------------------------------------------------- |
5327 | ;----------------------------------------------------------------------------- |
5310 | align 4 |
5328 | align 4 |
5311 | syscall_putarea_backgr: |
5329 | syscall_putarea_backgr: |
5312 | ;eax = 25 |
5330 | ;eax = 25 |
5313 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5331 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5314 | ;ecx = [size x]*65536 + [size y] |
5332 | ;ecx = [size x]*65536 + [size y] |
5315 | ;edx = [start x]*65536 + [start y] |
5333 | ;edx = [start x]*65536 + [start y] |
5316 | pushad |
5334 | pushad |
5317 | mov edi, ebx |
5335 | mov edi, ebx |
5318 | mov eax, edx |
5336 | mov eax, edx |
5319 | shr eax, 16 |
5337 | shr eax, 16 |
5320 | mov ebx, edx |
5338 | mov ebx, edx |
5321 | and ebx, 0xffff |
5339 | and ebx, 0xffff |
5322 | dec eax |
5340 | dec eax |
5323 | dec ebx |
5341 | dec ebx |
5324 | ; eax - x, ebx - y |
5342 | ; eax - x, ebx - y |
5325 | mov edx, ecx |
5343 | mov edx, ecx |
5326 | shr ecx, 16 |
5344 | shr ecx, 16 |
5327 | and edx, 0xffff |
5345 | and edx, 0xffff |
5328 | mov esi, ecx |
5346 | mov esi, ecx |
5329 | ; ecx - size x, edx - size y |
5347 | ; ecx - size x, edx - size y |
5330 | mov ebp, edx |
5348 | mov ebp, edx |
5331 | dec ebp |
5349 | dec ebp |
5332 | shl ebp, 2 |
5350 | shl ebp, 2 |
5333 | 5351 | ||
5334 | imul ebp, esi |
5352 | imul ebp, esi |
5335 | 5353 | ||
5336 | mov esi, ecx |
5354 | mov esi, ecx |
5337 | dec esi |
5355 | dec esi |
5338 | shl esi, 2 |
5356 | shl esi, 2 |
5339 | 5357 | ||
5340 | add ebp, esi |
5358 | add ebp, esi |
5341 | add ebp, edi |
5359 | add ebp, edi |
5342 | 5360 | ||
5343 | add ebx, edx |
5361 | add ebx, edx |
5344 | ;-------------------------------------- |
5362 | ;-------------------------------------- |
5345 | align 4 |
5363 | align 4 |
5346 | .start_y: |
5364 | .start_y: |
5347 | push ecx edx |
5365 | push ecx edx |
5348 | ;-------------------------------------- |
5366 | ;-------------------------------------- |
5349 | align 4 |
5367 | align 4 |
5350 | .start_x: |
5368 | .start_x: |
5351 | push eax ecx |
5369 | push eax ecx |
5352 | add eax, ecx |
5370 | add eax, ecx |
5353 | 5371 | ||
5354 | mov ecx, [ebp] |
5372 | mov ecx, [ebp] |
5355 | rol ecx, 8 |
5373 | rol ecx, 8 |
5356 | test cl, cl ; transparensy = 0 |
5374 | test cl, cl ; transparensy = 0 |
5357 | jz .no_put |
5375 | jz .no_put |
5358 | 5376 | ||
5359 | xor cl, cl |
5377 | xor cl, cl |
5360 | ror ecx, 8 |
5378 | ror ecx, 8 |
5361 | 5379 | ||
5362 | pushad |
5380 | pushad |
5363 | mov edx, [d_width_calc_area + ebx*4] |
5381 | mov edx, [d_width_calc_area + ebx*4] |
5364 | add edx, [_display.win_map] |
5382 | add edx, [_display.win_map] |
5365 | movzx edx, byte [eax+edx] |
5383 | movzx edx, byte [eax+edx] |
5366 | cmp dl, byte 1 |
5384 | cmp dl, byte 1 |
5367 | jne @f |
5385 | jne @f |
5368 | 5386 | ||
5369 | call dword [PUTPIXEL]; eax - x, ebx - y |
5387 | call dword [PUTPIXEL]; eax - x, ebx - y |
5370 | ;-------------------------------------- |
5388 | ;-------------------------------------- |
5371 | align 4 |
5389 | align 4 |
5372 | @@: |
5390 | @@: |
5373 | popad |
5391 | popad |
5374 | ;-------------------------------------- |
5392 | ;-------------------------------------- |
5375 | align 4 |
5393 | align 4 |
5376 | .no_put: |
5394 | .no_put: |
5377 | pop ecx eax |
5395 | pop ecx eax |
5378 | 5396 | ||
5379 | sub ebp, 4 |
5397 | sub ebp, 4 |
5380 | dec ecx |
5398 | dec ecx |
5381 | jnz .start_x |
5399 | jnz .start_x |
5382 | 5400 | ||
5383 | pop edx ecx |
5401 | pop edx ecx |
5384 | dec ebx |
5402 | dec ebx |
5385 | dec edx |
5403 | dec edx |
5386 | jnz .start_y |
5404 | jnz .start_y |
5387 | 5405 | ||
5388 | popad |
5406 | popad |
5389 | ret |
5407 | ret |
5390 | ;----------------------------------------------------------------------------- |
5408 | ;----------------------------------------------------------------------------- |
5391 | align 4 |
5409 | align 4 |
5392 | syscall_drawline: ; DrawLine |
5410 | syscall_drawline: ; DrawLine |
5393 | 5411 | ||
5394 | mov edi, [TASK_BASE] |
5412 | mov edi, [TASK_BASE] |
5395 | movzx eax, word[edi-twdw+WDATA.box.left] |
5413 | movzx eax, word[edi-twdw+WDATA.box.left] |
5396 | mov ebp, eax |
5414 | mov ebp, eax |
5397 | mov esi, [current_slot] |
5415 | mov esi, [current_slot] |
5398 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5416 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5399 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5417 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5400 | add ebp, ebx |
5418 | add ebp, ebx |
5401 | shl eax, 16 |
5419 | shl eax, 16 |
5402 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5420 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5403 | add eax, ebp |
5421 | add eax, ebp |
5404 | mov ebp, ebx |
5422 | mov ebp, ebx |
5405 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5423 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5406 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5424 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5407 | add ebp, ecx |
5425 | add ebp, ecx |
5408 | shl ebx, 16 |
5426 | shl ebx, 16 |
5409 | xor edi, edi |
5427 | xor edi, edi |
5410 | add ebx, ebp |
5428 | add ebx, ebp |
5411 | mov ecx, edx |
5429 | mov ecx, edx |
5412 | ; jmp [draw_line] |
5430 | ; jmp [draw_line] |
5413 | jmp __sys_draw_line |
5431 | jmp __sys_draw_line |
5414 | 5432 | ||
5415 | 5433 | ||
5416 | align 4 |
5434 | align 4 |
5417 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5435 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5418 | 5436 | ||
5419 | call r_f_port_area |
5437 | call r_f_port_area |
5420 | mov [esp+32], eax |
5438 | mov [esp+32], eax |
5421 | ret |
5439 | ret |
5422 | 5440 | ||
5423 | align 4 |
5441 | align 4 |
5424 | syscall_threads: ; CreateThreads |
5442 | syscall_threads: ; CreateThreads |
5425 | ; |
5443 | ; |
5426 | ; ecx=thread entry point |
5444 | ; ecx=thread entry point |
5427 | ; edx=thread stack pointer |
5445 | ; edx=thread stack pointer |
5428 | ; |
5446 | ; |
5429 | ; on return : eax = pid |
5447 | ; on return : eax = pid |
5430 | 5448 | ||
5431 | xor ebx, ebx |
5449 | xor ebx, ebx |
5432 | call new_sys_threads |
5450 | call new_sys_threads |
5433 | 5451 | ||
5434 | mov [esp+32], eax |
5452 | mov [esp+32], eax |
5435 | ret |
5453 | ret |
5436 | 5454 | ||
5437 | align 4 |
5455 | align 4 |
5438 | 5456 | ||
5439 | paleholder: |
5457 | paleholder: |
5440 | ret |
5458 | ret |
5441 | ;------------------------------------------------------------------------------ |
5459 | ;------------------------------------------------------------------------------ |
5442 | align 4 |
5460 | align 4 |
5443 | calculate_fast_getting_offset_for_WinMapAddress: |
5461 | calculate_fast_getting_offset_for_WinMapAddress: |
5444 | ; calculate data area for fast getting offset to _WinMapAddress |
5462 | ; calculate data area for fast getting offset to _WinMapAddress |
5445 | xor eax, eax |
5463 | xor eax, eax |
5446 | mov ecx, [_display.height] |
5464 | mov ecx, [_display.height] |
5447 | mov edi, d_width_calc_area |
5465 | mov edi, d_width_calc_area |
5448 | cld |
5466 | cld |
5449 | @@: |
5467 | @@: |
5450 | stosd |
5468 | stosd |
5451 | add eax, [_display.width] |
5469 | add eax, [_display.width] |
5452 | dec ecx |
5470 | dec ecx |
5453 | jnz @r |
5471 | jnz @r |
5454 | ret |
5472 | ret |
5455 | ;------------------------------------------------------------------------------ |
5473 | ;------------------------------------------------------------------------------ |
5456 | align 4 |
5474 | align 4 |
5457 | calculate_fast_getting_offset_for_LFB: |
5475 | calculate_fast_getting_offset_for_LFB: |
5458 | ; calculate data area for fast getting offset to LFB |
5476 | ; calculate data area for fast getting offset to LFB |
5459 | xor eax, eax |
5477 | xor eax, eax |
5460 | mov ecx, [_display.height] |
5478 | mov ecx, [_display.height] |
5461 | mov edi, BPSLine_calc_area |
5479 | mov edi, BPSLine_calc_area |
5462 | cld |
5480 | cld |
5463 | @@: |
5481 | @@: |
5464 | stosd |
5482 | stosd |
5465 | add eax, [_display.lfb_pitch] |
5483 | add eax, [_display.lfb_pitch] |
5466 | dec ecx |
5484 | dec ecx |
5467 | jnz @r |
5485 | jnz @r |
5468 | ret |
5486 | ret |
5469 | ;------------------------------------------------------------------------------ |
5487 | ;------------------------------------------------------------------------------ |
5470 | align 4 |
5488 | align 4 |
5471 | set_screen: |
5489 | set_screen: |
5472 | ; in: |
5490 | ; in: |
5473 | ; eax - new Screen_Max_X |
5491 | ; eax - new Screen_Max_X |
5474 | ; ecx - new BytesPerScanLine |
5492 | ; ecx - new BytesPerScanLine |
5475 | ; edx - new Screen_Max_Y |
5493 | ; edx - new Screen_Max_Y |
5476 | 5494 | ||
5477 | pushfd |
5495 | pushfd |
5478 | cli |
5496 | cli |
5479 | 5497 | ||
5480 | mov [_display.lfb_pitch], ecx |
5498 | mov [_display.lfb_pitch], ecx |
5481 | 5499 | ||
5482 | mov [screen_workarea.right], eax |
5500 | mov [screen_workarea.right], eax |
5483 | mov [screen_workarea.bottom], edx |
5501 | mov [screen_workarea.bottom], edx |
5484 | 5502 | ||
5485 | push ebx |
5503 | push ebx |
5486 | push esi |
5504 | push esi |
5487 | push edi |
5505 | push edi |
5488 | 5506 | ||
5489 | pushad |
5507 | pushad |
5490 | 5508 | ||
5491 | cmp [do_not_touch_winmap], 1 |
5509 | cmp [do_not_touch_winmap], 1 |
5492 | je @f |
5510 | je @f |
5493 | 5511 | ||
5494 | stdcall kernel_free, [_display.win_map] |
5512 | stdcall kernel_free, [_display.win_map] |
5495 | 5513 | ||
5496 | mov eax, [_display.width] |
5514 | mov eax, [_display.width] |
5497 | mul [_display.height] |
5515 | mul [_display.height] |
5498 | mov [_display.win_map_size], eax |
5516 | mov [_display.win_map_size], eax |
5499 | 5517 | ||
5500 | stdcall kernel_alloc, eax |
5518 | stdcall kernel_alloc, eax |
5501 | mov [_display.win_map], eax |
5519 | mov [_display.win_map], eax |
5502 | test eax, eax |
5520 | test eax, eax |
5503 | jz .epic_fail |
5521 | jz .epic_fail |
5504 | ; store for f.18.24 |
5522 | ; store for f.18.24 |
5505 | mov eax, [_display.width] |
5523 | mov eax, [_display.width] |
5506 | mov [display_width_standard], eax |
5524 | mov [display_width_standard], eax |
5507 | 5525 | ||
5508 | mov eax, [_display.height] |
5526 | mov eax, [_display.height] |
5509 | mov [display_height_standard], eax |
5527 | mov [display_height_standard], eax |
5510 | @@: |
5528 | @@: |
5511 | call calculate_fast_getting_offset_for_WinMapAddress |
5529 | call calculate_fast_getting_offset_for_WinMapAddress |
5512 | ; for Qemu or non standart video cards |
5530 | ; for Qemu or non standart video cards |
5513 | ; Unfortunately [BytesPerScanLine] does not always |
5531 | ; Unfortunately [BytesPerScanLine] does not always |
5514 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5532 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5515 | call calculate_fast_getting_offset_for_LFB |
5533 | call calculate_fast_getting_offset_for_LFB |
5516 | popad |
5534 | popad |
5517 | 5535 | ||
5518 | call repos_windows |
5536 | call repos_windows |
5519 | xor eax, eax |
5537 | xor eax, eax |
5520 | xor ebx, ebx |
5538 | xor ebx, ebx |
5521 | mov ecx, [_display.width] |
5539 | mov ecx, [_display.width] |
5522 | mov edx, [_display.height] |
5540 | mov edx, [_display.height] |
5523 | dec ecx |
5541 | dec ecx |
5524 | dec edx |
5542 | dec edx |
5525 | call calculatescreen |
5543 | call calculatescreen |
5526 | pop edi |
5544 | pop edi |
5527 | pop esi |
5545 | pop esi |
5528 | pop ebx |
5546 | pop ebx |
5529 | 5547 | ||
5530 | popfd |
5548 | popfd |
5531 | ret |
5549 | ret |
5532 | 5550 | ||
5533 | .epic_fail: |
5551 | .epic_fail: |
5534 | hlt ; Houston, we've had a problem |
5552 | hlt ; Houston, we've had a problem |
5535 | 5553 | ||
5536 | ; --------------- APM --------------------- |
5554 | ; --------------- APM --------------------- |
5537 | uglobal |
5555 | uglobal |
5538 | apm_entry dp 0 |
5556 | apm_entry dp 0 |
5539 | apm_vf dd 0 |
5557 | apm_vf dd 0 |
5540 | endg |
5558 | endg |
5541 | 5559 | ||
5542 | align 4 |
5560 | align 4 |
5543 | sys_apm: |
5561 | sys_apm: |
5544 | xor eax, eax |
5562 | xor eax, eax |
5545 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5563 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5546 | jne @f |
5564 | jne @f |
5547 | inc eax |
5565 | inc eax |
5548 | or dword [esp + 44], eax ; error |
5566 | or dword [esp + 44], eax ; error |
5549 | add eax, 7 |
5567 | add eax, 7 |
5550 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5568 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5551 | ret |
5569 | ret |
5552 | 5570 | ||
5553 | @@: |
5571 | @@: |
5554 | ; xchg eax, ecx |
5572 | ; xchg eax, ecx |
5555 | ; xchg ebx, ecx |
5573 | ; xchg ebx, ecx |
5556 | 5574 | ||
5557 | cmp dx, 3 |
5575 | cmp dx, 3 |
5558 | ja @f |
5576 | ja @f |
5559 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5577 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5560 | mov eax, [apm_vf] |
5578 | mov eax, [apm_vf] |
5561 | mov [esp + 32], eax |
5579 | mov [esp + 32], eax |
5562 | shr eax, 16 |
5580 | shr eax, 16 |
5563 | mov [esp + 28], eax |
5581 | mov [esp + 28], eax |
5564 | ret |
5582 | ret |
5565 | 5583 | ||
5566 | @@: |
5584 | @@: |
5567 | 5585 | ||
5568 | mov esi, [master_tab+(OS_BASE shr 20)] |
5586 | mov esi, [master_tab+(OS_BASE shr 20)] |
5569 | xchg [master_tab], esi |
5587 | xchg [master_tab], esi |
5570 | push esi |
5588 | push esi |
5571 | mov edi, cr3 |
5589 | mov edi, cr3 |
5572 | mov cr3, edi ;flush TLB |
5590 | mov cr3, edi ;flush TLB |
5573 | 5591 | ||
5574 | call pword [apm_entry] ;call APM BIOS |
5592 | call pword [apm_entry] ;call APM BIOS |
5575 | 5593 | ||
5576 | xchg eax, [esp] |
5594 | xchg eax, [esp] |
5577 | mov [master_tab], eax |
5595 | mov [master_tab], eax |
5578 | mov eax, cr3 |
5596 | mov eax, cr3 |
5579 | mov cr3, eax |
5597 | mov cr3, eax |
5580 | pop eax |
5598 | pop eax |
5581 | 5599 | ||
5582 | mov [esp + 4 ], edi |
5600 | mov [esp + 4 ], edi |
5583 | mov [esp + 8], esi |
5601 | mov [esp + 8], esi |
5584 | mov [esp + 20], ebx |
5602 | mov [esp + 20], ebx |
5585 | mov [esp + 24], edx |
5603 | mov [esp + 24], edx |
5586 | mov [esp + 28], ecx |
5604 | mov [esp + 28], ecx |
5587 | mov [esp + 32], eax |
5605 | mov [esp + 32], eax |
5588 | setc al |
5606 | setc al |
5589 | and [esp + 44], byte 0xfe |
5607 | and [esp + 44], byte 0xfe |
5590 | or [esp + 44], al |
5608 | or [esp + 44], al |
5591 | ret |
5609 | ret |
5592 | ; ----------------------------------------- |
5610 | ; ----------------------------------------- |
5593 | 5611 | ||
5594 | align 4 |
5612 | align 4 |
5595 | 5613 | ||
5596 | undefined_syscall: ; Undefined system call |
5614 | undefined_syscall: ; Undefined system call |
5597 | mov [esp + 32], dword -1 |
5615 | mov [esp + 32], dword -1 |
5598 | ret |
5616 | ret |
5599 | 5617 | ||
5600 | align 4 |
5618 | align 4 |
5601 | system_shutdown: ; shut down the system |
5619 | system_shutdown: ; shut down the system |
5602 | 5620 | ||
5603 | cmp byte [BOOT_VARS+0x9030], 1 |
5621 | cmp byte [BOOT_VARS+0x9030], 1 |
5604 | jne @F |
5622 | jne @F |
5605 | ret |
5623 | ret |
5606 | @@: |
5624 | @@: |
5607 | call stop_all_services |
5625 | call stop_all_services |
5608 | 5626 | ||
5609 | yes_shutdown_param: |
5627 | yes_shutdown_param: |
5610 | ; Shutdown other CPUs, if initialized |
5628 | ; Shutdown other CPUs, if initialized |
5611 | cmp [ap_initialized], 0 |
5629 | cmp [ap_initialized], 0 |
5612 | jz .no_shutdown_cpus |
5630 | jz .no_shutdown_cpus |
5613 | mov edi, [LAPIC_BASE] |
5631 | mov edi, [LAPIC_BASE] |
5614 | add edi, 300h |
5632 | add edi, 300h |
5615 | mov esi, smpt+4 |
5633 | mov esi, smpt+4 |
5616 | mov ebx, [cpu_count] |
5634 | mov ebx, [cpu_count] |
5617 | dec ebx |
5635 | dec ebx |
5618 | .shutdown_cpus_loop: |
5636 | .shutdown_cpus_loop: |
5619 | lodsd |
5637 | lodsd |
5620 | push esi |
5638 | push esi |
5621 | xor esi, esi |
5639 | xor esi, esi |
5622 | inc esi |
5640 | inc esi |
5623 | shl eax, 24 |
5641 | shl eax, 24 |
5624 | mov [edi+10h], eax |
5642 | mov [edi+10h], eax |
5625 | ; assert INIT IPI |
5643 | ; assert INIT IPI |
5626 | mov dword [edi], 0C500h |
5644 | mov dword [edi], 0C500h |
5627 | call delay_ms |
5645 | call delay_ms |
5628 | @@: |
5646 | @@: |
5629 | test dword [edi], 1000h |
5647 | test dword [edi], 1000h |
5630 | jnz @b |
5648 | jnz @b |
5631 | ; deassert INIT IPI |
5649 | ; deassert INIT IPI |
5632 | mov dword [edi], 8500h |
5650 | mov dword [edi], 8500h |
5633 | call delay_ms |
5651 | call delay_ms |
5634 | @@: |
5652 | @@: |
5635 | test dword [edi], 1000h |
5653 | test dword [edi], 1000h |
5636 | jnz @b |
5654 | jnz @b |
5637 | ; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
5655 | ; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
5638 | pop esi |
5656 | pop esi |
5639 | dec ebx |
5657 | dec ebx |
5640 | jnz .shutdown_cpus_loop |
5658 | jnz .shutdown_cpus_loop |
5641 | .no_shutdown_cpus: |
5659 | .no_shutdown_cpus: |
5642 | 5660 | ||
5643 | cli |
5661 | cli |
5644 | 5662 | ||
5645 | if ~ defined extended_primary_loader |
5663 | if ~ defined extended_primary_loader |
5646 | ; load kernel.mnt to 0x7000:0 |
5664 | ; load kernel.mnt to 0x7000:0 |
5647 | mov ebx, kernel_file_load |
5665 | mov ebx, kernel_file_load |
5648 | pushad |
5666 | pushad |
5649 | call file_system_lfn |
5667 | call file_system_lfn |
5650 | popad |
5668 | popad |
5651 | 5669 | ||
5652 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5670 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5653 | mov edi, OS_BASE+0x40000 |
5671 | mov edi, OS_BASE+0x40000 |
5654 | mov ecx, 1000 |
5672 | mov ecx, 1000 |
5655 | rep movsb |
5673 | rep movsb |
5656 | end if |
5674 | end if |
5657 | 5675 | ||
5658 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5676 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5659 | ; mov edi, OS_BASE |
5677 | ; mov edi, OS_BASE |
5660 | ; mov ecx, 0x10000/4 |
5678 | ; mov ecx, 0x10000/4 |
5661 | ; cld |
5679 | ; cld |
5662 | ; rep movsd |
5680 | ; rep movsd |
5663 | 5681 | ||
5664 | call IRQ_mask_all |
5682 | call IRQ_mask_all |
5665 | 5683 | ||
5666 | cmp byte [OS_BASE + 0x9030], 2 |
5684 | cmp byte [OS_BASE + 0x9030], 2 |
5667 | jnz no_acpi_power_off |
5685 | jnz no_acpi_power_off |
5668 | 5686 | ||
5669 | ; scan for RSDP |
5687 | ; scan for RSDP |
5670 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5688 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5671 | movzx eax, word [OS_BASE + 0x40E] |
5689 | movzx eax, word [OS_BASE + 0x40E] |
5672 | shl eax, 4 |
5690 | shl eax, 4 |
5673 | jz @f |
5691 | jz @f |
5674 | mov ecx, 1024/16 |
5692 | mov ecx, 1024/16 |
5675 | call scan_rsdp |
5693 | call scan_rsdp |
5676 | jnc .rsdp_found |
5694 | jnc .rsdp_found |
5677 | @@: |
5695 | @@: |
5678 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5696 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5679 | mov eax, 0xE0000 |
5697 | mov eax, 0xE0000 |
5680 | mov ecx, 0x2000 |
5698 | mov ecx, 0x2000 |
5681 | call scan_rsdp |
5699 | call scan_rsdp |
5682 | jc no_acpi_power_off |
5700 | jc no_acpi_power_off |
5683 | .rsdp_found: |
5701 | .rsdp_found: |
5684 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5702 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5685 | mov ebp, [ipc_tmp] |
5703 | mov ebp, [ipc_tmp] |
5686 | stdcall map_page, ebp, esi, PG_READ |
5704 | stdcall map_page, ebp, esi, PG_READ |
5687 | lea eax, [esi+1000h] |
5705 | lea eax, [esi+1000h] |
5688 | lea edx, [ebp+1000h] |
5706 | lea edx, [ebp+1000h] |
5689 | stdcall map_page, edx, eax, PG_READ |
5707 | stdcall map_page, edx, eax, PG_READ |
5690 | and esi, 0xFFF |
5708 | and esi, 0xFFF |
5691 | add esi, ebp |
5709 | add esi, ebp |
5692 | cmp dword [esi], 'RSDT' |
5710 | cmp dword [esi], 'RSDT' |
5693 | jnz no_acpi_power_off |
5711 | jnz no_acpi_power_off |
5694 | mov ecx, [esi+4] |
5712 | mov ecx, [esi+4] |
5695 | sub ecx, 24h |
5713 | sub ecx, 24h |
5696 | jbe no_acpi_power_off |
5714 | jbe no_acpi_power_off |
5697 | shr ecx, 2 |
5715 | shr ecx, 2 |
5698 | add esi, 24h |
5716 | add esi, 24h |
5699 | .scan_fadt: |
5717 | .scan_fadt: |
5700 | lodsd |
5718 | lodsd |
5701 | mov ebx, eax |
5719 | mov ebx, eax |
5702 | lea eax, [ebp+2000h] |
5720 | lea eax, [ebp+2000h] |
5703 | stdcall map_page, eax, ebx, PG_READ |
5721 | stdcall map_page, eax, ebx, PG_READ |
5704 | lea eax, [ebp+3000h] |
5722 | lea eax, [ebp+3000h] |
5705 | add ebx, 0x1000 |
5723 | add ebx, 0x1000 |
5706 | stdcall map_page, eax, ebx, PG_READ |
5724 | stdcall map_page, eax, ebx, PG_READ |
5707 | and ebx, 0xFFF |
5725 | and ebx, 0xFFF |
5708 | lea ebx, [ebx+ebp+2000h] |
5726 | lea ebx, [ebx+ebp+2000h] |
5709 | cmp dword [ebx], 'FACP' |
5727 | cmp dword [ebx], 'FACP' |
5710 | jz .fadt_found |
5728 | jz .fadt_found |
5711 | loop .scan_fadt |
5729 | loop .scan_fadt |
5712 | jmp no_acpi_power_off |
5730 | jmp no_acpi_power_off |
5713 | .fadt_found: |
5731 | .fadt_found: |
5714 | ; ebx is linear address of FADT |
5732 | ; ebx is linear address of FADT |
5715 | mov edi, [ebx+40] ; physical address of the DSDT |
5733 | mov edi, [ebx+40] ; physical address of the DSDT |
5716 | lea eax, [ebp+4000h] |
5734 | lea eax, [ebp+4000h] |
5717 | stdcall map_page, eax, edi, PG_READ |
5735 | stdcall map_page, eax, edi, PG_READ |
5718 | lea eax, [ebp+5000h] |
5736 | lea eax, [ebp+5000h] |
5719 | lea esi, [edi+0x1000] |
5737 | lea esi, [edi+0x1000] |
5720 | stdcall map_page, eax, esi, PG_READ |
5738 | stdcall map_page, eax, esi, PG_READ |
5721 | and esi, 0xFFF |
5739 | and esi, 0xFFF |
5722 | sub edi, esi |
5740 | sub edi, esi |
5723 | cmp dword [esi+ebp+4000h], 'DSDT' |
5741 | cmp dword [esi+ebp+4000h], 'DSDT' |
5724 | jnz no_acpi_power_off |
5742 | jnz no_acpi_power_off |
5725 | mov eax, [esi+ebp+4004h] ; DSDT length |
5743 | mov eax, [esi+ebp+4004h] ; DSDT length |
5726 | sub eax, 36+4 |
5744 | sub eax, 36+4 |
5727 | jbe no_acpi_power_off |
5745 | jbe no_acpi_power_off |
5728 | add esi, 36 |
5746 | add esi, 36 |
5729 | .scan_dsdt: |
5747 | .scan_dsdt: |
5730 | cmp dword [esi+ebp+4000h], '_S5_' |
5748 | cmp dword [esi+ebp+4000h], '_S5_' |
5731 | jnz .scan_dsdt_cont |
5749 | jnz .scan_dsdt_cont |
5732 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5750 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5733 | jnz .scan_dsdt_cont |
5751 | jnz .scan_dsdt_cont |
5734 | mov dl, [esi+ebp+4000h+6] |
5752 | mov dl, [esi+ebp+4000h+6] |
5735 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5753 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5736 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5754 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5737 | ja .scan_dsdt_cont |
5755 | ja .scan_dsdt_cont |
5738 | cmp dl, 1 |
5756 | cmp dl, 1 |
5739 | jb .scan_dsdt_cont |
5757 | jb .scan_dsdt_cont |
5740 | lea esi, [esi+ebp+4000h+7] |
5758 | lea esi, [esi+ebp+4000h+7] |
5741 | xor ecx, ecx |
5759 | xor ecx, ecx |
5742 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5760 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5743 | jz @f |
5761 | jz @f |
5744 | cmp byte [esi], 0xA |
5762 | cmp byte [esi], 0xA |
5745 | jnz no_acpi_power_off |
5763 | jnz no_acpi_power_off |
5746 | inc esi |
5764 | inc esi |
5747 | mov cl, [esi] |
5765 | mov cl, [esi] |
5748 | @@: |
5766 | @@: |
5749 | inc esi |
5767 | inc esi |
5750 | cmp dl, 2 |
5768 | cmp dl, 2 |
5751 | jb @f |
5769 | jb @f |
5752 | cmp byte [esi], 0 |
5770 | cmp byte [esi], 0 |
5753 | jz @f |
5771 | jz @f |
5754 | cmp byte [esi], 0xA |
5772 | cmp byte [esi], 0xA |
5755 | jnz no_acpi_power_off |
5773 | jnz no_acpi_power_off |
5756 | inc esi |
5774 | inc esi |
5757 | mov ch, [esi] |
5775 | mov ch, [esi] |
5758 | @@: |
5776 | @@: |
5759 | jmp do_acpi_power_off |
5777 | jmp do_acpi_power_off |
5760 | .scan_dsdt_cont: |
5778 | .scan_dsdt_cont: |
5761 | inc esi |
5779 | inc esi |
5762 | cmp esi, 0x1000 |
5780 | cmp esi, 0x1000 |
5763 | jb @f |
5781 | jb @f |
5764 | sub esi, 0x1000 |
5782 | sub esi, 0x1000 |
5765 | add edi, 0x1000 |
5783 | add edi, 0x1000 |
5766 | push eax |
5784 | push eax |
5767 | lea eax, [ebp+4000h] |
5785 | lea eax, [ebp+4000h] |
5768 | stdcall map_page, eax, edi, PG_READ |
5786 | stdcall map_page, eax, edi, PG_READ |
5769 | push PG_READ |
5787 | push PG_READ |
5770 | lea eax, [edi+1000h] |
5788 | lea eax, [edi+1000h] |
5771 | push eax |
5789 | push eax |
5772 | lea eax, [ebp+5000h] |
5790 | lea eax, [ebp+5000h] |
5773 | push eax |
5791 | push eax |
5774 | stdcall map_page |
5792 | stdcall map_page |
5775 | pop eax |
5793 | pop eax |
5776 | @@: |
5794 | @@: |
5777 | dec eax |
5795 | dec eax |
5778 | jnz .scan_dsdt |
5796 | jnz .scan_dsdt |
5779 | jmp no_acpi_power_off |
5797 | jmp no_acpi_power_off |
5780 | do_acpi_power_off: |
5798 | do_acpi_power_off: |
5781 | mov edx, [ebx+48] |
5799 | mov edx, [ebx+48] |
5782 | test edx, edx |
5800 | test edx, edx |
5783 | jz .nosmi |
5801 | jz .nosmi |
5784 | mov al, [ebx+52] |
5802 | mov al, [ebx+52] |
5785 | out dx, al |
5803 | out dx, al |
5786 | mov edx, [ebx+64] |
5804 | mov edx, [ebx+64] |
5787 | @@: |
5805 | @@: |
5788 | in ax, dx |
5806 | in ax, dx |
5789 | test al, 1 |
5807 | test al, 1 |
5790 | jz @b |
5808 | jz @b |
5791 | .nosmi: |
5809 | .nosmi: |
5792 | and cx, 0x0707 |
5810 | and cx, 0x0707 |
5793 | shl cx, 2 |
5811 | shl cx, 2 |
5794 | or cx, 0x2020 |
5812 | or cx, 0x2020 |
5795 | mov edx, [ebx+64] |
5813 | mov edx, [ebx+64] |
5796 | in ax, dx |
5814 | in ax, dx |
5797 | and ax, 203h |
5815 | and ax, 203h |
5798 | or ah, cl |
5816 | or ah, cl |
5799 | out dx, ax |
5817 | out dx, ax |
5800 | mov edx, [ebx+68] |
5818 | mov edx, [ebx+68] |
5801 | test edx, edx |
5819 | test edx, edx |
5802 | jz @f |
5820 | jz @f |
5803 | in ax, dx |
5821 | in ax, dx |
5804 | and ax, 203h |
5822 | and ax, 203h |
5805 | or ah, ch |
5823 | or ah, ch |
5806 | out dx, ax |
5824 | out dx, ax |
5807 | @@: |
5825 | @@: |
5808 | jmp $ |
5826 | jmp $ |
5809 | 5827 | ||
5810 | 5828 | ||
5811 | scan_rsdp: |
5829 | scan_rsdp: |
5812 | add eax, OS_BASE |
5830 | add eax, OS_BASE |
5813 | .s: |
5831 | .s: |
5814 | cmp dword [eax], 'RSD ' |
5832 | cmp dword [eax], 'RSD ' |
5815 | jnz .n |
5833 | jnz .n |
5816 | cmp dword [eax+4], 'PTR ' |
5834 | cmp dword [eax+4], 'PTR ' |
5817 | jnz .n |
5835 | jnz .n |
5818 | xor edx, edx |
5836 | xor edx, edx |
5819 | xor esi, esi |
5837 | xor esi, esi |
5820 | @@: |
5838 | @@: |
5821 | add dl, [eax+esi] |
5839 | add dl, [eax+esi] |
5822 | inc esi |
5840 | inc esi |
5823 | cmp esi, 20 |
5841 | cmp esi, 20 |
5824 | jnz @b |
5842 | jnz @b |
5825 | test dl, dl |
5843 | test dl, dl |
5826 | jz .ok |
5844 | jz .ok |
5827 | .n: |
5845 | .n: |
5828 | add eax, 10h |
5846 | add eax, 10h |
5829 | loop .s |
5847 | loop .s |
5830 | stc |
5848 | stc |
5831 | .ok: |
5849 | .ok: |
5832 | ret |
5850 | ret |
5833 | 5851 | ||
5834 | no_acpi_power_off: |
5852 | no_acpi_power_off: |
5835 | call create_trampoline_pgmap |
5853 | call create_trampoline_pgmap |
5836 | mov cr3, eax |
5854 | mov cr3, eax |
5837 | jmp become_real+0x10000 |
5855 | jmp become_real+0x10000 |
5838 | iglobal |
5856 | iglobal |
5839 | align 4 |
5857 | align 4 |
5840 | realmode_gdt: |
5858 | realmode_gdt: |
5841 | ; selector 0 - not used |
5859 | ; selector 0 - not used |
5842 | dw 23 |
5860 | dw 23 |
5843 | dd realmode_gdt-OS_BASE |
5861 | dd realmode_gdt-OS_BASE |
5844 | dw 0 |
5862 | dw 0 |
5845 | ; selector 8 - code from 1000:0000 to 1000:FFFF |
5863 | ; selector 8 - code from 1000:0000 to 1000:FFFF |
5846 | dw 0FFFFh |
5864 | dw 0FFFFh |
5847 | dw 0 |
5865 | dw 0 |
5848 | db 1 |
5866 | db 1 |
5849 | db 10011011b |
5867 | db 10011011b |
5850 | db 00000000b |
5868 | db 00000000b |
5851 | db 0 |
5869 | db 0 |
5852 | ; selector 10h - data from 1000:0000 to 1000:FFFF |
5870 | ; selector 10h - data from 1000:0000 to 1000:FFFF |
5853 | dw 0FFFFh |
5871 | dw 0FFFFh |
5854 | dw 0 |
5872 | dw 0 |
5855 | db 1 |
5873 | db 1 |
5856 | db 10010011b |
5874 | db 10010011b |
5857 | db 00000000b |
5875 | db 00000000b |
5858 | db 0 |
5876 | db 0 |
5859 | endg |
5877 | endg |
5860 | 5878 | ||
5861 | if ~ lang eq sp |
5879 | if ~ lang eq sp |
5862 | diff16 "end of .text segment",0,$ |
5880 | diff16 "end of .text segment",0,$ |
5863 | end if |
5881 | end if |
5864 | 5882 | ||
5865 | include "data32.inc" |
5883 | include "data32.inc" |
5866 | 5884 | ||
5867 | __REV__ = __REV |
5885 | __REV__ = __REV |
5868 | 5886 | ||
5869 | if ~ lang eq sp |
5887 | if ~ lang eq sp |
5870 | diff16 "end of kernel code",0,$ |
5888 | diff16 "end of kernel code",0,$ |
5871 | end if=> |
5889 | end if=> |