Rev 4262 | Rev 4286 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4262 | Rev 4273 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
4 | ;; PROGRAMMING: |
4 | ;; PROGRAMMING: |
5 | ;; Ivan Poddubny |
5 | ;; Ivan Poddubny |
6 | ;; Marat Zakiyanov (Mario79) |
6 | ;; Marat Zakiyanov (Mario79) |
7 | ;; VaStaNi |
7 | ;; VaStaNi |
8 | ;; Trans |
8 | ;; Trans |
9 | ;; Mihail Semenyako (mike.dld) |
9 | ;; Mihail Semenyako (mike.dld) |
10 | ;; Sergey Kuzmin (Wildwest) |
10 | ;; Sergey Kuzmin (Wildwest) |
11 | ;; Andrey Halyavin (halyavin) |
11 | ;; Andrey Halyavin (halyavin) |
12 | ;; Mihail Lisovin (Mihasik) |
12 | ;; Mihail Lisovin (Mihasik) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
14 | ;; NoName |
14 | ;; NoName |
15 | ;; Evgeny Grechnikov (Diamond) |
15 | ;; Evgeny Grechnikov (Diamond) |
16 | ;; Iliya Mihailov (Ghost) |
16 | ;; Iliya Mihailov (Ghost) |
17 | ;; Sergey Semyonov (Serge) |
17 | ;; Sergey Semyonov (Serge) |
18 | ;; Johnny_B |
18 | ;; Johnny_B |
19 | ;; SPraid (simba) |
19 | ;; SPraid (simba) |
20 | ;; Hidnplayr |
20 | ;; Hidnplayr |
21 | ;; Alexey Teplov ( |
21 | ;; Alexey Teplov ( |
22 | ;; Rus |
22 | ;; Rus |
23 | ;; Nable |
23 | ;; Nable |
24 | ;; shurf |
24 | ;; shurf |
25 | ;; Alver |
25 | ;; Alver |
26 | ;; Maxis |
26 | ;; Maxis |
27 | ;; Galkov |
27 | ;; Galkov |
28 | ;; CleverMouse |
28 | ;; CleverMouse |
29 | ;; tsdima |
29 | ;; tsdima |
30 | ;; turbanoff |
30 | ;; turbanoff |
31 | ;; Asper |
31 | ;; Asper |
32 | ;; art_zh |
32 | ;; art_zh |
33 | ;; |
33 | ;; |
34 | ;; Data in this file was originally part of MenuetOS project which is |
34 | ;; Data in this file was originally part of MenuetOS project which is |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
37 | ;; |
37 | ;; |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
39 | ;; PROGRAMMING: |
39 | ;; PROGRAMMING: |
40 | ;; |
40 | ;; |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
42 | ;; - main os coding/design |
42 | ;; - main os coding/design |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
46 | ;; quickcode@mail.ru |
46 | ;; quickcode@mail.ru |
47 | ;; Alexey, kgaz@crosswinds.net |
47 | ;; Alexey, kgaz@crosswinds.net |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
49 | ;; kristol@nic.fi |
49 | ;; kristol@nic.fi |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
53 | ;; |
53 | ;; |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
58 | ;; License (the "GPL") for full details. |
58 | ;; License (the "GPL") for full details. |
59 | ; |
59 | ; |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
65 | ;; on all copies. |
65 | ;; on all copies. |
66 | ;; |
66 | ;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
68 | 68 | ||
69 | format binary as "mnt" |
69 | format binary as "mnt" |
70 | 70 | ||
71 | include 'macros.inc' |
71 | include 'macros.inc' |
72 | include 'struct.inc' |
72 | include 'struct.inc' |
73 | 73 | ||
74 | $Revision: 4262 $ |
74 | $Revision: 4273 $ |
75 | 75 | ||
76 | 76 | ||
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
78 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
78 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
79 | 79 | ||
80 | ; Enabling the next line will enable serial output console |
80 | ; Enabling the next line will enable serial output console |
81 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
81 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
82 | 82 | ||
83 | include "proc32.inc" |
83 | include "proc32.inc" |
84 | include "kglobals.inc" |
84 | include "kglobals.inc" |
85 | include "lang.inc" |
85 | include "lang.inc" |
86 | include "encoding.inc" |
86 | include "encoding.inc" |
87 | 87 | ||
88 | include "const.inc" |
88 | include "const.inc" |
89 | 89 | ||
90 | iglobal |
90 | iglobal |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
92 | debug_direct_print db 0 |
92 | debug_direct_print db 0 |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
94 | launcher_start db 1 |
94 | launcher_start db 1 |
95 | endg |
95 | endg |
96 | 96 | ||
97 | max_processes equ 255 |
97 | max_processes equ 255 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
99 | 99 | ||
100 | os_stack equ (os_data_l-gdts) ; GDTs |
100 | os_stack equ (os_data_l-gdts) ; GDTs |
101 | os_code equ (os_code_l-gdts) |
101 | os_code equ (os_code_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
109 | 109 | ||
110 | 110 | ||
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
112 | ;; |
112 | ;; |
113 | ;; Included files: |
113 | ;; Included files: |
114 | ;; |
114 | ;; |
115 | ;; Kernel16.inc |
115 | ;; Kernel16.inc |
116 | ;; - Booteng.inc English text for bootup |
116 | ;; - Booteng.inc English text for bootup |
117 | ;; - Bootcode.inc Hardware setup |
117 | ;; - Bootcode.inc Hardware setup |
118 | ;; - Pci16.inc PCI functions |
118 | ;; - Pci16.inc PCI functions |
119 | ;; |
119 | ;; |
120 | ;; Kernel32.inc |
120 | ;; Kernel32.inc |
121 | ;; - Sys32.inc Process management |
121 | ;; - Sys32.inc Process management |
122 | ;; - Shutdown.inc Shutdown and restart |
122 | ;; - Shutdown.inc Shutdown and restart |
123 | ;; - Fat32.inc Read / write hd |
123 | ;; - Fat32.inc Read / write hd |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
126 | ;; - Vga.inc VGA driver |
126 | ;; - Vga.inc VGA driver |
127 | ;; - Stack.inc Network interface |
127 | ;; - Stack.inc Network interface |
128 | ;; - Mouse.inc Mouse pointer |
128 | ;; - Mouse.inc Mouse pointer |
129 | ;; - Scincode.inc Window skinning |
129 | ;; - Scincode.inc Window skinning |
130 | ;; - Pci32.inc PCI functions |
130 | ;; - Pci32.inc PCI functions |
131 | ;; |
131 | ;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
133 | 133 | ||
134 | 134 | ||
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
136 | ;; ;; |
136 | ;; ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
138 | ;; ;; |
138 | ;; ;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
140 | 140 | ||
141 | use16 |
141 | use16 |
142 | org 0x0 |
142 | org 0x0 |
143 | jmp start_of_code |
143 | jmp start_of_code |
144 | 144 | ||
145 | if lang eq sp |
145 | if lang eq sp |
146 | include "kernelsp.inc" ; spanish kernel messages |
146 | include "kernelsp.inc" ; spanish kernel messages |
147 | else if lang eq et |
147 | else if lang eq et |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
149 | else |
149 | else |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
151 | end if |
151 | end if |
152 | 152 | ||
153 | include "boot/bootstr.inc" ; language-independent boot messages |
153 | include "boot/bootstr.inc" ; language-independent boot messages |
154 | include "boot/preboot.inc" |
154 | include "boot/preboot.inc" |
155 | 155 | ||
156 | if lang eq ge |
156 | if lang eq ge |
157 | include "boot/bootge.inc" ; german system boot messages |
157 | include "boot/bootge.inc" ; german system boot messages |
158 | else if lang eq sp |
158 | else if lang eq sp |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
160 | else if lang eq ru |
160 | else if lang eq ru |
161 | include "boot/bootru.inc" ; russian system boot messages |
161 | include "boot/bootru.inc" ; russian system boot messages |
162 | include "boot/ru.inc" ; Russian font |
162 | include "boot/ru.inc" ; Russian font |
163 | else if lang eq et |
163 | else if lang eq et |
164 | include "boot/bootet.inc" ; estonian system boot messages |
164 | include "boot/bootet.inc" ; estonian system boot messages |
165 | include "boot/et.inc" ; Estonian font |
165 | include "boot/et.inc" ; Estonian font |
166 | else |
166 | else |
167 | include "boot/booten.inc" ; english system boot messages |
167 | include "boot/booten.inc" ; english system boot messages |
168 | end if |
168 | end if |
169 | 169 | ||
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
171 | include "bus/pci/pci16.inc" |
171 | include "bus/pci/pci16.inc" |
172 | include "detect/biosdisk.inc" |
172 | include "detect/biosdisk.inc" |
173 | 173 | ||
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
175 | ;; ;; |
175 | ;; ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
177 | ;; ;; |
177 | ;; ;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
179 | 179 | ||
180 | 180 | ||
181 | ; CR0 Flags - Protected mode and Paging |
181 | ; CR0 Flags - Protected mode and Paging |
182 | 182 | ||
183 | mov ecx, CR0_PE |
183 | mov ecx, CR0_PE |
184 | 184 | ||
185 | ; Enabling 32 bit protected mode |
185 | ; Enabling 32 bit protected mode |
186 | 186 | ||
187 | sidt [cs:old_ints_h] |
187 | sidt [cs:old_ints_h] |
188 | 188 | ||
189 | cli ; disable all irqs |
189 | cli ; disable all irqs |
190 | cld |
190 | cld |
191 | mov al, 255 ; mask all irqs |
191 | mov al, 255 ; mask all irqs |
192 | out 0xa1, al |
192 | out 0xa1, al |
193 | out 0x21, al |
193 | out 0x21, al |
194 | l.5: |
194 | l.5: |
195 | in al, 0x64 ; Enable A20 |
195 | in al, 0x64 ; Enable A20 |
196 | test al, 2 |
196 | test al, 2 |
197 | jnz l.5 |
197 | jnz l.5 |
198 | mov al, 0xD1 |
198 | mov al, 0xD1 |
199 | out 0x64, al |
199 | out 0x64, al |
200 | l.6: |
200 | l.6: |
201 | in al, 0x64 |
201 | in al, 0x64 |
202 | test al, 2 |
202 | test al, 2 |
203 | jnz l.6 |
203 | jnz l.6 |
204 | mov al, 0xDF |
204 | mov al, 0xDF |
205 | out 0x60, al |
205 | out 0x60, al |
206 | l.7: |
206 | l.7: |
207 | in al, 0x64 |
207 | in al, 0x64 |
208 | test al, 2 |
208 | test al, 2 |
209 | jnz l.7 |
209 | jnz l.7 |
210 | mov al, 0xFF |
210 | mov al, 0xFF |
211 | out 0x64, al |
211 | out 0x64, al |
212 | 212 | ||
213 | lgdt [cs:tmp_gdt] ; Load GDT |
213 | lgdt [cs:tmp_gdt] ; Load GDT |
214 | mov eax, cr0 ; protected mode |
214 | mov eax, cr0 ; protected mode |
215 | or eax, ecx |
215 | or eax, ecx |
216 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
216 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
217 | mov cr0, eax |
217 | mov cr0, eax |
218 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
218 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
219 | 219 | ||
220 | align 8 |
220 | align 8 |
221 | tmp_gdt: |
221 | tmp_gdt: |
222 | 222 | ||
223 | dw 23 |
223 | dw 23 |
224 | dd tmp_gdt+0x10000 |
224 | dd tmp_gdt+0x10000 |
225 | dw 0 |
225 | dw 0 |
226 | 226 | ||
227 | dw 0xffff |
227 | dw 0xffff |
228 | dw 0x0000 |
228 | dw 0x0000 |
229 | db 0x00 |
229 | db 0x00 |
230 | dw 11011111b *256 +10011010b |
230 | dw 11011111b *256 +10011010b |
231 | db 0x00 |
231 | db 0x00 |
232 | 232 | ||
233 | dw 0xffff |
233 | dw 0xffff |
234 | dw 0x0000 |
234 | dw 0x0000 |
235 | db 0x00 |
235 | db 0x00 |
236 | dw 11011111b *256 +10010010b |
236 | dw 11011111b *256 +10010010b |
237 | db 0x00 |
237 | db 0x00 |
238 | 238 | ||
239 | include "data16.inc" |
239 | include "data16.inc" |
240 | 240 | ||
241 | if ~ lang eq sp |
241 | if ~ lang eq sp |
242 | diff16 "end of bootcode",0,$+0x10000 |
242 | diff16 "end of bootcode",0,$+0x10000 |
243 | end if |
243 | end if |
244 | 244 | ||
245 | use32 |
245 | use32 |
246 | org $+0x10000 |
246 | org $+0x10000 |
247 | 247 | ||
248 | align 4 |
248 | align 4 |
249 | B32: |
249 | B32: |
250 | mov ax, os_stack ; Selector for os |
250 | mov ax, os_stack ; Selector for os |
251 | mov ds, ax |
251 | mov ds, ax |
252 | mov es, ax |
252 | mov es, ax |
253 | mov fs, ax |
253 | mov fs, ax |
254 | mov gs, ax |
254 | mov gs, ax |
255 | mov ss, ax |
255 | mov ss, ax |
256 | mov esp, 0x006CC00 ; Set stack |
256 | mov esp, 0x006CC00 ; Set stack |
257 | 257 | ||
258 | ; CLEAR 0x280000 - HEAP_BASE |
258 | ; CLEAR 0x280000 - HEAP_BASE |
259 | 259 | ||
260 | xor eax, eax |
260 | xor eax, eax |
261 | mov edi, CLEAN_ZONE |
261 | mov edi, CLEAN_ZONE |
262 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
262 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
263 | cld |
263 | cld |
264 | rep stosd |
264 | rep stosd |
265 | 265 | ||
266 | ; CLEAR KERNEL UNDEFINED GLOBALS |
266 | ; CLEAR KERNEL UNDEFINED GLOBALS |
267 | mov edi, endofcode-OS_BASE |
267 | mov edi, endofcode-OS_BASE |
268 | mov ecx, 0x90000 |
268 | mov ecx, 0x90000 |
269 | sub ecx, edi |
269 | sub ecx, edi |
270 | shr ecx, 2 |
270 | shr ecx, 2 |
271 | rep stosd |
271 | rep stosd |
272 | 272 | ||
273 | ; SAVE & CLEAR 0-0xffff |
273 | ; SAVE & CLEAR 0-0xffff |
274 | 274 | ||
275 | mov edi, 0x1000 |
275 | mov edi, 0x1000 |
276 | mov ecx, 0x8000 / 4 |
276 | mov ecx, 0x8000 / 4 |
277 | rep stosd |
277 | rep stosd |
278 | mov edi, 0xa000 |
278 | mov edi, 0xa000 |
279 | mov ecx, 0x6000 / 4 |
279 | mov ecx, 0x6000 / 4 |
280 | rep stosd |
280 | rep stosd |
281 | 281 | ||
282 | call test_cpu |
282 | call test_cpu |
283 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
283 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
284 | 284 | ||
285 | call check_acpi |
285 | call check_acpi |
286 | call init_BIOS32 |
286 | call init_BIOS32 |
287 | ; MEMORY MODEL |
287 | ; MEMORY MODEL |
288 | call mem_test |
288 | call mem_test |
289 | call init_mem |
289 | call init_mem |
290 | call init_page_map |
290 | call init_page_map |
291 | 291 | ||
292 | ; ENABLE PAGING |
292 | ; ENABLE PAGING |
293 | 293 | ||
294 | mov eax, sys_pgdir-OS_BASE |
294 | mov eax, sys_pgdir-OS_BASE |
295 | mov cr3, eax |
295 | mov cr3, eax |
296 | 296 | ||
297 | mov eax, cr0 |
297 | mov eax, cr0 |
298 | or eax, CR0_PG+CR0_WP |
298 | or eax, CR0_PG+CR0_WP |
299 | mov cr0, eax |
299 | mov cr0, eax |
300 | 300 | ||
301 | lgdt [gdts] |
301 | lgdt [gdts] |
302 | jmp pword os_code:high_code |
302 | jmp pword os_code:high_code |
303 | 303 | ||
304 | align 4 |
304 | align 4 |
305 | bios32_entry dd ? |
305 | bios32_entry dd ? |
306 | tmp_page_tabs dd ? |
306 | tmp_page_tabs dd ? |
307 | 307 | ||
308 | use16 |
308 | use16 |
309 | org $-0x10000 |
309 | org $-0x10000 |
310 | include "boot/shutdown.inc" ; shutdown or restart |
310 | include "boot/shutdown.inc" ; shutdown or restart |
311 | org $+0x10000 |
311 | org $+0x10000 |
312 | use32 |
312 | use32 |
313 | 313 | ||
314 | __DEBUG__ fix 1 |
314 | __DEBUG__ fix 1 |
315 | __DEBUG_LEVEL__ fix 1 |
315 | __DEBUG_LEVEL__ fix 1 |
316 | include 'init.inc' |
316 | include 'init.inc' |
317 | 317 | ||
318 | org OS_BASE+$ |
318 | org OS_BASE+$ |
319 | 319 | ||
320 | include 'fdo.inc' |
320 | include 'fdo.inc' |
321 | 321 | ||
322 | align 4 |
322 | align 4 |
323 | high_code: |
323 | high_code: |
324 | mov ax, os_stack |
324 | mov ax, os_stack |
325 | mov bx, app_data |
325 | mov bx, app_data |
326 | mov cx, app_tls |
326 | mov cx, app_tls |
327 | mov ss, ax |
327 | mov ss, ax |
328 | add esp, OS_BASE |
328 | add esp, OS_BASE |
329 | 329 | ||
330 | mov ds, bx |
330 | mov ds, bx |
331 | mov es, bx |
331 | mov es, bx |
332 | mov fs, cx |
332 | mov fs, cx |
333 | mov gs, bx |
333 | mov gs, bx |
334 | 334 | ||
335 | bt [cpu_caps], CAPS_PGE |
335 | bt [cpu_caps], CAPS_PGE |
336 | jnc @F |
336 | jnc @F |
337 | 337 | ||
338 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
338 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
339 | 339 | ||
340 | mov ebx, cr4 |
340 | mov ebx, cr4 |
341 | or ebx, CR4_PGE |
341 | or ebx, CR4_PGE |
342 | mov cr4, ebx |
342 | mov cr4, ebx |
343 | @@: |
343 | @@: |
344 | xor eax, eax |
344 | xor eax, eax |
345 | mov dword [sys_pgdir], eax |
345 | mov dword [sys_pgdir], eax |
346 | mov dword [sys_pgdir+4], eax |
346 | mov dword [sys_pgdir+4], eax |
347 | 347 | ||
348 | mov eax, cr3 |
348 | mov eax, cr3 |
349 | mov cr3, eax ; flush TLB |
349 | mov cr3, eax ; flush TLB |
350 | 350 | ||
351 | mov ecx, pg_data.mutex |
351 | mov ecx, pg_data.mutex |
352 | call mutex_init |
352 | call mutex_init |
353 | 353 | ||
354 | mov ecx, disk_list_mutex |
354 | mov ecx, disk_list_mutex |
355 | call mutex_init |
355 | call mutex_init |
356 | 356 | ||
357 | mov ecx, keyboard_list_mutex |
357 | mov ecx, keyboard_list_mutex |
358 | call mutex_init |
358 | call mutex_init |
359 | 359 | ||
360 | mov ecx, unpack_mutex |
360 | mov ecx, unpack_mutex |
361 | call mutex_init |
361 | call mutex_init |
362 | 362 | ||
363 | mov ecx, application_table_mutex |
363 | mov ecx, application_table_mutex |
364 | call mutex_init |
364 | call mutex_init |
365 | 365 | ||
366 | mov ecx, ide_mutex |
366 | mov ecx, ide_mutex |
367 | call mutex_init |
367 | call mutex_init |
368 | mov ecx, ide_channel1_mutex |
368 | mov ecx, ide_channel1_mutex |
369 | call mutex_init |
369 | call mutex_init |
370 | mov ecx, ide_channel2_mutex |
370 | mov ecx, ide_channel2_mutex |
371 | call mutex_init |
371 | call mutex_init |
372 | ;----------------------------------------------------------------------------- |
372 | ;----------------------------------------------------------------------------- |
373 | ; SAVE REAL MODE VARIABLES |
373 | ; SAVE REAL MODE VARIABLES |
374 | ;----------------------------------------------------------------------------- |
374 | ;----------------------------------------------------------------------------- |
375 | save_variables_IDE_controller: |
375 | save_variables_IDE_controller: |
376 | xor eax, eax |
376 | xor eax, eax |
377 | mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] |
377 | mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] |
378 | mov [IDE_Interrupt], ax |
378 | mov [IDE_Interrupt], ax |
379 | ;-------------------------------------- |
379 | ;-------------------------------------- |
380 | mov ax, [BOOT_VARS + BOOT_IDE_PI_16] |
380 | mov ax, [BOOT_VARS + BOOT_IDE_PI_16] |
381 | mov [IDEContrProgrammingInterface], ax |
381 | mov [IDEContrProgrammingInterface], ax |
382 | ;-------------------------------------- |
382 | ;-------------------------------------- |
383 | mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] |
383 | mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] |
384 | mov [IDEContrRegsBaseAddr], ax |
384 | mov [IDEContrRegsBaseAddr], ax |
385 | ;-------------------------------------- |
385 | ;-------------------------------------- |
386 | mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] |
386 | mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] |
387 | cmp ax, 0 |
387 | cmp ax, 0 |
388 | je @f |
388 | je @f |
389 | cmp ax, 1 |
389 | cmp ax, 1 |
390 | jne .no_PATA_BAR0 |
390 | jne .no_PATA_BAR0 |
391 | @@: |
391 | @@: |
392 | mov ax, 0x1F0 |
392 | mov ax, 0x1F0 |
393 | jmp @f |
393 | jmp @f |
394 | .no_PATA_BAR0: |
394 | .no_PATA_BAR0: |
395 | and ax, 0xFFFC |
395 | and ax, 0xFFFC |
396 | @@: |
396 | @@: |
397 | mov [StandardATABases], ax |
397 | mov [StandardATABases], ax |
398 | mov [hd_address_table], eax |
398 | mov [hd_address_table], eax |
399 | mov [hd_address_table+8], eax |
399 | mov [hd_address_table+8], eax |
400 | mov [IDE_BAR0_val], ax |
400 | mov [IDE_BAR0_val], ax |
401 | ;-------------------------------------- |
401 | ;-------------------------------------- |
402 | mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16] |
402 | mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16] |
403 | cmp ax, 0 |
403 | cmp ax, 0 |
404 | je @f |
404 | je @f |
405 | cmp ax, 1 |
405 | cmp ax, 1 |
406 | jne .no_PATA_BAR1 |
406 | jne .no_PATA_BAR1 |
407 | @@: |
407 | @@: |
408 | mov ax, 0x3F4 |
408 | mov ax, 0x3F4 |
409 | jmp @f |
409 | jmp @f |
410 | .no_PATA_BAR1: |
410 | .no_PATA_BAR1: |
411 | and ax, 0xFFFC |
411 | and ax, 0xFFFC |
412 | @@: |
412 | @@: |
413 | mov [IDE_BAR1_val], ax |
413 | mov [IDE_BAR1_val], ax |
414 | ;-------------------------------------- |
414 | ;-------------------------------------- |
415 | mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16] |
415 | mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16] |
416 | cmp ax, 0 |
416 | cmp ax, 0 |
417 | je @f |
417 | je @f |
418 | cmp ax, 1 |
418 | cmp ax, 1 |
419 | jne .no_PATA_BAR2 |
419 | jne .no_PATA_BAR2 |
420 | @@: |
420 | @@: |
421 | mov ax, 0x170 |
421 | mov ax, 0x170 |
422 | jmp @f |
422 | jmp @f |
423 | .no_PATA_BAR2: |
423 | .no_PATA_BAR2: |
424 | and ax, 0xFFFC |
424 | and ax, 0xFFFC |
425 | @@: |
425 | @@: |
426 | mov [StandardATABases+2], ax |
426 | mov [StandardATABases+2], ax |
427 | mov [hd_address_table+16], eax |
427 | mov [hd_address_table+16], eax |
428 | mov [hd_address_table+24], eax |
428 | mov [hd_address_table+24], eax |
429 | mov [IDE_BAR2_val], ax |
429 | mov [IDE_BAR2_val], ax |
430 | ;-------------------------------------- |
430 | ;-------------------------------------- |
431 | mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16] |
431 | mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16] |
432 | cmp ax, 0 |
432 | cmp ax, 0 |
433 | je @f |
433 | je @f |
434 | cmp ax, 1 |
434 | cmp ax, 1 |
435 | jne .no_PATA_BAR3 |
435 | jne .no_PATA_BAR3 |
436 | @@: |
436 | @@: |
437 | mov ax, 0x374 |
437 | mov ax, 0x374 |
438 | jmp @f |
438 | jmp @f |
439 | .no_PATA_BAR3: |
439 | .no_PATA_BAR3: |
440 | and ax, 0xFFFC |
440 | and ax, 0xFFFC |
441 | @@: |
441 | @@: |
442 | mov [IDE_BAR3_val], ax |
442 | mov [IDE_BAR3_val], ax |
443 | 443 | ||
444 | ; --------------- APM --------------------- |
444 | ; --------------- APM --------------------- |
445 | 445 | ||
446 | ; init selectors |
446 | ; init selectors |
447 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
447 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
448 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
448 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
449 | ; protected-mode 32-bit code segment |
449 | ; protected-mode 32-bit code segment |
450 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
450 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
451 | ; protected-mode 16-bit code segment |
451 | ; protected-mode 16-bit code segment |
452 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
452 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
453 | ; protected-mode 16-bit data segment |
453 | ; protected-mode 16-bit data segment |
454 | 454 | ||
455 | shl eax, 4 |
455 | shl eax, 4 |
456 | mov [dword apm_code_32 + 2], ax |
456 | mov [dword apm_code_32 + 2], ax |
457 | shr eax, 16 |
457 | shr eax, 16 |
458 | mov [dword apm_code_32 + 4], al |
458 | mov [dword apm_code_32 + 4], al |
459 | 459 | ||
460 | shl ecx, 4 |
460 | shl ecx, 4 |
461 | mov [dword apm_code_16 + 2], cx |
461 | mov [dword apm_code_16 + 2], cx |
462 | shr ecx, 16 |
462 | shr ecx, 16 |
463 | mov [dword apm_code_16 + 4], cl |
463 | mov [dword apm_code_16 + 4], cl |
464 | 464 | ||
465 | shl edx, 4 |
465 | shl edx, 4 |
466 | mov [dword apm_data_16 + 2], dx |
466 | mov [dword apm_data_16 + 2], dx |
467 | shr edx, 16 |
467 | shr edx, 16 |
468 | mov [dword apm_data_16 + 4], dl |
468 | mov [dword apm_data_16 + 4], dl |
469 | 469 | ||
470 | mov dword[apm_entry], ebx |
470 | mov dword[apm_entry], ebx |
471 | mov word [apm_entry + 4], apm_code_32 - gdts |
471 | mov word [apm_entry + 4], apm_code_32 - gdts |
472 | 472 | ||
473 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
473 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
474 | mov [apm_vf], eax |
474 | mov [apm_vf], eax |
475 | ; ----------------------------------------- |
475 | ; ----------------------------------------- |
476 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
476 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
477 | mov [allow_dma_access], al |
477 | mov [allow_dma_access], al |
478 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
478 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
479 | mov [_display.bpp], eax |
479 | mov [_display.bpp], eax |
480 | mov [_display.vrefresh], 60 |
480 | mov [_display.vrefresh], 60 |
481 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
481 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
482 | mov [debug_direct_print], al |
482 | mov [debug_direct_print], al |
483 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
483 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
484 | mov [launcher_start], al |
484 | mov [launcher_start], al |
485 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
485 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
486 | mov [_display.width], eax |
486 | mov [_display.width], eax |
487 | mov [display_width_standard], eax |
487 | mov [display_width_standard], eax |
488 | dec eax |
488 | dec eax |
489 | mov [Screen_Max_X], eax |
489 | mov [Screen_Max_X], eax |
490 | mov [screen_workarea.right], eax |
490 | mov [screen_workarea.right], eax |
491 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
491 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
492 | mov [_display.height], eax |
492 | mov [_display.height], eax |
493 | mov [display_height_standard], eax |
493 | mov [display_height_standard], eax |
494 | dec eax |
494 | dec eax |
495 | mov [Screen_Max_Y], eax |
495 | mov [Screen_Max_Y], eax |
496 | mov [screen_workarea.bottom], eax |
496 | mov [screen_workarea.bottom], eax |
497 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
497 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
498 | mov dword [SCR_MODE], eax |
498 | mov dword [SCR_MODE], eax |
499 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
499 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
500 | ; mov [BANK_SWITCH], eax |
500 | ; mov [BANK_SWITCH], eax |
501 | mov eax, 640 *4 ; Bytes PerScanLine |
501 | mov eax, 640 *4 ; Bytes PerScanLine |
502 | cmp [SCR_MODE], word 0x13 ; 320x200 |
502 | cmp [SCR_MODE], word 0x13 ; 320x200 |
503 | je @f |
503 | je @f |
504 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
504 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
505 | je @f |
505 | je @f |
506 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
506 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
507 | @@: |
507 | @@: |
508 | mov [_display.pitch], eax |
508 | mov [_display.pitch], eax |
509 | mov eax, [_display.width] |
509 | mov eax, [_display.width] |
510 | mul [_display.height] |
510 | mul [_display.height] |
511 | mov [_WinMapSize], eax |
511 | mov [_WinMapSize], eax |
512 | 512 | ||
513 | call calculate_fast_getting_offset_for_WinMapAddress |
513 | call calculate_fast_getting_offset_for_WinMapAddress |
514 | ; for Qemu or non standart video cards |
514 | ; for Qemu or non standart video cards |
515 | ; Unfortunately [BytesPerScanLine] does not always |
515 | ; Unfortunately [BytesPerScanLine] does not always |
516 | ; equal to [_display.width] * [ScreenBPP] / 8 |
516 | ; equal to [_display.width] * [ScreenBPP] / 8 |
517 | call calculate_fast_getting_offset_for_LFB |
517 | call calculate_fast_getting_offset_for_LFB |
518 | 518 | ||
519 | mov esi, BOOT_VARS+0x9080 |
519 | mov esi, BOOT_VARS+0x9080 |
520 | movzx ecx, byte [esi-1] |
520 | movzx ecx, byte [esi-1] |
521 | mov [NumBiosDisks], ecx |
521 | mov [NumBiosDisks], ecx |
522 | mov edi, BiosDisksData |
522 | mov edi, BiosDisksData |
523 | rep movsd |
523 | rep movsd |
524 | 524 | ||
525 | ; GRAPHICS ADDRESSES |
525 | ; GRAPHICS ADDRESSES |
526 | 526 | ||
527 | mov eax, [BOOT_VARS+BOOT_LFB] |
527 | mov eax, [BOOT_VARS+BOOT_LFB] |
528 | mov [LFBAddress], eax |
528 | mov [LFBAddress], eax |
529 | 529 | ||
530 | cmp [SCR_MODE], word 0100000000000000b |
530 | cmp [SCR_MODE], word 0100000000000000b |
531 | jge setvesa20 |
531 | jge setvesa20 |
532 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
532 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
533 | je v20ga32 |
533 | je v20ga32 |
534 | jmp v20ga24 |
534 | jmp v20ga24 |
535 | 535 | ||
536 | setvesa20: |
536 | setvesa20: |
537 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
537 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
538 | mov [GETPIXEL], dword Vesa20_getpixel24 |
538 | mov [GETPIXEL], dword Vesa20_getpixel24 |
539 | cmp byte [_display.bpp], 24 |
539 | cmp byte [_display.bpp], 24 |
540 | jz v20ga24 |
540 | jz v20ga24 |
541 | v20ga32: |
541 | v20ga32: |
542 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
542 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
543 | mov [GETPIXEL], dword Vesa20_getpixel32 |
543 | mov [GETPIXEL], dword Vesa20_getpixel32 |
544 | jmp no_mode_0x12 |
544 | jmp no_mode_0x12 |
545 | v20ga24: |
545 | v20ga24: |
546 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
546 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
547 | jne no_mode_0x12 |
547 | jne no_mode_0x12 |
548 | mov [PUTPIXEL], dword VGA_putpixel |
548 | mov [PUTPIXEL], dword VGA_putpixel |
549 | mov [GETPIXEL], dword Vesa20_getpixel32 |
549 | mov [GETPIXEL], dword Vesa20_getpixel32 |
550 | no_mode_0x12: |
550 | no_mode_0x12: |
551 | 551 | ||
552 | mov [MOUSE_PICTURE], dword mousepointer |
552 | mov [MOUSE_PICTURE], dword mousepointer |
553 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
553 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
554 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
554 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
555 | 555 | ||
556 | ; -------- Fast System Call init ---------- |
556 | ; -------- Fast System Call init ---------- |
557 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
557 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
558 | bt [cpu_caps], CAPS_SEP |
558 | bt [cpu_caps], CAPS_SEP |
559 | jnc .SEnP ; SysEnter not Present |
559 | jnc .SEnP ; SysEnter not Present |
560 | xor edx, edx |
560 | xor edx, edx |
561 | mov ecx, MSR_SYSENTER_CS |
561 | mov ecx, MSR_SYSENTER_CS |
562 | mov eax, os_code |
562 | mov eax, os_code |
563 | wrmsr |
563 | wrmsr |
564 | mov ecx, MSR_SYSENTER_ESP |
564 | mov ecx, MSR_SYSENTER_ESP |
565 | ; mov eax, sysenter_stack ; Check it |
565 | ; mov eax, sysenter_stack ; Check it |
566 | xor eax, eax |
566 | xor eax, eax |
567 | wrmsr |
567 | wrmsr |
568 | mov ecx, MSR_SYSENTER_EIP |
568 | mov ecx, MSR_SYSENTER_EIP |
569 | mov eax, sysenter_entry |
569 | mov eax, sysenter_entry |
570 | wrmsr |
570 | wrmsr |
571 | .SEnP: |
571 | .SEnP: |
572 | ; AMD SYSCALL/SYSRET |
572 | ; AMD SYSCALL/SYSRET |
573 | cmp byte[cpu_vendor], 'A' |
573 | cmp byte[cpu_vendor], 'A' |
574 | jne .noSYSCALL |
574 | jne .noSYSCALL |
575 | mov eax, 0x80000001 |
575 | mov eax, 0x80000001 |
576 | cpuid |
576 | cpuid |
577 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
577 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
578 | jz .noSYSCALL |
578 | jz .noSYSCALL |
579 | mov ecx, MSR_AMD_EFER |
579 | mov ecx, MSR_AMD_EFER |
580 | rdmsr |
580 | rdmsr |
581 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
581 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
582 | wrmsr |
582 | wrmsr |
583 | 583 | ||
584 | ; !!!! It`s dirty hack, fix it !!! |
584 | ; !!!! It`s dirty hack, fix it !!! |
585 | ; Bits of EDX : |
585 | ; Bits of EDX : |
586 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
586 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
587 | ; and the contents of this field, plus 8, are copied into the SS register. |
587 | ; and the contents of this field, plus 8, are copied into the SS register. |
588 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
588 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
589 | ; and the contents of this field, plus 8, are copied into the SS register. |
589 | ; and the contents of this field, plus 8, are copied into the SS register. |
590 | 590 | ||
591 | ; mov edx, (os_code + 16) * 65536 + os_code |
591 | ; mov edx, (os_code + 16) * 65536 + os_code |
592 | mov edx, 0x1B0008 |
592 | mov edx, 0x1B0008 |
593 | 593 | ||
594 | mov eax, syscall_entry |
594 | mov eax, syscall_entry |
595 | mov ecx, MSR_AMD_STAR |
595 | mov ecx, MSR_AMD_STAR |
596 | wrmsr |
596 | wrmsr |
597 | .noSYSCALL: |
597 | .noSYSCALL: |
598 | ; ----------------------------------------- |
598 | ; ----------------------------------------- |
599 | stdcall alloc_page |
599 | stdcall alloc_page |
600 | stdcall map_page, tss-0xF80, eax, PG_SW |
600 | stdcall map_page, tss-0xF80, eax, PG_SW |
601 | stdcall alloc_page |
601 | stdcall alloc_page |
602 | stdcall map_page, tss+0x80, eax, PG_SW |
602 | stdcall map_page, tss+0x80, eax, PG_SW |
603 | stdcall alloc_page |
603 | stdcall alloc_page |
604 | stdcall map_page, tss+0x1080, eax, PG_SW |
604 | stdcall map_page, tss+0x1080, eax, PG_SW |
605 | 605 | ||
606 | ; LOAD IDT |
606 | ; LOAD IDT |
607 | 607 | ||
608 | call build_interrupt_table ;lidt is executed |
608 | call build_interrupt_table ;lidt is executed |
609 | ;lidt [idtreg] |
609 | ;lidt [idtreg] |
610 | 610 | ||
611 | call init_kernel_heap |
611 | call init_kernel_heap |
612 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
612 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
613 | mov [os_stack_seg], eax |
613 | mov [os_stack_seg], eax |
614 | 614 | ||
615 | lea esp, [eax+RING0_STACK_SIZE] |
615 | lea esp, [eax+RING0_STACK_SIZE] |
616 | 616 | ||
617 | mov [tss._ss0], os_stack |
617 | mov [tss._ss0], os_stack |
618 | mov [tss._esp0], esp |
618 | mov [tss._esp0], esp |
619 | mov [tss._esp], esp |
619 | mov [tss._esp], esp |
620 | mov [tss._cs], os_code |
620 | mov [tss._cs], os_code |
621 | mov [tss._ss], os_stack |
621 | mov [tss._ss], os_stack |
622 | mov [tss._ds], app_data |
622 | mov [tss._ds], app_data |
623 | mov [tss._es], app_data |
623 | mov [tss._es], app_data |
624 | mov [tss._fs], app_data |
624 | mov [tss._fs], app_data |
625 | mov [tss._gs], app_data |
625 | mov [tss._gs], app_data |
626 | mov [tss._io], 128 |
626 | mov [tss._io], 128 |
627 | ;Add IO access table - bit array of permitted ports |
627 | ;Add IO access table - bit array of permitted ports |
628 | mov edi, tss._io_map_0 |
628 | mov edi, tss._io_map_0 |
629 | xor eax, eax |
629 | xor eax, eax |
630 | not eax |
630 | not eax |
631 | mov ecx, 8192/4 |
631 | mov ecx, 8192/4 |
632 | rep stosd ; access to 4096*8=65536 ports |
632 | rep stosd ; access to 4096*8=65536 ports |
633 | 633 | ||
634 | mov ax, tss0 |
634 | mov ax, tss0 |
635 | ltr ax |
635 | ltr ax |
636 | 636 | ||
637 | mov [LFBSize], 0xC00000 |
637 | mov [LFBSize], 0xC00000 |
638 | call init_LFB |
638 | call init_LFB |
639 | call init_fpu |
639 | call init_fpu |
640 | call init_malloc |
640 | call init_malloc |
641 | 641 | ||
642 | stdcall alloc_kernel_space, 0x51000 |
642 | stdcall alloc_kernel_space, 0x51000 |
643 | mov [default_io_map], eax |
643 | mov [default_io_map], eax |
644 | 644 | ||
645 | add eax, 0x2000 |
645 | add eax, 0x2000 |
646 | mov [ipc_tmp], eax |
646 | mov [ipc_tmp], eax |
647 | mov ebx, 0x1000 |
647 | mov ebx, 0x1000 |
648 | 648 | ||
649 | add eax, 0x40000 |
649 | add eax, 0x40000 |
650 | mov [proc_mem_map], eax |
650 | mov [proc_mem_map], eax |
651 | 651 | ||
652 | add eax, 0x8000 |
652 | add eax, 0x8000 |
653 | mov [proc_mem_pdir], eax |
653 | mov [proc_mem_pdir], eax |
654 | 654 | ||
655 | add eax, ebx |
655 | add eax, ebx |
656 | mov [proc_mem_tab], eax |
656 | mov [proc_mem_tab], eax |
657 | 657 | ||
658 | add eax, ebx |
658 | add eax, ebx |
659 | mov [tmp_task_pdir], eax |
659 | mov [tmp_task_pdir], eax |
660 | 660 | ||
661 | add eax, ebx |
661 | add eax, ebx |
662 | mov [tmp_task_ptab], eax |
662 | mov [tmp_task_ptab], eax |
663 | 663 | ||
664 | add eax, ebx |
664 | add eax, ebx |
665 | mov [ipc_pdir], eax |
665 | mov [ipc_pdir], eax |
666 | 666 | ||
667 | add eax, ebx |
667 | add eax, ebx |
668 | mov [ipc_ptab], eax |
668 | mov [ipc_ptab], eax |
669 | 669 | ||
670 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
670 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
671 | (unpack.lc+unpack.lp)))*4 |
671 | (unpack.lc+unpack.lp)))*4 |
672 | 672 | ||
673 | mov [unpack.p], eax |
673 | mov [unpack.p], eax |
674 | 674 | ||
675 | call init_events |
675 | call init_events |
676 | mov eax, srv.fd-SRV.fd |
676 | mov eax, srv.fd-SRV.fd |
677 | mov [srv.fd], eax |
677 | mov [srv.fd], eax |
678 | mov [srv.bk], eax |
678 | mov [srv.bk], eax |
679 | 679 | ||
680 | ;Set base of graphic segment to linear address of LFB |
680 | ;Set base of graphic segment to linear address of LFB |
681 | mov eax, [LFBAddress] ; set for gs |
681 | mov eax, [LFBAddress] ; set for gs |
682 | mov [graph_data_l+2], ax |
682 | mov [graph_data_l+2], ax |
683 | shr eax, 16 |
683 | shr eax, 16 |
684 | mov [graph_data_l+4], al |
684 | mov [graph_data_l+4], al |
685 | mov [graph_data_l+7], ah |
685 | mov [graph_data_l+7], ah |
686 | 686 | ||
687 | stdcall kernel_alloc, [_WinMapSize] |
687 | stdcall kernel_alloc, [_WinMapSize] |
688 | mov [_WinMapAddress], eax |
688 | mov [_WinMapAddress], eax |
689 | 689 | ||
690 | xor eax, eax |
690 | xor eax, eax |
691 | inc eax |
691 | inc eax |
692 | 692 | ||
693 | ; set background |
693 | ; set background |
694 | 694 | ||
695 | mov [BgrDrawMode], eax |
695 | mov [BgrDrawMode], eax |
696 | mov [BgrDataWidth], eax |
696 | mov [BgrDataWidth], eax |
697 | mov [BgrDataHeight], eax |
697 | mov [BgrDataHeight], eax |
698 | mov [mem_BACKGROUND], 4 |
698 | mov [mem_BACKGROUND], 4 |
699 | mov [img_background], static_background_data |
699 | mov [img_background], static_background_data |
700 | 700 | ||
701 | ; set clipboard |
701 | ; set clipboard |
702 | 702 | ||
703 | xor eax, eax |
703 | xor eax, eax |
704 | mov [clipboard_slots], eax |
704 | mov [clipboard_slots], eax |
705 | mov [clipboard_write_lock], eax |
705 | mov [clipboard_write_lock], eax |
706 | stdcall kernel_alloc, 4096 |
706 | stdcall kernel_alloc, 4096 |
707 | test eax, eax |
707 | test eax, eax |
708 | jnz @f |
708 | jnz @f |
709 | 709 | ||
710 | dec eax |
710 | dec eax |
711 | @@: |
711 | @@: |
712 | mov [clipboard_main_list], eax |
712 | mov [clipboard_main_list], eax |
713 | 713 | ||
714 | ; SET UP OS TASK |
714 | ; SET UP OS TASK |
715 | 715 | ||
716 | mov esi, boot_setostask |
716 | mov esi, boot_setostask |
717 | call boot_log |
717 | call boot_log |
718 | 718 | ||
719 | mov edx, SLOT_BASE+256 |
719 | mov edx, SLOT_BASE+256 |
720 | mov ebx, [os_stack_seg] |
720 | mov ebx, [os_stack_seg] |
721 | add ebx, 0x2000 |
721 | add ebx, 0x2000 |
722 | call setup_os_slot |
722 | call setup_os_slot |
723 | mov dword [edx], 'IDLE' |
723 | mov dword [edx], 'IDLE' |
724 | sub [edx+APPDATA.saved_esp], 4 |
724 | sub [edx+APPDATA.saved_esp], 4 |
725 | mov eax, [edx+APPDATA.saved_esp] |
725 | mov eax, [edx+APPDATA.saved_esp] |
726 | mov dword [eax], idle_thread |
726 | mov dword [eax], idle_thread |
727 | mov ecx, IDLE_PRIORITY |
727 | mov ecx, IDLE_PRIORITY |
728 | call scheduler_add_thread |
728 | call scheduler_add_thread |
729 | 729 | ||
730 | mov edx, SLOT_BASE+256*2 |
730 | mov edx, SLOT_BASE+256*2 |
731 | mov ebx, [os_stack_seg] |
731 | mov ebx, [os_stack_seg] |
732 | call setup_os_slot |
732 | call setup_os_slot |
733 | mov dword [edx], 'OS' |
733 | mov dword [edx], 'OS' |
734 | xor ecx, ecx |
734 | xor ecx, ecx |
735 | call scheduler_add_thread |
735 | call scheduler_add_thread |
736 | 736 | ||
737 | mov dword [CURRENT_TASK], 2 |
737 | mov dword [CURRENT_TASK], 2 |
738 | mov dword [TASK_COUNT], 2 |
738 | mov dword [TASK_COUNT], 2 |
739 | mov dword [current_slot], SLOT_BASE + 256*2 |
739 | mov dword [current_slot], SLOT_BASE + 256*2 |
740 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
740 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
741 | 741 | ||
742 | 742 | ||
743 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
743 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
744 | mov esi, boot_initirq |
744 | mov esi, boot_initirq |
745 | call boot_log |
745 | call boot_log |
746 | call init_irqs |
746 | call init_irqs |
747 | 747 | ||
748 | mov esi, boot_picinit |
748 | mov esi, boot_picinit |
749 | call boot_log |
749 | call boot_log |
750 | call PIC_init |
750 | call PIC_init |
751 | 751 | ||
752 | mov esi, boot_v86machine |
752 | mov esi, boot_v86machine |
753 | call boot_log |
753 | call boot_log |
754 | ; Initialize system V86 machine |
754 | ; Initialize system V86 machine |
755 | call init_sys_v86 |
755 | call init_sys_v86 |
756 | 756 | ||
757 | mov esi, boot_inittimer |
757 | mov esi, boot_inittimer |
758 | call boot_log |
758 | call boot_log |
759 | ; Initialize system timer (IRQ0) |
759 | ; Initialize system timer (IRQ0) |
760 | call PIT_init |
760 | call PIT_init |
761 | 761 | ||
762 | ; CALCULATE FAT CHAIN FOR RAMDISK |
- | |
- | 762 | ; Register ramdisk file system |
|
- | 763 | mov esi, boot_initramdisk |
|
763 | 764 | call boot_log |
|
764 | call calculatefatchain |
765 | call ramdisk_init |
765 | 766 | ||
766 | mov esi, boot_initapic |
767 | mov esi, boot_initapic |
767 | call boot_log |
768 | call boot_log |
768 | ; Try to Initialize APIC |
769 | ; Try to Initialize APIC |
769 | call APIC_init |
770 | call APIC_init |
770 | 771 | ||
771 | mov esi, boot_enableirq |
772 | mov esi, boot_enableirq |
772 | call boot_log |
773 | call boot_log |
773 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
774 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
774 | ; they are used: when partitions are scanned, hd_read relies on timer |
775 | ; they are used: when partitions are scanned, hd_read relies on timer |
775 | call unmask_timer |
776 | call unmask_timer |
776 | stdcall enable_irq, 2 ; @#$%! PIC |
777 | stdcall enable_irq, 2 ; @#$%! PIC |
777 | stdcall enable_irq, 13 ; co-processor |
778 | stdcall enable_irq, 13 ; co-processor |
778 | 779 | ||
779 | cmp [IDEContrProgrammingInterface], 0 |
780 | cmp [IDEContrProgrammingInterface], 0 |
780 | je @f |
781 | je @f |
781 | 782 | ||
782 | mov esi, boot_disabling_ide |
783 | mov esi, boot_disabling_ide |
783 | call boot_log |
784 | call boot_log |
784 | ;-------------------------------------- |
785 | ;-------------------------------------- |
785 | ; Disable IDE interrupts, because the search |
786 | ; Disable IDE interrupts, because the search |
786 | ; for IDE partitions is in the PIO mode. |
787 | ; for IDE partitions is in the PIO mode. |
787 | ;-------------------------------------- |
788 | ;-------------------------------------- |
788 | .disable_IDE_interrupt: |
789 | .disable_IDE_interrupt: |
789 | ; Disable interrupts in IDE controller for PIO |
790 | ; Disable interrupts in IDE controller for PIO |
790 | mov al, 2 |
791 | mov al, 2 |
791 | mov dx, [IDE_BAR1_val] ;0x3F4 |
792 | mov dx, [IDE_BAR1_val] ;0x3F4 |
792 | add dx, 2 ;0x3F6 |
793 | add dx, 2 ;0x3F6 |
793 | out dx, al |
794 | out dx, al |
794 | mov dx, [IDE_BAR3_val] ;0x374 |
795 | mov dx, [IDE_BAR3_val] ;0x374 |
795 | add dx, 2 ;0x376 |
796 | add dx, 2 ;0x376 |
796 | out dx, al |
797 | out dx, al |
797 | @@: |
798 | @@: |
798 | ;----------------------------------------------------------------------------- |
799 | ;----------------------------------------------------------------------------- |
799 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
800 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
800 | ; mov esi, boot_detectdisks |
801 | ; mov esi, boot_detectdisks |
801 | ; call boot_log |
802 | ; call boot_log |
802 | ;include 'detect/disks.inc' |
803 | ;include 'detect/disks.inc' |
803 | mov esi, boot_detectfloppy |
804 | mov esi, boot_detectfloppy |
804 | call boot_log |
805 | call boot_log |
805 | include 'detect/dev_fd.inc' |
806 | include 'detect/dev_fd.inc' |
806 | mov esi, boot_detecthdcd |
807 | mov esi, boot_detecthdcd |
807 | call boot_log |
808 | call boot_log |
808 | include 'detect/dev_hdcd.inc' |
809 | include 'detect/dev_hdcd.inc' |
809 | mov esi, boot_getcache |
810 | mov esi, boot_getcache |
810 | call boot_log |
811 | call boot_log |
811 | include 'detect/getcache.inc' |
812 | include 'detect/getcache.inc' |
812 | mov esi, boot_detectpart |
813 | mov esi, boot_detectpart |
813 | call boot_log |
814 | call boot_log |
814 | include 'detect/sear_par.inc' |
815 | include 'detect/sear_par.inc' |
815 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
816 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
816 | 817 | ||
817 | mov esi, boot_init_sys |
818 | mov esi, boot_init_sys |
818 | call boot_log |
819 | call boot_log |
819 | call Parser_params |
820 | call Parser_params |
820 | 821 | ||
821 | if ~ defined extended_primary_loader |
822 | if ~ defined extended_primary_loader |
822 | ; ramdisk image should be loaded by extended primary loader if it exists |
823 | ; ramdisk image should be loaded by extended primary loader if it exists |
823 | ; READ RAMDISK IMAGE FROM HD |
824 | ; READ RAMDISK IMAGE FROM HD |
824 | 825 | ||
825 | ;!!!!!!!!!!!!!!!!!!!!!!! |
826 | ;!!!!!!!!!!!!!!!!!!!!!!! |
826 | include 'boot/rdload.inc' |
827 | include 'boot/rdload.inc' |
827 | ;!!!!!!!!!!!!!!!!!!!!!!! |
828 | ;!!!!!!!!!!!!!!!!!!!!!!! |
828 | end if |
829 | end if |
829 | ; mov [dma_hdd],1 |
830 | ; mov [dma_hdd],1 |
830 | 831 | ||
831 | if 0 |
832 | if 0 |
832 | mov ax, [OS_BASE+0x10000+bx_from_load] |
833 | mov ax, [OS_BASE+0x10000+bx_from_load] |
833 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
834 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
834 | je no_lib_load |
835 | je no_lib_load |
835 | 836 | ||
836 | mov esi, boot_loadlibs |
837 | mov esi, boot_loadlibs |
837 | call boot_log |
838 | call boot_log |
838 | ; LOADING LIBRARES |
839 | ; LOADING LIBRARES |
839 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
840 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
840 | call load_file_parse_table ; prepare file parse table |
841 | call load_file_parse_table ; prepare file parse table |
841 | call set_kernel_conf ; configure devices and gui |
842 | call set_kernel_conf ; configure devices and gui |
842 | no_lib_load: |
843 | no_lib_load: |
843 | end if |
844 | end if |
844 | 845 | ||
845 | ; Display APIC status |
846 | ; Display APIC status |
846 | mov esi, boot_APIC_found |
847 | mov esi, boot_APIC_found |
847 | cmp [irq_mode], IRQ_APIC |
848 | cmp [irq_mode], IRQ_APIC |
848 | je @f |
849 | je @f |
849 | mov esi, boot_APIC_nfound |
850 | mov esi, boot_APIC_nfound |
850 | @@: |
851 | @@: |
851 | call boot_log |
852 | call boot_log |
852 | 853 | ||
853 | ; PRINT AMOUNT OF MEMORY |
854 | ; PRINT AMOUNT OF MEMORY |
854 | mov esi, boot_memdetect |
855 | mov esi, boot_memdetect |
855 | call boot_log |
856 | call boot_log |
856 | 857 | ||
857 | movzx ecx, word [boot_y] |
858 | movzx ecx, word [boot_y] |
858 | if lang eq ru |
859 | if lang eq ru |
859 | or ecx, (10+30*6) shl 16 |
860 | or ecx, (10+30*6) shl 16 |
860 | else if lang eq sp |
861 | else if lang eq sp |
861 | or ecx, (10+33*6) shl 16 |
862 | or ecx, (10+33*6) shl 16 |
862 | else |
863 | else |
863 | or ecx, (10+29*6) shl 16 |
864 | or ecx, (10+29*6) shl 16 |
864 | end if |
865 | end if |
865 | sub ecx, 10 |
866 | sub ecx, 10 |
866 | mov edx, 0xFFFFFF |
867 | mov edx, 0xFFFFFF |
867 | mov ebx, [MEM_AMOUNT] |
868 | mov ebx, [MEM_AMOUNT] |
868 | shr ebx, 20 |
869 | shr ebx, 20 |
869 | xor edi, edi |
870 | xor edi, edi |
870 | mov eax, 0x00040000 |
871 | mov eax, 0x00040000 |
871 | inc edi |
872 | inc edi |
872 | call display_number_force |
873 | call display_number_force |
873 | 874 | ||
874 | ; BUILD SCHEDULER |
875 | ; BUILD SCHEDULER |
875 | 876 | ||
876 | ; call build_scheduler; sys32.inc |
877 | ; call build_scheduler; sys32.inc |
877 | 878 | ||
878 | ; mov esi, boot_devices |
879 | ; mov esi, boot_devices |
879 | ; call boot_log |
880 | ; call boot_log |
880 | 881 | ||
881 | mov [pci_access_enabled], 1 |
882 | mov [pci_access_enabled], 1 |
882 | call pci_enum |
883 | call pci_enum |
883 | 884 | ||
884 | stdcall load_driver, szVidintel |
885 | stdcall load_driver, szVidintel |
885 | 886 | ||
886 | call usb_init |
887 | call usb_init |
887 | 888 | ||
888 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
889 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
889 | 890 | ||
890 | mov esi, boot_windefs |
891 | mov esi, boot_windefs |
891 | call boot_log |
892 | call boot_log |
892 | call set_window_defaults |
893 | call set_window_defaults |
893 | 894 | ||
894 | ; SET BACKGROUND DEFAULTS |
895 | ; SET BACKGROUND DEFAULTS |
895 | 896 | ||
896 | mov esi, boot_bgr |
897 | mov esi, boot_bgr |
897 | call boot_log |
898 | call boot_log |
898 | call init_background |
899 | call init_background |
899 | call calculatebackground |
900 | call calculatebackground |
900 | 901 | ||
901 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
902 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
902 | 903 | ||
903 | mov esi, boot_resirqports |
904 | mov esi, boot_resirqports |
904 | call boot_log |
905 | call boot_log |
905 | call reserve_irqs_ports |
906 | call reserve_irqs_ports |
906 | 907 | ||
907 | call init_display |
908 | call init_display |
908 | mov eax, [def_cursor] |
909 | mov eax, [def_cursor] |
909 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
910 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
910 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
911 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
911 | 912 | ||
912 | ; PRINT CPU FREQUENCY |
913 | ; PRINT CPU FREQUENCY |
913 | 914 | ||
914 | mov esi, boot_cpufreq |
915 | mov esi, boot_cpufreq |
915 | call boot_log |
916 | call boot_log |
916 | 917 | ||
917 | cli ;FIXME check IF |
918 | cli ;FIXME check IF |
918 | rdtsc |
919 | rdtsc |
919 | mov ecx, eax |
920 | mov ecx, eax |
920 | mov esi, 250 ; wait 1/4 a second |
921 | mov esi, 250 ; wait 1/4 a second |
921 | call delay_ms |
922 | call delay_ms |
922 | rdtsc |
923 | rdtsc |
923 | 924 | ||
924 | sub eax, ecx |
925 | sub eax, ecx |
925 | xor edx, edx |
926 | xor edx, edx |
926 | shld edx, eax, 2 |
927 | shld edx, eax, 2 |
927 | shl eax, 2 |
928 | shl eax, 2 |
928 | mov dword [cpu_freq], eax |
929 | mov dword [cpu_freq], eax |
929 | mov dword [cpu_freq+4], edx |
930 | mov dword [cpu_freq+4], edx |
930 | mov ebx, 1000000 |
931 | mov ebx, 1000000 |
931 | div ebx |
932 | div ebx |
932 | mov ebx, eax |
933 | mov ebx, eax |
933 | 934 | ||
934 | movzx ecx, word [boot_y] |
935 | movzx ecx, word [boot_y] |
935 | if lang eq ru |
936 | if lang eq ru |
936 | add ecx, (10+19*6) shl 16 - 10 |
937 | add ecx, (10+19*6) shl 16 - 10 |
937 | else if lang eq sp |
938 | else if lang eq sp |
938 | add ecx, (10+25*6) shl 16 - 10 |
939 | add ecx, (10+25*6) shl 16 - 10 |
939 | else |
940 | else |
940 | add ecx, (10+17*6) shl 16 - 10 |
941 | add ecx, (10+17*6) shl 16 - 10 |
941 | end if |
942 | end if |
942 | 943 | ||
943 | mov edx, 0xFFFFFF |
944 | mov edx, 0xFFFFFF |
944 | xor edi, edi |
945 | xor edi, edi |
945 | mov eax, 0x00040000 |
946 | mov eax, 0x00040000 |
946 | inc edi |
947 | inc edi |
947 | call display_number_force |
948 | call display_number_force |
948 | 949 | ||
949 | ; SET VARIABLES |
950 | ; SET VARIABLES |
950 | 951 | ||
951 | call set_variables |
952 | call set_variables |
952 | 953 | ||
953 | ; STACK AND FDC |
954 | ; STACK AND FDC |
954 | 955 | ||
955 | call stack_init |
956 | call stack_init |
956 | call fdc_init |
957 | call fdc_init |
957 | 958 | ||
958 | ; PALETTE FOR 320x200 and 640x480 16 col |
959 | ; PALETTE FOR 320x200 and 640x480 16 col |
959 | 960 | ||
960 | cmp [SCR_MODE], word 0x12 |
961 | cmp [SCR_MODE], word 0x12 |
961 | jne no_pal_vga |
962 | jne no_pal_vga |
962 | mov esi, boot_pal_vga |
963 | mov esi, boot_pal_vga |
963 | call boot_log |
964 | call boot_log |
964 | call paletteVGA |
965 | call paletteVGA |
965 | no_pal_vga: |
966 | no_pal_vga: |
966 | 967 | ||
967 | cmp [SCR_MODE], word 0x13 |
968 | cmp [SCR_MODE], word 0x13 |
968 | jne no_pal_ega |
969 | jne no_pal_ega |
969 | mov esi, boot_pal_ega |
970 | mov esi, boot_pal_ega |
970 | call boot_log |
971 | call boot_log |
971 | call palette320x200 |
972 | call palette320x200 |
972 | no_pal_ega: |
973 | no_pal_ega: |
973 | 974 | ||
974 | ; LOAD DEFAULT SKIN |
975 | ; LOAD DEFAULT SKIN |
975 | 976 | ||
976 | call load_default_skin |
977 | call load_default_skin |
977 | 978 | ||
978 | ;protect io permission map |
979 | ;protect io permission map |
979 | 980 | ||
980 | mov esi, [default_io_map] |
981 | mov esi, [default_io_map] |
981 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
982 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
982 | add esi, 0x1000 |
983 | add esi, 0x1000 |
983 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
984 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
984 | 985 | ||
985 | stdcall map_page, tss._io_map_0, \ |
986 | stdcall map_page, tss._io_map_0, \ |
986 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
987 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
987 | stdcall map_page, tss._io_map_1, \ |
988 | stdcall map_page, tss._io_map_1, \ |
988 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
989 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
989 | 990 | ||
990 | ; LOAD FIRST APPLICATION |
991 | ; LOAD FIRST APPLICATION |
991 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
992 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
992 | jnz first_app_found |
993 | jnz first_app_found |
993 | 994 | ||
994 | cli |
995 | cli |
995 | mov ebp, firstapp |
996 | mov ebp, firstapp |
996 | call fs_execute_from_sysdir |
997 | call fs_execute_from_sysdir |
997 | test eax, eax |
998 | test eax, eax |
998 | jns first_app_found |
999 | jns first_app_found |
999 | 1000 | ||
1000 | mov esi, boot_failed |
1001 | mov esi, boot_failed |
1001 | call boot_log |
1002 | call boot_log |
1002 | 1003 | ||
1003 | mov eax, 0xDEADBEEF ; otherwise halt |
1004 | mov eax, 0xDEADBEEF ; otherwise halt |
1004 | hlt |
1005 | hlt |
1005 | 1006 | ||
1006 | first_app_found: |
1007 | first_app_found: |
1007 | 1008 | ||
1008 | cli |
1009 | cli |
1009 | 1010 | ||
1010 | ; SET KEYBOARD PARAMETERS |
1011 | ; SET KEYBOARD PARAMETERS |
1011 | mov al, 0xf6 ; reset keyboard, scan enabled |
1012 | mov al, 0xf6 ; reset keyboard, scan enabled |
1012 | call kb_write |
1013 | call kb_write |
1013 | test ah, ah |
1014 | test ah, ah |
1014 | jnz .no_keyboard |
1015 | jnz .no_keyboard |
1015 | 1016 | ||
1016 | ; wait until 8042 is ready |
1017 | ; wait until 8042 is ready |
1017 | xor ecx, ecx |
1018 | xor ecx, ecx |
1018 | @@: |
1019 | @@: |
1019 | in al, 64h |
1020 | in al, 64h |
1020 | and al, 00000010b |
1021 | and al, 00000010b |
1021 | loopnz @b |
1022 | loopnz @b |
1022 | 1023 | ||
1023 | iglobal |
1024 | iglobal |
1024 | align 4 |
1025 | align 4 |
1025 | ps2_keyboard_functions: |
1026 | ps2_keyboard_functions: |
1026 | dd .end - $ |
1027 | dd .end - $ |
1027 | dd 0 ; no close |
1028 | dd 0 ; no close |
1028 | dd ps2_set_lights |
1029 | dd ps2_set_lights |
1029 | .end: |
1030 | .end: |
1030 | endg |
1031 | endg |
1031 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1032 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1032 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1033 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1033 | ; call kb_write |
1034 | ; call kb_write |
1034 | ; call kb_read |
1035 | ; call kb_read |
1035 | ; mov al, 111b |
1036 | ; mov al, 111b |
1036 | ; call kb_write |
1037 | ; call kb_write |
1037 | ; call kb_read |
1038 | ; call kb_read |
1038 | 1039 | ||
1039 | mov al, 0xF3 ; set repeat rate & delay |
1040 | mov al, 0xF3 ; set repeat rate & delay |
1040 | call kb_write |
1041 | call kb_write |
1041 | ; call kb_read |
1042 | ; call kb_read |
1042 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1043 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1043 | call kb_write |
1044 | call kb_write |
1044 | ; call kb_read |
1045 | ; call kb_read |
1045 | ;// mike.dld [ |
1046 | ;// mike.dld [ |
1046 | call set_lights |
1047 | call set_lights |
1047 | ;// mike.dld ] |
1048 | ;// mike.dld ] |
1048 | stdcall attach_int_handler, 1, irq1, 0 |
1049 | stdcall attach_int_handler, 1, irq1, 0 |
1049 | DEBUGF 1, "K : IRQ1 error code %x\n", eax |
1050 | DEBUGF 1, "K : IRQ1 error code %x\n", eax |
1050 | .no_keyboard: |
1051 | .no_keyboard: |
1051 | 1052 | ||
1052 | ; SET MOUSE |
1053 | ; SET MOUSE |
1053 | 1054 | ||
1054 | stdcall load_driver, szPS2MDriver |
1055 | stdcall load_driver, szPS2MDriver |
1055 | ; stdcall load_driver, szCOM_MDriver |
1056 | ; stdcall load_driver, szCOM_MDriver |
1056 | 1057 | ||
1057 | mov esi, boot_setmouse |
1058 | mov esi, boot_setmouse |
1058 | call boot_log |
1059 | call boot_log |
1059 | call setmouse |
1060 | call setmouse |
1060 | 1061 | ||
1061 | ; Setup serial output console (if enabled) |
1062 | ; Setup serial output console (if enabled) |
1062 | 1063 | ||
1063 | if defined debug_com_base |
1064 | if defined debug_com_base |
1064 | 1065 | ||
1065 | ; enable Divisor latch |
1066 | ; enable Divisor latch |
1066 | 1067 | ||
1067 | mov dx, debug_com_base+3 |
1068 | mov dx, debug_com_base+3 |
1068 | mov al, 1 shl 7 |
1069 | mov al, 1 shl 7 |
1069 | out dx, al |
1070 | out dx, al |
1070 | 1071 | ||
1071 | ; Set speed to 115200 baud (max speed) |
1072 | ; Set speed to 115200 baud (max speed) |
1072 | 1073 | ||
1073 | mov dx, debug_com_base |
1074 | mov dx, debug_com_base |
1074 | mov al, 0x01 |
1075 | mov al, 0x01 |
1075 | out dx, al |
1076 | out dx, al |
1076 | 1077 | ||
1077 | mov dx, debug_com_base+1 |
1078 | mov dx, debug_com_base+1 |
1078 | mov al, 0x00 |
1079 | mov al, 0x00 |
1079 | out dx, al |
1080 | out dx, al |
1080 | 1081 | ||
1081 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1082 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1082 | 1083 | ||
1083 | mov dx, debug_com_base+3 |
1084 | mov dx, debug_com_base+3 |
1084 | mov al, 3 |
1085 | mov al, 3 |
1085 | out dx, al |
1086 | out dx, al |
1086 | 1087 | ||
1087 | ; disable interrupts |
1088 | ; disable interrupts |
1088 | 1089 | ||
1089 | mov dx, debug_com_base+1 |
1090 | mov dx, debug_com_base+1 |
1090 | mov al, 0 |
1091 | mov al, 0 |
1091 | out dx, al |
1092 | out dx, al |
1092 | 1093 | ||
1093 | ; clear + enable fifo (64 bits) |
1094 | ; clear + enable fifo (64 bits) |
1094 | 1095 | ||
1095 | mov dx, debug_com_base+2 |
1096 | mov dx, debug_com_base+2 |
1096 | mov al, 0x7 + 1 shl 5 |
1097 | mov al, 0x7 + 1 shl 5 |
1097 | out dx, al |
1098 | out dx, al |
1098 | 1099 | ||
1099 | 1100 | ||
1100 | end if |
1101 | end if |
1101 | mov eax, [version_inf.rev] |
1102 | mov eax, [version_inf.rev] |
1102 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1103 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1103 | 1104 | ||
1104 | mov eax, [cpu_count] |
1105 | mov eax, [cpu_count] |
1105 | test eax, eax |
1106 | test eax, eax |
1106 | jnz @F |
1107 | jnz @F |
1107 | mov al, 1 ; at least one CPU |
1108 | mov al, 1 ; at least one CPU |
1108 | @@: |
1109 | @@: |
1109 | DEBUGF 1, "K : %d CPU detected\n", eax |
1110 | DEBUGF 1, "K : %d CPU detected\n", eax |
1110 | 1111 | ||
1111 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
1112 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
1112 | 1113 | ||
1113 | DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 |
1114 | DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 |
1114 | DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 |
1115 | DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 |
1115 | DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 |
1116 | DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 |
1116 | DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 |
1117 | DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 |
1117 | DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 |
1118 | DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 |
1118 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 |
1119 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 |
1119 | DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4 |
1120 | DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4 |
1120 | 1121 | ||
1121 | ; START MULTITASKING |
1122 | ; START MULTITASKING |
1122 | 1123 | ||
1123 | ; A 'All set - press ESC to start' messages if need |
1124 | ; A 'All set - press ESC to start' messages if need |
1124 | if preboot_blogesc |
1125 | if preboot_blogesc |
1125 | mov esi, boot_tasking |
1126 | mov esi, boot_tasking |
1126 | call boot_log |
1127 | call boot_log |
1127 | .bll1: |
1128 | .bll1: |
1128 | in al, 0x60 ; wait for ESC key press |
1129 | in al, 0x60 ; wait for ESC key press |
1129 | cmp al, 129 |
1130 | cmp al, 129 |
1130 | jne .bll1 |
1131 | jne .bll1 |
1131 | end if |
1132 | end if |
1132 | 1133 | ||
1133 | push eax edx |
1134 | push eax edx |
1134 | mov dx, [IDEContrRegsBaseAddr] |
1135 | mov dx, [IDEContrRegsBaseAddr] |
1135 | xor eax, eax |
1136 | xor eax, eax |
1136 | add dx, 2 |
1137 | add dx, 2 |
1137 | in al, dx |
1138 | in al, dx |
1138 | DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax |
1139 | DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax |
1139 | 1140 | ||
1140 | add dx, 8 |
1141 | add dx, 8 |
1141 | in al, dx |
1142 | in al, dx |
1142 | DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax |
1143 | DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax |
1143 | pop edx eax |
1144 | pop edx eax |
1144 | 1145 | ||
1145 | cmp [IDEContrRegsBaseAddr], 0 |
1146 | cmp [IDEContrRegsBaseAddr], 0 |
1146 | setnz [dma_hdd] |
1147 | setnz [dma_hdd] |
1147 | 1148 | ||
1148 | cmp [IDEContrProgrammingInterface], 0 |
1149 | cmp [IDEContrProgrammingInterface], 0 |
1149 | je set_interrupts_for_IDE_controllers.continue |
1150 | je set_interrupts_for_IDE_controllers.continue |
1150 | 1151 | ||
1151 | mov ax, [IDE_Interrupt] |
1152 | mov ax, [IDE_Interrupt] |
1152 | cmp al, 0xff |
1153 | cmp al, 0xff |
1153 | jne @f |
1154 | jne @f |
1154 | 1155 | ||
1155 | mov [dma_hdd], 0 |
1156 | mov [dma_hdd], 0 |
1156 | jmp set_interrupts_for_IDE_controllers.end_set_interrupts |
1157 | jmp set_interrupts_for_IDE_controllers.end_set_interrupts |
1157 | @@: |
1158 | @@: |
1158 | ;----------------------------------------------------------------------------- |
1159 | ;----------------------------------------------------------------------------- |
1159 | ; set interrupts for IDE Controller |
1160 | ; set interrupts for IDE Controller |
1160 | ;----------------------------------------------------------------------------- |
1161 | ;----------------------------------------------------------------------------- |
1161 | mov esi, boot_set_int_IDE |
1162 | mov esi, boot_set_int_IDE |
1162 | call boot_log |
1163 | call boot_log |
1163 | set_interrupts_for_IDE_controllers: |
1164 | set_interrupts_for_IDE_controllers: |
1164 | mov ax, [IDEContrProgrammingInterface] |
1165 | mov ax, [IDEContrProgrammingInterface] |
1165 | cmp ax, 0x0180 |
1166 | cmp ax, 0x0180 |
1166 | je .pata_ide |
1167 | je .pata_ide |
1167 | 1168 | ||
1168 | cmp ax, 0x018a |
1169 | cmp ax, 0x018a |
1169 | jne .sata_ide |
1170 | jne .sata_ide |
1170 | ;-------------------------------------- |
1171 | ;-------------------------------------- |
1171 | .pata_ide: |
1172 | .pata_ide: |
1172 | cmp [IDEContrRegsBaseAddr], 0 |
1173 | cmp [IDEContrRegsBaseAddr], 0 |
1173 | je .end_set_interrupts |
1174 | je .end_set_interrupts |
1174 | 1175 | ||
1175 | stdcall attach_int_handler, 14, IDE_irq_14_handler, 0 |
1176 | stdcall attach_int_handler, 14, IDE_irq_14_handler, 0 |
1176 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
1177 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
1177 | stdcall attach_int_handler, 15, IDE_irq_15_handler, 0 |
1178 | stdcall attach_int_handler, 15, IDE_irq_15_handler, 0 |
1178 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
1179 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
1179 | jmp .enable_IDE_interrupt |
1180 | jmp .enable_IDE_interrupt |
1180 | ;-------------------------------------- |
1181 | ;-------------------------------------- |
1181 | .sata_ide: |
1182 | .sata_ide: |
1182 | cmp ax, 0x0185 |
1183 | cmp ax, 0x0185 |
1183 | je .sata_ide_1 |
1184 | je .sata_ide_1 |
1184 | 1185 | ||
1185 | cmp ax, 0x018f |
1186 | cmp ax, 0x018f |
1186 | jne .end_set_interrupts |
1187 | jne .end_set_interrupts |
1187 | ;-------------------------------------- |
1188 | ;-------------------------------------- |
1188 | .sata_ide_1: |
1189 | .sata_ide_1: |
1189 | cmp [IDEContrRegsBaseAddr], 0 |
1190 | cmp [IDEContrRegsBaseAddr], 0 |
1190 | je .end_set_interrupts |
1191 | je .end_set_interrupts |
1191 | 1192 | ||
1192 | mov ax, [IDE_Interrupt] |
1193 | mov ax, [IDE_Interrupt] |
1193 | movzx eax, al |
1194 | movzx eax, al |
1194 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
1195 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
1195 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax |
1196 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax |
1196 | ;-------------------------------------- |
1197 | ;-------------------------------------- |
1197 | .enable_IDE_interrupt: |
1198 | .enable_IDE_interrupt: |
1198 | mov esi, boot_enabling_ide |
1199 | mov esi, boot_enabling_ide |
1199 | call boot_log |
1200 | call boot_log |
1200 | ; Enable interrupts in IDE controller for DMA |
1201 | ; Enable interrupts in IDE controller for DMA |
1201 | mov al, 0 |
1202 | mov al, 0 |
1202 | mov dx, [IDE_BAR1_val] ;0x3F4 |
1203 | mov dx, [IDE_BAR1_val] ;0x3F4 |
1203 | add dx, 2 ;0x3F6 |
1204 | add dx, 2 ;0x3F6 |
1204 | out dx, al |
1205 | out dx, al |
1205 | mov dx, [IDE_BAR3_val] ;0x374 |
1206 | mov dx, [IDE_BAR3_val] ;0x374 |
1206 | add dx, 2 ;0x376 |
1207 | add dx, 2 ;0x376 |
1207 | out dx, al |
1208 | out dx, al |
1208 | ;-------------------------------------- |
1209 | ;-------------------------------------- |
1209 | .end_set_interrupts: |
1210 | .end_set_interrupts: |
1210 | ;----------------------------------------------------------------------------- |
1211 | ;----------------------------------------------------------------------------- |
1211 | cmp [dma_hdd], 0 |
1212 | cmp [dma_hdd], 0 |
1212 | je .print_pio |
1213 | je .print_pio |
1213 | .print_dma: |
1214 | .print_dma: |
1214 | DEBUGF 1, "K : IDE DMA mode\n" |
1215 | DEBUGF 1, "K : IDE DMA mode\n" |
1215 | jmp .continue |
1216 | jmp .continue |
1216 | 1217 | ||
1217 | .print_pio: |
1218 | .print_pio: |
1218 | DEBUGF 1, "K : IDE PIO mode\n" |
1219 | DEBUGF 1, "K : IDE PIO mode\n" |
1219 | .continue: |
1220 | .continue: |
1220 | 1221 | ||
1221 | mov [timer_ticks_enable], 1 ; for cd driver |
1222 | mov [timer_ticks_enable], 1 ; for cd driver |
1222 | 1223 | ||
1223 | sti |
1224 | sti |
1224 | ; call change_task |
1225 | ; call change_task |
1225 | 1226 | ||
1226 | jmp osloop |
1227 | jmp osloop |
1227 | 1228 | ||
1228 | 1229 | ||
1229 | ; Fly :) |
1230 | ; Fly :) |
1230 | 1231 | ||
1231 | include 'unpacker.inc' |
1232 | include 'unpacker.inc' |
1232 | 1233 | ||
1233 | align 4 |
1234 | align 4 |
1234 | boot_log: |
1235 | boot_log: |
1235 | pushad |
1236 | pushad |
1236 | 1237 | ||
1237 | mov ebx, 10*65536 |
1238 | mov ebx, 10*65536 |
1238 | mov bx, word [boot_y] |
1239 | mov bx, word [boot_y] |
1239 | add [boot_y], dword 10 |
1240 | add [boot_y], dword 10 |
1240 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1241 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1241 | xor edi, edi |
1242 | xor edi, edi |
1242 | mov edx, esi |
1243 | mov edx, esi |
1243 | inc edi |
1244 | inc edi |
1244 | call dtext |
1245 | call dtext |
1245 | 1246 | ||
1246 | mov [novesachecksum], 1000 |
1247 | mov [novesachecksum], 1000 |
1247 | call checkVga_N13 |
1248 | call checkVga_N13 |
1248 | 1249 | ||
1249 | popad |
1250 | popad |
1250 | 1251 | ||
1251 | ret |
1252 | ret |
1252 | 1253 | ||
1253 | ; in: edx -> APPDATA for OS/IDLE slot |
1254 | ; in: edx -> APPDATA for OS/IDLE slot |
1254 | ; in: ebx = stack base |
1255 | ; in: ebx = stack base |
1255 | proc setup_os_slot |
1256 | proc setup_os_slot |
1256 | xor eax, eax |
1257 | xor eax, eax |
1257 | mov ecx, 256/4 |
1258 | mov ecx, 256/4 |
1258 | mov edi, edx |
1259 | mov edi, edx |
1259 | rep stosd |
1260 | rep stosd |
1260 | 1261 | ||
1261 | mov eax, tss+0x80 |
1262 | mov eax, tss+0x80 |
1262 | call get_pg_addr |
1263 | call get_pg_addr |
1263 | inc eax |
1264 | inc eax |
1264 | mov [edx+APPDATA.io_map], eax |
1265 | mov [edx+APPDATA.io_map], eax |
1265 | mov eax, tss+0x1080 |
1266 | mov eax, tss+0x1080 |
1266 | call get_pg_addr |
1267 | call get_pg_addr |
1267 | inc eax |
1268 | inc eax |
1268 | mov [edx+APPDATA.io_map+4], eax |
1269 | mov [edx+APPDATA.io_map+4], eax |
1269 | 1270 | ||
1270 | mov dword [edx+APPDATA.pl0_stack], ebx |
1271 | mov dword [edx+APPDATA.pl0_stack], ebx |
1271 | lea edi, [ebx+0x2000-512] |
1272 | lea edi, [ebx+0x2000-512] |
1272 | mov dword [edx+APPDATA.fpu_state], edi |
1273 | mov dword [edx+APPDATA.fpu_state], edi |
1273 | mov dword [edx+APPDATA.saved_esp0], edi |
1274 | mov dword [edx+APPDATA.saved_esp0], edi |
1274 | mov dword [edx+APPDATA.saved_esp], edi |
1275 | mov dword [edx+APPDATA.saved_esp], edi |
1275 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1276 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1276 | 1277 | ||
1277 | mov esi, fpu_data |
1278 | mov esi, fpu_data |
1278 | mov ecx, 512/4 |
1279 | mov ecx, 512/4 |
1279 | cld |
1280 | cld |
1280 | rep movsd |
1281 | rep movsd |
1281 | 1282 | ||
1282 | lea eax, [edx+APP_OBJ_OFFSET] |
1283 | lea eax, [edx+APP_OBJ_OFFSET] |
1283 | mov dword [edx+APPDATA.fd_obj], eax |
1284 | mov dword [edx+APPDATA.fd_obj], eax |
1284 | mov dword [edx+APPDATA.bk_obj], eax |
1285 | mov dword [edx+APPDATA.bk_obj], eax |
1285 | 1286 | ||
1286 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1287 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1287 | 1288 | ||
1288 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1289 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1289 | 1290 | ||
1290 | mov eax, edx |
1291 | mov eax, edx |
1291 | shr eax, 3 |
1292 | shr eax, 3 |
1292 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1293 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1293 | mov [eax+TASKDATA.wnd_number], dh |
1294 | mov [eax+TASKDATA.wnd_number], dh |
1294 | mov byte [eax+TASKDATA.pid], dh |
1295 | mov byte [eax+TASKDATA.pid], dh |
1295 | 1296 | ||
1296 | ret |
1297 | ret |
1297 | endp |
1298 | endp |
1298 | 1299 | ||
1299 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1300 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1300 | ; ; |
1301 | ; ; |
1301 | ; MAIN OS LOOP START ; |
1302 | ; MAIN OS LOOP START ; |
1302 | ; ; |
1303 | ; ; |
1303 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1304 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1304 | align 32 |
1305 | align 32 |
1305 | osloop: |
1306 | osloop: |
1306 | mov edx, osloop_has_work? |
1307 | mov edx, osloop_has_work? |
1307 | xor ecx, ecx |
1308 | xor ecx, ecx |
1308 | call Wait_events |
1309 | call Wait_events |
1309 | xor eax, eax |
1310 | xor eax, eax |
1310 | xchg eax, [osloop_nonperiodic_work] |
1311 | xchg eax, [osloop_nonperiodic_work] |
1311 | test eax, eax |
1312 | test eax, eax |
1312 | jz .no_periodic |
1313 | jz .no_periodic |
1313 | ; call [draw_pointer] |
1314 | ; call [draw_pointer] |
1314 | call __sys_draw_pointer |
1315 | call __sys_draw_pointer |
1315 | call window_check_events |
1316 | call window_check_events |
1316 | call mouse_check_events |
1317 | call mouse_check_events |
1317 | call checkmisc |
1318 | call checkmisc |
1318 | call checkVga_N13 |
1319 | call checkVga_N13 |
1319 | .no_periodic: |
1320 | .no_periodic: |
1320 | call stack_handler |
1321 | call stack_handler |
1321 | call check_fdd_motor_status |
1322 | call check_fdd_motor_status |
1322 | call check_ATAPI_device_event |
1323 | call check_ATAPI_device_event |
1323 | call check_lights_state |
1324 | call check_lights_state |
1324 | call check_timers |
1325 | call check_timers |
1325 | jmp osloop |
1326 | jmp osloop |
1326 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1327 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1327 | ; ; |
1328 | ; ; |
1328 | ; MAIN OS LOOP END ; |
1329 | ; MAIN OS LOOP END ; |
1329 | ; ; |
1330 | ; ; |
1330 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1331 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1331 | proc osloop_has_work? |
1332 | proc osloop_has_work? |
1332 | cmp [osloop_nonperiodic_work], 0 |
1333 | cmp [osloop_nonperiodic_work], 0 |
1333 | jnz .yes |
1334 | jnz .yes |
1334 | call stack_handler_has_work? |
1335 | call stack_handler_has_work? |
1335 | jnz .yes |
1336 | jnz .yes |
1336 | ; call check_fdd_motor_status_has_work? |
1337 | call check_fdd_motor_status_has_work? |
1337 | ; jnz .yes |
1338 | jnz .yes |
1338 | call check_ATAPI_device_event_has_work? |
1339 | call check_ATAPI_device_event_has_work? |
1339 | jnz .yes |
1340 | jnz .yes |
1340 | call check_lights_state_has_work? |
1341 | call check_lights_state_has_work? |
1341 | jnz .yes |
1342 | jnz .yes |
1342 | call check_timers_has_work? |
1343 | call check_timers_has_work? |
1343 | jnz .yes |
1344 | jnz .yes |
1344 | .no: |
1345 | .no: |
1345 | xor eax, eax |
1346 | xor eax, eax |
1346 | ret |
1347 | ret |
1347 | .yes: |
1348 | .yes: |
1348 | xor eax, eax |
1349 | xor eax, eax |
1349 | inc eax |
1350 | inc eax |
1350 | ret |
1351 | ret |
1351 | endp |
1352 | endp |
1352 | 1353 | ||
1353 | proc wakeup_osloop |
1354 | proc wakeup_osloop |
1354 | mov [osloop_nonperiodic_work], 1 |
1355 | mov [osloop_nonperiodic_work], 1 |
1355 | ret |
1356 | ret |
1356 | endp |
1357 | endp |
1357 | 1358 | ||
1358 | uglobal |
1359 | uglobal |
1359 | align 4 |
1360 | align 4 |
1360 | osloop_nonperiodic_work dd ? |
1361 | osloop_nonperiodic_work dd ? |
1361 | endg |
1362 | endg |
1362 | 1363 | ||
1363 | align 4 |
1364 | align 4 |
1364 | idle_thread: |
1365 | idle_thread: |
1365 | sti |
1366 | sti |
1366 | idle_loop: |
1367 | idle_loop: |
1367 | hlt |
1368 | hlt |
1368 | jmp idle_loop |
1369 | jmp idle_loop |
1369 | 1370 | ||
1370 | 1371 | ||
1371 | 1372 | ||
1372 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1373 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1373 | ; ; |
1374 | ; ; |
1374 | ; INCLUDED SYSTEM FILES ; |
1375 | ; INCLUDED SYSTEM FILES ; |
1375 | ; ; |
1376 | ; ; |
1376 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1377 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1377 | 1378 | ||
1378 | 1379 | ||
1379 | include "kernel32.inc" |
1380 | include "kernel32.inc" |
1380 | 1381 | ||
1381 | 1382 | ||
1382 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1383 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1383 | ; ; |
1384 | ; ; |
1384 | ; KERNEL FUNCTIONS ; |
1385 | ; KERNEL FUNCTIONS ; |
1385 | ; ; |
1386 | ; ; |
1386 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1387 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1387 | 1388 | ||
1388 | reserve_irqs_ports: |
1389 | reserve_irqs_ports: |
1389 | 1390 | ||
1390 | 1391 | ||
1391 | ; RESERVE PORTS |
1392 | ; RESERVE PORTS |
1392 | mov eax, RESERVED_PORTS |
1393 | mov eax, RESERVED_PORTS |
1393 | mov ecx, 1 |
1394 | mov ecx, 1 |
1394 | 1395 | ||
1395 | mov [eax], dword 4 |
1396 | mov [eax], dword 4 |
1396 | 1397 | ||
1397 | mov [eax+16], ecx |
1398 | mov [eax+16], ecx |
1398 | mov [eax+16+4], dword 0 |
1399 | mov [eax+16+4], dword 0 |
1399 | mov [eax+16+8], dword 0x2D |
1400 | mov [eax+16+8], dword 0x2D |
1400 | 1401 | ||
1401 | mov [eax+32], ecx |
1402 | mov [eax+32], ecx |
1402 | mov [eax+32+4], dword 0x30 |
1403 | mov [eax+32+4], dword 0x30 |
1403 | mov [eax+32+8], dword 0x4D |
1404 | mov [eax+32+8], dword 0x4D |
1404 | 1405 | ||
1405 | mov [eax+48], ecx |
1406 | mov [eax+48], ecx |
1406 | mov [eax+48+4], dword 0x50 |
1407 | mov [eax+48+4], dword 0x50 |
1407 | mov [eax+48+8], dword 0xDF |
1408 | mov [eax+48+8], dword 0xDF |
1408 | 1409 | ||
1409 | mov [eax+64], ecx |
1410 | mov [eax+64], ecx |
1410 | mov [eax+64+4], dword 0xE5 |
1411 | mov [eax+64+4], dword 0xE5 |
1411 | mov [eax+64+8], dword 0xFF |
1412 | mov [eax+64+8], dword 0xFF |
1412 | 1413 | ||
1413 | ret |
1414 | ret |
1414 | 1415 | ||
1415 | 1416 | ||
1416 | iglobal |
1417 | iglobal |
1417 | process_number dd 0x2 |
1418 | process_number dd 0x2 |
1418 | endg |
1419 | endg |
1419 | 1420 | ||
1420 | set_variables: |
1421 | set_variables: |
1421 | 1422 | ||
1422 | mov ecx, 0x16 ; flush port 0x60 |
1423 | mov ecx, 0x16 ; flush port 0x60 |
1423 | .fl60: |
1424 | .fl60: |
1424 | in al, 0x60 |
1425 | in al, 0x60 |
1425 | loop .fl60 |
1426 | loop .fl60 |
1426 | push eax |
1427 | push eax |
1427 | 1428 | ||
1428 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1429 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1429 | shr ax, 1 |
1430 | shr ax, 1 |
1430 | shl eax, 16 |
1431 | shl eax, 16 |
1431 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1432 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1432 | shr ax, 1 |
1433 | shr ax, 1 |
1433 | mov [MOUSE_X], eax |
1434 | mov [MOUSE_X], eax |
1434 | call wakeup_osloop |
1435 | call wakeup_osloop |
1435 | 1436 | ||
1436 | xor eax, eax |
1437 | xor eax, eax |
1437 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1438 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1438 | 1439 | ||
1439 | mov byte [KEY_COUNT], al ; keyboard buffer |
1440 | mov byte [KEY_COUNT], al ; keyboard buffer |
1440 | mov byte [BTN_COUNT], al ; button buffer |
1441 | mov byte [BTN_COUNT], al ; button buffer |
1441 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1442 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1442 | 1443 | ||
1443 | pop eax |
1444 | pop eax |
1444 | ret |
1445 | ret |
1445 | 1446 | ||
1446 | align 4 |
1447 | align 4 |
1447 | ;input eax=43,bl-byte of output, ecx - number of port |
1448 | ;input eax=43,bl-byte of output, ecx - number of port |
1448 | sys_outport: |
1449 | sys_outport: |
1449 | 1450 | ||
1450 | mov edi, ecx ; separate flag for read / write |
1451 | mov edi, ecx ; separate flag for read / write |
1451 | and ecx, 65535 |
1452 | and ecx, 65535 |
1452 | 1453 | ||
1453 | mov eax, [RESERVED_PORTS] |
1454 | mov eax, [RESERVED_PORTS] |
1454 | test eax, eax |
1455 | test eax, eax |
1455 | jnz .sopl8 |
1456 | jnz .sopl8 |
1456 | inc eax |
1457 | inc eax |
1457 | mov [esp+32], eax |
1458 | mov [esp+32], eax |
1458 | ret |
1459 | ret |
1459 | 1460 | ||
1460 | .sopl8: |
1461 | .sopl8: |
1461 | mov edx, [TASK_BASE] |
1462 | mov edx, [TASK_BASE] |
1462 | mov edx, [edx+0x4] |
1463 | mov edx, [edx+0x4] |
1463 | ;and ecx,65535 |
1464 | ;and ecx,65535 |
1464 | ;cld - set on interrupt 0x40 |
1465 | ;cld - set on interrupt 0x40 |
1465 | .sopl1: |
1466 | .sopl1: |
1466 | 1467 | ||
1467 | mov esi, eax |
1468 | mov esi, eax |
1468 | shl esi, 4 |
1469 | shl esi, 4 |
1469 | add esi, RESERVED_PORTS |
1470 | add esi, RESERVED_PORTS |
1470 | cmp edx, [esi+0] |
1471 | cmp edx, [esi+0] |
1471 | jne .sopl2 |
1472 | jne .sopl2 |
1472 | cmp ecx, [esi+4] |
1473 | cmp ecx, [esi+4] |
1473 | jb .sopl2 |
1474 | jb .sopl2 |
1474 | cmp ecx, [esi+8] |
1475 | cmp ecx, [esi+8] |
1475 | jg .sopl2 |
1476 | jg .sopl2 |
1476 | .sopl3: |
1477 | .sopl3: |
1477 | 1478 | ||
1478 | test edi, 0x80000000; read ? |
1479 | test edi, 0x80000000; read ? |
1479 | jnz .sopl4 |
1480 | jnz .sopl4 |
1480 | 1481 | ||
1481 | mov eax, ebx |
1482 | mov eax, ebx |
1482 | mov dx, cx ; write |
1483 | mov dx, cx ; write |
1483 | out dx, al |
1484 | out dx, al |
1484 | and [esp+32], dword 0 |
1485 | and [esp+32], dword 0 |
1485 | ret |
1486 | ret |
1486 | 1487 | ||
1487 | .sopl2: |
1488 | .sopl2: |
1488 | 1489 | ||
1489 | dec eax |
1490 | dec eax |
1490 | jnz .sopl1 |
1491 | jnz .sopl1 |
1491 | inc eax |
1492 | inc eax |
1492 | mov [esp+32], eax |
1493 | mov [esp+32], eax |
1493 | ret |
1494 | ret |
1494 | 1495 | ||
1495 | 1496 | ||
1496 | .sopl4: |
1497 | .sopl4: |
1497 | 1498 | ||
1498 | mov dx, cx ; read |
1499 | mov dx, cx ; read |
1499 | in al, dx |
1500 | in al, dx |
1500 | and eax, 0xff |
1501 | and eax, 0xff |
1501 | and [esp+32], dword 0 |
1502 | and [esp+32], dword 0 |
1502 | mov [esp+20], eax |
1503 | mov [esp+20], eax |
1503 | ret |
1504 | ret |
1504 | 1505 | ||
1505 | display_number: |
1506 | display_number: |
1506 | ;It is not optimization |
1507 | ;It is not optimization |
1507 | mov eax, ebx |
1508 | mov eax, ebx |
1508 | mov ebx, ecx |
1509 | mov ebx, ecx |
1509 | mov ecx, edx |
1510 | mov ecx, edx |
1510 | mov edx, esi |
1511 | mov edx, esi |
1511 | mov esi, edi |
1512 | mov esi, edi |
1512 | ; eax = print type, al=0 -> ebx is number |
1513 | ; eax = print type, al=0 -> ebx is number |
1513 | ; al=1 -> ebx is pointer |
1514 | ; al=1 -> ebx is pointer |
1514 | ; ah=0 -> display decimal |
1515 | ; ah=0 -> display decimal |
1515 | ; ah=1 -> display hexadecimal |
1516 | ; ah=1 -> display hexadecimal |
1516 | ; ah=2 -> display binary |
1517 | ; ah=2 -> display binary |
1517 | ; eax bits 16-21 = number of digits to display (0-32) |
1518 | ; eax bits 16-21 = number of digits to display (0-32) |
1518 | ; eax bits 22-31 = reserved |
1519 | ; eax bits 22-31 = reserved |
1519 | ; |
1520 | ; |
1520 | ; ebx = number or pointer |
1521 | ; ebx = number or pointer |
1521 | ; ecx = x shl 16 + y |
1522 | ; ecx = x shl 16 + y |
1522 | ; edx = color |
1523 | ; edx = color |
1523 | xor edi, edi |
1524 | xor edi, edi |
1524 | display_number_force: |
1525 | display_number_force: |
1525 | push eax |
1526 | push eax |
1526 | and eax, 0x3fffffff |
1527 | and eax, 0x3fffffff |
1527 | cmp eax, 0xffff ; length > 0 ? |
1528 | cmp eax, 0xffff ; length > 0 ? |
1528 | pop eax |
1529 | pop eax |
1529 | jge cont_displ |
1530 | jge cont_displ |
1530 | ret |
1531 | ret |
1531 | cont_displ: |
1532 | cont_displ: |
1532 | push eax |
1533 | push eax |
1533 | and eax, 0x3fffffff |
1534 | and eax, 0x3fffffff |
1534 | cmp eax, 61*0x10000 ; length <= 60 ? |
1535 | cmp eax, 61*0x10000 ; length <= 60 ? |
1535 | pop eax |
1536 | pop eax |
1536 | jb cont_displ2 |
1537 | jb cont_displ2 |
1537 | ret |
1538 | ret |
1538 | cont_displ2: |
1539 | cont_displ2: |
1539 | 1540 | ||
1540 | pushad |
1541 | pushad |
1541 | 1542 | ||
1542 | cmp al, 1 ; ecx is a pointer ? |
1543 | cmp al, 1 ; ecx is a pointer ? |
1543 | jne displnl1 |
1544 | jne displnl1 |
1544 | mov ebp, ebx |
1545 | mov ebp, ebx |
1545 | add ebp, 4 |
1546 | add ebp, 4 |
1546 | mov ebp, [ebp+std_application_base_address] |
1547 | mov ebp, [ebp+std_application_base_address] |
1547 | mov ebx, [ebx+std_application_base_address] |
1548 | mov ebx, [ebx+std_application_base_address] |
1548 | displnl1: |
1549 | displnl1: |
1549 | sub esp, 64 |
1550 | sub esp, 64 |
1550 | 1551 | ||
1551 | test ah, ah ; DECIMAL |
1552 | test ah, ah ; DECIMAL |
1552 | jnz no_display_desnum |
1553 | jnz no_display_desnum |
1553 | shr eax, 16 |
1554 | shr eax, 16 |
1554 | and eax, 0xC03f |
1555 | and eax, 0xC03f |
1555 | ; and eax,0x3f |
1556 | ; and eax,0x3f |
1556 | push eax |
1557 | push eax |
1557 | and eax, 0x3f |
1558 | and eax, 0x3f |
1558 | mov edi, esp |
1559 | mov edi, esp |
1559 | add edi, 4+64-1 |
1560 | add edi, 4+64-1 |
1560 | mov ecx, eax |
1561 | mov ecx, eax |
1561 | mov eax, ebx |
1562 | mov eax, ebx |
1562 | mov ebx, 10 |
1563 | mov ebx, 10 |
1563 | d_desnum: |
1564 | d_desnum: |
1564 | xor edx, edx |
1565 | xor edx, edx |
1565 | call division_64_bits |
1566 | call division_64_bits |
1566 | div ebx |
1567 | div ebx |
1567 | add dl, 48 |
1568 | add dl, 48 |
1568 | mov [edi], dl |
1569 | mov [edi], dl |
1569 | dec edi |
1570 | dec edi |
1570 | loop d_desnum |
1571 | loop d_desnum |
1571 | pop eax |
1572 | pop eax |
1572 | call normalize_number |
1573 | call normalize_number |
1573 | call draw_num_text |
1574 | call draw_num_text |
1574 | add esp, 64 |
1575 | add esp, 64 |
1575 | popad |
1576 | popad |
1576 | ret |
1577 | ret |
1577 | no_display_desnum: |
1578 | no_display_desnum: |
1578 | 1579 | ||
1579 | cmp ah, 0x01 ; HEXADECIMAL |
1580 | cmp ah, 0x01 ; HEXADECIMAL |
1580 | jne no_display_hexnum |
1581 | jne no_display_hexnum |
1581 | shr eax, 16 |
1582 | shr eax, 16 |
1582 | and eax, 0xC03f |
1583 | and eax, 0xC03f |
1583 | ; and eax,0x3f |
1584 | ; and eax,0x3f |
1584 | push eax |
1585 | push eax |
1585 | and eax, 0x3f |
1586 | and eax, 0x3f |
1586 | mov edi, esp |
1587 | mov edi, esp |
1587 | add edi, 4+64-1 |
1588 | add edi, 4+64-1 |
1588 | mov ecx, eax |
1589 | mov ecx, eax |
1589 | mov eax, ebx |
1590 | mov eax, ebx |
1590 | mov ebx, 16 |
1591 | mov ebx, 16 |
1591 | d_hexnum: |
1592 | d_hexnum: |
1592 | xor edx, edx |
1593 | xor edx, edx |
1593 | call division_64_bits |
1594 | call division_64_bits |
1594 | div ebx |
1595 | div ebx |
1595 | hexletters = __fdo_hexdigits |
1596 | hexletters = __fdo_hexdigits |
1596 | add edx, hexletters |
1597 | add edx, hexletters |
1597 | mov dl, [edx] |
1598 | mov dl, [edx] |
1598 | mov [edi], dl |
1599 | mov [edi], dl |
1599 | dec edi |
1600 | dec edi |
1600 | loop d_hexnum |
1601 | loop d_hexnum |
1601 | pop eax |
1602 | pop eax |
1602 | call normalize_number |
1603 | call normalize_number |
1603 | call draw_num_text |
1604 | call draw_num_text |
1604 | add esp, 64 |
1605 | add esp, 64 |
1605 | popad |
1606 | popad |
1606 | ret |
1607 | ret |
1607 | no_display_hexnum: |
1608 | no_display_hexnum: |
1608 | 1609 | ||
1609 | cmp ah, 0x02 ; BINARY |
1610 | cmp ah, 0x02 ; BINARY |
1610 | jne no_display_binnum |
1611 | jne no_display_binnum |
1611 | shr eax, 16 |
1612 | shr eax, 16 |
1612 | and eax, 0xC03f |
1613 | and eax, 0xC03f |
1613 | ; and eax,0x3f |
1614 | ; and eax,0x3f |
1614 | push eax |
1615 | push eax |
1615 | and eax, 0x3f |
1616 | and eax, 0x3f |
1616 | mov edi, esp |
1617 | mov edi, esp |
1617 | add edi, 4+64-1 |
1618 | add edi, 4+64-1 |
1618 | mov ecx, eax |
1619 | mov ecx, eax |
1619 | mov eax, ebx |
1620 | mov eax, ebx |
1620 | mov ebx, 2 |
1621 | mov ebx, 2 |
1621 | d_binnum: |
1622 | d_binnum: |
1622 | xor edx, edx |
1623 | xor edx, edx |
1623 | call division_64_bits |
1624 | call division_64_bits |
1624 | div ebx |
1625 | div ebx |
1625 | add dl, 48 |
1626 | add dl, 48 |
1626 | mov [edi], dl |
1627 | mov [edi], dl |
1627 | dec edi |
1628 | dec edi |
1628 | loop d_binnum |
1629 | loop d_binnum |
1629 | pop eax |
1630 | pop eax |
1630 | call normalize_number |
1631 | call normalize_number |
1631 | call draw_num_text |
1632 | call draw_num_text |
1632 | add esp, 64 |
1633 | add esp, 64 |
1633 | popad |
1634 | popad |
1634 | ret |
1635 | ret |
1635 | no_display_binnum: |
1636 | no_display_binnum: |
1636 | 1637 | ||
1637 | add esp, 64 |
1638 | add esp, 64 |
1638 | popad |
1639 | popad |
1639 | ret |
1640 | ret |
1640 | 1641 | ||
1641 | normalize_number: |
1642 | normalize_number: |
1642 | test ah, 0x80 |
1643 | test ah, 0x80 |
1643 | jz .continue |
1644 | jz .continue |
1644 | mov ecx, 48 |
1645 | mov ecx, 48 |
1645 | and eax, 0x3f |
1646 | and eax, 0x3f |
1646 | @@: |
1647 | @@: |
1647 | inc edi |
1648 | inc edi |
1648 | cmp [edi], cl |
1649 | cmp [edi], cl |
1649 | jne .continue |
1650 | jne .continue |
1650 | dec eax |
1651 | dec eax |
1651 | cmp eax, 1 |
1652 | cmp eax, 1 |
1652 | ja @r |
1653 | ja @r |
1653 | mov al, 1 |
1654 | mov al, 1 |
1654 | .continue: |
1655 | .continue: |
1655 | and eax, 0x3f |
1656 | and eax, 0x3f |
1656 | ret |
1657 | ret |
1657 | 1658 | ||
1658 | division_64_bits: |
1659 | division_64_bits: |
1659 | test [esp+1+4], byte 0x40 |
1660 | test [esp+1+4], byte 0x40 |
1660 | jz .continue |
1661 | jz .continue |
1661 | push eax |
1662 | push eax |
1662 | mov eax, ebp |
1663 | mov eax, ebp |
1663 | div ebx |
1664 | div ebx |
1664 | mov ebp, eax |
1665 | mov ebp, eax |
1665 | pop eax |
1666 | pop eax |
1666 | .continue: |
1667 | .continue: |
1667 | ret |
1668 | ret |
1668 | 1669 | ||
1669 | draw_num_text: |
1670 | draw_num_text: |
1670 | mov esi, eax |
1671 | mov esi, eax |
1671 | mov edx, 64+4 |
1672 | mov edx, 64+4 |
1672 | sub edx, eax |
1673 | sub edx, eax |
1673 | add edx, esp |
1674 | add edx, esp |
1674 | mov ebx, [esp+64+32-8+4] |
1675 | mov ebx, [esp+64+32-8+4] |
1675 | ; add window start x & y |
1676 | ; add window start x & y |
1676 | mov ecx, [TASK_BASE] |
1677 | mov ecx, [TASK_BASE] |
1677 | 1678 | ||
1678 | mov edi, [CURRENT_TASK] |
1679 | mov edi, [CURRENT_TASK] |
1679 | shl edi, 8 |
1680 | shl edi, 8 |
1680 | 1681 | ||
1681 | mov eax, [ecx-twdw+WDATA.box.left] |
1682 | mov eax, [ecx-twdw+WDATA.box.left] |
1682 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1683 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1683 | shl eax, 16 |
1684 | shl eax, 16 |
1684 | add eax, [ecx-twdw+WDATA.box.top] |
1685 | add eax, [ecx-twdw+WDATA.box.top] |
1685 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1686 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1686 | add ebx, eax |
1687 | add ebx, eax |
1687 | mov ecx, [esp+64+32-12+4] |
1688 | mov ecx, [esp+64+32-12+4] |
1688 | and ecx, not 0x80000000 ; force counted string |
1689 | and ecx, not 0x80000000 ; force counted string |
1689 | mov eax, [esp+64+8] ; background color (if given) |
1690 | mov eax, [esp+64+8] ; background color (if given) |
1690 | mov edi, [esp+64+4] |
1691 | mov edi, [esp+64+4] |
1691 | jmp dtext |
1692 | jmp dtext |
1692 | 1693 | ||
1693 | align 4 |
1694 | align 4 |
1694 | 1695 | ||
1695 | sys_setup: |
1696 | sys_setup: |
1696 | 1697 | ||
1697 | ; 1=roland mpu midi base , base io address |
1698 | ; 1=roland mpu midi base , base io address |
1698 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1699 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1699 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1700 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1700 | ; 5=system language, 1eng 2fi 3ger 4rus |
1701 | ; 5=system language, 1eng 2fi 3ger 4rus |
1701 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1702 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1702 | ; 8=fat32 partition in hd |
1703 | ; 8=fat32 partition in hd |
1703 | ; 9 |
1704 | ; 9 |
1704 | ; 10 = sound dma channel |
1705 | ; 10 = sound dma channel |
1705 | ; 11 = enable lba read |
1706 | ; 11 = enable lba read |
1706 | ; 12 = enable pci access |
1707 | ; 12 = enable pci access |
1707 | 1708 | ||
1708 | 1709 | ||
1709 | and [esp+32], dword 0 |
1710 | and [esp+32], dword 0 |
1710 | dec ebx ; MIDI |
1711 | dec ebx ; MIDI |
1711 | jnz nsyse1 |
1712 | jnz nsyse1 |
1712 | cmp ecx, 0x100 |
1713 | cmp ecx, 0x100 |
1713 | 1714 | ||
1714 | jb nsyse1 |
1715 | jb nsyse1 |
1715 | mov esi, 65535 |
1716 | mov esi, 65535 |
1716 | cmp esi, ecx |
1717 | cmp esi, ecx |
1717 | 1718 | ||
1718 | jb nsyse1 |
1719 | jb nsyse1 |
1719 | mov [midi_base], cx ;bx |
1720 | mov [midi_base], cx ;bx |
1720 | mov word [mididp], cx;bx |
1721 | mov word [mididp], cx;bx |
1721 | inc cx ;bx |
1722 | inc cx ;bx |
1722 | mov word [midisp], cx;bx |
1723 | mov word [midisp], cx;bx |
1723 | ret |
1724 | ret |
1724 | 1725 | ||
1725 | iglobal |
1726 | iglobal |
1726 | midi_base dw 0 |
1727 | midi_base dw 0 |
1727 | endg |
1728 | endg |
1728 | 1729 | ||
1729 | nsyse1: |
1730 | nsyse1: |
1730 | dec ebx ; KEYBOARD |
1731 | dec ebx ; KEYBOARD |
1731 | jnz nsyse2 |
1732 | jnz nsyse2 |
1732 | mov edi, [TASK_BASE] |
1733 | mov edi, [TASK_BASE] |
1733 | mov eax, [edi+TASKDATA.mem_start] |
1734 | mov eax, [edi+TASKDATA.mem_start] |
1734 | add eax, edx |
1735 | add eax, edx |
1735 | 1736 | ||
1736 | dec ecx |
1737 | dec ecx |
1737 | jnz kbnobase |
1738 | jnz kbnobase |
1738 | mov ebx, keymap |
1739 | mov ebx, keymap |
1739 | mov ecx, 128 |
1740 | mov ecx, 128 |
1740 | call memmove |
1741 | call memmove |
1741 | ret |
1742 | ret |
1742 | kbnobase: |
1743 | kbnobase: |
1743 | dec ecx |
1744 | dec ecx |
1744 | jnz kbnoshift |
1745 | jnz kbnoshift |
1745 | 1746 | ||
1746 | mov ebx, keymap_shift |
1747 | mov ebx, keymap_shift |
1747 | mov ecx, 128 |
1748 | mov ecx, 128 |
1748 | call memmove |
1749 | call memmove |
1749 | ret |
1750 | ret |
1750 | kbnoshift: |
1751 | kbnoshift: |
1751 | dec ecx |
1752 | dec ecx |
1752 | jnz kbnoalt |
1753 | jnz kbnoalt |
1753 | mov ebx, keymap_alt |
1754 | mov ebx, keymap_alt |
1754 | mov ecx, 128 |
1755 | mov ecx, 128 |
1755 | call memmove |
1756 | call memmove |
1756 | ret |
1757 | ret |
1757 | kbnoalt: |
1758 | kbnoalt: |
1758 | sub ecx, 6 |
1759 | sub ecx, 6 |
1759 | jnz kbnocountry |
1760 | jnz kbnocountry |
1760 | mov word [keyboard], dx |
1761 | mov word [keyboard], dx |
1761 | ret |
1762 | ret |
1762 | kbnocountry: |
1763 | kbnocountry: |
1763 | mov [esp+32], dword 1 |
1764 | mov [esp+32], dword 1 |
1764 | ret |
1765 | ret |
1765 | nsyse2: |
1766 | nsyse2: |
1766 | dec ebx ; CD |
1767 | dec ebx ; CD |
1767 | jnz nsyse4 |
1768 | jnz nsyse4 |
1768 | 1769 | ||
1769 | test ecx, ecx |
1770 | test ecx, ecx |
1770 | jz nosesl |
1771 | jz nosesl |
1771 | 1772 | ||
1772 | cmp ecx, 4 |
1773 | cmp ecx, 4 |
1773 | ja nosesl |
1774 | ja nosesl |
1774 | mov [cd_base], cl |
1775 | mov [cd_base], cl |
1775 | 1776 | ||
1776 | dec ecx |
1777 | dec ecx |
1777 | jnz noprma |
1778 | jnz noprma |
1778 | mov eax, [hd_address_table] |
1779 | mov eax, [hd_address_table] |
1779 | mov [cdbase], eax ;0x1f0 |
1780 | mov [cdbase], eax ;0x1f0 |
1780 | mov [cdid], 0xa0 |
1781 | mov [cdid], 0xa0 |
1781 | noprma: |
1782 | noprma: |
1782 | 1783 | ||
1783 | dec ecx |
1784 | dec ecx |
1784 | jnz noprsl |
1785 | jnz noprsl |
1785 | mov eax, [hd_address_table] |
1786 | mov eax, [hd_address_table] |
1786 | mov [cdbase], eax ;0x1f0 |
1787 | mov [cdbase], eax ;0x1f0 |
1787 | mov [cdid], 0xb0 |
1788 | mov [cdid], 0xb0 |
1788 | noprsl: |
1789 | noprsl: |
1789 | dec ecx |
1790 | dec ecx |
1790 | jnz nosema |
1791 | jnz nosema |
1791 | mov eax, [hd_address_table+16] |
1792 | mov eax, [hd_address_table+16] |
1792 | mov [cdbase], eax ;0x170 |
1793 | mov [cdbase], eax ;0x170 |
1793 | mov [cdid], 0xa0 |
1794 | mov [cdid], 0xa0 |
1794 | nosema: |
1795 | nosema: |
1795 | dec ecx |
1796 | dec ecx |
1796 | jnz nosesl |
1797 | jnz nosesl |
1797 | mov eax, [hd_address_table+16] |
1798 | mov eax, [hd_address_table+16] |
1798 | mov [cdbase], eax ;0x170 |
1799 | mov [cdbase], eax ;0x170 |
1799 | mov [cdid], 0xb0 |
1800 | mov [cdid], 0xb0 |
1800 | nosesl: |
1801 | nosesl: |
1801 | ret |
1802 | ret |
1802 | 1803 | ||
1803 | iglobal |
1804 | iglobal |
1804 | cd_base db 0 |
1805 | cd_base db 0 |
1805 | 1806 | ||
1806 | endg |
1807 | endg |
1807 | nsyse4: |
1808 | nsyse4: |
1808 | 1809 | ||
1809 | sub ebx, 2 ; SYSTEM LANGUAGE |
1810 | sub ebx, 2 ; SYSTEM LANGUAGE |
1810 | jnz nsyse5 |
1811 | jnz nsyse5 |
1811 | mov [syslang], ecx |
1812 | mov [syslang], ecx |
1812 | ret |
1813 | ret |
1813 | nsyse5: |
1814 | nsyse5: |
1814 | 1815 | ||
1815 | sub ebx, 2 ; HD BASE - obsolete |
1816 | sub ebx, 2 ; HD BASE - obsolete |
1816 | jnz nsyse7 |
1817 | jnz nsyse7 |
1817 | 1818 | ||
1818 | nosethd: |
1819 | nosethd: |
1819 | ret |
1820 | ret |
1820 | 1821 | ||
1821 | nsyse7: |
1822 | nsyse7: |
1822 | 1823 | ||
1823 | ; cmp eax,8 ; HD PARTITION - obsolete |
1824 | ; cmp eax,8 ; HD PARTITION - obsolete |
1824 | dec ebx |
1825 | dec ebx |
1825 | jnz nsyse8 |
1826 | jnz nsyse8 |
1826 | ret |
1827 | ret |
1827 | 1828 | ||
1828 | nsyse8: |
1829 | nsyse8: |
1829 | ; cmp eax,11 ; ENABLE LBA READ |
1830 | ; cmp eax,11 ; ENABLE LBA READ |
1830 | and ecx, 1 |
1831 | and ecx, 1 |
1831 | sub ebx, 3 |
1832 | sub ebx, 3 |
1832 | jnz no_set_lba_read |
1833 | jnz no_set_lba_read |
1833 | mov [lba_read_enabled], ecx |
1834 | mov [lba_read_enabled], ecx |
1834 | ret |
1835 | ret |
1835 | 1836 | ||
1836 | no_set_lba_read: |
1837 | no_set_lba_read: |
1837 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1838 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1838 | dec ebx |
1839 | dec ebx |
1839 | jnz sys_setup_err |
1840 | jnz sys_setup_err |
1840 | mov [pci_access_enabled], ecx |
1841 | mov [pci_access_enabled], ecx |
1841 | ret |
1842 | ret |
1842 | 1843 | ||
1843 | sys_setup_err: |
1844 | sys_setup_err: |
1844 | or [esp+32], dword -1 |
1845 | or [esp+32], dword -1 |
1845 | ret |
1846 | ret |
1846 | 1847 | ||
1847 | align 4 |
1848 | align 4 |
1848 | 1849 | ||
1849 | sys_getsetup: |
1850 | sys_getsetup: |
1850 | 1851 | ||
1851 | ; 1=roland mpu midi base , base io address |
1852 | ; 1=roland mpu midi base , base io address |
1852 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1853 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1853 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1854 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1854 | ; 5=system language, 1eng 2fi 3ger 4rus |
1855 | ; 5=system language, 1eng 2fi 3ger 4rus |
1855 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1856 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1856 | ; 8=fat32 partition in hd |
1857 | ; 8=fat32 partition in hd |
1857 | ; 9=get hs timer tic |
1858 | ; 9=get hs timer tic |
1858 | 1859 | ||
1859 | ; cmp eax,1 |
1860 | ; cmp eax,1 |
1860 | dec ebx |
1861 | dec ebx |
1861 | jnz ngsyse1 |
1862 | jnz ngsyse1 |
1862 | movzx eax, [midi_base] |
1863 | movzx eax, [midi_base] |
1863 | mov [esp+32], eax |
1864 | mov [esp+32], eax |
1864 | ret |
1865 | ret |
1865 | ngsyse1: |
1866 | ngsyse1: |
1866 | ; cmp eax,2 |
1867 | ; cmp eax,2 |
1867 | dec ebx |
1868 | dec ebx |
1868 | jnz ngsyse2 |
1869 | jnz ngsyse2 |
1869 | 1870 | ||
1870 | mov edi, [TASK_BASE] |
1871 | mov edi, [TASK_BASE] |
1871 | mov ebx, [edi+TASKDATA.mem_start] |
1872 | mov ebx, [edi+TASKDATA.mem_start] |
1872 | add ebx, edx |
1873 | add ebx, edx |
1873 | 1874 | ||
1874 | ; cmp ebx,1 |
1875 | ; cmp ebx,1 |
1875 | dec ecx |
1876 | dec ecx |
1876 | jnz kbnobaseret |
1877 | jnz kbnobaseret |
1877 | mov eax, keymap |
1878 | mov eax, keymap |
1878 | mov ecx, 128 |
1879 | mov ecx, 128 |
1879 | call memmove |
1880 | call memmove |
1880 | ret |
1881 | ret |
1881 | kbnobaseret: |
1882 | kbnobaseret: |
1882 | ; cmp ebx,2 |
1883 | ; cmp ebx,2 |
1883 | dec ecx |
1884 | dec ecx |
1884 | jnz kbnoshiftret |
1885 | jnz kbnoshiftret |
1885 | 1886 | ||
1886 | mov eax, keymap_shift |
1887 | mov eax, keymap_shift |
1887 | mov ecx, 128 |
1888 | mov ecx, 128 |
1888 | call memmove |
1889 | call memmove |
1889 | ret |
1890 | ret |
1890 | kbnoshiftret: |
1891 | kbnoshiftret: |
1891 | ; cmp ebx,3 |
1892 | ; cmp ebx,3 |
1892 | dec ecx |
1893 | dec ecx |
1893 | jne kbnoaltret |
1894 | jne kbnoaltret |
1894 | 1895 | ||
1895 | mov eax, keymap_alt |
1896 | mov eax, keymap_alt |
1896 | mov ecx, 128 |
1897 | mov ecx, 128 |
1897 | call memmove |
1898 | call memmove |
1898 | ret |
1899 | ret |
1899 | kbnoaltret: |
1900 | kbnoaltret: |
1900 | ; cmp ebx,9 |
1901 | ; cmp ebx,9 |
1901 | sub ecx, 6 |
1902 | sub ecx, 6 |
1902 | jnz ngsyse2 |
1903 | jnz ngsyse2 |
1903 | movzx eax, word [keyboard] |
1904 | movzx eax, word [keyboard] |
1904 | mov [esp+32], eax |
1905 | mov [esp+32], eax |
1905 | ret |
1906 | ret |
1906 | 1907 | ||
1907 | 1908 | ||
1908 | ngsyse2: |
1909 | ngsyse2: |
1909 | ; cmp eax,3 |
1910 | ; cmp eax,3 |
1910 | dec ebx |
1911 | dec ebx |
1911 | jnz ngsyse3 |
1912 | jnz ngsyse3 |
1912 | movzx eax, [cd_base] |
1913 | movzx eax, [cd_base] |
1913 | mov [esp+32], eax |
1914 | mov [esp+32], eax |
1914 | ret |
1915 | ret |
1915 | ngsyse3: |
1916 | ngsyse3: |
1916 | ; cmp eax,5 |
1917 | ; cmp eax,5 |
1917 | sub ebx, 2 |
1918 | sub ebx, 2 |
1918 | jnz ngsyse5 |
1919 | jnz ngsyse5 |
1919 | mov eax, [syslang] |
1920 | mov eax, [syslang] |
1920 | mov [esp+32], eax |
1921 | mov [esp+32], eax |
1921 | ret |
1922 | ret |
1922 | ngsyse5: |
1923 | ngsyse5: |
1923 | ; cmp eax,7 |
1924 | ; cmp eax,7 |
1924 | sub ebx, 2 |
1925 | sub ebx, 2 |
1925 | jnz ngsyse7 |
1926 | jnz ngsyse7 |
1926 | xor eax, eax |
1927 | xor eax, eax |
1927 | mov [esp+32], eax |
1928 | mov [esp+32], eax |
1928 | ret |
1929 | ret |
1929 | ngsyse7: |
1930 | ngsyse7: |
1930 | ; cmp eax,8 |
1931 | ; cmp eax,8 |
1931 | dec ebx |
1932 | dec ebx |
1932 | jnz ngsyse8 |
1933 | jnz ngsyse8 |
1933 | mov eax, [fat32part] |
1934 | mov eax, [fat32part] |
1934 | mov [esp+32], eax |
1935 | mov [esp+32], eax |
1935 | ret |
1936 | ret |
1936 | ngsyse8: |
1937 | ngsyse8: |
1937 | ; cmp eax,9 |
1938 | ; cmp eax,9 |
1938 | dec ebx |
1939 | dec ebx |
1939 | jnz ngsyse9 |
1940 | jnz ngsyse9 |
1940 | mov eax, [timer_ticks];[0xfdf0] |
1941 | mov eax, [timer_ticks];[0xfdf0] |
1941 | mov [esp+32], eax |
1942 | mov [esp+32], eax |
1942 | ret |
1943 | ret |
1943 | ngsyse9: |
1944 | ngsyse9: |
1944 | ; cmp eax,11 |
1945 | ; cmp eax,11 |
1945 | sub ebx, 2 |
1946 | sub ebx, 2 |
1946 | jnz ngsyse11 |
1947 | jnz ngsyse11 |
1947 | mov eax, [lba_read_enabled] |
1948 | mov eax, [lba_read_enabled] |
1948 | mov [esp+32], eax |
1949 | mov [esp+32], eax |
1949 | ret |
1950 | ret |
1950 | ngsyse11: |
1951 | ngsyse11: |
1951 | ; cmp eax,12 |
1952 | ; cmp eax,12 |
1952 | dec ebx |
1953 | dec ebx |
1953 | jnz ngsyse12 |
1954 | jnz ngsyse12 |
1954 | mov eax, [pci_access_enabled] |
1955 | mov eax, [pci_access_enabled] |
1955 | mov [esp+32], eax |
1956 | mov [esp+32], eax |
1956 | ret |
1957 | ret |
1957 | ngsyse12: |
1958 | ngsyse12: |
1958 | mov [esp+32], dword 1 |
1959 | mov [esp+32], dword 1 |
1959 | ret |
1960 | ret |
1960 | 1961 | ||
1961 | 1962 | ||
1962 | get_timer_ticks: |
1963 | get_timer_ticks: |
1963 | mov eax, [timer_ticks] |
1964 | mov eax, [timer_ticks] |
1964 | ret |
1965 | ret |
1965 | 1966 | ||
1966 | iglobal |
1967 | iglobal |
1967 | align 4 |
1968 | align 4 |
1968 | mousefn dd msscreen, mswin, msbutton, msset |
1969 | mousefn dd msscreen, mswin, msbutton, msset |
1969 | dd app_load_cursor |
1970 | dd app_load_cursor |
1970 | dd app_set_cursor |
1971 | dd app_set_cursor |
1971 | dd app_delete_cursor |
1972 | dd app_delete_cursor |
1972 | dd msz |
1973 | dd msz |
1973 | endg |
1974 | endg |
1974 | 1975 | ||
1975 | readmousepos: |
1976 | readmousepos: |
1976 | 1977 | ||
1977 | ; eax=0 screen relative |
1978 | ; eax=0 screen relative |
1978 | ; eax=1 window relative |
1979 | ; eax=1 window relative |
1979 | ; eax=2 buttons pressed |
1980 | ; eax=2 buttons pressed |
1980 | ; eax=3 set mouse pos ; reserved |
1981 | ; eax=3 set mouse pos ; reserved |
1981 | ; eax=4 load cursor |
1982 | ; eax=4 load cursor |
1982 | ; eax=5 set cursor |
1983 | ; eax=5 set cursor |
1983 | ; eax=6 delete cursor ; reserved |
1984 | ; eax=6 delete cursor ; reserved |
1984 | ; eax=7 get mouse_z |
1985 | ; eax=7 get mouse_z |
1985 | 1986 | ||
1986 | cmp ebx, 7 |
1987 | cmp ebx, 7 |
1987 | ja msset |
1988 | ja msset |
1988 | jmp [mousefn+ebx*4] |
1989 | jmp [mousefn+ebx*4] |
1989 | msscreen: |
1990 | msscreen: |
1990 | mov eax, [MOUSE_X] |
1991 | mov eax, [MOUSE_X] |
1991 | shl eax, 16 |
1992 | shl eax, 16 |
1992 | mov ax, [MOUSE_Y] |
1993 | mov ax, [MOUSE_Y] |
1993 | mov [esp+36-4], eax |
1994 | mov [esp+36-4], eax |
1994 | ret |
1995 | ret |
1995 | mswin: |
1996 | mswin: |
1996 | mov eax, [MOUSE_X] |
1997 | mov eax, [MOUSE_X] |
1997 | shl eax, 16 |
1998 | shl eax, 16 |
1998 | mov ax, [MOUSE_Y] |
1999 | mov ax, [MOUSE_Y] |
1999 | mov esi, [TASK_BASE] |
2000 | mov esi, [TASK_BASE] |
2000 | mov bx, word [esi-twdw+WDATA.box.left] |
2001 | mov bx, word [esi-twdw+WDATA.box.left] |
2001 | shl ebx, 16 |
2002 | shl ebx, 16 |
2002 | mov bx, word [esi-twdw+WDATA.box.top] |
2003 | mov bx, word [esi-twdw+WDATA.box.top] |
2003 | sub eax, ebx |
2004 | sub eax, ebx |
2004 | 2005 | ||
2005 | mov edi, [CURRENT_TASK] |
2006 | mov edi, [CURRENT_TASK] |
2006 | shl edi, 8 |
2007 | shl edi, 8 |
2007 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
2008 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
2008 | rol eax, 16 |
2009 | rol eax, 16 |
2009 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
2010 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
2010 | rol eax, 16 |
2011 | rol eax, 16 |
2011 | mov [esp+36-4], eax |
2012 | mov [esp+36-4], eax |
2012 | ret |
2013 | ret |
2013 | msbutton: |
2014 | msbutton: |
2014 | movzx eax, byte [BTN_DOWN] |
2015 | movzx eax, byte [BTN_DOWN] |
2015 | mov [esp+36-4], eax |
2016 | mov [esp+36-4], eax |
2016 | ret |
2017 | ret |
2017 | msz: |
2018 | msz: |
2018 | mov edi, [TASK_COUNT] |
2019 | mov edi, [TASK_COUNT] |
2019 | movzx edi, word [WIN_POS + edi*2] |
2020 | movzx edi, word [WIN_POS + edi*2] |
2020 | cmp edi, [CURRENT_TASK] |
2021 | cmp edi, [CURRENT_TASK] |
2021 | jne @f |
2022 | jne @f |
2022 | mov ax, [MOUSE_SCROLL_H] |
2023 | mov ax, [MOUSE_SCROLL_H] |
2023 | shl eax, 16 |
2024 | shl eax, 16 |
2024 | mov ax, [MOUSE_SCROLL_V] |
2025 | mov ax, [MOUSE_SCROLL_V] |
2025 | mov [esp+36-4], eax |
2026 | mov [esp+36-4], eax |
2026 | and [MOUSE_SCROLL_H], word 0 |
2027 | and [MOUSE_SCROLL_H], word 0 |
2027 | and [MOUSE_SCROLL_V], word 0 |
2028 | and [MOUSE_SCROLL_V], word 0 |
2028 | ret |
2029 | ret |
2029 | @@: |
2030 | @@: |
2030 | and [esp+36-4], dword 0 |
2031 | and [esp+36-4], dword 0 |
2031 | ; ret |
2032 | ; ret |
2032 | msset: |
2033 | msset: |
2033 | ret |
2034 | ret |
2034 | 2035 | ||
2035 | app_load_cursor: |
2036 | app_load_cursor: |
2036 | cmp ecx, OS_BASE |
2037 | cmp ecx, OS_BASE |
2037 | jae msset |
2038 | jae msset |
2038 | stdcall load_cursor, ecx, edx |
2039 | stdcall load_cursor, ecx, edx |
2039 | mov [esp+36-4], eax |
2040 | mov [esp+36-4], eax |
2040 | ret |
2041 | ret |
2041 | 2042 | ||
2042 | app_set_cursor: |
2043 | app_set_cursor: |
2043 | stdcall set_cursor, ecx |
2044 | stdcall set_cursor, ecx |
2044 | mov [esp+36-4], eax |
2045 | mov [esp+36-4], eax |
2045 | ret |
2046 | ret |
2046 | 2047 | ||
2047 | app_delete_cursor: |
2048 | app_delete_cursor: |
2048 | stdcall delete_cursor, ecx |
2049 | stdcall delete_cursor, ecx |
2049 | mov [esp+36-4], eax |
2050 | mov [esp+36-4], eax |
2050 | ret |
2051 | ret |
2051 | 2052 | ||
2052 | is_input: |
2053 | is_input: |
2053 | 2054 | ||
2054 | push edx |
2055 | push edx |
2055 | mov dx, word [midisp] |
2056 | mov dx, word [midisp] |
2056 | in al, dx |
2057 | in al, dx |
2057 | and al, 0x80 |
2058 | and al, 0x80 |
2058 | pop edx |
2059 | pop edx |
2059 | ret |
2060 | ret |
2060 | 2061 | ||
2061 | is_output: |
2062 | is_output: |
2062 | 2063 | ||
2063 | push edx |
2064 | push edx |
2064 | mov dx, word [midisp] |
2065 | mov dx, word [midisp] |
2065 | in al, dx |
2066 | in al, dx |
2066 | and al, 0x40 |
2067 | and al, 0x40 |
2067 | pop edx |
2068 | pop edx |
2068 | ret |
2069 | ret |
2069 | 2070 | ||
2070 | 2071 | ||
2071 | get_mpu_in: |
2072 | get_mpu_in: |
2072 | 2073 | ||
2073 | push edx |
2074 | push edx |
2074 | mov dx, word [mididp] |
2075 | mov dx, word [mididp] |
2075 | in al, dx |
2076 | in al, dx |
2076 | pop edx |
2077 | pop edx |
2077 | ret |
2078 | ret |
2078 | 2079 | ||
2079 | 2080 | ||
2080 | put_mpu_out: |
2081 | put_mpu_out: |
2081 | 2082 | ||
2082 | push edx |
2083 | push edx |
2083 | mov dx, word [mididp] |
2084 | mov dx, word [mididp] |
2084 | out dx, al |
2085 | out dx, al |
2085 | pop edx |
2086 | pop edx |
2086 | ret |
2087 | ret |
2087 | 2088 | ||
2088 | 2089 | ||
2089 | 2090 | ||
2090 | align 4 |
2091 | align 4 |
2091 | 2092 | ||
2092 | sys_midi: |
2093 | sys_midi: |
2093 | cmp [mididp], 0 |
2094 | cmp [mididp], 0 |
2094 | jnz sm0 |
2095 | jnz sm0 |
2095 | mov [esp+36], dword 1 |
2096 | mov [esp+36], dword 1 |
2096 | ret |
2097 | ret |
2097 | sm0: |
2098 | sm0: |
2098 | and [esp+36], dword 0 |
2099 | and [esp+36], dword 0 |
2099 | dec ebx |
2100 | dec ebx |
2100 | jnz smn1 |
2101 | jnz smn1 |
2101 | ; call setuart |
2102 | ; call setuart |
2102 | su1: |
2103 | su1: |
2103 | call is_output |
2104 | call is_output |
2104 | test al, al |
2105 | test al, al |
2105 | jnz su1 |
2106 | jnz su1 |
2106 | mov dx, word [midisp] |
2107 | mov dx, word [midisp] |
2107 | mov al, 0xff |
2108 | mov al, 0xff |
2108 | out dx, al |
2109 | out dx, al |
2109 | su2: |
2110 | su2: |
2110 | mov dx, word [midisp] |
2111 | mov dx, word [midisp] |
2111 | mov al, 0xff |
2112 | mov al, 0xff |
2112 | out dx, al |
2113 | out dx, al |
2113 | call is_input |
2114 | call is_input |
2114 | test al, al |
2115 | test al, al |
2115 | jnz su2 |
2116 | jnz su2 |
2116 | call get_mpu_in |
2117 | call get_mpu_in |
2117 | cmp al, 0xfe |
2118 | cmp al, 0xfe |
2118 | jnz su2 |
2119 | jnz su2 |
2119 | su3: |
2120 | su3: |
2120 | call is_output |
2121 | call is_output |
2121 | test al, al |
2122 | test al, al |
2122 | jnz su3 |
2123 | jnz su3 |
2123 | mov dx, word [midisp] |
2124 | mov dx, word [midisp] |
2124 | mov al, 0x3f |
2125 | mov al, 0x3f |
2125 | out dx, al |
2126 | out dx, al |
2126 | ret |
2127 | ret |
2127 | smn1: |
2128 | smn1: |
2128 | dec ebx |
2129 | dec ebx |
2129 | jnz smn2 |
2130 | jnz smn2 |
2130 | sm10: |
2131 | sm10: |
2131 | call get_mpu_in |
2132 | call get_mpu_in |
2132 | call is_output |
2133 | call is_output |
2133 | test al, al |
2134 | test al, al |
2134 | jnz sm10 |
2135 | jnz sm10 |
2135 | mov al, bl |
2136 | mov al, bl |
2136 | call put_mpu_out |
2137 | call put_mpu_out |
2137 | smn2: |
2138 | smn2: |
2138 | ret |
2139 | ret |
2139 | 2140 | ||
2140 | detect_devices: |
2141 | detect_devices: |
2141 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2142 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2142 | ;include 'detect/commouse.inc' |
2143 | ;include 'detect/commouse.inc' |
2143 | ;include 'detect/ps2mouse.inc' |
2144 | ;include 'detect/ps2mouse.inc' |
2144 | ;include 'detect/dev_fd.inc' |
2145 | ;include 'detect/dev_fd.inc' |
2145 | ;include 'detect/dev_hdcd.inc' |
2146 | ;include 'detect/dev_hdcd.inc' |
2146 | ;include 'detect/sear_par.inc' |
2147 | ;include 'detect/sear_par.inc' |
2147 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2148 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2148 | ret |
2149 | ret |
2149 | 2150 | ||
2150 | sys_end: |
2151 | sys_end: |
2151 | ;-------------------------------------- |
2152 | ;-------------------------------------- |
2152 | cmp [_display.select_cursor], 0 |
2153 | cmp [_display.select_cursor], 0 |
2153 | je @f |
2154 | je @f |
2154 | ; restore default cursor before killing |
2155 | ; restore default cursor before killing |
2155 | pusha |
2156 | pusha |
2156 | mov ecx, [current_slot] |
2157 | mov ecx, [current_slot] |
2157 | call restore_default_cursor_before_killing |
2158 | call restore_default_cursor_before_killing |
2158 | popa |
2159 | popa |
2159 | @@: |
2160 | @@: |
2160 | ;-------------------------------------- |
2161 | ;-------------------------------------- |
2161 | ; kill all sockets this process owns |
2162 | ; kill all sockets this process owns |
2162 | pusha |
2163 | pusha |
2163 | mov edx, [TASK_BASE] |
2164 | mov edx, [TASK_BASE] |
2164 | mov edx, [edx+TASKDATA.pid] |
2165 | mov edx, [edx+TASKDATA.pid] |
2165 | call SOCKET_process_end |
2166 | call SOCKET_process_end |
2166 | popa |
2167 | popa |
2167 | ;-------------------------------------- |
2168 | ;-------------------------------------- |
2168 | mov ecx, [current_slot] |
2169 | mov ecx, [current_slot] |
2169 | mov eax, [ecx+APPDATA.tls_base] |
2170 | mov eax, [ecx+APPDATA.tls_base] |
2170 | test eax, eax |
2171 | test eax, eax |
2171 | jz @F |
2172 | jz @F |
2172 | 2173 | ||
2173 | stdcall user_free, eax |
2174 | stdcall user_free, eax |
2174 | @@: |
2175 | @@: |
2175 | 2176 | ||
2176 | mov eax, [TASK_BASE] |
2177 | mov eax, [TASK_BASE] |
2177 | mov [eax+TASKDATA.state], 3; terminate this program |
2178 | mov [eax+TASKDATA.state], 3; terminate this program |
2178 | call wakeup_osloop |
2179 | call wakeup_osloop |
2179 | 2180 | ||
2180 | .waitterm: ; wait here for termination |
2181 | .waitterm: ; wait here for termination |
2181 | call change_task |
2182 | call change_task |
2182 | jmp .waitterm |
2183 | jmp .waitterm |
2183 | ;------------------------------------------------------------------------------ |
2184 | ;------------------------------------------------------------------------------ |
2184 | align 4 |
2185 | align 4 |
2185 | restore_default_cursor_before_killing: |
2186 | restore_default_cursor_before_killing: |
2186 | pushfd |
2187 | pushfd |
2187 | cli |
2188 | cli |
2188 | mov eax, [def_cursor] |
2189 | mov eax, [def_cursor] |
2189 | mov [ecx+APPDATA.cursor], eax |
2190 | mov [ecx+APPDATA.cursor], eax |
2190 | 2191 | ||
2191 | movzx eax, word [MOUSE_Y] |
2192 | movzx eax, word [MOUSE_Y] |
2192 | movzx ebx, word [MOUSE_X] |
2193 | movzx ebx, word [MOUSE_X] |
2193 | ; mov ecx, [Screen_Max_X] |
2194 | ; mov ecx, [Screen_Max_X] |
2194 | ; inc ecx |
2195 | ; inc ecx |
2195 | ; mul ecx |
2196 | ; mul ecx |
2196 | mov eax, [d_width_calc_area + eax*4] |
2197 | mov eax, [d_width_calc_area + eax*4] |
2197 | 2198 | ||
2198 | add eax, [_WinMapAddress] |
2199 | add eax, [_WinMapAddress] |
2199 | movzx edx, byte [ebx+eax] |
2200 | movzx edx, byte [ebx+eax] |
2200 | shl edx, 8 |
2201 | shl edx, 8 |
2201 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2202 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2202 | 2203 | ||
2203 | cmp esi, [current_cursor] |
2204 | cmp esi, [current_cursor] |
2204 | je @f |
2205 | je @f |
2205 | 2206 | ||
2206 | push esi |
2207 | push esi |
2207 | call [_display.select_cursor] |
2208 | call [_display.select_cursor] |
2208 | mov [current_cursor], esi |
2209 | mov [current_cursor], esi |
2209 | @@: |
2210 | @@: |
2210 | mov [redrawmouse_unconditional], 1 |
2211 | mov [redrawmouse_unconditional], 1 |
2211 | call wakeup_osloop |
2212 | call wakeup_osloop |
2212 | popfd |
2213 | popfd |
2213 | ret |
2214 | ret |
2214 | ;------------------------------------------------------------------------------ |
2215 | ;------------------------------------------------------------------------------ |
2215 | iglobal |
2216 | iglobal |
2216 | align 4 |
2217 | align 4 |
2217 | sys_system_table: |
2218 | sys_system_table: |
2218 | dd sysfn_deactivate ; 1 = deactivate window |
2219 | dd sysfn_deactivate ; 1 = deactivate window |
2219 | dd sysfn_terminate ; 2 = terminate thread |
2220 | dd sysfn_terminate ; 2 = terminate thread |
2220 | dd sysfn_activate ; 3 = activate window |
2221 | dd sysfn_activate ; 3 = activate window |
2221 | dd sysfn_getidletime ; 4 = get idle time |
2222 | dd sysfn_getidletime ; 4 = get idle time |
2222 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2223 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2223 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2224 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2224 | dd sysfn_getactive ; 7 = get active window |
2225 | dd sysfn_getactive ; 7 = get active window |
2225 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2226 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2226 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2227 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2227 | dd sysfn_minimize ; 10 = minimize window |
2228 | dd sysfn_minimize ; 10 = minimize window |
2228 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2229 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2229 | dd sysfn_lastkey ; 12 = get last pressed key |
2230 | dd sysfn_lastkey ; 12 = get last pressed key |
2230 | dd sysfn_getversion ; 13 = get kernel version |
2231 | dd sysfn_getversion ; 13 = get kernel version |
2231 | dd sysfn_waitretrace ; 14 = wait retrace |
2232 | dd sysfn_waitretrace ; 14 = wait retrace |
2232 | dd sysfn_centermouse ; 15 = center mouse cursor |
2233 | dd sysfn_centermouse ; 15 = center mouse cursor |
2233 | dd sysfn_getfreemem ; 16 = get free memory size |
2234 | dd sysfn_getfreemem ; 16 = get free memory size |
2234 | dd sysfn_getallmem ; 17 = get total memory size |
2235 | dd sysfn_getallmem ; 17 = get total memory size |
2235 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2236 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2236 | ; instead of slot |
2237 | ; instead of slot |
2237 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2238 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2238 | dd sysfn_meminfo ; 20 = get extended memory info |
2239 | dd sysfn_meminfo ; 20 = get extended memory info |
2239 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2240 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2240 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2241 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2241 | dd sysfn_min_windows ; 23 = minimize all windows |
2242 | dd sysfn_min_windows ; 23 = minimize all windows |
2242 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2243 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2243 | sysfn_num = ($ - sys_system_table)/4 |
2244 | sysfn_num = ($ - sys_system_table)/4 |
2244 | endg |
2245 | endg |
2245 | ;------------------------------------------------------------------------------ |
2246 | ;------------------------------------------------------------------------------ |
2246 | sys_system: |
2247 | sys_system: |
2247 | dec ebx |
2248 | dec ebx |
2248 | cmp ebx, sysfn_num |
2249 | cmp ebx, sysfn_num |
2249 | jae @f |
2250 | jae @f |
2250 | jmp dword [sys_system_table + ebx*4] |
2251 | jmp dword [sys_system_table + ebx*4] |
2251 | @@: |
2252 | @@: |
2252 | ret |
2253 | ret |
2253 | ;------------------------------------------------------------------------------ |
2254 | ;------------------------------------------------------------------------------ |
2254 | sysfn_shutdown: ; 18.9 = system shutdown |
2255 | sysfn_shutdown: ; 18.9 = system shutdown |
2255 | cmp ecx, 1 |
2256 | cmp ecx, 1 |
2256 | jl exit_for_anyone |
2257 | jl exit_for_anyone |
2257 | cmp ecx, 4 |
2258 | cmp ecx, 4 |
2258 | jg exit_for_anyone |
2259 | jg exit_for_anyone |
2259 | mov [BOOT_VARS+0x9030], cl |
2260 | mov [BOOT_VARS+0x9030], cl |
2260 | 2261 | ||
2261 | mov eax, [TASK_COUNT] |
2262 | mov eax, [TASK_COUNT] |
2262 | mov [SYS_SHUTDOWN], al |
2263 | mov [SYS_SHUTDOWN], al |
2263 | mov [shutdown_processes], eax |
2264 | mov [shutdown_processes], eax |
2264 | call wakeup_osloop |
2265 | call wakeup_osloop |
2265 | and dword [esp+32], 0 |
2266 | and dword [esp+32], 0 |
2266 | exit_for_anyone: |
2267 | exit_for_anyone: |
2267 | ret |
2268 | ret |
2268 | uglobal |
2269 | uglobal |
2269 | shutdown_processes: |
2270 | shutdown_processes: |
2270 | dd 0x0 |
2271 | dd 0x0 |
2271 | endg |
2272 | endg |
2272 | ;------------------------------------------------------------------------------ |
2273 | ;------------------------------------------------------------------------------ |
2273 | sysfn_terminate: ; 18.2 = TERMINATE |
2274 | sysfn_terminate: ; 18.2 = TERMINATE |
2274 | push ecx |
2275 | push ecx |
2275 | cmp ecx, 2 |
2276 | cmp ecx, 2 |
2276 | jb noprocessterminate |
2277 | jb noprocessterminate |
2277 | mov edx, [TASK_COUNT] |
2278 | mov edx, [TASK_COUNT] |
2278 | cmp ecx, edx |
2279 | cmp ecx, edx |
2279 | ja noprocessterminate |
2280 | ja noprocessterminate |
2280 | mov eax, [TASK_COUNT] |
2281 | mov eax, [TASK_COUNT] |
2281 | shl ecx, 5 |
2282 | shl ecx, 5 |
2282 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2283 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2283 | add ecx, CURRENT_TASK+TASKDATA.state |
2284 | add ecx, CURRENT_TASK+TASKDATA.state |
2284 | cmp byte [ecx], 9 |
2285 | cmp byte [ecx], 9 |
2285 | jz noprocessterminate |
2286 | jz noprocessterminate |
2286 | push ecx edx |
2287 | push ecx edx |
2287 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2288 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2288 | call request_terminate |
2289 | call request_terminate |
2289 | pop edx ecx |
2290 | pop edx ecx |
2290 | test eax, eax |
2291 | test eax, eax |
2291 | jz noprocessterminate |
2292 | jz noprocessterminate |
2292 | ;-------------------------------------- |
2293 | ;-------------------------------------- |
2293 | ; terminate all network sockets it used |
2294 | ; terminate all network sockets it used |
2294 | pusha |
2295 | pusha |
2295 | mov eax, edx |
2296 | mov eax, edx |
2296 | call SOCKET_process_end |
2297 | call SOCKET_process_end |
2297 | popa |
2298 | popa |
2298 | ;-------------------------------------- |
2299 | ;-------------------------------------- |
2299 | cmp [_display.select_cursor], 0 |
2300 | cmp [_display.select_cursor], 0 |
2300 | je .restore_end |
2301 | je .restore_end |
2301 | ; restore default cursor before killing |
2302 | ; restore default cursor before killing |
2302 | pusha |
2303 | pusha |
2303 | mov ecx, [esp+32] |
2304 | mov ecx, [esp+32] |
2304 | shl ecx, 8 |
2305 | shl ecx, 8 |
2305 | add ecx, SLOT_BASE |
2306 | add ecx, SLOT_BASE |
2306 | mov eax, [def_cursor] |
2307 | mov eax, [def_cursor] |
2307 | cmp [ecx+APPDATA.cursor], eax |
2308 | cmp [ecx+APPDATA.cursor], eax |
2308 | je @f |
2309 | je @f |
2309 | call restore_default_cursor_before_killing |
2310 | call restore_default_cursor_before_killing |
2310 | @@: |
2311 | @@: |
2311 | popa |
2312 | popa |
2312 | .restore_end: |
2313 | .restore_end: |
2313 | ;-------------------------------------- |
2314 | ;-------------------------------------- |
2314 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2315 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2315 | mov [ecx], byte 3; clear possible i40's |
2316 | mov [ecx], byte 3; clear possible i40's |
2316 | call wakeup_osloop |
2317 | call wakeup_osloop |
2317 | ;call MEM_Heap_UnLock |
2318 | ;call MEM_Heap_UnLock |
2318 | 2319 | ||
2319 | cmp edx, [application_table_owner]; clear app table stat |
2320 | cmp edx, [application_table_owner]; clear app table stat |
2320 | jne noatsc |
2321 | jne noatsc |
2321 | call unlock_application_table |
2322 | call unlock_application_table |
2322 | noatsc: |
2323 | noatsc: |
2323 | noprocessterminate: |
2324 | noprocessterminate: |
2324 | add esp, 4 |
2325 | add esp, 4 |
2325 | ret |
2326 | ret |
2326 | ;------------------------------------------------------------------------------ |
2327 | ;------------------------------------------------------------------------------ |
2327 | sysfn_terminate2: |
2328 | sysfn_terminate2: |
2328 | ;lock application_table_status mutex |
2329 | ;lock application_table_status mutex |
2329 | .table_status: |
2330 | .table_status: |
2330 | call lock_application_table |
2331 | call lock_application_table |
2331 | mov eax, ecx |
2332 | mov eax, ecx |
2332 | call pid_to_slot |
2333 | call pid_to_slot |
2333 | test eax, eax |
2334 | test eax, eax |
2334 | jz .not_found |
2335 | jz .not_found |
2335 | mov ecx, eax |
2336 | mov ecx, eax |
2336 | cli |
2337 | cli |
2337 | call sysfn_terminate |
2338 | call sysfn_terminate |
2338 | call unlock_application_table |
2339 | call unlock_application_table |
2339 | sti |
2340 | sti |
2340 | and dword [esp+32], 0 |
2341 | and dword [esp+32], 0 |
2341 | ret |
2342 | ret |
2342 | .not_found: |
2343 | .not_found: |
2343 | call unlock_application_table |
2344 | call unlock_application_table |
2344 | or dword [esp+32], -1 |
2345 | or dword [esp+32], -1 |
2345 | ret |
2346 | ret |
2346 | ;------------------------------------------------------------------------------ |
2347 | ;------------------------------------------------------------------------------ |
2347 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2348 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2348 | cmp ecx, 2 |
2349 | cmp ecx, 2 |
2349 | jb .nowindowdeactivate |
2350 | jb .nowindowdeactivate |
2350 | cmp ecx, [TASK_COUNT] |
2351 | cmp ecx, [TASK_COUNT] |
2351 | ja .nowindowdeactivate |
2352 | ja .nowindowdeactivate |
2352 | 2353 | ||
2353 | movzx esi, word [WIN_STACK + ecx*2] |
2354 | movzx esi, word [WIN_STACK + ecx*2] |
2354 | cmp esi, 1 |
2355 | cmp esi, 1 |
2355 | je .nowindowdeactivate ; already deactive |
2356 | je .nowindowdeactivate ; already deactive |
2356 | 2357 | ||
2357 | mov edi, ecx |
2358 | mov edi, ecx |
2358 | shl edi, 5 |
2359 | shl edi, 5 |
2359 | add edi, window_data |
2360 | add edi, window_data |
2360 | movzx esi, word [WIN_STACK + ecx * 2] |
2361 | movzx esi, word [WIN_STACK + ecx * 2] |
2361 | lea esi, [WIN_POS + esi * 2] |
2362 | lea esi, [WIN_POS + esi * 2] |
2362 | call window._.window_deactivate |
2363 | call window._.window_deactivate |
2363 | 2364 | ||
2364 | call syscall_display_settings._.calculate_whole_screen |
2365 | call syscall_display_settings._.calculate_whole_screen |
2365 | call syscall_display_settings._.redraw_whole_screen |
2366 | call syscall_display_settings._.redraw_whole_screen |
2366 | .nowindowdeactivate: |
2367 | .nowindowdeactivate: |
2367 | ret |
2368 | ret |
2368 | ;------------------------------------------------------------------------------ |
2369 | ;------------------------------------------------------------------------------ |
2369 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2370 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2370 | cmp ecx, 2 |
2371 | cmp ecx, 2 |
2371 | jb .nowindowactivate |
2372 | jb .nowindowactivate |
2372 | cmp ecx, [TASK_COUNT] |
2373 | cmp ecx, [TASK_COUNT] |
2373 | ja .nowindowactivate |
2374 | ja .nowindowactivate |
2374 | ;------------------------------------- |
2375 | ;------------------------------------- |
2375 | @@: |
2376 | @@: |
2376 | ; If the window is captured and moved by the user, |
2377 | ; If the window is captured and moved by the user, |
2377 | ; then you can't change the position in window stack!!! |
2378 | ; then you can't change the position in window stack!!! |
2378 | mov al, [mouse.active_sys_window.action] |
2379 | mov al, [mouse.active_sys_window.action] |
2379 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2380 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2380 | test al, al |
2381 | test al, al |
2381 | jz @f |
2382 | jz @f |
2382 | call change_task |
2383 | call change_task |
2383 | jmp @b |
2384 | jmp @b |
2384 | @@: |
2385 | @@: |
2385 | ;------------------------------------- |
2386 | ;------------------------------------- |
2386 | mov [window_minimize], 2; restore window if minimized |
2387 | mov [window_minimize], 2; restore window if minimized |
2387 | call wakeup_osloop |
2388 | call wakeup_osloop |
2388 | 2389 | ||
2389 | movzx esi, word [WIN_STACK + ecx*2] |
2390 | movzx esi, word [WIN_STACK + ecx*2] |
2390 | cmp esi, [TASK_COUNT] |
2391 | cmp esi, [TASK_COUNT] |
2391 | je .nowindowactivate; already active |
2392 | je .nowindowactivate; already active |
2392 | 2393 | ||
2393 | mov edi, ecx |
2394 | mov edi, ecx |
2394 | shl edi, 5 |
2395 | shl edi, 5 |
2395 | add edi, window_data |
2396 | add edi, window_data |
2396 | movzx esi, word [WIN_STACK + ecx * 2] |
2397 | movzx esi, word [WIN_STACK + ecx * 2] |
2397 | lea esi, [WIN_POS + esi * 2] |
2398 | lea esi, [WIN_POS + esi * 2] |
2398 | call waredraw |
2399 | call waredraw |
2399 | .nowindowactivate: |
2400 | .nowindowactivate: |
2400 | ret |
2401 | ret |
2401 | ;------------------------------------------------------------------------------ |
2402 | ;------------------------------------------------------------------------------ |
2402 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2403 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2403 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2404 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2404 | mov [esp+32], eax |
2405 | mov [esp+32], eax |
2405 | ret |
2406 | ret |
2406 | ;------------------------------------------------------------------------------ |
2407 | ;------------------------------------------------------------------------------ |
2407 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2408 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2408 | mov eax, dword [cpu_freq] |
2409 | mov eax, dword [cpu_freq] |
2409 | mov [esp+32], eax |
2410 | mov [esp+32], eax |
2410 | ret |
2411 | ret |
2411 | ;------------------------------------------------------------------------------ |
2412 | ;------------------------------------------------------------------------------ |
2412 | get_cpu_freq: |
2413 | get_cpu_freq: |
2413 | mov eax, dword [cpu_freq] |
2414 | mov eax, dword [cpu_freq] |
2414 | mov edx, dword [cpu_freq+4] |
2415 | mov edx, dword [cpu_freq+4] |
2415 | ret |
2416 | ret |
2416 | ; SAVE ramdisk to /hd/1/menuet.img |
2417 | ; SAVE ramdisk to /hd/1/menuet.img |
2417 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2418 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2418 | include 'blkdev/rdsave.inc' |
2419 | include 'blkdev/rdsave.inc' |
2419 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2420 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2420 | ;------------------------------------------------------------------------------ |
2421 | ;------------------------------------------------------------------------------ |
2421 | align 4 |
2422 | align 4 |
2422 | sysfn_getactive: ; 18.7 = get active window |
2423 | sysfn_getactive: ; 18.7 = get active window |
2423 | mov eax, [TASK_COUNT] |
2424 | mov eax, [TASK_COUNT] |
2424 | movzx eax, word [WIN_POS + eax*2] |
2425 | movzx eax, word [WIN_POS + eax*2] |
2425 | mov [esp+32], eax |
2426 | mov [esp+32], eax |
2426 | ret |
2427 | ret |
2427 | ;------------------------------------------------------------------------------ |
2428 | ;------------------------------------------------------------------------------ |
2428 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2429 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2429 | ; cmp ecx,1 |
2430 | ; cmp ecx,1 |
2430 | dec ecx |
2431 | dec ecx |
2431 | jnz nogetsoundflag |
2432 | jnz nogetsoundflag |
2432 | movzx eax, byte [sound_flag]; get sound_flag |
2433 | movzx eax, byte [sound_flag]; get sound_flag |
2433 | mov [esp+32], eax |
2434 | mov [esp+32], eax |
2434 | ret |
2435 | ret |
2435 | nogetsoundflag: |
2436 | nogetsoundflag: |
2436 | ; cmp ecx,2 |
2437 | ; cmp ecx,2 |
2437 | dec ecx |
2438 | dec ecx |
2438 | jnz nosoundflag |
2439 | jnz nosoundflag |
2439 | xor byte [sound_flag], 1 |
2440 | xor byte [sound_flag], 1 |
2440 | nosoundflag: |
2441 | nosoundflag: |
2441 | ret |
2442 | ret |
2442 | ;------------------------------------------------------------------------------ |
2443 | ;------------------------------------------------------------------------------ |
2443 | sysfn_minimize: ; 18.10 = minimize window |
2444 | sysfn_minimize: ; 18.10 = minimize window |
2444 | mov [window_minimize], 1 |
2445 | mov [window_minimize], 1 |
2445 | call wakeup_osloop |
2446 | call wakeup_osloop |
2446 | ret |
2447 | ret |
2447 | ;------------------------------------------------------------------------------ |
2448 | ;------------------------------------------------------------------------------ |
2448 | align 4 |
2449 | align 4 |
2449 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2450 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2450 | ; cmp ecx,1 |
2451 | ; cmp ecx,1 |
2451 | dec ecx |
2452 | dec ecx |
2452 | jnz full_table |
2453 | jnz full_table |
2453 | small_table: |
2454 | small_table: |
2454 | call for_all_tables |
2455 | call for_all_tables |
2455 | mov ecx, 10 |
2456 | mov ecx, 10 |
2456 | cld |
2457 | cld |
2457 | rep movsb |
2458 | rep movsb |
2458 | ret |
2459 | ret |
2459 | for_all_tables: |
2460 | for_all_tables: |
2460 | mov edi, edx |
2461 | mov edi, edx |
2461 | mov esi, DRIVE_DATA |
2462 | mov esi, DRIVE_DATA |
2462 | ret |
2463 | ret |
2463 | full_table: |
2464 | full_table: |
2464 | ; cmp ecx,2 |
2465 | ; cmp ecx,2 |
2465 | dec ecx |
2466 | dec ecx |
2466 | jnz exit_for_anyone |
2467 | jnz exit_for_anyone |
2467 | call for_all_tables |
2468 | call for_all_tables |
2468 | mov ecx, DRIVE_DATA_SIZE/4 |
2469 | mov ecx, DRIVE_DATA_SIZE/4 |
2469 | cld |
2470 | cld |
2470 | rep movsd |
2471 | rep movsd |
2471 | ret |
2472 | ret |
2472 | ;------------------------------------------------------------------------------ |
2473 | ;------------------------------------------------------------------------------ |
2473 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2474 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2474 | and dword [esp+32], 0 |
2475 | and dword [esp+32], 0 |
2475 | ret |
2476 | ret |
2476 | ;------------------------------------------------------------------------------ |
2477 | ;------------------------------------------------------------------------------ |
2477 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2478 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2478 | mov edi, ecx |
2479 | mov edi, ecx |
2479 | mov esi, version_inf |
2480 | mov esi, version_inf |
2480 | mov ecx, version_end-version_inf |
2481 | mov ecx, version_end-version_inf |
2481 | rep movsb |
2482 | rep movsb |
2482 | ret |
2483 | ret |
2483 | ;------------------------------------------------------------------------------ |
2484 | ;------------------------------------------------------------------------------ |
2484 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2485 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2485 | ;wait retrace functions |
2486 | ;wait retrace functions |
2486 | sys_wait_retrace: |
2487 | sys_wait_retrace: |
2487 | mov edx, 0x3da |
2488 | mov edx, 0x3da |
2488 | WaitRetrace_loop: |
2489 | WaitRetrace_loop: |
2489 | in al, dx |
2490 | in al, dx |
2490 | test al, 1000b |
2491 | test al, 1000b |
2491 | jz WaitRetrace_loop |
2492 | jz WaitRetrace_loop |
2492 | and [esp+32], dword 0 |
2493 | and [esp+32], dword 0 |
2493 | ret |
2494 | ret |
2494 | ;------------------------------------------------------------------------------ |
2495 | ;------------------------------------------------------------------------------ |
2495 | align 4 |
2496 | align 4 |
2496 | sysfn_centermouse: ; 18.15 = mouse centered |
2497 | sysfn_centermouse: ; 18.15 = mouse centered |
2497 | ; removed here by |
2498 | ; removed here by |
2498 | ; call mouse_centered |
2499 | ; call mouse_centered |
2499 | ;* mouse centered - start code- Mario79 |
2500 | ;* mouse centered - start code- Mario79 |
2500 | ;mouse_centered: |
2501 | ;mouse_centered: |
2501 | ; push eax |
2502 | ; push eax |
2502 | mov eax, [Screen_Max_X] |
2503 | mov eax, [Screen_Max_X] |
2503 | shr eax, 1 |
2504 | shr eax, 1 |
2504 | mov [MOUSE_X], ax |
2505 | mov [MOUSE_X], ax |
2505 | mov eax, [Screen_Max_Y] |
2506 | mov eax, [Screen_Max_Y] |
2506 | shr eax, 1 |
2507 | shr eax, 1 |
2507 | mov [MOUSE_Y], ax |
2508 | mov [MOUSE_Y], ax |
2508 | call wakeup_osloop |
2509 | call wakeup_osloop |
2509 | ; ret |
2510 | ; ret |
2510 | ;* mouse centered - end code- Mario79 |
2511 | ;* mouse centered - end code- Mario79 |
2511 | xor eax, eax |
2512 | xor eax, eax |
2512 | and [esp+32], eax |
2513 | and [esp+32], eax |
2513 | ; pop eax |
2514 | ; pop eax |
2514 | ret |
2515 | ret |
2515 | ;------------------------------------------------------------------------------ |
2516 | ;------------------------------------------------------------------------------ |
2516 | align 4 |
2517 | align 4 |
2517 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2518 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2518 | test ecx, ecx; get mouse speed factor |
2519 | test ecx, ecx; get mouse speed factor |
2519 | jnz .set_mouse_acceleration |
2520 | jnz .set_mouse_acceleration |
2520 | xor eax, eax |
2521 | xor eax, eax |
2521 | mov ax, [mouse_speed_factor] |
2522 | mov ax, [mouse_speed_factor] |
2522 | mov [esp+32], eax |
2523 | mov [esp+32], eax |
2523 | ret |
2524 | ret |
2524 | .set_mouse_acceleration: |
2525 | .set_mouse_acceleration: |
2525 | ; cmp ecx,1 ; set mouse speed factor |
2526 | ; cmp ecx,1 ; set mouse speed factor |
2526 | dec ecx |
2527 | dec ecx |
2527 | jnz .get_mouse_delay |
2528 | jnz .get_mouse_delay |
2528 | mov [mouse_speed_factor], dx |
2529 | mov [mouse_speed_factor], dx |
2529 | ret |
2530 | ret |
2530 | .get_mouse_delay: |
2531 | .get_mouse_delay: |
2531 | ; cmp ecx,2 ; get mouse delay |
2532 | ; cmp ecx,2 ; get mouse delay |
2532 | dec ecx |
2533 | dec ecx |
2533 | jnz .set_mouse_delay |
2534 | jnz .set_mouse_delay |
2534 | mov eax, [mouse_delay] |
2535 | mov eax, [mouse_delay] |
2535 | mov [esp+32], eax |
2536 | mov [esp+32], eax |
2536 | ret |
2537 | ret |
2537 | .set_mouse_delay: |
2538 | .set_mouse_delay: |
2538 | ; cmp ecx,3 ; set mouse delay |
2539 | ; cmp ecx,3 ; set mouse delay |
2539 | dec ecx |
2540 | dec ecx |
2540 | jnz .set_pointer_position |
2541 | jnz .set_pointer_position |
2541 | mov [mouse_delay], edx |
2542 | mov [mouse_delay], edx |
2542 | ret |
2543 | ret |
2543 | .set_pointer_position: |
2544 | .set_pointer_position: |
2544 | ; cmp ecx,4 ; set mouse pointer position |
2545 | ; cmp ecx,4 ; set mouse pointer position |
2545 | dec ecx |
2546 | dec ecx |
2546 | jnz .set_mouse_button |
2547 | jnz .set_mouse_button |
2547 | cmp dx, word[Screen_Max_Y] |
2548 | cmp dx, word[Screen_Max_Y] |
2548 | ja .end |
2549 | ja .end |
2549 | rol edx, 16 |
2550 | rol edx, 16 |
2550 | cmp dx, word[Screen_Max_X] |
2551 | cmp dx, word[Screen_Max_X] |
2551 | ja .end |
2552 | ja .end |
2552 | mov [MOUSE_X], edx |
2553 | mov [MOUSE_X], edx |
2553 | call wakeup_osloop |
2554 | call wakeup_osloop |
2554 | ret |
2555 | ret |
2555 | .set_mouse_button: |
2556 | .set_mouse_button: |
2556 | ; cmp ecx,5 ; set mouse button features |
2557 | ; cmp ecx,5 ; set mouse button features |
2557 | dec ecx |
2558 | dec ecx |
2558 | jnz .end |
2559 | jnz .end |
2559 | mov [BTN_DOWN], dl |
2560 | mov [BTN_DOWN], dl |
2560 | mov [mouse_active], 1 |
2561 | mov [mouse_active], 1 |
2561 | call wakeup_osloop |
2562 | call wakeup_osloop |
2562 | .end: |
2563 | .end: |
2563 | ret |
2564 | ret |
2564 | ;------------------------------------------------------------------------------ |
2565 | ;------------------------------------------------------------------------------ |
2565 | sysfn_getfreemem: |
2566 | sysfn_getfreemem: |
2566 | mov eax, [pg_data.pages_free] |
2567 | mov eax, [pg_data.pages_free] |
2567 | shl eax, 2 |
2568 | shl eax, 2 |
2568 | mov [esp+32], eax |
2569 | mov [esp+32], eax |
2569 | ret |
2570 | ret |
2570 | ;------------------------------------------------------------------------------ |
2571 | ;------------------------------------------------------------------------------ |
2571 | sysfn_getallmem: |
2572 | sysfn_getallmem: |
2572 | mov eax, [MEM_AMOUNT] |
2573 | mov eax, [MEM_AMOUNT] |
2573 | shr eax, 10 |
2574 | shr eax, 10 |
2574 | mov [esp+32], eax |
2575 | mov [esp+32], eax |
2575 | ret |
2576 | ret |
2576 | ;------------------------------------------------------------------------------ |
2577 | ;------------------------------------------------------------------------------ |
2577 | sysfn_pid_to_slot: |
2578 | sysfn_pid_to_slot: |
2578 | mov eax, ecx |
2579 | mov eax, ecx |
2579 | call pid_to_slot |
2580 | call pid_to_slot |
2580 | mov [esp+32], eax |
2581 | mov [esp+32], eax |
2581 | ret |
2582 | ret |
2582 | ;------------------------------------------------------------------------------ |
2583 | ;------------------------------------------------------------------------------ |
2583 | sysfn_min_rest_window: |
2584 | sysfn_min_rest_window: |
2584 | pushad |
2585 | pushad |
2585 | mov eax, edx ; ebx - operating |
2586 | mov eax, edx ; ebx - operating |
2586 | shr ecx, 1 |
2587 | shr ecx, 1 |
2587 | jnc @f |
2588 | jnc @f |
2588 | call pid_to_slot |
2589 | call pid_to_slot |
2589 | @@: |
2590 | @@: |
2590 | or eax, eax ; eax - number of slot |
2591 | or eax, eax ; eax - number of slot |
2591 | jz .error |
2592 | jz .error |
2592 | cmp eax, 255 ; varify maximal slot number |
2593 | cmp eax, 255 ; varify maximal slot number |
2593 | ja .error |
2594 | ja .error |
2594 | movzx eax, word [WIN_STACK + eax*2] |
2595 | movzx eax, word [WIN_STACK + eax*2] |
2595 | shr ecx, 1 |
2596 | shr ecx, 1 |
2596 | jc .restore |
2597 | jc .restore |
2597 | ; .minimize: |
2598 | ; .minimize: |
2598 | call minimize_window |
2599 | call minimize_window |
2599 | jmp .exit |
2600 | jmp .exit |
2600 | .restore: |
2601 | .restore: |
2601 | call restore_minimized_window |
2602 | call restore_minimized_window |
2602 | .exit: |
2603 | .exit: |
2603 | popad |
2604 | popad |
2604 | xor eax, eax |
2605 | xor eax, eax |
2605 | mov [esp+32], eax |
2606 | mov [esp+32], eax |
2606 | ret |
2607 | ret |
2607 | .error: |
2608 | .error: |
2608 | popad |
2609 | popad |
2609 | xor eax, eax |
2610 | xor eax, eax |
2610 | dec eax |
2611 | dec eax |
2611 | mov [esp+32], eax |
2612 | mov [esp+32], eax |
2612 | ret |
2613 | ret |
2613 | ;------------------------------------------------------------------------------ |
2614 | ;------------------------------------------------------------------------------ |
2614 | sysfn_min_windows: |
2615 | sysfn_min_windows: |
2615 | call minimize_all_window |
2616 | call minimize_all_window |
2616 | mov [esp+32], eax |
2617 | mov [esp+32], eax |
2617 | call change_task |
2618 | call change_task |
2618 | ret |
2619 | ret |
2619 | ;------------------------------------------------------------------------------ |
2620 | ;------------------------------------------------------------------------------ |
2620 | sysfn_set_screen_sizes: |
2621 | sysfn_set_screen_sizes: |
2621 | cmp [SCR_MODE], word 0x13 |
2622 | cmp [SCR_MODE], word 0x13 |
2622 | jbe .exit |
2623 | jbe .exit |
2623 | 2624 | ||
2624 | cmp [_display.select_cursor], select_cursor |
2625 | cmp [_display.select_cursor], select_cursor |
2625 | jne .exit |
2626 | jne .exit |
2626 | 2627 | ||
2627 | cmp ecx, [display_width_standard] |
2628 | cmp ecx, [display_width_standard] |
2628 | ja .exit |
2629 | ja .exit |
2629 | 2630 | ||
2630 | cmp edx, [display_height_standard] |
2631 | cmp edx, [display_height_standard] |
2631 | ja .exit |
2632 | ja .exit |
2632 | 2633 | ||
2633 | pushfd |
2634 | pushfd |
2634 | cli |
2635 | cli |
2635 | mov eax, ecx |
2636 | mov eax, ecx |
2636 | mov ecx, [_display.pitch] |
2637 | mov ecx, [_display.pitch] |
2637 | mov [_display.width], eax |
2638 | mov [_display.width], eax |
2638 | dec eax |
2639 | dec eax |
2639 | mov [_display.height], edx |
2640 | mov [_display.height], edx |
2640 | dec edx |
2641 | dec edx |
2641 | ; eax - new Screen_Max_X |
2642 | ; eax - new Screen_Max_X |
2642 | ; edx - new Screen_Max_Y |
2643 | ; edx - new Screen_Max_Y |
2643 | mov [do_not_touch_winmap], 1 |
2644 | mov [do_not_touch_winmap], 1 |
2644 | call set_screen |
2645 | call set_screen |
2645 | mov [do_not_touch_winmap], 0 |
2646 | mov [do_not_touch_winmap], 0 |
2646 | popfd |
2647 | popfd |
2647 | call change_task |
2648 | call change_task |
2648 | .exit: |
2649 | .exit: |
2649 | ret |
2650 | ret |
2650 | ;------------------------------------------------------------------------------ |
2651 | ;------------------------------------------------------------------------------ |
2651 | uglobal |
2652 | uglobal |
2652 | screen_workarea RECT |
2653 | screen_workarea RECT |
2653 | display_width_standard dd 0 |
2654 | display_width_standard dd 0 |
2654 | display_height_standard dd 0 |
2655 | display_height_standard dd 0 |
2655 | do_not_touch_winmap db 0 |
2656 | do_not_touch_winmap db 0 |
2656 | window_minimize db 0 |
2657 | window_minimize db 0 |
2657 | sound_flag db 0 |
2658 | sound_flag db 0 |
2658 | 2659 | ||
2659 | endg |
2660 | endg |
2660 | 2661 | ||
2661 | UID_NONE=0 |
2662 | UID_NONE=0 |
2662 | UID_MENUETOS=1 ;official |
2663 | UID_MENUETOS=1 ;official |
2663 | UID_KOLIBRI=2 ;russian |
2664 | UID_KOLIBRI=2 ;russian |
2664 | 2665 | ||
2665 | iglobal |
2666 | iglobal |
2666 | version_inf: |
2667 | version_inf: |
2667 | db 0,7,7,0 ; version 0.7.7.0 |
2668 | db 0,7,7,0 ; version 0.7.7.0 |
2668 | db 0 |
2669 | db 0 |
2669 | .rev dd __REV__ |
2670 | .rev dd __REV__ |
2670 | version_end: |
2671 | version_end: |
2671 | endg |
2672 | endg |
2672 | ;------------------------------------------------------------------------------ |
2673 | ;------------------------------------------------------------------------------ |
2673 | align 4 |
2674 | align 4 |
2674 | sys_cachetodiskette: |
2675 | sys_cachetodiskette: |
2675 | cmp ebx, 1 |
2676 | cmp ebx, 1 |
2676 | jne .no_floppy_a_save |
2677 | jb .no_floppy_save |
2677 | mov [flp_number], 1 |
- | |
2678 | jmp .save_image_on_floppy |
- | |
2679 | ;-------------------------------------- |
- | |
2680 | align 4 |
- | |
2681 | .no_floppy_a_save: |
- | |
2682 | cmp ebx, 2 |
2678 | cmp ebx, 2 |
2683 | jne .no_floppy_b_save |
2679 | ja .no_floppy_save |
2684 | mov [flp_number], 2 |
- | |
2685 | ;-------------------------------------- |
- | |
2686 | align 4 |
- | |
2687 | .save_image_on_floppy: |
- | |
2688 | call save_image |
2680 | call save_image |
2689 | mov [esp + 32], dword 0 |
2681 | mov [esp + 32], eax |
2690 | cmp [FDC_Status], 0 |
- | |
2691 | je .yes_floppy_save |
- | |
2692 | ;-------------------------------------- |
- | |
2693 | align 4 |
2682 | ret |
2694 | .no_floppy_b_save: |
2683 | .no_floppy_save: |
2695 | mov [esp + 32], dword 1 |
2684 | mov [esp + 32], dword 1 |
2696 | ;-------------------------------------- |
- | |
2697 | align 4 |
- | |
2698 | .yes_floppy_save: |
- | |
2699 | ret |
2685 | ret |
2700 | ;------------------------------------------------------------------------------ |
2686 | ;------------------------------------------------------------------------------ |
2701 | uglobal |
2687 | uglobal |
2702 | ; bgrchanged dd 0x0 |
2688 | ; bgrchanged dd 0x0 |
2703 | align 4 |
2689 | align 4 |
2704 | bgrlockpid dd 0 |
2690 | bgrlockpid dd 0 |
2705 | bgrlock db 0 |
2691 | bgrlock db 0 |
2706 | endg |
2692 | endg |
2707 | ;------------------------------------------------------------------------------ |
2693 | ;------------------------------------------------------------------------------ |
2708 | align 4 |
2694 | align 4 |
2709 | sys_background: |
2695 | sys_background: |
2710 | cmp ebx, 1 ; BACKGROUND SIZE |
2696 | cmp ebx, 1 ; BACKGROUND SIZE |
2711 | jnz nosb1 |
2697 | jnz nosb1 |
2712 | test ecx, ecx |
2698 | test ecx, ecx |
2713 | jz sbgrr |
2699 | jz sbgrr |
2714 | 2700 | ||
2715 | test edx, edx |
2701 | test edx, edx |
2716 | jz sbgrr |
2702 | jz sbgrr |
2717 | ;-------------------------------------- |
2703 | ;-------------------------------------- |
2718 | align 4 |
2704 | align 4 |
2719 | @@: |
2705 | @@: |
2720 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2706 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2721 | bts dword [bgrlock], 0 |
2707 | bts dword [bgrlock], 0 |
2722 | jnc @f |
2708 | jnc @f |
2723 | call change_task |
2709 | call change_task |
2724 | jmp @b |
2710 | jmp @b |
2725 | ;-------------------------------------- |
2711 | ;-------------------------------------- |
2726 | align 4 |
2712 | align 4 |
2727 | @@: |
2713 | @@: |
2728 | mov [BgrDataWidth], ecx |
2714 | mov [BgrDataWidth], ecx |
2729 | mov [BgrDataHeight], edx |
2715 | mov [BgrDataHeight], edx |
2730 | ; mov [bgrchanged],1 |
2716 | ; mov [bgrchanged],1 |
2731 | 2717 | ||
2732 | pushad |
2718 | pushad |
2733 | ; return memory for old background |
2719 | ; return memory for old background |
2734 | mov eax, [img_background] |
2720 | mov eax, [img_background] |
2735 | cmp eax, static_background_data |
2721 | cmp eax, static_background_data |
2736 | jz @f |
2722 | jz @f |
2737 | stdcall kernel_free, eax |
2723 | stdcall kernel_free, eax |
2738 | ;-------------------------------------- |
2724 | ;-------------------------------------- |
2739 | align 4 |
2725 | align 4 |
2740 | @@: |
2726 | @@: |
2741 | ; calculate RAW size |
2727 | ; calculate RAW size |
2742 | xor eax, eax |
2728 | xor eax, eax |
2743 | inc eax |
2729 | inc eax |
2744 | cmp [BgrDataWidth], eax |
2730 | cmp [BgrDataWidth], eax |
2745 | jae @f |
2731 | jae @f |
2746 | mov [BgrDataWidth], eax |
2732 | mov [BgrDataWidth], eax |
2747 | ;-------------------------------------- |
2733 | ;-------------------------------------- |
2748 | align 4 |
2734 | align 4 |
2749 | @@: |
2735 | @@: |
2750 | cmp [BgrDataHeight], eax |
2736 | cmp [BgrDataHeight], eax |
2751 | jae @f |
2737 | jae @f |
2752 | mov [BgrDataHeight], eax |
2738 | mov [BgrDataHeight], eax |
2753 | ;-------------------------------------- |
2739 | ;-------------------------------------- |
2754 | align 4 |
2740 | align 4 |
2755 | @@: |
2741 | @@: |
2756 | mov eax, [BgrDataWidth] |
2742 | mov eax, [BgrDataWidth] |
2757 | imul eax, [BgrDataHeight] |
2743 | imul eax, [BgrDataHeight] |
2758 | lea eax, [eax*3] |
2744 | lea eax, [eax*3] |
2759 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2745 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2760 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2746 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2761 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2747 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2762 | shr eax, 12 |
2748 | shr eax, 12 |
2763 | inc eax |
2749 | inc eax |
2764 | shl eax, 12 |
2750 | shl eax, 12 |
2765 | mov [mem_BACKGROUND], eax |
2751 | mov [mem_BACKGROUND], eax |
2766 | ; get memory for new background |
2752 | ; get memory for new background |
2767 | stdcall kernel_alloc, eax |
2753 | stdcall kernel_alloc, eax |
2768 | test eax, eax |
2754 | test eax, eax |
2769 | jz .memfailed |
2755 | jz .memfailed |
2770 | mov [img_background], eax |
2756 | mov [img_background], eax |
2771 | jmp .exit |
2757 | jmp .exit |
2772 | ;-------------------------------------- |
2758 | ;-------------------------------------- |
2773 | align 4 |
2759 | align 4 |
2774 | .memfailed: |
2760 | .memfailed: |
2775 | ; revert to static monotone data |
2761 | ; revert to static monotone data |
2776 | mov [img_background], static_background_data |
2762 | mov [img_background], static_background_data |
2777 | xor eax, eax |
2763 | xor eax, eax |
2778 | inc eax |
2764 | inc eax |
2779 | mov [BgrDataWidth], eax |
2765 | mov [BgrDataWidth], eax |
2780 | mov [BgrDataHeight], eax |
2766 | mov [BgrDataHeight], eax |
2781 | mov [mem_BACKGROUND], 4 |
2767 | mov [mem_BACKGROUND], 4 |
2782 | ;-------------------------------------- |
2768 | ;-------------------------------------- |
2783 | align 4 |
2769 | align 4 |
2784 | .exit: |
2770 | .exit: |
2785 | popad |
2771 | popad |
2786 | mov [bgrlock], 0 |
2772 | mov [bgrlock], 0 |
2787 | ;-------------------------------------- |
2773 | ;-------------------------------------- |
2788 | align 4 |
2774 | align 4 |
2789 | sbgrr: |
2775 | sbgrr: |
2790 | ret |
2776 | ret |
2791 | ;------------------------------------------------------------------------------ |
2777 | ;------------------------------------------------------------------------------ |
2792 | align 4 |
2778 | align 4 |
2793 | nosb1: |
2779 | nosb1: |
2794 | cmp ebx, 2 ; SET PIXEL |
2780 | cmp ebx, 2 ; SET PIXEL |
2795 | jnz nosb2 |
2781 | jnz nosb2 |
2796 | 2782 | ||
2797 | mov eax, [img_background] |
2783 | mov eax, [img_background] |
2798 | test ecx, ecx |
2784 | test ecx, ecx |
2799 | jz @f |
2785 | jz @f |
2800 | cmp eax, static_background_data |
2786 | cmp eax, static_background_data |
2801 | jz .ret |
2787 | jz .ret |
2802 | ;-------------------------------------- |
2788 | ;-------------------------------------- |
2803 | align 4 |
2789 | align 4 |
2804 | @@: |
2790 | @@: |
2805 | mov ebx, [mem_BACKGROUND] |
2791 | mov ebx, [mem_BACKGROUND] |
2806 | add ebx, 4095 |
2792 | add ebx, 4095 |
2807 | and ebx, -4096 |
2793 | and ebx, -4096 |
2808 | sub ebx, 4 |
2794 | sub ebx, 4 |
2809 | cmp ecx, ebx |
2795 | cmp ecx, ebx |
2810 | ja .ret |
2796 | ja .ret |
2811 | 2797 | ||
2812 | mov ebx, [eax+ecx] |
2798 | mov ebx, [eax+ecx] |
2813 | and ebx, 0xFF000000;255*256*256*256 |
2799 | and ebx, 0xFF000000;255*256*256*256 |
2814 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2800 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2815 | add edx, ebx |
2801 | add edx, ebx |
2816 | mov [eax+ecx], edx |
2802 | mov [eax+ecx], edx |
2817 | ;-------------------------------------- |
2803 | ;-------------------------------------- |
2818 | align 4 |
2804 | align 4 |
2819 | .ret: |
2805 | .ret: |
2820 | ret |
2806 | ret |
2821 | ;------------------------------------------------------------------------------ |
2807 | ;------------------------------------------------------------------------------ |
2822 | align 4 |
2808 | align 4 |
2823 | nosb2: |
2809 | nosb2: |
2824 | cmp ebx, 3 ; DRAW BACKGROUND |
2810 | cmp ebx, 3 ; DRAW BACKGROUND |
2825 | jnz nosb3 |
2811 | jnz nosb3 |
2826 | ;-------------------------------------- |
2812 | ;-------------------------------------- |
2827 | align 4 |
2813 | align 4 |
2828 | draw_background_temp: |
2814 | draw_background_temp: |
2829 | mov [background_defined], 1 |
2815 | mov [background_defined], 1 |
2830 | call force_redraw_background |
2816 | call force_redraw_background |
2831 | ;-------------------------------------- |
2817 | ;-------------------------------------- |
2832 | align 4 |
2818 | align 4 |
2833 | nosb31: |
2819 | nosb31: |
2834 | ret |
2820 | ret |
2835 | ;------------------------------------------------------------------------------ |
2821 | ;------------------------------------------------------------------------------ |
2836 | align 4 |
2822 | align 4 |
2837 | nosb3: |
2823 | nosb3: |
2838 | cmp ebx, 4 ; TILED / STRETCHED |
2824 | cmp ebx, 4 ; TILED / STRETCHED |
2839 | jnz nosb4 |
2825 | jnz nosb4 |
2840 | cmp ecx, [BgrDrawMode] |
2826 | cmp ecx, [BgrDrawMode] |
2841 | je nosb41 |
2827 | je nosb41 |
2842 | mov [BgrDrawMode], ecx |
2828 | mov [BgrDrawMode], ecx |
2843 | ;-------------------------------------- |
2829 | ;-------------------------------------- |
2844 | align 4 |
2830 | align 4 |
2845 | nosb41: |
2831 | nosb41: |
2846 | ret |
2832 | ret |
2847 | ;------------------------------------------------------------------------------ |
2833 | ;------------------------------------------------------------------------------ |
2848 | align 4 |
2834 | align 4 |
2849 | nosb4: |
2835 | nosb4: |
2850 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2836 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2851 | jnz nosb5 |
2837 | jnz nosb5 |
2852 | cmp [img_background], static_background_data |
2838 | cmp [img_background], static_background_data |
2853 | jnz @f |
2839 | jnz @f |
2854 | test edx, edx |
2840 | test edx, edx |
2855 | jnz .fin |
2841 | jnz .fin |
2856 | cmp esi, 4 |
2842 | cmp esi, 4 |
2857 | ja .fin |
2843 | ja .fin |
2858 | ;-------------------------------------- |
2844 | ;-------------------------------------- |
2859 | align 4 |
2845 | align 4 |
2860 | @@: |
2846 | @@: |
2861 | ; bughere |
2847 | ; bughere |
2862 | mov eax, ecx |
2848 | mov eax, ecx |
2863 | mov ebx, edx |
2849 | mov ebx, edx |
2864 | add ebx, [img_background];IMG_BACKGROUND |
2850 | add ebx, [img_background];IMG_BACKGROUND |
2865 | mov ecx, esi |
2851 | mov ecx, esi |
2866 | call memmove |
2852 | call memmove |
2867 | ;-------------------------------------- |
2853 | ;-------------------------------------- |
2868 | align 4 |
2854 | align 4 |
2869 | .fin: |
2855 | .fin: |
2870 | ret |
2856 | ret |
2871 | ;------------------------------------------------------------------------------ |
2857 | ;------------------------------------------------------------------------------ |
2872 | align 4 |
2858 | align 4 |
2873 | nosb5: |
2859 | nosb5: |
2874 | cmp ebx, 6 |
2860 | cmp ebx, 6 |
2875 | jnz nosb6 |
2861 | jnz nosb6 |
2876 | ;-------------------------------------- |
2862 | ;-------------------------------------- |
2877 | align 4 |
2863 | align 4 |
2878 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2864 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2879 | @@: |
2865 | @@: |
2880 | bts dword [bgrlock], 0 |
2866 | bts dword [bgrlock], 0 |
2881 | jnc @f |
2867 | jnc @f |
2882 | call change_task |
2868 | call change_task |
2883 | jmp @b |
2869 | jmp @b |
2884 | ;-------------------------------------- |
2870 | ;-------------------------------------- |
2885 | align 4 |
2871 | align 4 |
2886 | @@: |
2872 | @@: |
2887 | mov eax, [CURRENT_TASK] |
2873 | mov eax, [CURRENT_TASK] |
2888 | mov [bgrlockpid], eax |
2874 | mov [bgrlockpid], eax |
2889 | cmp [img_background], static_background_data |
2875 | cmp [img_background], static_background_data |
2890 | jz .nomem |
2876 | jz .nomem |
2891 | stdcall user_alloc, [mem_BACKGROUND] |
2877 | stdcall user_alloc, [mem_BACKGROUND] |
2892 | mov [esp+32], eax |
2878 | mov [esp+32], eax |
2893 | test eax, eax |
2879 | test eax, eax |
2894 | jz .nomem |
2880 | jz .nomem |
2895 | mov ebx, eax |
2881 | mov ebx, eax |
2896 | shr ebx, 12 |
2882 | shr ebx, 12 |
2897 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2883 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2898 | mov esi, [img_background] |
2884 | mov esi, [img_background] |
2899 | shr esi, 12 |
2885 | shr esi, 12 |
2900 | mov ecx, [mem_BACKGROUND] |
2886 | mov ecx, [mem_BACKGROUND] |
2901 | add ecx, 0xFFF |
2887 | add ecx, 0xFFF |
2902 | shr ecx, 12 |
2888 | shr ecx, 12 |
2903 | ;-------------------------------------- |
2889 | ;-------------------------------------- |
2904 | align 4 |
2890 | align 4 |
2905 | .z: |
2891 | .z: |
2906 | mov eax, [page_tabs+ebx*4] |
2892 | mov eax, [page_tabs+ebx*4] |
2907 | test al, 1 |
2893 | test al, 1 |
2908 | jz @f |
2894 | jz @f |
2909 | call free_page |
2895 | call free_page |
2910 | ;-------------------------------------- |
2896 | ;-------------------------------------- |
2911 | align 4 |
2897 | align 4 |
2912 | @@: |
2898 | @@: |
2913 | mov eax, [page_tabs+esi*4] |
2899 | mov eax, [page_tabs+esi*4] |
2914 | or al, PG_UW |
2900 | or al, PG_UW |
2915 | mov [page_tabs+ebx*4], eax |
2901 | mov [page_tabs+ebx*4], eax |
2916 | mov eax, ebx |
2902 | mov eax, ebx |
2917 | shl eax, 12 |
2903 | shl eax, 12 |
2918 | invlpg [eax] |
2904 | invlpg [eax] |
2919 | inc ebx |
2905 | inc ebx |
2920 | inc esi |
2906 | inc esi |
2921 | loop .z |
2907 | loop .z |
2922 | ret |
2908 | ret |
2923 | ;-------------------------------------- |
2909 | ;-------------------------------------- |
2924 | align 4 |
2910 | align 4 |
2925 | .nomem: |
2911 | .nomem: |
2926 | and [bgrlockpid], 0 |
2912 | and [bgrlockpid], 0 |
2927 | mov [bgrlock], 0 |
2913 | mov [bgrlock], 0 |
2928 | ;------------------------------------------------------------------------------ |
2914 | ;------------------------------------------------------------------------------ |
2929 | align 4 |
2915 | align 4 |
2930 | nosb6: |
2916 | nosb6: |
2931 | cmp ebx, 7 |
2917 | cmp ebx, 7 |
2932 | jnz nosb7 |
2918 | jnz nosb7 |
2933 | cmp [bgrlock], 0 |
2919 | cmp [bgrlock], 0 |
2934 | jz .err |
2920 | jz .err |
2935 | mov eax, [CURRENT_TASK] |
2921 | mov eax, [CURRENT_TASK] |
2936 | cmp [bgrlockpid], eax |
2922 | cmp [bgrlockpid], eax |
2937 | jnz .err |
2923 | jnz .err |
2938 | mov eax, ecx |
2924 | mov eax, ecx |
2939 | mov ebx, ecx |
2925 | mov ebx, ecx |
2940 | shr eax, 12 |
2926 | shr eax, 12 |
2941 | mov ecx, [page_tabs+(eax-1)*4] |
2927 | mov ecx, [page_tabs+(eax-1)*4] |
2942 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2928 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2943 | jz .err |
2929 | jz .err |
2944 | jnp .err |
2930 | jnp .err |
2945 | push eax |
2931 | push eax |
2946 | shr ecx, 12 |
2932 | shr ecx, 12 |
2947 | dec ecx |
2933 | dec ecx |
2948 | ;-------------------------------------- |
2934 | ;-------------------------------------- |
2949 | align 4 |
2935 | align 4 |
2950 | @@: |
2936 | @@: |
2951 | and dword [page_tabs+eax*4], 0 |
2937 | and dword [page_tabs+eax*4], 0 |
2952 | mov edx, eax |
2938 | mov edx, eax |
2953 | shl edx, 12 |
2939 | shl edx, 12 |
2954 | push eax |
2940 | push eax |
2955 | invlpg [edx] |
2941 | invlpg [edx] |
2956 | pop eax |
2942 | pop eax |
2957 | inc eax |
2943 | inc eax |
2958 | loop @b |
2944 | loop @b |
2959 | pop eax |
2945 | pop eax |
2960 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2946 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2961 | stdcall user_free, ebx |
2947 | stdcall user_free, ebx |
2962 | mov [esp+32], eax |
2948 | mov [esp+32], eax |
2963 | and [bgrlockpid], 0 |
2949 | and [bgrlockpid], 0 |
2964 | mov [bgrlock], 0 |
2950 | mov [bgrlock], 0 |
2965 | ret |
2951 | ret |
2966 | ;-------------------------------------- |
2952 | ;-------------------------------------- |
2967 | align 4 |
2953 | align 4 |
2968 | .err: |
2954 | .err: |
2969 | and dword [esp+32], 0 |
2955 | and dword [esp+32], 0 |
2970 | ret |
2956 | ret |
2971 | ;------------------------------------------------------------------------------ |
2957 | ;------------------------------------------------------------------------------ |
2972 | align 4 |
2958 | align 4 |
2973 | nosb7: |
2959 | nosb7: |
2974 | cmp ebx, 8 |
2960 | cmp ebx, 8 |
2975 | jnz nosb8 |
2961 | jnz nosb8 |
2976 | 2962 | ||
2977 | mov ecx, [current_slot] |
2963 | mov ecx, [current_slot] |
2978 | xor eax, eax |
2964 | xor eax, eax |
2979 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2965 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2980 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2966 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2981 | xor eax, eax |
2967 | xor eax, eax |
2982 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2968 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2983 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2969 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2984 | ret |
2970 | ret |
2985 | ;------------------------------------------------------------------------------ |
2971 | ;------------------------------------------------------------------------------ |
2986 | align 4 |
2972 | align 4 |
2987 | nosb8: |
2973 | nosb8: |
2988 | cmp ebx, 9 |
2974 | cmp ebx, 9 |
2989 | jnz nosb9 |
2975 | jnz nosb9 |
2990 | ; ecx = [left]*65536 + [right] |
2976 | ; ecx = [left]*65536 + [right] |
2991 | ; edx = [top]*65536 + [bottom] |
2977 | ; edx = [top]*65536 + [bottom] |
2992 | mov eax, [Screen_Max_X] |
2978 | mov eax, [Screen_Max_X] |
2993 | mov ebx, [Screen_Max_Y] |
2979 | mov ebx, [Screen_Max_Y] |
2994 | ; check [right] |
2980 | ; check [right] |
2995 | cmp cx, ax |
2981 | cmp cx, ax |
2996 | ja .exit |
2982 | ja .exit |
2997 | ; check [left] |
2983 | ; check [left] |
2998 | ror ecx, 16 |
2984 | ror ecx, 16 |
2999 | cmp cx, ax |
2985 | cmp cx, ax |
3000 | ja .exit |
2986 | ja .exit |
3001 | ; check [bottom] |
2987 | ; check [bottom] |
3002 | cmp dx, bx |
2988 | cmp dx, bx |
3003 | ja .exit |
2989 | ja .exit |
3004 | ; check [top] |
2990 | ; check [top] |
3005 | ror edx, 16 |
2991 | ror edx, 16 |
3006 | cmp dx, bx |
2992 | cmp dx, bx |
3007 | ja .exit |
2993 | ja .exit |
3008 | 2994 | ||
3009 | movzx eax, cx ; [left] |
2995 | movzx eax, cx ; [left] |
3010 | movzx ebx, dx ; [top] |
2996 | movzx ebx, dx ; [top] |
3011 | 2997 | ||
3012 | shr ecx, 16 ; [right] |
2998 | shr ecx, 16 ; [right] |
3013 | shr edx, 16 ; [bottom] |
2999 | shr edx, 16 ; [bottom] |
3014 | 3000 | ||
3015 | mov [background_defined], 1 |
3001 | mov [background_defined], 1 |
3016 | 3002 | ||
3017 | mov [draw_data+32 + RECT.left], eax |
3003 | mov [draw_data+32 + RECT.left], eax |
3018 | mov [draw_data+32 + RECT.top], ebx |
3004 | mov [draw_data+32 + RECT.top], ebx |
3019 | 3005 | ||
3020 | mov [draw_data+32 + RECT.right], ecx |
3006 | mov [draw_data+32 + RECT.right], ecx |
3021 | mov [draw_data+32 + RECT.bottom], edx |
3007 | mov [draw_data+32 + RECT.bottom], edx |
3022 | 3008 | ||
3023 | inc byte[REDRAW_BACKGROUND] |
3009 | inc byte[REDRAW_BACKGROUND] |
3024 | call wakeup_osloop |
3010 | call wakeup_osloop |
3025 | ;-------------------------------------- |
3011 | ;-------------------------------------- |
3026 | align 4 |
3012 | align 4 |
3027 | .exit: |
3013 | .exit: |
3028 | ret |
3014 | ret |
3029 | ;------------------------------------------------------------------------------ |
3015 | ;------------------------------------------------------------------------------ |
3030 | align 4 |
3016 | align 4 |
3031 | nosb9: |
3017 | nosb9: |
3032 | ret |
3018 | ret |
3033 | ;------------------------------------------------------------------------------ |
3019 | ;------------------------------------------------------------------------------ |
3034 | align 4 |
3020 | align 4 |
3035 | uglobal |
3021 | uglobal |
3036 | BG_Rect_X_left_right dd 0x0 |
3022 | BG_Rect_X_left_right dd 0x0 |
3037 | BG_Rect_Y_top_bottom dd 0x0 |
3023 | BG_Rect_Y_top_bottom dd 0x0 |
3038 | endg |
3024 | endg |
3039 | ;------------------------------------------------------------------------------ |
3025 | ;------------------------------------------------------------------------------ |
3040 | align 4 |
3026 | align 4 |
3041 | force_redraw_background: |
3027 | force_redraw_background: |
3042 | and [draw_data+32 + RECT.left], 0 |
3028 | and [draw_data+32 + RECT.left], 0 |
3043 | and [draw_data+32 + RECT.top], 0 |
3029 | and [draw_data+32 + RECT.top], 0 |
3044 | push eax ebx |
3030 | push eax ebx |
3045 | mov eax, [Screen_Max_X] |
3031 | mov eax, [Screen_Max_X] |
3046 | mov ebx, [Screen_Max_Y] |
3032 | mov ebx, [Screen_Max_Y] |
3047 | mov [draw_data+32 + RECT.right], eax |
3033 | mov [draw_data+32 + RECT.right], eax |
3048 | mov [draw_data+32 + RECT.bottom], ebx |
3034 | mov [draw_data+32 + RECT.bottom], ebx |
3049 | pop ebx eax |
3035 | pop ebx eax |
3050 | inc byte[REDRAW_BACKGROUND] |
3036 | inc byte[REDRAW_BACKGROUND] |
3051 | call wakeup_osloop |
3037 | call wakeup_osloop |
3052 | ret |
3038 | ret |
3053 | ;------------------------------------------------------------------------------ |
3039 | ;------------------------------------------------------------------------------ |
3054 | align 4 |
3040 | align 4 |
3055 | sys_getbackground: |
3041 | sys_getbackground: |
3056 | ; cmp eax,1 ; SIZE |
3042 | ; cmp eax,1 ; SIZE |
3057 | dec ebx |
3043 | dec ebx |
3058 | jnz nogb1 |
3044 | jnz nogb1 |
3059 | mov eax, [BgrDataWidth] |
3045 | mov eax, [BgrDataWidth] |
3060 | shl eax, 16 |
3046 | shl eax, 16 |
3061 | mov ax, word [BgrDataHeight] |
3047 | mov ax, word [BgrDataHeight] |
3062 | mov [esp+32], eax |
3048 | mov [esp+32], eax |
3063 | ret |
3049 | ret |
3064 | ;------------------------------------------------------------------------------ |
3050 | ;------------------------------------------------------------------------------ |
3065 | align 4 |
3051 | align 4 |
3066 | nogb1: |
3052 | nogb1: |
3067 | ; cmp eax,2 ; PIXEL |
3053 | ; cmp eax,2 ; PIXEL |
3068 | dec ebx |
3054 | dec ebx |
3069 | jnz nogb2 |
3055 | jnz nogb2 |
3070 | 3056 | ||
3071 | mov eax, [img_background] |
3057 | mov eax, [img_background] |
3072 | test ecx, ecx |
3058 | test ecx, ecx |
3073 | jz @f |
3059 | jz @f |
3074 | cmp eax, static_background_data |
3060 | cmp eax, static_background_data |
3075 | jz .ret |
3061 | jz .ret |
3076 | ;-------------------------------------- |
3062 | ;-------------------------------------- |
3077 | align 4 |
3063 | align 4 |
3078 | @@: |
3064 | @@: |
3079 | mov ebx, [mem_BACKGROUND] |
3065 | mov ebx, [mem_BACKGROUND] |
3080 | add ebx, 4095 |
3066 | add ebx, 4095 |
3081 | and ebx, -4096 |
3067 | and ebx, -4096 |
3082 | sub ebx, 4 |
3068 | sub ebx, 4 |
3083 | cmp ecx, ebx |
3069 | cmp ecx, ebx |
3084 | ja .ret |
3070 | ja .ret |
3085 | 3071 | ||
3086 | mov eax, [ecx+eax] |
3072 | mov eax, [ecx+eax] |
3087 | 3073 | ||
3088 | and eax, 0xFFFFFF |
3074 | and eax, 0xFFFFFF |
3089 | mov [esp+32], eax |
3075 | mov [esp+32], eax |
3090 | ;-------------------------------------- |
3076 | ;-------------------------------------- |
3091 | align 4 |
3077 | align 4 |
3092 | .ret: |
3078 | .ret: |
3093 | ret |
3079 | ret |
3094 | ;------------------------------------------------------------------------------ |
3080 | ;------------------------------------------------------------------------------ |
3095 | align 4 |
3081 | align 4 |
3096 | nogb2: |
3082 | nogb2: |
3097 | 3083 | ||
3098 | ; cmp eax,4 ; TILED / STRETCHED |
3084 | ; cmp eax,4 ; TILED / STRETCHED |
3099 | dec ebx |
3085 | dec ebx |
3100 | dec ebx |
3086 | dec ebx |
3101 | jnz nogb4 |
3087 | jnz nogb4 |
3102 | mov eax, [BgrDrawMode] |
3088 | mov eax, [BgrDrawMode] |
3103 | ;-------------------------------------- |
3089 | ;-------------------------------------- |
3104 | align 4 |
3090 | align 4 |
3105 | nogb4: |
3091 | nogb4: |
3106 | mov [esp+32], eax |
3092 | mov [esp+32], eax |
3107 | ret |
3093 | ret |
3108 | ;------------------------------------------------------------------------------ |
3094 | ;------------------------------------------------------------------------------ |
3109 | align 4 |
3095 | align 4 |
3110 | sys_getkey: |
3096 | sys_getkey: |
3111 | mov [esp + 32], dword 1 |
3097 | mov [esp + 32], dword 1 |
3112 | ; test main buffer |
3098 | ; test main buffer |
3113 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3099 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3114 | movzx ecx, word [WIN_STACK + ebx * 2] |
3100 | movzx ecx, word [WIN_STACK + ebx * 2] |
3115 | mov edx, [TASK_COUNT] |
3101 | mov edx, [TASK_COUNT] |
3116 | cmp ecx, edx |
3102 | cmp ecx, edx |
3117 | jne .finish |
3103 | jne .finish |
3118 | cmp [KEY_COUNT], byte 0 |
3104 | cmp [KEY_COUNT], byte 0 |
3119 | je .finish |
3105 | je .finish |
3120 | movzx eax, byte [KEY_BUFF] |
3106 | movzx eax, byte [KEY_BUFF] |
3121 | shl eax, 8 |
3107 | shl eax, 8 |
3122 | push eax |
3108 | push eax |
3123 | dec byte [KEY_COUNT] |
3109 | dec byte [KEY_COUNT] |
3124 | and byte [KEY_COUNT], 127 |
3110 | and byte [KEY_COUNT], 127 |
3125 | movzx ecx, byte [KEY_COUNT] |
3111 | movzx ecx, byte [KEY_COUNT] |
3126 | add ecx, 2 |
3112 | add ecx, 2 |
3127 | mov eax, KEY_BUFF + 1 |
3113 | mov eax, KEY_BUFF + 1 |
3128 | mov ebx, KEY_BUFF |
3114 | mov ebx, KEY_BUFF |
3129 | call memmove |
3115 | call memmove |
3130 | pop eax |
3116 | pop eax |
3131 | ;-------------------------------------- |
3117 | ;-------------------------------------- |
3132 | align 4 |
3118 | align 4 |
3133 | .ret_eax: |
3119 | .ret_eax: |
3134 | mov [esp + 32], eax |
3120 | mov [esp + 32], eax |
3135 | ret |
3121 | ret |
3136 | ;-------------------------------------- |
3122 | ;-------------------------------------- |
3137 | align 4 |
3123 | align 4 |
3138 | .finish: |
3124 | .finish: |
3139 | ; test hotkeys buffer |
3125 | ; test hotkeys buffer |
3140 | mov ecx, hotkey_buffer |
3126 | mov ecx, hotkey_buffer |
3141 | ;-------------------------------------- |
3127 | ;-------------------------------------- |
3142 | align 4 |
3128 | align 4 |
3143 | @@: |
3129 | @@: |
3144 | cmp [ecx], ebx |
3130 | cmp [ecx], ebx |
3145 | jz .found |
3131 | jz .found |
3146 | add ecx, 8 |
3132 | add ecx, 8 |
3147 | cmp ecx, hotkey_buffer + 120 * 8 |
3133 | cmp ecx, hotkey_buffer + 120 * 8 |
3148 | jb @b |
3134 | jb @b |
3149 | ret |
3135 | ret |
3150 | ;-------------------------------------- |
3136 | ;-------------------------------------- |
3151 | align 4 |
3137 | align 4 |
3152 | .found: |
3138 | .found: |
3153 | mov ax, [ecx + 6] |
3139 | mov ax, [ecx + 6] |
3154 | shl eax, 16 |
3140 | shl eax, 16 |
3155 | mov ah, [ecx + 4] |
3141 | mov ah, [ecx + 4] |
3156 | mov al, 2 |
3142 | mov al, 2 |
3157 | and dword [ecx + 4], 0 |
3143 | and dword [ecx + 4], 0 |
3158 | and dword [ecx], 0 |
3144 | and dword [ecx], 0 |
3159 | jmp .ret_eax |
3145 | jmp .ret_eax |
3160 | ;------------------------------------------------------------------------------ |
3146 | ;------------------------------------------------------------------------------ |
3161 | align 4 |
3147 | align 4 |
3162 | sys_getbutton: |
3148 | sys_getbutton: |
3163 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3149 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3164 | mov [esp + 32], dword 1 |
3150 | mov [esp + 32], dword 1 |
3165 | movzx ecx, word [WIN_STACK + ebx * 2] |
3151 | movzx ecx, word [WIN_STACK + ebx * 2] |
3166 | mov edx, [TASK_COUNT] ; less than 256 processes |
3152 | mov edx, [TASK_COUNT] ; less than 256 processes |
3167 | cmp ecx, edx |
3153 | cmp ecx, edx |
3168 | jne .exit |
3154 | jne .exit |
3169 | movzx eax, byte [BTN_COUNT] |
3155 | movzx eax, byte [BTN_COUNT] |
3170 | test eax, eax |
3156 | test eax, eax |
3171 | jz .exit |
3157 | jz .exit |
3172 | mov eax, [BTN_BUFF] |
3158 | mov eax, [BTN_BUFF] |
3173 | and al, 0xFE ; delete left button bit |
3159 | and al, 0xFE ; delete left button bit |
3174 | mov [BTN_COUNT], byte 0 |
3160 | mov [BTN_COUNT], byte 0 |
3175 | mov [esp + 32], eax |
3161 | mov [esp + 32], eax |
3176 | ;-------------------------------------- |
3162 | ;-------------------------------------- |
3177 | align 4 |
3163 | align 4 |
3178 | .exit: |
3164 | .exit: |
3179 | ret |
3165 | ret |
3180 | ;------------------------------------------------------------------------------ |
3166 | ;------------------------------------------------------------------------------ |
3181 | align 4 |
3167 | align 4 |
3182 | sys_cpuusage: |
3168 | sys_cpuusage: |
3183 | 3169 | ||
3184 | ; RETURN: |
3170 | ; RETURN: |
3185 | ; |
3171 | ; |
3186 | ; +00 dword process cpu usage |
3172 | ; +00 dword process cpu usage |
3187 | ; +04 word position in windowing stack |
3173 | ; +04 word position in windowing stack |
3188 | ; +06 word windowing stack value at current position (cpu nro) |
3174 | ; +06 word windowing stack value at current position (cpu nro) |
3189 | ; +10 12 bytes name |
3175 | ; +10 12 bytes name |
3190 | ; +22 dword start in mem |
3176 | ; +22 dword start in mem |
3191 | ; +26 dword used mem |
3177 | ; +26 dword used mem |
3192 | ; +30 dword PID , process idenfification number |
3178 | ; +30 dword PID , process idenfification number |
3193 | ; |
3179 | ; |
3194 | 3180 | ||
3195 | cmp ecx, -1 ; who am I ? |
3181 | cmp ecx, -1 ; who am I ? |
3196 | jne .no_who_am_i |
3182 | jne .no_who_am_i |
3197 | mov ecx, [CURRENT_TASK] |
3183 | mov ecx, [CURRENT_TASK] |
3198 | .no_who_am_i: |
3184 | .no_who_am_i: |
3199 | cmp ecx, max_processes |
3185 | cmp ecx, max_processes |
3200 | ja .nofillbuf |
3186 | ja .nofillbuf |
3201 | 3187 | ||
3202 | ; +4: word: position of the window of thread in the window stack |
3188 | ; +4: word: position of the window of thread in the window stack |
3203 | mov ax, [WIN_STACK + ecx * 2] |
3189 | mov ax, [WIN_STACK + ecx * 2] |
3204 | mov [ebx+4], ax |
3190 | mov [ebx+4], ax |
3205 | ; +6: word: number of the thread slot, which window has in the window stack |
3191 | ; +6: word: number of the thread slot, which window has in the window stack |
3206 | ; position ecx (has no relation to the specific thread) |
3192 | ; position ecx (has no relation to the specific thread) |
3207 | mov ax, [WIN_POS + ecx * 2] |
3193 | mov ax, [WIN_POS + ecx * 2] |
3208 | mov [ebx+6], ax |
3194 | mov [ebx+6], ax |
3209 | 3195 | ||
3210 | shl ecx, 5 |
3196 | shl ecx, 5 |
3211 | 3197 | ||
3212 | ; +0: dword: memory usage |
3198 | ; +0: dword: memory usage |
3213 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3199 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3214 | mov [ebx], eax |
3200 | mov [ebx], eax |
3215 | ; +10: 11 bytes: name of the process |
3201 | ; +10: 11 bytes: name of the process |
3216 | push ecx |
3202 | push ecx |
3217 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3203 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3218 | add ebx, 10 |
3204 | add ebx, 10 |
3219 | mov ecx, 11 |
3205 | mov ecx, 11 |
3220 | call memmove |
3206 | call memmove |
3221 | pop ecx |
3207 | pop ecx |
3222 | 3208 | ||
3223 | ; +22: address of the process in memory |
3209 | ; +22: address of the process in memory |
3224 | ; +26: size of used memory - 1 |
3210 | ; +26: size of used memory - 1 |
3225 | push edi |
3211 | push edi |
3226 | lea edi, [ebx+12] |
3212 | lea edi, [ebx+12] |
3227 | xor eax, eax |
3213 | xor eax, eax |
3228 | mov edx, 0x100000*16 |
3214 | mov edx, 0x100000*16 |
3229 | cmp ecx, 1 shl 5 |
3215 | cmp ecx, 1 shl 5 |
3230 | je .os_mem |
3216 | je .os_mem |
3231 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3217 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3232 | mov eax, std_application_base_address |
3218 | mov eax, std_application_base_address |
3233 | .os_mem: |
3219 | .os_mem: |
3234 | stosd |
3220 | stosd |
3235 | lea eax, [edx-1] |
3221 | lea eax, [edx-1] |
3236 | stosd |
3222 | stosd |
3237 | 3223 | ||
3238 | ; +30: PID/TID |
3224 | ; +30: PID/TID |
3239 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3225 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3240 | stosd |
3226 | stosd |
3241 | 3227 | ||
3242 | ; window position and size |
3228 | ; window position and size |
3243 | push esi |
3229 | push esi |
3244 | lea esi, [ecx + window_data + WDATA.box] |
3230 | lea esi, [ecx + window_data + WDATA.box] |
3245 | movsd |
3231 | movsd |
3246 | movsd |
3232 | movsd |
3247 | movsd |
3233 | movsd |
3248 | movsd |
3234 | movsd |
3249 | 3235 | ||
3250 | ; Process state (+50) |
3236 | ; Process state (+50) |
3251 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3237 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3252 | stosd |
3238 | stosd |
3253 | 3239 | ||
3254 | ; Window client area box |
3240 | ; Window client area box |
3255 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3241 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3256 | movsd |
3242 | movsd |
3257 | movsd |
3243 | movsd |
3258 | movsd |
3244 | movsd |
3259 | movsd |
3245 | movsd |
3260 | 3246 | ||
3261 | ; Window state |
3247 | ; Window state |
3262 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3248 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3263 | stosb |
3249 | stosb |
3264 | 3250 | ||
3265 | ; Event mask (+71) |
3251 | ; Event mask (+71) |
3266 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3252 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3267 | stosd |
3253 | stosd |
3268 | 3254 | ||
3269 | ; Keyboard mode (+75) |
3255 | ; Keyboard mode (+75) |
3270 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3256 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3271 | stosb |
3257 | stosb |
3272 | 3258 | ||
3273 | pop esi |
3259 | pop esi |
3274 | pop edi |
3260 | pop edi |
3275 | 3261 | ||
3276 | .nofillbuf: |
3262 | .nofillbuf: |
3277 | ; return number of processes |
3263 | ; return number of processes |
3278 | 3264 | ||
3279 | mov eax, [TASK_COUNT] |
3265 | mov eax, [TASK_COUNT] |
3280 | mov [esp+32], eax |
3266 | mov [esp+32], eax |
3281 | ret |
3267 | ret |
3282 | 3268 | ||
3283 | align 4 |
3269 | align 4 |
3284 | sys_clock: |
3270 | sys_clock: |
3285 | cli |
3271 | cli |
3286 | ; Mikhail Lisovin xx Jan 2005 |
3272 | ; Mikhail Lisovin xx Jan 2005 |
3287 | @@: |
3273 | @@: |
3288 | mov al, 10 |
3274 | mov al, 10 |
3289 | out 0x70, al |
3275 | out 0x70, al |
3290 | in al, 0x71 |
3276 | in al, 0x71 |
3291 | test al, al |
3277 | test al, al |
3292 | jns @f |
3278 | jns @f |
3293 | mov esi, 1 |
3279 | mov esi, 1 |
3294 | call delay_ms |
3280 | call delay_ms |
3295 | jmp @b |
3281 | jmp @b |
3296 | @@: |
3282 | @@: |
3297 | ; end Lisovin's fix |
3283 | ; end Lisovin's fix |
3298 | 3284 | ||
3299 | xor al, al ; seconds |
3285 | xor al, al ; seconds |
3300 | out 0x70, al |
3286 | out 0x70, al |
3301 | in al, 0x71 |
3287 | in al, 0x71 |
3302 | movzx ecx, al |
3288 | movzx ecx, al |
3303 | mov al, 02 ; minutes |
3289 | mov al, 02 ; minutes |
3304 | shl ecx, 16 |
3290 | shl ecx, 16 |
3305 | out 0x70, al |
3291 | out 0x70, al |
3306 | in al, 0x71 |
3292 | in al, 0x71 |
3307 | movzx edx, al |
3293 | movzx edx, al |
3308 | mov al, 04 ; hours |
3294 | mov al, 04 ; hours |
3309 | shl edx, 8 |
3295 | shl edx, 8 |
3310 | out 0x70, al |
3296 | out 0x70, al |
3311 | in al, 0x71 |
3297 | in al, 0x71 |
3312 | add ecx, edx |
3298 | add ecx, edx |
3313 | movzx edx, al |
3299 | movzx edx, al |
3314 | add ecx, edx |
3300 | add ecx, edx |
3315 | sti |
3301 | sti |
3316 | mov [esp + 32], ecx |
3302 | mov [esp + 32], ecx |
3317 | ret |
3303 | ret |
3318 | 3304 | ||
3319 | 3305 | ||
3320 | align 4 |
3306 | align 4 |
3321 | 3307 | ||
3322 | sys_date: |
3308 | sys_date: |
3323 | 3309 | ||
3324 | cli |
3310 | cli |
3325 | @@: |
3311 | @@: |
3326 | mov al, 10 |
3312 | mov al, 10 |
3327 | out 0x70, al |
3313 | out 0x70, al |
3328 | in al, 0x71 |
3314 | in al, 0x71 |
3329 | test al, al |
3315 | test al, al |
3330 | jns @f |
3316 | jns @f |
3331 | mov esi, 1 |
3317 | mov esi, 1 |
3332 | call delay_ms |
3318 | call delay_ms |
3333 | jmp @b |
3319 | jmp @b |
3334 | @@: |
3320 | @@: |
3335 | 3321 | ||
3336 | mov ch, 0 |
3322 | mov ch, 0 |
3337 | mov al, 7 ; date |
3323 | mov al, 7 ; date |
3338 | out 0x70, al |
3324 | out 0x70, al |
3339 | in al, 0x71 |
3325 | in al, 0x71 |
3340 | mov cl, al |
3326 | mov cl, al |
3341 | mov al, 8 ; month |
3327 | mov al, 8 ; month |
3342 | shl ecx, 16 |
3328 | shl ecx, 16 |
3343 | out 0x70, al |
3329 | out 0x70, al |
3344 | in al, 0x71 |
3330 | in al, 0x71 |
3345 | mov ch, al |
3331 | mov ch, al |
3346 | mov al, 9 ; year |
3332 | mov al, 9 ; year |
3347 | out 0x70, al |
3333 | out 0x70, al |
3348 | in al, 0x71 |
3334 | in al, 0x71 |
3349 | mov cl, al |
3335 | mov cl, al |
3350 | sti |
3336 | sti |
3351 | mov [esp+32], ecx |
3337 | mov [esp+32], ecx |
3352 | ret |
3338 | ret |
3353 | 3339 | ||
3354 | 3340 | ||
3355 | ; redraw status |
3341 | ; redraw status |
3356 | 3342 | ||
3357 | sys_redrawstat: |
3343 | sys_redrawstat: |
3358 | cmp ebx, 1 |
3344 | cmp ebx, 1 |
3359 | jne no_widgets_away |
3345 | jne no_widgets_away |
3360 | ; buttons away |
3346 | ; buttons away |
3361 | mov ecx, [CURRENT_TASK] |
3347 | mov ecx, [CURRENT_TASK] |
3362 | sys_newba2: |
3348 | sys_newba2: |
3363 | mov edi, [BTN_ADDR] |
3349 | mov edi, [BTN_ADDR] |
3364 | cmp [edi], dword 0 ; empty button list ? |
3350 | cmp [edi], dword 0 ; empty button list ? |
3365 | je end_of_buttons_away |
3351 | je end_of_buttons_away |
3366 | movzx ebx, word [edi] |
3352 | movzx ebx, word [edi] |
3367 | inc ebx |
3353 | inc ebx |
3368 | mov eax, edi |
3354 | mov eax, edi |
3369 | sys_newba: |
3355 | sys_newba: |
3370 | dec ebx |
3356 | dec ebx |
3371 | jz end_of_buttons_away |
3357 | jz end_of_buttons_away |
3372 | 3358 | ||
3373 | add eax, 0x10 |
3359 | add eax, 0x10 |
3374 | cmp cx, [eax] |
3360 | cmp cx, [eax] |
3375 | jnz sys_newba |
3361 | jnz sys_newba |
3376 | 3362 | ||
3377 | push eax ebx ecx |
3363 | push eax ebx ecx |
3378 | mov ecx, ebx |
3364 | mov ecx, ebx |
3379 | inc ecx |
3365 | inc ecx |
3380 | shl ecx, 4 |
3366 | shl ecx, 4 |
3381 | mov ebx, eax |
3367 | mov ebx, eax |
3382 | add eax, 0x10 |
3368 | add eax, 0x10 |
3383 | call memmove |
3369 | call memmove |
3384 | dec dword [edi] |
3370 | dec dword [edi] |
3385 | pop ecx ebx eax |
3371 | pop ecx ebx eax |
3386 | 3372 | ||
3387 | jmp sys_newba2 |
3373 | jmp sys_newba2 |
3388 | 3374 | ||
3389 | end_of_buttons_away: |
3375 | end_of_buttons_away: |
3390 | 3376 | ||
3391 | ret |
3377 | ret |
3392 | 3378 | ||
3393 | no_widgets_away: |
3379 | no_widgets_away: |
3394 | 3380 | ||
3395 | cmp ebx, 2 |
3381 | cmp ebx, 2 |
3396 | jnz srl1 |
3382 | jnz srl1 |
3397 | 3383 | ||
3398 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3384 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3399 | add edx, draw_data - CURRENT_TASK |
3385 | add edx, draw_data - CURRENT_TASK |
3400 | mov [edx + RECT.left], 0 |
3386 | mov [edx + RECT.left], 0 |
3401 | mov [edx + RECT.top], 0 |
3387 | mov [edx + RECT.top], 0 |
3402 | mov eax, [Screen_Max_X] |
3388 | mov eax, [Screen_Max_X] |
3403 | mov [edx + RECT.right], eax |
3389 | mov [edx + RECT.right], eax |
3404 | mov eax, [Screen_Max_Y] |
3390 | mov eax, [Screen_Max_Y] |
3405 | mov [edx + RECT.bottom], eax |
3391 | mov [edx + RECT.bottom], eax |
3406 | 3392 | ||
3407 | srl1: |
3393 | srl1: |
3408 | ret |
3394 | ret |
3409 | 3395 | ||
3410 | ;ok - 100% work |
3396 | ;ok - 100% work |
3411 | ;nt - not tested |
3397 | ;nt - not tested |
3412 | ;--------------------------------------------------------------------------------------------- |
3398 | ;--------------------------------------------------------------------------------------------- |
3413 | ;eax |
3399 | ;eax |
3414 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3400 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3415 | ;1 - change task. Ret nothing. Block. ok. |
3401 | ;1 - change task. Ret nothing. Block. ok. |
3416 | ;2 - performance control |
3402 | ;2 - performance control |
3417 | ; ebx |
3403 | ; ebx |
3418 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3404 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3419 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3405 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3420 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3406 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3421 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3407 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3422 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3408 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3423 | ;eax |
3409 | ;eax |
3424 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3410 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3425 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3411 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3426 | ;--------------------------------------------------------------------------------------------- |
3412 | ;--------------------------------------------------------------------------------------------- |
3427 | iglobal |
3413 | iglobal |
3428 | align 4 |
3414 | align 4 |
3429 | sheduler: |
3415 | sheduler: |
3430 | dd sys_sheduler.00 |
3416 | dd sys_sheduler.00 |
3431 | dd change_task |
3417 | dd change_task |
3432 | dd sys_sheduler.02 |
3418 | dd sys_sheduler.02 |
3433 | dd sys_sheduler.03 |
3419 | dd sys_sheduler.03 |
3434 | dd sys_sheduler.04 |
3420 | dd sys_sheduler.04 |
3435 | endg |
3421 | endg |
3436 | sys_sheduler: |
3422 | sys_sheduler: |
3437 | ;rewritten by |
3423 | ;rewritten by |
3438 | jmp dword [sheduler+ebx*4] |
3424 | jmp dword [sheduler+ebx*4] |
3439 | ;.shed_counter: |
3425 | ;.shed_counter: |
3440 | .00: |
3426 | .00: |
3441 | mov eax, [context_counter] |
3427 | mov eax, [context_counter] |
3442 | mov [esp+32], eax |
3428 | mov [esp+32], eax |
3443 | ret |
3429 | ret |
3444 | 3430 | ||
3445 | .02: |
3431 | .02: |
3446 | ;.perf_control: |
3432 | ;.perf_control: |
3447 | inc ebx ;before ebx=2, ebx=3 |
3433 | inc ebx ;before ebx=2, ebx=3 |
3448 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3434 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3449 | jz cache_disable |
3435 | jz cache_disable |
3450 | 3436 | ||
3451 | dec ebx ;ebx=2 |
3437 | dec ebx ;ebx=2 |
3452 | cmp ebx, ecx ; |
3438 | cmp ebx, ecx ; |
3453 | jz cache_enable ;if ecx=2 and ebx=2 |
3439 | jz cache_enable ;if ecx=2 and ebx=2 |
3454 | 3440 | ||
3455 | dec ebx ;ebx=1 |
3441 | dec ebx ;ebx=1 |
3456 | cmp ebx, ecx |
3442 | cmp ebx, ecx |
3457 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3443 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3458 | 3444 | ||
3459 | dec ebx |
3445 | dec ebx |
3460 | test ebx, ecx ;ebx=0 and ecx=0 |
3446 | test ebx, ecx ;ebx=0 and ecx=0 |
3461 | jz modify_pce ;if ecx=0 |
3447 | jz modify_pce ;if ecx=0 |
3462 | 3448 | ||
3463 | ret |
3449 | ret |
3464 | 3450 | ||
3465 | .03: |
3451 | .03: |
3466 | ;.rdmsr_instr: |
3452 | ;.rdmsr_instr: |
3467 | ;now counter in ecx |
3453 | ;now counter in ecx |
3468 | ;(edx:eax) esi:edi => edx:esi |
3454 | ;(edx:eax) esi:edi => edx:esi |
3469 | mov eax, esi |
3455 | mov eax, esi |
3470 | mov ecx, edx |
3456 | mov ecx, edx |
3471 | rdmsr |
3457 | rdmsr |
3472 | mov [esp+32], eax |
3458 | mov [esp+32], eax |
3473 | mov [esp+20], edx ;ret in ebx? |
3459 | mov [esp+20], edx ;ret in ebx? |
3474 | ret |
3460 | ret |
3475 | 3461 | ||
3476 | .04: |
3462 | .04: |
3477 | ;.wrmsr_instr: |
3463 | ;.wrmsr_instr: |
3478 | ;now counter in ecx |
3464 | ;now counter in ecx |
3479 | ;(edx:eax) esi:edi => edx:esi |
3465 | ;(edx:eax) esi:edi => edx:esi |
3480 | ; Fast Call MSR can't be destroy |
3466 | ; Fast Call MSR can't be destroy |
3481 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3467 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3482 | ; включаются/выключаются расширенные возможности |
3468 | ; включаются/выключаются расширенные возможности |
3483 | cmp edx, MSR_SYSENTER_CS |
3469 | cmp edx, MSR_SYSENTER_CS |
3484 | je @f |
3470 | je @f |
3485 | cmp edx, MSR_SYSENTER_ESP |
3471 | cmp edx, MSR_SYSENTER_ESP |
3486 | je @f |
3472 | je @f |
3487 | cmp edx, MSR_SYSENTER_EIP |
3473 | cmp edx, MSR_SYSENTER_EIP |
3488 | je @f |
3474 | je @f |
3489 | cmp edx, MSR_AMD_STAR |
3475 | cmp edx, MSR_AMD_STAR |
3490 | je @f |
3476 | je @f |
3491 | 3477 | ||
3492 | mov eax, esi |
3478 | mov eax, esi |
3493 | mov ecx, edx |
3479 | mov ecx, edx |
3494 | wrmsr |
3480 | wrmsr |
3495 | ; mov [esp + 32], eax |
3481 | ; mov [esp + 32], eax |
3496 | ; mov [esp + 20], edx ;ret in ebx? |
3482 | ; mov [esp + 20], edx ;ret in ebx? |
3497 | @@: |
3483 | @@: |
3498 | ret |
3484 | ret |
3499 | 3485 | ||
3500 | cache_disable: |
3486 | cache_disable: |
3501 | mov eax, cr0 |
3487 | mov eax, cr0 |
3502 | or eax, 01100000000000000000000000000000b |
3488 | or eax, 01100000000000000000000000000000b |
3503 | mov cr0, eax |
3489 | mov cr0, eax |
3504 | wbinvd ;set MESI |
3490 | wbinvd ;set MESI |
3505 | ret |
3491 | ret |
3506 | 3492 | ||
3507 | cache_enable: |
3493 | cache_enable: |
3508 | mov eax, cr0 |
3494 | mov eax, cr0 |
3509 | and eax, 10011111111111111111111111111111b |
3495 | and eax, 10011111111111111111111111111111b |
3510 | mov cr0, eax |
3496 | mov cr0, eax |
3511 | ret |
3497 | ret |
3512 | 3498 | ||
3513 | is_cache_enabled: |
3499 | is_cache_enabled: |
3514 | mov eax, cr0 |
3500 | mov eax, cr0 |
3515 | mov ebx, eax |
3501 | mov ebx, eax |
3516 | and eax, 01100000000000000000000000000000b |
3502 | and eax, 01100000000000000000000000000000b |
3517 | jz cache_disabled |
3503 | jz cache_disabled |
3518 | mov [esp+32], ebx |
3504 | mov [esp+32], ebx |
3519 | cache_disabled: |
3505 | cache_disabled: |
3520 | mov dword [esp+32], eax;0 |
3506 | mov dword [esp+32], eax;0 |
3521 | ret |
3507 | ret |
3522 | 3508 | ||
3523 | modify_pce: |
3509 | modify_pce: |
3524 | mov eax, cr4 |
3510 | mov eax, cr4 |
3525 | ; mov ebx,0 |
3511 | ; mov ebx,0 |
3526 | ; or bx,100000000b ;pce |
3512 | ; or bx,100000000b ;pce |
3527 | ; xor eax,ebx ;invert pce |
3513 | ; xor eax,ebx ;invert pce |
3528 | bts eax, 8;pce=cr4[8] |
3514 | bts eax, 8;pce=cr4[8] |
3529 | mov cr4, eax |
3515 | mov cr4, eax |
3530 | mov [esp+32], eax |
3516 | mov [esp+32], eax |
3531 | ret |
3517 | ret |
3532 | ;--------------------------------------------------------------------------------------------- |
3518 | ;--------------------------------------------------------------------------------------------- |
3533 | 3519 | ||
3534 | 3520 | ||
3535 | ; check if pixel is allowed to be drawn |
3521 | ; check if pixel is allowed to be drawn |
3536 | 3522 | ||
3537 | ;checkpixel: |
3523 | ;checkpixel: |
3538 | ; push eax edx |
3524 | ; push eax edx |
3539 | 3525 | ||
3540 | ;; mov edx, [Screen_Max_X] ; screen x size |
3526 | ;; mov edx, [Screen_Max_X] ; screen x size |
3541 | ;; inc edx |
3527 | ;; inc edx |
3542 | ;; imul edx, ebx |
3528 | ;; imul edx, ebx |
3543 | ; mov edx, [d_width_calc_area + ebx*4] |
3529 | ; mov edx, [d_width_calc_area + ebx*4] |
3544 | ; add eax, [_WinMapAddress] |
3530 | ; add eax, [_WinMapAddress] |
3545 | ; mov dl, [eax+edx]; lea eax, [...] |
3531 | ; mov dl, [eax+edx]; lea eax, [...] |
3546 | 3532 | ||
3547 | ; xor ecx, ecx |
3533 | ; xor ecx, ecx |
3548 | ; mov eax, [CURRENT_TASK] |
3534 | ; mov eax, [CURRENT_TASK] |
3549 | ; cmp al, dl |
3535 | ; cmp al, dl |
3550 | ; setne cl |
3536 | ; setne cl |
3551 | 3537 | ||
3552 | ; pop edx eax |
3538 | ; pop edx eax |
3553 | ; ret |
3539 | ; ret |
3554 | 3540 | ||
3555 | iglobal |
3541 | iglobal |
3556 | cpustring db 'CPU',0 |
3542 | cpustring db 'CPU',0 |
3557 | endg |
3543 | endg |
3558 | 3544 | ||
3559 | uglobal |
3545 | uglobal |
3560 | background_defined db 0 ; diamond, 11.04.2006 |
3546 | background_defined db 0 ; diamond, 11.04.2006 |
3561 | endg |
3547 | endg |
3562 | ;----------------------------------------------------------------------------- |
3548 | ;----------------------------------------------------------------------------- |
3563 | align 4 |
3549 | align 4 |
3564 | checkmisc: |
3550 | checkmisc: |
3565 | cmp [ctrl_alt_del], 1 |
3551 | cmp [ctrl_alt_del], 1 |
3566 | jne nocpustart |
3552 | jne nocpustart |
3567 | 3553 | ||
3568 | mov ebp, cpustring |
3554 | mov ebp, cpustring |
3569 | call fs_execute_from_sysdir |
3555 | call fs_execute_from_sysdir |
3570 | 3556 | ||
3571 | mov [ctrl_alt_del], 0 |
3557 | mov [ctrl_alt_del], 0 |
3572 | ;-------------------------------------- |
3558 | ;-------------------------------------- |
3573 | align 4 |
3559 | align 4 |
3574 | nocpustart: |
3560 | nocpustart: |
3575 | cmp [mouse_active], 1 |
3561 | cmp [mouse_active], 1 |
3576 | jne mouse_not_active |
3562 | jne mouse_not_active |
3577 | mov [mouse_active], 0 |
3563 | mov [mouse_active], 0 |
3578 | 3564 | ||
3579 | xor edi, edi |
3565 | xor edi, edi |
3580 | mov ebx, CURRENT_TASK |
3566 | mov ebx, CURRENT_TASK |
3581 | 3567 | ||
3582 | mov ecx, [TASK_COUNT] |
3568 | mov ecx, [TASK_COUNT] |
3583 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3569 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3584 | shl eax, 8 |
3570 | shl eax, 8 |
3585 | push eax |
3571 | push eax |
3586 | 3572 | ||
3587 | movzx eax, word [MOUSE_X] |
3573 | movzx eax, word [MOUSE_X] |
3588 | movzx edx, word [MOUSE_Y] |
3574 | movzx edx, word [MOUSE_Y] |
3589 | ;-------------------------------------- |
3575 | ;-------------------------------------- |
3590 | align 4 |
3576 | align 4 |
3591 | .set_mouse_event: |
3577 | .set_mouse_event: |
3592 | add edi, 256 |
3578 | add edi, 256 |
3593 | add ebx, 32 |
3579 | add ebx, 32 |
3594 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3580 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3595 | jz .pos_filter |
3581 | jz .pos_filter |
3596 | 3582 | ||
3597 | cmp edi, [esp] ; skip if filtration active |
3583 | cmp edi, [esp] ; skip if filtration active |
3598 | jne .skip |
3584 | jne .skip |
3599 | ;-------------------------------------- |
3585 | ;-------------------------------------- |
3600 | align 4 |
3586 | align 4 |
3601 | .pos_filter: |
3587 | .pos_filter: |
3602 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3588 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3603 | jz .set |
3589 | jz .set |
3604 | 3590 | ||
3605 | mov esi, [ebx-twdw+WDATA.box.left] |
3591 | mov esi, [ebx-twdw+WDATA.box.left] |
3606 | cmp eax, esi |
3592 | cmp eax, esi |
3607 | jb .skip |
3593 | jb .skip |
3608 | add esi, [ebx-twdw+WDATA.box.width] |
3594 | add esi, [ebx-twdw+WDATA.box.width] |
3609 | cmp eax, esi |
3595 | cmp eax, esi |
3610 | ja .skip |
3596 | ja .skip |
3611 | 3597 | ||
3612 | mov esi, [ebx-twdw+WDATA.box.top] |
3598 | mov esi, [ebx-twdw+WDATA.box.top] |
3613 | cmp edx, esi |
3599 | cmp edx, esi |
3614 | jb .skip |
3600 | jb .skip |
3615 | add esi, [ebx-twdw+WDATA.box.height] |
3601 | add esi, [ebx-twdw+WDATA.box.height] |
3616 | cmp edx, esi |
3602 | cmp edx, esi |
3617 | ja .skip |
3603 | ja .skip |
3618 | ;-------------------------------------- |
3604 | ;-------------------------------------- |
3619 | align 4 |
3605 | align 4 |
3620 | .set: |
3606 | .set: |
3621 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3607 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3622 | ;-------------------------------------- |
3608 | ;-------------------------------------- |
3623 | align 4 |
3609 | align 4 |
3624 | .skip: |
3610 | .skip: |
3625 | loop .set_mouse_event |
3611 | loop .set_mouse_event |
3626 | 3612 | ||
3627 | pop eax |
3613 | pop eax |
3628 | ;-------------------------------------- |
3614 | ;-------------------------------------- |
3629 | align 4 |
3615 | align 4 |
3630 | mouse_not_active: |
3616 | mouse_not_active: |
3631 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3617 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3632 | jz nobackgr |
3618 | jz nobackgr |
3633 | 3619 | ||
3634 | cmp [background_defined], 0 |
3620 | cmp [background_defined], 0 |
3635 | jz nobackgr |
3621 | jz nobackgr |
3636 | ;-------------------------------------- |
3622 | ;-------------------------------------- |
3637 | align 4 |
3623 | align 4 |
3638 | backgr: |
3624 | backgr: |
3639 | mov eax, [draw_data+32 + RECT.left] |
3625 | mov eax, [draw_data+32 + RECT.left] |
3640 | shl eax, 16 |
3626 | shl eax, 16 |
3641 | add eax, [draw_data+32 + RECT.right] |
3627 | add eax, [draw_data+32 + RECT.right] |
3642 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3628 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3643 | 3629 | ||
3644 | mov eax, [draw_data+32 + RECT.top] |
3630 | mov eax, [draw_data+32 + RECT.top] |
3645 | shl eax, 16 |
3631 | shl eax, 16 |
3646 | add eax, [draw_data+32 + RECT.bottom] |
3632 | add eax, [draw_data+32 + RECT.bottom] |
3647 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3633 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3648 | 3634 | ||
3649 | call drawbackground |
3635 | call drawbackground |
3650 | ; DEBUGF 1, "K : drawbackground\n" |
3636 | ; DEBUGF 1, "K : drawbackground\n" |
3651 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3637 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3652 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3638 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3653 | ;--------- set event 5 start ---------- |
3639 | ;--------- set event 5 start ---------- |
3654 | push ecx edi |
3640 | push ecx edi |
3655 | xor edi, edi |
3641 | xor edi, edi |
3656 | mov ecx, [TASK_COUNT] |
3642 | mov ecx, [TASK_COUNT] |
3657 | ;-------------------------------------- |
3643 | ;-------------------------------------- |
3658 | align 4 |
3644 | align 4 |
3659 | set_bgr_event: |
3645 | set_bgr_event: |
3660 | add edi, 256 |
3646 | add edi, 256 |
3661 | mov eax, [BG_Rect_X_left_right] |
3647 | mov eax, [BG_Rect_X_left_right] |
3662 | mov edx, [BG_Rect_Y_top_bottom] |
3648 | mov edx, [BG_Rect_Y_top_bottom] |
3663 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3649 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3664 | jz .set |
3650 | jz .set |
3665 | .join: |
3651 | .join: |
3666 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3652 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3667 | jae @f |
3653 | jae @f |
3668 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3654 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3669 | @@: |
3655 | @@: |
3670 | shr eax, 16 |
3656 | shr eax, 16 |
3671 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3657 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3672 | jbe @f |
3658 | jbe @f |
3673 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3659 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3674 | @@: |
3660 | @@: |
3675 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3661 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3676 | jae @f |
3662 | jae @f |
3677 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3663 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3678 | @@: |
3664 | @@: |
3679 | shr edx, 16 |
3665 | shr edx, 16 |
3680 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3666 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3681 | jbe @f |
3667 | jbe @f |
3682 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3668 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3683 | @@: |
3669 | @@: |
3684 | jmp .common |
3670 | jmp .common |
3685 | .set: |
3671 | .set: |
3686 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3672 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3687 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3673 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3688 | .common: |
3674 | .common: |
3689 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3675 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3690 | loop set_bgr_event |
3676 | loop set_bgr_event |
3691 | pop edi ecx |
3677 | pop edi ecx |
3692 | ;--------- set event 5 stop ----------- |
3678 | ;--------- set event 5 stop ----------- |
3693 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3679 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3694 | jnz backgr |
3680 | jnz backgr |
3695 | 3681 | ||
3696 | xor eax, eax |
3682 | xor eax, eax |
3697 | mov [draw_data+32 + RECT.left], eax |
3683 | mov [draw_data+32 + RECT.left], eax |
3698 | mov [draw_data+32 + RECT.top], eax |
3684 | mov [draw_data+32 + RECT.top], eax |
3699 | mov [draw_data+32 + RECT.right], eax |
3685 | mov [draw_data+32 + RECT.right], eax |
3700 | mov [draw_data+32 + RECT.bottom], eax |
3686 | mov [draw_data+32 + RECT.bottom], eax |
3701 | ;-------------------------------------- |
3687 | ;-------------------------------------- |
3702 | align 4 |
3688 | align 4 |
3703 | nobackgr: |
3689 | nobackgr: |
3704 | ; system shutdown request |
3690 | ; system shutdown request |
3705 | cmp [SYS_SHUTDOWN], byte 0 |
3691 | cmp [SYS_SHUTDOWN], byte 0 |
3706 | je noshutdown |
3692 | je noshutdown |
3707 | 3693 | ||
3708 | mov edx, [shutdown_processes] |
3694 | mov edx, [shutdown_processes] |
3709 | 3695 | ||
3710 | cmp [SYS_SHUTDOWN], dl |
3696 | cmp [SYS_SHUTDOWN], dl |
3711 | jne noshutdown |
3697 | jne noshutdown |
3712 | 3698 | ||
3713 | lea ecx, [edx-1] |
3699 | lea ecx, [edx-1] |
3714 | mov edx, OS_BASE+0x3040 |
3700 | mov edx, OS_BASE+0x3040 |
3715 | jecxz no_mark_system_shutdown |
3701 | jecxz no_mark_system_shutdown |
3716 | ;-------------------------------------- |
3702 | ;-------------------------------------- |
3717 | align 4 |
3703 | align 4 |
3718 | markz: |
3704 | markz: |
3719 | push ecx edx |
3705 | push ecx edx |
3720 | cmp [edx+TASKDATA.state], 9 |
3706 | cmp [edx+TASKDATA.state], 9 |
3721 | jz .nokill |
3707 | jz .nokill |
3722 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3708 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3723 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3709 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3724 | jz .nokill |
3710 | jz .nokill |
3725 | call request_terminate |
3711 | call request_terminate |
3726 | jmp .common |
3712 | jmp .common |
3727 | .nokill: |
3713 | .nokill: |
3728 | dec byte [SYS_SHUTDOWN] |
3714 | dec byte [SYS_SHUTDOWN] |
3729 | xor eax, eax |
3715 | xor eax, eax |
3730 | .common: |
3716 | .common: |
3731 | pop edx ecx |
3717 | pop edx ecx |
3732 | test eax, eax |
3718 | test eax, eax |
3733 | jz @f |
3719 | jz @f |
3734 | mov [edx+TASKDATA.state], byte 3 |
3720 | mov [edx+TASKDATA.state], byte 3 |
3735 | @@: |
3721 | @@: |
3736 | add edx, 0x20 |
3722 | add edx, 0x20 |
3737 | loop markz |
3723 | loop markz |
3738 | call wakeup_osloop |
3724 | call wakeup_osloop |
3739 | ;-------------------------------------- |
3725 | ;-------------------------------------- |
3740 | align 4 |
3726 | align 4 |
3741 | @@: |
3727 | @@: |
3742 | no_mark_system_shutdown: |
3728 | no_mark_system_shutdown: |
3743 | dec byte [SYS_SHUTDOWN] |
3729 | dec byte [SYS_SHUTDOWN] |
3744 | je system_shutdown |
3730 | je system_shutdown |
3745 | ;-------------------------------------- |
3731 | ;-------------------------------------- |
3746 | align 4 |
3732 | align 4 |
3747 | noshutdown: |
3733 | noshutdown: |
3748 | mov eax, [TASK_COUNT] ; termination |
3734 | mov eax, [TASK_COUNT] ; termination |
3749 | mov ebx, TASK_DATA+TASKDATA.state |
3735 | mov ebx, TASK_DATA+TASKDATA.state |
3750 | mov esi, 1 |
3736 | mov esi, 1 |
3751 | ;-------------------------------------- |
3737 | ;-------------------------------------- |
3752 | align 4 |
3738 | align 4 |
3753 | newct: |
3739 | newct: |
3754 | mov cl, [ebx] |
3740 | mov cl, [ebx] |
3755 | cmp cl, byte 3 |
3741 | cmp cl, byte 3 |
3756 | jz .terminate |
3742 | jz .terminate |
3757 | 3743 | ||
3758 | cmp cl, byte 4 |
3744 | cmp cl, byte 4 |
3759 | jnz .noterminate |
3745 | jnz .noterminate |
3760 | .terminate: |
3746 | .terminate: |
3761 | pushad |
3747 | pushad |
3762 | mov ecx, eax |
3748 | mov ecx, eax |
3763 | shl ecx, 8 |
3749 | shl ecx, 8 |
3764 | add ecx, SLOT_BASE |
3750 | add ecx, SLOT_BASE |
3765 | call restore_default_cursor_before_killing |
3751 | call restore_default_cursor_before_killing |
3766 | popad |
3752 | popad |
3767 | 3753 | ||
3768 | pushad |
3754 | pushad |
3769 | call terminate |
3755 | call terminate |
3770 | popad |
3756 | popad |
3771 | cmp byte [SYS_SHUTDOWN], 0 |
3757 | cmp byte [SYS_SHUTDOWN], 0 |
3772 | jz .noterminate |
3758 | jz .noterminate |
3773 | dec byte [SYS_SHUTDOWN] |
3759 | dec byte [SYS_SHUTDOWN] |
3774 | je system_shutdown |
3760 | je system_shutdown |
3775 | 3761 | ||
3776 | .noterminate: |
3762 | .noterminate: |
3777 | add ebx, 0x20 |
3763 | add ebx, 0x20 |
3778 | inc esi |
3764 | inc esi |
3779 | dec eax |
3765 | dec eax |
3780 | jnz newct |
3766 | jnz newct |
3781 | ret |
3767 | ret |
3782 | ;----------------------------------------------------------------------------- |
3768 | ;----------------------------------------------------------------------------- |
3783 | align 4 |
3769 | align 4 |
3784 | redrawscreen: |
3770 | redrawscreen: |
3785 | ; eax , if process window_data base is eax, do not set flag/limits |
3771 | ; eax , if process window_data base is eax, do not set flag/limits |
3786 | 3772 | ||
3787 | pushad |
3773 | pushad |
3788 | push eax |
3774 | push eax |
3789 | 3775 | ||
3790 | ;;; mov ebx,2 |
3776 | ;;; mov ebx,2 |
3791 | ;;; call delay_hs |
3777 | ;;; call delay_hs |
3792 | 3778 | ||
3793 | ;mov ecx,0 ; redraw flags for apps |
3779 | ;mov ecx,0 ; redraw flags for apps |
3794 | xor ecx, ecx |
3780 | xor ecx, ecx |
3795 | ;-------------------------------------- |
3781 | ;-------------------------------------- |
3796 | align 4 |
3782 | align 4 |
3797 | newdw2: |
3783 | newdw2: |
3798 | inc ecx |
3784 | inc ecx |
3799 | push ecx |
3785 | push ecx |
3800 | 3786 | ||
3801 | mov eax, ecx |
3787 | mov eax, ecx |
3802 | shl eax, 5 |
3788 | shl eax, 5 |
3803 | add eax, window_data |
3789 | add eax, window_data |
3804 | 3790 | ||
3805 | cmp eax, [esp+4] |
3791 | cmp eax, [esp+4] |
3806 | je not_this_task |
3792 | je not_this_task |
3807 | ; check if window in redraw area |
3793 | ; check if window in redraw area |
3808 | mov edi, eax |
3794 | mov edi, eax |
3809 | 3795 | ||
3810 | cmp ecx, 1 ; limit for background |
3796 | cmp ecx, 1 ; limit for background |
3811 | jz bgli |
3797 | jz bgli |
3812 | 3798 | ||
3813 | mov eax, [edi + WDATA.box.left] |
3799 | mov eax, [edi + WDATA.box.left] |
3814 | mov ebx, [edi + WDATA.box.top] |
3800 | mov ebx, [edi + WDATA.box.top] |
3815 | 3801 | ||
3816 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3802 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3817 | cmp ecx, ebx |
3803 | cmp ecx, ebx |
3818 | jb ricino |
3804 | jb ricino |
3819 | 3805 | ||
3820 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3806 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3821 | cmp ecx, eax |
3807 | cmp ecx, eax |
3822 | jb ricino |
3808 | jb ricino |
3823 | 3809 | ||
3824 | mov eax, [edi + WDATA.box.left] |
3810 | mov eax, [edi + WDATA.box.left] |
3825 | mov ebx, [edi + WDATA.box.top] |
3811 | mov ebx, [edi + WDATA.box.top] |
3826 | mov ecx, [edi + WDATA.box.width] |
3812 | mov ecx, [edi + WDATA.box.width] |
3827 | mov edx, [edi + WDATA.box.height] |
3813 | mov edx, [edi + WDATA.box.height] |
3828 | add ecx, eax |
3814 | add ecx, eax |
3829 | add edx, ebx |
3815 | add edx, ebx |
3830 | 3816 | ||
3831 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3817 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3832 | cmp edx, eax |
3818 | cmp edx, eax |
3833 | jb ricino |
3819 | jb ricino |
3834 | 3820 | ||
3835 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3821 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3836 | cmp ecx, eax |
3822 | cmp ecx, eax |
3837 | jb ricino |
3823 | jb ricino |
3838 | ;-------------------------------------- |
3824 | ;-------------------------------------- |
3839 | align 4 |
3825 | align 4 |
3840 | bgli: |
3826 | bgli: |
3841 | cmp dword[esp], 1 |
3827 | cmp dword[esp], 1 |
3842 | jnz .az |
3828 | jnz .az |
3843 | 3829 | ||
3844 | cmp byte[REDRAW_BACKGROUND], 0 |
3830 | cmp byte[REDRAW_BACKGROUND], 0 |
3845 | jz .az |
3831 | jz .az |
3846 | 3832 | ||
3847 | mov dl, 0 |
3833 | mov dl, 0 |
3848 | lea eax, [edi+draw_data-window_data] |
3834 | lea eax, [edi+draw_data-window_data] |
3849 | mov ebx, [draw_limits.left] |
3835 | mov ebx, [draw_limits.left] |
3850 | cmp ebx, [eax+RECT.left] |
3836 | cmp ebx, [eax+RECT.left] |
3851 | jae @f |
3837 | jae @f |
3852 | 3838 | ||
3853 | mov [eax+RECT.left], ebx |
3839 | mov [eax+RECT.left], ebx |
3854 | mov dl, 1 |
3840 | mov dl, 1 |
3855 | ;-------------------------------------- |
3841 | ;-------------------------------------- |
3856 | align 4 |
3842 | align 4 |
3857 | @@: |
3843 | @@: |
3858 | mov ebx, [draw_limits.top] |
3844 | mov ebx, [draw_limits.top] |
3859 | cmp ebx, [eax+RECT.top] |
3845 | cmp ebx, [eax+RECT.top] |
3860 | jae @f |
3846 | jae @f |
3861 | 3847 | ||
3862 | mov [eax+RECT.top], ebx |
3848 | mov [eax+RECT.top], ebx |
3863 | mov dl, 1 |
3849 | mov dl, 1 |
3864 | ;-------------------------------------- |
3850 | ;-------------------------------------- |
3865 | align 4 |
3851 | align 4 |
3866 | @@: |
3852 | @@: |
3867 | mov ebx, [draw_limits.right] |
3853 | mov ebx, [draw_limits.right] |
3868 | cmp ebx, [eax+RECT.right] |
3854 | cmp ebx, [eax+RECT.right] |
3869 | jbe @f |
3855 | jbe @f |
3870 | 3856 | ||
3871 | mov [eax+RECT.right], ebx |
3857 | mov [eax+RECT.right], ebx |
3872 | mov dl, 1 |
3858 | mov dl, 1 |
3873 | ;-------------------------------------- |
3859 | ;-------------------------------------- |
3874 | align 4 |
3860 | align 4 |
3875 | @@: |
3861 | @@: |
3876 | mov ebx, [draw_limits.bottom] |
3862 | mov ebx, [draw_limits.bottom] |
3877 | cmp ebx, [eax+RECT.bottom] |
3863 | cmp ebx, [eax+RECT.bottom] |
3878 | jbe @f |
3864 | jbe @f |
3879 | 3865 | ||
3880 | mov [eax+RECT.bottom], ebx |
3866 | mov [eax+RECT.bottom], ebx |
3881 | mov dl, 1 |
3867 | mov dl, 1 |
3882 | ;-------------------------------------- |
3868 | ;-------------------------------------- |
3883 | align 4 |
3869 | align 4 |
3884 | @@: |
3870 | @@: |
3885 | add byte[REDRAW_BACKGROUND], dl |
3871 | add byte[REDRAW_BACKGROUND], dl |
3886 | call wakeup_osloop |
3872 | call wakeup_osloop |
3887 | jmp newdw8 |
3873 | jmp newdw8 |
3888 | ;-------------------------------------- |
3874 | ;-------------------------------------- |
3889 | align 4 |
3875 | align 4 |
3890 | .az: |
3876 | .az: |
3891 | mov eax, edi |
3877 | mov eax, edi |
3892 | add eax, draw_data-window_data |
3878 | add eax, draw_data-window_data |
3893 | 3879 | ||
3894 | mov ebx, [draw_limits.left] ; set limits |
3880 | mov ebx, [draw_limits.left] ; set limits |
3895 | mov [eax + RECT.left], ebx |
3881 | mov [eax + RECT.left], ebx |
3896 | mov ebx, [draw_limits.top] |
3882 | mov ebx, [draw_limits.top] |
3897 | mov [eax + RECT.top], ebx |
3883 | mov [eax + RECT.top], ebx |
3898 | mov ebx, [draw_limits.right] |
3884 | mov ebx, [draw_limits.right] |
3899 | mov [eax + RECT.right], ebx |
3885 | mov [eax + RECT.right], ebx |
3900 | mov ebx, [draw_limits.bottom] |
3886 | mov ebx, [draw_limits.bottom] |
3901 | mov [eax + RECT.bottom], ebx |
3887 | mov [eax + RECT.bottom], ebx |
3902 | 3888 | ||
3903 | sub eax, draw_data-window_data |
3889 | sub eax, draw_data-window_data |
3904 | 3890 | ||
3905 | cmp dword [esp], 1 |
3891 | cmp dword [esp], 1 |
3906 | jne nobgrd |
3892 | jne nobgrd |
3907 | inc byte[REDRAW_BACKGROUND] |
3893 | inc byte[REDRAW_BACKGROUND] |
3908 | call wakeup_osloop |
3894 | call wakeup_osloop |
3909 | ;-------------------------------------- |
3895 | ;-------------------------------------- |
3910 | align 4 |
3896 | align 4 |
3911 | newdw8: |
3897 | newdw8: |
3912 | nobgrd: |
3898 | nobgrd: |
3913 | ;-------------------------------------- |
3899 | ;-------------------------------------- |
3914 | push eax edi ebp |
3900 | push eax edi ebp |
3915 | mov edi, [esp+12] |
3901 | mov edi, [esp+12] |
3916 | cmp edi, 1 |
3902 | cmp edi, 1 |
3917 | je .found |
3903 | je .found |
3918 | 3904 | ||
3919 | mov eax, [draw_limits.left] |
3905 | mov eax, [draw_limits.left] |
3920 | mov ebx, [draw_limits.top] |
3906 | mov ebx, [draw_limits.top] |
3921 | mov ecx, [draw_limits.right] |
3907 | mov ecx, [draw_limits.right] |
3922 | sub ecx, eax |
3908 | sub ecx, eax |
3923 | test ecx, ecx |
3909 | test ecx, ecx |
3924 | jz .not_found |
3910 | jz .not_found |
3925 | 3911 | ||
3926 | mov edx, [draw_limits.bottom] |
3912 | mov edx, [draw_limits.bottom] |
3927 | sub edx, ebx |
3913 | sub edx, ebx |
3928 | test edx, edx |
3914 | test edx, edx |
3929 | jz .not_found |
3915 | jz .not_found |
3930 | 3916 | ||
3931 | ; eax - x, ebx - y |
3917 | ; eax - x, ebx - y |
3932 | ; ecx - size x, edx - size y |
3918 | ; ecx - size x, edx - size y |
3933 | add ebx, edx |
3919 | add ebx, edx |
3934 | ;-------------------------------------- |
3920 | ;-------------------------------------- |
3935 | align 4 |
3921 | align 4 |
3936 | .start_y: |
3922 | .start_y: |
3937 | push ecx |
3923 | push ecx |
3938 | ;-------------------------------------- |
3924 | ;-------------------------------------- |
3939 | align 4 |
3925 | align 4 |
3940 | .start_x: |
3926 | .start_x: |
3941 | add eax, ecx |
3927 | add eax, ecx |
3942 | mov ebp, [d_width_calc_area + ebx*4] |
3928 | mov ebp, [d_width_calc_area + ebx*4] |
3943 | add ebp, [_WinMapAddress] |
3929 | add ebp, [_WinMapAddress] |
3944 | movzx ebp, byte[eax+ebp] ; get value for current point |
3930 | movzx ebp, byte[eax+ebp] ; get value for current point |
3945 | cmp ebp, edi |
3931 | cmp ebp, edi |
3946 | jne @f |
3932 | jne @f |
3947 | 3933 | ||
3948 | pop ecx |
3934 | pop ecx |
3949 | jmp .found |
3935 | jmp .found |
3950 | ;-------------------------------------- |
3936 | ;-------------------------------------- |
3951 | align 4 |
3937 | align 4 |
3952 | @@: |
3938 | @@: |
3953 | sub eax, ecx |
3939 | sub eax, ecx |
3954 | 3940 | ||
3955 | dec ecx |
3941 | dec ecx |
3956 | jnz .start_x |
3942 | jnz .start_x |
3957 | 3943 | ||
3958 | pop ecx |
3944 | pop ecx |
3959 | dec ebx |
3945 | dec ebx |
3960 | dec edx |
3946 | dec edx |
3961 | jnz .start_y |
3947 | jnz .start_y |
3962 | ;-------------------------------------- |
3948 | ;-------------------------------------- |
3963 | align 4 |
3949 | align 4 |
3964 | .not_found: |
3950 | .not_found: |
3965 | pop ebp edi eax |
3951 | pop ebp edi eax |
3966 | jmp ricino |
3952 | jmp ricino |
3967 | ;-------------------------------------- |
3953 | ;-------------------------------------- |
3968 | align 4 |
3954 | align 4 |
3969 | .found: |
3955 | .found: |
3970 | pop ebp edi eax |
3956 | pop ebp edi eax |
3971 | 3957 | ||
3972 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3958 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3973 | ;-------------------------------------- |
3959 | ;-------------------------------------- |
3974 | align 4 |
3960 | align 4 |
3975 | ricino: |
3961 | ricino: |
3976 | not_this_task: |
3962 | not_this_task: |
3977 | pop ecx |
3963 | pop ecx |
3978 | 3964 | ||
3979 | cmp ecx, [TASK_COUNT] |
3965 | cmp ecx, [TASK_COUNT] |
3980 | jle newdw2 |
3966 | jle newdw2 |
3981 | 3967 | ||
3982 | pop eax |
3968 | pop eax |
3983 | popad |
3969 | popad |
3984 | ret |
3970 | ret |
3985 | ;----------------------------------------------------------------------------- |
3971 | ;----------------------------------------------------------------------------- |
3986 | align 4 |
3972 | align 4 |
3987 | calculatebackground: ; background |
3973 | calculatebackground: ; background |
3988 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3974 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3989 | mov eax, 0x01010101 |
3975 | mov eax, 0x01010101 |
3990 | mov ecx, [_WinMapSize] |
3976 | mov ecx, [_WinMapSize] |
3991 | shr ecx, 2 |
3977 | shr ecx, 2 |
3992 | rep stosd |
3978 | rep stosd |
3993 | 3979 | ||
3994 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3980 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3995 | ret |
3981 | ret |
3996 | ;----------------------------------------------------------------------------- |
3982 | ;----------------------------------------------------------------------------- |
3997 | uglobal |
3983 | uglobal |
3998 | imax dd 0x0 |
3984 | imax dd 0x0 |
3999 | endg |
3985 | endg |
4000 | ;----------------------------------------------------------------------------- |
3986 | ;----------------------------------------------------------------------------- |
4001 | align 4 |
3987 | align 4 |
4002 | delay_ms: ; delay in 1/1000 sec |
3988 | delay_ms: ; delay in 1/1000 sec |
4003 | push eax |
3989 | push eax |
4004 | push ecx |
3990 | push ecx |
4005 | 3991 | ||
4006 | mov ecx, esi |
3992 | mov ecx, esi |
4007 | ; |
3993 | ; |
4008 | imul ecx, 33941 |
3994 | imul ecx, 33941 |
4009 | shr ecx, 9 |
3995 | shr ecx, 9 |
4010 | ; |
3996 | ; |
4011 | 3997 | ||
4012 | in al, 0x61 |
3998 | in al, 0x61 |
4013 | and al, 0x10 |
3999 | and al, 0x10 |
4014 | mov ah, al |
4000 | mov ah, al |
4015 | cld |
4001 | cld |
4016 | ;-------------------------------------- |
4002 | ;-------------------------------------- |
4017 | align 4 |
4003 | align 4 |
4018 | cnt1: |
4004 | cnt1: |
4019 | in al, 0x61 |
4005 | in al, 0x61 |
4020 | and al, 0x10 |
4006 | and al, 0x10 |
4021 | cmp al, ah |
4007 | cmp al, ah |
4022 | jz cnt1 |
4008 | jz cnt1 |
4023 | 4009 | ||
4024 | mov ah, al |
4010 | mov ah, al |
4025 | loop cnt1 |
4011 | loop cnt1 |
4026 | 4012 | ||
4027 | pop ecx |
4013 | pop ecx |
4028 | pop eax |
4014 | pop eax |
4029 | ret |
4015 | ret |
4030 | ;----------------------------------------------------------------------------- |
4016 | ;----------------------------------------------------------------------------- |
4031 | align 4 |
4017 | align 4 |
4032 | set_app_param: |
4018 | set_app_param: |
4033 | mov edi, [TASK_BASE] |
4019 | mov edi, [TASK_BASE] |
4034 | mov eax, ebx |
4020 | mov eax, ebx |
4035 | btr eax, 3 ; move MOUSE_FILTRATION |
4021 | btr eax, 3 ; move MOUSE_FILTRATION |
4036 | mov ebx, [current_slot] ; bit into event_filter |
4022 | mov ebx, [current_slot] ; bit into event_filter |
4037 | setc byte [ebx+APPDATA.event_filter] |
4023 | setc byte [ebx+APPDATA.event_filter] |
4038 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
4024 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
4039 | mov [esp+32], eax ; return old mask value |
4025 | mov [esp+32], eax ; return old mask value |
4040 | ret |
4026 | ret |
4041 | ;----------------------------------------------------------------------------- |
4027 | ;----------------------------------------------------------------------------- |
4042 | 4028 | ||
4043 | ; this is for syscall |
4029 | ; this is for syscall |
4044 | proc delay_hs_unprotected |
4030 | proc delay_hs_unprotected |
4045 | call unprotect_from_terminate |
4031 | call unprotect_from_terminate |
4046 | call delay_hs |
4032 | call delay_hs |
4047 | call protect_from_terminate |
4033 | call protect_from_terminate |
4048 | ret |
4034 | ret |
4049 | endp |
4035 | endp |
4050 | 4036 | ||
4051 | if 1 |
4037 | if 1 |
4052 | align 4 |
4038 | align 4 |
4053 | delay_hs: ; delay in 1/100 secs |
4039 | delay_hs: ; delay in 1/100 secs |
4054 | ; ebx = delay time |
4040 | ; ebx = delay time |
4055 | 4041 | ||
4056 | pushad |
4042 | pushad |
4057 | push ebx |
4043 | push ebx |
4058 | xor esi, esi |
4044 | xor esi, esi |
4059 | mov ecx, MANUAL_DESTROY |
4045 | mov ecx, MANUAL_DESTROY |
4060 | call create_event |
4046 | call create_event |
4061 | test eax, eax |
4047 | test eax, eax |
4062 | jz .done |
4048 | jz .done |
4063 | 4049 | ||
4064 | mov ebx, edx |
4050 | mov ebx, edx |
4065 | mov ecx, [esp] |
4051 | mov ecx, [esp] |
4066 | push edx |
4052 | push edx |
4067 | push eax |
4053 | push eax |
4068 | call wait_event_timeout |
4054 | call wait_event_timeout |
4069 | pop eax |
4055 | pop eax |
4070 | pop ebx |
4056 | pop ebx |
4071 | call destroy_event |
4057 | call destroy_event |
4072 | .done: |
4058 | .done: |
4073 | add esp, 4 |
4059 | add esp, 4 |
4074 | popad |
4060 | popad |
4075 | ret |
4061 | ret |
4076 | 4062 | ||
4077 | else |
4063 | else |
4078 | 4064 | ||
4079 | align 4 |
4065 | align 4 |
4080 | delay_hs: ; delay in 1/100 secs |
4066 | delay_hs: ; delay in 1/100 secs |
4081 | ; ebx = delay time |
4067 | ; ebx = delay time |
4082 | push ecx |
4068 | push ecx |
4083 | push edx |
4069 | push edx |
4084 | 4070 | ||
4085 | mov edx, [timer_ticks] |
4071 | mov edx, [timer_ticks] |
4086 | ;-------------------------------------- |
4072 | ;-------------------------------------- |
4087 | align 4 |
4073 | align 4 |
4088 | newtic: |
4074 | newtic: |
4089 | mov ecx, [timer_ticks] |
4075 | mov ecx, [timer_ticks] |
4090 | sub ecx, edx |
4076 | sub ecx, edx |
4091 | cmp ecx, ebx |
4077 | cmp ecx, ebx |
4092 | jae zerodelay |
4078 | jae zerodelay |
4093 | 4079 | ||
4094 | call change_task |
4080 | call change_task |
4095 | 4081 | ||
4096 | jmp newtic |
4082 | jmp newtic |
4097 | ;-------------------------------------- |
4083 | ;-------------------------------------- |
4098 | align 4 |
4084 | align 4 |
4099 | zerodelay: |
4085 | zerodelay: |
4100 | pop edx |
4086 | pop edx |
4101 | pop ecx |
4087 | pop ecx |
4102 | ret |
4088 | ret |
4103 | end if |
4089 | end if |
4104 | 4090 | ||
4105 | ;----------------------------------------------------------------------------- |
4091 | ;----------------------------------------------------------------------------- |
4106 | align 16 ;very often call this subrutine |
4092 | align 16 ;very often call this subrutine |
4107 | memmove: ; memory move in bytes |
4093 | memmove: ; memory move in bytes |
4108 | ; eax = from |
4094 | ; eax = from |
4109 | ; ebx = to |
4095 | ; ebx = to |
4110 | ; ecx = no of bytes |
4096 | ; ecx = no of bytes |
4111 | test ecx, ecx |
4097 | test ecx, ecx |
4112 | jle .ret |
4098 | jle .ret |
4113 | 4099 | ||
4114 | push esi edi ecx |
4100 | push esi edi ecx |
4115 | 4101 | ||
4116 | mov edi, ebx |
4102 | mov edi, ebx |
4117 | mov esi, eax |
4103 | mov esi, eax |
4118 | 4104 | ||
4119 | test ecx, not 11b |
4105 | test ecx, not 11b |
4120 | jz @f |
4106 | jz @f |
4121 | 4107 | ||
4122 | push ecx |
4108 | push ecx |
4123 | shr ecx, 2 |
4109 | shr ecx, 2 |
4124 | rep movsd |
4110 | rep movsd |
4125 | pop ecx |
4111 | pop ecx |
4126 | and ecx, 11b |
4112 | and ecx, 11b |
4127 | jz .finish |
4113 | jz .finish |
4128 | ;-------------------------------------- |
4114 | ;-------------------------------------- |
4129 | align 4 |
4115 | align 4 |
4130 | @@: |
4116 | @@: |
4131 | rep movsb |
4117 | rep movsb |
4132 | ;-------------------------------------- |
4118 | ;-------------------------------------- |
4133 | align 4 |
4119 | align 4 |
4134 | .finish: |
4120 | .finish: |
4135 | pop ecx edi esi |
4121 | pop ecx edi esi |
4136 | ;-------------------------------------- |
4122 | ;-------------------------------------- |
4137 | align 4 |
4123 | align 4 |
4138 | .ret: |
4124 | .ret: |
4139 | ret |
4125 | ret |
4140 | ;----------------------------------------------------------------------------- |
4126 | ;----------------------------------------------------------------------------- |
4141 | ; |
4127 | ; |
4142 | ;align 4 |
4128 | ;align 4 |
4143 | ; |
4129 | ; |
4144 | ;read_floppy_file: |
4130 | ;read_floppy_file: |
4145 | ; |
4131 | ; |
4146 | ;; as input |
4132 | ;; as input |
4147 | ;; |
4133 | ;; |
4148 | ;; eax pointer to file |
4134 | ;; eax pointer to file |
4149 | ;; ebx file lenght |
4135 | ;; ebx file lenght |
4150 | ;; ecx start 512 byte block number |
4136 | ;; ecx start 512 byte block number |
4151 | ;; edx number of blocks to read |
4137 | ;; edx number of blocks to read |
4152 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4138 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4153 | ;; |
4139 | ;; |
4154 | ;; |
4140 | ;; |
4155 | ;; on return |
4141 | ;; on return |
4156 | ;; |
4142 | ;; |
4157 | ;; eax = 0 command succesful |
4143 | ;; eax = 0 command succesful |
4158 | ;; 1 no fd base and/or partition defined |
4144 | ;; 1 no fd base and/or partition defined |
4159 | ;; 2 yet unsupported FS |
4145 | ;; 2 yet unsupported FS |
4160 | ;; 3 unknown FS |
4146 | ;; 3 unknown FS |
4161 | ;; 4 partition not defined at hd |
4147 | ;; 4 partition not defined at hd |
4162 | ;; 5 file not found |
4148 | ;; 5 file not found |
4163 | ;; ebx = size of file |
4149 | ;; ebx = size of file |
4164 | ; |
4150 | ; |
4165 | ; mov edi,[TASK_BASE] |
4151 | ; mov edi,[TASK_BASE] |
4166 | ; add edi,0x10 |
4152 | ; add edi,0x10 |
4167 | ; add esi,[edi] |
4153 | ; add esi,[edi] |
4168 | ; add eax,[edi] |
4154 | ; add eax,[edi] |
4169 | ; |
4155 | ; |
4170 | ; pushad |
4156 | ; pushad |
4171 | ; mov edi,esi |
4157 | ; mov edi,esi |
4172 | ; add edi,1024 |
4158 | ; add edi,1024 |
4173 | ; mov esi,0x100000+19*512 |
4159 | ; mov esi,0x100000+19*512 |
4174 | ; sub ecx,1 |
4160 | ; sub ecx,1 |
4175 | ; shl ecx,9 |
4161 | ; shl ecx,9 |
4176 | ; add esi,ecx |
4162 | ; add esi,ecx |
4177 | ; shl edx,9 |
4163 | ; shl edx,9 |
4178 | ; mov ecx,edx |
4164 | ; mov ecx,edx |
4179 | ; cld |
4165 | ; cld |
4180 | ; rep movsb |
4166 | ; rep movsb |
4181 | ; popad |
4167 | ; popad |
4182 | ; |
4168 | ; |
4183 | ; mov [esp+36],eax |
4169 | ; mov [esp+36],eax |
4184 | ; mov [esp+24],ebx |
4170 | ; mov [esp+24],ebx |
4185 | ; ret |
4171 | ; ret |
4186 | 4172 | ||
4187 | 4173 | ||
4188 | 4174 | ||
4189 | align 4 |
4175 | align 4 |
4190 | set_io_access_rights: |
4176 | set_io_access_rights: |
4191 | push edi eax |
4177 | push edi eax |
4192 | mov edi, tss._io_map_0 |
4178 | mov edi, tss._io_map_0 |
4193 | ; mov ecx,eax |
4179 | ; mov ecx,eax |
4194 | ; and ecx,7 ; offset in byte |
4180 | ; and ecx,7 ; offset in byte |
4195 | ; shr eax,3 ; number of byte |
4181 | ; shr eax,3 ; number of byte |
4196 | ; add edi,eax |
4182 | ; add edi,eax |
4197 | ; mov ebx,1 |
4183 | ; mov ebx,1 |
4198 | ; shl ebx,cl |
4184 | ; shl ebx,cl |
4199 | test ebp, ebp |
4185 | test ebp, ebp |
4200 | ; cmp ebp,0 ; enable access - ebp = 0 |
4186 | ; cmp ebp,0 ; enable access - ebp = 0 |
4201 | jnz .siar1 |
4187 | jnz .siar1 |
4202 | ; not ebx |
4188 | ; not ebx |
4203 | ; and [edi],byte bl |
4189 | ; and [edi],byte bl |
4204 | btr [edi], eax |
4190 | btr [edi], eax |
4205 | pop eax edi |
4191 | pop eax edi |
4206 | ret |
4192 | ret |
4207 | .siar1: |
4193 | .siar1: |
4208 | bts [edi], eax |
4194 | bts [edi], eax |
4209 | ; or [edi],byte bl ; disable access - ebp = 1 |
4195 | ; or [edi],byte bl ; disable access - ebp = 1 |
4210 | pop eax edi |
4196 | pop eax edi |
4211 | ret |
4197 | ret |
4212 | ;reserve/free group of ports |
4198 | ;reserve/free group of ports |
4213 | ; * eax = 46 - number function |
4199 | ; * eax = 46 - number function |
4214 | ; * ebx = 0 - reserve, 1 - free |
4200 | ; * ebx = 0 - reserve, 1 - free |
4215 | ; * ecx = number start arrea of ports |
4201 | ; * ecx = number start arrea of ports |
4216 | ; * edx = number end arrea of ports (include last number of port) |
4202 | ; * edx = number end arrea of ports (include last number of port) |
4217 | ;Return value: |
4203 | ;Return value: |
4218 | ; * eax = 0 - succesful |
4204 | ; * eax = 0 - succesful |
4219 | ; * eax = 1 - error |
4205 | ; * eax = 1 - error |
4220 | ; * The system has reserve this ports: |
4206 | ; * The system has reserve this ports: |
4221 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4207 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4222 | ;destroys eax,ebx, ebp |
4208 | ;destroys eax,ebx, ebp |
4223 | r_f_port_area: |
4209 | r_f_port_area: |
4224 | 4210 | ||
4225 | test ebx, ebx |
4211 | test ebx, ebx |
4226 | jnz free_port_area |
4212 | jnz free_port_area |
4227 | ; je r_port_area |
4213 | ; je r_port_area |
4228 | ; jmp free_port_area |
4214 | ; jmp free_port_area |
4229 | 4215 | ||
4230 | ; r_port_area: |
4216 | ; r_port_area: |
4231 | 4217 | ||
4232 | ; pushad |
4218 | ; pushad |
4233 | 4219 | ||
4234 | cmp ecx, edx ; beginning > end ? |
4220 | cmp ecx, edx ; beginning > end ? |
4235 | ja rpal1 |
4221 | ja rpal1 |
4236 | cmp edx, 65536 |
4222 | cmp edx, 65536 |
4237 | jae rpal1 |
4223 | jae rpal1 |
4238 | mov eax, [RESERVED_PORTS] |
4224 | mov eax, [RESERVED_PORTS] |
4239 | test eax, eax ; no reserved areas ? |
4225 | test eax, eax ; no reserved areas ? |
4240 | je rpal2 |
4226 | je rpal2 |
4241 | cmp eax, 255 ; max reserved |
4227 | cmp eax, 255 ; max reserved |
4242 | jae rpal1 |
4228 | jae rpal1 |
4243 | rpal3: |
4229 | rpal3: |
4244 | mov ebx, eax |
4230 | mov ebx, eax |
4245 | shl ebx, 4 |
4231 | shl ebx, 4 |
4246 | add ebx, RESERVED_PORTS |
4232 | add ebx, RESERVED_PORTS |
4247 | cmp ecx, [ebx+8] |
4233 | cmp ecx, [ebx+8] |
4248 | ja rpal4 |
4234 | ja rpal4 |
4249 | cmp edx, [ebx+4] |
4235 | cmp edx, [ebx+4] |
4250 | jae rpal1 |
4236 | jae rpal1 |
4251 | ; jb rpal4 |
4237 | ; jb rpal4 |
4252 | ; jmp rpal1 |
4238 | ; jmp rpal1 |
4253 | rpal4: |
4239 | rpal4: |
4254 | dec eax |
4240 | dec eax |
4255 | jnz rpal3 |
4241 | jnz rpal3 |
4256 | jmp rpal2 |
4242 | jmp rpal2 |
4257 | rpal1: |
4243 | rpal1: |
4258 | ; popad |
4244 | ; popad |
4259 | ; mov eax,1 |
4245 | ; mov eax,1 |
4260 | xor eax, eax |
4246 | xor eax, eax |
4261 | inc eax |
4247 | inc eax |
4262 | ret |
4248 | ret |
4263 | rpal2: |
4249 | rpal2: |
4264 | ; popad |
4250 | ; popad |
4265 | ; enable port access at port IO map |
4251 | ; enable port access at port IO map |
4266 | cli |
4252 | cli |
4267 | pushad ; start enable io map |
4253 | pushad ; start enable io map |
4268 | 4254 | ||
4269 | cmp edx, 65536;16384 |
4255 | cmp edx, 65536;16384 |
4270 | jae no_unmask_io; jge |
4256 | jae no_unmask_io; jge |
4271 | mov eax, ecx |
4257 | mov eax, ecx |
4272 | ; push ebp |
4258 | ; push ebp |
4273 | xor ebp, ebp ; enable - eax = port |
4259 | xor ebp, ebp ; enable - eax = port |
4274 | new_port_access: |
4260 | new_port_access: |
4275 | ; pushad |
4261 | ; pushad |
4276 | call set_io_access_rights |
4262 | call set_io_access_rights |
4277 | ; popad |
4263 | ; popad |
4278 | inc eax |
4264 | inc eax |
4279 | cmp eax, edx |
4265 | cmp eax, edx |
4280 | jbe new_port_access |
4266 | jbe new_port_access |
4281 | ; pop ebp |
4267 | ; pop ebp |
4282 | no_unmask_io: |
4268 | no_unmask_io: |
4283 | popad ; end enable io map |
4269 | popad ; end enable io map |
4284 | sti |
4270 | sti |
4285 | 4271 | ||
4286 | mov eax, [RESERVED_PORTS] |
4272 | mov eax, [RESERVED_PORTS] |
4287 | add eax, 1 |
4273 | add eax, 1 |
4288 | mov [RESERVED_PORTS], eax |
4274 | mov [RESERVED_PORTS], eax |
4289 | shl eax, 4 |
4275 | shl eax, 4 |
4290 | add eax, RESERVED_PORTS |
4276 | add eax, RESERVED_PORTS |
4291 | mov ebx, [TASK_BASE] |
4277 | mov ebx, [TASK_BASE] |
4292 | mov ebx, [ebx+TASKDATA.pid] |
4278 | mov ebx, [ebx+TASKDATA.pid] |
4293 | mov [eax], ebx |
4279 | mov [eax], ebx |
4294 | mov [eax+4], ecx |
4280 | mov [eax+4], ecx |
4295 | mov [eax+8], edx |
4281 | mov [eax+8], edx |
4296 | 4282 | ||
4297 | xor eax, eax |
4283 | xor eax, eax |
4298 | ret |
4284 | ret |
4299 | 4285 | ||
4300 | free_port_area: |
4286 | free_port_area: |
4301 | 4287 | ||
4302 | ; pushad |
4288 | ; pushad |
4303 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4289 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4304 | test eax, eax |
4290 | test eax, eax |
4305 | jz frpal2 |
4291 | jz frpal2 |
4306 | mov ebx, [TASK_BASE] |
4292 | mov ebx, [TASK_BASE] |
4307 | mov ebx, [ebx+TASKDATA.pid] |
4293 | mov ebx, [ebx+TASKDATA.pid] |
4308 | frpal3: |
4294 | frpal3: |
4309 | mov edi, eax |
4295 | mov edi, eax |
4310 | shl edi, 4 |
4296 | shl edi, 4 |
4311 | add edi, RESERVED_PORTS |
4297 | add edi, RESERVED_PORTS |
4312 | cmp ebx, [edi] |
4298 | cmp ebx, [edi] |
4313 | jne frpal4 |
4299 | jne frpal4 |
4314 | cmp ecx, [edi+4] |
4300 | cmp ecx, [edi+4] |
4315 | jne frpal4 |
4301 | jne frpal4 |
4316 | cmp edx, [edi+8] |
4302 | cmp edx, [edi+8] |
4317 | jne frpal4 |
4303 | jne frpal4 |
4318 | jmp frpal1 |
4304 | jmp frpal1 |
4319 | frpal4: |
4305 | frpal4: |
4320 | dec eax |
4306 | dec eax |
4321 | jnz frpal3 |
4307 | jnz frpal3 |
4322 | frpal2: |
4308 | frpal2: |
4323 | ; popad |
4309 | ; popad |
4324 | inc eax |
4310 | inc eax |
4325 | ret |
4311 | ret |
4326 | frpal1: |
4312 | frpal1: |
4327 | push ecx |
4313 | push ecx |
4328 | mov ecx, 256 |
4314 | mov ecx, 256 |
4329 | sub ecx, eax |
4315 | sub ecx, eax |
4330 | shl ecx, 4 |
4316 | shl ecx, 4 |
4331 | mov esi, edi |
4317 | mov esi, edi |
4332 | add esi, 16 |
4318 | add esi, 16 |
4333 | cld |
4319 | cld |
4334 | rep movsb |
4320 | rep movsb |
4335 | 4321 | ||
4336 | dec dword [RESERVED_PORTS] |
4322 | dec dword [RESERVED_PORTS] |
4337 | ;popad |
4323 | ;popad |
4338 | ;disable port access at port IO map |
4324 | ;disable port access at port IO map |
4339 | 4325 | ||
4340 | ; pushad ; start disable io map |
4326 | ; pushad ; start disable io map |
4341 | pop eax ;start port |
4327 | pop eax ;start port |
4342 | cmp edx, 65536;16384 |
4328 | cmp edx, 65536;16384 |
4343 | jge no_mask_io |
4329 | jge no_mask_io |
4344 | 4330 | ||
4345 | ; mov eax,ecx |
4331 | ; mov eax,ecx |
4346 | xor ebp, ebp |
4332 | xor ebp, ebp |
4347 | inc ebp |
4333 | inc ebp |
4348 | new_port_access_disable: |
4334 | new_port_access_disable: |
4349 | ; pushad |
4335 | ; pushad |
4350 | ; mov ebp,1 ; disable - eax = port |
4336 | ; mov ebp,1 ; disable - eax = port |
4351 | call set_io_access_rights |
4337 | call set_io_access_rights |
4352 | ; popad |
4338 | ; popad |
4353 | inc eax |
4339 | inc eax |
4354 | cmp eax, edx |
4340 | cmp eax, edx |
4355 | jbe new_port_access_disable |
4341 | jbe new_port_access_disable |
4356 | no_mask_io: |
4342 | no_mask_io: |
4357 | ; popad ; end disable io map |
4343 | ; popad ; end disable io map |
4358 | xor eax, eax |
4344 | xor eax, eax |
4359 | ret |
4345 | ret |
4360 | ;----------------------------------------------------------------------------- |
4346 | ;----------------------------------------------------------------------------- |
4361 | align 4 |
4347 | align 4 |
4362 | drawbackground: |
4348 | drawbackground: |
4363 | dbrv20: |
4349 | dbrv20: |
4364 | cmp [BgrDrawMode], dword 1 |
4350 | cmp [BgrDrawMode], dword 1 |
4365 | jne bgrstr |
4351 | jne bgrstr |
4366 | call vesa20_drawbackground_tiled |
4352 | call vesa20_drawbackground_tiled |
4367 | ; call [draw_pointer] |
4353 | ; call [draw_pointer] |
4368 | call __sys_draw_pointer |
4354 | call __sys_draw_pointer |
4369 | ret |
4355 | ret |
4370 | ;-------------------------------------- |
4356 | ;-------------------------------------- |
4371 | align 4 |
4357 | align 4 |
4372 | bgrstr: |
4358 | bgrstr: |
4373 | call vesa20_drawbackground_stretch |
4359 | call vesa20_drawbackground_stretch |
4374 | ; call [draw_pointer] |
4360 | ; call [draw_pointer] |
4375 | call __sys_draw_pointer |
4361 | call __sys_draw_pointer |
4376 | ret |
4362 | ret |
4377 | ;----------------------------------------------------------------------------- |
4363 | ;----------------------------------------------------------------------------- |
4378 | align 4 |
4364 | align 4 |
4379 | syscall_putimage: ; PutImage |
4365 | syscall_putimage: ; PutImage |
4380 | sys_putimage: |
4366 | sys_putimage: |
4381 | test ecx, 0x80008000 |
4367 | test ecx, 0x80008000 |
4382 | jnz .exit |
4368 | jnz .exit |
4383 | test ecx, 0x0000FFFF |
4369 | test ecx, 0x0000FFFF |
4384 | jz .exit |
4370 | jz .exit |
4385 | test ecx, 0xFFFF0000 |
4371 | test ecx, 0xFFFF0000 |
4386 | jnz @f |
4372 | jnz @f |
4387 | ;-------------------------------------- |
4373 | ;-------------------------------------- |
4388 | align 4 |
4374 | align 4 |
4389 | .exit: |
4375 | .exit: |
4390 | ret |
4376 | ret |
4391 | ;-------------------------------------- |
4377 | ;-------------------------------------- |
4392 | align 4 |
4378 | align 4 |
4393 | @@: |
4379 | @@: |
4394 | mov edi, [current_slot] |
4380 | mov edi, [current_slot] |
4395 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4381 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4396 | rol edx, 16 |
4382 | rol edx, 16 |
4397 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4383 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4398 | rol edx, 16 |
4384 | rol edx, 16 |
4399 | ;-------------------------------------- |
4385 | ;-------------------------------------- |
4400 | align 4 |
4386 | align 4 |
4401 | .forced: |
4387 | .forced: |
4402 | push ebp esi 0 |
4388 | push ebp esi 0 |
4403 | mov ebp, putimage_get24bpp |
4389 | mov ebp, putimage_get24bpp |
4404 | mov esi, putimage_init24bpp |
4390 | mov esi, putimage_init24bpp |
4405 | ;-------------------------------------- |
4391 | ;-------------------------------------- |
4406 | align 4 |
4392 | align 4 |
4407 | sys_putimage_bpp: |
4393 | sys_putimage_bpp: |
4408 | call vesa20_putimage |
4394 | call vesa20_putimage |
4409 | pop ebp esi ebp |
4395 | pop ebp esi ebp |
4410 | ret |
4396 | ret |
4411 | ; jmp [draw_pointer] |
4397 | ; jmp [draw_pointer] |
4412 | ;----------------------------------------------------------------------------- |
4398 | ;----------------------------------------------------------------------------- |
4413 | align 4 |
4399 | align 4 |
4414 | sys_putimage_palette: |
4400 | sys_putimage_palette: |
4415 | ; ebx = pointer to image |
4401 | ; ebx = pointer to image |
4416 | ; ecx = [xsize]*65536 + [ysize] |
4402 | ; ecx = [xsize]*65536 + [ysize] |
4417 | ; edx = [xstart]*65536 + [ystart] |
4403 | ; edx = [xstart]*65536 + [ystart] |
4418 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4404 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4419 | ; edi = pointer to palette |
4405 | ; edi = pointer to palette |
4420 | ; ebp = row delta |
4406 | ; ebp = row delta |
4421 | mov eax, [CURRENT_TASK] |
4407 | mov eax, [CURRENT_TASK] |
4422 | shl eax, 8 |
4408 | shl eax, 8 |
4423 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4409 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4424 | rol edx, 16 |
4410 | rol edx, 16 |
4425 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4411 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4426 | rol edx, 16 |
4412 | rol edx, 16 |
4427 | ;-------------------------------------- |
4413 | ;-------------------------------------- |
4428 | align 4 |
4414 | align 4 |
4429 | .forced: |
4415 | .forced: |
4430 | cmp esi, 1 |
4416 | cmp esi, 1 |
4431 | jnz @f |
4417 | jnz @f |
4432 | push edi |
4418 | push edi |
4433 | mov eax, [edi+4] |
4419 | mov eax, [edi+4] |
4434 | sub eax, [edi] |
4420 | sub eax, [edi] |
4435 | push eax |
4421 | push eax |
4436 | push dword [edi] |
4422 | push dword [edi] |
4437 | push 0ffffff80h |
4423 | push 0ffffff80h |
4438 | mov edi, esp |
4424 | mov edi, esp |
4439 | call put_mono_image |
4425 | call put_mono_image |
4440 | add esp, 12 |
4426 | add esp, 12 |
4441 | pop edi |
4427 | pop edi |
4442 | ret |
4428 | ret |
4443 | ;-------------------------------------- |
4429 | ;-------------------------------------- |
4444 | align 4 |
4430 | align 4 |
4445 | @@: |
4431 | @@: |
4446 | cmp esi, 2 |
4432 | cmp esi, 2 |
4447 | jnz @f |
4433 | jnz @f |
4448 | push edi |
4434 | push edi |
4449 | push 0ffffff80h |
4435 | push 0ffffff80h |
4450 | mov edi, esp |
4436 | mov edi, esp |
4451 | call put_2bit_image |
4437 | call put_2bit_image |
4452 | pop eax |
4438 | pop eax |
4453 | pop edi |
4439 | pop edi |
4454 | ret |
4440 | ret |
4455 | ;-------------------------------------- |
4441 | ;-------------------------------------- |
4456 | align 4 |
4442 | align 4 |
4457 | @@: |
4443 | @@: |
4458 | cmp esi, 4 |
4444 | cmp esi, 4 |
4459 | jnz @f |
4445 | jnz @f |
4460 | push edi |
4446 | push edi |
4461 | push 0ffffff80h |
4447 | push 0ffffff80h |
4462 | mov edi, esp |
4448 | mov edi, esp |
4463 | call put_4bit_image |
4449 | call put_4bit_image |
4464 | pop eax |
4450 | pop eax |
4465 | pop edi |
4451 | pop edi |
4466 | ret |
4452 | ret |
4467 | ;-------------------------------------- |
4453 | ;-------------------------------------- |
4468 | align 4 |
4454 | align 4 |
4469 | @@: |
4455 | @@: |
4470 | push ebp esi ebp |
4456 | push ebp esi ebp |
4471 | cmp esi, 8 |
4457 | cmp esi, 8 |
4472 | jnz @f |
4458 | jnz @f |
4473 | mov ebp, putimage_get8bpp |
4459 | mov ebp, putimage_get8bpp |
4474 | mov esi, putimage_init8bpp |
4460 | mov esi, putimage_init8bpp |
4475 | jmp sys_putimage_bpp |
4461 | jmp sys_putimage_bpp |
4476 | ;-------------------------------------- |
4462 | ;-------------------------------------- |
4477 | align 4 |
4463 | align 4 |
4478 | @@: |
4464 | @@: |
4479 | cmp esi, 9 |
4465 | cmp esi, 9 |
4480 | jnz @f |
4466 | jnz @f |
4481 | mov ebp, putimage_get9bpp |
4467 | mov ebp, putimage_get9bpp |
4482 | mov esi, putimage_init9bpp |
4468 | mov esi, putimage_init9bpp |
4483 | jmp sys_putimage_bpp |
4469 | jmp sys_putimage_bpp |
4484 | ;-------------------------------------- |
4470 | ;-------------------------------------- |
4485 | align 4 |
4471 | align 4 |
4486 | @@: |
4472 | @@: |
4487 | cmp esi, 15 |
4473 | cmp esi, 15 |
4488 | jnz @f |
4474 | jnz @f |
4489 | mov ebp, putimage_get15bpp |
4475 | mov ebp, putimage_get15bpp |
4490 | mov esi, putimage_init15bpp |
4476 | mov esi, putimage_init15bpp |
4491 | jmp sys_putimage_bpp |
4477 | jmp sys_putimage_bpp |
4492 | ;-------------------------------------- |
4478 | ;-------------------------------------- |
4493 | align 4 |
4479 | align 4 |
4494 | @@: |
4480 | @@: |
4495 | cmp esi, 16 |
4481 | cmp esi, 16 |
4496 | jnz @f |
4482 | jnz @f |
4497 | mov ebp, putimage_get16bpp |
4483 | mov ebp, putimage_get16bpp |
4498 | mov esi, putimage_init16bpp |
4484 | mov esi, putimage_init16bpp |
4499 | jmp sys_putimage_bpp |
4485 | jmp sys_putimage_bpp |
4500 | ;-------------------------------------- |
4486 | ;-------------------------------------- |
4501 | align 4 |
4487 | align 4 |
4502 | @@: |
4488 | @@: |
4503 | cmp esi, 24 |
4489 | cmp esi, 24 |
4504 | jnz @f |
4490 | jnz @f |
4505 | mov ebp, putimage_get24bpp |
4491 | mov ebp, putimage_get24bpp |
4506 | mov esi, putimage_init24bpp |
4492 | mov esi, putimage_init24bpp |
4507 | jmp sys_putimage_bpp |
4493 | jmp sys_putimage_bpp |
4508 | ;-------------------------------------- |
4494 | ;-------------------------------------- |
4509 | align 4 |
4495 | align 4 |
4510 | @@: |
4496 | @@: |
4511 | cmp esi, 32 |
4497 | cmp esi, 32 |
4512 | jnz @f |
4498 | jnz @f |
4513 | mov ebp, putimage_get32bpp |
4499 | mov ebp, putimage_get32bpp |
4514 | mov esi, putimage_init32bpp |
4500 | mov esi, putimage_init32bpp |
4515 | jmp sys_putimage_bpp |
4501 | jmp sys_putimage_bpp |
4516 | ;-------------------------------------- |
4502 | ;-------------------------------------- |
4517 | align 4 |
4503 | align 4 |
4518 | @@: |
4504 | @@: |
4519 | pop ebp esi ebp |
4505 | pop ebp esi ebp |
4520 | ret |
4506 | ret |
4521 | ;----------------------------------------------------------------------------- |
4507 | ;----------------------------------------------------------------------------- |
4522 | align 4 |
4508 | align 4 |
4523 | put_mono_image: |
4509 | put_mono_image: |
4524 | push ebp esi ebp |
4510 | push ebp esi ebp |
4525 | mov ebp, putimage_get1bpp |
4511 | mov ebp, putimage_get1bpp |
4526 | mov esi, putimage_init1bpp |
4512 | mov esi, putimage_init1bpp |
4527 | jmp sys_putimage_bpp |
4513 | jmp sys_putimage_bpp |
4528 | ;----------------------------------------------------------------------------- |
4514 | ;----------------------------------------------------------------------------- |
4529 | align 4 |
4515 | align 4 |
4530 | put_2bit_image: |
4516 | put_2bit_image: |
4531 | push ebp esi ebp |
4517 | push ebp esi ebp |
4532 | mov ebp, putimage_get2bpp |
4518 | mov ebp, putimage_get2bpp |
4533 | mov esi, putimage_init2bpp |
4519 | mov esi, putimage_init2bpp |
4534 | jmp sys_putimage_bpp |
4520 | jmp sys_putimage_bpp |
4535 | ;----------------------------------------------------------------------------- |
4521 | ;----------------------------------------------------------------------------- |
4536 | align 4 |
4522 | align 4 |
4537 | put_4bit_image: |
4523 | put_4bit_image: |
4538 | push ebp esi ebp |
4524 | push ebp esi ebp |
4539 | mov ebp, putimage_get4bpp |
4525 | mov ebp, putimage_get4bpp |
4540 | mov esi, putimage_init4bpp |
4526 | mov esi, putimage_init4bpp |
4541 | jmp sys_putimage_bpp |
4527 | jmp sys_putimage_bpp |
4542 | ;----------------------------------------------------------------------------- |
4528 | ;----------------------------------------------------------------------------- |
4543 | align 4 |
4529 | align 4 |
4544 | putimage_init24bpp: |
4530 | putimage_init24bpp: |
4545 | lea eax, [eax*3] |
4531 | lea eax, [eax*3] |
4546 | putimage_init8bpp: |
4532 | putimage_init8bpp: |
4547 | putimage_init9bpp: |
4533 | putimage_init9bpp: |
4548 | ret |
4534 | ret |
4549 | ;----------------------------------------------------------------------------- |
4535 | ;----------------------------------------------------------------------------- |
4550 | align 16 |
4536 | align 16 |
4551 | putimage_get24bpp: |
4537 | putimage_get24bpp: |
4552 | movzx eax, byte [esi+2] |
4538 | movzx eax, byte [esi+2] |
4553 | shl eax, 16 |
4539 | shl eax, 16 |
4554 | mov ax, [esi] |
4540 | mov ax, [esi] |
4555 | add esi, 3 |
4541 | add esi, 3 |
4556 | ret 4 |
4542 | ret 4 |
4557 | ;----------------------------------------------------------------------------- |
4543 | ;----------------------------------------------------------------------------- |
4558 | align 16 |
4544 | align 16 |
4559 | putimage_get8bpp: |
4545 | putimage_get8bpp: |
4560 | movzx eax, byte [esi] |
4546 | movzx eax, byte [esi] |
4561 | push edx |
4547 | push edx |
4562 | mov edx, [esp+8] |
4548 | mov edx, [esp+8] |
4563 | mov eax, [edx+eax*4] |
4549 | mov eax, [edx+eax*4] |
4564 | pop edx |
4550 | pop edx |
4565 | inc esi |
4551 | inc esi |
4566 | ret 4 |
4552 | ret 4 |
4567 | ;----------------------------------------------------------------------------- |
4553 | ;----------------------------------------------------------------------------- |
4568 | align 16 |
4554 | align 16 |
4569 | putimage_get9bpp: |
4555 | putimage_get9bpp: |
4570 | lodsb |
4556 | lodsb |
4571 | mov ah, al |
4557 | mov ah, al |
4572 | shl eax, 8 |
4558 | shl eax, 8 |
4573 | mov al, ah |
4559 | mov al, ah |
4574 | ret 4 |
4560 | ret 4 |
4575 | ;----------------------------------------------------------------------------- |
4561 | ;----------------------------------------------------------------------------- |
4576 | align 4 |
4562 | align 4 |
4577 | putimage_init1bpp: |
4563 | putimage_init1bpp: |
4578 | add eax, ecx |
4564 | add eax, ecx |
4579 | push ecx |
4565 | push ecx |
4580 | add eax, 7 |
4566 | add eax, 7 |
4581 | add ecx, 7 |
4567 | add ecx, 7 |
4582 | shr eax, 3 |
4568 | shr eax, 3 |
4583 | shr ecx, 3 |
4569 | shr ecx, 3 |
4584 | sub eax, ecx |
4570 | sub eax, ecx |
4585 | pop ecx |
4571 | pop ecx |
4586 | ret |
4572 | ret |
4587 | ;----------------------------------------------------------------------------- |
4573 | ;----------------------------------------------------------------------------- |
4588 | align 16 |
4574 | align 16 |
4589 | putimage_get1bpp: |
4575 | putimage_get1bpp: |
4590 | push edx |
4576 | push edx |
4591 | mov edx, [esp+8] |
4577 | mov edx, [esp+8] |
4592 | mov al, [edx] |
4578 | mov al, [edx] |
4593 | add al, al |
4579 | add al, al |
4594 | jnz @f |
4580 | jnz @f |
4595 | lodsb |
4581 | lodsb |
4596 | adc al, al |
4582 | adc al, al |
4597 | @@: |
4583 | @@: |
4598 | mov [edx], al |
4584 | mov [edx], al |
4599 | sbb eax, eax |
4585 | sbb eax, eax |
4600 | and eax, [edx+8] |
4586 | and eax, [edx+8] |
4601 | add eax, [edx+4] |
4587 | add eax, [edx+4] |
4602 | pop edx |
4588 | pop edx |
4603 | ret 4 |
4589 | ret 4 |
4604 | ;----------------------------------------------------------------------------- |
4590 | ;----------------------------------------------------------------------------- |
4605 | align 4 |
4591 | align 4 |
4606 | putimage_init2bpp: |
4592 | putimage_init2bpp: |
4607 | add eax, ecx |
4593 | add eax, ecx |
4608 | push ecx |
4594 | push ecx |
4609 | add ecx, 3 |
4595 | add ecx, 3 |
4610 | add eax, 3 |
4596 | add eax, 3 |
4611 | shr ecx, 2 |
4597 | shr ecx, 2 |
4612 | shr eax, 2 |
4598 | shr eax, 2 |
4613 | sub eax, ecx |
4599 | sub eax, ecx |
4614 | pop ecx |
4600 | pop ecx |
4615 | ret |
4601 | ret |
4616 | ;----------------------------------------------------------------------------- |
4602 | ;----------------------------------------------------------------------------- |
4617 | align 16 |
4603 | align 16 |
4618 | putimage_get2bpp: |
4604 | putimage_get2bpp: |
4619 | push edx |
4605 | push edx |
4620 | mov edx, [esp+8] |
4606 | mov edx, [esp+8] |
4621 | mov al, [edx] |
4607 | mov al, [edx] |
4622 | mov ah, al |
4608 | mov ah, al |
4623 | shr al, 6 |
4609 | shr al, 6 |
4624 | shl ah, 2 |
4610 | shl ah, 2 |
4625 | jnz .nonewbyte |
4611 | jnz .nonewbyte |
4626 | lodsb |
4612 | lodsb |
4627 | mov ah, al |
4613 | mov ah, al |
4628 | shr al, 6 |
4614 | shr al, 6 |
4629 | shl ah, 2 |
4615 | shl ah, 2 |
4630 | add ah, 1 |
4616 | add ah, 1 |
4631 | .nonewbyte: |
4617 | .nonewbyte: |
4632 | mov [edx], ah |
4618 | mov [edx], ah |
4633 | mov edx, [edx+4] |
4619 | mov edx, [edx+4] |
4634 | movzx eax, al |
4620 | movzx eax, al |
4635 | mov eax, [edx+eax*4] |
4621 | mov eax, [edx+eax*4] |
4636 | pop edx |
4622 | pop edx |
4637 | ret 4 |
4623 | ret 4 |
4638 | ;----------------------------------------------------------------------------- |
4624 | ;----------------------------------------------------------------------------- |
4639 | align 4 |
4625 | align 4 |
4640 | putimage_init4bpp: |
4626 | putimage_init4bpp: |
4641 | add eax, ecx |
4627 | add eax, ecx |
4642 | push ecx |
4628 | push ecx |
4643 | add ecx, 1 |
4629 | add ecx, 1 |
4644 | add eax, 1 |
4630 | add eax, 1 |
4645 | shr ecx, 1 |
4631 | shr ecx, 1 |
4646 | shr eax, 1 |
4632 | shr eax, 1 |
4647 | sub eax, ecx |
4633 | sub eax, ecx |
4648 | pop ecx |
4634 | pop ecx |
4649 | ret |
4635 | ret |
4650 | ;----------------------------------------------------------------------------- |
4636 | ;----------------------------------------------------------------------------- |
4651 | align 16 |
4637 | align 16 |
4652 | putimage_get4bpp: |
4638 | putimage_get4bpp: |
4653 | push edx |
4639 | push edx |
4654 | mov edx, [esp+8] |
4640 | mov edx, [esp+8] |
4655 | add byte [edx], 80h |
4641 | add byte [edx], 80h |
4656 | jc @f |
4642 | jc @f |
4657 | movzx eax, byte [edx+1] |
4643 | movzx eax, byte [edx+1] |
4658 | mov edx, [edx+4] |
4644 | mov edx, [edx+4] |
4659 | and eax, 0x0F |
4645 | and eax, 0x0F |
4660 | mov eax, [edx+eax*4] |
4646 | mov eax, [edx+eax*4] |
4661 | pop edx |
4647 | pop edx |
4662 | ret 4 |
4648 | ret 4 |
4663 | @@: |
4649 | @@: |
4664 | movzx eax, byte [esi] |
4650 | movzx eax, byte [esi] |
4665 | add esi, 1 |
4651 | add esi, 1 |
4666 | mov [edx+1], al |
4652 | mov [edx+1], al |
4667 | shr eax, 4 |
4653 | shr eax, 4 |
4668 | mov edx, [edx+4] |
4654 | mov edx, [edx+4] |
4669 | mov eax, [edx+eax*4] |
4655 | mov eax, [edx+eax*4] |
4670 | pop edx |
4656 | pop edx |
4671 | ret 4 |
4657 | ret 4 |
4672 | ;----------------------------------------------------------------------------- |
4658 | ;----------------------------------------------------------------------------- |
4673 | align 4 |
4659 | align 4 |
4674 | putimage_init32bpp: |
4660 | putimage_init32bpp: |
4675 | shl eax, 2 |
4661 | shl eax, 2 |
4676 | ret |
4662 | ret |
4677 | ;----------------------------------------------------------------------------- |
4663 | ;----------------------------------------------------------------------------- |
4678 | align 16 |
4664 | align 16 |
4679 | putimage_get32bpp: |
4665 | putimage_get32bpp: |
4680 | lodsd |
4666 | lodsd |
4681 | ret 4 |
4667 | ret 4 |
4682 | ;----------------------------------------------------------------------------- |
4668 | ;----------------------------------------------------------------------------- |
4683 | align 4 |
4669 | align 4 |
4684 | putimage_init15bpp: |
4670 | putimage_init15bpp: |
4685 | putimage_init16bpp: |
4671 | putimage_init16bpp: |
4686 | add eax, eax |
4672 | add eax, eax |
4687 | ret |
4673 | ret |
4688 | ;----------------------------------------------------------------------------- |
4674 | ;----------------------------------------------------------------------------- |
4689 | align 16 |
4675 | align 16 |
4690 | putimage_get15bpp: |
4676 | putimage_get15bpp: |
4691 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4677 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4692 | push ecx edx |
4678 | push ecx edx |
4693 | movzx eax, word [esi] |
4679 | movzx eax, word [esi] |
4694 | add esi, 2 |
4680 | add esi, 2 |
4695 | mov ecx, eax |
4681 | mov ecx, eax |
4696 | mov edx, eax |
4682 | mov edx, eax |
4697 | and eax, 0x1F |
4683 | and eax, 0x1F |
4698 | and ecx, 0x1F shl 5 |
4684 | and ecx, 0x1F shl 5 |
4699 | and edx, 0x1F shl 10 |
4685 | and edx, 0x1F shl 10 |
4700 | shl eax, 3 |
4686 | shl eax, 3 |
4701 | shl ecx, 6 |
4687 | shl ecx, 6 |
4702 | shl edx, 9 |
4688 | shl edx, 9 |
4703 | or eax, ecx |
4689 | or eax, ecx |
4704 | or eax, edx |
4690 | or eax, edx |
4705 | pop edx ecx |
4691 | pop edx ecx |
4706 | ret 4 |
4692 | ret 4 |
4707 | ;----------------------------------------------------------------------------- |
4693 | ;----------------------------------------------------------------------------- |
4708 | align 16 |
4694 | align 16 |
4709 | putimage_get16bpp: |
4695 | putimage_get16bpp: |
4710 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4696 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4711 | push ecx edx |
4697 | push ecx edx |
4712 | movzx eax, word [esi] |
4698 | movzx eax, word [esi] |
4713 | add esi, 2 |
4699 | add esi, 2 |
4714 | mov ecx, eax |
4700 | mov ecx, eax |
4715 | mov edx, eax |
4701 | mov edx, eax |
4716 | and eax, 0x1F |
4702 | and eax, 0x1F |
4717 | and ecx, 0x3F shl 5 |
4703 | and ecx, 0x3F shl 5 |
4718 | and edx, 0x1F shl 11 |
4704 | and edx, 0x1F shl 11 |
4719 | shl eax, 3 |
4705 | shl eax, 3 |
4720 | shl ecx, 5 |
4706 | shl ecx, 5 |
4721 | shl edx, 8 |
4707 | shl edx, 8 |
4722 | or eax, ecx |
4708 | or eax, ecx |
4723 | or eax, edx |
4709 | or eax, edx |
4724 | pop edx ecx |
4710 | pop edx ecx |
4725 | ret 4 |
4711 | ret 4 |
4726 | ;----------------------------------------------------------------------------- |
4712 | ;----------------------------------------------------------------------------- |
4727 | ;align 4 |
4713 | ;align 4 |
4728 | ; eax x beginning |
4714 | ; eax x beginning |
4729 | ; ebx y beginning |
4715 | ; ebx y beginning |
4730 | ; ecx x end |
4716 | ; ecx x end |
4731 | ; edx y end |
4717 | ; edx y end |
4732 | ; edi color |
4718 | ; edi color |
4733 | ;__sys_drawbar: |
4719 | ;__sys_drawbar: |
4734 | ; mov esi, [current_slot] |
4720 | ; mov esi, [current_slot] |
4735 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4721 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4736 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4722 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4737 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4723 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4738 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4724 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4739 | ;-------------------------------------- |
4725 | ;-------------------------------------- |
4740 | ;align 4 |
4726 | ;align 4 |
4741 | ;.forced: |
4727 | ;.forced: |
4742 | ; call vesa20_drawbar |
4728 | ; call vesa20_drawbar |
4743 | ; call [draw_pointer] |
4729 | ; call [draw_pointer] |
4744 | ; ret |
4730 | ; ret |
4745 | ;----------------------------------------------------------------------------- |
4731 | ;----------------------------------------------------------------------------- |
4746 | align 4 |
4732 | align 4 |
4747 | kb_read: |
4733 | kb_read: |
4748 | 4734 | ||
4749 | push ecx edx |
4735 | push ecx edx |
4750 | 4736 | ||
4751 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4737 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4752 | kr_loop: |
4738 | kr_loop: |
4753 | in al, 0x64 |
4739 | in al, 0x64 |
4754 | test al, 1 |
4740 | test al, 1 |
4755 | jnz kr_ready |
4741 | jnz kr_ready |
4756 | loop kr_loop |
4742 | loop kr_loop |
4757 | mov ah, 1 |
4743 | mov ah, 1 |
4758 | jmp kr_exit |
4744 | jmp kr_exit |
4759 | kr_ready: |
4745 | kr_ready: |
4760 | push ecx |
4746 | push ecx |
4761 | mov ecx, 32 |
4747 | mov ecx, 32 |
4762 | kr_delay: |
4748 | kr_delay: |
4763 | loop kr_delay |
4749 | loop kr_delay |
4764 | pop ecx |
4750 | pop ecx |
4765 | in al, 0x60 |
4751 | in al, 0x60 |
4766 | xor ah, ah |
4752 | xor ah, ah |
4767 | kr_exit: |
4753 | kr_exit: |
4768 | 4754 | ||
4769 | pop edx ecx |
4755 | pop edx ecx |
4770 | 4756 | ||
4771 | ret |
4757 | ret |
4772 | ;----------------------------------------------------------------------------- |
4758 | ;----------------------------------------------------------------------------- |
4773 | align 4 |
4759 | align 4 |
4774 | kb_write: |
4760 | kb_write: |
4775 | 4761 | ||
4776 | push ecx edx |
4762 | push ecx edx |
4777 | 4763 | ||
4778 | mov dl, al |
4764 | mov dl, al |
4779 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4765 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4780 | ; kw_loop1: |
4766 | ; kw_loop1: |
4781 | ; in al,0x64 |
4767 | ; in al,0x64 |
4782 | ; test al,0x20 |
4768 | ; test al,0x20 |
4783 | ; jz kw_ok1 |
4769 | ; jz kw_ok1 |
4784 | ; loop kw_loop1 |
4770 | ; loop kw_loop1 |
4785 | ; mov ah,1 |
4771 | ; mov ah,1 |
4786 | ; jmp kw_exit |
4772 | ; jmp kw_exit |
4787 | ; kw_ok1: |
4773 | ; kw_ok1: |
4788 | in al, 0x60 |
4774 | in al, 0x60 |
4789 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4775 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4790 | kw_loop: |
4776 | kw_loop: |
4791 | in al, 0x64 |
4777 | in al, 0x64 |
4792 | test al, 2 |
4778 | test al, 2 |
4793 | jz kw_ok |
4779 | jz kw_ok |
4794 | loop kw_loop |
4780 | loop kw_loop |
4795 | mov ah, 1 |
4781 | mov ah, 1 |
4796 | jmp kw_exit |
4782 | jmp kw_exit |
4797 | kw_ok: |
4783 | kw_ok: |
4798 | mov al, dl |
4784 | mov al, dl |
4799 | out 0x60, al |
4785 | out 0x60, al |
4800 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4786 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4801 | kw_loop3: |
4787 | kw_loop3: |
4802 | in al, 0x64 |
4788 | in al, 0x64 |
4803 | test al, 2 |
4789 | test al, 2 |
4804 | jz kw_ok3 |
4790 | jz kw_ok3 |
4805 | loop kw_loop3 |
4791 | loop kw_loop3 |
4806 | mov ah, 1 |
4792 | mov ah, 1 |
4807 | jmp kw_exit |
4793 | jmp kw_exit |
4808 | kw_ok3: |
4794 | kw_ok3: |
4809 | mov ah, 8 |
4795 | mov ah, 8 |
4810 | kw_loop4: |
4796 | kw_loop4: |
4811 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4797 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4812 | kw_loop5: |
4798 | kw_loop5: |
4813 | in al, 0x64 |
4799 | in al, 0x64 |
4814 | test al, 1 |
4800 | test al, 1 |
4815 | jnz kw_ok4 |
4801 | jnz kw_ok4 |
4816 | loop kw_loop5 |
4802 | loop kw_loop5 |
4817 | dec ah |
4803 | dec ah |
4818 | jnz kw_loop4 |
4804 | jnz kw_loop4 |
4819 | kw_ok4: |
4805 | kw_ok4: |
4820 | xor ah, ah |
4806 | xor ah, ah |
4821 | kw_exit: |
4807 | kw_exit: |
4822 | 4808 | ||
4823 | pop edx ecx |
4809 | pop edx ecx |
4824 | 4810 | ||
4825 | ret |
4811 | ret |
4826 | ;----------------------------------------------------------------------------- |
4812 | ;----------------------------------------------------------------------------- |
4827 | align 4 |
4813 | align 4 |
4828 | kb_cmd: |
4814 | kb_cmd: |
4829 | 4815 | ||
4830 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4816 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4831 | c_wait: |
4817 | c_wait: |
4832 | in al, 0x64 |
4818 | in al, 0x64 |
4833 | test al, 2 |
4819 | test al, 2 |
4834 | jz c_send |
4820 | jz c_send |
4835 | loop c_wait |
4821 | loop c_wait |
4836 | jmp c_error |
4822 | jmp c_error |
4837 | c_send: |
4823 | c_send: |
4838 | mov al, bl |
4824 | mov al, bl |
4839 | out 0x64, al |
4825 | out 0x64, al |
4840 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4826 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4841 | c_accept: |
4827 | c_accept: |
4842 | in al, 0x64 |
4828 | in al, 0x64 |
4843 | test al, 2 |
4829 | test al, 2 |
4844 | jz c_ok |
4830 | jz c_ok |
4845 | loop c_accept |
4831 | loop c_accept |
4846 | c_error: |
4832 | c_error: |
4847 | mov ah, 1 |
4833 | mov ah, 1 |
4848 | jmp c_exit |
4834 | jmp c_exit |
4849 | c_ok: |
4835 | c_ok: |
4850 | xor ah, ah |
4836 | xor ah, ah |
4851 | c_exit: |
4837 | c_exit: |
4852 | ret |
4838 | ret |
4853 | 4839 | ||
4854 | 4840 | ||
4855 | setmouse: ; set mousepicture -pointer |
4841 | setmouse: ; set mousepicture -pointer |
4856 | ; ps2 mouse enable |
4842 | ; ps2 mouse enable |
4857 | 4843 | ||
4858 | ; mov [MOUSE_PICTURE], dword mousepointer |
4844 | ; mov [MOUSE_PICTURE], dword mousepointer |
4859 | 4845 | ||
4860 | cli |
4846 | cli |
4861 | 4847 | ||
4862 | ret |
4848 | ret |
4863 | 4849 | ||
4864 | if used _rdtsc |
4850 | if used _rdtsc |
4865 | _rdtsc: |
4851 | _rdtsc: |
4866 | bt [cpu_caps], CAPS_TSC |
4852 | bt [cpu_caps], CAPS_TSC |
4867 | jnc ret_rdtsc |
4853 | jnc ret_rdtsc |
4868 | rdtsc |
4854 | rdtsc |
4869 | ret |
4855 | ret |
4870 | ret_rdtsc: |
4856 | ret_rdtsc: |
4871 | mov edx, 0xffffffff |
4857 | mov edx, 0xffffffff |
4872 | mov eax, 0xffffffff |
4858 | mov eax, 0xffffffff |
4873 | ret |
4859 | ret |
4874 | end if |
4860 | end if |
4875 | 4861 | ||
4876 | sys_msg_board_str: |
4862 | sys_msg_board_str: |
4877 | 4863 | ||
4878 | pushad |
4864 | pushad |
4879 | @@: |
4865 | @@: |
4880 | cmp [esi], byte 0 |
4866 | cmp [esi], byte 0 |
4881 | je @f |
4867 | je @f |
4882 | mov ebx, 1 |
4868 | mov ebx, 1 |
4883 | movzx ecx, byte [esi] |
4869 | movzx ecx, byte [esi] |
4884 | call sys_msg_board |
4870 | call sys_msg_board |
4885 | inc esi |
4871 | inc esi |
4886 | jmp @b |
4872 | jmp @b |
4887 | @@: |
4873 | @@: |
4888 | popad |
4874 | popad |
4889 | ret |
4875 | ret |
4890 | 4876 | ||
4891 | sys_msg_board_byte: |
4877 | sys_msg_board_byte: |
4892 | ; in: al = byte to display |
4878 | ; in: al = byte to display |
4893 | ; out: nothing |
4879 | ; out: nothing |
4894 | ; destroys: nothing |
4880 | ; destroys: nothing |
4895 | pushad |
4881 | pushad |
4896 | mov ecx, 2 |
4882 | mov ecx, 2 |
4897 | shl eax, 24 |
4883 | shl eax, 24 |
4898 | jmp @f |
4884 | jmp @f |
4899 | 4885 | ||
4900 | sys_msg_board_word: |
4886 | sys_msg_board_word: |
4901 | ; in: ax = word to display |
4887 | ; in: ax = word to display |
4902 | ; out: nothing |
4888 | ; out: nothing |
4903 | ; destroys: nothing |
4889 | ; destroys: nothing |
4904 | pushad |
4890 | pushad |
4905 | mov ecx, 4 |
4891 | mov ecx, 4 |
4906 | shl eax, 16 |
4892 | shl eax, 16 |
4907 | jmp @f |
4893 | jmp @f |
4908 | 4894 | ||
4909 | sys_msg_board_dword: |
4895 | sys_msg_board_dword: |
4910 | ; in: eax = dword to display |
4896 | ; in: eax = dword to display |
4911 | ; out: nothing |
4897 | ; out: nothing |
4912 | ; destroys: nothing |
4898 | ; destroys: nothing |
4913 | pushad |
4899 | pushad |
4914 | mov ecx, 8 |
4900 | mov ecx, 8 |
4915 | @@: |
4901 | @@: |
4916 | push ecx |
4902 | push ecx |
4917 | rol eax, 4 |
4903 | rol eax, 4 |
4918 | push eax |
4904 | push eax |
4919 | and al, 0xF |
4905 | and al, 0xF |
4920 | cmp al, 10 |
4906 | cmp al, 10 |
4921 | sbb al, 69h |
4907 | sbb al, 69h |
4922 | das |
4908 | das |
4923 | mov cl, al |
4909 | mov cl, al |
4924 | xor ebx, ebx |
4910 | xor ebx, ebx |
4925 | inc ebx |
4911 | inc ebx |
4926 | call sys_msg_board |
4912 | call sys_msg_board |
4927 | pop eax |
4913 | pop eax |
4928 | pop ecx |
4914 | pop ecx |
4929 | loop @b |
4915 | loop @b |
4930 | popad |
4916 | popad |
4931 | ret |
4917 | ret |
4932 | 4918 | ||
4933 | msg_board_data_size = 65536 ; Must be power of two |
4919 | msg_board_data_size = 65536 ; Must be power of two |
4934 | 4920 | ||
4935 | uglobal |
4921 | uglobal |
4936 | msg_board_data rb msg_board_data_size |
4922 | msg_board_data rb msg_board_data_size |
4937 | msg_board_count dd 0x0 |
4923 | msg_board_count dd 0x0 |
4938 | endg |
4924 | endg |
4939 | 4925 | ||
4940 | sys_msg_board: |
4926 | sys_msg_board: |
4941 | 4927 | ||
4942 | ; ebx=1 : write : bl byte to write |
4928 | ; ebx=1 : write : bl byte to write |
4943 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4929 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4944 | 4930 | ||
4945 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4931 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4946 | mov eax, ebx |
4932 | mov eax, ebx |
4947 | mov ebx, ecx |
4933 | mov ebx, ecx |
4948 | 4934 | ||
4949 | mov ecx, [msg_board_count] |
4935 | mov ecx, [msg_board_count] |
4950 | cmp eax, 1 |
4936 | cmp eax, 1 |
4951 | jne .smbl1 |
4937 | jne .smbl1 |
4952 | 4938 | ||
4953 | if defined debug_com_base |
4939 | if defined debug_com_base |
4954 | 4940 | ||
4955 | push dx ax |
4941 | push dx ax |
4956 | 4942 | ||
4957 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4943 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4958 | mov dx, debug_com_base+5 |
4944 | mov dx, debug_com_base+5 |
4959 | in al, dx |
4945 | in al, dx |
4960 | test al, 1 shl 5 |
4946 | test al, 1 shl 5 |
4961 | jz @r |
4947 | jz @r |
4962 | 4948 | ||
4963 | mov dx, debug_com_base ; Output the byte |
4949 | mov dx, debug_com_base ; Output the byte |
4964 | mov al, bl |
4950 | mov al, bl |
4965 | out dx, al |
4951 | out dx, al |
4966 | 4952 | ||
4967 | pop ax dx |
4953 | pop ax dx |
4968 | 4954 | ||
4969 | end if |
4955 | end if |
4970 | 4956 | ||
4971 | mov [msg_board_data+ecx], bl |
4957 | mov [msg_board_data+ecx], bl |
4972 | ; // if debug_direct_print == 1 |
4958 | ; // if debug_direct_print == 1 |
4973 | cmp byte [debug_direct_print], 1 |
4959 | cmp byte [debug_direct_print], 1 |
4974 | jnz @f |
4960 | jnz @f |
4975 | pusha |
4961 | pusha |
4976 | iglobal |
4962 | iglobal |
4977 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4963 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4978 | endg |
4964 | endg |
4979 | lea edx, [msg_board_data+ecx] |
4965 | lea edx, [msg_board_data+ecx] |
4980 | mov ecx, 0x40FFFFFF |
4966 | mov ecx, 0x40FFFFFF |
4981 | mov ebx, [msg_board_pos] |
4967 | mov ebx, [msg_board_pos] |
4982 | mov edi, 1 |
4968 | mov edi, 1 |
4983 | mov esi, 1 |
4969 | mov esi, 1 |
4984 | call dtext |
4970 | call dtext |
4985 | popa |
4971 | popa |
4986 | add word [msg_board_pos+2], 6 |
4972 | add word [msg_board_pos+2], 6 |
4987 | cmp bl, 10 |
4973 | cmp bl, 10 |
4988 | jnz @f |
4974 | jnz @f |
4989 | mov word [msg_board_pos+2], (42*6) |
4975 | mov word [msg_board_pos+2], (42*6) |
4990 | add word [msg_board_pos], 10 |
4976 | add word [msg_board_pos], 10 |
4991 | mov ax, word [Screen_Max_Y] |
4977 | mov ax, word [Screen_Max_Y] |
4992 | cmp word [msg_board_pos], ax |
4978 | cmp word [msg_board_pos], ax |
4993 | jbe @f |
4979 | jbe @f |
4994 | mov word [msg_board_pos], 10 |
4980 | mov word [msg_board_pos], 10 |
4995 | @@: |
4981 | @@: |
4996 | ; // end if |
4982 | ; // end if |
4997 | 4983 | ||
4998 | if 0 |
4984 | if 0 |
4999 | pusha |
4985 | pusha |
5000 | mov al, bl |
4986 | mov al, bl |
5001 | mov edx, 402h |
4987 | mov edx, 402h |
5002 | out dx, al |
4988 | out dx, al |
5003 | popa |
4989 | popa |
5004 | end if |
4990 | end if |
5005 | inc ecx |
4991 | inc ecx |
5006 | and ecx, msg_board_data_size - 1 |
4992 | and ecx, msg_board_data_size - 1 |
5007 | mov [msg_board_count], ecx |
4993 | mov [msg_board_count], ecx |
5008 | 4994 | ||
5009 | pop ebx eax |
4995 | pop ebx eax |
5010 | ret |
4996 | ret |
5011 | .smbl1: |
4997 | .smbl1: |
5012 | cmp eax, 2 |
4998 | cmp eax, 2 |
5013 | jne .smbl2 |
4999 | jne .smbl2 |
5014 | test ecx, ecx |
5000 | test ecx, ecx |
5015 | jz .smbl21 |
5001 | jz .smbl21 |
5016 | 5002 | ||
5017 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
5003 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
5018 | mov eax, msg_board_data+1 |
5004 | mov eax, msg_board_data+1 |
5019 | mov ebx, msg_board_data |
5005 | mov ebx, msg_board_data |
5020 | movzx edx, byte [ebx] |
5006 | movzx edx, byte [ebx] |
5021 | call memmove |
5007 | call memmove |
5022 | dec [msg_board_count] |
5008 | dec [msg_board_count] |
5023 | mov [esp + 32], edx ;eax |
5009 | mov [esp + 32], edx ;eax |
5024 | mov [esp + 20], dword 1 |
5010 | mov [esp + 20], dword 1 |
5025 | ret |
5011 | ret |
5026 | .smbl21: |
5012 | .smbl21: |
5027 | mov [esp+32], ecx |
5013 | mov [esp+32], ecx |
5028 | mov [esp+20], ecx |
5014 | mov [esp+20], ecx |
5029 | .smbl2: |
5015 | .smbl2: |
5030 | pop ebx eax |
5016 | pop ebx eax |
5031 | ret |
5017 | ret |
5032 | 5018 | ||
5033 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5019 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5034 | ;; 66 sys function. ;; |
5020 | ;; 66 sys function. ;; |
5035 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
5021 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
5036 | ;; out eax ;; |
5022 | ;; out eax ;; |
5037 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5023 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5038 | iglobal |
5024 | iglobal |
5039 | align 4 |
5025 | align 4 |
5040 | f66call: |
5026 | f66call: |
5041 | dd sys_process_def.1 ; 1 = set keyboard mode |
5027 | dd sys_process_def.1 ; 1 = set keyboard mode |
5042 | dd sys_process_def.2 ; 2 = get keyboard mode |
5028 | dd sys_process_def.2 ; 2 = get keyboard mode |
5043 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
5029 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
5044 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
5030 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
5045 | dd sys_process_def.5 ; 5 = delete installed hotkey |
5031 | dd sys_process_def.5 ; 5 = delete installed hotkey |
5046 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
5032 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
5047 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
5033 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
5048 | endg |
5034 | endg |
5049 | ;----------------------------------------------------------------------------- |
5035 | ;----------------------------------------------------------------------------- |
5050 | align 4 |
5036 | align 4 |
5051 | sys_process_def: |
5037 | sys_process_def: |
5052 | dec ebx |
5038 | dec ebx |
5053 | cmp ebx, 7 |
5039 | cmp ebx, 7 |
5054 | jae .not_support ;if >=8 then or eax,-1 |
5040 | jae .not_support ;if >=8 then or eax,-1 |
5055 | 5041 | ||
5056 | mov edi, [CURRENT_TASK] |
5042 | mov edi, [CURRENT_TASK] |
5057 | jmp dword [f66call+ebx*4] |
5043 | jmp dword [f66call+ebx*4] |
5058 | 5044 | ||
5059 | .not_support: |
5045 | .not_support: |
5060 | or eax, -1 |
5046 | or eax, -1 |
5061 | ret |
5047 | ret |
5062 | ;----------------------------------------------------------------------------- |
5048 | ;----------------------------------------------------------------------------- |
5063 | align 4 |
5049 | align 4 |
5064 | .1: |
5050 | .1: |
5065 | shl edi, 8 |
5051 | shl edi, 8 |
5066 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
5052 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
5067 | 5053 | ||
5068 | ret |
5054 | ret |
5069 | ;----------------------------------------------------------------------------- |
5055 | ;----------------------------------------------------------------------------- |
5070 | align 4 |
5056 | align 4 |
5071 | .2: ; 2 = get keyboard mode |
5057 | .2: ; 2 = get keyboard mode |
5072 | shl edi, 8 |
5058 | shl edi, 8 |
5073 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
5059 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
5074 | mov [esp+32], eax |
5060 | mov [esp+32], eax |
5075 | ret |
5061 | ret |
5076 | ;----------------------------------------------------------------------------- |
5062 | ;----------------------------------------------------------------------------- |
5077 | align 4 |
5063 | align 4 |
5078 | .3: ;3 = get keyboard ctrl, alt, shift |
5064 | .3: ;3 = get keyboard ctrl, alt, shift |
5079 | mov eax, [kb_state] |
5065 | mov eax, [kb_state] |
5080 | mov [esp+32], eax |
5066 | mov [esp+32], eax |
5081 | ret |
5067 | ret |
5082 | ;----------------------------------------------------------------------------- |
5068 | ;----------------------------------------------------------------------------- |
5083 | align 4 |
5069 | align 4 |
5084 | .4: |
5070 | .4: |
5085 | mov eax, hotkey_list |
5071 | mov eax, hotkey_list |
5086 | @@: |
5072 | @@: |
5087 | cmp dword [eax+8], 0 |
5073 | cmp dword [eax+8], 0 |
5088 | jz .found_free |
5074 | jz .found_free |
5089 | add eax, 16 |
5075 | add eax, 16 |
5090 | cmp eax, hotkey_list+16*256 |
5076 | cmp eax, hotkey_list+16*256 |
5091 | jb @b |
5077 | jb @b |
5092 | mov dword [esp+32], 1 |
5078 | mov dword [esp+32], 1 |
5093 | ret |
5079 | ret |
5094 | .found_free: |
5080 | .found_free: |
5095 | mov [eax+8], edi |
5081 | mov [eax+8], edi |
5096 | mov [eax+4], edx |
5082 | mov [eax+4], edx |
5097 | movzx ecx, cl |
5083 | movzx ecx, cl |
5098 | lea ecx, [hotkey_scancodes+ecx*4] |
5084 | lea ecx, [hotkey_scancodes+ecx*4] |
5099 | mov edx, [ecx] |
5085 | mov edx, [ecx] |
5100 | mov [eax], edx |
5086 | mov [eax], edx |
5101 | mov [ecx], eax |
5087 | mov [ecx], eax |
5102 | mov [eax+12], ecx |
5088 | mov [eax+12], ecx |
5103 | test edx, edx |
5089 | test edx, edx |
5104 | jz @f |
5090 | jz @f |
5105 | mov [edx+12], eax |
5091 | mov [edx+12], eax |
5106 | @@: |
5092 | @@: |
5107 | and dword [esp+32], 0 |
5093 | and dword [esp+32], 0 |
5108 | ret |
5094 | ret |
5109 | ;----------------------------------------------------------------------------- |
5095 | ;----------------------------------------------------------------------------- |
5110 | align 4 |
5096 | align 4 |
5111 | .5: |
5097 | .5: |
5112 | movzx ebx, cl |
5098 | movzx ebx, cl |
5113 | lea ebx, [hotkey_scancodes+ebx*4] |
5099 | lea ebx, [hotkey_scancodes+ebx*4] |
5114 | mov eax, [ebx] |
5100 | mov eax, [ebx] |
5115 | .scan: |
5101 | .scan: |
5116 | test eax, eax |
5102 | test eax, eax |
5117 | jz .notfound |
5103 | jz .notfound |
5118 | cmp [eax+8], edi |
5104 | cmp [eax+8], edi |
5119 | jnz .next |
5105 | jnz .next |
5120 | cmp [eax+4], edx |
5106 | cmp [eax+4], edx |
5121 | jz .found |
5107 | jz .found |
5122 | .next: |
5108 | .next: |
5123 | mov eax, [eax] |
5109 | mov eax, [eax] |
5124 | jmp .scan |
5110 | jmp .scan |
5125 | .notfound: |
5111 | .notfound: |
5126 | mov dword [esp+32], 1 |
5112 | mov dword [esp+32], 1 |
5127 | ret |
5113 | ret |
5128 | .found: |
5114 | .found: |
5129 | mov ecx, [eax] |
5115 | mov ecx, [eax] |
5130 | jecxz @f |
5116 | jecxz @f |
5131 | mov edx, [eax+12] |
5117 | mov edx, [eax+12] |
5132 | mov [ecx+12], edx |
5118 | mov [ecx+12], edx |
5133 | @@: |
5119 | @@: |
5134 | mov ecx, [eax+12] |
5120 | mov ecx, [eax+12] |
5135 | mov edx, [eax] |
5121 | mov edx, [eax] |
5136 | mov [ecx], edx |
5122 | mov [ecx], edx |
5137 | xor edx, edx |
5123 | xor edx, edx |
5138 | mov [eax+4], edx |
5124 | mov [eax+4], edx |
5139 | mov [eax+8], edx |
5125 | mov [eax+8], edx |
5140 | mov [eax+12], edx |
5126 | mov [eax+12], edx |
5141 | mov [eax], edx |
5127 | mov [eax], edx |
5142 | mov [esp+32], edx |
5128 | mov [esp+32], edx |
5143 | ret |
5129 | ret |
5144 | ;----------------------------------------------------------------------------- |
5130 | ;----------------------------------------------------------------------------- |
5145 | align 4 |
5131 | align 4 |
5146 | .6: |
5132 | .6: |
5147 | pushfd |
5133 | pushfd |
5148 | cli |
5134 | cli |
5149 | mov eax, [PID_lock_input] |
5135 | mov eax, [PID_lock_input] |
5150 | test eax, eax |
5136 | test eax, eax |
5151 | jnz @f |
5137 | jnz @f |
5152 | ; get current PID |
5138 | ; get current PID |
5153 | mov eax, [CURRENT_TASK] |
5139 | mov eax, [CURRENT_TASK] |
5154 | shl eax, 5 |
5140 | shl eax, 5 |
5155 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5141 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5156 | ; set current PID for lock input |
5142 | ; set current PID for lock input |
5157 | mov [PID_lock_input], eax |
5143 | mov [PID_lock_input], eax |
5158 | @@: |
5144 | @@: |
5159 | popfd |
5145 | popfd |
5160 | ret |
5146 | ret |
5161 | ;----------------------------------------------------------------------------- |
5147 | ;----------------------------------------------------------------------------- |
5162 | align 4 |
5148 | align 4 |
5163 | .7: |
5149 | .7: |
5164 | mov eax, [PID_lock_input] |
5150 | mov eax, [PID_lock_input] |
5165 | test eax, eax |
5151 | test eax, eax |
5166 | jz @f |
5152 | jz @f |
5167 | ; get current PID |
5153 | ; get current PID |
5168 | mov ebx, [CURRENT_TASK] |
5154 | mov ebx, [CURRENT_TASK] |
5169 | shl ebx, 5 |
5155 | shl ebx, 5 |
5170 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5156 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5171 | ; compare current lock input with current PID |
5157 | ; compare current lock input with current PID |
5172 | cmp ebx, eax |
5158 | cmp ebx, eax |
5173 | jne @f |
5159 | jne @f |
5174 | 5160 | ||
5175 | xor eax, eax |
5161 | xor eax, eax |
5176 | mov [PID_lock_input], eax |
5162 | mov [PID_lock_input], eax |
5177 | @@: |
5163 | @@: |
5178 | ret |
5164 | ret |
5179 | ;----------------------------------------------------------------------------- |
5165 | ;----------------------------------------------------------------------------- |
5180 | uglobal |
5166 | uglobal |
5181 | PID_lock_input dd 0x0 |
5167 | PID_lock_input dd 0x0 |
5182 | endg |
5168 | endg |
5183 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5169 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5184 | ;; 61 sys function. ;; |
5170 | ;; 61 sys function. ;; |
5185 | ;; in eax=61,ebx in [1..3] ;; |
5171 | ;; in eax=61,ebx in [1..3] ;; |
5186 | ;; out eax ;; |
5172 | ;; out eax ;; |
5187 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5173 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5188 | iglobal |
5174 | iglobal |
5189 | align 4 |
5175 | align 4 |
5190 | f61call: |
5176 | f61call: |
5191 | dd sys_gs.1 ; resolution |
5177 | dd sys_gs.1 ; resolution |
5192 | dd sys_gs.2 ; bits per pixel |
5178 | dd sys_gs.2 ; bits per pixel |
5193 | dd sys_gs.3 ; bytes per scanline |
5179 | dd sys_gs.3 ; bytes per scanline |
5194 | endg |
5180 | endg |
5195 | 5181 | ||
5196 | 5182 | ||
5197 | align 4 |
5183 | align 4 |
5198 | 5184 | ||
5199 | sys_gs: ; direct screen access |
5185 | sys_gs: ; direct screen access |
5200 | dec ebx |
5186 | dec ebx |
5201 | cmp ebx, 2 |
5187 | cmp ebx, 2 |
5202 | ja .not_support |
5188 | ja .not_support |
5203 | jmp dword [f61call+ebx*4] |
5189 | jmp dword [f61call+ebx*4] |
5204 | .not_support: |
5190 | .not_support: |
5205 | or [esp+32], dword -1 |
5191 | or [esp+32], dword -1 |
5206 | ret |
5192 | ret |
5207 | 5193 | ||
5208 | 5194 | ||
5209 | .1: ; resolution |
5195 | .1: ; resolution |
5210 | mov eax, [Screen_Max_X] |
5196 | mov eax, [Screen_Max_X] |
5211 | shl eax, 16 |
5197 | shl eax, 16 |
5212 | mov ax, word [Screen_Max_Y] |
5198 | mov ax, word [Screen_Max_Y] |
5213 | add eax, 0x00010001 |
5199 | add eax, 0x00010001 |
5214 | mov [esp+32], eax |
5200 | mov [esp+32], eax |
5215 | ret |
5201 | ret |
5216 | .2: ; bits per pixel |
5202 | .2: ; bits per pixel |
5217 | mov eax, [_display.bpp] |
5203 | mov eax, [_display.bpp] |
5218 | mov [esp+32], eax |
5204 | mov [esp+32], eax |
5219 | ret |
5205 | ret |
5220 | .3: ; bytes per scanline |
5206 | .3: ; bytes per scanline |
5221 | mov eax, [_display.pitch] |
5207 | mov eax, [_display.pitch] |
5222 | mov [esp+32], eax |
5208 | mov [esp+32], eax |
5223 | ret |
5209 | ret |
5224 | 5210 | ||
5225 | align 4 ; system functions |
5211 | align 4 ; system functions |
5226 | 5212 | ||
5227 | syscall_setpixel: ; SetPixel |
5213 | syscall_setpixel: ; SetPixel |
5228 | 5214 | ||
5229 | mov eax, ebx |
5215 | mov eax, ebx |
5230 | mov ebx, ecx |
5216 | mov ebx, ecx |
5231 | mov ecx, edx |
5217 | mov ecx, edx |
5232 | mov edx, [TASK_BASE] |
5218 | mov edx, [TASK_BASE] |
5233 | add eax, [edx-twdw+WDATA.box.left] |
5219 | add eax, [edx-twdw+WDATA.box.left] |
5234 | add ebx, [edx-twdw+WDATA.box.top] |
5220 | add ebx, [edx-twdw+WDATA.box.top] |
5235 | mov edi, [current_slot] |
5221 | mov edi, [current_slot] |
5236 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5222 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5237 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5223 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5238 | xor edi, edi ; no force |
5224 | xor edi, edi ; no force |
5239 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5225 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5240 | ; jmp [putpixel] |
5226 | ; jmp [putpixel] |
5241 | jmp __sys_putpixel |
5227 | jmp __sys_putpixel |
5242 | 5228 | ||
5243 | align 4 |
5229 | align 4 |
5244 | 5230 | ||
5245 | syscall_writetext: ; WriteText |
5231 | syscall_writetext: ; WriteText |
5246 | 5232 | ||
5247 | mov eax, [TASK_BASE] |
5233 | mov eax, [TASK_BASE] |
5248 | mov ebp, [eax-twdw+WDATA.box.left] |
5234 | mov ebp, [eax-twdw+WDATA.box.left] |
5249 | push esi |
5235 | push esi |
5250 | mov esi, [current_slot] |
5236 | mov esi, [current_slot] |
5251 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5237 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5252 | shl ebp, 16 |
5238 | shl ebp, 16 |
5253 | add ebp, [eax-twdw+WDATA.box.top] |
5239 | add ebp, [eax-twdw+WDATA.box.top] |
5254 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5240 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5255 | pop esi |
5241 | pop esi |
5256 | test ecx, 0x08000000 ; redirect the output to the user area |
5242 | test ecx, 0x08000000 ; redirect the output to the user area |
5257 | jnz @f |
5243 | jnz @f |
5258 | add ebx, ebp |
5244 | add ebx, ebp |
5259 | align 4 |
5245 | align 4 |
5260 | @@: |
5246 | @@: |
5261 | mov eax, edi |
5247 | mov eax, edi |
5262 | test ecx, 0x08000000 ; redirect the output to the user area |
5248 | test ecx, 0x08000000 ; redirect the output to the user area |
5263 | jnz dtext |
5249 | jnz dtext |
5264 | xor edi, edi |
5250 | xor edi, edi |
5265 | jmp dtext |
5251 | jmp dtext |
5266 | 5252 | ||
5267 | align 4 |
5253 | align 4 |
5268 | - | ||
5269 | syscall_openramdiskfile: ; OpenRamdiskFile |
- | |
5270 | - | ||
5271 | mov eax, ebx |
- | |
5272 | mov ebx, ecx |
- | |
5273 | mov ecx, edx |
- | |
5274 | mov edx, esi |
- | |
5275 | mov esi, 12 |
- | |
5276 | call fileread |
- | |
5277 | mov [esp+32], eax |
- | |
5278 | ret |
- | |
5279 | - | ||
5280 | align 4 |
- | |
5281 | 5254 | ||
5282 | syscall_drawrect: ; DrawRect |
5255 | syscall_drawrect: ; DrawRect |
5283 | 5256 | ||
5284 | mov edi, edx ; color + gradient |
5257 | mov edi, edx ; color + gradient |
5285 | and edi, 0x80FFFFFF |
5258 | and edi, 0x80FFFFFF |
5286 | test bx, bx ; x.size |
5259 | test bx, bx ; x.size |
5287 | je .drectr |
5260 | je .drectr |
5288 | test cx, cx ; y.size |
5261 | test cx, cx ; y.size |
5289 | je .drectr |
5262 | je .drectr |
5290 | 5263 | ||
5291 | mov eax, ebx ; bad idea |
5264 | mov eax, ebx ; bad idea |
5292 | mov ebx, ecx |
5265 | mov ebx, ecx |
5293 | 5266 | ||
5294 | movzx ecx, ax ; ecx - x.size |
5267 | movzx ecx, ax ; ecx - x.size |
5295 | shr eax, 16 ; eax - x.coord |
5268 | shr eax, 16 ; eax - x.coord |
5296 | movzx edx, bx ; edx - y.size |
5269 | movzx edx, bx ; edx - y.size |
5297 | shr ebx, 16 ; ebx - y.coord |
5270 | shr ebx, 16 ; ebx - y.coord |
5298 | mov esi, [current_slot] |
5271 | mov esi, [current_slot] |
5299 | 5272 | ||
5300 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5273 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5301 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5274 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5302 | add ecx, eax |
5275 | add ecx, eax |
5303 | add edx, ebx |
5276 | add edx, ebx |
5304 | ; jmp [drawbar] |
5277 | ; jmp [drawbar] |
5305 | jmp vesa20_drawbar |
5278 | jmp vesa20_drawbar |
5306 | .drectr: |
5279 | .drectr: |
5307 | ret |
5280 | ret |
5308 | 5281 | ||
5309 | align 4 |
5282 | align 4 |
5310 | syscall_getscreensize: ; GetScreenSize |
5283 | syscall_getscreensize: ; GetScreenSize |
5311 | mov ax, word [Screen_Max_X] |
5284 | mov ax, word [Screen_Max_X] |
5312 | shl eax, 16 |
5285 | shl eax, 16 |
5313 | mov ax, word [Screen_Max_Y] |
5286 | mov ax, word [Screen_Max_Y] |
5314 | mov [esp + 32], eax |
5287 | mov [esp + 32], eax |
5315 | ret |
5288 | ret |
5316 | 5289 | ||
5317 | align 4 |
5290 | align 4 |
5318 | 5291 | ||
5319 | syscall_cdaudio: ; CD |
5292 | syscall_cdaudio: ; CD |
5320 | 5293 | ||
5321 | cmp ebx, 4 |
5294 | cmp ebx, 4 |
5322 | jb .audio |
5295 | jb .audio |
5323 | jz .eject |
5296 | jz .eject |
5324 | cmp ebx, 5 |
5297 | cmp ebx, 5 |
5325 | jnz .ret |
5298 | jnz .ret |
5326 | .load: |
5299 | .load: |
5327 | call .reserve |
5300 | call .reserve |
5328 | call LoadMedium |
5301 | call LoadMedium |
5329 | ;call .free |
5302 | ;call .free |
5330 | jmp .free |
5303 | jmp .free |
5331 | ; ret |
5304 | ; ret |
5332 | .eject: |
5305 | .eject: |
5333 | call .reserve |
5306 | call .reserve |
5334 | call clear_CD_cache |
5307 | call clear_CD_cache |
5335 | call allow_medium_removal |
5308 | call allow_medium_removal |
5336 | call EjectMedium |
5309 | call EjectMedium |
5337 | ; call .free |
5310 | ; call .free |
5338 | jmp .free |
5311 | jmp .free |
5339 | ; ret |
5312 | ; ret |
5340 | .audio: |
5313 | .audio: |
5341 | call sys_cd_audio |
5314 | call sys_cd_audio |
5342 | mov [esp+36-4], eax |
5315 | mov [esp+36-4], eax |
5343 | .ret: |
5316 | .ret: |
5344 | ret |
5317 | ret |
5345 | 5318 | ||
5346 | .reserve: |
5319 | .reserve: |
5347 | call reserve_cd |
5320 | call reserve_cd |
5348 | mov eax, ecx |
5321 | mov eax, ecx |
5349 | shr eax, 1 |
5322 | shr eax, 1 |
5350 | and eax, 1 |
5323 | and eax, 1 |
5351 | inc eax |
5324 | inc eax |
5352 | mov [ChannelNumber], ax |
5325 | mov [ChannelNumber], ax |
5353 | mov eax, ecx |
5326 | mov eax, ecx |
5354 | and eax, 1 |
5327 | and eax, 1 |
5355 | mov [DiskNumber], al |
5328 | mov [DiskNumber], al |
5356 | call reserve_cd_channel |
5329 | call reserve_cd_channel |
5357 | and ebx, 3 |
5330 | and ebx, 3 |
5358 | inc ebx |
5331 | inc ebx |
5359 | mov [cdpos], ebx |
5332 | mov [cdpos], ebx |
5360 | add ebx, ebx |
5333 | add ebx, ebx |
5361 | mov cl, 8 |
5334 | mov cl, 8 |
5362 | sub cl, bl |
5335 | sub cl, bl |
5363 | mov al, [DRIVE_DATA+1] |
5336 | mov al, [DRIVE_DATA+1] |
5364 | shr al, cl |
5337 | shr al, cl |
5365 | test al, 2 |
5338 | test al, 2 |
5366 | jz .free;.err |
5339 | jz .free;.err |
5367 | ret |
5340 | ret |
5368 | .free: |
5341 | .free: |
5369 | call free_cd_channel |
5342 | call free_cd_channel |
5370 | and [cd_status], 0 |
5343 | and [cd_status], 0 |
5371 | ret |
5344 | ret |
5372 | .err: |
5345 | .err: |
5373 | call .free |
5346 | call .free |
5374 | ; pop eax |
5347 | ; pop eax |
5375 | ret |
5348 | ret |
5376 | ;----------------------------------------------------------------------------- |
5349 | ;----------------------------------------------------------------------------- |
5377 | align 4 |
5350 | align 4 |
5378 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5351 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5379 | cmp ebx, [Screen_Max_X] |
5352 | cmp ebx, [Screen_Max_X] |
5380 | jbe @f |
5353 | jbe @f |
5381 | cmp ecx, [Screen_Max_Y] |
5354 | cmp ecx, [Screen_Max_Y] |
5382 | jbe @f |
5355 | jbe @f |
5383 | xor eax, eax |
5356 | xor eax, eax |
5384 | jmp .store |
5357 | jmp .store |
5385 | ;-------------------------------------- |
5358 | ;-------------------------------------- |
5386 | align 4 |
5359 | align 4 |
5387 | @@: |
5360 | @@: |
5388 | mov eax, [d_width_calc_area + ecx*4] |
5361 | mov eax, [d_width_calc_area + ecx*4] |
5389 | add eax, [_WinMapAddress] |
5362 | add eax, [_WinMapAddress] |
5390 | movzx eax, byte[eax+ebx] ; get value for current point |
5363 | movzx eax, byte[eax+ebx] ; get value for current point |
5391 | ;-------------------------------------- |
5364 | ;-------------------------------------- |
5392 | align 4 |
5365 | align 4 |
5393 | .store: |
5366 | .store: |
5394 | mov [esp + 32], eax |
5367 | mov [esp + 32], eax |
5395 | ret |
5368 | ret |
5396 | ;----------------------------------------------------------------------------- |
5369 | ;----------------------------------------------------------------------------- |
5397 | align 4 |
5370 | align 4 |
5398 | syscall_getpixel: ; GetPixel |
5371 | syscall_getpixel: ; GetPixel |
5399 | mov ecx, [Screen_Max_X] |
5372 | mov ecx, [Screen_Max_X] |
5400 | inc ecx |
5373 | inc ecx |
5401 | xor edx, edx |
5374 | xor edx, edx |
5402 | mov eax, ebx |
5375 | mov eax, ebx |
5403 | div ecx |
5376 | div ecx |
5404 | mov ebx, edx |
5377 | mov ebx, edx |
5405 | xchg eax, ebx |
5378 | xchg eax, ebx |
5406 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5379 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5407 | call dword [GETPIXEL]; eax - x, ebx - y |
5380 | call dword [GETPIXEL]; eax - x, ebx - y |
5408 | mov [esp + 32], ecx |
5381 | mov [esp + 32], ecx |
5409 | ret |
5382 | ret |
5410 | ;----------------------------------------------------------------------------- |
5383 | ;----------------------------------------------------------------------------- |
5411 | align 4 |
5384 | align 4 |
5412 | syscall_getarea: |
5385 | syscall_getarea: |
5413 | ;eax = 36 |
5386 | ;eax = 36 |
5414 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5387 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5415 | ;ecx = [size x]*65536 + [size y] |
5388 | ;ecx = [size x]*65536 + [size y] |
5416 | ;edx = [start x]*65536 + [start y] |
5389 | ;edx = [start x]*65536 + [start y] |
5417 | pushad |
5390 | pushad |
5418 | mov edi, ebx |
5391 | mov edi, ebx |
5419 | mov eax, edx |
5392 | mov eax, edx |
5420 | shr eax, 16 |
5393 | shr eax, 16 |
5421 | mov ebx, edx |
5394 | mov ebx, edx |
5422 | and ebx, 0xffff |
5395 | and ebx, 0xffff |
5423 | dec eax |
5396 | dec eax |
5424 | dec ebx |
5397 | dec ebx |
5425 | ; eax - x, ebx - y |
5398 | ; eax - x, ebx - y |
5426 | mov edx, ecx |
5399 | mov edx, ecx |
5427 | 5400 | ||
5428 | shr ecx, 16 |
5401 | shr ecx, 16 |
5429 | and edx, 0xffff |
5402 | and edx, 0xffff |
5430 | mov esi, ecx |
5403 | mov esi, ecx |
5431 | ; ecx - size x, edx - size y |
5404 | ; ecx - size x, edx - size y |
5432 | 5405 | ||
5433 | mov ebp, edx |
5406 | mov ebp, edx |
5434 | dec ebp |
5407 | dec ebp |
5435 | lea ebp, [ebp*3] |
5408 | lea ebp, [ebp*3] |
5436 | 5409 | ||
5437 | imul ebp, esi |
5410 | imul ebp, esi |
5438 | 5411 | ||
5439 | mov esi, ecx |
5412 | mov esi, ecx |
5440 | dec esi |
5413 | dec esi |
5441 | lea esi, [esi*3] |
5414 | lea esi, [esi*3] |
5442 | 5415 | ||
5443 | add ebp, esi |
5416 | add ebp, esi |
5444 | add ebp, edi |
5417 | add ebp, edi |
5445 | 5418 | ||
5446 | add ebx, edx |
5419 | add ebx, edx |
5447 | ;-------------------------------------- |
5420 | ;-------------------------------------- |
5448 | align 4 |
5421 | align 4 |
5449 | .start_y: |
5422 | .start_y: |
5450 | push ecx edx |
5423 | push ecx edx |
5451 | ;-------------------------------------- |
5424 | ;-------------------------------------- |
5452 | align 4 |
5425 | align 4 |
5453 | .start_x: |
5426 | .start_x: |
5454 | push eax ebx ecx |
5427 | push eax ebx ecx |
5455 | add eax, ecx |
5428 | add eax, ecx |
5456 | 5429 | ||
5457 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5430 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5458 | call dword [GETPIXEL]; eax - x, ebx - y |
5431 | call dword [GETPIXEL]; eax - x, ebx - y |
5459 | 5432 | ||
5460 | mov [ebp], cx |
5433 | mov [ebp], cx |
5461 | shr ecx, 16 |
5434 | shr ecx, 16 |
5462 | mov [ebp+2], cl |
5435 | mov [ebp+2], cl |
5463 | 5436 | ||
5464 | pop ecx ebx eax |
5437 | pop ecx ebx eax |
5465 | sub ebp, 3 |
5438 | sub ebp, 3 |
5466 | dec ecx |
5439 | dec ecx |
5467 | jnz .start_x |
5440 | jnz .start_x |
5468 | pop edx ecx |
5441 | pop edx ecx |
5469 | dec ebx |
5442 | dec ebx |
5470 | dec edx |
5443 | dec edx |
5471 | jnz .start_y |
5444 | jnz .start_y |
5472 | popad |
5445 | popad |
5473 | ret |
5446 | ret |
5474 | ;----------------------------------------------------------------------------- |
5447 | ;----------------------------------------------------------------------------- |
5475 | align 4 |
5448 | align 4 |
5476 | syscall_putarea_backgr: |
5449 | syscall_putarea_backgr: |
5477 | ;eax = 25 |
5450 | ;eax = 25 |
5478 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5451 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5479 | ;ecx = [size x]*65536 + [size y] |
5452 | ;ecx = [size x]*65536 + [size y] |
5480 | ;edx = [start x]*65536 + [start y] |
5453 | ;edx = [start x]*65536 + [start y] |
5481 | pushad |
5454 | pushad |
5482 | mov edi, ebx |
5455 | mov edi, ebx |
5483 | mov eax, edx |
5456 | mov eax, edx |
5484 | shr eax, 16 |
5457 | shr eax, 16 |
5485 | mov ebx, edx |
5458 | mov ebx, edx |
5486 | and ebx, 0xffff |
5459 | and ebx, 0xffff |
5487 | dec eax |
5460 | dec eax |
5488 | dec ebx |
5461 | dec ebx |
5489 | ; eax - x, ebx - y |
5462 | ; eax - x, ebx - y |
5490 | mov edx, ecx |
5463 | mov edx, ecx |
5491 | shr ecx, 16 |
5464 | shr ecx, 16 |
5492 | and edx, 0xffff |
5465 | and edx, 0xffff |
5493 | mov esi, ecx |
5466 | mov esi, ecx |
5494 | ; ecx - size x, edx - size y |
5467 | ; ecx - size x, edx - size y |
5495 | mov ebp, edx |
5468 | mov ebp, edx |
5496 | dec ebp |
5469 | dec ebp |
5497 | shl ebp, 2 |
5470 | shl ebp, 2 |
5498 | 5471 | ||
5499 | imul ebp, esi |
5472 | imul ebp, esi |
5500 | 5473 | ||
5501 | mov esi, ecx |
5474 | mov esi, ecx |
5502 | dec esi |
5475 | dec esi |
5503 | shl esi, 2 |
5476 | shl esi, 2 |
5504 | 5477 | ||
5505 | add ebp, esi |
5478 | add ebp, esi |
5506 | add ebp, edi |
5479 | add ebp, edi |
5507 | 5480 | ||
5508 | add ebx, edx |
5481 | add ebx, edx |
5509 | ;-------------------------------------- |
5482 | ;-------------------------------------- |
5510 | align 4 |
5483 | align 4 |
5511 | .start_y: |
5484 | .start_y: |
5512 | push ecx edx |
5485 | push ecx edx |
5513 | ;-------------------------------------- |
5486 | ;-------------------------------------- |
5514 | align 4 |
5487 | align 4 |
5515 | .start_x: |
5488 | .start_x: |
5516 | push eax ecx |
5489 | push eax ecx |
5517 | add eax, ecx |
5490 | add eax, ecx |
5518 | 5491 | ||
5519 | mov ecx, [ebp] |
5492 | mov ecx, [ebp] |
5520 | rol ecx, 8 |
5493 | rol ecx, 8 |
5521 | test cl, cl ; transparensy = 0 |
5494 | test cl, cl ; transparensy = 0 |
5522 | jz .no_put |
5495 | jz .no_put |
5523 | 5496 | ||
5524 | xor cl, cl |
5497 | xor cl, cl |
5525 | ror ecx, 8 |
5498 | ror ecx, 8 |
5526 | 5499 | ||
5527 | pushad |
5500 | pushad |
5528 | mov edx, [d_width_calc_area + ebx*4] |
5501 | mov edx, [d_width_calc_area + ebx*4] |
5529 | add edx, [_WinMapAddress] |
5502 | add edx, [_WinMapAddress] |
5530 | movzx edx, byte [eax+edx] |
5503 | movzx edx, byte [eax+edx] |
5531 | cmp dl, byte 1 |
5504 | cmp dl, byte 1 |
5532 | jne @f |
5505 | jne @f |
5533 | 5506 | ||
5534 | call dword [PUTPIXEL]; eax - x, ebx - y |
5507 | call dword [PUTPIXEL]; eax - x, ebx - y |
5535 | ;-------------------------------------- |
5508 | ;-------------------------------------- |
5536 | align 4 |
5509 | align 4 |
5537 | @@: |
5510 | @@: |
5538 | popad |
5511 | popad |
5539 | ;-------------------------------------- |
5512 | ;-------------------------------------- |
5540 | align 4 |
5513 | align 4 |
5541 | .no_put: |
5514 | .no_put: |
5542 | pop ecx eax |
5515 | pop ecx eax |
5543 | 5516 | ||
5544 | sub ebp, 4 |
5517 | sub ebp, 4 |
5545 | dec ecx |
5518 | dec ecx |
5546 | jnz .start_x |
5519 | jnz .start_x |
5547 | 5520 | ||
5548 | pop edx ecx |
5521 | pop edx ecx |
5549 | dec ebx |
5522 | dec ebx |
5550 | dec edx |
5523 | dec edx |
5551 | jnz .start_y |
5524 | jnz .start_y |
5552 | 5525 | ||
5553 | popad |
5526 | popad |
5554 | ret |
5527 | ret |
5555 | ;----------------------------------------------------------------------------- |
5528 | ;----------------------------------------------------------------------------- |
5556 | align 4 |
5529 | align 4 |
5557 | syscall_drawline: ; DrawLine |
5530 | syscall_drawline: ; DrawLine |
5558 | 5531 | ||
5559 | mov edi, [TASK_BASE] |
5532 | mov edi, [TASK_BASE] |
5560 | movzx eax, word[edi-twdw+WDATA.box.left] |
5533 | movzx eax, word[edi-twdw+WDATA.box.left] |
5561 | mov ebp, eax |
5534 | mov ebp, eax |
5562 | mov esi, [current_slot] |
5535 | mov esi, [current_slot] |
5563 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5536 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5564 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5537 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5565 | add ebp, ebx |
5538 | add ebp, ebx |
5566 | shl eax, 16 |
5539 | shl eax, 16 |
5567 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5540 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5568 | add eax, ebp |
5541 | add eax, ebp |
5569 | mov ebp, ebx |
5542 | mov ebp, ebx |
5570 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5543 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5571 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5544 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5572 | add ebp, ecx |
5545 | add ebp, ecx |
5573 | shl ebx, 16 |
5546 | shl ebx, 16 |
5574 | xor edi, edi |
5547 | xor edi, edi |
5575 | add ebx, ebp |
5548 | add ebx, ebp |
5576 | mov ecx, edx |
5549 | mov ecx, edx |
5577 | ; jmp [draw_line] |
5550 | ; jmp [draw_line] |
5578 | jmp __sys_draw_line |
5551 | jmp __sys_draw_line |
5579 | 5552 | ||
5580 | 5553 | ||
5581 | align 4 |
5554 | align 4 |
5582 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5555 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5583 | 5556 | ||
5584 | call r_f_port_area |
5557 | call r_f_port_area |
5585 | mov [esp+32], eax |
5558 | mov [esp+32], eax |
5586 | ret |
5559 | ret |
5587 | 5560 | ||
5588 | align 4 |
5561 | align 4 |
5589 | syscall_threads: ; CreateThreads |
5562 | syscall_threads: ; CreateThreads |
5590 | ; |
5563 | ; |
5591 | ; ecx=thread entry point |
5564 | ; ecx=thread entry point |
5592 | ; edx=thread stack pointer |
5565 | ; edx=thread stack pointer |
5593 | ; |
5566 | ; |
5594 | ; on return : eax = pid |
5567 | ; on return : eax = pid |
5595 | 5568 | ||
5596 | xor ebx, ebx |
5569 | xor ebx, ebx |
5597 | call new_sys_threads |
5570 | call new_sys_threads |
5598 | 5571 | ||
5599 | mov [esp+32], eax |
5572 | mov [esp+32], eax |
5600 | ret |
5573 | ret |
5601 | 5574 | ||
5602 | align 4 |
5575 | align 4 |
5603 | 5576 | ||
5604 | paleholder: |
5577 | paleholder: |
5605 | ret |
5578 | ret |
5606 | ;------------------------------------------------------------------------------ |
5579 | ;------------------------------------------------------------------------------ |
5607 | align 4 |
5580 | align 4 |
5608 | calculate_fast_getting_offset_for_WinMapAddress: |
5581 | calculate_fast_getting_offset_for_WinMapAddress: |
5609 | ; calculate data area for fast getting offset to _WinMapAddress |
5582 | ; calculate data area for fast getting offset to _WinMapAddress |
5610 | xor eax, eax |
5583 | xor eax, eax |
5611 | mov ecx, [_display.height] |
5584 | mov ecx, [_display.height] |
5612 | mov edi, d_width_calc_area |
5585 | mov edi, d_width_calc_area |
5613 | cld |
5586 | cld |
5614 | @@: |
5587 | @@: |
5615 | stosd |
5588 | stosd |
5616 | add eax, [_display.width] |
5589 | add eax, [_display.width] |
5617 | dec ecx |
5590 | dec ecx |
5618 | jnz @r |
5591 | jnz @r |
5619 | ret |
5592 | ret |
5620 | ;------------------------------------------------------------------------------ |
5593 | ;------------------------------------------------------------------------------ |
5621 | align 4 |
5594 | align 4 |
5622 | calculate_fast_getting_offset_for_LFB: |
5595 | calculate_fast_getting_offset_for_LFB: |
5623 | ; calculate data area for fast getting offset to LFB |
5596 | ; calculate data area for fast getting offset to LFB |
5624 | xor eax, eax |
5597 | xor eax, eax |
5625 | mov ecx, [_display.height] |
5598 | mov ecx, [_display.height] |
5626 | mov edi, BPSLine_calc_area |
5599 | mov edi, BPSLine_calc_area |
5627 | cld |
5600 | cld |
5628 | @@: |
5601 | @@: |
5629 | stosd |
5602 | stosd |
5630 | add eax, [_display.pitch] |
5603 | add eax, [_display.pitch] |
5631 | dec ecx |
5604 | dec ecx |
5632 | jnz @r |
5605 | jnz @r |
5633 | ret |
5606 | ret |
5634 | ;------------------------------------------------------------------------------ |
5607 | ;------------------------------------------------------------------------------ |
5635 | align 4 |
5608 | align 4 |
5636 | set_screen: |
5609 | set_screen: |
5637 | ; in: |
5610 | ; in: |
5638 | ; eax - new Screen_Max_X |
5611 | ; eax - new Screen_Max_X |
5639 | ; ecx - new BytesPerScanLine |
5612 | ; ecx - new BytesPerScanLine |
5640 | ; edx - new Screen_Max_Y |
5613 | ; edx - new Screen_Max_Y |
5641 | cmp eax, [Screen_Max_X] |
5614 | cmp eax, [Screen_Max_X] |
5642 | jne .set |
5615 | jne .set |
5643 | 5616 | ||
5644 | cmp edx, [Screen_Max_Y] |
5617 | cmp edx, [Screen_Max_Y] |
5645 | jne .set |
5618 | jne .set |
5646 | ret |
5619 | ret |
5647 | .set: |
5620 | .set: |
5648 | pushfd |
5621 | pushfd |
5649 | cli |
5622 | cli |
5650 | 5623 | ||
5651 | mov [Screen_Max_X], eax |
5624 | mov [Screen_Max_X], eax |
5652 | mov [Screen_Max_Y], edx |
5625 | mov [Screen_Max_Y], edx |
5653 | mov [_display.pitch], ecx |
5626 | mov [_display.pitch], ecx |
5654 | 5627 | ||
5655 | mov [screen_workarea.right], eax |
5628 | mov [screen_workarea.right], eax |
5656 | mov [screen_workarea.bottom], edx |
5629 | mov [screen_workarea.bottom], edx |
5657 | 5630 | ||
5658 | push ebx |
5631 | push ebx |
5659 | push esi |
5632 | push esi |
5660 | push edi |
5633 | push edi |
5661 | 5634 | ||
5662 | pushad |
5635 | pushad |
5663 | 5636 | ||
5664 | cmp [do_not_touch_winmap], 1 |
5637 | cmp [do_not_touch_winmap], 1 |
5665 | je @f |
5638 | je @f |
5666 | 5639 | ||
5667 | stdcall kernel_free, [_WinMapAddress] |
5640 | stdcall kernel_free, [_WinMapAddress] |
5668 | 5641 | ||
5669 | mov eax, [_display.width] |
5642 | mov eax, [_display.width] |
5670 | mul [_display.height] |
5643 | mul [_display.height] |
5671 | mov [_WinMapSize], eax |
5644 | mov [_WinMapSize], eax |
5672 | 5645 | ||
5673 | stdcall kernel_alloc, eax |
5646 | stdcall kernel_alloc, eax |
5674 | mov [_WinMapAddress], eax |
5647 | mov [_WinMapAddress], eax |
5675 | test eax, eax |
5648 | test eax, eax |
5676 | jz .epic_fail |
5649 | jz .epic_fail |
5677 | ; store for f.18.24 |
5650 | ; store for f.18.24 |
5678 | mov eax, [_display.width] |
5651 | mov eax, [_display.width] |
5679 | mov [display_width_standard], eax |
5652 | mov [display_width_standard], eax |
5680 | 5653 | ||
5681 | mov eax, [_display.height] |
5654 | mov eax, [_display.height] |
5682 | mov [display_height_standard], eax |
5655 | mov [display_height_standard], eax |
5683 | @@: |
5656 | @@: |
5684 | call calculate_fast_getting_offset_for_WinMapAddress |
5657 | call calculate_fast_getting_offset_for_WinMapAddress |
5685 | ; for Qemu or non standart video cards |
5658 | ; for Qemu or non standart video cards |
5686 | ; Unfortunately [BytesPerScanLine] does not always |
5659 | ; Unfortunately [BytesPerScanLine] does not always |
5687 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5660 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5688 | call calculate_fast_getting_offset_for_LFB |
5661 | call calculate_fast_getting_offset_for_LFB |
5689 | popad |
5662 | popad |
5690 | 5663 | ||
5691 | call repos_windows |
5664 | call repos_windows |
5692 | xor eax, eax |
5665 | xor eax, eax |
5693 | xor ebx, ebx |
5666 | xor ebx, ebx |
5694 | mov ecx, [Screen_Max_X] |
5667 | mov ecx, [Screen_Max_X] |
5695 | mov edx, [Screen_Max_Y] |
5668 | mov edx, [Screen_Max_Y] |
5696 | call calculatescreen |
5669 | call calculatescreen |
5697 | pop edi |
5670 | pop edi |
5698 | pop esi |
5671 | pop esi |
5699 | pop ebx |
5672 | pop ebx |
5700 | 5673 | ||
5701 | popfd |
5674 | popfd |
5702 | ret |
5675 | ret |
5703 | 5676 | ||
5704 | .epic_fail: |
5677 | .epic_fail: |
5705 | hlt ; Houston, we've had a problem |
5678 | hlt ; Houston, we've had a problem |
5706 | 5679 | ||
5707 | ; --------------- APM --------------------- |
5680 | ; --------------- APM --------------------- |
5708 | uglobal |
5681 | uglobal |
5709 | apm_entry dp 0 |
5682 | apm_entry dp 0 |
5710 | apm_vf dd 0 |
5683 | apm_vf dd 0 |
5711 | endg |
5684 | endg |
5712 | 5685 | ||
5713 | align 4 |
5686 | align 4 |
5714 | sys_apm: |
5687 | sys_apm: |
5715 | xor eax, eax |
5688 | xor eax, eax |
5716 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5689 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5717 | jne @f |
5690 | jne @f |
5718 | inc eax |
5691 | inc eax |
5719 | or dword [esp + 44], eax ; error |
5692 | or dword [esp + 44], eax ; error |
5720 | add eax, 7 |
5693 | add eax, 7 |
5721 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5694 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5722 | ret |
5695 | ret |
5723 | 5696 | ||
5724 | @@: |
5697 | @@: |
5725 | ; xchg eax, ecx |
5698 | ; xchg eax, ecx |
5726 | ; xchg ebx, ecx |
5699 | ; xchg ebx, ecx |
5727 | 5700 | ||
5728 | cmp dx, 3 |
5701 | cmp dx, 3 |
5729 | ja @f |
5702 | ja @f |
5730 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5703 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5731 | mov eax, [apm_vf] |
5704 | mov eax, [apm_vf] |
5732 | mov [esp + 32], eax |
5705 | mov [esp + 32], eax |
5733 | shr eax, 16 |
5706 | shr eax, 16 |
5734 | mov [esp + 28], eax |
5707 | mov [esp + 28], eax |
5735 | ret |
5708 | ret |
5736 | 5709 | ||
5737 | @@: |
5710 | @@: |
5738 | 5711 | ||
5739 | mov esi, [master_tab+(OS_BASE shr 20)] |
5712 | mov esi, [master_tab+(OS_BASE shr 20)] |
5740 | xchg [master_tab], esi |
5713 | xchg [master_tab], esi |
5741 | push esi |
5714 | push esi |
5742 | mov edi, cr3 |
5715 | mov edi, cr3 |
5743 | mov cr3, edi ;flush TLB |
5716 | mov cr3, edi ;flush TLB |
5744 | 5717 | ||
5745 | call pword [apm_entry] ;call APM BIOS |
5718 | call pword [apm_entry] ;call APM BIOS |
5746 | 5719 | ||
5747 | xchg eax, [esp] |
5720 | xchg eax, [esp] |
5748 | mov [master_tab], eax |
5721 | mov [master_tab], eax |
5749 | mov eax, cr3 |
5722 | mov eax, cr3 |
5750 | mov cr3, eax |
5723 | mov cr3, eax |
5751 | pop eax |
5724 | pop eax |
5752 | 5725 | ||
5753 | mov [esp + 4 ], edi |
5726 | mov [esp + 4 ], edi |
5754 | mov [esp + 8], esi |
5727 | mov [esp + 8], esi |
5755 | mov [esp + 20], ebx |
5728 | mov [esp + 20], ebx |
5756 | mov [esp + 24], edx |
5729 | mov [esp + 24], edx |
5757 | mov [esp + 28], ecx |
5730 | mov [esp + 28], ecx |
5758 | mov [esp + 32], eax |
5731 | mov [esp + 32], eax |
5759 | setc al |
5732 | setc al |
5760 | and [esp + 44], byte 0xfe |
5733 | and [esp + 44], byte 0xfe |
5761 | or [esp + 44], al |
5734 | or [esp + 44], al |
5762 | ret |
5735 | ret |
5763 | ; ----------------------------------------- |
5736 | ; ----------------------------------------- |
5764 | 5737 | ||
5765 | align 4 |
5738 | align 4 |
5766 | 5739 | ||
5767 | undefined_syscall: ; Undefined system call |
5740 | undefined_syscall: ; Undefined system call |
5768 | mov [esp + 32], dword -1 |
5741 | mov [esp + 32], dword -1 |
5769 | ret |
5742 | ret |
5770 | 5743 | ||
5771 | align 4 |
5744 | align 4 |
5772 | system_shutdown: ; shut down the system |
5745 | system_shutdown: ; shut down the system |
5773 | 5746 | ||
5774 | cmp byte [BOOT_VARS+0x9030], 1 |
5747 | cmp byte [BOOT_VARS+0x9030], 1 |
5775 | jne @F |
5748 | jne @F |
5776 | ret |
5749 | ret |
5777 | @@: |
5750 | @@: |
5778 | call stop_all_services |
5751 | call stop_all_services |
5779 | movi eax, 3 |
5752 | movi eax, 3 |
5780 | call sys_cd_audio |
5753 | call sys_cd_audio |
5781 | 5754 | ||
5782 | yes_shutdown_param: |
5755 | yes_shutdown_param: |
5783 | cli |
5756 | cli |
5784 | 5757 | ||
5785 | if ~ defined extended_primary_loader |
5758 | if ~ defined extended_primary_loader |
5786 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5759 | ; load kernel.mnt to 0x7000:0 |
5787 | movi esi, 12 |
- | |
5788 | xor ebx, ebx |
5760 | mov ebx, kernel_file_load |
5789 | or ecx, -1 |
5761 | pushad |
5790 | mov edx, OS_BASE+0x70000 |
5762 | call file_system_lfn |
5791 | call fileread |
5763 | popad |
5792 | 5764 | ||
5793 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5765 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5794 | mov edi, OS_BASE+0x40000 |
5766 | mov edi, OS_BASE+0x40000 |
5795 | mov ecx, 1000 |
5767 | mov ecx, 1000 |
5796 | rep movsb |
5768 | rep movsb |
5797 | end if |
5769 | end if |
5798 | 5770 | ||
5799 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5771 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5800 | ; mov edi, OS_BASE |
5772 | ; mov edi, OS_BASE |
5801 | ; mov ecx, 0x10000/4 |
5773 | ; mov ecx, 0x10000/4 |
5802 | ; cld |
5774 | ; cld |
5803 | ; rep movsd |
5775 | ; rep movsd |
5804 | - | ||
5805 | call restorefatchain |
- | |
5806 | 5776 | ||
5807 | call IRQ_mask_all |
5777 | call IRQ_mask_all |
5808 | 5778 | ||
5809 | if 0 |
5779 | if 0 |
5810 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5780 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5811 | mov word [OS_BASE+0x467+2], 0x1000 |
5781 | mov word [OS_BASE+0x467+2], 0x1000 |
5812 | 5782 | ||
5813 | mov al, 0x0F |
5783 | mov al, 0x0F |
5814 | out 0x70, al |
5784 | out 0x70, al |
5815 | mov al, 0x05 |
5785 | mov al, 0x05 |
5816 | out 0x71, al |
5786 | out 0x71, al |
5817 | 5787 | ||
5818 | mov al, 0xFE |
5788 | mov al, 0xFE |
5819 | out 0x64, al |
5789 | out 0x64, al |
5820 | 5790 | ||
5821 | hlt |
5791 | hlt |
5822 | jmp $-1 |
5792 | jmp $-1 |
5823 | 5793 | ||
5824 | else |
5794 | else |
5825 | cmp byte [OS_BASE + 0x9030], 2 |
5795 | cmp byte [OS_BASE + 0x9030], 2 |
5826 | jnz no_acpi_power_off |
5796 | jnz no_acpi_power_off |
5827 | 5797 | ||
5828 | ; scan for RSDP |
5798 | ; scan for RSDP |
5829 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5799 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5830 | movzx eax, word [OS_BASE + 0x40E] |
5800 | movzx eax, word [OS_BASE + 0x40E] |
5831 | shl eax, 4 |
5801 | shl eax, 4 |
5832 | jz @f |
5802 | jz @f |
5833 | mov ecx, 1024/16 |
5803 | mov ecx, 1024/16 |
5834 | call scan_rsdp |
5804 | call scan_rsdp |
5835 | jnc .rsdp_found |
5805 | jnc .rsdp_found |
5836 | @@: |
5806 | @@: |
5837 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5807 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5838 | mov eax, 0xE0000 |
5808 | mov eax, 0xE0000 |
5839 | mov ecx, 0x2000 |
5809 | mov ecx, 0x2000 |
5840 | call scan_rsdp |
5810 | call scan_rsdp |
5841 | jc no_acpi_power_off |
5811 | jc no_acpi_power_off |
5842 | .rsdp_found: |
5812 | .rsdp_found: |
5843 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5813 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5844 | mov ebp, [ipc_tmp] |
5814 | mov ebp, [ipc_tmp] |
5845 | stdcall map_page, ebp, esi, PG_MAP |
5815 | stdcall map_page, ebp, esi, PG_MAP |
5846 | lea eax, [esi+1000h] |
5816 | lea eax, [esi+1000h] |
5847 | lea edx, [ebp+1000h] |
5817 | lea edx, [ebp+1000h] |
5848 | stdcall map_page, edx, eax, PG_MAP |
5818 | stdcall map_page, edx, eax, PG_MAP |
5849 | and esi, 0xFFF |
5819 | and esi, 0xFFF |
5850 | add esi, ebp |
5820 | add esi, ebp |
5851 | cmp dword [esi], 'RSDT' |
5821 | cmp dword [esi], 'RSDT' |
5852 | jnz no_acpi_power_off |
5822 | jnz no_acpi_power_off |
5853 | mov ecx, [esi+4] |
5823 | mov ecx, [esi+4] |
5854 | sub ecx, 24h |
5824 | sub ecx, 24h |
5855 | jbe no_acpi_power_off |
5825 | jbe no_acpi_power_off |
5856 | shr ecx, 2 |
5826 | shr ecx, 2 |
5857 | add esi, 24h |
5827 | add esi, 24h |
5858 | .scan_fadt: |
5828 | .scan_fadt: |
5859 | lodsd |
5829 | lodsd |
5860 | mov ebx, eax |
5830 | mov ebx, eax |
5861 | lea eax, [ebp+2000h] |
5831 | lea eax, [ebp+2000h] |
5862 | stdcall map_page, eax, ebx, PG_MAP |
5832 | stdcall map_page, eax, ebx, PG_MAP |
5863 | lea eax, [ebp+3000h] |
5833 | lea eax, [ebp+3000h] |
5864 | add ebx, 0x1000 |
5834 | add ebx, 0x1000 |
5865 | stdcall map_page, eax, ebx, PG_MAP |
5835 | stdcall map_page, eax, ebx, PG_MAP |
5866 | and ebx, 0xFFF |
5836 | and ebx, 0xFFF |
5867 | lea ebx, [ebx+ebp+2000h] |
5837 | lea ebx, [ebx+ebp+2000h] |
5868 | cmp dword [ebx], 'FACP' |
5838 | cmp dword [ebx], 'FACP' |
5869 | jz .fadt_found |
5839 | jz .fadt_found |
5870 | loop .scan_fadt |
5840 | loop .scan_fadt |
5871 | jmp no_acpi_power_off |
5841 | jmp no_acpi_power_off |
5872 | .fadt_found: |
5842 | .fadt_found: |
5873 | ; ebx is linear address of FADT |
5843 | ; ebx is linear address of FADT |
5874 | mov edi, [ebx+40] ; physical address of the DSDT |
5844 | mov edi, [ebx+40] ; physical address of the DSDT |
5875 | lea eax, [ebp+4000h] |
5845 | lea eax, [ebp+4000h] |
5876 | stdcall map_page, eax, edi, PG_MAP |
5846 | stdcall map_page, eax, edi, PG_MAP |
5877 | lea eax, [ebp+5000h] |
5847 | lea eax, [ebp+5000h] |
5878 | lea esi, [edi+0x1000] |
5848 | lea esi, [edi+0x1000] |
5879 | stdcall map_page, eax, esi, PG_MAP |
5849 | stdcall map_page, eax, esi, PG_MAP |
5880 | and esi, 0xFFF |
5850 | and esi, 0xFFF |
5881 | sub edi, esi |
5851 | sub edi, esi |
5882 | cmp dword [esi+ebp+4000h], 'DSDT' |
5852 | cmp dword [esi+ebp+4000h], 'DSDT' |
5883 | jnz no_acpi_power_off |
5853 | jnz no_acpi_power_off |
5884 | mov eax, [esi+ebp+4004h] ; DSDT length |
5854 | mov eax, [esi+ebp+4004h] ; DSDT length |
5885 | sub eax, 36+4 |
5855 | sub eax, 36+4 |
5886 | jbe no_acpi_power_off |
5856 | jbe no_acpi_power_off |
5887 | add esi, 36 |
5857 | add esi, 36 |
5888 | .scan_dsdt: |
5858 | .scan_dsdt: |
5889 | cmp dword [esi+ebp+4000h], '_S5_' |
5859 | cmp dword [esi+ebp+4000h], '_S5_' |
5890 | jnz .scan_dsdt_cont |
5860 | jnz .scan_dsdt_cont |
5891 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5861 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5892 | jnz .scan_dsdt_cont |
5862 | jnz .scan_dsdt_cont |
5893 | mov dl, [esi+ebp+4000h+6] |
5863 | mov dl, [esi+ebp+4000h+6] |
5894 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5864 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5895 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5865 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5896 | ja .scan_dsdt_cont |
5866 | ja .scan_dsdt_cont |
5897 | cmp dl, 1 |
5867 | cmp dl, 1 |
5898 | jb .scan_dsdt_cont |
5868 | jb .scan_dsdt_cont |
5899 | lea esi, [esi+ebp+4000h+7] |
5869 | lea esi, [esi+ebp+4000h+7] |
5900 | xor ecx, ecx |
5870 | xor ecx, ecx |
5901 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5871 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5902 | jz @f |
5872 | jz @f |
5903 | cmp byte [esi], 0xA |
5873 | cmp byte [esi], 0xA |
5904 | jnz no_acpi_power_off |
5874 | jnz no_acpi_power_off |
5905 | inc esi |
5875 | inc esi |
5906 | mov cl, [esi] |
5876 | mov cl, [esi] |
5907 | @@: |
5877 | @@: |
5908 | inc esi |
5878 | inc esi |
5909 | cmp dl, 2 |
5879 | cmp dl, 2 |
5910 | jb @f |
5880 | jb @f |
5911 | cmp byte [esi], 0 |
5881 | cmp byte [esi], 0 |
5912 | jz @f |
5882 | jz @f |
5913 | cmp byte [esi], 0xA |
5883 | cmp byte [esi], 0xA |
5914 | jnz no_acpi_power_off |
5884 | jnz no_acpi_power_off |
5915 | inc esi |
5885 | inc esi |
5916 | mov ch, [esi] |
5886 | mov ch, [esi] |
5917 | @@: |
5887 | @@: |
5918 | jmp do_acpi_power_off |
5888 | jmp do_acpi_power_off |
5919 | .scan_dsdt_cont: |
5889 | .scan_dsdt_cont: |
5920 | inc esi |
5890 | inc esi |
5921 | cmp esi, 0x1000 |
5891 | cmp esi, 0x1000 |
5922 | jb @f |
5892 | jb @f |
5923 | sub esi, 0x1000 |
5893 | sub esi, 0x1000 |
5924 | add edi, 0x1000 |
5894 | add edi, 0x1000 |
5925 | push eax |
5895 | push eax |
5926 | lea eax, [ebp+4000h] |
5896 | lea eax, [ebp+4000h] |
5927 | stdcall map_page, eax, edi, PG_MAP |
5897 | stdcall map_page, eax, edi, PG_MAP |
5928 | push PG_MAP |
5898 | push PG_MAP |
5929 | lea eax, [edi+1000h] |
5899 | lea eax, [edi+1000h] |
5930 | push eax |
5900 | push eax |
5931 | lea eax, [ebp+5000h] |
5901 | lea eax, [ebp+5000h] |
5932 | push eax |
5902 | push eax |
5933 | stdcall map_page |
5903 | stdcall map_page |
5934 | pop eax |
5904 | pop eax |
5935 | @@: |
5905 | @@: |
5936 | dec eax |
5906 | dec eax |
5937 | jnz .scan_dsdt |
5907 | jnz .scan_dsdt |
5938 | jmp no_acpi_power_off |
5908 | jmp no_acpi_power_off |
5939 | do_acpi_power_off: |
5909 | do_acpi_power_off: |
5940 | mov edx, [ebx+48] |
5910 | mov edx, [ebx+48] |
5941 | test edx, edx |
5911 | test edx, edx |
5942 | jz .nosmi |
5912 | jz .nosmi |
5943 | mov al, [ebx+52] |
5913 | mov al, [ebx+52] |
5944 | out dx, al |
5914 | out dx, al |
5945 | mov edx, [ebx+64] |
5915 | mov edx, [ebx+64] |
5946 | @@: |
5916 | @@: |
5947 | in ax, dx |
5917 | in ax, dx |
5948 | test al, 1 |
5918 | test al, 1 |
5949 | jz @b |
5919 | jz @b |
5950 | .nosmi: |
5920 | .nosmi: |
5951 | and cx, 0x0707 |
5921 | and cx, 0x0707 |
5952 | shl cx, 2 |
5922 | shl cx, 2 |
5953 | or cx, 0x2020 |
5923 | or cx, 0x2020 |
5954 | mov edx, [ebx+64] |
5924 | mov edx, [ebx+64] |
5955 | in ax, dx |
5925 | in ax, dx |
5956 | and ax, 203h |
5926 | and ax, 203h |
5957 | or ah, cl |
5927 | or ah, cl |
5958 | out dx, ax |
5928 | out dx, ax |
5959 | mov edx, [ebx+68] |
5929 | mov edx, [ebx+68] |
5960 | test edx, edx |
5930 | test edx, edx |
5961 | jz @f |
5931 | jz @f |
5962 | in ax, dx |
5932 | in ax, dx |
5963 | and ax, 203h |
5933 | and ax, 203h |
5964 | or ah, ch |
5934 | or ah, ch |
5965 | out dx, ax |
5935 | out dx, ax |
5966 | @@: |
5936 | @@: |
5967 | jmp $ |
5937 | jmp $ |
5968 | 5938 | ||
5969 | 5939 | ||
5970 | no_acpi_power_off: |
5940 | no_acpi_power_off: |
5971 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5941 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5972 | mov word [OS_BASE+0x467+2], 0x1000 |
5942 | mov word [OS_BASE+0x467+2], 0x1000 |
5973 | 5943 | ||
5974 | mov al, 0x0F |
5944 | mov al, 0x0F |
5975 | out 0x70, al |
5945 | out 0x70, al |
5976 | mov al, 0x05 |
5946 | mov al, 0x05 |
5977 | out 0x71, al |
5947 | out 0x71, al |
5978 | 5948 | ||
5979 | mov al, 0xFE |
5949 | mov al, 0xFE |
5980 | out 0x64, al |
5950 | out 0x64, al |
5981 | 5951 | ||
5982 | hlt |
5952 | hlt |
5983 | jmp $-1 |
5953 | jmp $-1 |
5984 | 5954 | ||
5985 | scan_rsdp: |
5955 | scan_rsdp: |
5986 | add eax, OS_BASE |
5956 | add eax, OS_BASE |
5987 | .s: |
5957 | .s: |
5988 | cmp dword [eax], 'RSD ' |
5958 | cmp dword [eax], 'RSD ' |
5989 | jnz .n |
5959 | jnz .n |
5990 | cmp dword [eax+4], 'PTR ' |
5960 | cmp dword [eax+4], 'PTR ' |
5991 | jnz .n |
5961 | jnz .n |
5992 | xor edx, edx |
5962 | xor edx, edx |
5993 | xor esi, esi |
5963 | xor esi, esi |
5994 | @@: |
5964 | @@: |
5995 | add dl, [eax+esi] |
5965 | add dl, [eax+esi] |
5996 | inc esi |
5966 | inc esi |
5997 | cmp esi, 20 |
5967 | cmp esi, 20 |
5998 | jnz @b |
5968 | jnz @b |
5999 | test dl, dl |
5969 | test dl, dl |
6000 | jz .ok |
5970 | jz .ok |
6001 | .n: |
5971 | .n: |
6002 | add eax, 10h |
5972 | add eax, 10h |
6003 | loop .s |
5973 | loop .s |
6004 | stc |
5974 | stc |
6005 | .ok: |
5975 | .ok: |
6006 | ret |
5976 | ret |
6007 | end if |
5977 | end if |
6008 | 5978 | ||
6009 | if ~ lang eq sp |
5979 | if ~ lang eq sp |
6010 | diff16 "end of .text segment",0,$ |
5980 | diff16 "end of .text segment",0,$ |
6011 | end if |
5981 | end if |
6012 | 5982 | ||
6013 | include "data32.inc" |
5983 | include "data32.inc" |
6014 | 5984 | ||
6015 | __REV__ = __REV |
5985 | __REV__ = __REV |
6016 | 5986 | ||
6017 | if ~ lang eq sp |
5987 | if ~ lang eq sp |
6018 | diff16 "end of kernel code",0,$ |
5988 | diff16 "end of kernel code",0,$ |
6019 | end if=> |
5989 | end if=> |