Rev 3627 | Rev 3706 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3627 | Rev 3702 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2012. 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: 3627 $ |
74 | $Revision: 3702 $ |
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 | ; The following constant, if nonzero, duplicates debug output to the screen. |
82 | ; The following constant, if nonzero, duplicates debug output to the screen. |
83 | debug_direct_print equ 0 |
83 | debug_direct_print equ 0 |
84 | 84 | ||
85 | include "proc32.inc" |
85 | include "proc32.inc" |
86 | include "kglobals.inc" |
86 | include "kglobals.inc" |
87 | include "lang.inc" |
87 | include "lang.inc" |
88 | include "encoding.inc" |
88 | include "encoding.inc" |
89 | 89 | ||
90 | include "const.inc" |
90 | include "const.inc" |
91 | max_processes equ 255 |
91 | max_processes equ 255 |
92 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
92 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
93 | 93 | ||
94 | 94 | ||
95 | os_stack equ (os_data_l-gdts) ; GDTs |
95 | os_stack equ (os_data_l-gdts) ; GDTs |
96 | os_code equ (os_code_l-gdts) |
96 | os_code equ (os_code_l-gdts) |
97 | graph_data equ (3+graph_data_l-gdts) |
97 | graph_data equ (3+graph_data_l-gdts) |
98 | tss0 equ (tss0_l-gdts) |
98 | tss0 equ (tss0_l-gdts) |
99 | app_code equ (3+app_code_l-gdts) |
99 | app_code equ (3+app_code_l-gdts) |
100 | app_data equ (3+app_data_l-gdts) |
100 | app_data equ (3+app_data_l-gdts) |
101 | app_tls equ (3+tls_data_l-gdts) |
101 | app_tls equ (3+tls_data_l-gdts) |
102 | pci_code_sel equ (pci_code_32-gdts) |
102 | pci_code_sel equ (pci_code_32-gdts) |
103 | pci_data_sel equ (pci_data_32-gdts) |
103 | pci_data_sel equ (pci_data_32-gdts) |
104 | 104 | ||
105 | 105 | ||
106 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
106 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
107 | ;; |
107 | ;; |
108 | ;; Included files: |
108 | ;; Included files: |
109 | ;; |
109 | ;; |
110 | ;; Kernel16.inc |
110 | ;; Kernel16.inc |
111 | ;; - Booteng.inc English text for bootup |
111 | ;; - Booteng.inc English text for bootup |
112 | ;; - Bootcode.inc Hardware setup |
112 | ;; - Bootcode.inc Hardware setup |
113 | ;; - Pci16.inc PCI functions |
113 | ;; - Pci16.inc PCI functions |
114 | ;; |
114 | ;; |
115 | ;; Kernel32.inc |
115 | ;; Kernel32.inc |
116 | ;; - Sys32.inc Process management |
116 | ;; - Sys32.inc Process management |
117 | ;; - Shutdown.inc Shutdown and restart |
117 | ;; - Shutdown.inc Shutdown and restart |
118 | ;; - Fat32.inc Read / write hd |
118 | ;; - Fat32.inc Read / write hd |
119 | ;; - Vesa12.inc Vesa 1.2 driver |
119 | ;; - Vesa12.inc Vesa 1.2 driver |
120 | ;; - Vesa20.inc Vesa 2.0 driver |
120 | ;; - Vesa20.inc Vesa 2.0 driver |
121 | ;; - Vga.inc VGA driver |
121 | ;; - Vga.inc VGA driver |
122 | ;; - Stack.inc Network interface |
122 | ;; - Stack.inc Network interface |
123 | ;; - Mouse.inc Mouse pointer |
123 | ;; - Mouse.inc Mouse pointer |
124 | ;; - Scincode.inc Window skinning |
124 | ;; - Scincode.inc Window skinning |
125 | ;; - Pci32.inc PCI functions |
125 | ;; - Pci32.inc PCI functions |
126 | ;; |
126 | ;; |
127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
128 | 128 | ||
129 | 129 | ||
130 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
130 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
131 | ;; ;; |
131 | ;; ;; |
132 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
132 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
133 | ;; ;; |
133 | ;; ;; |
134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
135 | 135 | ||
136 | use16 |
136 | use16 |
137 | org 0x0 |
137 | org 0x0 |
138 | jmp start_of_code |
138 | jmp start_of_code |
139 | 139 | ||
140 | if lang eq sp |
140 | if lang eq sp |
141 | include "kernelsp.inc" ; spanish kernel messages |
141 | include "kernelsp.inc" ; spanish kernel messages |
142 | else |
142 | else |
143 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
143 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
144 | end if |
144 | end if |
145 | 145 | ||
146 | include "boot/bootstr.inc" ; language-independent boot messages |
146 | include "boot/bootstr.inc" ; language-independent boot messages |
147 | include "boot/preboot.inc" |
147 | include "boot/preboot.inc" |
148 | 148 | ||
149 | if lang eq ge |
149 | if lang eq ge |
150 | include "boot/bootge.inc" ; german system boot messages |
150 | include "boot/bootge.inc" ; german system boot messages |
151 | else if lang eq sp |
151 | else if lang eq sp |
152 | include "boot/bootsp.inc" ; spanish system boot messages |
152 | include "boot/bootsp.inc" ; spanish system boot messages |
153 | else if lang eq ru |
153 | else if lang eq ru |
154 | include "boot/bootru.inc" ; russian system boot messages |
154 | include "boot/bootru.inc" ; russian system boot messages |
155 | include "boot/ru.inc" ; Russian font |
155 | include "boot/ru.inc" ; Russian font |
156 | else if lang eq et |
156 | else if lang eq et |
157 | include "boot/bootet.inc" ; estonian system boot messages |
157 | include "boot/bootet.inc" ; estonian system boot messages |
158 | include "boot/et.inc" ; Estonian font |
158 | include "boot/et.inc" ; Estonian font |
159 | else |
159 | else |
160 | include "boot/booten.inc" ; english system boot messages |
160 | include "boot/booten.inc" ; english system boot messages |
161 | end if |
161 | end if |
162 | 162 | ||
163 | include "boot/bootcode.inc" ; 16 bit system boot code |
163 | include "boot/bootcode.inc" ; 16 bit system boot code |
164 | include "bus/pci/pci16.inc" |
164 | include "bus/pci/pci16.inc" |
165 | include "detect/biosdisk.inc" |
165 | include "detect/biosdisk.inc" |
166 | 166 | ||
167 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
167 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
168 | ;; ;; |
168 | ;; ;; |
169 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
169 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
170 | ;; ;; |
170 | ;; ;; |
171 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
171 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
172 | 172 | ||
173 | 173 | ||
174 | ; CR0 Flags - Protected mode and Paging |
174 | ; CR0 Flags - Protected mode and Paging |
175 | 175 | ||
176 | mov ecx, CR0_PE |
176 | mov ecx, CR0_PE |
177 | 177 | ||
178 | ; Enabling 32 bit protected mode |
178 | ; Enabling 32 bit protected mode |
179 | 179 | ||
180 | sidt [cs:old_ints_h] |
180 | sidt [cs:old_ints_h] |
181 | 181 | ||
182 | cli ; disable all irqs |
182 | cli ; disable all irqs |
183 | cld |
183 | cld |
184 | mov al, 255 ; mask all irqs |
184 | mov al, 255 ; mask all irqs |
185 | out 0xa1, al |
185 | out 0xa1, al |
186 | out 0x21, al |
186 | out 0x21, al |
187 | l.5: |
187 | l.5: |
188 | in al, 0x64 ; Enable A20 |
188 | in al, 0x64 ; Enable A20 |
189 | test al, 2 |
189 | test al, 2 |
190 | jnz l.5 |
190 | jnz l.5 |
191 | mov al, 0xD1 |
191 | mov al, 0xD1 |
192 | out 0x64, al |
192 | out 0x64, al |
193 | l.6: |
193 | l.6: |
194 | in al, 0x64 |
194 | in al, 0x64 |
195 | test al, 2 |
195 | test al, 2 |
196 | jnz l.6 |
196 | jnz l.6 |
197 | mov al, 0xDF |
197 | mov al, 0xDF |
198 | out 0x60, al |
198 | out 0x60, al |
199 | l.7: |
199 | l.7: |
200 | in al, 0x64 |
200 | in al, 0x64 |
201 | test al, 2 |
201 | test al, 2 |
202 | jnz l.7 |
202 | jnz l.7 |
203 | mov al, 0xFF |
203 | mov al, 0xFF |
204 | out 0x64, al |
204 | out 0x64, al |
205 | 205 | ||
206 | lgdt [cs:tmp_gdt] ; Load GDT |
206 | lgdt [cs:tmp_gdt] ; Load GDT |
207 | mov eax, cr0 ; protected mode |
207 | mov eax, cr0 ; protected mode |
208 | or eax, ecx |
208 | or eax, ecx |
209 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
209 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
210 | mov cr0, eax |
210 | mov cr0, eax |
211 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
211 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
212 | 212 | ||
213 | align 8 |
213 | align 8 |
214 | tmp_gdt: |
214 | tmp_gdt: |
215 | 215 | ||
216 | dw 23 |
216 | dw 23 |
217 | dd tmp_gdt+0x10000 |
217 | dd tmp_gdt+0x10000 |
218 | dw 0 |
218 | dw 0 |
219 | 219 | ||
220 | dw 0xffff |
220 | dw 0xffff |
221 | dw 0x0000 |
221 | dw 0x0000 |
222 | db 0x00 |
222 | db 0x00 |
223 | dw 11011111b *256 +10011010b |
223 | dw 11011111b *256 +10011010b |
224 | db 0x00 |
224 | db 0x00 |
225 | 225 | ||
226 | dw 0xffff |
226 | dw 0xffff |
227 | dw 0x0000 |
227 | dw 0x0000 |
228 | db 0x00 |
228 | db 0x00 |
229 | dw 11011111b *256 +10010010b |
229 | dw 11011111b *256 +10010010b |
230 | db 0x00 |
230 | db 0x00 |
231 | 231 | ||
232 | include "data16.inc" |
232 | include "data16.inc" |
233 | 233 | ||
234 | if ~ lang eq sp |
234 | if ~ lang eq sp |
235 | diff16 "end of bootcode",0,$+0x10000 |
235 | diff16 "end of bootcode",0,$+0x10000 |
236 | end if |
236 | end if |
237 | 237 | ||
238 | use32 |
238 | use32 |
239 | org $+0x10000 |
239 | org $+0x10000 |
240 | 240 | ||
241 | align 4 |
241 | align 4 |
242 | B32: |
242 | B32: |
243 | mov ax, os_stack ; Selector for os |
243 | mov ax, os_stack ; Selector for os |
244 | mov ds, ax |
244 | mov ds, ax |
245 | mov es, ax |
245 | mov es, ax |
246 | mov fs, ax |
246 | mov fs, ax |
247 | mov gs, ax |
247 | mov gs, ax |
248 | mov ss, ax |
248 | mov ss, ax |
249 | mov esp, 0x006CC00 ; Set stack |
249 | mov esp, 0x006CC00 ; Set stack |
250 | 250 | ||
251 | ; CLEAR 0x280000 - HEAP_BASE |
251 | ; CLEAR 0x280000 - HEAP_BASE |
252 | 252 | ||
253 | xor eax, eax |
253 | xor eax, eax |
254 | mov edi, CLEAN_ZONE |
254 | mov edi, CLEAN_ZONE |
255 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
255 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
256 | cld |
256 | cld |
257 | rep stosd |
257 | rep stosd |
258 | 258 | ||
259 | ; CLEAR KERNEL UNDEFINED GLOBALS |
259 | ; CLEAR KERNEL UNDEFINED GLOBALS |
260 | mov edi, endofcode-OS_BASE |
260 | mov edi, endofcode-OS_BASE |
261 | mov ecx, 0x90000 |
261 | mov ecx, 0x90000 |
262 | sub ecx, edi |
262 | sub ecx, edi |
263 | shr ecx, 2 |
263 | shr ecx, 2 |
264 | rep stosd |
264 | rep stosd |
265 | 265 | ||
266 | ; SAVE & CLEAR 0-0xffff |
266 | ; SAVE & CLEAR 0-0xffff |
267 | 267 | ||
268 | xor esi, esi |
268 | xor esi, esi |
269 | mov edi, (BOOT_VAR-OS_BASE) |
269 | mov edi, (BOOT_VAR-OS_BASE) |
270 | mov ecx, 0x10000 / 4 |
270 | mov ecx, 0x10000 / 4 |
271 | rep movsd |
271 | rep movsd |
272 | mov edi, 0x1000 |
272 | mov edi, 0x1000 |
273 | mov ecx, 0xf000 / 4 |
273 | mov ecx, 0xf000 / 4 |
274 | rep stosd |
274 | rep stosd |
275 | 275 | ||
276 | call test_cpu |
276 | call test_cpu |
277 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
277 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
278 | 278 | ||
279 | call check_acpi |
279 | call check_acpi |
280 | call init_BIOS32 |
280 | call init_BIOS32 |
281 | ; MEMORY MODEL |
281 | ; MEMORY MODEL |
282 | call mem_test |
282 | call mem_test |
283 | call init_mem |
283 | call init_mem |
284 | call init_page_map |
284 | call init_page_map |
285 | 285 | ||
286 | ; ENABLE PAGING |
286 | ; ENABLE PAGING |
287 | 287 | ||
288 | mov eax, sys_pgdir-OS_BASE |
288 | mov eax, sys_pgdir-OS_BASE |
289 | mov cr3, eax |
289 | mov cr3, eax |
290 | 290 | ||
291 | mov eax, cr0 |
291 | mov eax, cr0 |
292 | or eax, CR0_PG+CR0_WP |
292 | or eax, CR0_PG+CR0_WP |
293 | mov cr0, eax |
293 | mov cr0, eax |
294 | 294 | ||
295 | lgdt [gdts] |
295 | lgdt [gdts] |
296 | jmp pword os_code:high_code |
296 | jmp pword os_code:high_code |
297 | 297 | ||
298 | align 4 |
298 | align 4 |
299 | bios32_entry dd ? |
299 | bios32_entry dd ? |
300 | tmp_page_tabs dd ? |
300 | tmp_page_tabs dd ? |
301 | 301 | ||
302 | use16 |
302 | use16 |
303 | org $-0x10000 |
303 | org $-0x10000 |
304 | include "boot/shutdown.inc" ; shutdown or restart |
304 | include "boot/shutdown.inc" ; shutdown or restart |
305 | org $+0x10000 |
305 | org $+0x10000 |
306 | use32 |
306 | use32 |
307 | 307 | ||
308 | __DEBUG__ fix 1 |
308 | __DEBUG__ fix 1 |
309 | __DEBUG_LEVEL__ fix 1 |
309 | __DEBUG_LEVEL__ fix 1 |
310 | include 'init.inc' |
310 | include 'init.inc' |
311 | 311 | ||
312 | org OS_BASE+$ |
312 | org OS_BASE+$ |
313 | 313 | ||
314 | include 'fdo.inc' |
314 | include 'fdo.inc' |
315 | 315 | ||
316 | align 4 |
316 | align 4 |
317 | high_code: |
317 | high_code: |
318 | mov ax, os_stack |
318 | mov ax, os_stack |
319 | mov bx, app_data |
319 | mov bx, app_data |
320 | mov cx, app_tls |
320 | mov cx, app_tls |
321 | mov ss, ax |
321 | mov ss, ax |
322 | add esp, OS_BASE |
322 | add esp, OS_BASE |
323 | 323 | ||
324 | mov ds, bx |
324 | mov ds, bx |
325 | mov es, bx |
325 | mov es, bx |
326 | mov fs, cx |
326 | mov fs, cx |
327 | mov gs, bx |
327 | mov gs, bx |
328 | 328 | ||
329 | bt [cpu_caps], CAPS_PGE |
329 | bt [cpu_caps], CAPS_PGE |
330 | jnc @F |
330 | jnc @F |
331 | 331 | ||
332 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
332 | or dword [sys_pgdir+(OS_BASE shr 20)], PG_GLOBAL |
333 | 333 | ||
334 | mov ebx, cr4 |
334 | mov ebx, cr4 |
335 | or ebx, CR4_PGE |
335 | or ebx, CR4_PGE |
336 | mov cr4, ebx |
336 | mov cr4, ebx |
337 | @@: |
337 | @@: |
338 | xor eax, eax |
338 | xor eax, eax |
339 | mov dword [sys_pgdir], eax |
339 | mov dword [sys_pgdir], eax |
340 | mov dword [sys_pgdir+4], eax |
340 | mov dword [sys_pgdir+4], eax |
341 | 341 | ||
342 | mov eax, cr3 |
342 | mov eax, cr3 |
343 | mov cr3, eax ; flush TLB |
343 | mov cr3, eax ; flush TLB |
344 | 344 | ||
345 | mov ecx, pg_data.mutex |
345 | mov ecx, pg_data.mutex |
346 | call mutex_init |
346 | call mutex_init |
347 | 347 | ||
348 | mov ecx, disk_list_mutex |
348 | mov ecx, disk_list_mutex |
349 | call mutex_init |
349 | call mutex_init |
350 | 350 | ||
351 | mov ecx, keyboard_list_mutex |
351 | mov ecx, keyboard_list_mutex |
352 | call mutex_init |
352 | call mutex_init |
353 | 353 | ||
354 | mov ecx, unpack_mutex |
354 | mov ecx, unpack_mutex |
355 | call mutex_init |
355 | call mutex_init |
356 | 356 | ||
357 | mov ecx, application_table_mutex |
357 | mov ecx, application_table_mutex |
358 | call mutex_init |
358 | call mutex_init |
359 | 359 | ||
360 | ; SAVE REAL MODE VARIABLES |
360 | ; SAVE REAL MODE VARIABLES |
- | 361 | xor eax,eax |
|
- | 362 | mov ax, [BOOT_VAR + BOOT_IDE_PI_16] |
|
- | 363 | mov [IDEContrProgrammingInterface], ax |
|
361 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
364 | mov ax, [BOOT_VAR + BOOT_IDE_BASE_ADDR] |
362 | mov [IDEContrRegsBaseAddr], ax |
365 | mov [IDEContrRegsBaseAddr], ax |
- | 366 | mov ax, [BOOT_VAR + BOOT_IDE_BAR0_16] |
|
- | 367 | mov [IDE_BAR0_val], ax |
|
- | 368 | ||
- | 369 | cmp ax,0 |
|
- | 370 | je @f |
|
- | 371 | cmp ax,1 |
|
- | 372 | je @f |
|
- | 373 | and ax,0xfff0 |
|
- | 374 | mov [StandardATABases],ax |
|
- | 375 | mov [hd_address_table],eax |
|
- | 376 | mov [hd_address_table+8],eax |
|
- | 377 | @@: |
|
- | 378 | mov ax, [BOOT_VAR + BOOT_IDE_BAR1_16] |
|
- | 379 | mov [IDE_BAR1_val], ax |
|
- | 380 | mov ax, [BOOT_VAR + BOOT_IDE_BAR2_16] |
|
- | 381 | mov [IDE_BAR2_val], ax |
|
- | 382 | ||
- | 383 | cmp ax,0 |
|
- | 384 | je @f |
|
- | 385 | cmp ax,1 |
|
- | 386 | je @f |
|
- | 387 | and ax,0xfff0 |
|
- | 388 | mov [StandardATABases+2],ax |
|
- | 389 | mov [hd_address_table+16],eax |
|
- | 390 | mov [hd_address_table+24],eax |
|
- | 391 | @@: |
|
- | 392 | mov ax, [BOOT_VAR + BOOT_IDE_BAR3_16] |
|
- | 393 | mov [IDE_BAR3_val], ax |
|
- | 394 | ||
363 | ; --------------- APM --------------------- |
395 | ; --------------- APM --------------------- |
364 | 396 | ||
365 | ; init selectors |
397 | ; init selectors |
366 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
398 | mov ebx, [BOOT_VAR+BOOT_APM_ENTRY] ; offset of APM entry point |
367 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
399 | movzx eax, word [BOOT_VAR+BOOT_APM_CODE_32] ; real-mode segment base address of |
368 | ; protected-mode 32-bit code segment |
400 | ; protected-mode 32-bit code segment |
369 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
401 | movzx ecx, word [BOOT_VAR+BOOT_APM_CODE_16]; real-mode segment base address of |
370 | ; protected-mode 16-bit code segment |
402 | ; protected-mode 16-bit code segment |
371 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
403 | movzx edx, word [BOOT_VAR+BOOT_APM_DATA_16]; real-mode segment base address of |
372 | ; protected-mode 16-bit data segment |
404 | ; protected-mode 16-bit data segment |
373 | 405 | ||
374 | shl eax, 4 |
406 | shl eax, 4 |
375 | mov [dword apm_code_32 + 2], ax |
407 | mov [dword apm_code_32 + 2], ax |
376 | shr eax, 16 |
408 | shr eax, 16 |
377 | mov [dword apm_code_32 + 4], al |
409 | mov [dword apm_code_32 + 4], al |
378 | 410 | ||
379 | shl ecx, 4 |
411 | shl ecx, 4 |
380 | mov [dword apm_code_16 + 2], cx |
412 | mov [dword apm_code_16 + 2], cx |
381 | shr ecx, 16 |
413 | shr ecx, 16 |
382 | mov [dword apm_code_16 + 4], cl |
414 | mov [dword apm_code_16 + 4], cl |
383 | 415 | ||
384 | shl edx, 4 |
416 | shl edx, 4 |
385 | mov [dword apm_data_16 + 2], dx |
417 | mov [dword apm_data_16 + 2], dx |
386 | shr edx, 16 |
418 | shr edx, 16 |
387 | mov [dword apm_data_16 + 4], dl |
419 | mov [dword apm_data_16 + 4], dl |
388 | 420 | ||
389 | mov dword[apm_entry], ebx |
421 | mov dword[apm_entry], ebx |
390 | mov word [apm_entry + 4], apm_code_32 - gdts |
422 | mov word [apm_entry + 4], apm_code_32 - gdts |
391 | 423 | ||
392 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
424 | mov eax, [BOOT_VAR + BOOT_APM_VERSION] ; version & flags |
393 | mov [apm_vf], eax |
425 | mov [apm_vf], eax |
394 | ; ----------------------------------------- |
426 | ; ----------------------------------------- |
395 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
427 | mov al, [BOOT_VAR+BOOT_DMA] ; DMA access |
396 | mov [allow_dma_access], al |
428 | mov [allow_dma_access], al |
397 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
429 | movzx eax, byte [BOOT_VAR+BOOT_BPP] ; bpp |
398 | mov [_display.bpp], eax |
430 | mov [_display.bpp], eax |
399 | mov [_display.vrefresh], 60 |
431 | mov [_display.vrefresh], 60 |
400 | 432 | ||
401 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
433 | movzx eax, word [BOOT_VAR+BOOT_X_RES]; X max |
402 | mov [_display.width], eax |
434 | mov [_display.width], eax |
403 | mov [display_width_standard], eax |
435 | mov [display_width_standard], eax |
404 | dec eax |
436 | dec eax |
405 | mov [Screen_Max_X], eax |
437 | mov [Screen_Max_X], eax |
406 | mov [screen_workarea.right], eax |
438 | mov [screen_workarea.right], eax |
407 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
439 | movzx eax, word [BOOT_VAR+BOOT_Y_RES]; Y max |
408 | mov [_display.height], eax |
440 | mov [_display.height], eax |
409 | mov [display_height_standard], eax |
441 | mov [display_height_standard], eax |
410 | dec eax |
442 | dec eax |
411 | mov [Screen_Max_Y], eax |
443 | mov [Screen_Max_Y], eax |
412 | mov [screen_workarea.bottom], eax |
444 | mov [screen_workarea.bottom], eax |
413 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE] ; screen mode |
445 | movzx eax, word [BOOT_VAR+BOOT_VESA_MODE] ; screen mode |
414 | mov dword [SCR_MODE], eax |
446 | mov dword [SCR_MODE], eax |
415 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
447 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
416 | ; mov [BANK_SWITCH], eax |
448 | ; mov [BANK_SWITCH], eax |
417 | mov eax, 640 *4 ; Bytes PerScanLine |
449 | mov eax, 640 *4 ; Bytes PerScanLine |
418 | cmp [SCR_MODE], word 0x13 ; 320x200 |
450 | cmp [SCR_MODE], word 0x13 ; 320x200 |
419 | je @f |
451 | je @f |
420 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
452 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
421 | je @f |
453 | je @f |
422 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
454 | movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes |
423 | @@: |
455 | @@: |
424 | mov [_display.pitch], eax |
456 | mov [_display.pitch], eax |
425 | mov eax, [_display.width] |
457 | mov eax, [_display.width] |
426 | mul [_display.height] |
458 | mul [_display.height] |
427 | mov [_WinMapSize], eax |
459 | mov [_WinMapSize], eax |
428 | 460 | ||
429 | call calculate_fast_getting_offset_for_WinMapAddress |
461 | call calculate_fast_getting_offset_for_WinMapAddress |
430 | ; for Qemu or non standart video cards |
462 | ; for Qemu or non standart video cards |
431 | ; Unfortunately [BytesPerScanLine] does not always |
463 | ; Unfortunately [BytesPerScanLine] does not always |
432 | ; equal to [_display.width] * [ScreenBPP] / 8 |
464 | ; equal to [_display.width] * [ScreenBPP] / 8 |
433 | call calculate_fast_getting_offset_for_LFB |
465 | call calculate_fast_getting_offset_for_LFB |
434 | 466 | ||
435 | mov esi, BOOT_VAR+0x9080 |
467 | mov esi, BOOT_VAR+0x9080 |
436 | movzx ecx, byte [esi-1] |
468 | movzx ecx, byte [esi-1] |
437 | mov [NumBiosDisks], ecx |
469 | mov [NumBiosDisks], ecx |
438 | mov edi, BiosDisksData |
470 | mov edi, BiosDisksData |
439 | rep movsd |
471 | rep movsd |
440 | 472 | ||
441 | ; GRAPHICS ADDRESSES |
473 | ; GRAPHICS ADDRESSES |
442 | 474 | ||
443 | mov eax, [BOOT_VAR+BOOT_LFB] |
475 | mov eax, [BOOT_VAR+BOOT_LFB] |
444 | mov [LFBAddress], eax |
476 | mov [LFBAddress], eax |
445 | 477 | ||
446 | cmp [SCR_MODE], word 0100000000000000b |
478 | cmp [SCR_MODE], word 0100000000000000b |
447 | jge setvesa20 |
479 | jge setvesa20 |
448 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
480 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
449 | je v20ga32 |
481 | je v20ga32 |
450 | jmp v20ga24 |
482 | jmp v20ga24 |
451 | 483 | ||
452 | setvesa20: |
484 | setvesa20: |
453 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
485 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
454 | mov [GETPIXEL], dword Vesa20_getpixel24 |
486 | mov [GETPIXEL], dword Vesa20_getpixel24 |
455 | cmp byte [_display.bpp], 24 |
487 | cmp byte [_display.bpp], 24 |
456 | jz v20ga24 |
488 | jz v20ga24 |
457 | v20ga32: |
489 | v20ga32: |
458 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
490 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
459 | mov [GETPIXEL], dword Vesa20_getpixel32 |
491 | mov [GETPIXEL], dword Vesa20_getpixel32 |
460 | jmp no_mode_0x12 |
492 | jmp no_mode_0x12 |
461 | v20ga24: |
493 | v20ga24: |
462 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
494 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
463 | jne no_mode_0x12 |
495 | jne no_mode_0x12 |
464 | mov [PUTPIXEL], dword VGA_putpixel |
496 | mov [PUTPIXEL], dword VGA_putpixel |
465 | mov [GETPIXEL], dword Vesa20_getpixel32 |
497 | mov [GETPIXEL], dword Vesa20_getpixel32 |
466 | no_mode_0x12: |
498 | no_mode_0x12: |
467 | 499 | ||
468 | mov [MOUSE_PICTURE], dword mousepointer |
500 | mov [MOUSE_PICTURE], dword mousepointer |
469 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
501 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
470 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
502 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
471 | 503 | ||
472 | ; -------- Fast System Call init ---------- |
504 | ; -------- Fast System Call init ---------- |
473 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
505 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
474 | bt [cpu_caps], CAPS_SEP |
506 | bt [cpu_caps], CAPS_SEP |
475 | jnc .SEnP ; SysEnter not Present |
507 | jnc .SEnP ; SysEnter not Present |
476 | xor edx, edx |
508 | xor edx, edx |
477 | mov ecx, MSR_SYSENTER_CS |
509 | mov ecx, MSR_SYSENTER_CS |
478 | mov eax, os_code |
510 | mov eax, os_code |
479 | wrmsr |
511 | wrmsr |
480 | mov ecx, MSR_SYSENTER_ESP |
512 | mov ecx, MSR_SYSENTER_ESP |
481 | ; mov eax, sysenter_stack ; Check it |
513 | ; mov eax, sysenter_stack ; Check it |
482 | xor eax, eax |
514 | xor eax, eax |
483 | wrmsr |
515 | wrmsr |
484 | mov ecx, MSR_SYSENTER_EIP |
516 | mov ecx, MSR_SYSENTER_EIP |
485 | mov eax, sysenter_entry |
517 | mov eax, sysenter_entry |
486 | wrmsr |
518 | wrmsr |
487 | .SEnP: |
519 | .SEnP: |
488 | ; AMD SYSCALL/SYSRET |
520 | ; AMD SYSCALL/SYSRET |
489 | cmp byte[cpu_vendor], 'A' |
521 | cmp byte[cpu_vendor], 'A' |
490 | jne .noSYSCALL |
522 | jne .noSYSCALL |
491 | mov eax, 0x80000001 |
523 | mov eax, 0x80000001 |
492 | cpuid |
524 | cpuid |
493 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
525 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
494 | jz .noSYSCALL |
526 | jz .noSYSCALL |
495 | mov ecx, MSR_AMD_EFER |
527 | mov ecx, MSR_AMD_EFER |
496 | rdmsr |
528 | rdmsr |
497 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
529 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
498 | wrmsr |
530 | wrmsr |
499 | 531 | ||
500 | ; !!!! It`s dirty hack, fix it !!! |
532 | ; !!!! It`s dirty hack, fix it !!! |
501 | ; Bits of EDX : |
533 | ; Bits of EDX : |
502 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
534 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
503 | ; and the contents of this field, plus 8, are copied into the SS register. |
535 | ; and the contents of this field, plus 8, are copied into the SS register. |
504 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
536 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
505 | ; and the contents of this field, plus 8, are copied into the SS register. |
537 | ; and the contents of this field, plus 8, are copied into the SS register. |
506 | 538 | ||
507 | ; mov edx, (os_code + 16) * 65536 + os_code |
539 | ; mov edx, (os_code + 16) * 65536 + os_code |
508 | mov edx, 0x1B0008 |
540 | mov edx, 0x1B0008 |
509 | 541 | ||
510 | mov eax, syscall_entry |
542 | mov eax, syscall_entry |
511 | mov ecx, MSR_AMD_STAR |
543 | mov ecx, MSR_AMD_STAR |
512 | wrmsr |
544 | wrmsr |
513 | .noSYSCALL: |
545 | .noSYSCALL: |
514 | ; ----------------------------------------- |
546 | ; ----------------------------------------- |
515 | stdcall alloc_page |
547 | stdcall alloc_page |
516 | stdcall map_page, tss-0xF80, eax, PG_SW |
548 | stdcall map_page, tss-0xF80, eax, PG_SW |
517 | stdcall alloc_page |
549 | stdcall alloc_page |
518 | stdcall map_page, tss+0x80, eax, PG_SW |
550 | stdcall map_page, tss+0x80, eax, PG_SW |
519 | stdcall alloc_page |
551 | stdcall alloc_page |
520 | stdcall map_page, tss+0x1080, eax, PG_SW |
552 | stdcall map_page, tss+0x1080, eax, PG_SW |
521 | 553 | ||
522 | ; LOAD IDT |
554 | ; LOAD IDT |
523 | 555 | ||
524 | call build_interrupt_table ;lidt is executed |
556 | call build_interrupt_table ;lidt is executed |
525 | ;lidt [idtreg] |
557 | ;lidt [idtreg] |
526 | 558 | ||
527 | call init_kernel_heap |
559 | call init_kernel_heap |
528 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
560 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
529 | mov [os_stack_seg], eax |
561 | mov [os_stack_seg], eax |
530 | 562 | ||
531 | lea esp, [eax+RING0_STACK_SIZE] |
563 | lea esp, [eax+RING0_STACK_SIZE] |
532 | 564 | ||
533 | mov [tss._ss0], os_stack |
565 | mov [tss._ss0], os_stack |
534 | mov [tss._esp0], esp |
566 | mov [tss._esp0], esp |
535 | mov [tss._esp], esp |
567 | mov [tss._esp], esp |
536 | mov [tss._cs], os_code |
568 | mov [tss._cs], os_code |
537 | mov [tss._ss], os_stack |
569 | mov [tss._ss], os_stack |
538 | mov [tss._ds], app_data |
570 | mov [tss._ds], app_data |
539 | mov [tss._es], app_data |
571 | mov [tss._es], app_data |
540 | mov [tss._fs], app_data |
572 | mov [tss._fs], app_data |
541 | mov [tss._gs], app_data |
573 | mov [tss._gs], app_data |
542 | mov [tss._io], 128 |
574 | mov [tss._io], 128 |
543 | ;Add IO access table - bit array of permitted ports |
575 | ;Add IO access table - bit array of permitted ports |
544 | mov edi, tss._io_map_0 |
576 | mov edi, tss._io_map_0 |
545 | xor eax, eax |
577 | xor eax, eax |
546 | not eax |
578 | not eax |
547 | mov ecx, 8192/4 |
579 | mov ecx, 8192/4 |
548 | rep stosd ; access to 4096*8=65536 ports |
580 | rep stosd ; access to 4096*8=65536 ports |
549 | 581 | ||
550 | mov ax, tss0 |
582 | mov ax, tss0 |
551 | ltr ax |
583 | ltr ax |
552 | 584 | ||
553 | mov [LFBSize], 0xC00000 |
585 | mov [LFBSize], 0xC00000 |
554 | call init_LFB |
586 | call init_LFB |
555 | call init_fpu |
587 | call init_fpu |
556 | call init_malloc |
588 | call init_malloc |
557 | 589 | ||
558 | stdcall alloc_kernel_space, 0x51000 |
590 | stdcall alloc_kernel_space, 0x51000 |
559 | mov [default_io_map], eax |
591 | mov [default_io_map], eax |
560 | 592 | ||
561 | add eax, 0x2000 |
593 | add eax, 0x2000 |
562 | mov [ipc_tmp], eax |
594 | mov [ipc_tmp], eax |
563 | mov ebx, 0x1000 |
595 | mov ebx, 0x1000 |
564 | 596 | ||
565 | add eax, 0x40000 |
597 | add eax, 0x40000 |
566 | mov [proc_mem_map], eax |
598 | mov [proc_mem_map], eax |
567 | 599 | ||
568 | add eax, 0x8000 |
600 | add eax, 0x8000 |
569 | mov [proc_mem_pdir], eax |
601 | mov [proc_mem_pdir], eax |
570 | 602 | ||
571 | add eax, ebx |
603 | add eax, ebx |
572 | mov [proc_mem_tab], eax |
604 | mov [proc_mem_tab], eax |
573 | 605 | ||
574 | add eax, ebx |
606 | add eax, ebx |
575 | mov [tmp_task_pdir], eax |
607 | mov [tmp_task_pdir], eax |
576 | 608 | ||
577 | add eax, ebx |
609 | add eax, ebx |
578 | mov [tmp_task_ptab], eax |
610 | mov [tmp_task_ptab], eax |
579 | 611 | ||
580 | add eax, ebx |
612 | add eax, ebx |
581 | mov [ipc_pdir], eax |
613 | mov [ipc_pdir], eax |
582 | 614 | ||
583 | add eax, ebx |
615 | add eax, ebx |
584 | mov [ipc_ptab], eax |
616 | mov [ipc_ptab], eax |
585 | 617 | ||
586 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
618 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
587 | (unpack.lc+unpack.lp)))*4 |
619 | (unpack.lc+unpack.lp)))*4 |
588 | 620 | ||
589 | mov [unpack.p], eax |
621 | mov [unpack.p], eax |
590 | 622 | ||
591 | call init_events |
623 | call init_events |
592 | mov eax, srv.fd-SRV.fd |
624 | mov eax, srv.fd-SRV.fd |
593 | mov [srv.fd], eax |
625 | mov [srv.fd], eax |
594 | mov [srv.bk], eax |
626 | mov [srv.bk], eax |
595 | 627 | ||
596 | ;Set base of graphic segment to linear address of LFB |
628 | ;Set base of graphic segment to linear address of LFB |
597 | mov eax, [LFBAddress] ; set for gs |
629 | mov eax, [LFBAddress] ; set for gs |
598 | mov [graph_data_l+2], ax |
630 | mov [graph_data_l+2], ax |
599 | shr eax, 16 |
631 | shr eax, 16 |
600 | mov [graph_data_l+4], al |
632 | mov [graph_data_l+4], al |
601 | mov [graph_data_l+7], ah |
633 | mov [graph_data_l+7], ah |
602 | 634 | ||
603 | stdcall kernel_alloc, [_WinMapSize] |
635 | stdcall kernel_alloc, [_WinMapSize] |
604 | mov [_WinMapAddress], eax |
636 | mov [_WinMapAddress], eax |
605 | 637 | ||
606 | xor eax, eax |
638 | xor eax, eax |
607 | inc eax |
639 | inc eax |
608 | 640 | ||
609 | ; set background |
641 | ; set background |
610 | 642 | ||
611 | mov [BgrDrawMode], eax |
643 | mov [BgrDrawMode], eax |
612 | mov [BgrDataWidth], eax |
644 | mov [BgrDataWidth], eax |
613 | mov [BgrDataHeight], eax |
645 | mov [BgrDataHeight], eax |
614 | mov [mem_BACKGROUND], 4 |
646 | mov [mem_BACKGROUND], 4 |
615 | mov [img_background], static_background_data |
647 | mov [img_background], static_background_data |
616 | 648 | ||
617 | ; SET UP OS TASK |
649 | ; SET UP OS TASK |
618 | 650 | ||
619 | mov esi, boot_setostask |
651 | mov esi, boot_setostask |
620 | call boot_log |
652 | call boot_log |
621 | 653 | ||
622 | mov edx, SLOT_BASE+256 |
654 | mov edx, SLOT_BASE+256 |
623 | mov ebx, [os_stack_seg] |
655 | mov ebx, [os_stack_seg] |
624 | add ebx, 0x2000 |
656 | add ebx, 0x2000 |
625 | call setup_os_slot |
657 | call setup_os_slot |
626 | mov dword [edx], 'IDLE' |
658 | mov dword [edx], 'IDLE' |
627 | sub [edx+APPDATA.saved_esp], 4 |
659 | sub [edx+APPDATA.saved_esp], 4 |
628 | mov eax, [edx+APPDATA.saved_esp] |
660 | mov eax, [edx+APPDATA.saved_esp] |
629 | mov dword [eax], idle_thread |
661 | mov dword [eax], idle_thread |
630 | mov ecx, IDLE_PRIORITY |
662 | mov ecx, IDLE_PRIORITY |
631 | call scheduler_add_thread |
663 | call scheduler_add_thread |
632 | 664 | ||
633 | mov edx, SLOT_BASE+256*2 |
665 | mov edx, SLOT_BASE+256*2 |
634 | mov ebx, [os_stack_seg] |
666 | mov ebx, [os_stack_seg] |
635 | call setup_os_slot |
667 | call setup_os_slot |
636 | mov dword [edx], 'OS' |
668 | mov dword [edx], 'OS' |
637 | xor ecx, ecx |
669 | xor ecx, ecx |
638 | call scheduler_add_thread |
670 | call scheduler_add_thread |
639 | 671 | ||
640 | mov dword [CURRENT_TASK], 2 |
672 | mov dword [CURRENT_TASK], 2 |
641 | mov dword [TASK_COUNT], 2 |
673 | mov dword [TASK_COUNT], 2 |
642 | mov dword [current_slot], SLOT_BASE + 256*2 |
674 | mov dword [current_slot], SLOT_BASE + 256*2 |
643 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
675 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
644 | 676 | ||
645 | 677 | ||
646 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
678 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
647 | mov esi, boot_initirq |
679 | mov esi, boot_initirq |
648 | call boot_log |
680 | call boot_log |
649 | call init_irqs |
681 | call init_irqs |
650 | 682 | ||
651 | mov esi, boot_picinit |
683 | mov esi, boot_picinit |
652 | call boot_log |
684 | call boot_log |
653 | call PIC_init |
685 | call PIC_init |
654 | 686 | ||
655 | mov esi, boot_v86machine |
687 | mov esi, boot_v86machine |
656 | call boot_log |
688 | call boot_log |
657 | ; Initialize system V86 machine |
689 | ; Initialize system V86 machine |
658 | call init_sys_v86 |
690 | call init_sys_v86 |
659 | 691 | ||
660 | mov esi, boot_inittimer |
692 | mov esi, boot_inittimer |
661 | call boot_log |
693 | call boot_log |
662 | ; Initialize system timer (IRQ0) |
694 | ; Initialize system timer (IRQ0) |
663 | call PIT_init |
695 | call PIT_init |
664 | 696 | ||
665 | ; CALCULATE FAT CHAIN FOR RAMDISK |
697 | ; CALCULATE FAT CHAIN FOR RAMDISK |
666 | 698 | ||
667 | call calculatefatchain |
699 | call calculatefatchain |
668 | 700 | ||
669 | mov esi, boot_initapic |
701 | mov esi, boot_initapic |
670 | call boot_log |
702 | call boot_log |
671 | ; Try to Initialize APIC |
703 | ; Try to Initialize APIC |
672 | call APIC_init |
704 | call APIC_init |
673 | 705 | ||
674 | mov esi, boot_enableirq |
706 | mov esi, boot_enableirq |
675 | call boot_log |
707 | call boot_log |
676 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
708 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
677 | ; they are used: when partitions are scanned, hd_read relies on timer |
709 | ; they are used: when partitions are scanned, hd_read relies on timer |
678 | call unmask_timer |
710 | call unmask_timer |
679 | stdcall enable_irq, 2 ; @#$%! PIC |
711 | stdcall enable_irq, 2 ; @#$%! PIC |
680 | stdcall enable_irq, 6 ; FDD |
712 | stdcall enable_irq, 6 ; FDD |
681 | stdcall enable_irq, 13 ; co-processor |
713 | stdcall enable_irq, 13 ; co-processor |
682 | stdcall enable_irq, 14 |
714 | stdcall enable_irq, 14 |
683 | stdcall enable_irq, 15 |
715 | stdcall enable_irq, 15 |
684 | 716 | ||
685 | mov esi, boot_enablint_ide |
717 | mov esi, boot_enablint_ide |
686 | call boot_log |
718 | call boot_log |
687 | ; Enable interrupts in IDE controller |
719 | ; Enable interrupts in IDE controller |
688 | mov al, 0 |
720 | mov al, 0 |
689 | mov dx, 0x3F6 |
721 | mov dx, 0x3F6 |
690 | out dx, al |
722 | out dx, al |
691 | mov dl, 0x76 |
723 | mov dl, 0x76 |
692 | out dx, al |
724 | out dx, al |
693 | 725 | ||
694 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
726 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
695 | ; mov esi, boot_detectdisks |
727 | ; mov esi, boot_detectdisks |
696 | ; call boot_log |
728 | ; call boot_log |
697 | ;include 'detect/disks.inc' |
729 | ;include 'detect/disks.inc' |
698 | mov esi, boot_detectfloppy |
730 | mov esi, boot_detectfloppy |
699 | call boot_log |
731 | call boot_log |
700 | include 'detect/dev_fd.inc' |
732 | include 'detect/dev_fd.inc' |
701 | mov esi, boot_detecthdcd |
733 | mov esi, boot_detecthdcd |
702 | call boot_log |
734 | call boot_log |
703 | include 'detect/dev_hdcd.inc' |
735 | include 'detect/dev_hdcd.inc' |
704 | mov esi, boot_getcache |
736 | mov esi, boot_getcache |
705 | call boot_log |
737 | call boot_log |
706 | include 'detect/getcache.inc' |
738 | include 'detect/getcache.inc' |
707 | mov esi, boot_detectpart |
739 | mov esi, boot_detectpart |
708 | call boot_log |
740 | call boot_log |
709 | include 'detect/sear_par.inc' |
741 | include 'detect/sear_par.inc' |
710 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
742 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
711 | 743 | ||
712 | mov esi, boot_init_sys |
744 | mov esi, boot_init_sys |
713 | call boot_log |
745 | call boot_log |
714 | call Parser_params |
746 | call Parser_params |
715 | 747 | ||
716 | if ~ defined extended_primary_loader |
748 | if ~ defined extended_primary_loader |
717 | ; ramdisk image should be loaded by extended primary loader if it exists |
749 | ; ramdisk image should be loaded by extended primary loader if it exists |
718 | ; READ RAMDISK IMAGE FROM HD |
750 | ; READ RAMDISK IMAGE FROM HD |
719 | 751 | ||
720 | ;!!!!!!!!!!!!!!!!!!!!!!! |
752 | ;!!!!!!!!!!!!!!!!!!!!!!! |
721 | include 'boot/rdload.inc' |
753 | include 'boot/rdload.inc' |
722 | ;!!!!!!!!!!!!!!!!!!!!!!! |
754 | ;!!!!!!!!!!!!!!!!!!!!!!! |
723 | end if |
755 | end if |
724 | ; mov [dma_hdd],1 |
756 | ; mov [dma_hdd],1 |
725 | 757 | ||
726 | if 0 |
758 | if 0 |
727 | mov ax, [OS_BASE+0x10000+bx_from_load] |
759 | mov ax, [OS_BASE+0x10000+bx_from_load] |
728 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
760 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
729 | je no_lib_load |
761 | je no_lib_load |
730 | 762 | ||
731 | mov esi, boot_loadlibs |
763 | mov esi, boot_loadlibs |
732 | call boot_log |
764 | call boot_log |
733 | ; LOADING LIBRARES |
765 | ; LOADING LIBRARES |
734 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
766 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
735 | call load_file_parse_table ; prepare file parse table |
767 | call load_file_parse_table ; prepare file parse table |
736 | call set_kernel_conf ; configure devices and gui |
768 | call set_kernel_conf ; configure devices and gui |
737 | no_lib_load: |
769 | no_lib_load: |
738 | end if |
770 | end if |
739 | 771 | ||
740 | ; Display APIC status |
772 | ; Display APIC status |
741 | mov esi, boot_APIC_found |
773 | mov esi, boot_APIC_found |
742 | cmp [irq_mode], IRQ_APIC |
774 | cmp [irq_mode], IRQ_APIC |
743 | je @f |
775 | je @f |
744 | mov esi, boot_APIC_nfound |
776 | mov esi, boot_APIC_nfound |
745 | @@: |
777 | @@: |
746 | call boot_log |
778 | call boot_log |
747 | 779 | ||
748 | ; PRINT AMOUNT OF MEMORY |
780 | ; PRINT AMOUNT OF MEMORY |
749 | mov esi, boot_memdetect |
781 | mov esi, boot_memdetect |
750 | call boot_log |
782 | call boot_log |
751 | 783 | ||
752 | movzx ecx, word [boot_y] |
784 | movzx ecx, word [boot_y] |
753 | if lang eq ru |
785 | if lang eq ru |
754 | or ecx, (10+30*6) shl 16 |
786 | or ecx, (10+30*6) shl 16 |
755 | else if lang eq sp |
787 | else if lang eq sp |
756 | or ecx, (10+33*6) shl 16 |
788 | or ecx, (10+33*6) shl 16 |
757 | else |
789 | else |
758 | or ecx, (10+29*6) shl 16 |
790 | or ecx, (10+29*6) shl 16 |
759 | end if |
791 | end if |
760 | sub ecx, 10 |
792 | sub ecx, 10 |
761 | mov edx, 0xFFFFFF |
793 | mov edx, 0xFFFFFF |
762 | mov ebx, [MEM_AMOUNT] |
794 | mov ebx, [MEM_AMOUNT] |
763 | shr ebx, 20 |
795 | shr ebx, 20 |
764 | xor edi, edi |
796 | xor edi, edi |
765 | mov eax, 0x00040000 |
797 | mov eax, 0x00040000 |
766 | inc edi |
798 | inc edi |
767 | call display_number_force |
799 | call display_number_force |
768 | 800 | ||
769 | ; BUILD SCHEDULER |
801 | ; BUILD SCHEDULER |
770 | 802 | ||
771 | ; call build_scheduler; sys32.inc |
803 | ; call build_scheduler; sys32.inc |
772 | 804 | ||
773 | ; mov esi, boot_devices |
805 | ; mov esi, boot_devices |
774 | ; call boot_log |
806 | ; call boot_log |
775 | 807 | ||
776 | mov [pci_access_enabled], 1 |
808 | mov [pci_access_enabled], 1 |
777 | call pci_enum |
809 | call pci_enum |
778 | 810 | ||
779 | stdcall load_driver, szVidintel |
811 | stdcall load_driver, szVidintel |
780 | 812 | ||
781 | call usb_init |
813 | call usb_init |
782 | 814 | ||
783 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
815 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
784 | 816 | ||
785 | mov esi, boot_windefs |
817 | mov esi, boot_windefs |
786 | call boot_log |
818 | call boot_log |
787 | call set_window_defaults |
819 | call set_window_defaults |
788 | 820 | ||
789 | ; SET BACKGROUND DEFAULTS |
821 | ; SET BACKGROUND DEFAULTS |
790 | 822 | ||
791 | mov esi, boot_bgr |
823 | mov esi, boot_bgr |
792 | call boot_log |
824 | call boot_log |
793 | call init_background |
825 | call init_background |
794 | call calculatebackground |
826 | call calculatebackground |
795 | 827 | ||
796 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
828 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
797 | 829 | ||
798 | mov esi, boot_resirqports |
830 | mov esi, boot_resirqports |
799 | call boot_log |
831 | call boot_log |
800 | call reserve_irqs_ports |
832 | call reserve_irqs_ports |
801 | 833 | ||
802 | call init_display |
834 | call init_display |
803 | mov eax, [def_cursor] |
835 | mov eax, [def_cursor] |
804 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
836 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
805 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
837 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
806 | 838 | ||
807 | ; PRINT CPU FREQUENCY |
839 | ; PRINT CPU FREQUENCY |
808 | 840 | ||
809 | mov esi, boot_cpufreq |
841 | mov esi, boot_cpufreq |
810 | call boot_log |
842 | call boot_log |
811 | 843 | ||
812 | cli ;FIXME check IF |
844 | cli ;FIXME check IF |
813 | rdtsc |
845 | rdtsc |
814 | mov ecx, eax |
846 | mov ecx, eax |
815 | mov esi, 250 ; wait 1/4 a second |
847 | mov esi, 250 ; wait 1/4 a second |
816 | call delay_ms |
848 | call delay_ms |
817 | rdtsc |
849 | rdtsc |
818 | 850 | ||
819 | sub eax, ecx |
851 | sub eax, ecx |
820 | xor edx, edx |
852 | xor edx, edx |
821 | shld edx, eax, 2 |
853 | shld edx, eax, 2 |
822 | shl eax, 2 |
854 | shl eax, 2 |
823 | mov dword [cpu_freq], eax |
855 | mov dword [cpu_freq], eax |
824 | mov dword [cpu_freq+4], edx |
856 | mov dword [cpu_freq+4], edx |
825 | mov ebx, 1000000 |
857 | mov ebx, 1000000 |
826 | div ebx |
858 | div ebx |
827 | mov ebx, eax |
859 | mov ebx, eax |
828 | 860 | ||
829 | movzx ecx, word [boot_y] |
861 | movzx ecx, word [boot_y] |
830 | if lang eq ru |
862 | if lang eq ru |
831 | add ecx, (10+19*6) shl 16 - 10 |
863 | add ecx, (10+19*6) shl 16 - 10 |
832 | else if lang eq sp |
864 | else if lang eq sp |
833 | add ecx, (10+25*6) shl 16 - 10 |
865 | add ecx, (10+25*6) shl 16 - 10 |
834 | else |
866 | else |
835 | add ecx, (10+17*6) shl 16 - 10 |
867 | add ecx, (10+17*6) shl 16 - 10 |
836 | end if |
868 | end if |
837 | 869 | ||
838 | mov edx, 0xFFFFFF |
870 | mov edx, 0xFFFFFF |
839 | xor edi, edi |
871 | xor edi, edi |
840 | mov eax, 0x00040000 |
872 | mov eax, 0x00040000 |
841 | inc edi |
873 | inc edi |
842 | call display_number_force |
874 | call display_number_force |
843 | 875 | ||
844 | ; SET VARIABLES |
876 | ; SET VARIABLES |
845 | 877 | ||
846 | call set_variables |
878 | call set_variables |
847 | 879 | ||
848 | ; STACK AND FDC |
880 | ; STACK AND FDC |
849 | 881 | ||
850 | call stack_init |
882 | call stack_init |
851 | call fdc_init |
883 | call fdc_init |
852 | 884 | ||
853 | ; PALETTE FOR 320x200 and 640x480 16 col |
885 | ; PALETTE FOR 320x200 and 640x480 16 col |
854 | 886 | ||
855 | cmp [SCR_MODE], word 0x12 |
887 | cmp [SCR_MODE], word 0x12 |
856 | jne no_pal_vga |
888 | jne no_pal_vga |
857 | mov esi, boot_pal_vga |
889 | mov esi, boot_pal_vga |
858 | call boot_log |
890 | call boot_log |
859 | call paletteVGA |
891 | call paletteVGA |
860 | no_pal_vga: |
892 | no_pal_vga: |
861 | 893 | ||
862 | cmp [SCR_MODE], word 0x13 |
894 | cmp [SCR_MODE], word 0x13 |
863 | jne no_pal_ega |
895 | jne no_pal_ega |
864 | mov esi, boot_pal_ega |
896 | mov esi, boot_pal_ega |
865 | call boot_log |
897 | call boot_log |
866 | call palette320x200 |
898 | call palette320x200 |
867 | no_pal_ega: |
899 | no_pal_ega: |
868 | 900 | ||
869 | ; LOAD DEFAULT SKIN |
901 | ; LOAD DEFAULT SKIN |
870 | 902 | ||
871 | call load_default_skin |
903 | call load_default_skin |
872 | 904 | ||
873 | ;protect io permission map |
905 | ;protect io permission map |
874 | 906 | ||
875 | mov esi, [default_io_map] |
907 | mov esi, [default_io_map] |
876 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
908 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
877 | add esi, 0x1000 |
909 | add esi, 0x1000 |
878 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
910 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
879 | 911 | ||
880 | stdcall map_page, tss._io_map_0, \ |
912 | stdcall map_page, tss._io_map_0, \ |
881 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
913 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
882 | stdcall map_page, tss._io_map_1, \ |
914 | stdcall map_page, tss._io_map_1, \ |
883 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
915 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
884 | 916 | ||
885 | ; LOAD FIRST APPLICATION |
917 | ; LOAD FIRST APPLICATION |
886 | cli |
918 | cli |
887 | 919 | ||
888 | ; cmp byte [BOOT_VAR+0x9030],1 |
920 | ; cmp byte [BOOT_VAR+0x9030],1 |
889 | ; jne no_load_vrr_m |
921 | ; jne no_load_vrr_m |
890 | 922 | ||
891 | ; mov ebp, vrr_m |
923 | ; mov ebp, vrr_m |
892 | ; call fs_execute_from_sysdir |
924 | ; call fs_execute_from_sysdir |
893 | ; |
925 | ; |
894 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
926 | ;; cmp eax,2 ; if vrr_m app found (PID=2) |
895 | ; sub eax,2 |
927 | ; sub eax,2 |
896 | ; jz first_app_found |
928 | ; jz first_app_found |
897 | ; |
929 | ; |
898 | ;no_load_vrr_m: |
930 | ;no_load_vrr_m: |
899 | 931 | ||
900 | mov ebp, firstapp |
932 | mov ebp, firstapp |
901 | call fs_execute_from_sysdir |
933 | call fs_execute_from_sysdir |
902 | 934 | ||
903 | ; cmp eax,2 ; continue if a process has been loaded |
935 | ; cmp eax,2 ; continue if a process has been loaded |
904 | test eax, eax |
936 | test eax, eax |
905 | jns first_app_found |
937 | jns first_app_found |
906 | 938 | ||
907 | mov esi, boot_failed |
939 | mov esi, boot_failed |
908 | call boot_log |
940 | call boot_log |
909 | 941 | ||
910 | mov eax, 0xDEADBEEF ; otherwise halt |
942 | mov eax, 0xDEADBEEF ; otherwise halt |
911 | hlt |
943 | hlt |
912 | 944 | ||
913 | first_app_found: |
945 | first_app_found: |
914 | 946 | ||
915 | cli |
947 | cli |
916 | 948 | ||
917 | ; SET KEYBOARD PARAMETERS |
949 | ; SET KEYBOARD PARAMETERS |
918 | mov al, 0xf6 ; reset keyboard, scan enabled |
950 | mov al, 0xf6 ; reset keyboard, scan enabled |
919 | call kb_write |
951 | call kb_write |
920 | test ah, ah |
952 | test ah, ah |
921 | jnz .no_keyboard |
953 | jnz .no_keyboard |
922 | 954 | ||
923 | ; wait until 8042 is ready |
955 | ; wait until 8042 is ready |
924 | xor ecx, ecx |
956 | xor ecx, ecx |
925 | @@: |
957 | @@: |
926 | in al, 64h |
958 | in al, 64h |
927 | and al, 00000010b |
959 | and al, 00000010b |
928 | loopnz @b |
960 | loopnz @b |
929 | 961 | ||
930 | iglobal |
962 | iglobal |
931 | align 4 |
963 | align 4 |
932 | ps2_keyboard_functions: |
964 | ps2_keyboard_functions: |
933 | dd .end - $ |
965 | dd .end - $ |
934 | dd 0 ; no close |
966 | dd 0 ; no close |
935 | dd ps2_set_lights |
967 | dd ps2_set_lights |
936 | .end: |
968 | .end: |
937 | endg |
969 | endg |
938 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
970 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
939 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
971 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
940 | ; call kb_write |
972 | ; call kb_write |
941 | ; call kb_read |
973 | ; call kb_read |
942 | ; mov al, 111b |
974 | ; mov al, 111b |
943 | ; call kb_write |
975 | ; call kb_write |
944 | ; call kb_read |
976 | ; call kb_read |
945 | 977 | ||
946 | mov al, 0xF3 ; set repeat rate & delay |
978 | mov al, 0xF3 ; set repeat rate & delay |
947 | call kb_write |
979 | call kb_write |
948 | ; call kb_read |
980 | ; call kb_read |
949 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
981 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
950 | call kb_write |
982 | call kb_write |
951 | ; call kb_read |
983 | ; call kb_read |
952 | ;// mike.dld [ |
984 | ;// mike.dld [ |
953 | call set_lights |
985 | call set_lights |
954 | ;// mike.dld ] |
986 | ;// mike.dld ] |
955 | stdcall attach_int_handler, 1, irq1, 0 |
987 | stdcall attach_int_handler, 1, irq1, 0 |
956 | .no_keyboard: |
988 | .no_keyboard: |
957 | 989 | ||
958 | ; SET MOUSE |
990 | ; SET MOUSE |
959 | 991 | ||
960 | stdcall load_driver, szPS2MDriver |
992 | stdcall load_driver, szPS2MDriver |
961 | ; stdcall load_driver, szCOM_MDriver |
993 | ; stdcall load_driver, szCOM_MDriver |
962 | 994 | ||
963 | mov esi, boot_setmouse |
995 | mov esi, boot_setmouse |
964 | call boot_log |
996 | call boot_log |
965 | call setmouse |
997 | call setmouse |
966 | 998 | ||
967 | ; Setup serial output console (if enabled) |
999 | ; Setup serial output console (if enabled) |
968 | 1000 | ||
969 | if defined debug_com_base |
1001 | if defined debug_com_base |
970 | 1002 | ||
971 | ; enable Divisor latch |
1003 | ; enable Divisor latch |
972 | 1004 | ||
973 | mov dx, debug_com_base+3 |
1005 | mov dx, debug_com_base+3 |
974 | mov al, 1 shl 7 |
1006 | mov al, 1 shl 7 |
975 | out dx, al |
1007 | out dx, al |
976 | 1008 | ||
977 | ; Set speed to 115200 baud (max speed) |
1009 | ; Set speed to 115200 baud (max speed) |
978 | 1010 | ||
979 | mov dx, debug_com_base |
1011 | mov dx, debug_com_base |
980 | mov al, 0x01 |
1012 | mov al, 0x01 |
981 | out dx, al |
1013 | out dx, al |
982 | 1014 | ||
983 | mov dx, debug_com_base+1 |
1015 | mov dx, debug_com_base+1 |
984 | mov al, 0x00 |
1016 | mov al, 0x00 |
985 | out dx, al |
1017 | out dx, al |
986 | 1018 | ||
987 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1019 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
988 | 1020 | ||
989 | mov dx, debug_com_base+3 |
1021 | mov dx, debug_com_base+3 |
990 | mov al, 3 |
1022 | mov al, 3 |
991 | out dx, al |
1023 | out dx, al |
992 | 1024 | ||
993 | ; disable interrupts |
1025 | ; disable interrupts |
994 | 1026 | ||
995 | mov dx, debug_com_base+1 |
1027 | mov dx, debug_com_base+1 |
996 | mov al, 0 |
1028 | mov al, 0 |
997 | out dx, al |
1029 | out dx, al |
998 | 1030 | ||
999 | ; clear + enable fifo (64 bits) |
1031 | ; clear + enable fifo (64 bits) |
1000 | 1032 | ||
1001 | mov dx, debug_com_base+2 |
1033 | mov dx, debug_com_base+2 |
1002 | mov al, 0x7 + 1 shl 5 |
1034 | mov al, 0x7 + 1 shl 5 |
1003 | out dx, al |
1035 | out dx, al |
1004 | 1036 | ||
1005 | 1037 | ||
1006 | end if |
1038 | end if |
1007 | mov eax, [version_inf.rev] |
1039 | mov eax, [version_inf.rev] |
1008 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1040 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1009 | 1041 | ||
1010 | mov eax, [cpu_count] |
1042 | mov eax, [cpu_count] |
1011 | test eax, eax |
1043 | test eax, eax |
1012 | jnz @F |
1044 | jnz @F |
1013 | mov al, 1 ; at least one CPU |
1045 | mov al, 1 ; at least one CPU |
1014 | @@: |
1046 | @@: |
1015 | DEBUGF 1, "K : %d CPU detected\n", eax |
1047 | DEBUGF 1, "K : %d CPU detected\n", eax |
- | 1048 | ||
- | 1049 | movzx eax,[IDE_BAR0_val] |
|
- | 1050 | DEBUGF 1, "K : BAR0 %x \n", eax |
|
- | 1051 | movzx eax,[IDE_BAR1_val] |
|
- | 1052 | DEBUGF 1, "K : BAR1 %x \n", eax |
|
- | 1053 | movzx eax,[IDE_BAR2_val] |
|
- | 1054 | DEBUGF 1, "K : BAR2 %x \n", eax |
|
- | 1055 | movzx eax,[IDE_BAR3_val] |
|
- | 1056 | DEBUGF 1, "K : BAR3 %x \n", eax |
|
- | 1057 | movzx eax,[IDEContrRegsBaseAddr] |
|
- | 1058 | DEBUGF 1, "K : BAR4 %x \n", eax |
|
- | 1059 | movzx eax,[IDEContrProgrammingInterface] |
|
1016 | 1060 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", eax |
|
1017 | ; START MULTITASKING |
1061 | ; START MULTITASKING |
1018 | 1062 | ||
1019 | ; A 'All set - press ESC to start' messages if need |
1063 | ; A 'All set - press ESC to start' messages if need |
1020 | if preboot_blogesc |
1064 | if preboot_blogesc |
1021 | mov esi, boot_tasking |
1065 | mov esi, boot_tasking |
1022 | call boot_log |
1066 | call boot_log |
1023 | .bll1: |
1067 | .bll1: |
1024 | in al, 0x60 ; wait for ESC key press |
1068 | in al, 0x60 ; wait for ESC key press |
1025 | cmp al, 129 |
1069 | cmp al, 129 |
1026 | jne .bll1 |
1070 | jne .bll1 |
1027 | end if |
1071 | end if |
1028 | 1072 | ||
1029 | cmp [IDEContrRegsBaseAddr], 0 |
1073 | cmp [IDEContrRegsBaseAddr], 0 |
1030 | setnz [dma_hdd] |
1074 | setnz [dma_hdd] |
- | 1075 | ||
- | 1076 | cmp [dma_hdd],0 |
|
- | 1077 | je .print_pio |
|
- | 1078 | .print_dma: |
|
- | 1079 | DEBUGF 1, "K : IDE DMA mode\n" |
|
- | 1080 | jmp .continue |
|
- | 1081 | ||
- | 1082 | .print_pio: |
|
- | 1083 | DEBUGF 1, "K : IDE PIO mode\n" |
|
- | 1084 | .continue: |
|
- | 1085 | ||
1031 | mov [timer_ticks_enable], 1 ; for cd driver |
1086 | mov [timer_ticks_enable], 1 ; for cd driver |
1032 | 1087 | ||
1033 | sti |
1088 | sti |
1034 | ; call change_task |
1089 | ; call change_task |
1035 | 1090 | ||
1036 | jmp osloop |
1091 | jmp osloop |
1037 | 1092 | ||
1038 | 1093 | ||
1039 | ; Fly :) |
1094 | ; Fly :) |
1040 | 1095 | ||
1041 | include 'unpacker.inc' |
1096 | include 'unpacker.inc' |
1042 | 1097 | ||
1043 | align 4 |
1098 | align 4 |
1044 | boot_log: |
1099 | boot_log: |
1045 | pushad |
1100 | pushad |
1046 | 1101 | ||
1047 | mov ebx, 10*65536 |
1102 | mov ebx, 10*65536 |
1048 | mov bx, word [boot_y] |
1103 | mov bx, word [boot_y] |
1049 | add [boot_y], dword 10 |
1104 | add [boot_y], dword 10 |
1050 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1105 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1051 | xor edi, edi |
1106 | xor edi, edi |
1052 | mov edx, esi |
1107 | mov edx, esi |
1053 | inc edi |
1108 | inc edi |
1054 | call dtext |
1109 | call dtext |
1055 | 1110 | ||
1056 | mov [novesachecksum], 1000 |
1111 | mov [novesachecksum], 1000 |
1057 | call checkVga_N13 |
1112 | call checkVga_N13 |
1058 | 1113 | ||
1059 | popad |
1114 | popad |
1060 | 1115 | ||
1061 | ret |
1116 | ret |
1062 | 1117 | ||
1063 | ; in: edx -> APPDATA for OS/IDLE slot |
1118 | ; in: edx -> APPDATA for OS/IDLE slot |
1064 | ; in: ebx = stack base |
1119 | ; in: ebx = stack base |
1065 | proc setup_os_slot |
1120 | proc setup_os_slot |
1066 | xor eax, eax |
1121 | xor eax, eax |
1067 | mov ecx, 256/4 |
1122 | mov ecx, 256/4 |
1068 | mov edi, edx |
1123 | mov edi, edx |
1069 | rep stosd |
1124 | rep stosd |
1070 | 1125 | ||
1071 | mov eax, tss+0x80 |
1126 | mov eax, tss+0x80 |
1072 | call get_pg_addr |
1127 | call get_pg_addr |
1073 | inc eax |
1128 | inc eax |
1074 | mov [edx+APPDATA.io_map], eax |
1129 | mov [edx+APPDATA.io_map], eax |
1075 | mov eax, tss+0x1080 |
1130 | mov eax, tss+0x1080 |
1076 | call get_pg_addr |
1131 | call get_pg_addr |
1077 | inc eax |
1132 | inc eax |
1078 | mov [edx+APPDATA.io_map+4], eax |
1133 | mov [edx+APPDATA.io_map+4], eax |
1079 | 1134 | ||
1080 | mov dword [edx+APPDATA.pl0_stack], ebx |
1135 | mov dword [edx+APPDATA.pl0_stack], ebx |
1081 | lea edi, [ebx+0x2000-512] |
1136 | lea edi, [ebx+0x2000-512] |
1082 | mov dword [edx+APPDATA.fpu_state], edi |
1137 | mov dword [edx+APPDATA.fpu_state], edi |
1083 | mov dword [edx+APPDATA.saved_esp0], edi |
1138 | mov dword [edx+APPDATA.saved_esp0], edi |
1084 | mov dword [edx+APPDATA.saved_esp], edi |
1139 | mov dword [edx+APPDATA.saved_esp], edi |
1085 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1140 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1086 | 1141 | ||
1087 | mov esi, fpu_data |
1142 | mov esi, fpu_data |
1088 | mov ecx, 512/4 |
1143 | mov ecx, 512/4 |
1089 | cld |
1144 | cld |
1090 | rep movsd |
1145 | rep movsd |
1091 | 1146 | ||
1092 | lea eax, [edx+APP_OBJ_OFFSET] |
1147 | lea eax, [edx+APP_OBJ_OFFSET] |
1093 | mov dword [edx+APPDATA.fd_obj], eax |
1148 | mov dword [edx+APPDATA.fd_obj], eax |
1094 | mov dword [edx+APPDATA.bk_obj], eax |
1149 | mov dword [edx+APPDATA.bk_obj], eax |
1095 | 1150 | ||
1096 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1151 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1097 | 1152 | ||
1098 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1153 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
1099 | 1154 | ||
1100 | mov eax, edx |
1155 | mov eax, edx |
1101 | shr eax, 3 |
1156 | shr eax, 3 |
1102 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1157 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1103 | mov [eax+TASKDATA.wnd_number], dh |
1158 | mov [eax+TASKDATA.wnd_number], dh |
1104 | mov byte [eax+TASKDATA.pid], dh |
1159 | mov byte [eax+TASKDATA.pid], dh |
1105 | 1160 | ||
1106 | ret |
1161 | ret |
1107 | endp |
1162 | endp |
1108 | 1163 | ||
1109 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1164 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1110 | ; ; |
1165 | ; ; |
1111 | ; MAIN OS LOOP START ; |
1166 | ; MAIN OS LOOP START ; |
1112 | ; ; |
1167 | ; ; |
1113 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1168 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1114 | align 32 |
1169 | align 32 |
1115 | osloop: |
1170 | osloop: |
1116 | mov edx, osloop_has_work? |
1171 | mov edx, osloop_has_work? |
1117 | xor ecx, ecx |
1172 | xor ecx, ecx |
1118 | call Wait_events |
1173 | call Wait_events |
1119 | xor eax, eax |
1174 | xor eax, eax |
1120 | xchg eax, [osloop_nonperiodic_work] |
1175 | xchg eax, [osloop_nonperiodic_work] |
1121 | test eax, eax |
1176 | test eax, eax |
1122 | jz .no_periodic |
1177 | jz .no_periodic |
1123 | ; call [draw_pointer] |
1178 | ; call [draw_pointer] |
1124 | call __sys_draw_pointer |
1179 | call __sys_draw_pointer |
1125 | call window_check_events |
1180 | call window_check_events |
1126 | call mouse_check_events |
1181 | call mouse_check_events |
1127 | call checkmisc |
1182 | call checkmisc |
1128 | call checkVga_N13 |
1183 | call checkVga_N13 |
1129 | .no_periodic: |
1184 | .no_periodic: |
1130 | call stack_handler |
1185 | call stack_handler |
1131 | call check_fdd_motor_status |
1186 | call check_fdd_motor_status |
1132 | call check_ATAPI_device_event |
1187 | call check_ATAPI_device_event |
1133 | call check_lights_state |
1188 | call check_lights_state |
1134 | call check_timers |
1189 | call check_timers |
1135 | jmp osloop |
1190 | jmp osloop |
1136 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1191 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1137 | ; ; |
1192 | ; ; |
1138 | ; MAIN OS LOOP END ; |
1193 | ; MAIN OS LOOP END ; |
1139 | ; ; |
1194 | ; ; |
1140 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1195 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1141 | proc osloop_has_work? |
1196 | proc osloop_has_work? |
1142 | cmp [osloop_nonperiodic_work], 0 |
1197 | cmp [osloop_nonperiodic_work], 0 |
1143 | jnz .yes |
1198 | jnz .yes |
1144 | call stack_handler_has_work? |
1199 | call stack_handler_has_work? |
1145 | jnz .yes |
1200 | jnz .yes |
1146 | call check_fdd_motor_status_has_work? |
1201 | call check_fdd_motor_status_has_work? |
1147 | jnz .yes |
1202 | jnz .yes |
1148 | call check_ATAPI_device_event_has_work? |
1203 | call check_ATAPI_device_event_has_work? |
1149 | jnz .yes |
1204 | jnz .yes |
1150 | call check_lights_state_has_work? |
1205 | call check_lights_state_has_work? |
1151 | jnz .yes |
1206 | jnz .yes |
1152 | call check_timers_has_work? |
1207 | call check_timers_has_work? |
1153 | jnz .yes |
1208 | jnz .yes |
1154 | .no: |
1209 | .no: |
1155 | xor eax, eax |
1210 | xor eax, eax |
1156 | ret |
1211 | ret |
1157 | .yes: |
1212 | .yes: |
1158 | xor eax, eax |
1213 | xor eax, eax |
1159 | inc eax |
1214 | inc eax |
1160 | ret |
1215 | ret |
1161 | endp |
1216 | endp |
1162 | 1217 | ||
1163 | proc wakeup_osloop |
1218 | proc wakeup_osloop |
1164 | mov [osloop_nonperiodic_work], 1 |
1219 | mov [osloop_nonperiodic_work], 1 |
1165 | ret |
1220 | ret |
1166 | endp |
1221 | endp |
1167 | 1222 | ||
1168 | uglobal |
1223 | uglobal |
1169 | align 4 |
1224 | align 4 |
1170 | osloop_nonperiodic_work dd ? |
1225 | osloop_nonperiodic_work dd ? |
1171 | endg |
1226 | endg |
1172 | 1227 | ||
1173 | align 4 |
1228 | align 4 |
1174 | idle_thread: |
1229 | idle_thread: |
1175 | sti |
1230 | sti |
1176 | idle_loop: |
1231 | idle_loop: |
1177 | hlt |
1232 | hlt |
1178 | jmp idle_loop |
1233 | jmp idle_loop |
1179 | 1234 | ||
1180 | 1235 | ||
1181 | 1236 | ||
1182 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1237 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1183 | ; ; |
1238 | ; ; |
1184 | ; INCLUDED SYSTEM FILES ; |
1239 | ; INCLUDED SYSTEM FILES ; |
1185 | ; ; |
1240 | ; ; |
1186 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1241 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1187 | 1242 | ||
1188 | 1243 | ||
1189 | include "kernel32.inc" |
1244 | include "kernel32.inc" |
1190 | 1245 | ||
1191 | 1246 | ||
1192 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1247 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1193 | ; ; |
1248 | ; ; |
1194 | ; KERNEL FUNCTIONS ; |
1249 | ; KERNEL FUNCTIONS ; |
1195 | ; ; |
1250 | ; ; |
1196 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1251 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1197 | 1252 | ||
1198 | reserve_irqs_ports: |
1253 | reserve_irqs_ports: |
1199 | 1254 | ||
1200 | 1255 | ||
1201 | ; RESERVE PORTS |
1256 | ; RESERVE PORTS |
1202 | mov eax, RESERVED_PORTS |
1257 | mov eax, RESERVED_PORTS |
1203 | mov ecx, 1 |
1258 | mov ecx, 1 |
1204 | 1259 | ||
1205 | mov [eax], dword 4 |
1260 | mov [eax], dword 4 |
1206 | 1261 | ||
1207 | mov [eax+16], ecx |
1262 | mov [eax+16], ecx |
1208 | mov [eax+16+4], dword 0 |
1263 | mov [eax+16+4], dword 0 |
1209 | mov [eax+16+8], dword 0x2D |
1264 | mov [eax+16+8], dword 0x2D |
1210 | 1265 | ||
1211 | mov [eax+32], ecx |
1266 | mov [eax+32], ecx |
1212 | mov [eax+32+4], dword 0x30 |
1267 | mov [eax+32+4], dword 0x30 |
1213 | mov [eax+32+8], dword 0x4D |
1268 | mov [eax+32+8], dword 0x4D |
1214 | 1269 | ||
1215 | mov [eax+48], ecx |
1270 | mov [eax+48], ecx |
1216 | mov [eax+48+4], dword 0x50 |
1271 | mov [eax+48+4], dword 0x50 |
1217 | mov [eax+48+8], dword 0xDF |
1272 | mov [eax+48+8], dword 0xDF |
1218 | 1273 | ||
1219 | mov [eax+64], ecx |
1274 | mov [eax+64], ecx |
1220 | mov [eax+64+4], dword 0xE5 |
1275 | mov [eax+64+4], dword 0xE5 |
1221 | mov [eax+64+8], dword 0xFF |
1276 | mov [eax+64+8], dword 0xFF |
1222 | 1277 | ||
1223 | ret |
1278 | ret |
1224 | 1279 | ||
1225 | 1280 | ||
1226 | iglobal |
1281 | iglobal |
1227 | process_number dd 0x2 |
1282 | process_number dd 0x2 |
1228 | endg |
1283 | endg |
1229 | 1284 | ||
1230 | set_variables: |
1285 | set_variables: |
1231 | 1286 | ||
1232 | mov ecx, 0x16 ; flush port 0x60 |
1287 | mov ecx, 0x16 ; flush port 0x60 |
1233 | .fl60: |
1288 | .fl60: |
1234 | in al, 0x60 |
1289 | in al, 0x60 |
1235 | loop .fl60 |
1290 | loop .fl60 |
1236 | push eax |
1291 | push eax |
1237 | 1292 | ||
1238 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1293 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
1239 | shr ax, 1 |
1294 | shr ax, 1 |
1240 | shl eax, 16 |
1295 | shl eax, 16 |
1241 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1296 | mov ax, [BOOT_VAR+BOOT_X_RES] |
1242 | shr ax, 1 |
1297 | shr ax, 1 |
1243 | mov [MOUSE_X], eax |
1298 | mov [MOUSE_X], eax |
1244 | call wakeup_osloop |
1299 | call wakeup_osloop |
1245 | 1300 | ||
1246 | xor eax, eax |
1301 | xor eax, eax |
1247 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1302 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1248 | 1303 | ||
1249 | mov byte [KEY_COUNT], al ; keyboard buffer |
1304 | mov byte [KEY_COUNT], al ; keyboard buffer |
1250 | mov byte [BTN_COUNT], al ; button buffer |
1305 | mov byte [BTN_COUNT], al ; button buffer |
1251 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1306 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1252 | 1307 | ||
1253 | pop eax |
1308 | pop eax |
1254 | ret |
1309 | ret |
1255 | 1310 | ||
1256 | align 4 |
1311 | align 4 |
1257 | ;input eax=43,bl-byte of output, ecx - number of port |
1312 | ;input eax=43,bl-byte of output, ecx - number of port |
1258 | sys_outport: |
1313 | sys_outport: |
1259 | 1314 | ||
1260 | mov edi, ecx ; separate flag for read / write |
1315 | mov edi, ecx ; separate flag for read / write |
1261 | and ecx, 65535 |
1316 | and ecx, 65535 |
1262 | 1317 | ||
1263 | mov eax, [RESERVED_PORTS] |
1318 | mov eax, [RESERVED_PORTS] |
1264 | test eax, eax |
1319 | test eax, eax |
1265 | jnz .sopl8 |
1320 | jnz .sopl8 |
1266 | inc eax |
1321 | inc eax |
1267 | mov [esp+32], eax |
1322 | mov [esp+32], eax |
1268 | ret |
1323 | ret |
1269 | 1324 | ||
1270 | .sopl8: |
1325 | .sopl8: |
1271 | mov edx, [TASK_BASE] |
1326 | mov edx, [TASK_BASE] |
1272 | mov edx, [edx+0x4] |
1327 | mov edx, [edx+0x4] |
1273 | ;and ecx,65535 |
1328 | ;and ecx,65535 |
1274 | ;cld - set on interrupt 0x40 |
1329 | ;cld - set on interrupt 0x40 |
1275 | .sopl1: |
1330 | .sopl1: |
1276 | 1331 | ||
1277 | mov esi, eax |
1332 | mov esi, eax |
1278 | shl esi, 4 |
1333 | shl esi, 4 |
1279 | add esi, RESERVED_PORTS |
1334 | add esi, RESERVED_PORTS |
1280 | cmp edx, [esi+0] |
1335 | cmp edx, [esi+0] |
1281 | jne .sopl2 |
1336 | jne .sopl2 |
1282 | cmp ecx, [esi+4] |
1337 | cmp ecx, [esi+4] |
1283 | jb .sopl2 |
1338 | jb .sopl2 |
1284 | cmp ecx, [esi+8] |
1339 | cmp ecx, [esi+8] |
1285 | jg .sopl2 |
1340 | jg .sopl2 |
1286 | .sopl3: |
1341 | .sopl3: |
1287 | 1342 | ||
1288 | test edi, 0x80000000; read ? |
1343 | test edi, 0x80000000; read ? |
1289 | jnz .sopl4 |
1344 | jnz .sopl4 |
1290 | 1345 | ||
1291 | mov eax, ebx |
1346 | mov eax, ebx |
1292 | mov dx, cx ; write |
1347 | mov dx, cx ; write |
1293 | out dx, al |
1348 | out dx, al |
1294 | and [esp+32], dword 0 |
1349 | and [esp+32], dword 0 |
1295 | ret |
1350 | ret |
1296 | 1351 | ||
1297 | .sopl2: |
1352 | .sopl2: |
1298 | 1353 | ||
1299 | dec eax |
1354 | dec eax |
1300 | jnz .sopl1 |
1355 | jnz .sopl1 |
1301 | inc eax |
1356 | inc eax |
1302 | mov [esp+32], eax |
1357 | mov [esp+32], eax |
1303 | ret |
1358 | ret |
1304 | 1359 | ||
1305 | 1360 | ||
1306 | .sopl4: |
1361 | .sopl4: |
1307 | 1362 | ||
1308 | mov dx, cx ; read |
1363 | mov dx, cx ; read |
1309 | in al, dx |
1364 | in al, dx |
1310 | and eax, 0xff |
1365 | and eax, 0xff |
1311 | and [esp+32], dword 0 |
1366 | and [esp+32], dword 0 |
1312 | mov [esp+20], eax |
1367 | mov [esp+20], eax |
1313 | ret |
1368 | ret |
1314 | 1369 | ||
1315 | display_number: |
1370 | display_number: |
1316 | ;It is not optimization |
1371 | ;It is not optimization |
1317 | mov eax, ebx |
1372 | mov eax, ebx |
1318 | mov ebx, ecx |
1373 | mov ebx, ecx |
1319 | mov ecx, edx |
1374 | mov ecx, edx |
1320 | mov edx, esi |
1375 | mov edx, esi |
1321 | mov esi, edi |
1376 | mov esi, edi |
1322 | ; eax = print type, al=0 -> ebx is number |
1377 | ; eax = print type, al=0 -> ebx is number |
1323 | ; al=1 -> ebx is pointer |
1378 | ; al=1 -> ebx is pointer |
1324 | ; ah=0 -> display decimal |
1379 | ; ah=0 -> display decimal |
1325 | ; ah=1 -> display hexadecimal |
1380 | ; ah=1 -> display hexadecimal |
1326 | ; ah=2 -> display binary |
1381 | ; ah=2 -> display binary |
1327 | ; eax bits 16-21 = number of digits to display (0-32) |
1382 | ; eax bits 16-21 = number of digits to display (0-32) |
1328 | ; eax bits 22-31 = reserved |
1383 | ; eax bits 22-31 = reserved |
1329 | ; |
1384 | ; |
1330 | ; ebx = number or pointer |
1385 | ; ebx = number or pointer |
1331 | ; ecx = x shl 16 + y |
1386 | ; ecx = x shl 16 + y |
1332 | ; edx = color |
1387 | ; edx = color |
1333 | xor edi, edi |
1388 | xor edi, edi |
1334 | display_number_force: |
1389 | display_number_force: |
1335 | push eax |
1390 | push eax |
1336 | and eax, 0x3fffffff |
1391 | and eax, 0x3fffffff |
1337 | cmp eax, 0xffff ; length > 0 ? |
1392 | cmp eax, 0xffff ; length > 0 ? |
1338 | pop eax |
1393 | pop eax |
1339 | jge cont_displ |
1394 | jge cont_displ |
1340 | ret |
1395 | ret |
1341 | cont_displ: |
1396 | cont_displ: |
1342 | push eax |
1397 | push eax |
1343 | and eax, 0x3fffffff |
1398 | and eax, 0x3fffffff |
1344 | cmp eax, 61*0x10000 ; length <= 60 ? |
1399 | cmp eax, 61*0x10000 ; length <= 60 ? |
1345 | pop eax |
1400 | pop eax |
1346 | jb cont_displ2 |
1401 | jb cont_displ2 |
1347 | ret |
1402 | ret |
1348 | cont_displ2: |
1403 | cont_displ2: |
1349 | 1404 | ||
1350 | pushad |
1405 | pushad |
1351 | 1406 | ||
1352 | cmp al, 1 ; ecx is a pointer ? |
1407 | cmp al, 1 ; ecx is a pointer ? |
1353 | jne displnl1 |
1408 | jne displnl1 |
1354 | mov ebp, ebx |
1409 | mov ebp, ebx |
1355 | add ebp, 4 |
1410 | add ebp, 4 |
1356 | mov ebp, [ebp+std_application_base_address] |
1411 | mov ebp, [ebp+std_application_base_address] |
1357 | mov ebx, [ebx+std_application_base_address] |
1412 | mov ebx, [ebx+std_application_base_address] |
1358 | displnl1: |
1413 | displnl1: |
1359 | sub esp, 64 |
1414 | sub esp, 64 |
1360 | 1415 | ||
1361 | test ah, ah ; DECIMAL |
1416 | test ah, ah ; DECIMAL |
1362 | jnz no_display_desnum |
1417 | jnz no_display_desnum |
1363 | shr eax, 16 |
1418 | shr eax, 16 |
1364 | and eax, 0xC03f |
1419 | and eax, 0xC03f |
1365 | ; and eax,0x3f |
1420 | ; and eax,0x3f |
1366 | push eax |
1421 | push eax |
1367 | and eax, 0x3f |
1422 | and eax, 0x3f |
1368 | mov edi, esp |
1423 | mov edi, esp |
1369 | add edi, 4+64-1 |
1424 | add edi, 4+64-1 |
1370 | mov ecx, eax |
1425 | mov ecx, eax |
1371 | mov eax, ebx |
1426 | mov eax, ebx |
1372 | mov ebx, 10 |
1427 | mov ebx, 10 |
1373 | d_desnum: |
1428 | d_desnum: |
1374 | xor edx, edx |
1429 | xor edx, edx |
1375 | call division_64_bits |
1430 | call division_64_bits |
1376 | div ebx |
1431 | div ebx |
1377 | add dl, 48 |
1432 | add dl, 48 |
1378 | mov [edi], dl |
1433 | mov [edi], dl |
1379 | dec edi |
1434 | dec edi |
1380 | loop d_desnum |
1435 | loop d_desnum |
1381 | pop eax |
1436 | pop eax |
1382 | call normalize_number |
1437 | call normalize_number |
1383 | call draw_num_text |
1438 | call draw_num_text |
1384 | add esp, 64 |
1439 | add esp, 64 |
1385 | popad |
1440 | popad |
1386 | ret |
1441 | ret |
1387 | no_display_desnum: |
1442 | no_display_desnum: |
1388 | 1443 | ||
1389 | cmp ah, 0x01 ; HEXADECIMAL |
1444 | cmp ah, 0x01 ; HEXADECIMAL |
1390 | jne no_display_hexnum |
1445 | jne no_display_hexnum |
1391 | shr eax, 16 |
1446 | shr eax, 16 |
1392 | and eax, 0xC03f |
1447 | and eax, 0xC03f |
1393 | ; and eax,0x3f |
1448 | ; and eax,0x3f |
1394 | push eax |
1449 | push eax |
1395 | and eax, 0x3f |
1450 | and eax, 0x3f |
1396 | mov edi, esp |
1451 | mov edi, esp |
1397 | add edi, 4+64-1 |
1452 | add edi, 4+64-1 |
1398 | mov ecx, eax |
1453 | mov ecx, eax |
1399 | mov eax, ebx |
1454 | mov eax, ebx |
1400 | mov ebx, 16 |
1455 | mov ebx, 16 |
1401 | d_hexnum: |
1456 | d_hexnum: |
1402 | xor edx, edx |
1457 | xor edx, edx |
1403 | call division_64_bits |
1458 | call division_64_bits |
1404 | div ebx |
1459 | div ebx |
1405 | hexletters = __fdo_hexdigits |
1460 | hexletters = __fdo_hexdigits |
1406 | add edx, hexletters |
1461 | add edx, hexletters |
1407 | mov dl, [edx] |
1462 | mov dl, [edx] |
1408 | mov [edi], dl |
1463 | mov [edi], dl |
1409 | dec edi |
1464 | dec edi |
1410 | loop d_hexnum |
1465 | loop d_hexnum |
1411 | pop eax |
1466 | pop eax |
1412 | call normalize_number |
1467 | call normalize_number |
1413 | call draw_num_text |
1468 | call draw_num_text |
1414 | add esp, 64 |
1469 | add esp, 64 |
1415 | popad |
1470 | popad |
1416 | ret |
1471 | ret |
1417 | no_display_hexnum: |
1472 | no_display_hexnum: |
1418 | 1473 | ||
1419 | cmp ah, 0x02 ; BINARY |
1474 | cmp ah, 0x02 ; BINARY |
1420 | jne no_display_binnum |
1475 | jne no_display_binnum |
1421 | shr eax, 16 |
1476 | shr eax, 16 |
1422 | and eax, 0xC03f |
1477 | and eax, 0xC03f |
1423 | ; and eax,0x3f |
1478 | ; and eax,0x3f |
1424 | push eax |
1479 | push eax |
1425 | and eax, 0x3f |
1480 | and eax, 0x3f |
1426 | mov edi, esp |
1481 | mov edi, esp |
1427 | add edi, 4+64-1 |
1482 | add edi, 4+64-1 |
1428 | mov ecx, eax |
1483 | mov ecx, eax |
1429 | mov eax, ebx |
1484 | mov eax, ebx |
1430 | mov ebx, 2 |
1485 | mov ebx, 2 |
1431 | d_binnum: |
1486 | d_binnum: |
1432 | xor edx, edx |
1487 | xor edx, edx |
1433 | call division_64_bits |
1488 | call division_64_bits |
1434 | div ebx |
1489 | div ebx |
1435 | add dl, 48 |
1490 | add dl, 48 |
1436 | mov [edi], dl |
1491 | mov [edi], dl |
1437 | dec edi |
1492 | dec edi |
1438 | loop d_binnum |
1493 | loop d_binnum |
1439 | pop eax |
1494 | pop eax |
1440 | call normalize_number |
1495 | call normalize_number |
1441 | call draw_num_text |
1496 | call draw_num_text |
1442 | add esp, 64 |
1497 | add esp, 64 |
1443 | popad |
1498 | popad |
1444 | ret |
1499 | ret |
1445 | no_display_binnum: |
1500 | no_display_binnum: |
1446 | 1501 | ||
1447 | add esp, 64 |
1502 | add esp, 64 |
1448 | popad |
1503 | popad |
1449 | ret |
1504 | ret |
1450 | 1505 | ||
1451 | normalize_number: |
1506 | normalize_number: |
1452 | test ah, 0x80 |
1507 | test ah, 0x80 |
1453 | jz .continue |
1508 | jz .continue |
1454 | mov ecx, 48 |
1509 | mov ecx, 48 |
1455 | and eax, 0x3f |
1510 | and eax, 0x3f |
1456 | @@: |
1511 | @@: |
1457 | inc edi |
1512 | inc edi |
1458 | cmp [edi], cl |
1513 | cmp [edi], cl |
1459 | jne .continue |
1514 | jne .continue |
1460 | dec eax |
1515 | dec eax |
1461 | cmp eax, 1 |
1516 | cmp eax, 1 |
1462 | ja @r |
1517 | ja @r |
1463 | mov al, 1 |
1518 | mov al, 1 |
1464 | .continue: |
1519 | .continue: |
1465 | and eax, 0x3f |
1520 | and eax, 0x3f |
1466 | ret |
1521 | ret |
1467 | 1522 | ||
1468 | division_64_bits: |
1523 | division_64_bits: |
1469 | test [esp+1+4], byte 0x40 |
1524 | test [esp+1+4], byte 0x40 |
1470 | jz .continue |
1525 | jz .continue |
1471 | push eax |
1526 | push eax |
1472 | mov eax, ebp |
1527 | mov eax, ebp |
1473 | div ebx |
1528 | div ebx |
1474 | mov ebp, eax |
1529 | mov ebp, eax |
1475 | pop eax |
1530 | pop eax |
1476 | .continue: |
1531 | .continue: |
1477 | ret |
1532 | ret |
1478 | 1533 | ||
1479 | draw_num_text: |
1534 | draw_num_text: |
1480 | mov esi, eax |
1535 | mov esi, eax |
1481 | mov edx, 64+4 |
1536 | mov edx, 64+4 |
1482 | sub edx, eax |
1537 | sub edx, eax |
1483 | add edx, esp |
1538 | add edx, esp |
1484 | mov ebx, [esp+64+32-8+4] |
1539 | mov ebx, [esp+64+32-8+4] |
1485 | ; add window start x & y |
1540 | ; add window start x & y |
1486 | mov ecx, [TASK_BASE] |
1541 | mov ecx, [TASK_BASE] |
1487 | 1542 | ||
1488 | mov edi, [CURRENT_TASK] |
1543 | mov edi, [CURRENT_TASK] |
1489 | shl edi, 8 |
1544 | shl edi, 8 |
1490 | 1545 | ||
1491 | mov eax, [ecx-twdw+WDATA.box.left] |
1546 | mov eax, [ecx-twdw+WDATA.box.left] |
1492 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1547 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1493 | shl eax, 16 |
1548 | shl eax, 16 |
1494 | add eax, [ecx-twdw+WDATA.box.top] |
1549 | add eax, [ecx-twdw+WDATA.box.top] |
1495 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1550 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1496 | add ebx, eax |
1551 | add ebx, eax |
1497 | mov ecx, [esp+64+32-12+4] |
1552 | mov ecx, [esp+64+32-12+4] |
1498 | and ecx, not 0x80000000 ; force counted string |
1553 | and ecx, not 0x80000000 ; force counted string |
1499 | mov eax, [esp+64+8] ; background color (if given) |
1554 | mov eax, [esp+64+8] ; background color (if given) |
1500 | mov edi, [esp+64+4] |
1555 | mov edi, [esp+64+4] |
1501 | jmp dtext |
1556 | jmp dtext |
1502 | 1557 | ||
1503 | align 4 |
1558 | align 4 |
1504 | 1559 | ||
1505 | sys_setup: |
1560 | sys_setup: |
1506 | 1561 | ||
1507 | ; 1=roland mpu midi base , base io address |
1562 | ; 1=roland mpu midi base , base io address |
1508 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1563 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1509 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1564 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1510 | ; 5=system language, 1eng 2fi 3ger 4rus |
1565 | ; 5=system language, 1eng 2fi 3ger 4rus |
1511 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1566 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1512 | ; 8=fat32 partition in hd |
1567 | ; 8=fat32 partition in hd |
1513 | ; 9 |
1568 | ; 9 |
1514 | ; 10 = sound dma channel |
1569 | ; 10 = sound dma channel |
1515 | ; 11 = enable lba read |
1570 | ; 11 = enable lba read |
1516 | ; 12 = enable pci access |
1571 | ; 12 = enable pci access |
1517 | 1572 | ||
1518 | 1573 | ||
1519 | and [esp+32], dword 0 |
1574 | and [esp+32], dword 0 |
1520 | dec ebx ; MIDI |
1575 | dec ebx ; MIDI |
1521 | jnz nsyse1 |
1576 | jnz nsyse1 |
1522 | cmp ecx, 0x100 |
1577 | cmp ecx, 0x100 |
1523 | 1578 | ||
1524 | jb nsyse1 |
1579 | jb nsyse1 |
1525 | mov esi, 65535 |
1580 | mov esi, 65535 |
1526 | cmp esi, ecx |
1581 | cmp esi, ecx |
1527 | 1582 | ||
1528 | jb nsyse1 |
1583 | jb nsyse1 |
1529 | mov [midi_base], cx ;bx |
1584 | mov [midi_base], cx ;bx |
1530 | mov word [mididp], cx;bx |
1585 | mov word [mididp], cx;bx |
1531 | inc cx ;bx |
1586 | inc cx ;bx |
1532 | mov word [midisp], cx;bx |
1587 | mov word [midisp], cx;bx |
1533 | ret |
1588 | ret |
1534 | 1589 | ||
1535 | iglobal |
1590 | iglobal |
1536 | midi_base dw 0 |
1591 | midi_base dw 0 |
1537 | endg |
1592 | endg |
1538 | 1593 | ||
1539 | nsyse1: |
1594 | nsyse1: |
1540 | dec ebx ; KEYBOARD |
1595 | dec ebx ; KEYBOARD |
1541 | jnz nsyse2 |
1596 | jnz nsyse2 |
1542 | mov edi, [TASK_BASE] |
1597 | mov edi, [TASK_BASE] |
1543 | mov eax, [edi+TASKDATA.mem_start] |
1598 | mov eax, [edi+TASKDATA.mem_start] |
1544 | add eax, edx |
1599 | add eax, edx |
1545 | 1600 | ||
1546 | dec ecx |
1601 | dec ecx |
1547 | jnz kbnobase |
1602 | jnz kbnobase |
1548 | mov ebx, keymap |
1603 | mov ebx, keymap |
1549 | mov ecx, 128 |
1604 | mov ecx, 128 |
1550 | call memmove |
1605 | call memmove |
1551 | ret |
1606 | ret |
1552 | kbnobase: |
1607 | kbnobase: |
1553 | dec ecx |
1608 | dec ecx |
1554 | jnz kbnoshift |
1609 | jnz kbnoshift |
1555 | 1610 | ||
1556 | mov ebx, keymap_shift |
1611 | mov ebx, keymap_shift |
1557 | mov ecx, 128 |
1612 | mov ecx, 128 |
1558 | call memmove |
1613 | call memmove |
1559 | ret |
1614 | ret |
1560 | kbnoshift: |
1615 | kbnoshift: |
1561 | dec ecx |
1616 | dec ecx |
1562 | jnz kbnoalt |
1617 | jnz kbnoalt |
1563 | mov ebx, keymap_alt |
1618 | mov ebx, keymap_alt |
1564 | mov ecx, 128 |
1619 | mov ecx, 128 |
1565 | call memmove |
1620 | call memmove |
1566 | ret |
1621 | ret |
1567 | kbnoalt: |
1622 | kbnoalt: |
1568 | sub ecx, 6 |
1623 | sub ecx, 6 |
1569 | jnz kbnocountry |
1624 | jnz kbnocountry |
1570 | mov word [keyboard], dx |
1625 | mov word [keyboard], dx |
1571 | ret |
1626 | ret |
1572 | kbnocountry: |
1627 | kbnocountry: |
1573 | mov [esp+32], dword 1 |
1628 | mov [esp+32], dword 1 |
1574 | ret |
1629 | ret |
1575 | nsyse2: |
1630 | nsyse2: |
1576 | dec ebx ; CD |
1631 | dec ebx ; CD |
1577 | jnz nsyse4 |
1632 | jnz nsyse4 |
1578 | 1633 | ||
1579 | test ecx, ecx |
1634 | test ecx, ecx |
1580 | jz nosesl |
1635 | jz nosesl |
1581 | 1636 | ||
1582 | cmp ecx, 4 |
1637 | cmp ecx, 4 |
1583 | ja nosesl |
1638 | ja nosesl |
1584 | mov [cd_base], cl |
1639 | mov [cd_base], cl |
1585 | 1640 | ||
1586 | dec ecx |
1641 | dec ecx |
1587 | jnz noprma |
1642 | jnz noprma |
- | 1643 | mov eax,[hd_address_table] |
|
1588 | mov [cdbase], 0x1f0 |
1644 | mov [cdbase], eax ;0x1f0 |
1589 | mov [cdid], 0xa0 |
1645 | mov [cdid], 0xa0 |
1590 | noprma: |
1646 | noprma: |
1591 | 1647 | ||
1592 | dec ecx |
1648 | dec ecx |
1593 | jnz noprsl |
1649 | jnz noprsl |
- | 1650 | mov eax,[hd_address_table] |
|
1594 | mov [cdbase], 0x1f0 |
1651 | mov [cdbase], eax ;0x1f0 |
1595 | mov [cdid], 0xb0 |
1652 | mov [cdid], 0xb0 |
1596 | noprsl: |
1653 | noprsl: |
1597 | dec ecx |
1654 | dec ecx |
1598 | jnz nosema |
1655 | jnz nosema |
- | 1656 | mov eax,[hd_address_table+16] |
|
1599 | mov [cdbase], 0x170 |
1657 | mov [cdbase], eax ;0x170 |
1600 | mov [cdid], 0xa0 |
1658 | mov [cdid], 0xa0 |
1601 | nosema: |
1659 | nosema: |
1602 | dec ecx |
1660 | dec ecx |
1603 | jnz nosesl |
1661 | jnz nosesl |
- | 1662 | mov eax,[hd_address_table+16] |
|
1604 | mov [cdbase], 0x170 |
1663 | mov [cdbase], eax ;0x170 |
1605 | mov [cdid], 0xb0 |
1664 | mov [cdid], 0xb0 |
1606 | nosesl: |
1665 | nosesl: |
1607 | ret |
1666 | ret |
1608 | 1667 | ||
1609 | iglobal |
1668 | iglobal |
1610 | cd_base db 0 |
1669 | cd_base db 0 |
1611 | 1670 | ||
1612 | endg |
1671 | endg |
1613 | nsyse4: |
1672 | nsyse4: |
1614 | 1673 | ||
1615 | sub ebx, 2 ; SYSTEM LANGUAGE |
1674 | sub ebx, 2 ; SYSTEM LANGUAGE |
1616 | jnz nsyse5 |
1675 | jnz nsyse5 |
1617 | mov [syslang], ecx |
1676 | mov [syslang], ecx |
1618 | ret |
1677 | ret |
1619 | nsyse5: |
1678 | nsyse5: |
1620 | 1679 | ||
1621 | sub ebx, 2 ; HD BASE |
1680 | sub ebx, 2 ; HD BASE |
1622 | jnz nsyse7 |
1681 | jnz nsyse7 |
1623 | 1682 | ||
1624 | test ecx, ecx |
1683 | test ecx, ecx |
1625 | jz nosethd |
1684 | jz nosethd |
1626 | 1685 | ||
1627 | cmp ecx, 4 |
1686 | cmp ecx, 4 |
1628 | ja nosethd |
1687 | ja nosethd |
1629 | mov [hd_base], cl |
1688 | mov [hd_base], cl |
1630 | 1689 | ||
1631 | cmp ecx, 1 |
1690 | cmp ecx, 1 |
1632 | jnz noprmahd |
1691 | jnz noprmahd |
- | 1692 | mov eax,[hd_address_table] |
|
1633 | mov [hdbase], 0x1f0 |
1693 | mov [hdbase], eax ;0x1f0 |
1634 | and dword [hdid], 0x0 |
1694 | and dword [hdid], 0x0 |
1635 | mov dword [hdpos], ecx |
1695 | mov dword [hdpos], ecx |
1636 | ; call set_FAT32_variables |
1696 | ; call set_FAT32_variables |
1637 | noprmahd: |
1697 | noprmahd: |
1638 | 1698 | ||
1639 | cmp ecx, 2 |
1699 | cmp ecx, 2 |
1640 | jnz noprslhd |
1700 | jnz noprslhd |
- | 1701 | mov eax,[hd_address_table] |
|
1641 | mov [hdbase], 0x1f0 |
1702 | mov [hdbase], eax ;0x1f0 |
1642 | mov [hdid], 0x10 |
1703 | mov [hdid], 0x10 |
1643 | mov dword [hdpos], ecx |
1704 | mov dword [hdpos], ecx |
1644 | ; call set_FAT32_variables |
1705 | ; call set_FAT32_variables |
1645 | noprslhd: |
1706 | noprslhd: |
1646 | 1707 | ||
1647 | cmp ecx, 3 |
1708 | cmp ecx, 3 |
1648 | jnz nosemahd |
1709 | jnz nosemahd |
- | 1710 | mov eax,[hd_address_table+16] |
|
1649 | mov [hdbase], 0x170 |
1711 | mov [hdbase], eax ;0x170 |
1650 | and dword [hdid], 0x0 |
1712 | and dword [hdid], 0x0 |
1651 | mov dword [hdpos], ecx |
1713 | mov dword [hdpos], ecx |
1652 | ; call set_FAT32_variables |
1714 | ; call set_FAT32_variables |
1653 | nosemahd: |
1715 | nosemahd: |
1654 | 1716 | ||
1655 | cmp ecx, 4 |
1717 | cmp ecx, 4 |
1656 | jnz noseslhd |
1718 | jnz noseslhd |
- | 1719 | mov eax,[hd_address_table+16] |
|
1657 | mov [hdbase], 0x170 |
1720 | mov [hdbase], eax ;0x170 |
1658 | mov [hdid], 0x10 |
1721 | mov [hdid], 0x10 |
1659 | mov dword [hdpos], ecx |
1722 | mov dword [hdpos], ecx |
1660 | ; call set_FAT32_variables |
1723 | ; call set_FAT32_variables |
1661 | noseslhd: |
1724 | noseslhd: |
1662 | call reserve_hd1 |
1725 | call reserve_hd1 |
1663 | call reserve_hd_channel |
1726 | call reserve_hd_channel |
1664 | call free_hd_channel |
1727 | call free_hd_channel |
1665 | and dword [hd1_status], 0 ; free |
1728 | and dword [hd1_status], 0 ; free |
1666 | nosethd: |
1729 | nosethd: |
1667 | ret |
1730 | ret |
1668 | 1731 | ||
1669 | iglobal |
1732 | iglobal |
1670 | hd_base db 0 |
1733 | hd_base db 0 |
1671 | endg |
1734 | endg |
1672 | 1735 | ||
1673 | nsyse7: |
1736 | nsyse7: |
1674 | 1737 | ||
1675 | ; cmp eax,8 ; HD PARTITION |
1738 | ; cmp eax,8 ; HD PARTITION |
1676 | dec ebx |
1739 | dec ebx |
1677 | jnz nsyse8 |
1740 | jnz nsyse8 |
1678 | mov [fat32part], ecx |
1741 | mov [fat32part], ecx |
1679 | ; call set_FAT32_variables |
1742 | ; call set_FAT32_variables |
1680 | call reserve_hd1 |
1743 | call reserve_hd1 |
1681 | call reserve_hd_channel |
1744 | call reserve_hd_channel |
1682 | call free_hd_channel |
1745 | call free_hd_channel |
1683 | ; pusha |
1746 | ; pusha |
1684 | call choice_necessity_partition_1 |
1747 | call choice_necessity_partition_1 |
1685 | ; popa |
1748 | ; popa |
1686 | and dword [hd1_status], 0 ; free |
1749 | and dword [hd1_status], 0 ; free |
1687 | ret |
1750 | ret |
1688 | 1751 | ||
1689 | nsyse8: |
1752 | nsyse8: |
1690 | ; cmp eax,11 ; ENABLE LBA READ |
1753 | ; cmp eax,11 ; ENABLE LBA READ |
1691 | and ecx, 1 |
1754 | and ecx, 1 |
1692 | sub ebx, 3 |
1755 | sub ebx, 3 |
1693 | jnz no_set_lba_read |
1756 | jnz no_set_lba_read |
1694 | mov [lba_read_enabled], ecx |
1757 | mov [lba_read_enabled], ecx |
1695 | ret |
1758 | ret |
1696 | 1759 | ||
1697 | no_set_lba_read: |
1760 | no_set_lba_read: |
1698 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1761 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1699 | dec ebx |
1762 | dec ebx |
1700 | jnz sys_setup_err |
1763 | jnz sys_setup_err |
1701 | mov [pci_access_enabled], ecx |
1764 | mov [pci_access_enabled], ecx |
1702 | ret |
1765 | ret |
1703 | 1766 | ||
1704 | sys_setup_err: |
1767 | sys_setup_err: |
1705 | or [esp+32], dword -1 |
1768 | or [esp+32], dword -1 |
1706 | ret |
1769 | ret |
1707 | 1770 | ||
1708 | align 4 |
1771 | align 4 |
1709 | 1772 | ||
1710 | sys_getsetup: |
1773 | sys_getsetup: |
1711 | 1774 | ||
1712 | ; 1=roland mpu midi base , base io address |
1775 | ; 1=roland mpu midi base , base io address |
1713 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1776 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1714 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1777 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1715 | ; 5=system language, 1eng 2fi 3ger 4rus |
1778 | ; 5=system language, 1eng 2fi 3ger 4rus |
1716 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1779 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1717 | ; 8=fat32 partition in hd |
1780 | ; 8=fat32 partition in hd |
1718 | ; 9=get hs timer tic |
1781 | ; 9=get hs timer tic |
1719 | 1782 | ||
1720 | ; cmp eax,1 |
1783 | ; cmp eax,1 |
1721 | dec ebx |
1784 | dec ebx |
1722 | jnz ngsyse1 |
1785 | jnz ngsyse1 |
1723 | movzx eax, [midi_base] |
1786 | movzx eax, [midi_base] |
1724 | mov [esp+32], eax |
1787 | mov [esp+32], eax |
1725 | ret |
1788 | ret |
1726 | ngsyse1: |
1789 | ngsyse1: |
1727 | ; cmp eax,2 |
1790 | ; cmp eax,2 |
1728 | dec ebx |
1791 | dec ebx |
1729 | jnz ngsyse2 |
1792 | jnz ngsyse2 |
1730 | 1793 | ||
1731 | mov edi, [TASK_BASE] |
1794 | mov edi, [TASK_BASE] |
1732 | mov ebx, [edi+TASKDATA.mem_start] |
1795 | mov ebx, [edi+TASKDATA.mem_start] |
1733 | add ebx, edx |
1796 | add ebx, edx |
1734 | 1797 | ||
1735 | ; cmp ebx,1 |
1798 | ; cmp ebx,1 |
1736 | dec ecx |
1799 | dec ecx |
1737 | jnz kbnobaseret |
1800 | jnz kbnobaseret |
1738 | mov eax, keymap |
1801 | mov eax, keymap |
1739 | mov ecx, 128 |
1802 | mov ecx, 128 |
1740 | call memmove |
1803 | call memmove |
1741 | ret |
1804 | ret |
1742 | kbnobaseret: |
1805 | kbnobaseret: |
1743 | ; cmp ebx,2 |
1806 | ; cmp ebx,2 |
1744 | dec ecx |
1807 | dec ecx |
1745 | jnz kbnoshiftret |
1808 | jnz kbnoshiftret |
1746 | 1809 | ||
1747 | mov eax, keymap_shift |
1810 | mov eax, keymap_shift |
1748 | mov ecx, 128 |
1811 | mov ecx, 128 |
1749 | call memmove |
1812 | call memmove |
1750 | ret |
1813 | ret |
1751 | kbnoshiftret: |
1814 | kbnoshiftret: |
1752 | ; cmp ebx,3 |
1815 | ; cmp ebx,3 |
1753 | dec ecx |
1816 | dec ecx |
1754 | jne kbnoaltret |
1817 | jne kbnoaltret |
1755 | 1818 | ||
1756 | mov eax, keymap_alt |
1819 | mov eax, keymap_alt |
1757 | mov ecx, 128 |
1820 | mov ecx, 128 |
1758 | call memmove |
1821 | call memmove |
1759 | ret |
1822 | ret |
1760 | kbnoaltret: |
1823 | kbnoaltret: |
1761 | ; cmp ebx,9 |
1824 | ; cmp ebx,9 |
1762 | sub ecx, 6 |
1825 | sub ecx, 6 |
1763 | jnz ngsyse2 |
1826 | jnz ngsyse2 |
1764 | movzx eax, word [keyboard] |
1827 | movzx eax, word [keyboard] |
1765 | mov [esp+32], eax |
1828 | mov [esp+32], eax |
1766 | ret |
1829 | ret |
1767 | 1830 | ||
1768 | 1831 | ||
1769 | ngsyse2: |
1832 | ngsyse2: |
1770 | ; cmp eax,3 |
1833 | ; cmp eax,3 |
1771 | dec ebx |
1834 | dec ebx |
1772 | jnz ngsyse3 |
1835 | jnz ngsyse3 |
1773 | movzx eax, [cd_base] |
1836 | movzx eax, [cd_base] |
1774 | mov [esp+32], eax |
1837 | mov [esp+32], eax |
1775 | ret |
1838 | ret |
1776 | ngsyse3: |
1839 | ngsyse3: |
1777 | ; cmp eax,5 |
1840 | ; cmp eax,5 |
1778 | sub ebx, 2 |
1841 | sub ebx, 2 |
1779 | jnz ngsyse5 |
1842 | jnz ngsyse5 |
1780 | mov eax, [syslang] |
1843 | mov eax, [syslang] |
1781 | mov [esp+32], eax |
1844 | mov [esp+32], eax |
1782 | ret |
1845 | ret |
1783 | ngsyse5: |
1846 | ngsyse5: |
1784 | ; cmp eax,7 |
1847 | ; cmp eax,7 |
1785 | sub ebx, 2 |
1848 | sub ebx, 2 |
1786 | jnz ngsyse7 |
1849 | jnz ngsyse7 |
1787 | movzx eax, [hd_base] |
1850 | movzx eax, [hd_base] |
1788 | mov [esp+32], eax |
1851 | mov [esp+32], eax |
1789 | ret |
1852 | ret |
1790 | ngsyse7: |
1853 | ngsyse7: |
1791 | ; cmp eax,8 |
1854 | ; cmp eax,8 |
1792 | dec ebx |
1855 | dec ebx |
1793 | jnz ngsyse8 |
1856 | jnz ngsyse8 |
1794 | mov eax, [fat32part] |
1857 | mov eax, [fat32part] |
1795 | mov [esp+32], eax |
1858 | mov [esp+32], eax |
1796 | ret |
1859 | ret |
1797 | ngsyse8: |
1860 | ngsyse8: |
1798 | ; cmp eax,9 |
1861 | ; cmp eax,9 |
1799 | dec ebx |
1862 | dec ebx |
1800 | jnz ngsyse9 |
1863 | jnz ngsyse9 |
1801 | mov eax, [timer_ticks];[0xfdf0] |
1864 | mov eax, [timer_ticks];[0xfdf0] |
1802 | mov [esp+32], eax |
1865 | mov [esp+32], eax |
1803 | ret |
1866 | ret |
1804 | ngsyse9: |
1867 | ngsyse9: |
1805 | ; cmp eax,11 |
1868 | ; cmp eax,11 |
1806 | sub ebx, 2 |
1869 | sub ebx, 2 |
1807 | jnz ngsyse11 |
1870 | jnz ngsyse11 |
1808 | mov eax, [lba_read_enabled] |
1871 | mov eax, [lba_read_enabled] |
1809 | mov [esp+32], eax |
1872 | mov [esp+32], eax |
1810 | ret |
1873 | ret |
1811 | ngsyse11: |
1874 | ngsyse11: |
1812 | ; cmp eax,12 |
1875 | ; cmp eax,12 |
1813 | dec ebx |
1876 | dec ebx |
1814 | jnz ngsyse12 |
1877 | jnz ngsyse12 |
1815 | mov eax, [pci_access_enabled] |
1878 | mov eax, [pci_access_enabled] |
1816 | mov [esp+32], eax |
1879 | mov [esp+32], eax |
1817 | ret |
1880 | ret |
1818 | ngsyse12: |
1881 | ngsyse12: |
1819 | mov [esp+32], dword 1 |
1882 | mov [esp+32], dword 1 |
1820 | ret |
1883 | ret |
1821 | 1884 | ||
1822 | 1885 | ||
1823 | get_timer_ticks: |
1886 | get_timer_ticks: |
1824 | mov eax, [timer_ticks] |
1887 | mov eax, [timer_ticks] |
1825 | ret |
1888 | ret |
1826 | 1889 | ||
1827 | iglobal |
1890 | iglobal |
1828 | align 4 |
1891 | align 4 |
1829 | mousefn dd msscreen, mswin, msbutton, msset |
1892 | mousefn dd msscreen, mswin, msbutton, msset |
1830 | dd app_load_cursor |
1893 | dd app_load_cursor |
1831 | dd app_set_cursor |
1894 | dd app_set_cursor |
1832 | dd app_delete_cursor |
1895 | dd app_delete_cursor |
1833 | dd msz |
1896 | dd msz |
1834 | endg |
1897 | endg |
1835 | 1898 | ||
1836 | readmousepos: |
1899 | readmousepos: |
1837 | 1900 | ||
1838 | ; eax=0 screen relative |
1901 | ; eax=0 screen relative |
1839 | ; eax=1 window relative |
1902 | ; eax=1 window relative |
1840 | ; eax=2 buttons pressed |
1903 | ; eax=2 buttons pressed |
1841 | ; eax=3 set mouse pos ; reserved |
1904 | ; eax=3 set mouse pos ; reserved |
1842 | ; eax=4 load cursor |
1905 | ; eax=4 load cursor |
1843 | ; eax=5 set cursor |
1906 | ; eax=5 set cursor |
1844 | ; eax=6 delete cursor ; reserved |
1907 | ; eax=6 delete cursor ; reserved |
1845 | ; eax=7 get mouse_z |
1908 | ; eax=7 get mouse_z |
1846 | 1909 | ||
1847 | cmp ebx, 7 |
1910 | cmp ebx, 7 |
1848 | ja msset |
1911 | ja msset |
1849 | jmp [mousefn+ebx*4] |
1912 | jmp [mousefn+ebx*4] |
1850 | msscreen: |
1913 | msscreen: |
1851 | mov eax, [MOUSE_X] |
1914 | mov eax, [MOUSE_X] |
1852 | shl eax, 16 |
1915 | shl eax, 16 |
1853 | mov ax, [MOUSE_Y] |
1916 | mov ax, [MOUSE_Y] |
1854 | mov [esp+36-4], eax |
1917 | mov [esp+36-4], eax |
1855 | ret |
1918 | ret |
1856 | mswin: |
1919 | mswin: |
1857 | mov eax, [MOUSE_X] |
1920 | mov eax, [MOUSE_X] |
1858 | shl eax, 16 |
1921 | shl eax, 16 |
1859 | mov ax, [MOUSE_Y] |
1922 | mov ax, [MOUSE_Y] |
1860 | mov esi, [TASK_BASE] |
1923 | mov esi, [TASK_BASE] |
1861 | mov bx, word [esi-twdw+WDATA.box.left] |
1924 | mov bx, word [esi-twdw+WDATA.box.left] |
1862 | shl ebx, 16 |
1925 | shl ebx, 16 |
1863 | mov bx, word [esi-twdw+WDATA.box.top] |
1926 | mov bx, word [esi-twdw+WDATA.box.top] |
1864 | sub eax, ebx |
1927 | sub eax, ebx |
1865 | 1928 | ||
1866 | mov edi, [CURRENT_TASK] |
1929 | mov edi, [CURRENT_TASK] |
1867 | shl edi, 8 |
1930 | shl edi, 8 |
1868 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1931 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1869 | rol eax, 16 |
1932 | rol eax, 16 |
1870 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1933 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1871 | rol eax, 16 |
1934 | rol eax, 16 |
1872 | mov [esp+36-4], eax |
1935 | mov [esp+36-4], eax |
1873 | ret |
1936 | ret |
1874 | msbutton: |
1937 | msbutton: |
1875 | movzx eax, byte [BTN_DOWN] |
1938 | movzx eax, byte [BTN_DOWN] |
1876 | mov [esp+36-4], eax |
1939 | mov [esp+36-4], eax |
1877 | ret |
1940 | ret |
1878 | msz: |
1941 | msz: |
1879 | mov edi, [TASK_COUNT] |
1942 | mov edi, [TASK_COUNT] |
1880 | movzx edi, word [WIN_POS + edi*2] |
1943 | movzx edi, word [WIN_POS + edi*2] |
1881 | cmp edi, [CURRENT_TASK] |
1944 | cmp edi, [CURRENT_TASK] |
1882 | jne @f |
1945 | jne @f |
1883 | mov ax, [MOUSE_SCROLL_H] |
1946 | mov ax, [MOUSE_SCROLL_H] |
1884 | shl eax, 16 |
1947 | shl eax, 16 |
1885 | mov ax, [MOUSE_SCROLL_V] |
1948 | mov ax, [MOUSE_SCROLL_V] |
1886 | mov [esp+36-4], eax |
1949 | mov [esp+36-4], eax |
1887 | and [MOUSE_SCROLL_H], word 0 |
1950 | and [MOUSE_SCROLL_H], word 0 |
1888 | and [MOUSE_SCROLL_V], word 0 |
1951 | and [MOUSE_SCROLL_V], word 0 |
1889 | ret |
1952 | ret |
1890 | @@: |
1953 | @@: |
1891 | and [esp+36-4], dword 0 |
1954 | and [esp+36-4], dword 0 |
1892 | ; ret |
1955 | ; ret |
1893 | msset: |
1956 | msset: |
1894 | ret |
1957 | ret |
1895 | 1958 | ||
1896 | app_load_cursor: |
1959 | app_load_cursor: |
1897 | cmp ecx, OS_BASE |
1960 | cmp ecx, OS_BASE |
1898 | jae msset |
1961 | jae msset |
1899 | stdcall load_cursor, ecx, edx |
1962 | stdcall load_cursor, ecx, edx |
1900 | mov [esp+36-4], eax |
1963 | mov [esp+36-4], eax |
1901 | ret |
1964 | ret |
1902 | 1965 | ||
1903 | app_set_cursor: |
1966 | app_set_cursor: |
1904 | stdcall set_cursor, ecx |
1967 | stdcall set_cursor, ecx |
1905 | mov [esp+36-4], eax |
1968 | mov [esp+36-4], eax |
1906 | ret |
1969 | ret |
1907 | 1970 | ||
1908 | app_delete_cursor: |
1971 | app_delete_cursor: |
1909 | stdcall delete_cursor, ecx |
1972 | stdcall delete_cursor, ecx |
1910 | mov [esp+36-4], eax |
1973 | mov [esp+36-4], eax |
1911 | ret |
1974 | ret |
1912 | 1975 | ||
1913 | is_input: |
1976 | is_input: |
1914 | 1977 | ||
1915 | push edx |
1978 | push edx |
1916 | mov dx, word [midisp] |
1979 | mov dx, word [midisp] |
1917 | in al, dx |
1980 | in al, dx |
1918 | and al, 0x80 |
1981 | and al, 0x80 |
1919 | pop edx |
1982 | pop edx |
1920 | ret |
1983 | ret |
1921 | 1984 | ||
1922 | is_output: |
1985 | is_output: |
1923 | 1986 | ||
1924 | push edx |
1987 | push edx |
1925 | mov dx, word [midisp] |
1988 | mov dx, word [midisp] |
1926 | in al, dx |
1989 | in al, dx |
1927 | and al, 0x40 |
1990 | and al, 0x40 |
1928 | pop edx |
1991 | pop edx |
1929 | ret |
1992 | ret |
1930 | 1993 | ||
1931 | 1994 | ||
1932 | get_mpu_in: |
1995 | get_mpu_in: |
1933 | 1996 | ||
1934 | push edx |
1997 | push edx |
1935 | mov dx, word [mididp] |
1998 | mov dx, word [mididp] |
1936 | in al, dx |
1999 | in al, dx |
1937 | pop edx |
2000 | pop edx |
1938 | ret |
2001 | ret |
1939 | 2002 | ||
1940 | 2003 | ||
1941 | put_mpu_out: |
2004 | put_mpu_out: |
1942 | 2005 | ||
1943 | push edx |
2006 | push edx |
1944 | mov dx, word [mididp] |
2007 | mov dx, word [mididp] |
1945 | out dx, al |
2008 | out dx, al |
1946 | pop edx |
2009 | pop edx |
1947 | ret |
2010 | ret |
1948 | 2011 | ||
1949 | 2012 | ||
1950 | 2013 | ||
1951 | align 4 |
2014 | align 4 |
1952 | 2015 | ||
1953 | sys_midi: |
2016 | sys_midi: |
1954 | cmp [mididp], 0 |
2017 | cmp [mididp], 0 |
1955 | jnz sm0 |
2018 | jnz sm0 |
1956 | mov [esp+36], dword 1 |
2019 | mov [esp+36], dword 1 |
1957 | ret |
2020 | ret |
1958 | sm0: |
2021 | sm0: |
1959 | and [esp+36], dword 0 |
2022 | and [esp+36], dword 0 |
1960 | dec ebx |
2023 | dec ebx |
1961 | jnz smn1 |
2024 | jnz smn1 |
1962 | ; call setuart |
2025 | ; call setuart |
1963 | su1: |
2026 | su1: |
1964 | call is_output |
2027 | call is_output |
1965 | test al, al |
2028 | test al, al |
1966 | jnz su1 |
2029 | jnz su1 |
1967 | mov dx, word [midisp] |
2030 | mov dx, word [midisp] |
1968 | mov al, 0xff |
2031 | mov al, 0xff |
1969 | out dx, al |
2032 | out dx, al |
1970 | su2: |
2033 | su2: |
1971 | mov dx, word [midisp] |
2034 | mov dx, word [midisp] |
1972 | mov al, 0xff |
2035 | mov al, 0xff |
1973 | out dx, al |
2036 | out dx, al |
1974 | call is_input |
2037 | call is_input |
1975 | test al, al |
2038 | test al, al |
1976 | jnz su2 |
2039 | jnz su2 |
1977 | call get_mpu_in |
2040 | call get_mpu_in |
1978 | cmp al, 0xfe |
2041 | cmp al, 0xfe |
1979 | jnz su2 |
2042 | jnz su2 |
1980 | su3: |
2043 | su3: |
1981 | call is_output |
2044 | call is_output |
1982 | test al, al |
2045 | test al, al |
1983 | jnz su3 |
2046 | jnz su3 |
1984 | mov dx, word [midisp] |
2047 | mov dx, word [midisp] |
1985 | mov al, 0x3f |
2048 | mov al, 0x3f |
1986 | out dx, al |
2049 | out dx, al |
1987 | ret |
2050 | ret |
1988 | smn1: |
2051 | smn1: |
1989 | dec ebx |
2052 | dec ebx |
1990 | jnz smn2 |
2053 | jnz smn2 |
1991 | sm10: |
2054 | sm10: |
1992 | call get_mpu_in |
2055 | call get_mpu_in |
1993 | call is_output |
2056 | call is_output |
1994 | test al, al |
2057 | test al, al |
1995 | jnz sm10 |
2058 | jnz sm10 |
1996 | mov al, bl |
2059 | mov al, bl |
1997 | call put_mpu_out |
2060 | call put_mpu_out |
1998 | smn2: |
2061 | smn2: |
1999 | ret |
2062 | ret |
2000 | 2063 | ||
2001 | detect_devices: |
2064 | detect_devices: |
2002 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2065 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2003 | ;include 'detect/commouse.inc' |
2066 | ;include 'detect/commouse.inc' |
2004 | ;include 'detect/ps2mouse.inc' |
2067 | ;include 'detect/ps2mouse.inc' |
2005 | ;include 'detect/dev_fd.inc' |
2068 | ;include 'detect/dev_fd.inc' |
2006 | ;include 'detect/dev_hdcd.inc' |
2069 | ;include 'detect/dev_hdcd.inc' |
2007 | ;include 'detect/sear_par.inc' |
2070 | ;include 'detect/sear_par.inc' |
2008 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2071 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2009 | ret |
2072 | ret |
2010 | 2073 | ||
2011 | sys_end: |
2074 | sys_end: |
2012 | ;-------------------------------------- |
2075 | ;-------------------------------------- |
2013 | cmp [_display.select_cursor], 0 |
2076 | cmp [_display.select_cursor], 0 |
2014 | je @f |
2077 | je @f |
2015 | ; restore default cursor before killing |
2078 | ; restore default cursor before killing |
2016 | pusha |
2079 | pusha |
2017 | mov ecx, [current_slot] |
2080 | mov ecx, [current_slot] |
2018 | call restore_default_cursor_before_killing |
2081 | call restore_default_cursor_before_killing |
2019 | popa |
2082 | popa |
2020 | @@: |
2083 | @@: |
2021 | ;-------------------------------------- |
2084 | ;-------------------------------------- |
2022 | ; kill all sockets this process owns |
2085 | ; kill all sockets this process owns |
2023 | pusha |
2086 | pusha |
2024 | mov edx, [TASK_BASE] |
2087 | mov edx, [TASK_BASE] |
2025 | mov edx, [edx+TASKDATA.pid] |
2088 | mov edx, [edx+TASKDATA.pid] |
2026 | call SOCKET_process_end |
2089 | call SOCKET_process_end |
2027 | popa |
2090 | popa |
2028 | ;-------------------------------------- |
2091 | ;-------------------------------------- |
2029 | mov ecx, [current_slot] |
2092 | mov ecx, [current_slot] |
2030 | mov eax, [ecx+APPDATA.tls_base] |
2093 | mov eax, [ecx+APPDATA.tls_base] |
2031 | test eax, eax |
2094 | test eax, eax |
2032 | jz @F |
2095 | jz @F |
2033 | 2096 | ||
2034 | stdcall user_free, eax |
2097 | stdcall user_free, eax |
2035 | @@: |
2098 | @@: |
2036 | 2099 | ||
2037 | mov eax, [TASK_BASE] |
2100 | mov eax, [TASK_BASE] |
2038 | mov [eax+TASKDATA.state], 3; terminate this program |
2101 | mov [eax+TASKDATA.state], 3; terminate this program |
2039 | call wakeup_osloop |
2102 | call wakeup_osloop |
2040 | 2103 | ||
2041 | .waitterm: ; wait here for termination |
2104 | .waitterm: ; wait here for termination |
2042 | call change_task |
2105 | call change_task |
2043 | jmp .waitterm |
2106 | jmp .waitterm |
2044 | ;------------------------------------------------------------------------------ |
2107 | ;------------------------------------------------------------------------------ |
2045 | align 4 |
2108 | align 4 |
2046 | restore_default_cursor_before_killing: |
2109 | restore_default_cursor_before_killing: |
2047 | pushfd |
2110 | pushfd |
2048 | cli |
2111 | cli |
2049 | mov eax, [def_cursor] |
2112 | mov eax, [def_cursor] |
2050 | mov [ecx+APPDATA.cursor], eax |
2113 | mov [ecx+APPDATA.cursor], eax |
2051 | 2114 | ||
2052 | movzx eax, word [MOUSE_Y] |
2115 | movzx eax, word [MOUSE_Y] |
2053 | movzx ebx, word [MOUSE_X] |
2116 | movzx ebx, word [MOUSE_X] |
2054 | ; mov ecx, [Screen_Max_X] |
2117 | ; mov ecx, [Screen_Max_X] |
2055 | ; inc ecx |
2118 | ; inc ecx |
2056 | ; mul ecx |
2119 | ; mul ecx |
2057 | mov eax, [d_width_calc_area + eax*4] |
2120 | mov eax, [d_width_calc_area + eax*4] |
2058 | 2121 | ||
2059 | add eax, [_WinMapAddress] |
2122 | add eax, [_WinMapAddress] |
2060 | movzx edx, byte [ebx+eax] |
2123 | movzx edx, byte [ebx+eax] |
2061 | shl edx, 8 |
2124 | shl edx, 8 |
2062 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2125 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2063 | 2126 | ||
2064 | cmp esi, [current_cursor] |
2127 | cmp esi, [current_cursor] |
2065 | je @f |
2128 | je @f |
2066 | 2129 | ||
2067 | push esi |
2130 | push esi |
2068 | call [_display.select_cursor] |
2131 | call [_display.select_cursor] |
2069 | mov [current_cursor], esi |
2132 | mov [current_cursor], esi |
2070 | @@: |
2133 | @@: |
2071 | mov [redrawmouse_unconditional], 1 |
2134 | mov [redrawmouse_unconditional], 1 |
2072 | call wakeup_osloop |
2135 | call wakeup_osloop |
2073 | popfd |
2136 | popfd |
2074 | ret |
2137 | ret |
2075 | ;------------------------------------------------------------------------------ |
2138 | ;------------------------------------------------------------------------------ |
2076 | iglobal |
2139 | iglobal |
2077 | align 4 |
2140 | align 4 |
2078 | sys_system_table: |
2141 | sys_system_table: |
2079 | dd sysfn_deactivate ; 1 = deactivate window |
2142 | dd sysfn_deactivate ; 1 = deactivate window |
2080 | dd sysfn_terminate ; 2 = terminate thread |
2143 | dd sysfn_terminate ; 2 = terminate thread |
2081 | dd sysfn_activate ; 3 = activate window |
2144 | dd sysfn_activate ; 3 = activate window |
2082 | dd sysfn_getidletime ; 4 = get idle time |
2145 | dd sysfn_getidletime ; 4 = get idle time |
2083 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2146 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2084 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2147 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2085 | dd sysfn_getactive ; 7 = get active window |
2148 | dd sysfn_getactive ; 7 = get active window |
2086 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2149 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2087 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2150 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2088 | dd sysfn_minimize ; 10 = minimize window |
2151 | dd sysfn_minimize ; 10 = minimize window |
2089 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2152 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2090 | dd sysfn_lastkey ; 12 = get last pressed key |
2153 | dd sysfn_lastkey ; 12 = get last pressed key |
2091 | dd sysfn_getversion ; 13 = get kernel version |
2154 | dd sysfn_getversion ; 13 = get kernel version |
2092 | dd sysfn_waitretrace ; 14 = wait retrace |
2155 | dd sysfn_waitretrace ; 14 = wait retrace |
2093 | dd sysfn_centermouse ; 15 = center mouse cursor |
2156 | dd sysfn_centermouse ; 15 = center mouse cursor |
2094 | dd sysfn_getfreemem ; 16 = get free memory size |
2157 | dd sysfn_getfreemem ; 16 = get free memory size |
2095 | dd sysfn_getallmem ; 17 = get total memory size |
2158 | dd sysfn_getallmem ; 17 = get total memory size |
2096 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2159 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2097 | ; instead of slot |
2160 | ; instead of slot |
2098 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2161 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2099 | dd sysfn_meminfo ; 20 = get extended memory info |
2162 | dd sysfn_meminfo ; 20 = get extended memory info |
2100 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2163 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2101 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2164 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2102 | dd sysfn_min_windows ; 23 = minimize all windows |
2165 | dd sysfn_min_windows ; 23 = minimize all windows |
2103 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2166 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2104 | sysfn_num = ($ - sys_system_table)/4 |
2167 | sysfn_num = ($ - sys_system_table)/4 |
2105 | endg |
2168 | endg |
2106 | ;------------------------------------------------------------------------------ |
2169 | ;------------------------------------------------------------------------------ |
2107 | sys_system: |
2170 | sys_system: |
2108 | dec ebx |
2171 | dec ebx |
2109 | cmp ebx, sysfn_num |
2172 | cmp ebx, sysfn_num |
2110 | jae @f |
2173 | jae @f |
2111 | jmp dword [sys_system_table + ebx*4] |
2174 | jmp dword [sys_system_table + ebx*4] |
2112 | @@: |
2175 | @@: |
2113 | ret |
2176 | ret |
2114 | ;------------------------------------------------------------------------------ |
2177 | ;------------------------------------------------------------------------------ |
2115 | sysfn_shutdown: ; 18.9 = system shutdown |
2178 | sysfn_shutdown: ; 18.9 = system shutdown |
2116 | cmp ecx, 1 |
2179 | cmp ecx, 1 |
2117 | jl exit_for_anyone |
2180 | jl exit_for_anyone |
2118 | cmp ecx, 4 |
2181 | cmp ecx, 4 |
2119 | jg exit_for_anyone |
2182 | jg exit_for_anyone |
2120 | mov [BOOT_VAR+0x9030], cl |
2183 | mov [BOOT_VAR+0x9030], cl |
2121 | 2184 | ||
2122 | mov eax, [TASK_COUNT] |
2185 | mov eax, [TASK_COUNT] |
2123 | mov [SYS_SHUTDOWN], al |
2186 | mov [SYS_SHUTDOWN], al |
2124 | mov [shutdown_processes], eax |
2187 | mov [shutdown_processes], eax |
2125 | call wakeup_osloop |
2188 | call wakeup_osloop |
2126 | and dword [esp+32], 0 |
2189 | and dword [esp+32], 0 |
2127 | exit_for_anyone: |
2190 | exit_for_anyone: |
2128 | ret |
2191 | ret |
2129 | uglobal |
2192 | uglobal |
2130 | shutdown_processes: |
2193 | shutdown_processes: |
2131 | dd 0x0 |
2194 | dd 0x0 |
2132 | endg |
2195 | endg |
2133 | ;------------------------------------------------------------------------------ |
2196 | ;------------------------------------------------------------------------------ |
2134 | sysfn_terminate: ; 18.2 = TERMINATE |
2197 | sysfn_terminate: ; 18.2 = TERMINATE |
2135 | push ecx |
2198 | push ecx |
2136 | cmp ecx, 2 |
2199 | cmp ecx, 2 |
2137 | jb noprocessterminate |
2200 | jb noprocessterminate |
2138 | mov edx, [TASK_COUNT] |
2201 | mov edx, [TASK_COUNT] |
2139 | cmp ecx, edx |
2202 | cmp ecx, edx |
2140 | ja noprocessterminate |
2203 | ja noprocessterminate |
2141 | mov eax, [TASK_COUNT] |
2204 | mov eax, [TASK_COUNT] |
2142 | shl ecx, 5 |
2205 | shl ecx, 5 |
2143 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2206 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2144 | add ecx, CURRENT_TASK+TASKDATA.state |
2207 | add ecx, CURRENT_TASK+TASKDATA.state |
2145 | cmp byte [ecx], 9 |
2208 | cmp byte [ecx], 9 |
2146 | jz noprocessterminate |
2209 | jz noprocessterminate |
2147 | push ecx edx |
2210 | push ecx edx |
2148 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2211 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2149 | call request_terminate |
2212 | call request_terminate |
2150 | pop edx ecx |
2213 | pop edx ecx |
2151 | test eax, eax |
2214 | test eax, eax |
2152 | jz noprocessterminate |
2215 | jz noprocessterminate |
2153 | ;-------------------------------------- |
2216 | ;-------------------------------------- |
2154 | ; terminate all network sockets it used |
2217 | ; terminate all network sockets it used |
2155 | pusha |
2218 | pusha |
2156 | mov eax, edx |
2219 | mov eax, edx |
2157 | call SOCKET_process_end |
2220 | call SOCKET_process_end |
2158 | popa |
2221 | popa |
2159 | ;-------------------------------------- |
2222 | ;-------------------------------------- |
2160 | cmp [_display.select_cursor], 0 |
2223 | cmp [_display.select_cursor], 0 |
2161 | je .restore_end |
2224 | je .restore_end |
2162 | ; restore default cursor before killing |
2225 | ; restore default cursor before killing |
2163 | pusha |
2226 | pusha |
2164 | mov ecx, [esp+32] |
2227 | mov ecx, [esp+32] |
2165 | shl ecx, 8 |
2228 | shl ecx, 8 |
2166 | add ecx, SLOT_BASE |
2229 | add ecx, SLOT_BASE |
2167 | mov eax, [def_cursor] |
2230 | mov eax, [def_cursor] |
2168 | cmp [ecx+APPDATA.cursor], eax |
2231 | cmp [ecx+APPDATA.cursor], eax |
2169 | je @f |
2232 | je @f |
2170 | call restore_default_cursor_before_killing |
2233 | call restore_default_cursor_before_killing |
2171 | @@: |
2234 | @@: |
2172 | popa |
2235 | popa |
2173 | .restore_end: |
2236 | .restore_end: |
2174 | ;-------------------------------------- |
2237 | ;-------------------------------------- |
2175 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2238 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2176 | mov [ecx], byte 3; clear possible i40's |
2239 | mov [ecx], byte 3; clear possible i40's |
2177 | call wakeup_osloop |
2240 | call wakeup_osloop |
2178 | ;call MEM_Heap_UnLock |
2241 | ;call MEM_Heap_UnLock |
2179 | 2242 | ||
2180 | cmp edx, [application_table_owner]; clear app table stat |
2243 | cmp edx, [application_table_owner]; clear app table stat |
2181 | jne noatsc |
2244 | jne noatsc |
2182 | call unlock_application_table |
2245 | call unlock_application_table |
2183 | noatsc: |
2246 | noatsc: |
2184 | noprocessterminate: |
2247 | noprocessterminate: |
2185 | add esp, 4 |
2248 | add esp, 4 |
2186 | ret |
2249 | ret |
2187 | ;------------------------------------------------------------------------------ |
2250 | ;------------------------------------------------------------------------------ |
2188 | sysfn_terminate2: |
2251 | sysfn_terminate2: |
2189 | ;lock application_table_status mutex |
2252 | ;lock application_table_status mutex |
2190 | .table_status: |
2253 | .table_status: |
2191 | call lock_application_table |
2254 | call lock_application_table |
2192 | mov eax, ecx |
2255 | mov eax, ecx |
2193 | call pid_to_slot |
2256 | call pid_to_slot |
2194 | test eax, eax |
2257 | test eax, eax |
2195 | jz .not_found |
2258 | jz .not_found |
2196 | mov ecx, eax |
2259 | mov ecx, eax |
2197 | cli |
2260 | cli |
2198 | call sysfn_terminate |
2261 | call sysfn_terminate |
2199 | call unlock_application_table |
2262 | call unlock_application_table |
2200 | sti |
2263 | sti |
2201 | and dword [esp+32], 0 |
2264 | and dword [esp+32], 0 |
2202 | ret |
2265 | ret |
2203 | .not_found: |
2266 | .not_found: |
2204 | call unlock_application_table |
2267 | call unlock_application_table |
2205 | or dword [esp+32], -1 |
2268 | or dword [esp+32], -1 |
2206 | ret |
2269 | ret |
2207 | ;------------------------------------------------------------------------------ |
2270 | ;------------------------------------------------------------------------------ |
2208 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2271 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2209 | cmp ecx, 2 |
2272 | cmp ecx, 2 |
2210 | jb .nowindowdeactivate |
2273 | jb .nowindowdeactivate |
2211 | cmp ecx, [TASK_COUNT] |
2274 | cmp ecx, [TASK_COUNT] |
2212 | ja .nowindowdeactivate |
2275 | ja .nowindowdeactivate |
2213 | 2276 | ||
2214 | movzx esi, word [WIN_STACK + ecx*2] |
2277 | movzx esi, word [WIN_STACK + ecx*2] |
2215 | cmp esi, 1 |
2278 | cmp esi, 1 |
2216 | je .nowindowdeactivate ; already deactive |
2279 | je .nowindowdeactivate ; already deactive |
2217 | 2280 | ||
2218 | mov edi, ecx |
2281 | mov edi, ecx |
2219 | shl edi, 5 |
2282 | shl edi, 5 |
2220 | add edi, window_data |
2283 | add edi, window_data |
2221 | movzx esi, word [WIN_STACK + ecx * 2] |
2284 | movzx esi, word [WIN_STACK + ecx * 2] |
2222 | lea esi, [WIN_POS + esi * 2] |
2285 | lea esi, [WIN_POS + esi * 2] |
2223 | call window._.window_deactivate |
2286 | call window._.window_deactivate |
2224 | 2287 | ||
2225 | call syscall_display_settings._.calculate_whole_screen |
2288 | call syscall_display_settings._.calculate_whole_screen |
2226 | call syscall_display_settings._.redraw_whole_screen |
2289 | call syscall_display_settings._.redraw_whole_screen |
2227 | .nowindowdeactivate: |
2290 | .nowindowdeactivate: |
2228 | ret |
2291 | ret |
2229 | ;------------------------------------------------------------------------------ |
2292 | ;------------------------------------------------------------------------------ |
2230 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2293 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2231 | cmp ecx, 2 |
2294 | cmp ecx, 2 |
2232 | jb .nowindowactivate |
2295 | jb .nowindowactivate |
2233 | cmp ecx, [TASK_COUNT] |
2296 | cmp ecx, [TASK_COUNT] |
2234 | ja .nowindowactivate |
2297 | ja .nowindowactivate |
2235 | ;------------------------------------- |
2298 | ;------------------------------------- |
2236 | @@: |
2299 | @@: |
2237 | ; If the window is captured and moved by the user, |
2300 | ; If the window is captured and moved by the user, |
2238 | ; then you can't change the position in window stack!!! |
2301 | ; then you can't change the position in window stack!!! |
2239 | mov al, [mouse.active_sys_window.action] |
2302 | mov al, [mouse.active_sys_window.action] |
2240 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2303 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2241 | test al, al |
2304 | test al, al |
2242 | jz @f |
2305 | jz @f |
2243 | call change_task |
2306 | call change_task |
2244 | jmp @b |
2307 | jmp @b |
2245 | @@: |
2308 | @@: |
2246 | ;------------------------------------- |
2309 | ;------------------------------------- |
2247 | mov [window_minimize], 2; restore window if minimized |
2310 | mov [window_minimize], 2; restore window if minimized |
2248 | call wakeup_osloop |
2311 | call wakeup_osloop |
2249 | 2312 | ||
2250 | movzx esi, word [WIN_STACK + ecx*2] |
2313 | movzx esi, word [WIN_STACK + ecx*2] |
2251 | cmp esi, [TASK_COUNT] |
2314 | cmp esi, [TASK_COUNT] |
2252 | je .nowindowactivate; already active |
2315 | je .nowindowactivate; already active |
2253 | 2316 | ||
2254 | mov edi, ecx |
2317 | mov edi, ecx |
2255 | shl edi, 5 |
2318 | shl edi, 5 |
2256 | add edi, window_data |
2319 | add edi, window_data |
2257 | movzx esi, word [WIN_STACK + ecx * 2] |
2320 | movzx esi, word [WIN_STACK + ecx * 2] |
2258 | lea esi, [WIN_POS + esi * 2] |
2321 | lea esi, [WIN_POS + esi * 2] |
2259 | call waredraw |
2322 | call waredraw |
2260 | .nowindowactivate: |
2323 | .nowindowactivate: |
2261 | ret |
2324 | ret |
2262 | ;------------------------------------------------------------------------------ |
2325 | ;------------------------------------------------------------------------------ |
2263 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2326 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2264 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2327 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2265 | mov [esp+32], eax |
2328 | mov [esp+32], eax |
2266 | ret |
2329 | ret |
2267 | ;------------------------------------------------------------------------------ |
2330 | ;------------------------------------------------------------------------------ |
2268 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2331 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2269 | mov eax, dword [cpu_freq] |
2332 | mov eax, dword [cpu_freq] |
2270 | mov [esp+32], eax |
2333 | mov [esp+32], eax |
2271 | ret |
2334 | ret |
2272 | ;------------------------------------------------------------------------------ |
2335 | ;------------------------------------------------------------------------------ |
2273 | get_cpu_freq: |
2336 | get_cpu_freq: |
2274 | mov eax, dword [cpu_freq] |
2337 | mov eax, dword [cpu_freq] |
2275 | mov edx, dword [cpu_freq+4] |
2338 | mov edx, dword [cpu_freq+4] |
2276 | ret |
2339 | ret |
2277 | ; SAVE ramdisk to /hd/1/menuet.img |
2340 | ; SAVE ramdisk to /hd/1/menuet.img |
2278 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2341 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2279 | include 'blkdev/rdsave.inc' |
2342 | include 'blkdev/rdsave.inc' |
2280 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2343 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2281 | ;------------------------------------------------------------------------------ |
2344 | ;------------------------------------------------------------------------------ |
2282 | align 4 |
2345 | align 4 |
2283 | sysfn_getactive: ; 18.7 = get active window |
2346 | sysfn_getactive: ; 18.7 = get active window |
2284 | mov eax, [TASK_COUNT] |
2347 | mov eax, [TASK_COUNT] |
2285 | movzx eax, word [WIN_POS + eax*2] |
2348 | movzx eax, word [WIN_POS + eax*2] |
2286 | mov [esp+32], eax |
2349 | mov [esp+32], eax |
2287 | ret |
2350 | ret |
2288 | ;------------------------------------------------------------------------------ |
2351 | ;------------------------------------------------------------------------------ |
2289 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2352 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2290 | ; cmp ecx,1 |
2353 | ; cmp ecx,1 |
2291 | dec ecx |
2354 | dec ecx |
2292 | jnz nogetsoundflag |
2355 | jnz nogetsoundflag |
2293 | movzx eax, byte [sound_flag]; get sound_flag |
2356 | movzx eax, byte [sound_flag]; get sound_flag |
2294 | mov [esp+32], eax |
2357 | mov [esp+32], eax |
2295 | ret |
2358 | ret |
2296 | nogetsoundflag: |
2359 | nogetsoundflag: |
2297 | ; cmp ecx,2 |
2360 | ; cmp ecx,2 |
2298 | dec ecx |
2361 | dec ecx |
2299 | jnz nosoundflag |
2362 | jnz nosoundflag |
2300 | xor byte [sound_flag], 1 |
2363 | xor byte [sound_flag], 1 |
2301 | nosoundflag: |
2364 | nosoundflag: |
2302 | ret |
2365 | ret |
2303 | ;------------------------------------------------------------------------------ |
2366 | ;------------------------------------------------------------------------------ |
2304 | sysfn_minimize: ; 18.10 = minimize window |
2367 | sysfn_minimize: ; 18.10 = minimize window |
2305 | mov [window_minimize], 1 |
2368 | mov [window_minimize], 1 |
2306 | call wakeup_osloop |
2369 | call wakeup_osloop |
2307 | ret |
2370 | ret |
2308 | ;------------------------------------------------------------------------------ |
2371 | ;------------------------------------------------------------------------------ |
2309 | align 4 |
2372 | align 4 |
2310 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2373 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2311 | ; cmp ecx,1 |
2374 | ; cmp ecx,1 |
2312 | dec ecx |
2375 | dec ecx |
2313 | jnz full_table |
2376 | jnz full_table |
2314 | small_table: |
2377 | small_table: |
2315 | call for_all_tables |
2378 | call for_all_tables |
2316 | mov ecx, 10 |
2379 | mov ecx, 10 |
2317 | cld |
2380 | cld |
2318 | rep movsb |
2381 | rep movsb |
2319 | ret |
2382 | ret |
2320 | for_all_tables: |
2383 | for_all_tables: |
2321 | mov edi, edx |
2384 | mov edi, edx |
2322 | mov esi, DRIVE_DATA |
2385 | mov esi, DRIVE_DATA |
2323 | ret |
2386 | ret |
2324 | full_table: |
2387 | full_table: |
2325 | ; cmp ecx,2 |
2388 | ; cmp ecx,2 |
2326 | dec ecx |
2389 | dec ecx |
2327 | jnz exit_for_anyone |
2390 | jnz exit_for_anyone |
2328 | call for_all_tables |
2391 | call for_all_tables |
2329 | mov ecx, DRIVE_DATA_SIZE/4 |
2392 | mov ecx, DRIVE_DATA_SIZE/4 |
2330 | cld |
2393 | cld |
2331 | rep movsd |
2394 | rep movsd |
2332 | ret |
2395 | ret |
2333 | ;------------------------------------------------------------------------------ |
2396 | ;------------------------------------------------------------------------------ |
2334 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2397 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2335 | and dword [esp+32], 0 |
2398 | and dword [esp+32], 0 |
2336 | ret |
2399 | ret |
2337 | ;------------------------------------------------------------------------------ |
2400 | ;------------------------------------------------------------------------------ |
2338 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2401 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2339 | mov edi, ecx |
2402 | mov edi, ecx |
2340 | mov esi, version_inf |
2403 | mov esi, version_inf |
2341 | mov ecx, version_end-version_inf |
2404 | mov ecx, version_end-version_inf |
2342 | rep movsb |
2405 | rep movsb |
2343 | ret |
2406 | ret |
2344 | ;------------------------------------------------------------------------------ |
2407 | ;------------------------------------------------------------------------------ |
2345 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2408 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2346 | ;wait retrace functions |
2409 | ;wait retrace functions |
2347 | sys_wait_retrace: |
2410 | sys_wait_retrace: |
2348 | mov edx, 0x3da |
2411 | mov edx, 0x3da |
2349 | WaitRetrace_loop: |
2412 | WaitRetrace_loop: |
2350 | in al, dx |
2413 | in al, dx |
2351 | test al, 1000b |
2414 | test al, 1000b |
2352 | jz WaitRetrace_loop |
2415 | jz WaitRetrace_loop |
2353 | and [esp+32], dword 0 |
2416 | and [esp+32], dword 0 |
2354 | ret |
2417 | ret |
2355 | ;------------------------------------------------------------------------------ |
2418 | ;------------------------------------------------------------------------------ |
2356 | align 4 |
2419 | align 4 |
2357 | sysfn_centermouse: ; 18.15 = mouse centered |
2420 | sysfn_centermouse: ; 18.15 = mouse centered |
2358 | ; removed here by |
2421 | ; removed here by |
2359 | ; call mouse_centered |
2422 | ; call mouse_centered |
2360 | ;* mouse centered - start code- Mario79 |
2423 | ;* mouse centered - start code- Mario79 |
2361 | ;mouse_centered: |
2424 | ;mouse_centered: |
2362 | ; push eax |
2425 | ; push eax |
2363 | mov eax, [Screen_Max_X] |
2426 | mov eax, [Screen_Max_X] |
2364 | shr eax, 1 |
2427 | shr eax, 1 |
2365 | mov [MOUSE_X], ax |
2428 | mov [MOUSE_X], ax |
2366 | mov eax, [Screen_Max_Y] |
2429 | mov eax, [Screen_Max_Y] |
2367 | shr eax, 1 |
2430 | shr eax, 1 |
2368 | mov [MOUSE_Y], ax |
2431 | mov [MOUSE_Y], ax |
2369 | call wakeup_osloop |
2432 | call wakeup_osloop |
2370 | ; ret |
2433 | ; ret |
2371 | ;* mouse centered - end code- Mario79 |
2434 | ;* mouse centered - end code- Mario79 |
2372 | xor eax, eax |
2435 | xor eax, eax |
2373 | and [esp+32], eax |
2436 | and [esp+32], eax |
2374 | ; pop eax |
2437 | ; pop eax |
2375 | ret |
2438 | ret |
2376 | ;------------------------------------------------------------------------------ |
2439 | ;------------------------------------------------------------------------------ |
2377 | align 4 |
2440 | align 4 |
2378 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2441 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2379 | test ecx, ecx; get mouse speed factor |
2442 | test ecx, ecx; get mouse speed factor |
2380 | jnz .set_mouse_acceleration |
2443 | jnz .set_mouse_acceleration |
2381 | xor eax, eax |
2444 | xor eax, eax |
2382 | mov ax, [mouse_speed_factor] |
2445 | mov ax, [mouse_speed_factor] |
2383 | mov [esp+32], eax |
2446 | mov [esp+32], eax |
2384 | ret |
2447 | ret |
2385 | .set_mouse_acceleration: |
2448 | .set_mouse_acceleration: |
2386 | ; cmp ecx,1 ; set mouse speed factor |
2449 | ; cmp ecx,1 ; set mouse speed factor |
2387 | dec ecx |
2450 | dec ecx |
2388 | jnz .get_mouse_delay |
2451 | jnz .get_mouse_delay |
2389 | mov [mouse_speed_factor], dx |
2452 | mov [mouse_speed_factor], dx |
2390 | ret |
2453 | ret |
2391 | .get_mouse_delay: |
2454 | .get_mouse_delay: |
2392 | ; cmp ecx,2 ; get mouse delay |
2455 | ; cmp ecx,2 ; get mouse delay |
2393 | dec ecx |
2456 | dec ecx |
2394 | jnz .set_mouse_delay |
2457 | jnz .set_mouse_delay |
2395 | mov eax, [mouse_delay] |
2458 | mov eax, [mouse_delay] |
2396 | mov [esp+32], eax |
2459 | mov [esp+32], eax |
2397 | ret |
2460 | ret |
2398 | .set_mouse_delay: |
2461 | .set_mouse_delay: |
2399 | ; cmp ecx,3 ; set mouse delay |
2462 | ; cmp ecx,3 ; set mouse delay |
2400 | dec ecx |
2463 | dec ecx |
2401 | jnz .set_pointer_position |
2464 | jnz .set_pointer_position |
2402 | mov [mouse_delay], edx |
2465 | mov [mouse_delay], edx |
2403 | ret |
2466 | ret |
2404 | .set_pointer_position: |
2467 | .set_pointer_position: |
2405 | ; cmp ecx,4 ; set mouse pointer position |
2468 | ; cmp ecx,4 ; set mouse pointer position |
2406 | dec ecx |
2469 | dec ecx |
2407 | jnz .set_mouse_button |
2470 | jnz .set_mouse_button |
2408 | cmp dx, word[Screen_Max_Y] |
2471 | cmp dx, word[Screen_Max_Y] |
2409 | ja .end |
2472 | ja .end |
2410 | rol edx, 16 |
2473 | rol edx, 16 |
2411 | cmp dx, word[Screen_Max_X] |
2474 | cmp dx, word[Screen_Max_X] |
2412 | ja .end |
2475 | ja .end |
2413 | mov [MOUSE_X], edx |
2476 | mov [MOUSE_X], edx |
2414 | call wakeup_osloop |
2477 | call wakeup_osloop |
2415 | ret |
2478 | ret |
2416 | .set_mouse_button: |
2479 | .set_mouse_button: |
2417 | ; cmp ecx,5 ; set mouse button features |
2480 | ; cmp ecx,5 ; set mouse button features |
2418 | dec ecx |
2481 | dec ecx |
2419 | jnz .end |
2482 | jnz .end |
2420 | mov [BTN_DOWN], dl |
2483 | mov [BTN_DOWN], dl |
2421 | mov [mouse_active], 1 |
2484 | mov [mouse_active], 1 |
2422 | call wakeup_osloop |
2485 | call wakeup_osloop |
2423 | .end: |
2486 | .end: |
2424 | ret |
2487 | ret |
2425 | ;------------------------------------------------------------------------------ |
2488 | ;------------------------------------------------------------------------------ |
2426 | sysfn_getfreemem: |
2489 | sysfn_getfreemem: |
2427 | mov eax, [pg_data.pages_free] |
2490 | mov eax, [pg_data.pages_free] |
2428 | shl eax, 2 |
2491 | shl eax, 2 |
2429 | mov [esp+32], eax |
2492 | mov [esp+32], eax |
2430 | ret |
2493 | ret |
2431 | ;------------------------------------------------------------------------------ |
2494 | ;------------------------------------------------------------------------------ |
2432 | sysfn_getallmem: |
2495 | sysfn_getallmem: |
2433 | mov eax, [MEM_AMOUNT] |
2496 | mov eax, [MEM_AMOUNT] |
2434 | shr eax, 10 |
2497 | shr eax, 10 |
2435 | mov [esp+32], eax |
2498 | mov [esp+32], eax |
2436 | ret |
2499 | ret |
2437 | ;------------------------------------------------------------------------------ |
2500 | ;------------------------------------------------------------------------------ |
2438 | sysfn_pid_to_slot: |
2501 | sysfn_pid_to_slot: |
2439 | mov eax, ecx |
2502 | mov eax, ecx |
2440 | call pid_to_slot |
2503 | call pid_to_slot |
2441 | mov [esp+32], eax |
2504 | mov [esp+32], eax |
2442 | ret |
2505 | ret |
2443 | ;------------------------------------------------------------------------------ |
2506 | ;------------------------------------------------------------------------------ |
2444 | sysfn_min_rest_window: |
2507 | sysfn_min_rest_window: |
2445 | pushad |
2508 | pushad |
2446 | mov eax, edx ; ebx - operating |
2509 | mov eax, edx ; ebx - operating |
2447 | shr ecx, 1 |
2510 | shr ecx, 1 |
2448 | jnc @f |
2511 | jnc @f |
2449 | call pid_to_slot |
2512 | call pid_to_slot |
2450 | @@: |
2513 | @@: |
2451 | or eax, eax ; eax - number of slot |
2514 | or eax, eax ; eax - number of slot |
2452 | jz .error |
2515 | jz .error |
2453 | cmp eax, 255 ; varify maximal slot number |
2516 | cmp eax, 255 ; varify maximal slot number |
2454 | ja .error |
2517 | ja .error |
2455 | movzx eax, word [WIN_STACK + eax*2] |
2518 | movzx eax, word [WIN_STACK + eax*2] |
2456 | shr ecx, 1 |
2519 | shr ecx, 1 |
2457 | jc .restore |
2520 | jc .restore |
2458 | ; .minimize: |
2521 | ; .minimize: |
2459 | call minimize_window |
2522 | call minimize_window |
2460 | jmp .exit |
2523 | jmp .exit |
2461 | .restore: |
2524 | .restore: |
2462 | call restore_minimized_window |
2525 | call restore_minimized_window |
2463 | .exit: |
2526 | .exit: |
2464 | popad |
2527 | popad |
2465 | xor eax, eax |
2528 | xor eax, eax |
2466 | mov [esp+32], eax |
2529 | mov [esp+32], eax |
2467 | ret |
2530 | ret |
2468 | .error: |
2531 | .error: |
2469 | popad |
2532 | popad |
2470 | xor eax, eax |
2533 | xor eax, eax |
2471 | dec eax |
2534 | dec eax |
2472 | mov [esp+32], eax |
2535 | mov [esp+32], eax |
2473 | ret |
2536 | ret |
2474 | ;------------------------------------------------------------------------------ |
2537 | ;------------------------------------------------------------------------------ |
2475 | sysfn_min_windows: |
2538 | sysfn_min_windows: |
2476 | call minimize_all_window |
2539 | call minimize_all_window |
2477 | mov [esp+32], eax |
2540 | mov [esp+32], eax |
2478 | call change_task |
2541 | call change_task |
2479 | ret |
2542 | ret |
2480 | ;------------------------------------------------------------------------------ |
2543 | ;------------------------------------------------------------------------------ |
2481 | sysfn_set_screen_sizes: |
2544 | sysfn_set_screen_sizes: |
2482 | cmp [SCR_MODE], word 0x13 |
2545 | cmp [SCR_MODE], word 0x13 |
2483 | jbe .exit |
2546 | jbe .exit |
2484 | 2547 | ||
2485 | cmp [_display.select_cursor], select_cursor |
2548 | cmp [_display.select_cursor], select_cursor |
2486 | jne .exit |
2549 | jne .exit |
2487 | 2550 | ||
2488 | cmp ecx, [display_width_standard] |
2551 | cmp ecx, [display_width_standard] |
2489 | ja .exit |
2552 | ja .exit |
2490 | 2553 | ||
2491 | cmp edx, [display_height_standard] |
2554 | cmp edx, [display_height_standard] |
2492 | ja .exit |
2555 | ja .exit |
2493 | 2556 | ||
2494 | pushfd |
2557 | pushfd |
2495 | cli |
2558 | cli |
2496 | mov eax, ecx |
2559 | mov eax, ecx |
2497 | mov ecx, [_display.pitch] |
2560 | mov ecx, [_display.pitch] |
2498 | mov [_display.width], eax |
2561 | mov [_display.width], eax |
2499 | dec eax |
2562 | dec eax |
2500 | mov [_display.height], edx |
2563 | mov [_display.height], edx |
2501 | dec edx |
2564 | dec edx |
2502 | ; eax - new Screen_Max_X |
2565 | ; eax - new Screen_Max_X |
2503 | ; edx - new Screen_Max_Y |
2566 | ; edx - new Screen_Max_Y |
2504 | mov [do_not_touch_winmap], 1 |
2567 | mov [do_not_touch_winmap], 1 |
2505 | call set_screen |
2568 | call set_screen |
2506 | mov [do_not_touch_winmap], 0 |
2569 | mov [do_not_touch_winmap], 0 |
2507 | popfd |
2570 | popfd |
2508 | call change_task |
2571 | call change_task |
2509 | .exit: |
2572 | .exit: |
2510 | ret |
2573 | ret |
2511 | ;------------------------------------------------------------------------------ |
2574 | ;------------------------------------------------------------------------------ |
2512 | uglobal |
2575 | uglobal |
2513 | screen_workarea RECT |
2576 | screen_workarea RECT |
2514 | display_width_standard dd 0 |
2577 | display_width_standard dd 0 |
2515 | display_height_standard dd 0 |
2578 | display_height_standard dd 0 |
2516 | do_not_touch_winmap db 0 |
2579 | do_not_touch_winmap db 0 |
2517 | window_minimize db 0 |
2580 | window_minimize db 0 |
2518 | sound_flag db 0 |
2581 | sound_flag db 0 |
2519 | 2582 | ||
2520 | endg |
2583 | endg |
2521 | 2584 | ||
2522 | UID_NONE=0 |
2585 | UID_NONE=0 |
2523 | UID_MENUETOS=1 ;official |
2586 | UID_MENUETOS=1 ;official |
2524 | UID_KOLIBRI=2 ;russian |
2587 | UID_KOLIBRI=2 ;russian |
2525 | 2588 | ||
2526 | iglobal |
2589 | iglobal |
2527 | version_inf: |
2590 | version_inf: |
2528 | db 0,7,7,0 ; version 0.7.7.0 |
2591 | db 0,7,7,0 ; version 0.7.7.0 |
2529 | db 0 |
2592 | db 0 |
2530 | .rev dd __REV__ |
2593 | .rev dd __REV__ |
2531 | version_end: |
2594 | version_end: |
2532 | endg |
2595 | endg |
2533 | ;------------------------------------------------------------------------------ |
2596 | ;------------------------------------------------------------------------------ |
2534 | align 4 |
2597 | align 4 |
2535 | sys_cachetodiskette: |
2598 | sys_cachetodiskette: |
2536 | cmp ebx, 1 |
2599 | cmp ebx, 1 |
2537 | jne .no_floppy_a_save |
2600 | jne .no_floppy_a_save |
2538 | mov [flp_number], 1 |
2601 | mov [flp_number], 1 |
2539 | jmp .save_image_on_floppy |
2602 | jmp .save_image_on_floppy |
2540 | ;-------------------------------------- |
2603 | ;-------------------------------------- |
2541 | align 4 |
2604 | align 4 |
2542 | .no_floppy_a_save: |
2605 | .no_floppy_a_save: |
2543 | cmp ebx, 2 |
2606 | cmp ebx, 2 |
2544 | jne .no_floppy_b_save |
2607 | jne .no_floppy_b_save |
2545 | mov [flp_number], 2 |
2608 | mov [flp_number], 2 |
2546 | ;-------------------------------------- |
2609 | ;-------------------------------------- |
2547 | align 4 |
2610 | align 4 |
2548 | .save_image_on_floppy: |
2611 | .save_image_on_floppy: |
2549 | call save_image |
2612 | call save_image |
2550 | mov [esp + 32], dword 0 |
2613 | mov [esp + 32], dword 0 |
2551 | cmp [FDC_Status], 0 |
2614 | cmp [FDC_Status], 0 |
2552 | je .yes_floppy_save |
2615 | je .yes_floppy_save |
2553 | ;-------------------------------------- |
2616 | ;-------------------------------------- |
2554 | align 4 |
2617 | align 4 |
2555 | .no_floppy_b_save: |
2618 | .no_floppy_b_save: |
2556 | mov [esp + 32], dword 1 |
2619 | mov [esp + 32], dword 1 |
2557 | ;-------------------------------------- |
2620 | ;-------------------------------------- |
2558 | align 4 |
2621 | align 4 |
2559 | .yes_floppy_save: |
2622 | .yes_floppy_save: |
2560 | ret |
2623 | ret |
2561 | ;------------------------------------------------------------------------------ |
2624 | ;------------------------------------------------------------------------------ |
2562 | uglobal |
2625 | uglobal |
2563 | ; bgrchanged dd 0x0 |
2626 | ; bgrchanged dd 0x0 |
2564 | align 4 |
2627 | align 4 |
2565 | bgrlockpid dd 0 |
2628 | bgrlockpid dd 0 |
2566 | bgrlock db 0 |
2629 | bgrlock db 0 |
2567 | endg |
2630 | endg |
2568 | ;------------------------------------------------------------------------------ |
2631 | ;------------------------------------------------------------------------------ |
2569 | align 4 |
2632 | align 4 |
2570 | sys_background: |
2633 | sys_background: |
2571 | cmp ebx, 1 ; BACKGROUND SIZE |
2634 | cmp ebx, 1 ; BACKGROUND SIZE |
2572 | jnz nosb1 |
2635 | jnz nosb1 |
2573 | test ecx, ecx |
2636 | test ecx, ecx |
2574 | jz sbgrr |
2637 | jz sbgrr |
2575 | 2638 | ||
2576 | test edx, edx |
2639 | test edx, edx |
2577 | jz sbgrr |
2640 | jz sbgrr |
2578 | ;-------------------------------------- |
2641 | ;-------------------------------------- |
2579 | align 4 |
2642 | align 4 |
2580 | @@: |
2643 | @@: |
2581 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2644 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2582 | bts dword [bgrlock], 0 |
2645 | bts dword [bgrlock], 0 |
2583 | jnc @f |
2646 | jnc @f |
2584 | call change_task |
2647 | call change_task |
2585 | jmp @b |
2648 | jmp @b |
2586 | ;-------------------------------------- |
2649 | ;-------------------------------------- |
2587 | align 4 |
2650 | align 4 |
2588 | @@: |
2651 | @@: |
2589 | mov [BgrDataWidth], ecx |
2652 | mov [BgrDataWidth], ecx |
2590 | mov [BgrDataHeight], edx |
2653 | mov [BgrDataHeight], edx |
2591 | ; mov [bgrchanged],1 |
2654 | ; mov [bgrchanged],1 |
2592 | 2655 | ||
2593 | pushad |
2656 | pushad |
2594 | ; return memory for old background |
2657 | ; return memory for old background |
2595 | mov eax, [img_background] |
2658 | mov eax, [img_background] |
2596 | cmp eax, static_background_data |
2659 | cmp eax, static_background_data |
2597 | jz @f |
2660 | jz @f |
2598 | stdcall kernel_free, eax |
2661 | stdcall kernel_free, eax |
2599 | ;-------------------------------------- |
2662 | ;-------------------------------------- |
2600 | align 4 |
2663 | align 4 |
2601 | @@: |
2664 | @@: |
2602 | ; calculate RAW size |
2665 | ; calculate RAW size |
2603 | xor eax, eax |
2666 | xor eax, eax |
2604 | inc eax |
2667 | inc eax |
2605 | cmp [BgrDataWidth], eax |
2668 | cmp [BgrDataWidth], eax |
2606 | jae @f |
2669 | jae @f |
2607 | mov [BgrDataWidth], eax |
2670 | mov [BgrDataWidth], eax |
2608 | ;-------------------------------------- |
2671 | ;-------------------------------------- |
2609 | align 4 |
2672 | align 4 |
2610 | @@: |
2673 | @@: |
2611 | cmp [BgrDataHeight], eax |
2674 | cmp [BgrDataHeight], eax |
2612 | jae @f |
2675 | jae @f |
2613 | mov [BgrDataHeight], eax |
2676 | mov [BgrDataHeight], eax |
2614 | ;-------------------------------------- |
2677 | ;-------------------------------------- |
2615 | align 4 |
2678 | align 4 |
2616 | @@: |
2679 | @@: |
2617 | mov eax, [BgrDataWidth] |
2680 | mov eax, [BgrDataWidth] |
2618 | imul eax, [BgrDataHeight] |
2681 | imul eax, [BgrDataHeight] |
2619 | lea eax, [eax*3] |
2682 | lea eax, [eax*3] |
2620 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2683 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2621 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2684 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2622 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2685 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2623 | shr eax, 12 |
2686 | shr eax, 12 |
2624 | inc eax |
2687 | inc eax |
2625 | shl eax, 12 |
2688 | shl eax, 12 |
2626 | mov [mem_BACKGROUND], eax |
2689 | mov [mem_BACKGROUND], eax |
2627 | ; get memory for new background |
2690 | ; get memory for new background |
2628 | stdcall kernel_alloc, eax |
2691 | stdcall kernel_alloc, eax |
2629 | test eax, eax |
2692 | test eax, eax |
2630 | jz .memfailed |
2693 | jz .memfailed |
2631 | mov [img_background], eax |
2694 | mov [img_background], eax |
2632 | jmp .exit |
2695 | jmp .exit |
2633 | ;-------------------------------------- |
2696 | ;-------------------------------------- |
2634 | align 4 |
2697 | align 4 |
2635 | .memfailed: |
2698 | .memfailed: |
2636 | ; revert to static monotone data |
2699 | ; revert to static monotone data |
2637 | mov [img_background], static_background_data |
2700 | mov [img_background], static_background_data |
2638 | xor eax, eax |
2701 | xor eax, eax |
2639 | inc eax |
2702 | inc eax |
2640 | mov [BgrDataWidth], eax |
2703 | mov [BgrDataWidth], eax |
2641 | mov [BgrDataHeight], eax |
2704 | mov [BgrDataHeight], eax |
2642 | mov [mem_BACKGROUND], 4 |
2705 | mov [mem_BACKGROUND], 4 |
2643 | ;-------------------------------------- |
2706 | ;-------------------------------------- |
2644 | align 4 |
2707 | align 4 |
2645 | .exit: |
2708 | .exit: |
2646 | popad |
2709 | popad |
2647 | mov [bgrlock], 0 |
2710 | mov [bgrlock], 0 |
2648 | ;-------------------------------------- |
2711 | ;-------------------------------------- |
2649 | align 4 |
2712 | align 4 |
2650 | sbgrr: |
2713 | sbgrr: |
2651 | ret |
2714 | ret |
2652 | ;------------------------------------------------------------------------------ |
2715 | ;------------------------------------------------------------------------------ |
2653 | align 4 |
2716 | align 4 |
2654 | nosb1: |
2717 | nosb1: |
2655 | cmp ebx, 2 ; SET PIXEL |
2718 | cmp ebx, 2 ; SET PIXEL |
2656 | jnz nosb2 |
2719 | jnz nosb2 |
2657 | 2720 | ||
2658 | mov eax, [img_background] |
2721 | mov eax, [img_background] |
2659 | test ecx, ecx |
2722 | test ecx, ecx |
2660 | jz @f |
2723 | jz @f |
2661 | cmp eax, static_background_data |
2724 | cmp eax, static_background_data |
2662 | jz .ret |
2725 | jz .ret |
2663 | ;-------------------------------------- |
2726 | ;-------------------------------------- |
2664 | align 4 |
2727 | align 4 |
2665 | @@: |
2728 | @@: |
2666 | mov ebx, [mem_BACKGROUND] |
2729 | mov ebx, [mem_BACKGROUND] |
2667 | add ebx, 4095 |
2730 | add ebx, 4095 |
2668 | and ebx, -4096 |
2731 | and ebx, -4096 |
2669 | sub ebx, 4 |
2732 | sub ebx, 4 |
2670 | cmp ecx, ebx |
2733 | cmp ecx, ebx |
2671 | ja .ret |
2734 | ja .ret |
2672 | 2735 | ||
2673 | mov ebx, [eax+ecx] |
2736 | mov ebx, [eax+ecx] |
2674 | and ebx, 0xFF000000;255*256*256*256 |
2737 | and ebx, 0xFF000000;255*256*256*256 |
2675 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2738 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2676 | add edx, ebx |
2739 | add edx, ebx |
2677 | mov [eax+ecx], edx |
2740 | mov [eax+ecx], edx |
2678 | ;-------------------------------------- |
2741 | ;-------------------------------------- |
2679 | align 4 |
2742 | align 4 |
2680 | .ret: |
2743 | .ret: |
2681 | ret |
2744 | ret |
2682 | ;------------------------------------------------------------------------------ |
2745 | ;------------------------------------------------------------------------------ |
2683 | align 4 |
2746 | align 4 |
2684 | nosb2: |
2747 | nosb2: |
2685 | cmp ebx, 3 ; DRAW BACKGROUND |
2748 | cmp ebx, 3 ; DRAW BACKGROUND |
2686 | jnz nosb3 |
2749 | jnz nosb3 |
2687 | ;-------------------------------------- |
2750 | ;-------------------------------------- |
2688 | align 4 |
2751 | align 4 |
2689 | draw_background_temp: |
2752 | draw_background_temp: |
2690 | mov [background_defined], 1 |
2753 | mov [background_defined], 1 |
2691 | call force_redraw_background |
2754 | call force_redraw_background |
2692 | ;-------------------------------------- |
2755 | ;-------------------------------------- |
2693 | align 4 |
2756 | align 4 |
2694 | nosb31: |
2757 | nosb31: |
2695 | ret |
2758 | ret |
2696 | ;------------------------------------------------------------------------------ |
2759 | ;------------------------------------------------------------------------------ |
2697 | align 4 |
2760 | align 4 |
2698 | nosb3: |
2761 | nosb3: |
2699 | cmp ebx, 4 ; TILED / STRETCHED |
2762 | cmp ebx, 4 ; TILED / STRETCHED |
2700 | jnz nosb4 |
2763 | jnz nosb4 |
2701 | cmp ecx, [BgrDrawMode] |
2764 | cmp ecx, [BgrDrawMode] |
2702 | je nosb41 |
2765 | je nosb41 |
2703 | mov [BgrDrawMode], ecx |
2766 | mov [BgrDrawMode], ecx |
2704 | ;-------------------------------------- |
2767 | ;-------------------------------------- |
2705 | align 4 |
2768 | align 4 |
2706 | nosb41: |
2769 | nosb41: |
2707 | ret |
2770 | ret |
2708 | ;------------------------------------------------------------------------------ |
2771 | ;------------------------------------------------------------------------------ |
2709 | align 4 |
2772 | align 4 |
2710 | nosb4: |
2773 | nosb4: |
2711 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2774 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2712 | jnz nosb5 |
2775 | jnz nosb5 |
2713 | cmp [img_background], static_background_data |
2776 | cmp [img_background], static_background_data |
2714 | jnz @f |
2777 | jnz @f |
2715 | test edx, edx |
2778 | test edx, edx |
2716 | jnz .fin |
2779 | jnz .fin |
2717 | cmp esi, 4 |
2780 | cmp esi, 4 |
2718 | ja .fin |
2781 | ja .fin |
2719 | ;-------------------------------------- |
2782 | ;-------------------------------------- |
2720 | align 4 |
2783 | align 4 |
2721 | @@: |
2784 | @@: |
2722 | ; bughere |
2785 | ; bughere |
2723 | mov eax, ecx |
2786 | mov eax, ecx |
2724 | mov ebx, edx |
2787 | mov ebx, edx |
2725 | add ebx, [img_background];IMG_BACKGROUND |
2788 | add ebx, [img_background];IMG_BACKGROUND |
2726 | mov ecx, esi |
2789 | mov ecx, esi |
2727 | call memmove |
2790 | call memmove |
2728 | ;-------------------------------------- |
2791 | ;-------------------------------------- |
2729 | align 4 |
2792 | align 4 |
2730 | .fin: |
2793 | .fin: |
2731 | ret |
2794 | ret |
2732 | ;------------------------------------------------------------------------------ |
2795 | ;------------------------------------------------------------------------------ |
2733 | align 4 |
2796 | align 4 |
2734 | nosb5: |
2797 | nosb5: |
2735 | cmp ebx, 6 |
2798 | cmp ebx, 6 |
2736 | jnz nosb6 |
2799 | jnz nosb6 |
2737 | ;-------------------------------------- |
2800 | ;-------------------------------------- |
2738 | align 4 |
2801 | align 4 |
2739 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2802 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2740 | @@: |
2803 | @@: |
2741 | bts dword [bgrlock], 0 |
2804 | bts dword [bgrlock], 0 |
2742 | jnc @f |
2805 | jnc @f |
2743 | call change_task |
2806 | call change_task |
2744 | jmp @b |
2807 | jmp @b |
2745 | ;-------------------------------------- |
2808 | ;-------------------------------------- |
2746 | align 4 |
2809 | align 4 |
2747 | @@: |
2810 | @@: |
2748 | mov eax, [CURRENT_TASK] |
2811 | mov eax, [CURRENT_TASK] |
2749 | mov [bgrlockpid], eax |
2812 | mov [bgrlockpid], eax |
2750 | cmp [img_background], static_background_data |
2813 | cmp [img_background], static_background_data |
2751 | jz .nomem |
2814 | jz .nomem |
2752 | stdcall user_alloc, [mem_BACKGROUND] |
2815 | stdcall user_alloc, [mem_BACKGROUND] |
2753 | mov [esp+32], eax |
2816 | mov [esp+32], eax |
2754 | test eax, eax |
2817 | test eax, eax |
2755 | jz .nomem |
2818 | jz .nomem |
2756 | mov ebx, eax |
2819 | mov ebx, eax |
2757 | shr ebx, 12 |
2820 | shr ebx, 12 |
2758 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2821 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2759 | mov esi, [img_background] |
2822 | mov esi, [img_background] |
2760 | shr esi, 12 |
2823 | shr esi, 12 |
2761 | mov ecx, [mem_BACKGROUND] |
2824 | mov ecx, [mem_BACKGROUND] |
2762 | add ecx, 0xFFF |
2825 | add ecx, 0xFFF |
2763 | shr ecx, 12 |
2826 | shr ecx, 12 |
2764 | ;-------------------------------------- |
2827 | ;-------------------------------------- |
2765 | align 4 |
2828 | align 4 |
2766 | .z: |
2829 | .z: |
2767 | mov eax, [page_tabs+ebx*4] |
2830 | mov eax, [page_tabs+ebx*4] |
2768 | test al, 1 |
2831 | test al, 1 |
2769 | jz @f |
2832 | jz @f |
2770 | call free_page |
2833 | call free_page |
2771 | ;-------------------------------------- |
2834 | ;-------------------------------------- |
2772 | align 4 |
2835 | align 4 |
2773 | @@: |
2836 | @@: |
2774 | mov eax, [page_tabs+esi*4] |
2837 | mov eax, [page_tabs+esi*4] |
2775 | or al, PG_UW |
2838 | or al, PG_UW |
2776 | mov [page_tabs+ebx*4], eax |
2839 | mov [page_tabs+ebx*4], eax |
2777 | mov eax, ebx |
2840 | mov eax, ebx |
2778 | shl eax, 12 |
2841 | shl eax, 12 |
2779 | invlpg [eax] |
2842 | invlpg [eax] |
2780 | inc ebx |
2843 | inc ebx |
2781 | inc esi |
2844 | inc esi |
2782 | loop .z |
2845 | loop .z |
2783 | ret |
2846 | ret |
2784 | ;-------------------------------------- |
2847 | ;-------------------------------------- |
2785 | align 4 |
2848 | align 4 |
2786 | .nomem: |
2849 | .nomem: |
2787 | and [bgrlockpid], 0 |
2850 | and [bgrlockpid], 0 |
2788 | mov [bgrlock], 0 |
2851 | mov [bgrlock], 0 |
2789 | ;------------------------------------------------------------------------------ |
2852 | ;------------------------------------------------------------------------------ |
2790 | align 4 |
2853 | align 4 |
2791 | nosb6: |
2854 | nosb6: |
2792 | cmp ebx, 7 |
2855 | cmp ebx, 7 |
2793 | jnz nosb7 |
2856 | jnz nosb7 |
2794 | cmp [bgrlock], 0 |
2857 | cmp [bgrlock], 0 |
2795 | jz .err |
2858 | jz .err |
2796 | mov eax, [CURRENT_TASK] |
2859 | mov eax, [CURRENT_TASK] |
2797 | cmp [bgrlockpid], eax |
2860 | cmp [bgrlockpid], eax |
2798 | jnz .err |
2861 | jnz .err |
2799 | mov eax, ecx |
2862 | mov eax, ecx |
2800 | mov ebx, ecx |
2863 | mov ebx, ecx |
2801 | shr eax, 12 |
2864 | shr eax, 12 |
2802 | mov ecx, [page_tabs+(eax-1)*4] |
2865 | mov ecx, [page_tabs+(eax-1)*4] |
2803 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2866 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2804 | jz .err |
2867 | jz .err |
2805 | jnp .err |
2868 | jnp .err |
2806 | push eax |
2869 | push eax |
2807 | shr ecx, 12 |
2870 | shr ecx, 12 |
2808 | dec ecx |
2871 | dec ecx |
2809 | ;-------------------------------------- |
2872 | ;-------------------------------------- |
2810 | align 4 |
2873 | align 4 |
2811 | @@: |
2874 | @@: |
2812 | and dword [page_tabs+eax*4], 0 |
2875 | and dword [page_tabs+eax*4], 0 |
2813 | mov edx, eax |
2876 | mov edx, eax |
2814 | shl edx, 12 |
2877 | shl edx, 12 |
2815 | push eax |
2878 | push eax |
2816 | invlpg [edx] |
2879 | invlpg [edx] |
2817 | pop eax |
2880 | pop eax |
2818 | inc eax |
2881 | inc eax |
2819 | loop @b |
2882 | loop @b |
2820 | pop eax |
2883 | pop eax |
2821 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2884 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2822 | stdcall user_free, ebx |
2885 | stdcall user_free, ebx |
2823 | mov [esp+32], eax |
2886 | mov [esp+32], eax |
2824 | and [bgrlockpid], 0 |
2887 | and [bgrlockpid], 0 |
2825 | mov [bgrlock], 0 |
2888 | mov [bgrlock], 0 |
2826 | ret |
2889 | ret |
2827 | ;-------------------------------------- |
2890 | ;-------------------------------------- |
2828 | align 4 |
2891 | align 4 |
2829 | .err: |
2892 | .err: |
2830 | and dword [esp+32], 0 |
2893 | and dword [esp+32], 0 |
2831 | ret |
2894 | ret |
2832 | ;------------------------------------------------------------------------------ |
2895 | ;------------------------------------------------------------------------------ |
2833 | align 4 |
2896 | align 4 |
2834 | nosb7: |
2897 | nosb7: |
2835 | cmp ebx, 8 |
2898 | cmp ebx, 8 |
2836 | jnz nosb8 |
2899 | jnz nosb8 |
2837 | 2900 | ||
2838 | mov ecx, [current_slot] |
2901 | mov ecx, [current_slot] |
2839 | xor eax, eax |
2902 | xor eax, eax |
2840 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2903 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2841 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2904 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2842 | xor eax, eax |
2905 | xor eax, eax |
2843 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2906 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2844 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2907 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2845 | ret |
2908 | ret |
2846 | ;------------------------------------------------------------------------------ |
2909 | ;------------------------------------------------------------------------------ |
2847 | align 4 |
2910 | align 4 |
2848 | nosb8: |
2911 | nosb8: |
2849 | cmp ebx, 9 |
2912 | cmp ebx, 9 |
2850 | jnz nosb9 |
2913 | jnz nosb9 |
2851 | ; ecx = [left]*65536 + [right] |
2914 | ; ecx = [left]*65536 + [right] |
2852 | ; edx = [top]*65536 + [bottom] |
2915 | ; edx = [top]*65536 + [bottom] |
2853 | mov eax, [Screen_Max_X] |
2916 | mov eax, [Screen_Max_X] |
2854 | mov ebx, [Screen_Max_Y] |
2917 | mov ebx, [Screen_Max_Y] |
2855 | ; check [right] |
2918 | ; check [right] |
2856 | cmp cx, ax |
2919 | cmp cx, ax |
2857 | ja .exit |
2920 | ja .exit |
2858 | ; check [left] |
2921 | ; check [left] |
2859 | ror ecx, 16 |
2922 | ror ecx, 16 |
2860 | cmp cx, ax |
2923 | cmp cx, ax |
2861 | ja .exit |
2924 | ja .exit |
2862 | ; check [bottom] |
2925 | ; check [bottom] |
2863 | cmp dx, bx |
2926 | cmp dx, bx |
2864 | ja .exit |
2927 | ja .exit |
2865 | ; check [top] |
2928 | ; check [top] |
2866 | ror edx, 16 |
2929 | ror edx, 16 |
2867 | cmp dx, bx |
2930 | cmp dx, bx |
2868 | ja .exit |
2931 | ja .exit |
2869 | 2932 | ||
2870 | movzx eax, cx ; [left] |
2933 | movzx eax, cx ; [left] |
2871 | movzx ebx, dx ; [top] |
2934 | movzx ebx, dx ; [top] |
2872 | 2935 | ||
2873 | shr ecx, 16 ; [right] |
2936 | shr ecx, 16 ; [right] |
2874 | shr edx, 16 ; [bottom] |
2937 | shr edx, 16 ; [bottom] |
2875 | 2938 | ||
2876 | mov [background_defined], 1 |
2939 | mov [background_defined], 1 |
2877 | 2940 | ||
2878 | mov [draw_data+32 + RECT.left], eax |
2941 | mov [draw_data+32 + RECT.left], eax |
2879 | mov [draw_data+32 + RECT.top], ebx |
2942 | mov [draw_data+32 + RECT.top], ebx |
2880 | 2943 | ||
2881 | mov [draw_data+32 + RECT.right], ecx |
2944 | mov [draw_data+32 + RECT.right], ecx |
2882 | mov [draw_data+32 + RECT.bottom], edx |
2945 | mov [draw_data+32 + RECT.bottom], edx |
2883 | 2946 | ||
2884 | inc byte[REDRAW_BACKGROUND] |
2947 | inc byte[REDRAW_BACKGROUND] |
2885 | call wakeup_osloop |
2948 | call wakeup_osloop |
2886 | ;-------------------------------------- |
2949 | ;-------------------------------------- |
2887 | align 4 |
2950 | align 4 |
2888 | .exit: |
2951 | .exit: |
2889 | ret |
2952 | ret |
2890 | ;------------------------------------------------------------------------------ |
2953 | ;------------------------------------------------------------------------------ |
2891 | align 4 |
2954 | align 4 |
2892 | nosb9: |
2955 | nosb9: |
2893 | ret |
2956 | ret |
2894 | ;------------------------------------------------------------------------------ |
2957 | ;------------------------------------------------------------------------------ |
2895 | align 4 |
2958 | align 4 |
2896 | uglobal |
2959 | uglobal |
2897 | BG_Rect_X_left_right dd 0x0 |
2960 | BG_Rect_X_left_right dd 0x0 |
2898 | BG_Rect_Y_top_bottom dd 0x0 |
2961 | BG_Rect_Y_top_bottom dd 0x0 |
2899 | endg |
2962 | endg |
2900 | ;------------------------------------------------------------------------------ |
2963 | ;------------------------------------------------------------------------------ |
2901 | align 4 |
2964 | align 4 |
2902 | force_redraw_background: |
2965 | force_redraw_background: |
2903 | and [draw_data+32 + RECT.left], 0 |
2966 | and [draw_data+32 + RECT.left], 0 |
2904 | and [draw_data+32 + RECT.top], 0 |
2967 | and [draw_data+32 + RECT.top], 0 |
2905 | push eax ebx |
2968 | push eax ebx |
2906 | mov eax, [Screen_Max_X] |
2969 | mov eax, [Screen_Max_X] |
2907 | mov ebx, [Screen_Max_Y] |
2970 | mov ebx, [Screen_Max_Y] |
2908 | mov [draw_data+32 + RECT.right], eax |
2971 | mov [draw_data+32 + RECT.right], eax |
2909 | mov [draw_data+32 + RECT.bottom], ebx |
2972 | mov [draw_data+32 + RECT.bottom], ebx |
2910 | pop ebx eax |
2973 | pop ebx eax |
2911 | inc byte[REDRAW_BACKGROUND] |
2974 | inc byte[REDRAW_BACKGROUND] |
2912 | call wakeup_osloop |
2975 | call wakeup_osloop |
2913 | ret |
2976 | ret |
2914 | ;------------------------------------------------------------------------------ |
2977 | ;------------------------------------------------------------------------------ |
2915 | align 4 |
2978 | align 4 |
2916 | sys_getbackground: |
2979 | sys_getbackground: |
2917 | ; cmp eax,1 ; SIZE |
2980 | ; cmp eax,1 ; SIZE |
2918 | dec ebx |
2981 | dec ebx |
2919 | jnz nogb1 |
2982 | jnz nogb1 |
2920 | mov eax, [BgrDataWidth] |
2983 | mov eax, [BgrDataWidth] |
2921 | shl eax, 16 |
2984 | shl eax, 16 |
2922 | mov ax, word [BgrDataHeight] |
2985 | mov ax, word [BgrDataHeight] |
2923 | mov [esp+32], eax |
2986 | mov [esp+32], eax |
2924 | ret |
2987 | ret |
2925 | ;------------------------------------------------------------------------------ |
2988 | ;------------------------------------------------------------------------------ |
2926 | align 4 |
2989 | align 4 |
2927 | nogb1: |
2990 | nogb1: |
2928 | ; cmp eax,2 ; PIXEL |
2991 | ; cmp eax,2 ; PIXEL |
2929 | dec ebx |
2992 | dec ebx |
2930 | jnz nogb2 |
2993 | jnz nogb2 |
2931 | 2994 | ||
2932 | mov eax, [img_background] |
2995 | mov eax, [img_background] |
2933 | test ecx, ecx |
2996 | test ecx, ecx |
2934 | jz @f |
2997 | jz @f |
2935 | cmp eax, static_background_data |
2998 | cmp eax, static_background_data |
2936 | jz .ret |
2999 | jz .ret |
2937 | ;-------------------------------------- |
3000 | ;-------------------------------------- |
2938 | align 4 |
3001 | align 4 |
2939 | @@: |
3002 | @@: |
2940 | mov ebx, [mem_BACKGROUND] |
3003 | mov ebx, [mem_BACKGROUND] |
2941 | add ebx, 4095 |
3004 | add ebx, 4095 |
2942 | and ebx, -4096 |
3005 | and ebx, -4096 |
2943 | sub ebx, 4 |
3006 | sub ebx, 4 |
2944 | cmp ecx, ebx |
3007 | cmp ecx, ebx |
2945 | ja .ret |
3008 | ja .ret |
2946 | 3009 | ||
2947 | mov eax, [ecx+eax] |
3010 | mov eax, [ecx+eax] |
2948 | 3011 | ||
2949 | and eax, 0xFFFFFF |
3012 | and eax, 0xFFFFFF |
2950 | mov [esp+32], eax |
3013 | mov [esp+32], eax |
2951 | ;-------------------------------------- |
3014 | ;-------------------------------------- |
2952 | align 4 |
3015 | align 4 |
2953 | .ret: |
3016 | .ret: |
2954 | ret |
3017 | ret |
2955 | ;------------------------------------------------------------------------------ |
3018 | ;------------------------------------------------------------------------------ |
2956 | align 4 |
3019 | align 4 |
2957 | nogb2: |
3020 | nogb2: |
2958 | 3021 | ||
2959 | ; cmp eax,4 ; TILED / STRETCHED |
3022 | ; cmp eax,4 ; TILED / STRETCHED |
2960 | dec ebx |
3023 | dec ebx |
2961 | dec ebx |
3024 | dec ebx |
2962 | jnz nogb4 |
3025 | jnz nogb4 |
2963 | mov eax, [BgrDrawMode] |
3026 | mov eax, [BgrDrawMode] |
2964 | ;-------------------------------------- |
3027 | ;-------------------------------------- |
2965 | align 4 |
3028 | align 4 |
2966 | nogb4: |
3029 | nogb4: |
2967 | mov [esp+32], eax |
3030 | mov [esp+32], eax |
2968 | ret |
3031 | ret |
2969 | ;------------------------------------------------------------------------------ |
3032 | ;------------------------------------------------------------------------------ |
2970 | align 4 |
3033 | align 4 |
2971 | sys_getkey: |
3034 | sys_getkey: |
2972 | mov [esp + 32], dword 1 |
3035 | mov [esp + 32], dword 1 |
2973 | ; test main buffer |
3036 | ; test main buffer |
2974 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3037 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2975 | movzx ecx, word [WIN_STACK + ebx * 2] |
3038 | movzx ecx, word [WIN_STACK + ebx * 2] |
2976 | mov edx, [TASK_COUNT] |
3039 | mov edx, [TASK_COUNT] |
2977 | cmp ecx, edx |
3040 | cmp ecx, edx |
2978 | jne .finish |
3041 | jne .finish |
2979 | cmp [KEY_COUNT], byte 0 |
3042 | cmp [KEY_COUNT], byte 0 |
2980 | je .finish |
3043 | je .finish |
2981 | movzx eax, byte [KEY_BUFF] |
3044 | movzx eax, byte [KEY_BUFF] |
2982 | shl eax, 8 |
3045 | shl eax, 8 |
2983 | push eax |
3046 | push eax |
2984 | dec byte [KEY_COUNT] |
3047 | dec byte [KEY_COUNT] |
2985 | and byte [KEY_COUNT], 127 |
3048 | and byte [KEY_COUNT], 127 |
2986 | movzx ecx, byte [KEY_COUNT] |
3049 | movzx ecx, byte [KEY_COUNT] |
2987 | add ecx, 2 |
3050 | add ecx, 2 |
2988 | mov eax, KEY_BUFF + 1 |
3051 | mov eax, KEY_BUFF + 1 |
2989 | mov ebx, KEY_BUFF |
3052 | mov ebx, KEY_BUFF |
2990 | call memmove |
3053 | call memmove |
2991 | pop eax |
3054 | pop eax |
2992 | ;-------------------------------------- |
3055 | ;-------------------------------------- |
2993 | align 4 |
3056 | align 4 |
2994 | .ret_eax: |
3057 | .ret_eax: |
2995 | mov [esp + 32], eax |
3058 | mov [esp + 32], eax |
2996 | ret |
3059 | ret |
2997 | ;-------------------------------------- |
3060 | ;-------------------------------------- |
2998 | align 4 |
3061 | align 4 |
2999 | .finish: |
3062 | .finish: |
3000 | ; test hotkeys buffer |
3063 | ; test hotkeys buffer |
3001 | mov ecx, hotkey_buffer |
3064 | mov ecx, hotkey_buffer |
3002 | ;-------------------------------------- |
3065 | ;-------------------------------------- |
3003 | align 4 |
3066 | align 4 |
3004 | @@: |
3067 | @@: |
3005 | cmp [ecx], ebx |
3068 | cmp [ecx], ebx |
3006 | jz .found |
3069 | jz .found |
3007 | add ecx, 8 |
3070 | add ecx, 8 |
3008 | cmp ecx, hotkey_buffer + 120 * 8 |
3071 | cmp ecx, hotkey_buffer + 120 * 8 |
3009 | jb @b |
3072 | jb @b |
3010 | ret |
3073 | ret |
3011 | ;-------------------------------------- |
3074 | ;-------------------------------------- |
3012 | align 4 |
3075 | align 4 |
3013 | .found: |
3076 | .found: |
3014 | mov ax, [ecx + 6] |
3077 | mov ax, [ecx + 6] |
3015 | shl eax, 16 |
3078 | shl eax, 16 |
3016 | mov ah, [ecx + 4] |
3079 | mov ah, [ecx + 4] |
3017 | mov al, 2 |
3080 | mov al, 2 |
3018 | and dword [ecx + 4], 0 |
3081 | and dword [ecx + 4], 0 |
3019 | and dword [ecx], 0 |
3082 | and dword [ecx], 0 |
3020 | jmp .ret_eax |
3083 | jmp .ret_eax |
3021 | ;------------------------------------------------------------------------------ |
3084 | ;------------------------------------------------------------------------------ |
3022 | align 4 |
3085 | align 4 |
3023 | sys_getbutton: |
3086 | sys_getbutton: |
3024 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3087 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3025 | mov [esp + 32], dword 1 |
3088 | mov [esp + 32], dword 1 |
3026 | movzx ecx, word [WIN_STACK + ebx * 2] |
3089 | movzx ecx, word [WIN_STACK + ebx * 2] |
3027 | mov edx, [TASK_COUNT] ; less than 256 processes |
3090 | mov edx, [TASK_COUNT] ; less than 256 processes |
3028 | cmp ecx, edx |
3091 | cmp ecx, edx |
3029 | jne .exit |
3092 | jne .exit |
3030 | movzx eax, byte [BTN_COUNT] |
3093 | movzx eax, byte [BTN_COUNT] |
3031 | test eax, eax |
3094 | test eax, eax |
3032 | jz .exit |
3095 | jz .exit |
3033 | mov eax, [BTN_BUFF] |
3096 | mov eax, [BTN_BUFF] |
3034 | and al, 0xFE ; delete left button bit |
3097 | and al, 0xFE ; delete left button bit |
3035 | mov [BTN_COUNT], byte 0 |
3098 | mov [BTN_COUNT], byte 0 |
3036 | mov [esp + 32], eax |
3099 | mov [esp + 32], eax |
3037 | ;-------------------------------------- |
3100 | ;-------------------------------------- |
3038 | align 4 |
3101 | align 4 |
3039 | .exit: |
3102 | .exit: |
3040 | ret |
3103 | ret |
3041 | ;------------------------------------------------------------------------------ |
3104 | ;------------------------------------------------------------------------------ |
3042 | align 4 |
3105 | align 4 |
3043 | sys_cpuusage: |
3106 | sys_cpuusage: |
3044 | 3107 | ||
3045 | ; RETURN: |
3108 | ; RETURN: |
3046 | ; |
3109 | ; |
3047 | ; +00 dword process cpu usage |
3110 | ; +00 dword process cpu usage |
3048 | ; +04 word position in windowing stack |
3111 | ; +04 word position in windowing stack |
3049 | ; +06 word windowing stack value at current position (cpu nro) |
3112 | ; +06 word windowing stack value at current position (cpu nro) |
3050 | ; +10 12 bytes name |
3113 | ; +10 12 bytes name |
3051 | ; +22 dword start in mem |
3114 | ; +22 dword start in mem |
3052 | ; +26 dword used mem |
3115 | ; +26 dword used mem |
3053 | ; +30 dword PID , process idenfification number |
3116 | ; +30 dword PID , process idenfification number |
3054 | ; |
3117 | ; |
3055 | 3118 | ||
3056 | cmp ecx, -1 ; who am I ? |
3119 | cmp ecx, -1 ; who am I ? |
3057 | jne .no_who_am_i |
3120 | jne .no_who_am_i |
3058 | mov ecx, [CURRENT_TASK] |
3121 | mov ecx, [CURRENT_TASK] |
3059 | .no_who_am_i: |
3122 | .no_who_am_i: |
3060 | cmp ecx, max_processes |
3123 | cmp ecx, max_processes |
3061 | ja .nofillbuf |
3124 | ja .nofillbuf |
3062 | 3125 | ||
3063 | ; +4: word: position of the window of thread in the window stack |
3126 | ; +4: word: position of the window of thread in the window stack |
3064 | mov ax, [WIN_STACK + ecx * 2] |
3127 | mov ax, [WIN_STACK + ecx * 2] |
3065 | mov [ebx+4], ax |
3128 | mov [ebx+4], ax |
3066 | ; +6: word: number of the thread slot, which window has in the window stack |
3129 | ; +6: word: number of the thread slot, which window has in the window stack |
3067 | ; position ecx (has no relation to the specific thread) |
3130 | ; position ecx (has no relation to the specific thread) |
3068 | mov ax, [WIN_POS + ecx * 2] |
3131 | mov ax, [WIN_POS + ecx * 2] |
3069 | mov [ebx+6], ax |
3132 | mov [ebx+6], ax |
3070 | 3133 | ||
3071 | shl ecx, 5 |
3134 | shl ecx, 5 |
3072 | 3135 | ||
3073 | ; +0: dword: memory usage |
3136 | ; +0: dword: memory usage |
3074 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3137 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3075 | mov [ebx], eax |
3138 | mov [ebx], eax |
3076 | ; +10: 11 bytes: name of the process |
3139 | ; +10: 11 bytes: name of the process |
3077 | push ecx |
3140 | push ecx |
3078 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3141 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3079 | add ebx, 10 |
3142 | add ebx, 10 |
3080 | mov ecx, 11 |
3143 | mov ecx, 11 |
3081 | call memmove |
3144 | call memmove |
3082 | pop ecx |
3145 | pop ecx |
3083 | 3146 | ||
3084 | ; +22: address of the process in memory |
3147 | ; +22: address of the process in memory |
3085 | ; +26: size of used memory - 1 |
3148 | ; +26: size of used memory - 1 |
3086 | push edi |
3149 | push edi |
3087 | lea edi, [ebx+12] |
3150 | lea edi, [ebx+12] |
3088 | xor eax, eax |
3151 | xor eax, eax |
3089 | mov edx, 0x100000*16 |
3152 | mov edx, 0x100000*16 |
3090 | cmp ecx, 1 shl 5 |
3153 | cmp ecx, 1 shl 5 |
3091 | je .os_mem |
3154 | je .os_mem |
3092 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3155 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
3093 | mov eax, std_application_base_address |
3156 | mov eax, std_application_base_address |
3094 | .os_mem: |
3157 | .os_mem: |
3095 | stosd |
3158 | stosd |
3096 | lea eax, [edx-1] |
3159 | lea eax, [edx-1] |
3097 | stosd |
3160 | stosd |
3098 | 3161 | ||
3099 | ; +30: PID/TID |
3162 | ; +30: PID/TID |
3100 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3163 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3101 | stosd |
3164 | stosd |
3102 | 3165 | ||
3103 | ; window position and size |
3166 | ; window position and size |
3104 | push esi |
3167 | push esi |
3105 | lea esi, [ecx + window_data + WDATA.box] |
3168 | lea esi, [ecx + window_data + WDATA.box] |
3106 | movsd |
3169 | movsd |
3107 | movsd |
3170 | movsd |
3108 | movsd |
3171 | movsd |
3109 | movsd |
3172 | movsd |
3110 | 3173 | ||
3111 | ; Process state (+50) |
3174 | ; Process state (+50) |
3112 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3175 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3113 | stosd |
3176 | stosd |
3114 | 3177 | ||
3115 | ; Window client area box |
3178 | ; Window client area box |
3116 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3179 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3117 | movsd |
3180 | movsd |
3118 | movsd |
3181 | movsd |
3119 | movsd |
3182 | movsd |
3120 | movsd |
3183 | movsd |
3121 | 3184 | ||
3122 | ; Window state |
3185 | ; Window state |
3123 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3186 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3124 | stosb |
3187 | stosb |
3125 | 3188 | ||
3126 | ; Event mask (+71) |
3189 | ; Event mask (+71) |
3127 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3190 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3128 | stosd |
3191 | stosd |
3129 | 3192 | ||
3130 | pop esi |
3193 | pop esi |
3131 | pop edi |
3194 | pop edi |
3132 | 3195 | ||
3133 | .nofillbuf: |
3196 | .nofillbuf: |
3134 | ; return number of processes |
3197 | ; return number of processes |
3135 | 3198 | ||
3136 | mov eax, [TASK_COUNT] |
3199 | mov eax, [TASK_COUNT] |
3137 | mov [esp+32], eax |
3200 | mov [esp+32], eax |
3138 | ret |
3201 | ret |
3139 | 3202 | ||
3140 | align 4 |
3203 | align 4 |
3141 | sys_clock: |
3204 | sys_clock: |
3142 | cli |
3205 | cli |
3143 | ; Mikhail Lisovin xx Jan 2005 |
3206 | ; Mikhail Lisovin xx Jan 2005 |
3144 | @@: |
3207 | @@: |
3145 | mov al, 10 |
3208 | mov al, 10 |
3146 | out 0x70, al |
3209 | out 0x70, al |
3147 | in al, 0x71 |
3210 | in al, 0x71 |
3148 | test al, al |
3211 | test al, al |
3149 | jns @f |
3212 | jns @f |
3150 | mov esi, 1 |
3213 | mov esi, 1 |
3151 | call delay_ms |
3214 | call delay_ms |
3152 | jmp @b |
3215 | jmp @b |
3153 | @@: |
3216 | @@: |
3154 | ; end Lisovin's fix |
3217 | ; end Lisovin's fix |
3155 | 3218 | ||
3156 | xor al, al ; seconds |
3219 | xor al, al ; seconds |
3157 | out 0x70, al |
3220 | out 0x70, al |
3158 | in al, 0x71 |
3221 | in al, 0x71 |
3159 | movzx ecx, al |
3222 | movzx ecx, al |
3160 | mov al, 02 ; minutes |
3223 | mov al, 02 ; minutes |
3161 | shl ecx, 16 |
3224 | shl ecx, 16 |
3162 | out 0x70, al |
3225 | out 0x70, al |
3163 | in al, 0x71 |
3226 | in al, 0x71 |
3164 | movzx edx, al |
3227 | movzx edx, al |
3165 | mov al, 04 ; hours |
3228 | mov al, 04 ; hours |
3166 | shl edx, 8 |
3229 | shl edx, 8 |
3167 | out 0x70, al |
3230 | out 0x70, al |
3168 | in al, 0x71 |
3231 | in al, 0x71 |
3169 | add ecx, edx |
3232 | add ecx, edx |
3170 | movzx edx, al |
3233 | movzx edx, al |
3171 | add ecx, edx |
3234 | add ecx, edx |
3172 | sti |
3235 | sti |
3173 | mov [esp + 32], ecx |
3236 | mov [esp + 32], ecx |
3174 | ret |
3237 | ret |
3175 | 3238 | ||
3176 | 3239 | ||
3177 | align 4 |
3240 | align 4 |
3178 | 3241 | ||
3179 | sys_date: |
3242 | sys_date: |
3180 | 3243 | ||
3181 | cli |
3244 | cli |
3182 | @@: |
3245 | @@: |
3183 | mov al, 10 |
3246 | mov al, 10 |
3184 | out 0x70, al |
3247 | out 0x70, al |
3185 | in al, 0x71 |
3248 | in al, 0x71 |
3186 | test al, al |
3249 | test al, al |
3187 | jns @f |
3250 | jns @f |
3188 | mov esi, 1 |
3251 | mov esi, 1 |
3189 | call delay_ms |
3252 | call delay_ms |
3190 | jmp @b |
3253 | jmp @b |
3191 | @@: |
3254 | @@: |
3192 | 3255 | ||
3193 | mov ch, 0 |
3256 | mov ch, 0 |
3194 | mov al, 7 ; date |
3257 | mov al, 7 ; date |
3195 | out 0x70, al |
3258 | out 0x70, al |
3196 | in al, 0x71 |
3259 | in al, 0x71 |
3197 | mov cl, al |
3260 | mov cl, al |
3198 | mov al, 8 ; month |
3261 | mov al, 8 ; month |
3199 | shl ecx, 16 |
3262 | shl ecx, 16 |
3200 | out 0x70, al |
3263 | out 0x70, al |
3201 | in al, 0x71 |
3264 | in al, 0x71 |
3202 | mov ch, al |
3265 | mov ch, al |
3203 | mov al, 9 ; year |
3266 | mov al, 9 ; year |
3204 | out 0x70, al |
3267 | out 0x70, al |
3205 | in al, 0x71 |
3268 | in al, 0x71 |
3206 | mov cl, al |
3269 | mov cl, al |
3207 | sti |
3270 | sti |
3208 | mov [esp+32], ecx |
3271 | mov [esp+32], ecx |
3209 | ret |
3272 | ret |
3210 | 3273 | ||
3211 | 3274 | ||
3212 | ; redraw status |
3275 | ; redraw status |
3213 | 3276 | ||
3214 | sys_redrawstat: |
3277 | sys_redrawstat: |
3215 | cmp ebx, 1 |
3278 | cmp ebx, 1 |
3216 | jne no_widgets_away |
3279 | jne no_widgets_away |
3217 | ; buttons away |
3280 | ; buttons away |
3218 | mov ecx, [CURRENT_TASK] |
3281 | mov ecx, [CURRENT_TASK] |
3219 | sys_newba2: |
3282 | sys_newba2: |
3220 | mov edi, [BTN_ADDR] |
3283 | mov edi, [BTN_ADDR] |
3221 | cmp [edi], dword 0 ; empty button list ? |
3284 | cmp [edi], dword 0 ; empty button list ? |
3222 | je end_of_buttons_away |
3285 | je end_of_buttons_away |
3223 | movzx ebx, word [edi] |
3286 | movzx ebx, word [edi] |
3224 | inc ebx |
3287 | inc ebx |
3225 | mov eax, edi |
3288 | mov eax, edi |
3226 | sys_newba: |
3289 | sys_newba: |
3227 | dec ebx |
3290 | dec ebx |
3228 | jz end_of_buttons_away |
3291 | jz end_of_buttons_away |
3229 | 3292 | ||
3230 | add eax, 0x10 |
3293 | add eax, 0x10 |
3231 | cmp cx, [eax] |
3294 | cmp cx, [eax] |
3232 | jnz sys_newba |
3295 | jnz sys_newba |
3233 | 3296 | ||
3234 | push eax ebx ecx |
3297 | push eax ebx ecx |
3235 | mov ecx, ebx |
3298 | mov ecx, ebx |
3236 | inc ecx |
3299 | inc ecx |
3237 | shl ecx, 4 |
3300 | shl ecx, 4 |
3238 | mov ebx, eax |
3301 | mov ebx, eax |
3239 | add eax, 0x10 |
3302 | add eax, 0x10 |
3240 | call memmove |
3303 | call memmove |
3241 | dec dword [edi] |
3304 | dec dword [edi] |
3242 | pop ecx ebx eax |
3305 | pop ecx ebx eax |
3243 | 3306 | ||
3244 | jmp sys_newba2 |
3307 | jmp sys_newba2 |
3245 | 3308 | ||
3246 | end_of_buttons_away: |
3309 | end_of_buttons_away: |
3247 | 3310 | ||
3248 | ret |
3311 | ret |
3249 | 3312 | ||
3250 | no_widgets_away: |
3313 | no_widgets_away: |
3251 | 3314 | ||
3252 | cmp ebx, 2 |
3315 | cmp ebx, 2 |
3253 | jnz srl1 |
3316 | jnz srl1 |
3254 | 3317 | ||
3255 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3318 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3256 | add edx, draw_data - CURRENT_TASK |
3319 | add edx, draw_data - CURRENT_TASK |
3257 | mov [edx + RECT.left], 0 |
3320 | mov [edx + RECT.left], 0 |
3258 | mov [edx + RECT.top], 0 |
3321 | mov [edx + RECT.top], 0 |
3259 | mov eax, [Screen_Max_X] |
3322 | mov eax, [Screen_Max_X] |
3260 | mov [edx + RECT.right], eax |
3323 | mov [edx + RECT.right], eax |
3261 | mov eax, [Screen_Max_Y] |
3324 | mov eax, [Screen_Max_Y] |
3262 | mov [edx + RECT.bottom], eax |
3325 | mov [edx + RECT.bottom], eax |
3263 | 3326 | ||
3264 | srl1: |
3327 | srl1: |
3265 | ret |
3328 | ret |
3266 | 3329 | ||
3267 | ;ok - 100% work |
3330 | ;ok - 100% work |
3268 | ;nt - not tested |
3331 | ;nt - not tested |
3269 | ;--------------------------------------------------------------------------------------------- |
3332 | ;--------------------------------------------------------------------------------------------- |
3270 | ;eax |
3333 | ;eax |
3271 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3334 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3272 | ;1 - change task. Ret nothing. Block. ok. |
3335 | ;1 - change task. Ret nothing. Block. ok. |
3273 | ;2 - performance control |
3336 | ;2 - performance control |
3274 | ; ebx |
3337 | ; ebx |
3275 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3338 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3276 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3339 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3277 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3340 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3278 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3341 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3279 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3342 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3280 | ;eax |
3343 | ;eax |
3281 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3344 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3282 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3345 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3283 | ;--------------------------------------------------------------------------------------------- |
3346 | ;--------------------------------------------------------------------------------------------- |
3284 | iglobal |
3347 | iglobal |
3285 | align 4 |
3348 | align 4 |
3286 | sheduler: |
3349 | sheduler: |
3287 | dd sys_sheduler.00 |
3350 | dd sys_sheduler.00 |
3288 | dd change_task |
3351 | dd change_task |
3289 | dd sys_sheduler.02 |
3352 | dd sys_sheduler.02 |
3290 | dd sys_sheduler.03 |
3353 | dd sys_sheduler.03 |
3291 | dd sys_sheduler.04 |
3354 | dd sys_sheduler.04 |
3292 | endg |
3355 | endg |
3293 | sys_sheduler: |
3356 | sys_sheduler: |
3294 | ;rewritten by |
3357 | ;rewritten by |
3295 | jmp dword [sheduler+ebx*4] |
3358 | jmp dword [sheduler+ebx*4] |
3296 | ;.shed_counter: |
3359 | ;.shed_counter: |
3297 | .00: |
3360 | .00: |
3298 | mov eax, [context_counter] |
3361 | mov eax, [context_counter] |
3299 | mov [esp+32], eax |
3362 | mov [esp+32], eax |
3300 | ret |
3363 | ret |
3301 | 3364 | ||
3302 | .02: |
3365 | .02: |
3303 | ;.perf_control: |
3366 | ;.perf_control: |
3304 | inc ebx ;before ebx=2, ebx=3 |
3367 | inc ebx ;before ebx=2, ebx=3 |
3305 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3368 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3306 | jz cache_disable |
3369 | jz cache_disable |
3307 | 3370 | ||
3308 | dec ebx ;ebx=2 |
3371 | dec ebx ;ebx=2 |
3309 | cmp ebx, ecx ; |
3372 | cmp ebx, ecx ; |
3310 | jz cache_enable ;if ecx=2 and ebx=2 |
3373 | jz cache_enable ;if ecx=2 and ebx=2 |
3311 | 3374 | ||
3312 | dec ebx ;ebx=1 |
3375 | dec ebx ;ebx=1 |
3313 | cmp ebx, ecx |
3376 | cmp ebx, ecx |
3314 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3377 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3315 | 3378 | ||
3316 | dec ebx |
3379 | dec ebx |
3317 | test ebx, ecx ;ebx=0 and ecx=0 |
3380 | test ebx, ecx ;ebx=0 and ecx=0 |
3318 | jz modify_pce ;if ecx=0 |
3381 | jz modify_pce ;if ecx=0 |
3319 | 3382 | ||
3320 | ret |
3383 | ret |
3321 | 3384 | ||
3322 | .03: |
3385 | .03: |
3323 | ;.rdmsr_instr: |
3386 | ;.rdmsr_instr: |
3324 | ;now counter in ecx |
3387 | ;now counter in ecx |
3325 | ;(edx:eax) esi:edi => edx:esi |
3388 | ;(edx:eax) esi:edi => edx:esi |
3326 | mov eax, esi |
3389 | mov eax, esi |
3327 | mov ecx, edx |
3390 | mov ecx, edx |
3328 | rdmsr |
3391 | rdmsr |
3329 | mov [esp+32], eax |
3392 | mov [esp+32], eax |
3330 | mov [esp+20], edx ;ret in ebx? |
3393 | mov [esp+20], edx ;ret in ebx? |
3331 | ret |
3394 | ret |
3332 | 3395 | ||
3333 | .04: |
3396 | .04: |
3334 | ;.wrmsr_instr: |
3397 | ;.wrmsr_instr: |
3335 | ;now counter in ecx |
3398 | ;now counter in ecx |
3336 | ;(edx:eax) esi:edi => edx:esi |
3399 | ;(edx:eax) esi:edi => edx:esi |
3337 | ; Fast Call MSR can't be destroy |
3400 | ; Fast Call MSR can't be destroy |
3338 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3401 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3339 | ; включаются/выключаются расширенные возможности |
3402 | ; включаются/выключаются расширенные возможности |
3340 | cmp edx, MSR_SYSENTER_CS |
3403 | cmp edx, MSR_SYSENTER_CS |
3341 | je @f |
3404 | je @f |
3342 | cmp edx, MSR_SYSENTER_ESP |
3405 | cmp edx, MSR_SYSENTER_ESP |
3343 | je @f |
3406 | je @f |
3344 | cmp edx, MSR_SYSENTER_EIP |
3407 | cmp edx, MSR_SYSENTER_EIP |
3345 | je @f |
3408 | je @f |
3346 | cmp edx, MSR_AMD_STAR |
3409 | cmp edx, MSR_AMD_STAR |
3347 | je @f |
3410 | je @f |
3348 | 3411 | ||
3349 | mov eax, esi |
3412 | mov eax, esi |
3350 | mov ecx, edx |
3413 | mov ecx, edx |
3351 | wrmsr |
3414 | wrmsr |
3352 | ; mov [esp + 32], eax |
3415 | ; mov [esp + 32], eax |
3353 | ; mov [esp + 20], edx ;ret in ebx? |
3416 | ; mov [esp + 20], edx ;ret in ebx? |
3354 | @@: |
3417 | @@: |
3355 | ret |
3418 | ret |
3356 | 3419 | ||
3357 | cache_disable: |
3420 | cache_disable: |
3358 | mov eax, cr0 |
3421 | mov eax, cr0 |
3359 | or eax, 01100000000000000000000000000000b |
3422 | or eax, 01100000000000000000000000000000b |
3360 | mov cr0, eax |
3423 | mov cr0, eax |
3361 | wbinvd ;set MESI |
3424 | wbinvd ;set MESI |
3362 | ret |
3425 | ret |
3363 | 3426 | ||
3364 | cache_enable: |
3427 | cache_enable: |
3365 | mov eax, cr0 |
3428 | mov eax, cr0 |
3366 | and eax, 10011111111111111111111111111111b |
3429 | and eax, 10011111111111111111111111111111b |
3367 | mov cr0, eax |
3430 | mov cr0, eax |
3368 | ret |
3431 | ret |
3369 | 3432 | ||
3370 | is_cache_enabled: |
3433 | is_cache_enabled: |
3371 | mov eax, cr0 |
3434 | mov eax, cr0 |
3372 | mov ebx, eax |
3435 | mov ebx, eax |
3373 | and eax, 01100000000000000000000000000000b |
3436 | and eax, 01100000000000000000000000000000b |
3374 | jz cache_disabled |
3437 | jz cache_disabled |
3375 | mov [esp+32], ebx |
3438 | mov [esp+32], ebx |
3376 | cache_disabled: |
3439 | cache_disabled: |
3377 | mov dword [esp+32], eax;0 |
3440 | mov dword [esp+32], eax;0 |
3378 | ret |
3441 | ret |
3379 | 3442 | ||
3380 | modify_pce: |
3443 | modify_pce: |
3381 | mov eax, cr4 |
3444 | mov eax, cr4 |
3382 | ; mov ebx,0 |
3445 | ; mov ebx,0 |
3383 | ; or bx,100000000b ;pce |
3446 | ; or bx,100000000b ;pce |
3384 | ; xor eax,ebx ;invert pce |
3447 | ; xor eax,ebx ;invert pce |
3385 | bts eax, 8;pce=cr4[8] |
3448 | bts eax, 8;pce=cr4[8] |
3386 | mov cr4, eax |
3449 | mov cr4, eax |
3387 | mov [esp+32], eax |
3450 | mov [esp+32], eax |
3388 | ret |
3451 | ret |
3389 | ;--------------------------------------------------------------------------------------------- |
3452 | ;--------------------------------------------------------------------------------------------- |
3390 | 3453 | ||
3391 | 3454 | ||
3392 | ; check if pixel is allowed to be drawn |
3455 | ; check if pixel is allowed to be drawn |
3393 | 3456 | ||
3394 | ;checkpixel: |
3457 | ;checkpixel: |
3395 | ; push eax edx |
3458 | ; push eax edx |
3396 | 3459 | ||
3397 | ;; mov edx, [Screen_Max_X] ; screen x size |
3460 | ;; mov edx, [Screen_Max_X] ; screen x size |
3398 | ;; inc edx |
3461 | ;; inc edx |
3399 | ;; imul edx, ebx |
3462 | ;; imul edx, ebx |
3400 | ; mov edx, [d_width_calc_area + ebx*4] |
3463 | ; mov edx, [d_width_calc_area + ebx*4] |
3401 | ; add eax, [_WinMapAddress] |
3464 | ; add eax, [_WinMapAddress] |
3402 | ; mov dl, [eax+edx]; lea eax, [...] |
3465 | ; mov dl, [eax+edx]; lea eax, [...] |
3403 | 3466 | ||
3404 | ; xor ecx, ecx |
3467 | ; xor ecx, ecx |
3405 | ; mov eax, [CURRENT_TASK] |
3468 | ; mov eax, [CURRENT_TASK] |
3406 | ; cmp al, dl |
3469 | ; cmp al, dl |
3407 | ; setne cl |
3470 | ; setne cl |
3408 | 3471 | ||
3409 | ; pop edx eax |
3472 | ; pop edx eax |
3410 | ; ret |
3473 | ; ret |
3411 | 3474 | ||
3412 | iglobal |
3475 | iglobal |
3413 | cpustring db 'CPU',0 |
3476 | cpustring db 'CPU',0 |
3414 | endg |
3477 | endg |
3415 | 3478 | ||
3416 | uglobal |
3479 | uglobal |
3417 | background_defined db 0 ; diamond, 11.04.2006 |
3480 | background_defined db 0 ; diamond, 11.04.2006 |
3418 | endg |
3481 | endg |
3419 | ;----------------------------------------------------------------------------- |
3482 | ;----------------------------------------------------------------------------- |
3420 | align 4 |
3483 | align 4 |
3421 | checkmisc: |
3484 | checkmisc: |
3422 | cmp [ctrl_alt_del], 1 |
3485 | cmp [ctrl_alt_del], 1 |
3423 | jne nocpustart |
3486 | jne nocpustart |
3424 | 3487 | ||
3425 | mov ebp, cpustring |
3488 | mov ebp, cpustring |
3426 | call fs_execute_from_sysdir |
3489 | call fs_execute_from_sysdir |
3427 | 3490 | ||
3428 | mov [ctrl_alt_del], 0 |
3491 | mov [ctrl_alt_del], 0 |
3429 | ;-------------------------------------- |
3492 | ;-------------------------------------- |
3430 | align 4 |
3493 | align 4 |
3431 | nocpustart: |
3494 | nocpustart: |
3432 | cmp [mouse_active], 1 |
3495 | cmp [mouse_active], 1 |
3433 | jne mouse_not_active |
3496 | jne mouse_not_active |
3434 | mov [mouse_active], 0 |
3497 | mov [mouse_active], 0 |
3435 | 3498 | ||
3436 | xor edi, edi |
3499 | xor edi, edi |
3437 | mov ebx, CURRENT_TASK |
3500 | mov ebx, CURRENT_TASK |
3438 | 3501 | ||
3439 | mov ecx, [TASK_COUNT] |
3502 | mov ecx, [TASK_COUNT] |
3440 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3503 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3441 | shl eax, 8 |
3504 | shl eax, 8 |
3442 | push eax |
3505 | push eax |
3443 | 3506 | ||
3444 | movzx eax, word [MOUSE_X] |
3507 | movzx eax, word [MOUSE_X] |
3445 | movzx edx, word [MOUSE_Y] |
3508 | movzx edx, word [MOUSE_Y] |
3446 | ;-------------------------------------- |
3509 | ;-------------------------------------- |
3447 | align 4 |
3510 | align 4 |
3448 | .set_mouse_event: |
3511 | .set_mouse_event: |
3449 | add edi, 256 |
3512 | add edi, 256 |
3450 | add ebx, 32 |
3513 | add ebx, 32 |
3451 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3514 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3452 | jz .pos_filter |
3515 | jz .pos_filter |
3453 | 3516 | ||
3454 | cmp edi, [esp] ; skip if filtration active |
3517 | cmp edi, [esp] ; skip if filtration active |
3455 | jne .skip |
3518 | jne .skip |
3456 | ;-------------------------------------- |
3519 | ;-------------------------------------- |
3457 | align 4 |
3520 | align 4 |
3458 | .pos_filter: |
3521 | .pos_filter: |
3459 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3522 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3460 | jz .set |
3523 | jz .set |
3461 | 3524 | ||
3462 | mov esi, [ebx-twdw+WDATA.box.left] |
3525 | mov esi, [ebx-twdw+WDATA.box.left] |
3463 | cmp eax, esi |
3526 | cmp eax, esi |
3464 | jb .skip |
3527 | jb .skip |
3465 | add esi, [ebx-twdw+WDATA.box.width] |
3528 | add esi, [ebx-twdw+WDATA.box.width] |
3466 | cmp eax, esi |
3529 | cmp eax, esi |
3467 | ja .skip |
3530 | ja .skip |
3468 | 3531 | ||
3469 | mov esi, [ebx-twdw+WDATA.box.top] |
3532 | mov esi, [ebx-twdw+WDATA.box.top] |
3470 | cmp edx, esi |
3533 | cmp edx, esi |
3471 | jb .skip |
3534 | jb .skip |
3472 | add esi, [ebx-twdw+WDATA.box.height] |
3535 | add esi, [ebx-twdw+WDATA.box.height] |
3473 | cmp edx, esi |
3536 | cmp edx, esi |
3474 | ja .skip |
3537 | ja .skip |
3475 | ;-------------------------------------- |
3538 | ;-------------------------------------- |
3476 | align 4 |
3539 | align 4 |
3477 | .set: |
3540 | .set: |
3478 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3541 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3479 | ;-------------------------------------- |
3542 | ;-------------------------------------- |
3480 | align 4 |
3543 | align 4 |
3481 | .skip: |
3544 | .skip: |
3482 | loop .set_mouse_event |
3545 | loop .set_mouse_event |
3483 | 3546 | ||
3484 | pop eax |
3547 | pop eax |
3485 | ;-------------------------------------- |
3548 | ;-------------------------------------- |
3486 | align 4 |
3549 | align 4 |
3487 | mouse_not_active: |
3550 | mouse_not_active: |
3488 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3551 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3489 | jz nobackgr |
3552 | jz nobackgr |
3490 | 3553 | ||
3491 | cmp [background_defined], 0 |
3554 | cmp [background_defined], 0 |
3492 | jz nobackgr |
3555 | jz nobackgr |
3493 | ;-------------------------------------- |
3556 | ;-------------------------------------- |
3494 | align 4 |
3557 | align 4 |
3495 | backgr: |
3558 | backgr: |
3496 | mov eax, [draw_data+32 + RECT.left] |
3559 | mov eax, [draw_data+32 + RECT.left] |
3497 | shl eax, 16 |
3560 | shl eax, 16 |
3498 | add eax, [draw_data+32 + RECT.right] |
3561 | add eax, [draw_data+32 + RECT.right] |
3499 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3562 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3500 | 3563 | ||
3501 | mov eax, [draw_data+32 + RECT.top] |
3564 | mov eax, [draw_data+32 + RECT.top] |
3502 | shl eax, 16 |
3565 | shl eax, 16 |
3503 | add eax, [draw_data+32 + RECT.bottom] |
3566 | add eax, [draw_data+32 + RECT.bottom] |
3504 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3567 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3505 | 3568 | ||
3506 | call drawbackground |
3569 | call drawbackground |
3507 | ; DEBUGF 1, "K : drawbackground\n" |
3570 | ; DEBUGF 1, "K : drawbackground\n" |
3508 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3571 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3509 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3572 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3510 | ;--------- set event 5 start ---------- |
3573 | ;--------- set event 5 start ---------- |
3511 | push ecx edi |
3574 | push ecx edi |
3512 | xor edi, edi |
3575 | xor edi, edi |
3513 | mov ecx, [TASK_COUNT] |
3576 | mov ecx, [TASK_COUNT] |
3514 | ;-------------------------------------- |
3577 | ;-------------------------------------- |
3515 | align 4 |
3578 | align 4 |
3516 | set_bgr_event: |
3579 | set_bgr_event: |
3517 | add edi, 256 |
3580 | add edi, 256 |
3518 | mov eax, [BG_Rect_X_left_right] |
3581 | mov eax, [BG_Rect_X_left_right] |
3519 | mov edx, [BG_Rect_Y_top_bottom] |
3582 | mov edx, [BG_Rect_Y_top_bottom] |
3520 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3583 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3521 | jz .set |
3584 | jz .set |
3522 | .join: |
3585 | .join: |
3523 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3586 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3524 | jae @f |
3587 | jae @f |
3525 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3588 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3526 | @@: |
3589 | @@: |
3527 | shr eax, 16 |
3590 | shr eax, 16 |
3528 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3591 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3529 | jbe @f |
3592 | jbe @f |
3530 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3593 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3531 | @@: |
3594 | @@: |
3532 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3595 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3533 | jae @f |
3596 | jae @f |
3534 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3597 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3535 | @@: |
3598 | @@: |
3536 | shr edx, 16 |
3599 | shr edx, 16 |
3537 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3600 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3538 | jbe @f |
3601 | jbe @f |
3539 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3602 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3540 | @@: |
3603 | @@: |
3541 | jmp .common |
3604 | jmp .common |
3542 | .set: |
3605 | .set: |
3543 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3606 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3544 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3607 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3545 | .common: |
3608 | .common: |
3546 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3609 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3547 | loop set_bgr_event |
3610 | loop set_bgr_event |
3548 | pop edi ecx |
3611 | pop edi ecx |
3549 | ;--------- set event 5 stop ----------- |
3612 | ;--------- set event 5 stop ----------- |
3550 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3613 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3551 | jnz backgr |
3614 | jnz backgr |
3552 | 3615 | ||
3553 | xor eax, eax |
3616 | xor eax, eax |
3554 | mov [draw_data+32 + RECT.left], eax |
3617 | mov [draw_data+32 + RECT.left], eax |
3555 | mov [draw_data+32 + RECT.top], eax |
3618 | mov [draw_data+32 + RECT.top], eax |
3556 | mov [draw_data+32 + RECT.right], eax |
3619 | mov [draw_data+32 + RECT.right], eax |
3557 | mov [draw_data+32 + RECT.bottom], eax |
3620 | mov [draw_data+32 + RECT.bottom], eax |
3558 | ;-------------------------------------- |
3621 | ;-------------------------------------- |
3559 | align 4 |
3622 | align 4 |
3560 | nobackgr: |
3623 | nobackgr: |
3561 | ; system shutdown request |
3624 | ; system shutdown request |
3562 | cmp [SYS_SHUTDOWN], byte 0 |
3625 | cmp [SYS_SHUTDOWN], byte 0 |
3563 | je noshutdown |
3626 | je noshutdown |
3564 | 3627 | ||
3565 | mov edx, [shutdown_processes] |
3628 | mov edx, [shutdown_processes] |
3566 | 3629 | ||
3567 | cmp [SYS_SHUTDOWN], dl |
3630 | cmp [SYS_SHUTDOWN], dl |
3568 | jne noshutdown |
3631 | jne noshutdown |
3569 | 3632 | ||
3570 | lea ecx, [edx-1] |
3633 | lea ecx, [edx-1] |
3571 | mov edx, OS_BASE+0x3040 |
3634 | mov edx, OS_BASE+0x3040 |
3572 | jecxz no_mark_system_shutdown |
3635 | jecxz no_mark_system_shutdown |
3573 | ;-------------------------------------- |
3636 | ;-------------------------------------- |
3574 | align 4 |
3637 | align 4 |
3575 | markz: |
3638 | markz: |
3576 | push ecx edx |
3639 | push ecx edx |
3577 | cmp [edx+TASKDATA.state], 9 |
3640 | cmp [edx+TASKDATA.state], 9 |
3578 | jz .nokill |
3641 | jz .nokill |
3579 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3642 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3580 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3643 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
3581 | jz .nokill |
3644 | jz .nokill |
3582 | call request_terminate |
3645 | call request_terminate |
3583 | jmp .common |
3646 | jmp .common |
3584 | .nokill: |
3647 | .nokill: |
3585 | dec byte [SYS_SHUTDOWN] |
3648 | dec byte [SYS_SHUTDOWN] |
3586 | xor eax, eax |
3649 | xor eax, eax |
3587 | .common: |
3650 | .common: |
3588 | pop edx ecx |
3651 | pop edx ecx |
3589 | test eax, eax |
3652 | test eax, eax |
3590 | jz @f |
3653 | jz @f |
3591 | mov [edx+TASKDATA.state], byte 3 |
3654 | mov [edx+TASKDATA.state], byte 3 |
3592 | @@: |
3655 | @@: |
3593 | add edx, 0x20 |
3656 | add edx, 0x20 |
3594 | loop markz |
3657 | loop markz |
3595 | call wakeup_osloop |
3658 | call wakeup_osloop |
3596 | ;-------------------------------------- |
3659 | ;-------------------------------------- |
3597 | align 4 |
3660 | align 4 |
3598 | @@: |
3661 | @@: |
3599 | no_mark_system_shutdown: |
3662 | no_mark_system_shutdown: |
3600 | dec byte [SYS_SHUTDOWN] |
3663 | dec byte [SYS_SHUTDOWN] |
3601 | je system_shutdown |
3664 | je system_shutdown |
3602 | ;-------------------------------------- |
3665 | ;-------------------------------------- |
3603 | align 4 |
3666 | align 4 |
3604 | noshutdown: |
3667 | noshutdown: |
3605 | mov eax, [TASK_COUNT] ; termination |
3668 | mov eax, [TASK_COUNT] ; termination |
3606 | mov ebx, TASK_DATA+TASKDATA.state |
3669 | mov ebx, TASK_DATA+TASKDATA.state |
3607 | mov esi, 1 |
3670 | mov esi, 1 |
3608 | ;-------------------------------------- |
3671 | ;-------------------------------------- |
3609 | align 4 |
3672 | align 4 |
3610 | newct: |
3673 | newct: |
3611 | mov cl, [ebx] |
3674 | mov cl, [ebx] |
3612 | cmp cl, byte 3 |
3675 | cmp cl, byte 3 |
3613 | jz .terminate |
3676 | jz .terminate |
3614 | 3677 | ||
3615 | cmp cl, byte 4 |
3678 | cmp cl, byte 4 |
3616 | jnz .noterminate |
3679 | jnz .noterminate |
3617 | .terminate: |
3680 | .terminate: |
3618 | pushad |
3681 | pushad |
3619 | mov ecx, eax |
3682 | mov ecx, eax |
3620 | shl ecx, 8 |
3683 | shl ecx, 8 |
3621 | add ecx, SLOT_BASE |
3684 | add ecx, SLOT_BASE |
3622 | call restore_default_cursor_before_killing |
3685 | call restore_default_cursor_before_killing |
3623 | popad |
3686 | popad |
3624 | 3687 | ||
3625 | pushad |
3688 | pushad |
3626 | call terminate |
3689 | call terminate |
3627 | popad |
3690 | popad |
3628 | cmp byte [SYS_SHUTDOWN], 0 |
3691 | cmp byte [SYS_SHUTDOWN], 0 |
3629 | jz .noterminate |
3692 | jz .noterminate |
3630 | dec byte [SYS_SHUTDOWN] |
3693 | dec byte [SYS_SHUTDOWN] |
3631 | je system_shutdown |
3694 | je system_shutdown |
3632 | 3695 | ||
3633 | .noterminate: |
3696 | .noterminate: |
3634 | add ebx, 0x20 |
3697 | add ebx, 0x20 |
3635 | inc esi |
3698 | inc esi |
3636 | dec eax |
3699 | dec eax |
3637 | jnz newct |
3700 | jnz newct |
3638 | ret |
3701 | ret |
3639 | ;----------------------------------------------------------------------------- |
3702 | ;----------------------------------------------------------------------------- |
3640 | align 4 |
3703 | align 4 |
3641 | redrawscreen: |
3704 | redrawscreen: |
3642 | ; eax , if process window_data base is eax, do not set flag/limits |
3705 | ; eax , if process window_data base is eax, do not set flag/limits |
3643 | 3706 | ||
3644 | pushad |
3707 | pushad |
3645 | push eax |
3708 | push eax |
3646 | 3709 | ||
3647 | ;;; mov ebx,2 |
3710 | ;;; mov ebx,2 |
3648 | ;;; call delay_hs |
3711 | ;;; call delay_hs |
3649 | 3712 | ||
3650 | ;mov ecx,0 ; redraw flags for apps |
3713 | ;mov ecx,0 ; redraw flags for apps |
3651 | xor ecx, ecx |
3714 | xor ecx, ecx |
3652 | ;-------------------------------------- |
3715 | ;-------------------------------------- |
3653 | align 4 |
3716 | align 4 |
3654 | newdw2: |
3717 | newdw2: |
3655 | inc ecx |
3718 | inc ecx |
3656 | push ecx |
3719 | push ecx |
3657 | 3720 | ||
3658 | mov eax, ecx |
3721 | mov eax, ecx |
3659 | shl eax, 5 |
3722 | shl eax, 5 |
3660 | add eax, window_data |
3723 | add eax, window_data |
3661 | 3724 | ||
3662 | cmp eax, [esp+4] |
3725 | cmp eax, [esp+4] |
3663 | je not_this_task |
3726 | je not_this_task |
3664 | ; check if window in redraw area |
3727 | ; check if window in redraw area |
3665 | mov edi, eax |
3728 | mov edi, eax |
3666 | 3729 | ||
3667 | cmp ecx, 1 ; limit for background |
3730 | cmp ecx, 1 ; limit for background |
3668 | jz bgli |
3731 | jz bgli |
3669 | 3732 | ||
3670 | mov eax, [edi + WDATA.box.left] |
3733 | mov eax, [edi + WDATA.box.left] |
3671 | mov ebx, [edi + WDATA.box.top] |
3734 | mov ebx, [edi + WDATA.box.top] |
3672 | mov ecx, [edi + WDATA.box.width] |
3735 | mov ecx, [edi + WDATA.box.width] |
3673 | mov edx, [edi + WDATA.box.height] |
3736 | mov edx, [edi + WDATA.box.height] |
3674 | add ecx, eax |
3737 | add ecx, eax |
3675 | add edx, ebx |
3738 | add edx, ebx |
3676 | 3739 | ||
3677 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3740 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3678 | cmp ecx, ebx |
3741 | cmp ecx, ebx |
3679 | jb ricino |
3742 | jb ricino |
3680 | 3743 | ||
3681 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3744 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3682 | cmp ecx, eax |
3745 | cmp ecx, eax |
3683 | jb ricino |
3746 | jb ricino |
3684 | 3747 | ||
3685 | mov eax, [edi + WDATA.box.left] |
3748 | mov eax, [edi + WDATA.box.left] |
3686 | mov ebx, [edi + WDATA.box.top] |
3749 | mov ebx, [edi + WDATA.box.top] |
3687 | mov ecx, [edi + WDATA.box.width] |
3750 | mov ecx, [edi + WDATA.box.width] |
3688 | mov edx, [edi + WDATA.box.height] |
3751 | mov edx, [edi + WDATA.box.height] |
3689 | add ecx, eax |
3752 | add ecx, eax |
3690 | add edx, ebx |
3753 | add edx, ebx |
3691 | 3754 | ||
3692 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3755 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3693 | cmp edx, eax |
3756 | cmp edx, eax |
3694 | jb ricino |
3757 | jb ricino |
3695 | 3758 | ||
3696 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3759 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3697 | cmp ecx, eax |
3760 | cmp ecx, eax |
3698 | jb ricino |
3761 | jb ricino |
3699 | ;-------------------------------------- |
3762 | ;-------------------------------------- |
3700 | align 4 |
3763 | align 4 |
3701 | bgli: |
3764 | bgli: |
3702 | cmp dword[esp], 1 |
3765 | cmp dword[esp], 1 |
3703 | jnz .az |
3766 | jnz .az |
3704 | 3767 | ||
3705 | cmp byte[REDRAW_BACKGROUND], 0 |
3768 | cmp byte[REDRAW_BACKGROUND], 0 |
3706 | jz .az |
3769 | jz .az |
3707 | 3770 | ||
3708 | mov dl, 0 |
3771 | mov dl, 0 |
3709 | lea eax, [edi+draw_data-window_data] |
3772 | lea eax, [edi+draw_data-window_data] |
3710 | mov ebx, [draw_limits.left] |
3773 | mov ebx, [draw_limits.left] |
3711 | cmp ebx, [eax+RECT.left] |
3774 | cmp ebx, [eax+RECT.left] |
3712 | jae @f |
3775 | jae @f |
3713 | 3776 | ||
3714 | mov [eax+RECT.left], ebx |
3777 | mov [eax+RECT.left], ebx |
3715 | mov dl, 1 |
3778 | mov dl, 1 |
3716 | ;-------------------------------------- |
3779 | ;-------------------------------------- |
3717 | align 4 |
3780 | align 4 |
3718 | @@: |
3781 | @@: |
3719 | mov ebx, [draw_limits.top] |
3782 | mov ebx, [draw_limits.top] |
3720 | cmp ebx, [eax+RECT.top] |
3783 | cmp ebx, [eax+RECT.top] |
3721 | jae @f |
3784 | jae @f |
3722 | 3785 | ||
3723 | mov [eax+RECT.top], ebx |
3786 | mov [eax+RECT.top], ebx |
3724 | mov dl, 1 |
3787 | mov dl, 1 |
3725 | ;-------------------------------------- |
3788 | ;-------------------------------------- |
3726 | align 4 |
3789 | align 4 |
3727 | @@: |
3790 | @@: |
3728 | mov ebx, [draw_limits.right] |
3791 | mov ebx, [draw_limits.right] |
3729 | cmp ebx, [eax+RECT.right] |
3792 | cmp ebx, [eax+RECT.right] |
3730 | jbe @f |
3793 | jbe @f |
3731 | 3794 | ||
3732 | mov [eax+RECT.right], ebx |
3795 | mov [eax+RECT.right], ebx |
3733 | mov dl, 1 |
3796 | mov dl, 1 |
3734 | ;-------------------------------------- |
3797 | ;-------------------------------------- |
3735 | align 4 |
3798 | align 4 |
3736 | @@: |
3799 | @@: |
3737 | mov ebx, [draw_limits.bottom] |
3800 | mov ebx, [draw_limits.bottom] |
3738 | cmp ebx, [eax+RECT.bottom] |
3801 | cmp ebx, [eax+RECT.bottom] |
3739 | jbe @f |
3802 | jbe @f |
3740 | 3803 | ||
3741 | mov [eax+RECT.bottom], ebx |
3804 | mov [eax+RECT.bottom], ebx |
3742 | mov dl, 1 |
3805 | mov dl, 1 |
3743 | ;-------------------------------------- |
3806 | ;-------------------------------------- |
3744 | align 4 |
3807 | align 4 |
3745 | @@: |
3808 | @@: |
3746 | add byte[REDRAW_BACKGROUND], dl |
3809 | add byte[REDRAW_BACKGROUND], dl |
3747 | call wakeup_osloop |
3810 | call wakeup_osloop |
3748 | jmp newdw8 |
3811 | jmp newdw8 |
3749 | ;-------------------------------------- |
3812 | ;-------------------------------------- |
3750 | align 4 |
3813 | align 4 |
3751 | .az: |
3814 | .az: |
3752 | mov eax, edi |
3815 | mov eax, edi |
3753 | add eax, draw_data-window_data |
3816 | add eax, draw_data-window_data |
3754 | 3817 | ||
3755 | mov ebx, [draw_limits.left] ; set limits |
3818 | mov ebx, [draw_limits.left] ; set limits |
3756 | mov [eax + RECT.left], ebx |
3819 | mov [eax + RECT.left], ebx |
3757 | mov ebx, [draw_limits.top] |
3820 | mov ebx, [draw_limits.top] |
3758 | mov [eax + RECT.top], ebx |
3821 | mov [eax + RECT.top], ebx |
3759 | mov ebx, [draw_limits.right] |
3822 | mov ebx, [draw_limits.right] |
3760 | mov [eax + RECT.right], ebx |
3823 | mov [eax + RECT.right], ebx |
3761 | mov ebx, [draw_limits.bottom] |
3824 | mov ebx, [draw_limits.bottom] |
3762 | mov [eax + RECT.bottom], ebx |
3825 | mov [eax + RECT.bottom], ebx |
3763 | 3826 | ||
3764 | sub eax, draw_data-window_data |
3827 | sub eax, draw_data-window_data |
3765 | 3828 | ||
3766 | cmp dword [esp], 1 |
3829 | cmp dword [esp], 1 |
3767 | jne nobgrd |
3830 | jne nobgrd |
3768 | inc byte[REDRAW_BACKGROUND] |
3831 | inc byte[REDRAW_BACKGROUND] |
3769 | call wakeup_osloop |
3832 | call wakeup_osloop |
3770 | ;-------------------------------------- |
3833 | ;-------------------------------------- |
3771 | align 4 |
3834 | align 4 |
3772 | newdw8: |
3835 | newdw8: |
3773 | nobgrd: |
3836 | nobgrd: |
3774 | 3837 | ||
3775 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3838 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3776 | ;-------------------------------------- |
3839 | ;-------------------------------------- |
3777 | align 4 |
3840 | align 4 |
3778 | ricino: |
3841 | ricino: |
3779 | not_this_task: |
3842 | not_this_task: |
3780 | pop ecx |
3843 | pop ecx |
3781 | 3844 | ||
3782 | cmp ecx, [TASK_COUNT] |
3845 | cmp ecx, [TASK_COUNT] |
3783 | jle newdw2 |
3846 | jle newdw2 |
3784 | 3847 | ||
3785 | pop eax |
3848 | pop eax |
3786 | popad |
3849 | popad |
3787 | ret |
3850 | ret |
3788 | ;----------------------------------------------------------------------------- |
3851 | ;----------------------------------------------------------------------------- |
3789 | align 4 |
3852 | align 4 |
3790 | calculatebackground: ; background |
3853 | calculatebackground: ; background |
3791 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3854 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3792 | mov eax, 0x01010101 |
3855 | mov eax, 0x01010101 |
3793 | mov ecx, [_WinMapSize] |
3856 | mov ecx, [_WinMapSize] |
3794 | shr ecx, 2 |
3857 | shr ecx, 2 |
3795 | rep stosd |
3858 | rep stosd |
3796 | 3859 | ||
3797 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3860 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3798 | ret |
3861 | ret |
3799 | ;----------------------------------------------------------------------------- |
3862 | ;----------------------------------------------------------------------------- |
3800 | uglobal |
3863 | uglobal |
3801 | imax dd 0x0 |
3864 | imax dd 0x0 |
3802 | endg |
3865 | endg |
3803 | ;----------------------------------------------------------------------------- |
3866 | ;----------------------------------------------------------------------------- |
3804 | align 4 |
3867 | align 4 |
3805 | delay_ms: ; delay in 1/1000 sec |
3868 | delay_ms: ; delay in 1/1000 sec |
3806 | push eax |
3869 | push eax |
3807 | push ecx |
3870 | push ecx |
3808 | 3871 | ||
3809 | mov ecx, esi |
3872 | mov ecx, esi |
3810 | ; |
3873 | ; |
3811 | imul ecx, 33941 |
3874 | imul ecx, 33941 |
3812 | shr ecx, 9 |
3875 | shr ecx, 9 |
3813 | ; |
3876 | ; |
3814 | 3877 | ||
3815 | in al, 0x61 |
3878 | in al, 0x61 |
3816 | and al, 0x10 |
3879 | and al, 0x10 |
3817 | mov ah, al |
3880 | mov ah, al |
3818 | cld |
3881 | cld |
3819 | ;-------------------------------------- |
3882 | ;-------------------------------------- |
3820 | align 4 |
3883 | align 4 |
3821 | cnt1: |
3884 | cnt1: |
3822 | in al, 0x61 |
3885 | in al, 0x61 |
3823 | and al, 0x10 |
3886 | and al, 0x10 |
3824 | cmp al, ah |
3887 | cmp al, ah |
3825 | jz cnt1 |
3888 | jz cnt1 |
3826 | 3889 | ||
3827 | mov ah, al |
3890 | mov ah, al |
3828 | loop cnt1 |
3891 | loop cnt1 |
3829 | 3892 | ||
3830 | pop ecx |
3893 | pop ecx |
3831 | pop eax |
3894 | pop eax |
3832 | ret |
3895 | ret |
3833 | ;----------------------------------------------------------------------------- |
3896 | ;----------------------------------------------------------------------------- |
3834 | align 4 |
3897 | align 4 |
3835 | set_app_param: |
3898 | set_app_param: |
3836 | mov edi, [TASK_BASE] |
3899 | mov edi, [TASK_BASE] |
3837 | mov eax, ebx |
3900 | mov eax, ebx |
3838 | btr eax, 3 ; move MOUSE_FILTRATION |
3901 | btr eax, 3 ; move MOUSE_FILTRATION |
3839 | mov ebx, [current_slot] ; bit into event_filter |
3902 | mov ebx, [current_slot] ; bit into event_filter |
3840 | setc byte [ebx+APPDATA.event_filter] |
3903 | setc byte [ebx+APPDATA.event_filter] |
3841 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3904 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3842 | mov [esp+32], eax ; return old mask value |
3905 | mov [esp+32], eax ; return old mask value |
3843 | ret |
3906 | ret |
3844 | ;----------------------------------------------------------------------------- |
3907 | ;----------------------------------------------------------------------------- |
3845 | 3908 | ||
3846 | ; this is for syscall |
3909 | ; this is for syscall |
3847 | proc delay_hs_unprotected |
3910 | proc delay_hs_unprotected |
3848 | call unprotect_from_terminate |
3911 | call unprotect_from_terminate |
3849 | call delay_hs |
3912 | call delay_hs |
3850 | call protect_from_terminate |
3913 | call protect_from_terminate |
3851 | ret |
3914 | ret |
3852 | endp |
3915 | endp |
3853 | 3916 | ||
3854 | if 1 |
3917 | if 1 |
3855 | align 4 |
3918 | align 4 |
3856 | delay_hs: ; delay in 1/100 secs |
3919 | delay_hs: ; delay in 1/100 secs |
3857 | ; ebx = delay time |
3920 | ; ebx = delay time |
3858 | 3921 | ||
3859 | pushad |
3922 | pushad |
3860 | push ebx |
3923 | push ebx |
3861 | xor esi, esi |
3924 | xor esi, esi |
3862 | mov ecx, MANUAL_DESTROY |
3925 | mov ecx, MANUAL_DESTROY |
3863 | call create_event |
3926 | call create_event |
3864 | test eax, eax |
3927 | test eax, eax |
3865 | jz .done |
3928 | jz .done |
3866 | 3929 | ||
3867 | mov ebx, edx |
3930 | mov ebx, edx |
3868 | mov ecx, [esp] |
3931 | mov ecx, [esp] |
3869 | push edx |
3932 | push edx |
3870 | push eax |
3933 | push eax |
3871 | call wait_event_timeout |
3934 | call wait_event_timeout |
3872 | pop eax |
3935 | pop eax |
3873 | pop ebx |
3936 | pop ebx |
3874 | call destroy_event |
3937 | call destroy_event |
3875 | .done: |
3938 | .done: |
3876 | add esp, 4 |
3939 | add esp, 4 |
3877 | popad |
3940 | popad |
3878 | ret |
3941 | ret |
3879 | 3942 | ||
3880 | else |
3943 | else |
3881 | 3944 | ||
3882 | align 4 |
3945 | align 4 |
3883 | delay_hs: ; delay in 1/100 secs |
3946 | delay_hs: ; delay in 1/100 secs |
3884 | ; ebx = delay time |
3947 | ; ebx = delay time |
3885 | push ecx |
3948 | push ecx |
3886 | push edx |
3949 | push edx |
3887 | 3950 | ||
3888 | mov edx, [timer_ticks] |
3951 | mov edx, [timer_ticks] |
3889 | ;-------------------------------------- |
3952 | ;-------------------------------------- |
3890 | align 4 |
3953 | align 4 |
3891 | newtic: |
3954 | newtic: |
3892 | mov ecx, [timer_ticks] |
3955 | mov ecx, [timer_ticks] |
3893 | sub ecx, edx |
3956 | sub ecx, edx |
3894 | cmp ecx, ebx |
3957 | cmp ecx, ebx |
3895 | jae zerodelay |
3958 | jae zerodelay |
3896 | 3959 | ||
3897 | call change_task |
3960 | call change_task |
3898 | 3961 | ||
3899 | jmp newtic |
3962 | jmp newtic |
3900 | ;-------------------------------------- |
3963 | ;-------------------------------------- |
3901 | align 4 |
3964 | align 4 |
3902 | zerodelay: |
3965 | zerodelay: |
3903 | pop edx |
3966 | pop edx |
3904 | pop ecx |
3967 | pop ecx |
3905 | ret |
3968 | ret |
3906 | end if |
3969 | end if |
3907 | 3970 | ||
3908 | ;----------------------------------------------------------------------------- |
3971 | ;----------------------------------------------------------------------------- |
3909 | align 16 ;very often call this subrutine |
3972 | align 16 ;very often call this subrutine |
3910 | memmove: ; memory move in bytes |
3973 | memmove: ; memory move in bytes |
3911 | ; eax = from |
3974 | ; eax = from |
3912 | ; ebx = to |
3975 | ; ebx = to |
3913 | ; ecx = no of bytes |
3976 | ; ecx = no of bytes |
3914 | test ecx, ecx |
3977 | test ecx, ecx |
3915 | jle .ret |
3978 | jle .ret |
3916 | 3979 | ||
3917 | push esi edi ecx |
3980 | push esi edi ecx |
3918 | 3981 | ||
3919 | mov edi, ebx |
3982 | mov edi, ebx |
3920 | mov esi, eax |
3983 | mov esi, eax |
3921 | 3984 | ||
3922 | test ecx, not 11b |
3985 | test ecx, not 11b |
3923 | jz @f |
3986 | jz @f |
3924 | 3987 | ||
3925 | push ecx |
3988 | push ecx |
3926 | shr ecx, 2 |
3989 | shr ecx, 2 |
3927 | rep movsd |
3990 | rep movsd |
3928 | pop ecx |
3991 | pop ecx |
3929 | and ecx, 11b |
3992 | and ecx, 11b |
3930 | jz .finish |
3993 | jz .finish |
3931 | ;-------------------------------------- |
3994 | ;-------------------------------------- |
3932 | align 4 |
3995 | align 4 |
3933 | @@: |
3996 | @@: |
3934 | rep movsb |
3997 | rep movsb |
3935 | ;-------------------------------------- |
3998 | ;-------------------------------------- |
3936 | align 4 |
3999 | align 4 |
3937 | .finish: |
4000 | .finish: |
3938 | pop ecx edi esi |
4001 | pop ecx edi esi |
3939 | ;-------------------------------------- |
4002 | ;-------------------------------------- |
3940 | align 4 |
4003 | align 4 |
3941 | .ret: |
4004 | .ret: |
3942 | ret |
4005 | ret |
3943 | ;----------------------------------------------------------------------------- |
4006 | ;----------------------------------------------------------------------------- |
3944 | ; |
4007 | ; |
3945 | ;align 4 |
4008 | ;align 4 |
3946 | ; |
4009 | ; |
3947 | ;read_floppy_file: |
4010 | ;read_floppy_file: |
3948 | ; |
4011 | ; |
3949 | ;; as input |
4012 | ;; as input |
3950 | ;; |
4013 | ;; |
3951 | ;; eax pointer to file |
4014 | ;; eax pointer to file |
3952 | ;; ebx file lenght |
4015 | ;; ebx file lenght |
3953 | ;; ecx start 512 byte block number |
4016 | ;; ecx start 512 byte block number |
3954 | ;; edx number of blocks to read |
4017 | ;; edx number of blocks to read |
3955 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4018 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3956 | ;; |
4019 | ;; |
3957 | ;; |
4020 | ;; |
3958 | ;; on return |
4021 | ;; on return |
3959 | ;; |
4022 | ;; |
3960 | ;; eax = 0 command succesful |
4023 | ;; eax = 0 command succesful |
3961 | ;; 1 no fd base and/or partition defined |
4024 | ;; 1 no fd base and/or partition defined |
3962 | ;; 2 yet unsupported FS |
4025 | ;; 2 yet unsupported FS |
3963 | ;; 3 unknown FS |
4026 | ;; 3 unknown FS |
3964 | ;; 4 partition not defined at hd |
4027 | ;; 4 partition not defined at hd |
3965 | ;; 5 file not found |
4028 | ;; 5 file not found |
3966 | ;; ebx = size of file |
4029 | ;; ebx = size of file |
3967 | ; |
4030 | ; |
3968 | ; mov edi,[TASK_BASE] |
4031 | ; mov edi,[TASK_BASE] |
3969 | ; add edi,0x10 |
4032 | ; add edi,0x10 |
3970 | ; add esi,[edi] |
4033 | ; add esi,[edi] |
3971 | ; add eax,[edi] |
4034 | ; add eax,[edi] |
3972 | ; |
4035 | ; |
3973 | ; pushad |
4036 | ; pushad |
3974 | ; mov edi,esi |
4037 | ; mov edi,esi |
3975 | ; add edi,1024 |
4038 | ; add edi,1024 |
3976 | ; mov esi,0x100000+19*512 |
4039 | ; mov esi,0x100000+19*512 |
3977 | ; sub ecx,1 |
4040 | ; sub ecx,1 |
3978 | ; shl ecx,9 |
4041 | ; shl ecx,9 |
3979 | ; add esi,ecx |
4042 | ; add esi,ecx |
3980 | ; shl edx,9 |
4043 | ; shl edx,9 |
3981 | ; mov ecx,edx |
4044 | ; mov ecx,edx |
3982 | ; cld |
4045 | ; cld |
3983 | ; rep movsb |
4046 | ; rep movsb |
3984 | ; popad |
4047 | ; popad |
3985 | ; |
4048 | ; |
3986 | ; mov [esp+36],eax |
4049 | ; mov [esp+36],eax |
3987 | ; mov [esp+24],ebx |
4050 | ; mov [esp+24],ebx |
3988 | ; ret |
4051 | ; ret |
3989 | 4052 | ||
3990 | 4053 | ||
3991 | 4054 | ||
3992 | align 4 |
4055 | align 4 |
3993 | set_io_access_rights: |
4056 | set_io_access_rights: |
3994 | push edi eax |
4057 | push edi eax |
3995 | mov edi, tss._io_map_0 |
4058 | mov edi, tss._io_map_0 |
3996 | ; mov ecx,eax |
4059 | ; mov ecx,eax |
3997 | ; and ecx,7 ; offset in byte |
4060 | ; and ecx,7 ; offset in byte |
3998 | ; shr eax,3 ; number of byte |
4061 | ; shr eax,3 ; number of byte |
3999 | ; add edi,eax |
4062 | ; add edi,eax |
4000 | ; mov ebx,1 |
4063 | ; mov ebx,1 |
4001 | ; shl ebx,cl |
4064 | ; shl ebx,cl |
4002 | test ebp, ebp |
4065 | test ebp, ebp |
4003 | ; cmp ebp,0 ; enable access - ebp = 0 |
4066 | ; cmp ebp,0 ; enable access - ebp = 0 |
4004 | jnz .siar1 |
4067 | jnz .siar1 |
4005 | ; not ebx |
4068 | ; not ebx |
4006 | ; and [edi],byte bl |
4069 | ; and [edi],byte bl |
4007 | btr [edi], eax |
4070 | btr [edi], eax |
4008 | pop eax edi |
4071 | pop eax edi |
4009 | ret |
4072 | ret |
4010 | .siar1: |
4073 | .siar1: |
4011 | bts [edi], eax |
4074 | bts [edi], eax |
4012 | ; or [edi],byte bl ; disable access - ebp = 1 |
4075 | ; or [edi],byte bl ; disable access - ebp = 1 |
4013 | pop eax edi |
4076 | pop eax edi |
4014 | ret |
4077 | ret |
4015 | ;reserve/free group of ports |
4078 | ;reserve/free group of ports |
4016 | ; * eax = 46 - number function |
4079 | ; * eax = 46 - number function |
4017 | ; * ebx = 0 - reserve, 1 - free |
4080 | ; * ebx = 0 - reserve, 1 - free |
4018 | ; * ecx = number start arrea of ports |
4081 | ; * ecx = number start arrea of ports |
4019 | ; * edx = number end arrea of ports (include last number of port) |
4082 | ; * edx = number end arrea of ports (include last number of port) |
4020 | ;Return value: |
4083 | ;Return value: |
4021 | ; * eax = 0 - succesful |
4084 | ; * eax = 0 - succesful |
4022 | ; * eax = 1 - error |
4085 | ; * eax = 1 - error |
4023 | ; * The system has reserve this ports: |
4086 | ; * The system has reserve this ports: |
4024 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4087 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4025 | ;destroys eax,ebx, ebp |
4088 | ;destroys eax,ebx, ebp |
4026 | r_f_port_area: |
4089 | r_f_port_area: |
4027 | 4090 | ||
4028 | test ebx, ebx |
4091 | test ebx, ebx |
4029 | jnz free_port_area |
4092 | jnz free_port_area |
4030 | ; je r_port_area |
4093 | ; je r_port_area |
4031 | ; jmp free_port_area |
4094 | ; jmp free_port_area |
4032 | 4095 | ||
4033 | ; r_port_area: |
4096 | ; r_port_area: |
4034 | 4097 | ||
4035 | ; pushad |
4098 | ; pushad |
4036 | 4099 | ||
4037 | cmp ecx, edx ; beginning > end ? |
4100 | cmp ecx, edx ; beginning > end ? |
4038 | ja rpal1 |
4101 | ja rpal1 |
4039 | cmp edx, 65536 |
4102 | cmp edx, 65536 |
4040 | jae rpal1 |
4103 | jae rpal1 |
4041 | mov eax, [RESERVED_PORTS] |
4104 | mov eax, [RESERVED_PORTS] |
4042 | test eax, eax ; no reserved areas ? |
4105 | test eax, eax ; no reserved areas ? |
4043 | je rpal2 |
4106 | je rpal2 |
4044 | cmp eax, 255 ; max reserved |
4107 | cmp eax, 255 ; max reserved |
4045 | jae rpal1 |
4108 | jae rpal1 |
4046 | rpal3: |
4109 | rpal3: |
4047 | mov ebx, eax |
4110 | mov ebx, eax |
4048 | shl ebx, 4 |
4111 | shl ebx, 4 |
4049 | add ebx, RESERVED_PORTS |
4112 | add ebx, RESERVED_PORTS |
4050 | cmp ecx, [ebx+8] |
4113 | cmp ecx, [ebx+8] |
4051 | ja rpal4 |
4114 | ja rpal4 |
4052 | cmp edx, [ebx+4] |
4115 | cmp edx, [ebx+4] |
4053 | jae rpal1 |
4116 | jae rpal1 |
4054 | ; jb rpal4 |
4117 | ; jb rpal4 |
4055 | ; jmp rpal1 |
4118 | ; jmp rpal1 |
4056 | rpal4: |
4119 | rpal4: |
4057 | dec eax |
4120 | dec eax |
4058 | jnz rpal3 |
4121 | jnz rpal3 |
4059 | jmp rpal2 |
4122 | jmp rpal2 |
4060 | rpal1: |
4123 | rpal1: |
4061 | ; popad |
4124 | ; popad |
4062 | ; mov eax,1 |
4125 | ; mov eax,1 |
4063 | xor eax, eax |
4126 | xor eax, eax |
4064 | inc eax |
4127 | inc eax |
4065 | ret |
4128 | ret |
4066 | rpal2: |
4129 | rpal2: |
4067 | ; popad |
4130 | ; popad |
4068 | ; enable port access at port IO map |
4131 | ; enable port access at port IO map |
4069 | cli |
4132 | cli |
4070 | pushad ; start enable io map |
4133 | pushad ; start enable io map |
4071 | 4134 | ||
4072 | cmp edx, 65536;16384 |
4135 | cmp edx, 65536;16384 |
4073 | jae no_unmask_io; jge |
4136 | jae no_unmask_io; jge |
4074 | mov eax, ecx |
4137 | mov eax, ecx |
4075 | ; push ebp |
4138 | ; push ebp |
4076 | xor ebp, ebp ; enable - eax = port |
4139 | xor ebp, ebp ; enable - eax = port |
4077 | new_port_access: |
4140 | new_port_access: |
4078 | ; pushad |
4141 | ; pushad |
4079 | call set_io_access_rights |
4142 | call set_io_access_rights |
4080 | ; popad |
4143 | ; popad |
4081 | inc eax |
4144 | inc eax |
4082 | cmp eax, edx |
4145 | cmp eax, edx |
4083 | jbe new_port_access |
4146 | jbe new_port_access |
4084 | ; pop ebp |
4147 | ; pop ebp |
4085 | no_unmask_io: |
4148 | no_unmask_io: |
4086 | popad ; end enable io map |
4149 | popad ; end enable io map |
4087 | sti |
4150 | sti |
4088 | 4151 | ||
4089 | mov eax, [RESERVED_PORTS] |
4152 | mov eax, [RESERVED_PORTS] |
4090 | add eax, 1 |
4153 | add eax, 1 |
4091 | mov [RESERVED_PORTS], eax |
4154 | mov [RESERVED_PORTS], eax |
4092 | shl eax, 4 |
4155 | shl eax, 4 |
4093 | add eax, RESERVED_PORTS |
4156 | add eax, RESERVED_PORTS |
4094 | mov ebx, [TASK_BASE] |
4157 | mov ebx, [TASK_BASE] |
4095 | mov ebx, [ebx+TASKDATA.pid] |
4158 | mov ebx, [ebx+TASKDATA.pid] |
4096 | mov [eax], ebx |
4159 | mov [eax], ebx |
4097 | mov [eax+4], ecx |
4160 | mov [eax+4], ecx |
4098 | mov [eax+8], edx |
4161 | mov [eax+8], edx |
4099 | 4162 | ||
4100 | xor eax, eax |
4163 | xor eax, eax |
4101 | ret |
4164 | ret |
4102 | 4165 | ||
4103 | free_port_area: |
4166 | free_port_area: |
4104 | 4167 | ||
4105 | ; pushad |
4168 | ; pushad |
4106 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4169 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4107 | test eax, eax |
4170 | test eax, eax |
4108 | jz frpal2 |
4171 | jz frpal2 |
4109 | mov ebx, [TASK_BASE] |
4172 | mov ebx, [TASK_BASE] |
4110 | mov ebx, [ebx+TASKDATA.pid] |
4173 | mov ebx, [ebx+TASKDATA.pid] |
4111 | frpal3: |
4174 | frpal3: |
4112 | mov edi, eax |
4175 | mov edi, eax |
4113 | shl edi, 4 |
4176 | shl edi, 4 |
4114 | add edi, RESERVED_PORTS |
4177 | add edi, RESERVED_PORTS |
4115 | cmp ebx, [edi] |
4178 | cmp ebx, [edi] |
4116 | jne frpal4 |
4179 | jne frpal4 |
4117 | cmp ecx, [edi+4] |
4180 | cmp ecx, [edi+4] |
4118 | jne frpal4 |
4181 | jne frpal4 |
4119 | cmp edx, [edi+8] |
4182 | cmp edx, [edi+8] |
4120 | jne frpal4 |
4183 | jne frpal4 |
4121 | jmp frpal1 |
4184 | jmp frpal1 |
4122 | frpal4: |
4185 | frpal4: |
4123 | dec eax |
4186 | dec eax |
4124 | jnz frpal3 |
4187 | jnz frpal3 |
4125 | frpal2: |
4188 | frpal2: |
4126 | ; popad |
4189 | ; popad |
4127 | inc eax |
4190 | inc eax |
4128 | ret |
4191 | ret |
4129 | frpal1: |
4192 | frpal1: |
4130 | push ecx |
4193 | push ecx |
4131 | mov ecx, 256 |
4194 | mov ecx, 256 |
4132 | sub ecx, eax |
4195 | sub ecx, eax |
4133 | shl ecx, 4 |
4196 | shl ecx, 4 |
4134 | mov esi, edi |
4197 | mov esi, edi |
4135 | add esi, 16 |
4198 | add esi, 16 |
4136 | cld |
4199 | cld |
4137 | rep movsb |
4200 | rep movsb |
4138 | 4201 | ||
4139 | dec dword [RESERVED_PORTS] |
4202 | dec dword [RESERVED_PORTS] |
4140 | ;popad |
4203 | ;popad |
4141 | ;disable port access at port IO map |
4204 | ;disable port access at port IO map |
4142 | 4205 | ||
4143 | ; pushad ; start disable io map |
4206 | ; pushad ; start disable io map |
4144 | pop eax ;start port |
4207 | pop eax ;start port |
4145 | cmp edx, 65536;16384 |
4208 | cmp edx, 65536;16384 |
4146 | jge no_mask_io |
4209 | jge no_mask_io |
4147 | 4210 | ||
4148 | ; mov eax,ecx |
4211 | ; mov eax,ecx |
4149 | xor ebp, ebp |
4212 | xor ebp, ebp |
4150 | inc ebp |
4213 | inc ebp |
4151 | new_port_access_disable: |
4214 | new_port_access_disable: |
4152 | ; pushad |
4215 | ; pushad |
4153 | ; mov ebp,1 ; disable - eax = port |
4216 | ; mov ebp,1 ; disable - eax = port |
4154 | call set_io_access_rights |
4217 | call set_io_access_rights |
4155 | ; popad |
4218 | ; popad |
4156 | inc eax |
4219 | inc eax |
4157 | cmp eax, edx |
4220 | cmp eax, edx |
4158 | jbe new_port_access_disable |
4221 | jbe new_port_access_disable |
4159 | no_mask_io: |
4222 | no_mask_io: |
4160 | ; popad ; end disable io map |
4223 | ; popad ; end disable io map |
4161 | xor eax, eax |
4224 | xor eax, eax |
4162 | ret |
4225 | ret |
4163 | ;----------------------------------------------------------------------------- |
4226 | ;----------------------------------------------------------------------------- |
4164 | align 4 |
4227 | align 4 |
4165 | drawbackground: |
4228 | drawbackground: |
4166 | dbrv20: |
4229 | dbrv20: |
4167 | cmp [BgrDrawMode], dword 1 |
4230 | cmp [BgrDrawMode], dword 1 |
4168 | jne bgrstr |
4231 | jne bgrstr |
4169 | call vesa20_drawbackground_tiled |
4232 | call vesa20_drawbackground_tiled |
4170 | ; call [draw_pointer] |
4233 | ; call [draw_pointer] |
4171 | call __sys_draw_pointer |
4234 | call __sys_draw_pointer |
4172 | ret |
4235 | ret |
4173 | ;-------------------------------------- |
4236 | ;-------------------------------------- |
4174 | align 4 |
4237 | align 4 |
4175 | bgrstr: |
4238 | bgrstr: |
4176 | call vesa20_drawbackground_stretch |
4239 | call vesa20_drawbackground_stretch |
4177 | ; call [draw_pointer] |
4240 | ; call [draw_pointer] |
4178 | call __sys_draw_pointer |
4241 | call __sys_draw_pointer |
4179 | ret |
4242 | ret |
4180 | ;----------------------------------------------------------------------------- |
4243 | ;----------------------------------------------------------------------------- |
4181 | align 4 |
4244 | align 4 |
4182 | syscall_putimage: ; PutImage |
4245 | syscall_putimage: ; PutImage |
4183 | sys_putimage: |
4246 | sys_putimage: |
4184 | test ecx, 0x80008000 |
4247 | test ecx, 0x80008000 |
4185 | jnz .exit |
4248 | jnz .exit |
4186 | test ecx, 0x0000FFFF |
4249 | test ecx, 0x0000FFFF |
4187 | jz .exit |
4250 | jz .exit |
4188 | test ecx, 0xFFFF0000 |
4251 | test ecx, 0xFFFF0000 |
4189 | jnz @f |
4252 | jnz @f |
4190 | ;-------------------------------------- |
4253 | ;-------------------------------------- |
4191 | align 4 |
4254 | align 4 |
4192 | .exit: |
4255 | .exit: |
4193 | ret |
4256 | ret |
4194 | ;-------------------------------------- |
4257 | ;-------------------------------------- |
4195 | align 4 |
4258 | align 4 |
4196 | @@: |
4259 | @@: |
4197 | mov edi, [current_slot] |
4260 | mov edi, [current_slot] |
4198 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4261 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4199 | rol edx, 16 |
4262 | rol edx, 16 |
4200 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4263 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4201 | rol edx, 16 |
4264 | rol edx, 16 |
4202 | ;-------------------------------------- |
4265 | ;-------------------------------------- |
4203 | align 4 |
4266 | align 4 |
4204 | .forced: |
4267 | .forced: |
4205 | push ebp esi 0 |
4268 | push ebp esi 0 |
4206 | mov ebp, putimage_get24bpp |
4269 | mov ebp, putimage_get24bpp |
4207 | mov esi, putimage_init24bpp |
4270 | mov esi, putimage_init24bpp |
4208 | ;-------------------------------------- |
4271 | ;-------------------------------------- |
4209 | align 4 |
4272 | align 4 |
4210 | sys_putimage_bpp: |
4273 | sys_putimage_bpp: |
4211 | call vesa20_putimage |
4274 | call vesa20_putimage |
4212 | pop ebp esi ebp |
4275 | pop ebp esi ebp |
4213 | ret |
4276 | ret |
4214 | ; jmp [draw_pointer] |
4277 | ; jmp [draw_pointer] |
4215 | ;----------------------------------------------------------------------------- |
4278 | ;----------------------------------------------------------------------------- |
4216 | align 4 |
4279 | align 4 |
4217 | sys_putimage_palette: |
4280 | sys_putimage_palette: |
4218 | ; ebx = pointer to image |
4281 | ; ebx = pointer to image |
4219 | ; ecx = [xsize]*65536 + [ysize] |
4282 | ; ecx = [xsize]*65536 + [ysize] |
4220 | ; edx = [xstart]*65536 + [ystart] |
4283 | ; edx = [xstart]*65536 + [ystart] |
4221 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4284 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4222 | ; edi = pointer to palette |
4285 | ; edi = pointer to palette |
4223 | ; ebp = row delta |
4286 | ; ebp = row delta |
4224 | mov eax, [CURRENT_TASK] |
4287 | mov eax, [CURRENT_TASK] |
4225 | shl eax, 8 |
4288 | shl eax, 8 |
4226 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4289 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4227 | rol edx, 16 |
4290 | rol edx, 16 |
4228 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4291 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4229 | rol edx, 16 |
4292 | rol edx, 16 |
4230 | ;-------------------------------------- |
4293 | ;-------------------------------------- |
4231 | align 4 |
4294 | align 4 |
4232 | .forced: |
4295 | .forced: |
4233 | cmp esi, 1 |
4296 | cmp esi, 1 |
4234 | jnz @f |
4297 | jnz @f |
4235 | push edi |
4298 | push edi |
4236 | mov eax, [edi+4] |
4299 | mov eax, [edi+4] |
4237 | sub eax, [edi] |
4300 | sub eax, [edi] |
4238 | push eax |
4301 | push eax |
4239 | push dword [edi] |
4302 | push dword [edi] |
4240 | push 0ffffff80h |
4303 | push 0ffffff80h |
4241 | mov edi, esp |
4304 | mov edi, esp |
4242 | call put_mono_image |
4305 | call put_mono_image |
4243 | add esp, 12 |
4306 | add esp, 12 |
4244 | pop edi |
4307 | pop edi |
4245 | ret |
4308 | ret |
4246 | ;-------------------------------------- |
4309 | ;-------------------------------------- |
4247 | align 4 |
4310 | align 4 |
4248 | @@: |
4311 | @@: |
4249 | cmp esi, 2 |
4312 | cmp esi, 2 |
4250 | jnz @f |
4313 | jnz @f |
4251 | push edi |
4314 | push edi |
4252 | push 0ffffff80h |
4315 | push 0ffffff80h |
4253 | mov edi, esp |
4316 | mov edi, esp |
4254 | call put_2bit_image |
4317 | call put_2bit_image |
4255 | pop eax |
4318 | pop eax |
4256 | pop edi |
4319 | pop edi |
4257 | ret |
4320 | ret |
4258 | ;-------------------------------------- |
4321 | ;-------------------------------------- |
4259 | align 4 |
4322 | align 4 |
4260 | @@: |
4323 | @@: |
4261 | cmp esi, 4 |
4324 | cmp esi, 4 |
4262 | jnz @f |
4325 | jnz @f |
4263 | push edi |
4326 | push edi |
4264 | push 0ffffff80h |
4327 | push 0ffffff80h |
4265 | mov edi, esp |
4328 | mov edi, esp |
4266 | call put_4bit_image |
4329 | call put_4bit_image |
4267 | pop eax |
4330 | pop eax |
4268 | pop edi |
4331 | pop edi |
4269 | ret |
4332 | ret |
4270 | ;-------------------------------------- |
4333 | ;-------------------------------------- |
4271 | align 4 |
4334 | align 4 |
4272 | @@: |
4335 | @@: |
4273 | push ebp esi ebp |
4336 | push ebp esi ebp |
4274 | cmp esi, 8 |
4337 | cmp esi, 8 |
4275 | jnz @f |
4338 | jnz @f |
4276 | mov ebp, putimage_get8bpp |
4339 | mov ebp, putimage_get8bpp |
4277 | mov esi, putimage_init8bpp |
4340 | mov esi, putimage_init8bpp |
4278 | jmp sys_putimage_bpp |
4341 | jmp sys_putimage_bpp |
4279 | ;-------------------------------------- |
4342 | ;-------------------------------------- |
4280 | align 4 |
4343 | align 4 |
4281 | @@: |
4344 | @@: |
4282 | cmp esi, 9 |
4345 | cmp esi, 9 |
4283 | jnz @f |
4346 | jnz @f |
4284 | mov ebp, putimage_get9bpp |
4347 | mov ebp, putimage_get9bpp |
4285 | mov esi, putimage_init9bpp |
4348 | mov esi, putimage_init9bpp |
4286 | jmp sys_putimage_bpp |
4349 | jmp sys_putimage_bpp |
4287 | ;-------------------------------------- |
4350 | ;-------------------------------------- |
4288 | align 4 |
4351 | align 4 |
4289 | @@: |
4352 | @@: |
4290 | cmp esi, 15 |
4353 | cmp esi, 15 |
4291 | jnz @f |
4354 | jnz @f |
4292 | mov ebp, putimage_get15bpp |
4355 | mov ebp, putimage_get15bpp |
4293 | mov esi, putimage_init15bpp |
4356 | mov esi, putimage_init15bpp |
4294 | jmp sys_putimage_bpp |
4357 | jmp sys_putimage_bpp |
4295 | ;-------------------------------------- |
4358 | ;-------------------------------------- |
4296 | align 4 |
4359 | align 4 |
4297 | @@: |
4360 | @@: |
4298 | cmp esi, 16 |
4361 | cmp esi, 16 |
4299 | jnz @f |
4362 | jnz @f |
4300 | mov ebp, putimage_get16bpp |
4363 | mov ebp, putimage_get16bpp |
4301 | mov esi, putimage_init16bpp |
4364 | mov esi, putimage_init16bpp |
4302 | jmp sys_putimage_bpp |
4365 | jmp sys_putimage_bpp |
4303 | ;-------------------------------------- |
4366 | ;-------------------------------------- |
4304 | align 4 |
4367 | align 4 |
4305 | @@: |
4368 | @@: |
4306 | cmp esi, 24 |
4369 | cmp esi, 24 |
4307 | jnz @f |
4370 | jnz @f |
4308 | mov ebp, putimage_get24bpp |
4371 | mov ebp, putimage_get24bpp |
4309 | mov esi, putimage_init24bpp |
4372 | mov esi, putimage_init24bpp |
4310 | jmp sys_putimage_bpp |
4373 | jmp sys_putimage_bpp |
4311 | ;-------------------------------------- |
4374 | ;-------------------------------------- |
4312 | align 4 |
4375 | align 4 |
4313 | @@: |
4376 | @@: |
4314 | cmp esi, 32 |
4377 | cmp esi, 32 |
4315 | jnz @f |
4378 | jnz @f |
4316 | mov ebp, putimage_get32bpp |
4379 | mov ebp, putimage_get32bpp |
4317 | mov esi, putimage_init32bpp |
4380 | mov esi, putimage_init32bpp |
4318 | jmp sys_putimage_bpp |
4381 | jmp sys_putimage_bpp |
4319 | ;-------------------------------------- |
4382 | ;-------------------------------------- |
4320 | align 4 |
4383 | align 4 |
4321 | @@: |
4384 | @@: |
4322 | pop ebp esi ebp |
4385 | pop ebp esi ebp |
4323 | ret |
4386 | ret |
4324 | ;----------------------------------------------------------------------------- |
4387 | ;----------------------------------------------------------------------------- |
4325 | align 4 |
4388 | align 4 |
4326 | put_mono_image: |
4389 | put_mono_image: |
4327 | push ebp esi ebp |
4390 | push ebp esi ebp |
4328 | mov ebp, putimage_get1bpp |
4391 | mov ebp, putimage_get1bpp |
4329 | mov esi, putimage_init1bpp |
4392 | mov esi, putimage_init1bpp |
4330 | jmp sys_putimage_bpp |
4393 | jmp sys_putimage_bpp |
4331 | ;----------------------------------------------------------------------------- |
4394 | ;----------------------------------------------------------------------------- |
4332 | align 4 |
4395 | align 4 |
4333 | put_2bit_image: |
4396 | put_2bit_image: |
4334 | push ebp esi ebp |
4397 | push ebp esi ebp |
4335 | mov ebp, putimage_get2bpp |
4398 | mov ebp, putimage_get2bpp |
4336 | mov esi, putimage_init2bpp |
4399 | mov esi, putimage_init2bpp |
4337 | jmp sys_putimage_bpp |
4400 | jmp sys_putimage_bpp |
4338 | ;----------------------------------------------------------------------------- |
4401 | ;----------------------------------------------------------------------------- |
4339 | align 4 |
4402 | align 4 |
4340 | put_4bit_image: |
4403 | put_4bit_image: |
4341 | push ebp esi ebp |
4404 | push ebp esi ebp |
4342 | mov ebp, putimage_get4bpp |
4405 | mov ebp, putimage_get4bpp |
4343 | mov esi, putimage_init4bpp |
4406 | mov esi, putimage_init4bpp |
4344 | jmp sys_putimage_bpp |
4407 | jmp sys_putimage_bpp |
4345 | ;----------------------------------------------------------------------------- |
4408 | ;----------------------------------------------------------------------------- |
4346 | align 4 |
4409 | align 4 |
4347 | putimage_init24bpp: |
4410 | putimage_init24bpp: |
4348 | lea eax, [eax*3] |
4411 | lea eax, [eax*3] |
4349 | putimage_init8bpp: |
4412 | putimage_init8bpp: |
4350 | putimage_init9bpp: |
4413 | putimage_init9bpp: |
4351 | ret |
4414 | ret |
4352 | ;----------------------------------------------------------------------------- |
4415 | ;----------------------------------------------------------------------------- |
4353 | align 16 |
4416 | align 16 |
4354 | putimage_get24bpp: |
4417 | putimage_get24bpp: |
4355 | movzx eax, byte [esi+2] |
4418 | movzx eax, byte [esi+2] |
4356 | shl eax, 16 |
4419 | shl eax, 16 |
4357 | mov ax, [esi] |
4420 | mov ax, [esi] |
4358 | add esi, 3 |
4421 | add esi, 3 |
4359 | ret 4 |
4422 | ret 4 |
4360 | ;----------------------------------------------------------------------------- |
4423 | ;----------------------------------------------------------------------------- |
4361 | align 16 |
4424 | align 16 |
4362 | putimage_get8bpp: |
4425 | putimage_get8bpp: |
4363 | movzx eax, byte [esi] |
4426 | movzx eax, byte [esi] |
4364 | push edx |
4427 | push edx |
4365 | mov edx, [esp+8] |
4428 | mov edx, [esp+8] |
4366 | mov eax, [edx+eax*4] |
4429 | mov eax, [edx+eax*4] |
4367 | pop edx |
4430 | pop edx |
4368 | inc esi |
4431 | inc esi |
4369 | ret 4 |
4432 | ret 4 |
4370 | ;----------------------------------------------------------------------------- |
4433 | ;----------------------------------------------------------------------------- |
4371 | align 16 |
4434 | align 16 |
4372 | putimage_get9bpp: |
4435 | putimage_get9bpp: |
4373 | lodsb |
4436 | lodsb |
4374 | mov ah, al |
4437 | mov ah, al |
4375 | shl eax, 8 |
4438 | shl eax, 8 |
4376 | mov al, ah |
4439 | mov al, ah |
4377 | ret 4 |
4440 | ret 4 |
4378 | ;----------------------------------------------------------------------------- |
4441 | ;----------------------------------------------------------------------------- |
4379 | align 4 |
4442 | align 4 |
4380 | putimage_init1bpp: |
4443 | putimage_init1bpp: |
4381 | add eax, ecx |
4444 | add eax, ecx |
4382 | push ecx |
4445 | push ecx |
4383 | add eax, 7 |
4446 | add eax, 7 |
4384 | add ecx, 7 |
4447 | add ecx, 7 |
4385 | shr eax, 3 |
4448 | shr eax, 3 |
4386 | shr ecx, 3 |
4449 | shr ecx, 3 |
4387 | sub eax, ecx |
4450 | sub eax, ecx |
4388 | pop ecx |
4451 | pop ecx |
4389 | ret |
4452 | ret |
4390 | ;----------------------------------------------------------------------------- |
4453 | ;----------------------------------------------------------------------------- |
4391 | align 16 |
4454 | align 16 |
4392 | putimage_get1bpp: |
4455 | putimage_get1bpp: |
4393 | push edx |
4456 | push edx |
4394 | mov edx, [esp+8] |
4457 | mov edx, [esp+8] |
4395 | mov al, [edx] |
4458 | mov al, [edx] |
4396 | add al, al |
4459 | add al, al |
4397 | jnz @f |
4460 | jnz @f |
4398 | lodsb |
4461 | lodsb |
4399 | adc al, al |
4462 | adc al, al |
4400 | @@: |
4463 | @@: |
4401 | mov [edx], al |
4464 | mov [edx], al |
4402 | sbb eax, eax |
4465 | sbb eax, eax |
4403 | and eax, [edx+8] |
4466 | and eax, [edx+8] |
4404 | add eax, [edx+4] |
4467 | add eax, [edx+4] |
4405 | pop edx |
4468 | pop edx |
4406 | ret 4 |
4469 | ret 4 |
4407 | ;----------------------------------------------------------------------------- |
4470 | ;----------------------------------------------------------------------------- |
4408 | align 4 |
4471 | align 4 |
4409 | putimage_init2bpp: |
4472 | putimage_init2bpp: |
4410 | add eax, ecx |
4473 | add eax, ecx |
4411 | push ecx |
4474 | push ecx |
4412 | add ecx, 3 |
4475 | add ecx, 3 |
4413 | add eax, 3 |
4476 | add eax, 3 |
4414 | shr ecx, 2 |
4477 | shr ecx, 2 |
4415 | shr eax, 2 |
4478 | shr eax, 2 |
4416 | sub eax, ecx |
4479 | sub eax, ecx |
4417 | pop ecx |
4480 | pop ecx |
4418 | ret |
4481 | ret |
4419 | ;----------------------------------------------------------------------------- |
4482 | ;----------------------------------------------------------------------------- |
4420 | align 16 |
4483 | align 16 |
4421 | putimage_get2bpp: |
4484 | putimage_get2bpp: |
4422 | push edx |
4485 | push edx |
4423 | mov edx, [esp+8] |
4486 | mov edx, [esp+8] |
4424 | mov al, [edx] |
4487 | mov al, [edx] |
4425 | mov ah, al |
4488 | mov ah, al |
4426 | shr al, 6 |
4489 | shr al, 6 |
4427 | shl ah, 2 |
4490 | shl ah, 2 |
4428 | jnz .nonewbyte |
4491 | jnz .nonewbyte |
4429 | lodsb |
4492 | lodsb |
4430 | mov ah, al |
4493 | mov ah, al |
4431 | shr al, 6 |
4494 | shr al, 6 |
4432 | shl ah, 2 |
4495 | shl ah, 2 |
4433 | add ah, 1 |
4496 | add ah, 1 |
4434 | .nonewbyte: |
4497 | .nonewbyte: |
4435 | mov [edx], ah |
4498 | mov [edx], ah |
4436 | mov edx, [edx+4] |
4499 | mov edx, [edx+4] |
4437 | movzx eax, al |
4500 | movzx eax, al |
4438 | mov eax, [edx+eax*4] |
4501 | mov eax, [edx+eax*4] |
4439 | pop edx |
4502 | pop edx |
4440 | ret 4 |
4503 | ret 4 |
4441 | ;----------------------------------------------------------------------------- |
4504 | ;----------------------------------------------------------------------------- |
4442 | align 4 |
4505 | align 4 |
4443 | putimage_init4bpp: |
4506 | putimage_init4bpp: |
4444 | add eax, ecx |
4507 | add eax, ecx |
4445 | push ecx |
4508 | push ecx |
4446 | add ecx, 1 |
4509 | add ecx, 1 |
4447 | add eax, 1 |
4510 | add eax, 1 |
4448 | shr ecx, 1 |
4511 | shr ecx, 1 |
4449 | shr eax, 1 |
4512 | shr eax, 1 |
4450 | sub eax, ecx |
4513 | sub eax, ecx |
4451 | pop ecx |
4514 | pop ecx |
4452 | ret |
4515 | ret |
4453 | ;----------------------------------------------------------------------------- |
4516 | ;----------------------------------------------------------------------------- |
4454 | align 16 |
4517 | align 16 |
4455 | putimage_get4bpp: |
4518 | putimage_get4bpp: |
4456 | push edx |
4519 | push edx |
4457 | mov edx, [esp+8] |
4520 | mov edx, [esp+8] |
4458 | add byte [edx], 80h |
4521 | add byte [edx], 80h |
4459 | jc @f |
4522 | jc @f |
4460 | movzx eax, byte [edx+1] |
4523 | movzx eax, byte [edx+1] |
4461 | mov edx, [edx+4] |
4524 | mov edx, [edx+4] |
4462 | and eax, 0x0F |
4525 | and eax, 0x0F |
4463 | mov eax, [edx+eax*4] |
4526 | mov eax, [edx+eax*4] |
4464 | pop edx |
4527 | pop edx |
4465 | ret 4 |
4528 | ret 4 |
4466 | @@: |
4529 | @@: |
4467 | movzx eax, byte [esi] |
4530 | movzx eax, byte [esi] |
4468 | add esi, 1 |
4531 | add esi, 1 |
4469 | mov [edx+1], al |
4532 | mov [edx+1], al |
4470 | shr eax, 4 |
4533 | shr eax, 4 |
4471 | mov edx, [edx+4] |
4534 | mov edx, [edx+4] |
4472 | mov eax, [edx+eax*4] |
4535 | mov eax, [edx+eax*4] |
4473 | pop edx |
4536 | pop edx |
4474 | ret 4 |
4537 | ret 4 |
4475 | ;----------------------------------------------------------------------------- |
4538 | ;----------------------------------------------------------------------------- |
4476 | align 4 |
4539 | align 4 |
4477 | putimage_init32bpp: |
4540 | putimage_init32bpp: |
4478 | shl eax, 2 |
4541 | shl eax, 2 |
4479 | ret |
4542 | ret |
4480 | ;----------------------------------------------------------------------------- |
4543 | ;----------------------------------------------------------------------------- |
4481 | align 16 |
4544 | align 16 |
4482 | putimage_get32bpp: |
4545 | putimage_get32bpp: |
4483 | lodsd |
4546 | lodsd |
4484 | ret 4 |
4547 | ret 4 |
4485 | ;----------------------------------------------------------------------------- |
4548 | ;----------------------------------------------------------------------------- |
4486 | align 4 |
4549 | align 4 |
4487 | putimage_init15bpp: |
4550 | putimage_init15bpp: |
4488 | putimage_init16bpp: |
4551 | putimage_init16bpp: |
4489 | add eax, eax |
4552 | add eax, eax |
4490 | ret |
4553 | ret |
4491 | ;----------------------------------------------------------------------------- |
4554 | ;----------------------------------------------------------------------------- |
4492 | align 16 |
4555 | align 16 |
4493 | putimage_get15bpp: |
4556 | putimage_get15bpp: |
4494 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4557 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4495 | push ecx edx |
4558 | push ecx edx |
4496 | movzx eax, word [esi] |
4559 | movzx eax, word [esi] |
4497 | add esi, 2 |
4560 | add esi, 2 |
4498 | mov ecx, eax |
4561 | mov ecx, eax |
4499 | mov edx, eax |
4562 | mov edx, eax |
4500 | and eax, 0x1F |
4563 | and eax, 0x1F |
4501 | and ecx, 0x1F shl 5 |
4564 | and ecx, 0x1F shl 5 |
4502 | and edx, 0x1F shl 10 |
4565 | and edx, 0x1F shl 10 |
4503 | shl eax, 3 |
4566 | shl eax, 3 |
4504 | shl ecx, 6 |
4567 | shl ecx, 6 |
4505 | shl edx, 9 |
4568 | shl edx, 9 |
4506 | or eax, ecx |
4569 | or eax, ecx |
4507 | or eax, edx |
4570 | or eax, edx |
4508 | pop edx ecx |
4571 | pop edx ecx |
4509 | ret 4 |
4572 | ret 4 |
4510 | ;----------------------------------------------------------------------------- |
4573 | ;----------------------------------------------------------------------------- |
4511 | align 16 |
4574 | align 16 |
4512 | putimage_get16bpp: |
4575 | putimage_get16bpp: |
4513 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4576 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4514 | push ecx edx |
4577 | push ecx edx |
4515 | movzx eax, word [esi] |
4578 | movzx eax, word [esi] |
4516 | add esi, 2 |
4579 | add esi, 2 |
4517 | mov ecx, eax |
4580 | mov ecx, eax |
4518 | mov edx, eax |
4581 | mov edx, eax |
4519 | and eax, 0x1F |
4582 | and eax, 0x1F |
4520 | and ecx, 0x3F shl 5 |
4583 | and ecx, 0x3F shl 5 |
4521 | and edx, 0x1F shl 11 |
4584 | and edx, 0x1F shl 11 |
4522 | shl eax, 3 |
4585 | shl eax, 3 |
4523 | shl ecx, 5 |
4586 | shl ecx, 5 |
4524 | shl edx, 8 |
4587 | shl edx, 8 |
4525 | or eax, ecx |
4588 | or eax, ecx |
4526 | or eax, edx |
4589 | or eax, edx |
4527 | pop edx ecx |
4590 | pop edx ecx |
4528 | ret 4 |
4591 | ret 4 |
4529 | ;----------------------------------------------------------------------------- |
4592 | ;----------------------------------------------------------------------------- |
4530 | ;align 4 |
4593 | ;align 4 |
4531 | ; eax x beginning |
4594 | ; eax x beginning |
4532 | ; ebx y beginning |
4595 | ; ebx y beginning |
4533 | ; ecx x end |
4596 | ; ecx x end |
4534 | ; edx y end |
4597 | ; edx y end |
4535 | ; edi color |
4598 | ; edi color |
4536 | ;__sys_drawbar: |
4599 | ;__sys_drawbar: |
4537 | ; mov esi, [current_slot] |
4600 | ; mov esi, [current_slot] |
4538 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4601 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4539 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4602 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4540 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4603 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4541 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4604 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4542 | ;-------------------------------------- |
4605 | ;-------------------------------------- |
4543 | ;align 4 |
4606 | ;align 4 |
4544 | ;.forced: |
4607 | ;.forced: |
4545 | ; call vesa20_drawbar |
4608 | ; call vesa20_drawbar |
4546 | ; call [draw_pointer] |
4609 | ; call [draw_pointer] |
4547 | ; ret |
4610 | ; ret |
4548 | ;----------------------------------------------------------------------------- |
4611 | ;----------------------------------------------------------------------------- |
4549 | align 4 |
4612 | align 4 |
4550 | kb_read: |
4613 | kb_read: |
4551 | 4614 | ||
4552 | push ecx edx |
4615 | push ecx edx |
4553 | 4616 | ||
4554 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4617 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4555 | kr_loop: |
4618 | kr_loop: |
4556 | in al, 0x64 |
4619 | in al, 0x64 |
4557 | test al, 1 |
4620 | test al, 1 |
4558 | jnz kr_ready |
4621 | jnz kr_ready |
4559 | loop kr_loop |
4622 | loop kr_loop |
4560 | mov ah, 1 |
4623 | mov ah, 1 |
4561 | jmp kr_exit |
4624 | jmp kr_exit |
4562 | kr_ready: |
4625 | kr_ready: |
4563 | push ecx |
4626 | push ecx |
4564 | mov ecx, 32 |
4627 | mov ecx, 32 |
4565 | kr_delay: |
4628 | kr_delay: |
4566 | loop kr_delay |
4629 | loop kr_delay |
4567 | pop ecx |
4630 | pop ecx |
4568 | in al, 0x60 |
4631 | in al, 0x60 |
4569 | xor ah, ah |
4632 | xor ah, ah |
4570 | kr_exit: |
4633 | kr_exit: |
4571 | 4634 | ||
4572 | pop edx ecx |
4635 | pop edx ecx |
4573 | 4636 | ||
4574 | ret |
4637 | ret |
4575 | ;----------------------------------------------------------------------------- |
4638 | ;----------------------------------------------------------------------------- |
4576 | align 4 |
4639 | align 4 |
4577 | kb_write: |
4640 | kb_write: |
4578 | 4641 | ||
4579 | push ecx edx |
4642 | push ecx edx |
4580 | 4643 | ||
4581 | mov dl, al |
4644 | mov dl, al |
4582 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4645 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4583 | ; kw_loop1: |
4646 | ; kw_loop1: |
4584 | ; in al,0x64 |
4647 | ; in al,0x64 |
4585 | ; test al,0x20 |
4648 | ; test al,0x20 |
4586 | ; jz kw_ok1 |
4649 | ; jz kw_ok1 |
4587 | ; loop kw_loop1 |
4650 | ; loop kw_loop1 |
4588 | ; mov ah,1 |
4651 | ; mov ah,1 |
4589 | ; jmp kw_exit |
4652 | ; jmp kw_exit |
4590 | ; kw_ok1: |
4653 | ; kw_ok1: |
4591 | in al, 0x60 |
4654 | in al, 0x60 |
4592 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4655 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4593 | kw_loop: |
4656 | kw_loop: |
4594 | in al, 0x64 |
4657 | in al, 0x64 |
4595 | test al, 2 |
4658 | test al, 2 |
4596 | jz kw_ok |
4659 | jz kw_ok |
4597 | loop kw_loop |
4660 | loop kw_loop |
4598 | mov ah, 1 |
4661 | mov ah, 1 |
4599 | jmp kw_exit |
4662 | jmp kw_exit |
4600 | kw_ok: |
4663 | kw_ok: |
4601 | mov al, dl |
4664 | mov al, dl |
4602 | out 0x60, al |
4665 | out 0x60, al |
4603 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4666 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4604 | kw_loop3: |
4667 | kw_loop3: |
4605 | in al, 0x64 |
4668 | in al, 0x64 |
4606 | test al, 2 |
4669 | test al, 2 |
4607 | jz kw_ok3 |
4670 | jz kw_ok3 |
4608 | loop kw_loop3 |
4671 | loop kw_loop3 |
4609 | mov ah, 1 |
4672 | mov ah, 1 |
4610 | jmp kw_exit |
4673 | jmp kw_exit |
4611 | kw_ok3: |
4674 | kw_ok3: |
4612 | mov ah, 8 |
4675 | mov ah, 8 |
4613 | kw_loop4: |
4676 | kw_loop4: |
4614 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4677 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4615 | kw_loop5: |
4678 | kw_loop5: |
4616 | in al, 0x64 |
4679 | in al, 0x64 |
4617 | test al, 1 |
4680 | test al, 1 |
4618 | jnz kw_ok4 |
4681 | jnz kw_ok4 |
4619 | loop kw_loop5 |
4682 | loop kw_loop5 |
4620 | dec ah |
4683 | dec ah |
4621 | jnz kw_loop4 |
4684 | jnz kw_loop4 |
4622 | kw_ok4: |
4685 | kw_ok4: |
4623 | xor ah, ah |
4686 | xor ah, ah |
4624 | kw_exit: |
4687 | kw_exit: |
4625 | 4688 | ||
4626 | pop edx ecx |
4689 | pop edx ecx |
4627 | 4690 | ||
4628 | ret |
4691 | ret |
4629 | ;----------------------------------------------------------------------------- |
4692 | ;----------------------------------------------------------------------------- |
4630 | align 4 |
4693 | align 4 |
4631 | kb_cmd: |
4694 | kb_cmd: |
4632 | 4695 | ||
4633 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4696 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4634 | c_wait: |
4697 | c_wait: |
4635 | in al, 0x64 |
4698 | in al, 0x64 |
4636 | test al, 2 |
4699 | test al, 2 |
4637 | jz c_send |
4700 | jz c_send |
4638 | loop c_wait |
4701 | loop c_wait |
4639 | jmp c_error |
4702 | jmp c_error |
4640 | c_send: |
4703 | c_send: |
4641 | mov al, bl |
4704 | mov al, bl |
4642 | out 0x64, al |
4705 | out 0x64, al |
4643 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4706 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4644 | c_accept: |
4707 | c_accept: |
4645 | in al, 0x64 |
4708 | in al, 0x64 |
4646 | test al, 2 |
4709 | test al, 2 |
4647 | jz c_ok |
4710 | jz c_ok |
4648 | loop c_accept |
4711 | loop c_accept |
4649 | c_error: |
4712 | c_error: |
4650 | mov ah, 1 |
4713 | mov ah, 1 |
4651 | jmp c_exit |
4714 | jmp c_exit |
4652 | c_ok: |
4715 | c_ok: |
4653 | xor ah, ah |
4716 | xor ah, ah |
4654 | c_exit: |
4717 | c_exit: |
4655 | ret |
4718 | ret |
4656 | 4719 | ||
4657 | 4720 | ||
4658 | setmouse: ; set mousepicture -pointer |
4721 | setmouse: ; set mousepicture -pointer |
4659 | ; ps2 mouse enable |
4722 | ; ps2 mouse enable |
4660 | 4723 | ||
4661 | ; mov [MOUSE_PICTURE], dword mousepointer |
4724 | ; mov [MOUSE_PICTURE], dword mousepointer |
4662 | 4725 | ||
4663 | cli |
4726 | cli |
4664 | 4727 | ||
4665 | ret |
4728 | ret |
4666 | 4729 | ||
4667 | if used _rdtsc |
4730 | if used _rdtsc |
4668 | _rdtsc: |
4731 | _rdtsc: |
4669 | bt [cpu_caps], CAPS_TSC |
4732 | bt [cpu_caps], CAPS_TSC |
4670 | jnc ret_rdtsc |
4733 | jnc ret_rdtsc |
4671 | rdtsc |
4734 | rdtsc |
4672 | ret |
4735 | ret |
4673 | ret_rdtsc: |
4736 | ret_rdtsc: |
4674 | mov edx, 0xffffffff |
4737 | mov edx, 0xffffffff |
4675 | mov eax, 0xffffffff |
4738 | mov eax, 0xffffffff |
4676 | ret |
4739 | ret |
4677 | end if |
4740 | end if |
4678 | 4741 | ||
4679 | sys_msg_board_str: |
4742 | sys_msg_board_str: |
4680 | 4743 | ||
4681 | pushad |
4744 | pushad |
4682 | @@: |
4745 | @@: |
4683 | cmp [esi], byte 0 |
4746 | cmp [esi], byte 0 |
4684 | je @f |
4747 | je @f |
4685 | mov ebx, 1 |
4748 | mov ebx, 1 |
4686 | movzx ecx, byte [esi] |
4749 | movzx ecx, byte [esi] |
4687 | call sys_msg_board |
4750 | call sys_msg_board |
4688 | inc esi |
4751 | inc esi |
4689 | jmp @b |
4752 | jmp @b |
4690 | @@: |
4753 | @@: |
4691 | popad |
4754 | popad |
4692 | ret |
4755 | ret |
4693 | 4756 | ||
4694 | sys_msg_board_byte: |
4757 | sys_msg_board_byte: |
4695 | ; in: al = byte to display |
4758 | ; in: al = byte to display |
4696 | ; out: nothing |
4759 | ; out: nothing |
4697 | ; destroys: nothing |
4760 | ; destroys: nothing |
4698 | pushad |
4761 | pushad |
4699 | mov ecx, 2 |
4762 | mov ecx, 2 |
4700 | shl eax, 24 |
4763 | shl eax, 24 |
4701 | jmp @f |
4764 | jmp @f |
4702 | 4765 | ||
4703 | sys_msg_board_word: |
4766 | sys_msg_board_word: |
4704 | ; in: ax = word to display |
4767 | ; in: ax = word to display |
4705 | ; out: nothing |
4768 | ; out: nothing |
4706 | ; destroys: nothing |
4769 | ; destroys: nothing |
4707 | pushad |
4770 | pushad |
4708 | mov ecx, 4 |
4771 | mov ecx, 4 |
4709 | shl eax, 16 |
4772 | shl eax, 16 |
4710 | jmp @f |
4773 | jmp @f |
4711 | 4774 | ||
4712 | sys_msg_board_dword: |
4775 | sys_msg_board_dword: |
4713 | ; in: eax = dword to display |
4776 | ; in: eax = dword to display |
4714 | ; out: nothing |
4777 | ; out: nothing |
4715 | ; destroys: nothing |
4778 | ; destroys: nothing |
4716 | pushad |
4779 | pushad |
4717 | mov ecx, 8 |
4780 | mov ecx, 8 |
4718 | @@: |
4781 | @@: |
4719 | push ecx |
4782 | push ecx |
4720 | rol eax, 4 |
4783 | rol eax, 4 |
4721 | push eax |
4784 | push eax |
4722 | and al, 0xF |
4785 | and al, 0xF |
4723 | cmp al, 10 |
4786 | cmp al, 10 |
4724 | sbb al, 69h |
4787 | sbb al, 69h |
4725 | das |
4788 | das |
4726 | mov cl, al |
4789 | mov cl, al |
4727 | xor ebx, ebx |
4790 | xor ebx, ebx |
4728 | inc ebx |
4791 | inc ebx |
4729 | call sys_msg_board |
4792 | call sys_msg_board |
4730 | pop eax |
4793 | pop eax |
4731 | pop ecx |
4794 | pop ecx |
4732 | loop @b |
4795 | loop @b |
4733 | popad |
4796 | popad |
4734 | ret |
4797 | ret |
4735 | 4798 | ||
4736 | msg_board_data_size = 65536 ; Must be power of two |
4799 | msg_board_data_size = 65536 ; Must be power of two |
4737 | 4800 | ||
4738 | uglobal |
4801 | uglobal |
4739 | msg_board_data rb msg_board_data_size |
4802 | msg_board_data rb msg_board_data_size |
4740 | msg_board_count dd 0x0 |
4803 | msg_board_count dd 0x0 |
4741 | endg |
4804 | endg |
4742 | 4805 | ||
4743 | sys_msg_board: |
4806 | sys_msg_board: |
4744 | 4807 | ||
4745 | ; ebx=1 : write : bl byte to write |
4808 | ; ebx=1 : write : bl byte to write |
4746 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4809 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4747 | 4810 | ||
4748 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4811 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4749 | mov eax, ebx |
4812 | mov eax, ebx |
4750 | mov ebx, ecx |
4813 | mov ebx, ecx |
4751 | 4814 | ||
4752 | mov ecx, [msg_board_count] |
4815 | mov ecx, [msg_board_count] |
4753 | cmp eax, 1 |
4816 | cmp eax, 1 |
4754 | jne .smbl1 |
4817 | jne .smbl1 |
4755 | 4818 | ||
4756 | if defined debug_com_base |
4819 | if defined debug_com_base |
4757 | 4820 | ||
4758 | push dx ax |
4821 | push dx ax |
4759 | 4822 | ||
4760 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4823 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4761 | mov dx, debug_com_base+5 |
4824 | mov dx, debug_com_base+5 |
4762 | in al, dx |
4825 | in al, dx |
4763 | test al, 1 shl 5 |
4826 | test al, 1 shl 5 |
4764 | jz @r |
4827 | jz @r |
4765 | 4828 | ||
4766 | mov dx, debug_com_base ; Output the byte |
4829 | mov dx, debug_com_base ; Output the byte |
4767 | mov al, bl |
4830 | mov al, bl |
4768 | out dx, al |
4831 | out dx, al |
4769 | 4832 | ||
4770 | pop ax dx |
4833 | pop ax dx |
4771 | 4834 | ||
4772 | end if |
4835 | end if |
4773 | 4836 | ||
4774 | mov [msg_board_data+ecx], bl |
4837 | mov [msg_board_data+ecx], bl |
4775 | if debug_direct_print |
4838 | if debug_direct_print |
4776 | pusha |
4839 | pusha |
4777 | iglobal |
4840 | iglobal |
4778 | msg_board_pos dd 234*65536+10 |
4841 | msg_board_pos dd 234*65536+10 |
4779 | endg |
4842 | endg |
4780 | lea edx, [msg_board_data+ecx] |
4843 | lea edx, [msg_board_data+ecx] |
4781 | mov ecx, 0x40FFFFFF |
4844 | mov ecx, 0x40FFFFFF |
4782 | mov ebx, [msg_board_pos] |
4845 | mov ebx, [msg_board_pos] |
4783 | mov edi, 1 |
4846 | mov edi, 1 |
4784 | mov esi, 1 |
4847 | mov esi, 1 |
4785 | call dtext |
4848 | call dtext |
4786 | popa |
4849 | popa |
4787 | add word [msg_board_pos+2], 6 |
4850 | add word [msg_board_pos+2], 6 |
4788 | cmp bl, 10 |
4851 | cmp bl, 10 |
4789 | jnz @f |
4852 | jnz @f |
4790 | mov word [msg_board_pos+2], 234 |
4853 | mov word [msg_board_pos+2], 234 |
4791 | add word [msg_board_pos], 10 |
4854 | add word [msg_board_pos], 10 |
4792 | mov ax, word [Screen_Max_Y] |
4855 | mov ax, word [Screen_Max_Y] |
4793 | cmp word [msg_board_pos], ax |
4856 | cmp word [msg_board_pos], ax |
4794 | jbe @f |
4857 | jbe @f |
4795 | mov word [msg_board_pos], 10 |
4858 | mov word [msg_board_pos], 10 |
4796 | @@: |
4859 | @@: |
4797 | end if |
4860 | end if |
4798 | if 0 |
4861 | if 0 |
4799 | pusha |
4862 | pusha |
4800 | mov al, bl |
4863 | mov al, bl |
4801 | mov edx, 402h |
4864 | mov edx, 402h |
4802 | out dx, al |
4865 | out dx, al |
4803 | popa |
4866 | popa |
4804 | end if |
4867 | end if |
4805 | inc ecx |
4868 | inc ecx |
4806 | and ecx, msg_board_data_size - 1 |
4869 | and ecx, msg_board_data_size - 1 |
4807 | mov [msg_board_count], ecx |
4870 | mov [msg_board_count], ecx |
4808 | 4871 | ||
4809 | pop ebx eax |
4872 | pop ebx eax |
4810 | ret |
4873 | ret |
4811 | .smbl1: |
4874 | .smbl1: |
4812 | cmp eax, 2 |
4875 | cmp eax, 2 |
4813 | jne .smbl2 |
4876 | jne .smbl2 |
4814 | test ecx, ecx |
4877 | test ecx, ecx |
4815 | jz .smbl21 |
4878 | jz .smbl21 |
4816 | 4879 | ||
4817 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4880 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4818 | mov eax, msg_board_data+1 |
4881 | mov eax, msg_board_data+1 |
4819 | mov ebx, msg_board_data |
4882 | mov ebx, msg_board_data |
4820 | movzx edx, byte [ebx] |
4883 | movzx edx, byte [ebx] |
4821 | call memmove |
4884 | call memmove |
4822 | dec [msg_board_count] |
4885 | dec [msg_board_count] |
4823 | mov [esp + 32], edx ;eax |
4886 | mov [esp + 32], edx ;eax |
4824 | mov [esp + 20], dword 1 |
4887 | mov [esp + 20], dword 1 |
4825 | ret |
4888 | ret |
4826 | .smbl21: |
4889 | .smbl21: |
4827 | mov [esp+32], ecx |
4890 | mov [esp+32], ecx |
4828 | mov [esp+20], ecx |
4891 | mov [esp+20], ecx |
4829 | .smbl2: |
4892 | .smbl2: |
4830 | pop ebx eax |
4893 | pop ebx eax |
4831 | ret |
4894 | ret |
4832 | 4895 | ||
4833 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4896 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4834 | ;; 66 sys function. ;; |
4897 | ;; 66 sys function. ;; |
4835 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4898 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4836 | ;; out eax ;; |
4899 | ;; out eax ;; |
4837 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4900 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4838 | iglobal |
4901 | iglobal |
4839 | align 4 |
4902 | align 4 |
4840 | f66call: |
4903 | f66call: |
4841 | dd sys_process_def.1 ; 1 = set keyboard mode |
4904 | dd sys_process_def.1 ; 1 = set keyboard mode |
4842 | dd sys_process_def.2 ; 2 = get keyboard mode |
4905 | dd sys_process_def.2 ; 2 = get keyboard mode |
4843 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4906 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4844 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4907 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4845 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4908 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4846 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4909 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4847 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4910 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4848 | endg |
4911 | endg |
4849 | ;----------------------------------------------------------------------------- |
4912 | ;----------------------------------------------------------------------------- |
4850 | align 4 |
4913 | align 4 |
4851 | sys_process_def: |
4914 | sys_process_def: |
4852 | dec ebx |
4915 | dec ebx |
4853 | cmp ebx, 7 |
4916 | cmp ebx, 7 |
4854 | jae .not_support ;if >=8 then or eax,-1 |
4917 | jae .not_support ;if >=8 then or eax,-1 |
4855 | 4918 | ||
4856 | mov edi, [CURRENT_TASK] |
4919 | mov edi, [CURRENT_TASK] |
4857 | jmp dword [f66call+ebx*4] |
4920 | jmp dword [f66call+ebx*4] |
4858 | 4921 | ||
4859 | .not_support: |
4922 | .not_support: |
4860 | or eax, -1 |
4923 | or eax, -1 |
4861 | ret |
4924 | ret |
4862 | ;----------------------------------------------------------------------------- |
4925 | ;----------------------------------------------------------------------------- |
4863 | align 4 |
4926 | align 4 |
4864 | .1: |
4927 | .1: |
4865 | shl edi, 8 |
4928 | shl edi, 8 |
4866 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4929 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4867 | 4930 | ||
4868 | ret |
4931 | ret |
4869 | ;----------------------------------------------------------------------------- |
4932 | ;----------------------------------------------------------------------------- |
4870 | align 4 |
4933 | align 4 |
4871 | .2: ; 2 = get keyboard mode |
4934 | .2: ; 2 = get keyboard mode |
4872 | shl edi, 8 |
4935 | shl edi, 8 |
4873 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4936 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4874 | mov [esp+32], eax |
4937 | mov [esp+32], eax |
4875 | ret |
4938 | ret |
4876 | ;----------------------------------------------------------------------------- |
4939 | ;----------------------------------------------------------------------------- |
4877 | align 4 |
4940 | align 4 |
4878 | .3: ;3 = get keyboard ctrl, alt, shift |
4941 | .3: ;3 = get keyboard ctrl, alt, shift |
4879 | mov eax, [kb_state] |
4942 | mov eax, [kb_state] |
4880 | mov [esp+32], eax |
4943 | mov [esp+32], eax |
4881 | ret |
4944 | ret |
4882 | ;----------------------------------------------------------------------------- |
4945 | ;----------------------------------------------------------------------------- |
4883 | align 4 |
4946 | align 4 |
4884 | .4: |
4947 | .4: |
4885 | mov eax, hotkey_list |
4948 | mov eax, hotkey_list |
4886 | @@: |
4949 | @@: |
4887 | cmp dword [eax+8], 0 |
4950 | cmp dword [eax+8], 0 |
4888 | jz .found_free |
4951 | jz .found_free |
4889 | add eax, 16 |
4952 | add eax, 16 |
4890 | cmp eax, hotkey_list+16*256 |
4953 | cmp eax, hotkey_list+16*256 |
4891 | jb @b |
4954 | jb @b |
4892 | mov dword [esp+32], 1 |
4955 | mov dword [esp+32], 1 |
4893 | ret |
4956 | ret |
4894 | .found_free: |
4957 | .found_free: |
4895 | mov [eax+8], edi |
4958 | mov [eax+8], edi |
4896 | mov [eax+4], edx |
4959 | mov [eax+4], edx |
4897 | movzx ecx, cl |
4960 | movzx ecx, cl |
4898 | lea ecx, [hotkey_scancodes+ecx*4] |
4961 | lea ecx, [hotkey_scancodes+ecx*4] |
4899 | mov edx, [ecx] |
4962 | mov edx, [ecx] |
4900 | mov [eax], edx |
4963 | mov [eax], edx |
4901 | mov [ecx], eax |
4964 | mov [ecx], eax |
4902 | mov [eax+12], ecx |
4965 | mov [eax+12], ecx |
4903 | test edx, edx |
4966 | test edx, edx |
4904 | jz @f |
4967 | jz @f |
4905 | mov [edx+12], eax |
4968 | mov [edx+12], eax |
4906 | @@: |
4969 | @@: |
4907 | and dword [esp+32], 0 |
4970 | and dword [esp+32], 0 |
4908 | ret |
4971 | ret |
4909 | ;----------------------------------------------------------------------------- |
4972 | ;----------------------------------------------------------------------------- |
4910 | align 4 |
4973 | align 4 |
4911 | .5: |
4974 | .5: |
4912 | movzx ebx, cl |
4975 | movzx ebx, cl |
4913 | lea ebx, [hotkey_scancodes+ebx*4] |
4976 | lea ebx, [hotkey_scancodes+ebx*4] |
4914 | mov eax, [ebx] |
4977 | mov eax, [ebx] |
4915 | .scan: |
4978 | .scan: |
4916 | test eax, eax |
4979 | test eax, eax |
4917 | jz .notfound |
4980 | jz .notfound |
4918 | cmp [eax+8], edi |
4981 | cmp [eax+8], edi |
4919 | jnz .next |
4982 | jnz .next |
4920 | cmp [eax+4], edx |
4983 | cmp [eax+4], edx |
4921 | jz .found |
4984 | jz .found |
4922 | .next: |
4985 | .next: |
4923 | mov eax, [eax] |
4986 | mov eax, [eax] |
4924 | jmp .scan |
4987 | jmp .scan |
4925 | .notfound: |
4988 | .notfound: |
4926 | mov dword [esp+32], 1 |
4989 | mov dword [esp+32], 1 |
4927 | ret |
4990 | ret |
4928 | .found: |
4991 | .found: |
4929 | mov ecx, [eax] |
4992 | mov ecx, [eax] |
4930 | jecxz @f |
4993 | jecxz @f |
4931 | mov edx, [eax+12] |
4994 | mov edx, [eax+12] |
4932 | mov [ecx+12], edx |
4995 | mov [ecx+12], edx |
4933 | @@: |
4996 | @@: |
4934 | mov ecx, [eax+12] |
4997 | mov ecx, [eax+12] |
4935 | mov edx, [eax] |
4998 | mov edx, [eax] |
4936 | mov [ecx], edx |
4999 | mov [ecx], edx |
4937 | xor edx, edx |
5000 | xor edx, edx |
4938 | mov [eax+4], edx |
5001 | mov [eax+4], edx |
4939 | mov [eax+8], edx |
5002 | mov [eax+8], edx |
4940 | mov [eax+12], edx |
5003 | mov [eax+12], edx |
4941 | mov [eax], edx |
5004 | mov [eax], edx |
4942 | mov [esp+32], edx |
5005 | mov [esp+32], edx |
4943 | ret |
5006 | ret |
4944 | ;----------------------------------------------------------------------------- |
5007 | ;----------------------------------------------------------------------------- |
4945 | align 4 |
5008 | align 4 |
4946 | .6: |
5009 | .6: |
4947 | pushfd |
5010 | pushfd |
4948 | cli |
5011 | cli |
4949 | mov eax, [PID_lock_input] |
5012 | mov eax, [PID_lock_input] |
4950 | test eax, eax |
5013 | test eax, eax |
4951 | jnz @f |
5014 | jnz @f |
4952 | ; get current PID |
5015 | ; get current PID |
4953 | mov eax, [CURRENT_TASK] |
5016 | mov eax, [CURRENT_TASK] |
4954 | shl eax, 5 |
5017 | shl eax, 5 |
4955 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5018 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4956 | ; set current PID for lock input |
5019 | ; set current PID for lock input |
4957 | mov [PID_lock_input], eax |
5020 | mov [PID_lock_input], eax |
4958 | @@: |
5021 | @@: |
4959 | popfd |
5022 | popfd |
4960 | ret |
5023 | ret |
4961 | ;----------------------------------------------------------------------------- |
5024 | ;----------------------------------------------------------------------------- |
4962 | align 4 |
5025 | align 4 |
4963 | .7: |
5026 | .7: |
4964 | mov eax, [PID_lock_input] |
5027 | mov eax, [PID_lock_input] |
4965 | test eax, eax |
5028 | test eax, eax |
4966 | jz @f |
5029 | jz @f |
4967 | ; get current PID |
5030 | ; get current PID |
4968 | mov ebx, [CURRENT_TASK] |
5031 | mov ebx, [CURRENT_TASK] |
4969 | shl ebx, 5 |
5032 | shl ebx, 5 |
4970 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5033 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4971 | ; compare current lock input with current PID |
5034 | ; compare current lock input with current PID |
4972 | cmp ebx, eax |
5035 | cmp ebx, eax |
4973 | jne @f |
5036 | jne @f |
4974 | 5037 | ||
4975 | xor eax, eax |
5038 | xor eax, eax |
4976 | mov [PID_lock_input], eax |
5039 | mov [PID_lock_input], eax |
4977 | @@: |
5040 | @@: |
4978 | ret |
5041 | ret |
4979 | ;----------------------------------------------------------------------------- |
5042 | ;----------------------------------------------------------------------------- |
4980 | uglobal |
5043 | uglobal |
4981 | PID_lock_input dd 0x0 |
5044 | PID_lock_input dd 0x0 |
4982 | endg |
5045 | endg |
4983 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5046 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4984 | ;; 61 sys function. ;; |
5047 | ;; 61 sys function. ;; |
4985 | ;; in eax=61,ebx in [1..3] ;; |
5048 | ;; in eax=61,ebx in [1..3] ;; |
4986 | ;; out eax ;; |
5049 | ;; out eax ;; |
4987 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5050 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4988 | iglobal |
5051 | iglobal |
4989 | align 4 |
5052 | align 4 |
4990 | f61call: |
5053 | f61call: |
4991 | dd sys_gs.1 ; resolution |
5054 | dd sys_gs.1 ; resolution |
4992 | dd sys_gs.2 ; bits per pixel |
5055 | dd sys_gs.2 ; bits per pixel |
4993 | dd sys_gs.3 ; bytes per scanline |
5056 | dd sys_gs.3 ; bytes per scanline |
4994 | endg |
5057 | endg |
4995 | 5058 | ||
4996 | 5059 | ||
4997 | align 4 |
5060 | align 4 |
4998 | 5061 | ||
4999 | sys_gs: ; direct screen access |
5062 | sys_gs: ; direct screen access |
5000 | dec ebx |
5063 | dec ebx |
5001 | cmp ebx, 2 |
5064 | cmp ebx, 2 |
5002 | ja .not_support |
5065 | ja .not_support |
5003 | jmp dword [f61call+ebx*4] |
5066 | jmp dword [f61call+ebx*4] |
5004 | .not_support: |
5067 | .not_support: |
5005 | or [esp+32], dword -1 |
5068 | or [esp+32], dword -1 |
5006 | ret |
5069 | ret |
5007 | 5070 | ||
5008 | 5071 | ||
5009 | .1: ; resolution |
5072 | .1: ; resolution |
5010 | mov eax, [Screen_Max_X] |
5073 | mov eax, [Screen_Max_X] |
5011 | shl eax, 16 |
5074 | shl eax, 16 |
5012 | mov ax, word [Screen_Max_Y] |
5075 | mov ax, word [Screen_Max_Y] |
5013 | add eax, 0x00010001 |
5076 | add eax, 0x00010001 |
5014 | mov [esp+32], eax |
5077 | mov [esp+32], eax |
5015 | ret |
5078 | ret |
5016 | .2: ; bits per pixel |
5079 | .2: ; bits per pixel |
5017 | mov eax, [_display.bpp] |
5080 | mov eax, [_display.bpp] |
5018 | mov [esp+32], eax |
5081 | mov [esp+32], eax |
5019 | ret |
5082 | ret |
5020 | .3: ; bytes per scanline |
5083 | .3: ; bytes per scanline |
5021 | mov eax, [_display.pitch] |
5084 | mov eax, [_display.pitch] |
5022 | mov [esp+32], eax |
5085 | mov [esp+32], eax |
5023 | ret |
5086 | ret |
5024 | 5087 | ||
5025 | align 4 ; system functions |
5088 | align 4 ; system functions |
5026 | 5089 | ||
5027 | syscall_setpixel: ; SetPixel |
5090 | syscall_setpixel: ; SetPixel |
5028 | 5091 | ||
5029 | mov eax, ebx |
5092 | mov eax, ebx |
5030 | mov ebx, ecx |
5093 | mov ebx, ecx |
5031 | mov ecx, edx |
5094 | mov ecx, edx |
5032 | mov edx, [TASK_BASE] |
5095 | mov edx, [TASK_BASE] |
5033 | add eax, [edx-twdw+WDATA.box.left] |
5096 | add eax, [edx-twdw+WDATA.box.left] |
5034 | add ebx, [edx-twdw+WDATA.box.top] |
5097 | add ebx, [edx-twdw+WDATA.box.top] |
5035 | mov edi, [current_slot] |
5098 | mov edi, [current_slot] |
5036 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5099 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5037 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5100 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5038 | xor edi, edi ; no force |
5101 | xor edi, edi ; no force |
5039 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5102 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5040 | ; jmp [putpixel] |
5103 | ; jmp [putpixel] |
5041 | jmp __sys_putpixel |
5104 | jmp __sys_putpixel |
5042 | 5105 | ||
5043 | align 4 |
5106 | align 4 |
5044 | 5107 | ||
5045 | syscall_writetext: ; WriteText |
5108 | syscall_writetext: ; WriteText |
5046 | 5109 | ||
5047 | mov eax, [TASK_BASE] |
5110 | mov eax, [TASK_BASE] |
5048 | mov ebp, [eax-twdw+WDATA.box.left] |
5111 | mov ebp, [eax-twdw+WDATA.box.left] |
5049 | push esi |
5112 | push esi |
5050 | mov esi, [current_slot] |
5113 | mov esi, [current_slot] |
5051 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5114 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5052 | shl ebp, 16 |
5115 | shl ebp, 16 |
5053 | add ebp, [eax-twdw+WDATA.box.top] |
5116 | add ebp, [eax-twdw+WDATA.box.top] |
5054 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5117 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5055 | pop esi |
5118 | pop esi |
5056 | test ecx, 0x08000000 ; redirect the output to the user area |
5119 | test ecx, 0x08000000 ; redirect the output to the user area |
5057 | jnz @f |
5120 | jnz @f |
5058 | add ebx, ebp |
5121 | add ebx, ebp |
5059 | align 4 |
5122 | align 4 |
5060 | @@: |
5123 | @@: |
5061 | mov eax, edi |
5124 | mov eax, edi |
5062 | test ecx, 0x08000000 ; redirect the output to the user area |
5125 | test ecx, 0x08000000 ; redirect the output to the user area |
5063 | jnz dtext |
5126 | jnz dtext |
5064 | xor edi, edi |
5127 | xor edi, edi |
5065 | jmp dtext |
5128 | jmp dtext |
5066 | 5129 | ||
5067 | align 4 |
5130 | align 4 |
5068 | 5131 | ||
5069 | syscall_openramdiskfile: ; OpenRamdiskFile |
5132 | syscall_openramdiskfile: ; OpenRamdiskFile |
5070 | 5133 | ||
5071 | mov eax, ebx |
5134 | mov eax, ebx |
5072 | mov ebx, ecx |
5135 | mov ebx, ecx |
5073 | mov ecx, edx |
5136 | mov ecx, edx |
5074 | mov edx, esi |
5137 | mov edx, esi |
5075 | mov esi, 12 |
5138 | mov esi, 12 |
5076 | call fileread |
5139 | call fileread |
5077 | mov [esp+32], eax |
5140 | mov [esp+32], eax |
5078 | ret |
5141 | ret |
5079 | 5142 | ||
5080 | align 4 |
5143 | align 4 |
5081 | 5144 | ||
5082 | syscall_drawrect: ; DrawRect |
5145 | syscall_drawrect: ; DrawRect |
5083 | 5146 | ||
5084 | mov edi, edx ; color + gradient |
5147 | mov edi, edx ; color + gradient |
5085 | and edi, 0x80FFFFFF |
5148 | and edi, 0x80FFFFFF |
5086 | test bx, bx ; x.size |
5149 | test bx, bx ; x.size |
5087 | je .drectr |
5150 | je .drectr |
5088 | test cx, cx ; y.size |
5151 | test cx, cx ; y.size |
5089 | je .drectr |
5152 | je .drectr |
5090 | 5153 | ||
5091 | mov eax, ebx ; bad idea |
5154 | mov eax, ebx ; bad idea |
5092 | mov ebx, ecx |
5155 | mov ebx, ecx |
5093 | 5156 | ||
5094 | movzx ecx, ax ; ecx - x.size |
5157 | movzx ecx, ax ; ecx - x.size |
5095 | shr eax, 16 ; eax - x.coord |
5158 | shr eax, 16 ; eax - x.coord |
5096 | movzx edx, bx ; edx - y.size |
5159 | movzx edx, bx ; edx - y.size |
5097 | shr ebx, 16 ; ebx - y.coord |
5160 | shr ebx, 16 ; ebx - y.coord |
5098 | mov esi, [current_slot] |
5161 | mov esi, [current_slot] |
5099 | 5162 | ||
5100 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5163 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5101 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5164 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5102 | add ecx, eax |
5165 | add ecx, eax |
5103 | add edx, ebx |
5166 | add edx, ebx |
5104 | ; jmp [drawbar] |
5167 | ; jmp [drawbar] |
5105 | jmp vesa20_drawbar |
5168 | jmp vesa20_drawbar |
5106 | .drectr: |
5169 | .drectr: |
5107 | ret |
5170 | ret |
5108 | 5171 | ||
5109 | align 4 |
5172 | align 4 |
5110 | syscall_getscreensize: ; GetScreenSize |
5173 | syscall_getscreensize: ; GetScreenSize |
5111 | mov ax, word [Screen_Max_X] |
5174 | mov ax, word [Screen_Max_X] |
5112 | shl eax, 16 |
5175 | shl eax, 16 |
5113 | mov ax, word [Screen_Max_Y] |
5176 | mov ax, word [Screen_Max_Y] |
5114 | mov [esp + 32], eax |
5177 | mov [esp + 32], eax |
5115 | ret |
5178 | ret |
5116 | 5179 | ||
5117 | align 4 |
5180 | align 4 |
5118 | 5181 | ||
5119 | syscall_cdaudio: ; CD |
5182 | syscall_cdaudio: ; CD |
5120 | 5183 | ||
5121 | cmp ebx, 4 |
5184 | cmp ebx, 4 |
5122 | jb .audio |
5185 | jb .audio |
5123 | jz .eject |
5186 | jz .eject |
5124 | cmp ebx, 5 |
5187 | cmp ebx, 5 |
5125 | jnz .ret |
5188 | jnz .ret |
5126 | .load: |
5189 | .load: |
5127 | call .reserve |
5190 | call .reserve |
5128 | call LoadMedium |
5191 | call LoadMedium |
5129 | ;call .free |
5192 | ;call .free |
5130 | jmp .free |
5193 | jmp .free |
5131 | ; ret |
5194 | ; ret |
5132 | .eject: |
5195 | .eject: |
5133 | call .reserve |
5196 | call .reserve |
5134 | call clear_CD_cache |
5197 | call clear_CD_cache |
5135 | call allow_medium_removal |
5198 | call allow_medium_removal |
5136 | call EjectMedium |
5199 | call EjectMedium |
5137 | ; call .free |
5200 | ; call .free |
5138 | jmp .free |
5201 | jmp .free |
5139 | ; ret |
5202 | ; ret |
5140 | .audio: |
5203 | .audio: |
5141 | call sys_cd_audio |
5204 | call sys_cd_audio |
5142 | mov [esp+36-4], eax |
5205 | mov [esp+36-4], eax |
5143 | .ret: |
5206 | .ret: |
5144 | ret |
5207 | ret |
5145 | 5208 | ||
5146 | .reserve: |
5209 | .reserve: |
5147 | call reserve_cd |
5210 | call reserve_cd |
5148 | mov eax, ecx |
5211 | mov eax, ecx |
5149 | shr eax, 1 |
5212 | shr eax, 1 |
5150 | and eax, 1 |
5213 | and eax, 1 |
5151 | inc eax |
5214 | inc eax |
5152 | mov [ChannelNumber], ax |
5215 | mov [ChannelNumber], ax |
5153 | mov eax, ecx |
5216 | mov eax, ecx |
5154 | and eax, 1 |
5217 | and eax, 1 |
5155 | mov [DiskNumber], al |
5218 | mov [DiskNumber], al |
5156 | call reserve_cd_channel |
5219 | call reserve_cd_channel |
5157 | and ebx, 3 |
5220 | and ebx, 3 |
5158 | inc ebx |
5221 | inc ebx |
5159 | mov [cdpos], ebx |
5222 | mov [cdpos], ebx |
5160 | add ebx, ebx |
5223 | add ebx, ebx |
5161 | mov cl, 8 |
5224 | mov cl, 8 |
5162 | sub cl, bl |
5225 | sub cl, bl |
5163 | mov al, [DRIVE_DATA+1] |
5226 | mov al, [DRIVE_DATA+1] |
5164 | shr al, cl |
5227 | shr al, cl |
5165 | test al, 2 |
5228 | test al, 2 |
5166 | jz .free;.err |
5229 | jz .free;.err |
5167 | ret |
5230 | ret |
5168 | .free: |
5231 | .free: |
5169 | call free_cd_channel |
5232 | call free_cd_channel |
5170 | and [cd_status], 0 |
5233 | and [cd_status], 0 |
5171 | ret |
5234 | ret |
5172 | .err: |
5235 | .err: |
5173 | call .free |
5236 | call .free |
5174 | ; pop eax |
5237 | ; pop eax |
5175 | ret |
5238 | ret |
5176 | ;----------------------------------------------------------------------------- |
5239 | ;----------------------------------------------------------------------------- |
5177 | align 4 |
5240 | align 4 |
5178 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5241 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5179 | cmp ebx, [Screen_Max_X] |
5242 | cmp ebx, [Screen_Max_X] |
5180 | jbe @f |
5243 | jbe @f |
5181 | cmp ecx, [Screen_Max_Y] |
5244 | cmp ecx, [Screen_Max_Y] |
5182 | jbe @f |
5245 | jbe @f |
5183 | xor eax, eax |
5246 | xor eax, eax |
5184 | jmp .store |
5247 | jmp .store |
5185 | ;-------------------------------------- |
5248 | ;-------------------------------------- |
5186 | align 4 |
5249 | align 4 |
5187 | @@: |
5250 | @@: |
5188 | mov eax, [d_width_calc_area + ecx*4] |
5251 | mov eax, [d_width_calc_area + ecx*4] |
5189 | add eax, [_WinMapAddress] |
5252 | add eax, [_WinMapAddress] |
5190 | movzx eax, byte[eax+ebx] ; get value for current point |
5253 | movzx eax, byte[eax+ebx] ; get value for current point |
5191 | ;-------------------------------------- |
5254 | ;-------------------------------------- |
5192 | align 4 |
5255 | align 4 |
5193 | .store: |
5256 | .store: |
5194 | mov [esp + 32], eax |
5257 | mov [esp + 32], eax |
5195 | ret |
5258 | ret |
5196 | ;----------------------------------------------------------------------------- |
5259 | ;----------------------------------------------------------------------------- |
5197 | align 4 |
5260 | align 4 |
5198 | syscall_getpixel: ; GetPixel |
5261 | syscall_getpixel: ; GetPixel |
5199 | mov ecx, [Screen_Max_X] |
5262 | mov ecx, [Screen_Max_X] |
5200 | inc ecx |
5263 | inc ecx |
5201 | xor edx, edx |
5264 | xor edx, edx |
5202 | mov eax, ebx |
5265 | mov eax, ebx |
5203 | div ecx |
5266 | div ecx |
5204 | mov ebx, edx |
5267 | mov ebx, edx |
5205 | xchg eax, ebx |
5268 | xchg eax, ebx |
5206 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5269 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5207 | call dword [GETPIXEL]; eax - x, ebx - y |
5270 | call dword [GETPIXEL]; eax - x, ebx - y |
5208 | mov [esp + 32], ecx |
5271 | mov [esp + 32], ecx |
5209 | ret |
5272 | ret |
5210 | ;----------------------------------------------------------------------------- |
5273 | ;----------------------------------------------------------------------------- |
5211 | align 4 |
5274 | align 4 |
5212 | syscall_getarea: |
5275 | syscall_getarea: |
5213 | ;eax = 36 |
5276 | ;eax = 36 |
5214 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5277 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5215 | ;ecx = [size x]*65536 + [size y] |
5278 | ;ecx = [size x]*65536 + [size y] |
5216 | ;edx = [start x]*65536 + [start y] |
5279 | ;edx = [start x]*65536 + [start y] |
5217 | pushad |
5280 | pushad |
5218 | mov edi, ebx |
5281 | mov edi, ebx |
5219 | mov eax, edx |
5282 | mov eax, edx |
5220 | shr eax, 16 |
5283 | shr eax, 16 |
5221 | mov ebx, edx |
5284 | mov ebx, edx |
5222 | and ebx, 0xffff |
5285 | and ebx, 0xffff |
5223 | dec eax |
5286 | dec eax |
5224 | dec ebx |
5287 | dec ebx |
5225 | ; eax - x, ebx - y |
5288 | ; eax - x, ebx - y |
5226 | mov edx, ecx |
5289 | mov edx, ecx |
5227 | 5290 | ||
5228 | shr ecx, 16 |
5291 | shr ecx, 16 |
5229 | and edx, 0xffff |
5292 | and edx, 0xffff |
5230 | mov esi, ecx |
5293 | mov esi, ecx |
5231 | ; ecx - size x, edx - size y |
5294 | ; ecx - size x, edx - size y |
5232 | 5295 | ||
5233 | mov ebp, edx |
5296 | mov ebp, edx |
5234 | dec ebp |
5297 | dec ebp |
5235 | lea ebp, [ebp*3] |
5298 | lea ebp, [ebp*3] |
5236 | 5299 | ||
5237 | imul ebp, esi |
5300 | imul ebp, esi |
5238 | 5301 | ||
5239 | mov esi, ecx |
5302 | mov esi, ecx |
5240 | dec esi |
5303 | dec esi |
5241 | lea esi, [esi*3] |
5304 | lea esi, [esi*3] |
5242 | 5305 | ||
5243 | add ebp, esi |
5306 | add ebp, esi |
5244 | add ebp, edi |
5307 | add ebp, edi |
5245 | 5308 | ||
5246 | add ebx, edx |
5309 | add ebx, edx |
5247 | ;-------------------------------------- |
5310 | ;-------------------------------------- |
5248 | align 4 |
5311 | align 4 |
5249 | .start_y: |
5312 | .start_y: |
5250 | push ecx edx |
5313 | push ecx edx |
5251 | ;-------------------------------------- |
5314 | ;-------------------------------------- |
5252 | align 4 |
5315 | align 4 |
5253 | .start_x: |
5316 | .start_x: |
5254 | push eax ebx ecx |
5317 | push eax ebx ecx |
5255 | add eax, ecx |
5318 | add eax, ecx |
5256 | 5319 | ||
5257 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5320 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5258 | call dword [GETPIXEL]; eax - x, ebx - y |
5321 | call dword [GETPIXEL]; eax - x, ebx - y |
5259 | 5322 | ||
5260 | mov [ebp], cx |
5323 | mov [ebp], cx |
5261 | shr ecx, 16 |
5324 | shr ecx, 16 |
5262 | mov [ebp+2], cl |
5325 | mov [ebp+2], cl |
5263 | 5326 | ||
5264 | pop ecx ebx eax |
5327 | pop ecx ebx eax |
5265 | sub ebp, 3 |
5328 | sub ebp, 3 |
5266 | dec ecx |
5329 | dec ecx |
5267 | jnz .start_x |
5330 | jnz .start_x |
5268 | pop edx ecx |
5331 | pop edx ecx |
5269 | dec ebx |
5332 | dec ebx |
5270 | dec edx |
5333 | dec edx |
5271 | jnz .start_y |
5334 | jnz .start_y |
5272 | popad |
5335 | popad |
5273 | ret |
5336 | ret |
5274 | ;----------------------------------------------------------------------------- |
5337 | ;----------------------------------------------------------------------------- |
5275 | align 4 |
5338 | align 4 |
5276 | syscall_putarea_backgr: |
5339 | syscall_putarea_backgr: |
5277 | ;eax = 25 |
5340 | ;eax = 25 |
5278 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5341 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5279 | ;ecx = [size x]*65536 + [size y] |
5342 | ;ecx = [size x]*65536 + [size y] |
5280 | ;edx = [start x]*65536 + [start y] |
5343 | ;edx = [start x]*65536 + [start y] |
5281 | pushad |
5344 | pushad |
5282 | mov edi, ebx |
5345 | mov edi, ebx |
5283 | mov eax, edx |
5346 | mov eax, edx |
5284 | shr eax, 16 |
5347 | shr eax, 16 |
5285 | mov ebx, edx |
5348 | mov ebx, edx |
5286 | and ebx, 0xffff |
5349 | and ebx, 0xffff |
5287 | dec eax |
5350 | dec eax |
5288 | dec ebx |
5351 | dec ebx |
5289 | ; eax - x, ebx - y |
5352 | ; eax - x, ebx - y |
5290 | mov edx, ecx |
5353 | mov edx, ecx |
5291 | shr ecx, 16 |
5354 | shr ecx, 16 |
5292 | and edx, 0xffff |
5355 | and edx, 0xffff |
5293 | mov esi, ecx |
5356 | mov esi, ecx |
5294 | ; ecx - size x, edx - size y |
5357 | ; ecx - size x, edx - size y |
5295 | mov ebp, edx |
5358 | mov ebp, edx |
5296 | dec ebp |
5359 | dec ebp |
5297 | shl ebp, 2 |
5360 | shl ebp, 2 |
5298 | 5361 | ||
5299 | imul ebp, esi |
5362 | imul ebp, esi |
5300 | 5363 | ||
5301 | mov esi, ecx |
5364 | mov esi, ecx |
5302 | dec esi |
5365 | dec esi |
5303 | shl esi, 2 |
5366 | shl esi, 2 |
5304 | 5367 | ||
5305 | add ebp, esi |
5368 | add ebp, esi |
5306 | add ebp, edi |
5369 | add ebp, edi |
5307 | 5370 | ||
5308 | add ebx, edx |
5371 | add ebx, edx |
5309 | ;-------------------------------------- |
5372 | ;-------------------------------------- |
5310 | align 4 |
5373 | align 4 |
5311 | .start_y: |
5374 | .start_y: |
5312 | push ecx edx |
5375 | push ecx edx |
5313 | ;-------------------------------------- |
5376 | ;-------------------------------------- |
5314 | align 4 |
5377 | align 4 |
5315 | .start_x: |
5378 | .start_x: |
5316 | push eax ecx |
5379 | push eax ecx |
5317 | add eax, ecx |
5380 | add eax, ecx |
5318 | 5381 | ||
5319 | mov ecx, [ebp] |
5382 | mov ecx, [ebp] |
5320 | rol ecx, 8 |
5383 | rol ecx, 8 |
5321 | test cl, cl ; transparensy = 0 |
5384 | test cl, cl ; transparensy = 0 |
5322 | jz .no_put |
5385 | jz .no_put |
5323 | 5386 | ||
5324 | xor cl, cl |
5387 | xor cl, cl |
5325 | ror ecx, 8 |
5388 | ror ecx, 8 |
5326 | 5389 | ||
5327 | pushad |
5390 | pushad |
5328 | mov edx, [d_width_calc_area + ebx*4] |
5391 | mov edx, [d_width_calc_area + ebx*4] |
5329 | add edx, [_WinMapAddress] |
5392 | add edx, [_WinMapAddress] |
5330 | movzx edx, byte [eax+edx] |
5393 | movzx edx, byte [eax+edx] |
5331 | cmp dl, byte 1 |
5394 | cmp dl, byte 1 |
5332 | jne @f |
5395 | jne @f |
5333 | 5396 | ||
5334 | call dword [PUTPIXEL]; eax - x, ebx - y |
5397 | call dword [PUTPIXEL]; eax - x, ebx - y |
5335 | ;-------------------------------------- |
5398 | ;-------------------------------------- |
5336 | align 4 |
5399 | align 4 |
5337 | @@: |
5400 | @@: |
5338 | popad |
5401 | popad |
5339 | ;-------------------------------------- |
5402 | ;-------------------------------------- |
5340 | align 4 |
5403 | align 4 |
5341 | .no_put: |
5404 | .no_put: |
5342 | pop ecx eax |
5405 | pop ecx eax |
5343 | 5406 | ||
5344 | sub ebp, 4 |
5407 | sub ebp, 4 |
5345 | dec ecx |
5408 | dec ecx |
5346 | jnz .start_x |
5409 | jnz .start_x |
5347 | 5410 | ||
5348 | pop edx ecx |
5411 | pop edx ecx |
5349 | dec ebx |
5412 | dec ebx |
5350 | dec edx |
5413 | dec edx |
5351 | jnz .start_y |
5414 | jnz .start_y |
5352 | 5415 | ||
5353 | popad |
5416 | popad |
5354 | ret |
5417 | ret |
5355 | ;----------------------------------------------------------------------------- |
5418 | ;----------------------------------------------------------------------------- |
5356 | align 4 |
5419 | align 4 |
5357 | syscall_drawline: ; DrawLine |
5420 | syscall_drawline: ; DrawLine |
5358 | 5421 | ||
5359 | mov edi, [TASK_BASE] |
5422 | mov edi, [TASK_BASE] |
5360 | movzx eax, word[edi-twdw+WDATA.box.left] |
5423 | movzx eax, word[edi-twdw+WDATA.box.left] |
5361 | mov ebp, eax |
5424 | mov ebp, eax |
5362 | mov esi, [current_slot] |
5425 | mov esi, [current_slot] |
5363 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5426 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5364 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5427 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5365 | add ebp, ebx |
5428 | add ebp, ebx |
5366 | shl eax, 16 |
5429 | shl eax, 16 |
5367 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5430 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5368 | add eax, ebp |
5431 | add eax, ebp |
5369 | mov ebp, ebx |
5432 | mov ebp, ebx |
5370 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5433 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5371 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5434 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5372 | add ebp, ecx |
5435 | add ebp, ecx |
5373 | shl ebx, 16 |
5436 | shl ebx, 16 |
5374 | xor edi, edi |
5437 | xor edi, edi |
5375 | add ebx, ebp |
5438 | add ebx, ebp |
5376 | mov ecx, edx |
5439 | mov ecx, edx |
5377 | ; jmp [draw_line] |
5440 | ; jmp [draw_line] |
5378 | jmp __sys_draw_line |
5441 | jmp __sys_draw_line |
5379 | 5442 | ||
5380 | 5443 | ||
5381 | align 4 |
5444 | align 4 |
5382 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5445 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5383 | 5446 | ||
5384 | call r_f_port_area |
5447 | call r_f_port_area |
5385 | mov [esp+32], eax |
5448 | mov [esp+32], eax |
5386 | ret |
5449 | ret |
5387 | 5450 | ||
5388 | align 4 |
5451 | align 4 |
5389 | syscall_threads: ; CreateThreads |
5452 | syscall_threads: ; CreateThreads |
5390 | ; eax=1 create thread |
5453 | ; eax=1 create thread |
5391 | ; |
5454 | ; |
5392 | ; ebx=thread start |
5455 | ; ebx=thread start |
5393 | ; ecx=thread stack value |
5456 | ; ecx=thread stack value |
5394 | ; |
5457 | ; |
5395 | ; on return : eax = pid |
5458 | ; on return : eax = pid |
5396 | 5459 | ||
5397 | call new_sys_threads |
5460 | call new_sys_threads |
5398 | 5461 | ||
5399 | mov [esp+32], eax |
5462 | mov [esp+32], eax |
5400 | ret |
5463 | ret |
5401 | 5464 | ||
5402 | align 4 |
5465 | align 4 |
5403 | 5466 | ||
5404 | paleholder: |
5467 | paleholder: |
5405 | ret |
5468 | ret |
5406 | ;------------------------------------------------------------------------------ |
5469 | ;------------------------------------------------------------------------------ |
5407 | align 4 |
5470 | align 4 |
5408 | calculate_fast_getting_offset_for_WinMapAddress: |
5471 | calculate_fast_getting_offset_for_WinMapAddress: |
5409 | ; calculate data area for fast getting offset to _WinMapAddress |
5472 | ; calculate data area for fast getting offset to _WinMapAddress |
5410 | xor eax, eax |
5473 | xor eax, eax |
5411 | mov ecx, [_display.height] |
5474 | mov ecx, [_display.height] |
5412 | inc ecx |
5475 | inc ecx |
5413 | mov edi, d_width_calc_area |
5476 | mov edi, d_width_calc_area |
5414 | cld |
5477 | cld |
5415 | @@: |
5478 | @@: |
5416 | stosd |
5479 | stosd |
5417 | add eax, [_display.width] |
5480 | add eax, [_display.width] |
5418 | dec ecx |
5481 | dec ecx |
5419 | jnz @r |
5482 | jnz @r |
5420 | ret |
5483 | ret |
5421 | ;------------------------------------------------------------------------------ |
5484 | ;------------------------------------------------------------------------------ |
5422 | align 4 |
5485 | align 4 |
5423 | calculate_fast_getting_offset_for_LFB: |
5486 | calculate_fast_getting_offset_for_LFB: |
5424 | ; calculate data area for fast getting offset to LFB |
5487 | ; calculate data area for fast getting offset to LFB |
5425 | xor eax, eax |
5488 | xor eax, eax |
5426 | mov ecx, [_display.height] |
5489 | mov ecx, [_display.height] |
5427 | inc ecx |
5490 | inc ecx |
5428 | mov edi, BPSLine_calc_area |
5491 | mov edi, BPSLine_calc_area |
5429 | cld |
5492 | cld |
5430 | @@: |
5493 | @@: |
5431 | stosd |
5494 | stosd |
5432 | add eax, [_display.pitch] |
5495 | add eax, [_display.pitch] |
5433 | dec ecx |
5496 | dec ecx |
5434 | jnz @r |
5497 | jnz @r |
5435 | ret |
5498 | ret |
5436 | ;------------------------------------------------------------------------------ |
5499 | ;------------------------------------------------------------------------------ |
5437 | align 4 |
5500 | align 4 |
5438 | set_screen: |
5501 | set_screen: |
5439 | ; in: |
5502 | ; in: |
5440 | ; eax - new Screen_Max_X |
5503 | ; eax - new Screen_Max_X |
5441 | ; ecx - new BytesPerScanLine |
5504 | ; ecx - new BytesPerScanLine |
5442 | ; edx - new Screen_Max_Y |
5505 | ; edx - new Screen_Max_Y |
5443 | cmp eax, [Screen_Max_X] |
5506 | cmp eax, [Screen_Max_X] |
5444 | jne .set |
5507 | jne .set |
5445 | 5508 | ||
5446 | cmp edx, [Screen_Max_Y] |
5509 | cmp edx, [Screen_Max_Y] |
5447 | jne .set |
5510 | jne .set |
5448 | ret |
5511 | ret |
5449 | .set: |
5512 | .set: |
5450 | pushfd |
5513 | pushfd |
5451 | cli |
5514 | cli |
5452 | 5515 | ||
5453 | mov [Screen_Max_X], eax |
5516 | mov [Screen_Max_X], eax |
5454 | mov [Screen_Max_Y], edx |
5517 | mov [Screen_Max_Y], edx |
5455 | mov [_display.pitch], ecx |
5518 | mov [_display.pitch], ecx |
5456 | 5519 | ||
5457 | mov [screen_workarea.right], eax |
5520 | mov [screen_workarea.right], eax |
5458 | mov [screen_workarea.bottom], edx |
5521 | mov [screen_workarea.bottom], edx |
5459 | 5522 | ||
5460 | push ebx |
5523 | push ebx |
5461 | push esi |
5524 | push esi |
5462 | push edi |
5525 | push edi |
5463 | 5526 | ||
5464 | pushad |
5527 | pushad |
5465 | 5528 | ||
5466 | cmp [do_not_touch_winmap], 1 |
5529 | cmp [do_not_touch_winmap], 1 |
5467 | je @f |
5530 | je @f |
5468 | 5531 | ||
5469 | stdcall kernel_free, [_WinMapAddress] |
5532 | stdcall kernel_free, [_WinMapAddress] |
5470 | 5533 | ||
5471 | mov eax, [_display.width] |
5534 | mov eax, [_display.width] |
5472 | mul [_display.height] |
5535 | mul [_display.height] |
5473 | mov [_WinMapSize], eax |
5536 | mov [_WinMapSize], eax |
5474 | 5537 | ||
5475 | stdcall kernel_alloc, eax |
5538 | stdcall kernel_alloc, eax |
5476 | mov [_WinMapAddress], eax |
5539 | mov [_WinMapAddress], eax |
5477 | test eax, eax |
5540 | test eax, eax |
5478 | jz .epic_fail |
5541 | jz .epic_fail |
5479 | ; store for f.18.24 |
5542 | ; store for f.18.24 |
5480 | mov eax, [_display.width] |
5543 | mov eax, [_display.width] |
5481 | mov [display_width_standard], eax |
5544 | mov [display_width_standard], eax |
5482 | 5545 | ||
5483 | mov eax, [_display.height] |
5546 | mov eax, [_display.height] |
5484 | mov [display_height_standard], eax |
5547 | mov [display_height_standard], eax |
5485 | @@: |
5548 | @@: |
5486 | call calculate_fast_getting_offset_for_WinMapAddress |
5549 | call calculate_fast_getting_offset_for_WinMapAddress |
5487 | ; for Qemu or non standart video cards |
5550 | ; for Qemu or non standart video cards |
5488 | ; Unfortunately [BytesPerScanLine] does not always |
5551 | ; Unfortunately [BytesPerScanLine] does not always |
5489 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5552 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5490 | call calculate_fast_getting_offset_for_LFB |
5553 | call calculate_fast_getting_offset_for_LFB |
5491 | popad |
5554 | popad |
5492 | 5555 | ||
5493 | call repos_windows |
5556 | call repos_windows |
5494 | xor eax, eax |
5557 | xor eax, eax |
5495 | xor ebx, ebx |
5558 | xor ebx, ebx |
5496 | mov ecx, [Screen_Max_X] |
5559 | mov ecx, [Screen_Max_X] |
5497 | mov edx, [Screen_Max_Y] |
5560 | mov edx, [Screen_Max_Y] |
5498 | call calculatescreen |
5561 | call calculatescreen |
5499 | pop edi |
5562 | pop edi |
5500 | pop esi |
5563 | pop esi |
5501 | pop ebx |
5564 | pop ebx |
5502 | 5565 | ||
5503 | popfd |
5566 | popfd |
5504 | ret |
5567 | ret |
5505 | 5568 | ||
5506 | .epic_fail: |
5569 | .epic_fail: |
5507 | hlt ; Houston, we've had a problem |
5570 | hlt ; Houston, we've had a problem |
5508 | 5571 | ||
5509 | ; --------------- APM --------------------- |
5572 | ; --------------- APM --------------------- |
5510 | uglobal |
5573 | uglobal |
5511 | apm_entry dp 0 |
5574 | apm_entry dp 0 |
5512 | apm_vf dd 0 |
5575 | apm_vf dd 0 |
5513 | endg |
5576 | endg |
5514 | 5577 | ||
5515 | align 4 |
5578 | align 4 |
5516 | sys_apm: |
5579 | sys_apm: |
5517 | xor eax, eax |
5580 | xor eax, eax |
5518 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5581 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5519 | jne @f |
5582 | jne @f |
5520 | inc eax |
5583 | inc eax |
5521 | or dword [esp + 44], eax ; error |
5584 | or dword [esp + 44], eax ; error |
5522 | add eax, 7 |
5585 | add eax, 7 |
5523 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5586 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5524 | ret |
5587 | ret |
5525 | 5588 | ||
5526 | @@: |
5589 | @@: |
5527 | ; xchg eax, ecx |
5590 | ; xchg eax, ecx |
5528 | ; xchg ebx, ecx |
5591 | ; xchg ebx, ecx |
5529 | 5592 | ||
5530 | cmp dx, 3 |
5593 | cmp dx, 3 |
5531 | ja @f |
5594 | ja @f |
5532 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5595 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5533 | mov eax, [apm_vf] |
5596 | mov eax, [apm_vf] |
5534 | mov [esp + 32], eax |
5597 | mov [esp + 32], eax |
5535 | shr eax, 16 |
5598 | shr eax, 16 |
5536 | mov [esp + 28], eax |
5599 | mov [esp + 28], eax |
5537 | ret |
5600 | ret |
5538 | 5601 | ||
5539 | @@: |
5602 | @@: |
5540 | 5603 | ||
5541 | mov esi, [master_tab+(OS_BASE shr 20)] |
5604 | mov esi, [master_tab+(OS_BASE shr 20)] |
5542 | xchg [master_tab], esi |
5605 | xchg [master_tab], esi |
5543 | push esi |
5606 | push esi |
5544 | mov edi, cr3 |
5607 | mov edi, cr3 |
5545 | mov cr3, edi ;flush TLB |
5608 | mov cr3, edi ;flush TLB |
5546 | 5609 | ||
5547 | call pword [apm_entry] ;call APM BIOS |
5610 | call pword [apm_entry] ;call APM BIOS |
5548 | 5611 | ||
5549 | xchg eax, [esp] |
5612 | xchg eax, [esp] |
5550 | mov [master_tab], eax |
5613 | mov [master_tab], eax |
5551 | mov eax, cr3 |
5614 | mov eax, cr3 |
5552 | mov cr3, eax |
5615 | mov cr3, eax |
5553 | pop eax |
5616 | pop eax |
5554 | 5617 | ||
5555 | mov [esp + 4 ], edi |
5618 | mov [esp + 4 ], edi |
5556 | mov [esp + 8], esi |
5619 | mov [esp + 8], esi |
5557 | mov [esp + 20], ebx |
5620 | mov [esp + 20], ebx |
5558 | mov [esp + 24], edx |
5621 | mov [esp + 24], edx |
5559 | mov [esp + 28], ecx |
5622 | mov [esp + 28], ecx |
5560 | mov [esp + 32], eax |
5623 | mov [esp + 32], eax |
5561 | setc al |
5624 | setc al |
5562 | and [esp + 44], byte 0xfe |
5625 | and [esp + 44], byte 0xfe |
5563 | or [esp + 44], al |
5626 | or [esp + 44], al |
5564 | ret |
5627 | ret |
5565 | ; ----------------------------------------- |
5628 | ; ----------------------------------------- |
5566 | 5629 | ||
5567 | align 4 |
5630 | align 4 |
5568 | 5631 | ||
5569 | undefined_syscall: ; Undefined system call |
5632 | undefined_syscall: ; Undefined system call |
5570 | mov [esp + 32], dword -1 |
5633 | mov [esp + 32], dword -1 |
5571 | ret |
5634 | ret |
5572 | 5635 | ||
5573 | align 4 |
5636 | align 4 |
5574 | system_shutdown: ; shut down the system |
5637 | system_shutdown: ; shut down the system |
5575 | 5638 | ||
5576 | cmp byte [BOOT_VAR+0x9030], 1 |
5639 | cmp byte [BOOT_VAR+0x9030], 1 |
5577 | jne @F |
5640 | jne @F |
5578 | ret |
5641 | ret |
5579 | @@: |
5642 | @@: |
5580 | call stop_all_services |
5643 | call stop_all_services |
5581 | movi eax, 3 |
5644 | movi eax, 3 |
5582 | call sys_cd_audio |
5645 | call sys_cd_audio |
5583 | 5646 | ||
5584 | yes_shutdown_param: |
5647 | yes_shutdown_param: |
5585 | cli |
5648 | cli |
5586 | 5649 | ||
5587 | if ~ defined extended_primary_loader |
5650 | if ~ defined extended_primary_loader |
5588 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5651 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5589 | movi esi, 12 |
5652 | movi esi, 12 |
5590 | xor ebx, ebx |
5653 | xor ebx, ebx |
5591 | or ecx, -1 |
5654 | or ecx, -1 |
5592 | mov edx, OS_BASE+0x70000 |
5655 | mov edx, OS_BASE+0x70000 |
5593 | call fileread |
5656 | call fileread |
5594 | 5657 | ||
5595 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5658 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5596 | mov edi, OS_BASE+0x40000 |
5659 | mov edi, OS_BASE+0x40000 |
5597 | mov ecx, 1000 |
5660 | mov ecx, 1000 |
5598 | rep movsb |
5661 | rep movsb |
5599 | end if |
5662 | end if |
5600 | 5663 | ||
5601 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5664 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5602 | mov edi, OS_BASE |
5665 | mov edi, OS_BASE |
5603 | mov ecx, 0x10000/4 |
5666 | mov ecx, 0x10000/4 |
5604 | cld |
5667 | cld |
5605 | rep movsd |
5668 | rep movsd |
5606 | 5669 | ||
5607 | call restorefatchain |
5670 | call restorefatchain |
5608 | 5671 | ||
5609 | call IRQ_mask_all |
5672 | call IRQ_mask_all |
5610 | 5673 | ||
5611 | if 0 |
5674 | if 0 |
5612 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5675 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5613 | mov word [OS_BASE+0x467+2], 0x1000 |
5676 | mov word [OS_BASE+0x467+2], 0x1000 |
5614 | 5677 | ||
5615 | mov al, 0x0F |
5678 | mov al, 0x0F |
5616 | out 0x70, al |
5679 | out 0x70, al |
5617 | mov al, 0x05 |
5680 | mov al, 0x05 |
5618 | out 0x71, al |
5681 | out 0x71, al |
5619 | 5682 | ||
5620 | mov al, 0xFE |
5683 | mov al, 0xFE |
5621 | out 0x64, al |
5684 | out 0x64, al |
5622 | 5685 | ||
5623 | hlt |
5686 | hlt |
5624 | jmp $-1 |
5687 | jmp $-1 |
5625 | 5688 | ||
5626 | else |
5689 | else |
5627 | cmp byte [OS_BASE + 0x9030], 2 |
5690 | cmp byte [OS_BASE + 0x9030], 2 |
5628 | jnz no_acpi_power_off |
5691 | jnz no_acpi_power_off |
5629 | 5692 | ||
5630 | ; scan for RSDP |
5693 | ; scan for RSDP |
5631 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5694 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5632 | movzx eax, word [OS_BASE + 0x40E] |
5695 | movzx eax, word [OS_BASE + 0x40E] |
5633 | shl eax, 4 |
5696 | shl eax, 4 |
5634 | jz @f |
5697 | jz @f |
5635 | mov ecx, 1024/16 |
5698 | mov ecx, 1024/16 |
5636 | call scan_rsdp |
5699 | call scan_rsdp |
5637 | jnc .rsdp_found |
5700 | jnc .rsdp_found |
5638 | @@: |
5701 | @@: |
5639 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5702 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5640 | mov eax, 0xE0000 |
5703 | mov eax, 0xE0000 |
5641 | mov ecx, 0x2000 |
5704 | mov ecx, 0x2000 |
5642 | call scan_rsdp |
5705 | call scan_rsdp |
5643 | jc no_acpi_power_off |
5706 | jc no_acpi_power_off |
5644 | .rsdp_found: |
5707 | .rsdp_found: |
5645 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5708 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5646 | mov ebp, [ipc_tmp] |
5709 | mov ebp, [ipc_tmp] |
5647 | stdcall map_page, ebp, esi, PG_MAP |
5710 | stdcall map_page, ebp, esi, PG_MAP |
5648 | lea eax, [esi+1000h] |
5711 | lea eax, [esi+1000h] |
5649 | lea edx, [ebp+1000h] |
5712 | lea edx, [ebp+1000h] |
5650 | stdcall map_page, edx, eax, PG_MAP |
5713 | stdcall map_page, edx, eax, PG_MAP |
5651 | and esi, 0xFFF |
5714 | and esi, 0xFFF |
5652 | add esi, ebp |
5715 | add esi, ebp |
5653 | cmp dword [esi], 'RSDT' |
5716 | cmp dword [esi], 'RSDT' |
5654 | jnz no_acpi_power_off |
5717 | jnz no_acpi_power_off |
5655 | mov ecx, [esi+4] |
5718 | mov ecx, [esi+4] |
5656 | sub ecx, 24h |
5719 | sub ecx, 24h |
5657 | jbe no_acpi_power_off |
5720 | jbe no_acpi_power_off |
5658 | shr ecx, 2 |
5721 | shr ecx, 2 |
5659 | add esi, 24h |
5722 | add esi, 24h |
5660 | .scan_fadt: |
5723 | .scan_fadt: |
5661 | lodsd |
5724 | lodsd |
5662 | mov ebx, eax |
5725 | mov ebx, eax |
5663 | lea eax, [ebp+2000h] |
5726 | lea eax, [ebp+2000h] |
5664 | stdcall map_page, eax, ebx, PG_MAP |
5727 | stdcall map_page, eax, ebx, PG_MAP |
5665 | lea eax, [ebp+3000h] |
5728 | lea eax, [ebp+3000h] |
5666 | add ebx, 0x1000 |
5729 | add ebx, 0x1000 |
5667 | stdcall map_page, eax, ebx, PG_MAP |
5730 | stdcall map_page, eax, ebx, PG_MAP |
5668 | and ebx, 0xFFF |
5731 | and ebx, 0xFFF |
5669 | lea ebx, [ebx+ebp+2000h] |
5732 | lea ebx, [ebx+ebp+2000h] |
5670 | cmp dword [ebx], 'FACP' |
5733 | cmp dword [ebx], 'FACP' |
5671 | jz .fadt_found |
5734 | jz .fadt_found |
5672 | loop .scan_fadt |
5735 | loop .scan_fadt |
5673 | jmp no_acpi_power_off |
5736 | jmp no_acpi_power_off |
5674 | .fadt_found: |
5737 | .fadt_found: |
5675 | ; ebx is linear address of FADT |
5738 | ; ebx is linear address of FADT |
5676 | mov edi, [ebx+40] ; physical address of the DSDT |
5739 | mov edi, [ebx+40] ; physical address of the DSDT |
5677 | lea eax, [ebp+4000h] |
5740 | lea eax, [ebp+4000h] |
5678 | stdcall map_page, eax, edi, PG_MAP |
5741 | stdcall map_page, eax, edi, PG_MAP |
5679 | lea eax, [ebp+5000h] |
5742 | lea eax, [ebp+5000h] |
5680 | lea esi, [edi+0x1000] |
5743 | lea esi, [edi+0x1000] |
5681 | stdcall map_page, eax, esi, PG_MAP |
5744 | stdcall map_page, eax, esi, PG_MAP |
5682 | and esi, 0xFFF |
5745 | and esi, 0xFFF |
5683 | sub edi, esi |
5746 | sub edi, esi |
5684 | cmp dword [esi+ebp+4000h], 'DSDT' |
5747 | cmp dword [esi+ebp+4000h], 'DSDT' |
5685 | jnz no_acpi_power_off |
5748 | jnz no_acpi_power_off |
5686 | mov eax, [esi+ebp+4004h] ; DSDT length |
5749 | mov eax, [esi+ebp+4004h] ; DSDT length |
5687 | sub eax, 36+4 |
5750 | sub eax, 36+4 |
5688 | jbe no_acpi_power_off |
5751 | jbe no_acpi_power_off |
5689 | add esi, 36 |
5752 | add esi, 36 |
5690 | .scan_dsdt: |
5753 | .scan_dsdt: |
5691 | cmp dword [esi+ebp+4000h], '_S5_' |
5754 | cmp dword [esi+ebp+4000h], '_S5_' |
5692 | jnz .scan_dsdt_cont |
5755 | jnz .scan_dsdt_cont |
5693 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5756 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5694 | jnz .scan_dsdt_cont |
5757 | jnz .scan_dsdt_cont |
5695 | mov dl, [esi+ebp+4000h+6] |
5758 | mov dl, [esi+ebp+4000h+6] |
5696 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5759 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5697 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5760 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5698 | ja .scan_dsdt_cont |
5761 | ja .scan_dsdt_cont |
5699 | cmp dl, 1 |
5762 | cmp dl, 1 |
5700 | jb .scan_dsdt_cont |
5763 | jb .scan_dsdt_cont |
5701 | lea esi, [esi+ebp+4000h+7] |
5764 | lea esi, [esi+ebp+4000h+7] |
5702 | xor ecx, ecx |
5765 | xor ecx, ecx |
5703 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5766 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5704 | jz @f |
5767 | jz @f |
5705 | cmp byte [esi], 0xA |
5768 | cmp byte [esi], 0xA |
5706 | jnz no_acpi_power_off |
5769 | jnz no_acpi_power_off |
5707 | inc esi |
5770 | inc esi |
5708 | mov cl, [esi] |
5771 | mov cl, [esi] |
5709 | @@: |
5772 | @@: |
5710 | inc esi |
5773 | inc esi |
5711 | cmp dl, 2 |
5774 | cmp dl, 2 |
5712 | jb @f |
5775 | jb @f |
5713 | cmp byte [esi], 0 |
5776 | cmp byte [esi], 0 |
5714 | jz @f |
5777 | jz @f |
5715 | cmp byte [esi], 0xA |
5778 | cmp byte [esi], 0xA |
5716 | jnz no_acpi_power_off |
5779 | jnz no_acpi_power_off |
5717 | inc esi |
5780 | inc esi |
5718 | mov ch, [esi] |
5781 | mov ch, [esi] |
5719 | @@: |
5782 | @@: |
5720 | jmp do_acpi_power_off |
5783 | jmp do_acpi_power_off |
5721 | .scan_dsdt_cont: |
5784 | .scan_dsdt_cont: |
5722 | inc esi |
5785 | inc esi |
5723 | cmp esi, 0x1000 |
5786 | cmp esi, 0x1000 |
5724 | jb @f |
5787 | jb @f |
5725 | sub esi, 0x1000 |
5788 | sub esi, 0x1000 |
5726 | add edi, 0x1000 |
5789 | add edi, 0x1000 |
5727 | push eax |
5790 | push eax |
5728 | lea eax, [ebp+4000h] |
5791 | lea eax, [ebp+4000h] |
5729 | stdcall map_page, eax, edi, PG_MAP |
5792 | stdcall map_page, eax, edi, PG_MAP |
5730 | push PG_MAP |
5793 | push PG_MAP |
5731 | lea eax, [edi+1000h] |
5794 | lea eax, [edi+1000h] |
5732 | push eax |
5795 | push eax |
5733 | lea eax, [ebp+5000h] |
5796 | lea eax, [ebp+5000h] |
5734 | push eax |
5797 | push eax |
5735 | stdcall map_page |
5798 | stdcall map_page |
5736 | pop eax |
5799 | pop eax |
5737 | @@: |
5800 | @@: |
5738 | dec eax |
5801 | dec eax |
5739 | jnz .scan_dsdt |
5802 | jnz .scan_dsdt |
5740 | jmp no_acpi_power_off |
5803 | jmp no_acpi_power_off |
5741 | do_acpi_power_off: |
5804 | do_acpi_power_off: |
5742 | mov edx, [ebx+48] |
5805 | mov edx, [ebx+48] |
5743 | test edx, edx |
5806 | test edx, edx |
5744 | jz .nosmi |
5807 | jz .nosmi |
5745 | mov al, [ebx+52] |
5808 | mov al, [ebx+52] |
5746 | out dx, al |
5809 | out dx, al |
5747 | mov edx, [ebx+64] |
5810 | mov edx, [ebx+64] |
5748 | @@: |
5811 | @@: |
5749 | in ax, dx |
5812 | in ax, dx |
5750 | test al, 1 |
5813 | test al, 1 |
5751 | jz @b |
5814 | jz @b |
5752 | .nosmi: |
5815 | .nosmi: |
5753 | and cx, 0x0707 |
5816 | and cx, 0x0707 |
5754 | shl cx, 2 |
5817 | shl cx, 2 |
5755 | or cx, 0x2020 |
5818 | or cx, 0x2020 |
5756 | mov edx, [ebx+64] |
5819 | mov edx, [ebx+64] |
5757 | in ax, dx |
5820 | in ax, dx |
5758 | and ax, 203h |
5821 | and ax, 203h |
5759 | or ah, cl |
5822 | or ah, cl |
5760 | out dx, ax |
5823 | out dx, ax |
5761 | mov edx, [ebx+68] |
5824 | mov edx, [ebx+68] |
5762 | test edx, edx |
5825 | test edx, edx |
5763 | jz @f |
5826 | jz @f |
5764 | in ax, dx |
5827 | in ax, dx |
5765 | and ax, 203h |
5828 | and ax, 203h |
5766 | or ah, ch |
5829 | or ah, ch |
5767 | out dx, ax |
5830 | out dx, ax |
5768 | @@: |
5831 | @@: |
5769 | jmp $ |
5832 | jmp $ |
5770 | 5833 | ||
5771 | 5834 | ||
5772 | no_acpi_power_off: |
5835 | no_acpi_power_off: |
5773 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5836 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5774 | mov word [OS_BASE+0x467+2], 0x1000 |
5837 | mov word [OS_BASE+0x467+2], 0x1000 |
5775 | 5838 | ||
5776 | mov al, 0x0F |
5839 | mov al, 0x0F |
5777 | out 0x70, al |
5840 | out 0x70, al |
5778 | mov al, 0x05 |
5841 | mov al, 0x05 |
5779 | out 0x71, al |
5842 | out 0x71, al |
5780 | 5843 | ||
5781 | mov al, 0xFE |
5844 | mov al, 0xFE |
5782 | out 0x64, al |
5845 | out 0x64, al |
5783 | 5846 | ||
5784 | hlt |
5847 | hlt |
5785 | jmp $-1 |
5848 | jmp $-1 |
5786 | 5849 | ||
5787 | scan_rsdp: |
5850 | scan_rsdp: |
5788 | add eax, OS_BASE |
5851 | add eax, OS_BASE |
5789 | .s: |
5852 | .s: |
5790 | cmp dword [eax], 'RSD ' |
5853 | cmp dword [eax], 'RSD ' |
5791 | jnz .n |
5854 | jnz .n |
5792 | cmp dword [eax+4], 'PTR ' |
5855 | cmp dword [eax+4], 'PTR ' |
5793 | jnz .n |
5856 | jnz .n |
5794 | xor edx, edx |
5857 | xor edx, edx |
5795 | xor esi, esi |
5858 | xor esi, esi |
5796 | @@: |
5859 | @@: |
5797 | add dl, [eax+esi] |
5860 | add dl, [eax+esi] |
5798 | inc esi |
5861 | inc esi |
5799 | cmp esi, 20 |
5862 | cmp esi, 20 |
5800 | jnz @b |
5863 | jnz @b |
5801 | test dl, dl |
5864 | test dl, dl |
5802 | jz .ok |
5865 | jz .ok |
5803 | .n: |
5866 | .n: |
5804 | add eax, 10h |
5867 | add eax, 10h |
5805 | loop .s |
5868 | loop .s |
5806 | stc |
5869 | stc |
5807 | .ok: |
5870 | .ok: |
5808 | ret |
5871 | ret |
5809 | end if |
5872 | end if |
5810 | 5873 | ||
5811 | if ~ lang eq sp |
5874 | if ~ lang eq sp |
5812 | diff16 "end of .text segment",0,$ |
5875 | diff16 "end of .text segment",0,$ |
5813 | end if |
5876 | end if |
5814 | 5877 | ||
5815 | include "data32.inc" |
5878 | include "data32.inc" |
5816 | 5879 | ||
5817 | __REV__ = __REV |
5880 | __REV__ = __REV |
5818 | 5881 | ||
5819 | uglobals_size = $ - endofcode |
5882 | uglobals_size = $ - endofcode |
5820 | if ~ lang eq sp |
5883 | if ~ lang eq sp |
5821 | diff16 "end of kernel code",0,$ |
5884 | diff16 "end of kernel code",0,$ |
5822 | end if=> |
5885 | end if=> |