Rev 4993 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4993 | Rev 5116 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
4 | ;; PROGRAMMING: |
4 | ;; PROGRAMMING: |
5 | ;; Ivan Poddubny |
5 | ;; Ivan Poddubny |
6 | ;; Marat Zakiyanov (Mario79) |
6 | ;; Marat Zakiyanov (Mario79) |
7 | ;; VaStaNi |
7 | ;; VaStaNi |
8 | ;; Trans |
8 | ;; Trans |
9 | ;; Mihail Semenyako (mike.dld) |
9 | ;; Mihail Semenyako (mike.dld) |
10 | ;; Sergey Kuzmin (Wildwest) |
10 | ;; Sergey Kuzmin (Wildwest) |
11 | ;; Andrey Halyavin (halyavin) |
11 | ;; Andrey Halyavin (halyavin) |
12 | ;; Mihail Lisovin (Mihasik) |
12 | ;; Mihail Lisovin (Mihasik) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
14 | ;; NoName |
14 | ;; NoName |
15 | ;; Evgeny Grechnikov (Diamond) |
15 | ;; Evgeny Grechnikov (Diamond) |
16 | ;; Iliya Mihailov (Ghost) |
16 | ;; Iliya Mihailov (Ghost) |
17 | ;; Sergey Semyonov (Serge) |
17 | ;; Sergey Semyonov (Serge) |
18 | ;; Johnny_B |
18 | ;; Johnny_B |
19 | ;; SPraid (simba) |
19 | ;; SPraid (simba) |
20 | ;; Hidnplayr |
20 | ;; Hidnplayr |
21 | ;; Alexey Teplov ( |
21 | ;; Alexey Teplov ( |
22 | ;; Rus |
22 | ;; Rus |
23 | ;; Nable |
23 | ;; Nable |
24 | ;; shurf |
24 | ;; shurf |
25 | ;; Alver |
25 | ;; Alver |
26 | ;; Maxis |
26 | ;; Maxis |
27 | ;; Galkov |
27 | ;; Galkov |
28 | ;; CleverMouse |
28 | ;; CleverMouse |
29 | ;; tsdima |
29 | ;; tsdima |
30 | ;; turbanoff |
30 | ;; turbanoff |
31 | ;; Asper |
31 | ;; Asper |
32 | ;; art_zh |
32 | ;; art_zh |
33 | ;; |
33 | ;; |
34 | ;; Data in this file was originally part of MenuetOS project which is |
34 | ;; Data in this file was originally part of MenuetOS project which is |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
37 | ;; |
37 | ;; |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
39 | ;; PROGRAMMING: |
39 | ;; PROGRAMMING: |
40 | ;; |
40 | ;; |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
42 | ;; - main os coding/design |
42 | ;; - main os coding/design |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
46 | ;; quickcode@mail.ru |
46 | ;; quickcode@mail.ru |
47 | ;; Alexey, kgaz@crosswinds.net |
47 | ;; Alexey, kgaz@crosswinds.net |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
49 | ;; kristol@nic.fi |
49 | ;; kristol@nic.fi |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
53 | ;; |
53 | ;; |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
58 | ;; License (the "GPL") for full details. |
58 | ;; License (the "GPL") for full details. |
59 | ; |
59 | ; |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
65 | ;; on all copies. |
65 | ;; on all copies. |
66 | ;; |
66 | ;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
68 | 68 | ||
69 | format binary as "mnt" |
69 | format binary as "mnt" |
70 | 70 | ||
71 | include 'macros.inc' |
71 | include 'macros.inc' |
72 | include 'struct.inc' |
72 | include 'struct.inc' |
73 | 73 | ||
74 | $Revision: 4381 $ |
74 | $Revision: 4381 $ |
75 | 75 | ||
76 | - | ||
77 | USE_FIX_FOR_INVALID_MS_VIRTUAL_PC_2007 equ 0 |
- | |
78 | 76 | ||
79 | 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 |
80 | 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 |
81 | 79 | ||
82 | ; Enabling the next line will enable serial output console |
80 | ; Enabling the next line will enable serial output console |
83 | ;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 |
84 | 82 | ||
85 | include "proc32.inc" |
83 | include "proc32.inc" |
86 | include "kglobals.inc" |
84 | include "kglobals.inc" |
87 | include "lang.inc" |
85 | include "lang.inc" |
88 | include "encoding.inc" |
86 | include "encoding.inc" |
89 | 87 | ||
90 | include "const.inc" |
88 | include "const.inc" |
91 | 89 | ||
92 | iglobal |
90 | iglobal |
93 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
94 | debug_direct_print db 0 |
92 | debug_direct_print db 0 |
95 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
96 | launcher_start db 1 |
94 | launcher_start db 1 |
97 | endg |
95 | endg |
98 | 96 | ||
99 | max_processes equ 255 |
97 | max_processes equ 255 |
100 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
101 | 99 | ||
102 | os_stack equ (os_data_l-gdts) ; GDTs |
100 | os_stack equ (os_data_l-gdts) ; GDTs |
103 | os_code equ (os_code_l-gdts) |
101 | os_code equ (os_code_l-gdts) |
104 | graph_data equ (3+graph_data_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
105 | tss0 equ (tss0_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
106 | app_code equ (3+app_code_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
107 | app_data equ (3+app_data_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
108 | app_tls equ (3+tls_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
109 | pci_code_sel equ (pci_code_32-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
110 | pci_data_sel equ (pci_data_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
111 | 109 | ||
112 | 110 | ||
113 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
114 | ;; |
112 | ;; |
115 | ;; Included files: |
113 | ;; Included files: |
116 | ;; |
114 | ;; |
117 | ;; Kernel16.inc |
115 | ;; Kernel16.inc |
118 | ;; - Booteng.inc English text for bootup |
116 | ;; - Booteng.inc English text for bootup |
119 | ;; - Bootcode.inc Hardware setup |
117 | ;; - Bootcode.inc Hardware setup |
120 | ;; - Pci16.inc PCI functions |
118 | ;; - Pci16.inc PCI functions |
121 | ;; |
119 | ;; |
122 | ;; Kernel32.inc |
120 | ;; Kernel32.inc |
123 | ;; - Sys32.inc Process management |
121 | ;; - Sys32.inc Process management |
124 | ;; - Shutdown.inc Shutdown and restart |
122 | ;; - Shutdown.inc Shutdown and restart |
125 | ;; - Fat32.inc Read / write hd |
123 | ;; - Fat32.inc Read / write hd |
126 | ;; - Vesa12.inc Vesa 1.2 driver |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
127 | ;; - Vesa20.inc Vesa 2.0 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
128 | ;; - Vga.inc VGA driver |
126 | ;; - Vga.inc VGA driver |
129 | ;; - Stack.inc Network interface |
127 | ;; - Stack.inc Network interface |
130 | ;; - Mouse.inc Mouse pointer |
128 | ;; - Mouse.inc Mouse pointer |
131 | ;; - Scincode.inc Window skinning |
129 | ;; - Scincode.inc Window skinning |
132 | ;; - Pci32.inc PCI functions |
130 | ;; - Pci32.inc PCI functions |
133 | ;; |
131 | ;; |
134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
135 | 133 | ||
136 | 134 | ||
137 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
138 | ;; ;; |
136 | ;; ;; |
139 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
140 | ;; ;; |
138 | ;; ;; |
141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
142 | 140 | ||
143 | use16 |
141 | use16 |
144 | org 0x0 |
142 | org 0x0 |
145 | jmp start_of_code |
143 | jmp start_of_code |
146 | 144 | ||
147 | if lang eq sp |
145 | if lang eq sp |
148 | include "kernelsp.inc" ; spanish kernel messages |
146 | include "kernelsp.inc" ; spanish kernel messages |
149 | else if lang eq et |
147 | else if lang eq et |
150 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
151 | else |
149 | else |
152 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
153 | end if |
151 | end if |
154 | 152 | ||
155 | include "boot/bootstr.inc" ; language-independent boot messages |
153 | include "boot/bootstr.inc" ; language-independent boot messages |
156 | include "boot/preboot.inc" |
154 | include "boot/preboot.inc" |
157 | 155 | ||
158 | if lang eq ge |
156 | if lang eq ge |
159 | include "boot/bootge.inc" ; german system boot messages |
157 | include "boot/bootge.inc" ; german system boot messages |
160 | else if lang eq sp |
158 | else if lang eq sp |
161 | include "boot/bootsp.inc" ; spanish system boot messages |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
162 | else if lang eq ru |
160 | else if lang eq ru |
163 | include "boot/bootru.inc" ; russian system boot messages |
161 | include "boot/bootru.inc" ; russian system boot messages |
164 | include "boot/ru.inc" ; Russian font |
162 | include "boot/ru.inc" ; Russian font |
165 | else if lang eq et |
163 | else if lang eq et |
166 | include "boot/bootet.inc" ; estonian system boot messages |
164 | include "boot/bootet.inc" ; estonian system boot messages |
167 | include "boot/et.inc" ; Estonian font |
165 | include "boot/et.inc" ; Estonian font |
168 | else |
166 | else |
169 | include "boot/booten.inc" ; english system boot messages |
167 | include "boot/booten.inc" ; english system boot messages |
170 | end if |
168 | end if |
171 | 169 | ||
172 | include "boot/bootcode.inc" ; 16 bit system boot code |
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
173 | include "bus/pci/pci16.inc" |
171 | include "bus/pci/pci16.inc" |
174 | include "detect/biosdisk.inc" |
172 | include "detect/biosdisk.inc" |
175 | 173 | ||
176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
177 | ;; ;; |
175 | ;; ;; |
178 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
179 | ;; ;; |
177 | ;; ;; |
180 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
181 | 179 | ||
182 | cld |
180 | cld |
183 | 181 | ||
184 | ; Enabling 32 bit protected mode |
182 | ; Enabling 32 bit protected mode |
185 | 183 | ||
186 | mov ecx, CR0_PE ; CR0 Flags - Protected mode and Paging |
184 | mov ecx, CR0_PE ; CR0 Flags - Protected mode and Paging |
187 | lgdt [cs:tmp_gdt] ; Load GDT |
185 | lgdt [cs:tmp_gdt] ; Load GDT |
188 | mov eax, cr0 ; protected mode |
186 | mov eax, cr0 ; protected mode |
189 | or eax, ecx |
187 | or eax, ecx |
190 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
188 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
191 | mov cr0, eax |
189 | mov cr0, eax |
192 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
190 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
193 | 191 | ||
194 | align 8 |
192 | align 8 |
195 | tmp_gdt: |
193 | tmp_gdt: |
196 | 194 | ||
197 | dw 23 |
195 | dw 23 |
198 | dd tmp_gdt+0x10000 |
196 | dd tmp_gdt+0x10000 |
199 | dw 0 |
197 | dw 0 |
200 | 198 | ||
201 | dw 0xffff |
199 | dw 0xffff |
202 | dw 0x0000 |
200 | dw 0x0000 |
203 | db 0x00 |
201 | db 0x00 |
204 | dw 11011111b *256 +10011010b |
202 | dw 11011111b *256 +10011010b |
205 | db 0x00 |
203 | db 0x00 |
206 | 204 | ||
207 | dw 0xffff |
205 | dw 0xffff |
208 | dw 0x0000 |
206 | dw 0x0000 |
209 | db 0x00 |
207 | db 0x00 |
210 | dw 11011111b *256 +10010010b |
208 | dw 11011111b *256 +10010010b |
211 | db 0x00 |
209 | db 0x00 |
212 | 210 | ||
213 | include "data16.inc" |
211 | include "data16.inc" |
214 | 212 | ||
215 | if ~ lang eq sp |
213 | if ~ lang eq sp |
216 | diff16 "end of bootcode",0,$+0x10000 |
214 | diff16 "end of bootcode",0,$+0x10000 |
217 | end if |
215 | end if |
218 | 216 | ||
219 | use32 |
217 | use32 |
220 | org $+0x10000 |
218 | org $+0x10000 |
221 | 219 | ||
222 | align 4 |
220 | align 4 |
223 | B32: |
221 | B32: |
224 | mov ax, os_stack ; Selector for os |
222 | mov ax, os_stack ; Selector for os |
225 | mov ds, ax |
223 | mov ds, ax |
226 | mov es, ax |
224 | mov es, ax |
227 | mov fs, ax |
225 | mov fs, ax |
228 | mov gs, ax |
226 | mov gs, ax |
229 | mov ss, ax |
227 | mov ss, ax |
230 | mov esp, 0x006CC00 ; Set stack |
228 | mov esp, 0x006CC00 ; Set stack |
231 | 229 | ||
232 | ; CLEAR 0x280000 - HEAP_BASE |
230 | ; CLEAR 0x280000 - HEAP_BASE |
233 | 231 | ||
234 | xor eax, eax |
232 | xor eax, eax |
235 | mov edi, CLEAN_ZONE |
233 | mov edi, CLEAN_ZONE |
236 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
234 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
237 | cld |
235 | cld |
238 | rep stosd |
236 | rep stosd |
239 | 237 | ||
240 | ; CLEAR KERNEL UNDEFINED GLOBALS |
238 | ; CLEAR KERNEL UNDEFINED GLOBALS |
241 | mov edi, endofcode-OS_BASE |
239 | mov edi, endofcode-OS_BASE |
242 | mov ecx, 0x90000 |
240 | mov ecx, 0x90000 |
243 | sub ecx, edi |
241 | sub ecx, edi |
244 | shr ecx, 2 |
242 | shr ecx, 2 |
245 | rep stosd |
243 | rep stosd |
246 | 244 | ||
247 | ; SAVE & CLEAR 0-0xffff |
245 | ; SAVE & CLEAR 0-0xffff |
248 | 246 | ||
249 | mov edi, 0x1000 |
247 | mov edi, 0x1000 |
250 | mov ecx, 0x8000 / 4 |
248 | mov ecx, 0x8000 / 4 |
251 | rep stosd |
249 | rep stosd |
252 | mov edi, 0xa000 |
250 | mov edi, 0xa000 |
253 | mov ecx, 0x6000 / 4 |
251 | mov ecx, 0x6000 / 4 |
254 | rep stosd |
252 | rep stosd |
255 | 253 | ||
256 | call test_cpu |
254 | call test_cpu |
257 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
255 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
258 | 256 | ||
259 | call check_acpi |
257 | call check_acpi |
260 | call init_BIOS32 |
258 | call init_BIOS32 |
261 | ; MEMORY MODEL |
259 | ; MEMORY MODEL |
262 | call mem_test |
260 | call mem_test |
263 | call init_mem |
261 | call init_mem |
264 | call init_page_map |
262 | call init_page_map |
265 | 263 | ||
266 | ; ENABLE PAGING |
264 | ; ENABLE PAGING |
267 | 265 | ||
268 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
266 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
269 | mov cr3, eax |
267 | mov cr3, eax |
270 | 268 | ||
271 | mov eax, cr0 |
269 | mov eax, cr0 |
272 | or eax, CR0_PG+CR0_WP |
270 | or eax, CR0_PG+CR0_WP |
273 | mov cr0, eax |
271 | mov cr0, eax |
274 | 272 | ||
275 | lgdt [gdts] |
273 | lgdt [gdts] |
276 | jmp pword os_code:high_code |
274 | jmp pword os_code:high_code |
277 | 275 | ||
278 | align 4 |
276 | align 4 |
279 | bios32_entry dd ? |
277 | bios32_entry dd ? |
280 | tmp_page_tabs dd ? |
278 | tmp_page_tabs dd ? |
281 | 279 | ||
282 | use16 |
280 | use16 |
283 | org $-0x10000 |
281 | org $-0x10000 |
284 | include "boot/shutdown.inc" ; shutdown or restart |
282 | include "boot/shutdown.inc" ; shutdown or restart |
285 | org $+0x10000 |
283 | org $+0x10000 |
- | 284 | ||
- | 285 | ap_init16: |
|
- | 286 | cli |
|
- | 287 | lgdt [cs:gdts_ap-ap_init16] |
|
- | 288 | mov eax, [cs:cr3_ap-ap_init16] |
|
- | 289 | mov cr3, eax |
|
- | 290 | mov eax, [cs:cr4_ap-ap_init16] |
|
- | 291 | mov cr4, eax |
|
- | 292 | mov eax, CR0_PE+CR0_PG+CR0_WP |
|
- | 293 | mov cr0, eax |
|
- | 294 | jmp pword os_code:ap_init_high |
|
- | 295 | align 16 |
|
- | 296 | gdts_ap: |
|
- | 297 | dw gdte-gdts-1 |
|
- | 298 | dd gdts |
|
- | 299 | dw 0 |
|
- | 300 | cr3_ap dd ? |
|
- | 301 | cr4_ap dd ? |
|
- | 302 | ap_init16_size = $ - ap_init16 |
|
286 | use32 |
303 | use32 |
287 | 304 | ||
288 | __DEBUG__ fix 1 |
305 | __DEBUG__ fix 1 |
289 | __DEBUG_LEVEL__ fix 1 |
306 | __DEBUG_LEVEL__ fix 1 |
290 | include 'init.inc' |
307 | include 'init.inc' |
291 | 308 | ||
292 | org OS_BASE+$ |
309 | org OS_BASE+$ |
293 | 310 | ||
294 | include 'fdo.inc' |
311 | include 'fdo.inc' |
295 | 312 | ||
296 | align 4 |
313 | align 4 |
297 | high_code: |
314 | high_code: |
298 | mov ax, os_stack |
315 | mov ax, os_stack |
299 | mov bx, app_data |
316 | mov bx, app_data |
300 | mov cx, app_tls |
317 | mov cx, app_tls |
301 | mov ss, ax |
318 | mov ss, ax |
302 | add esp, OS_BASE |
319 | add esp, OS_BASE |
303 | 320 | ||
304 | mov ds, bx |
321 | mov ds, bx |
305 | mov es, bx |
322 | mov es, bx |
306 | mov fs, cx |
323 | mov fs, cx |
307 | mov gs, bx |
324 | mov gs, bx |
308 | 325 | ||
309 | bt [cpu_caps], CAPS_PGE |
326 | bt [cpu_caps], CAPS_PGE |
310 | jnc @F |
327 | jnc @F |
311 | 328 | ||
312 | or dword [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], PG_GLOBAL |
329 | or dword [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], PG_GLOBAL |
313 | 330 | ||
314 | mov ebx, cr4 |
331 | mov ebx, cr4 |
315 | or ebx, CR4_PGE |
332 | or ebx, CR4_PGE |
316 | mov cr4, ebx |
333 | mov cr4, ebx |
317 | @@: |
334 | @@: |
318 | xor eax, eax |
335 | xor eax, eax |
319 | mov dword [sys_proc+PROC.pdt_0], eax |
336 | mov dword [sys_proc+PROC.pdt_0], eax |
320 | mov dword [sys_proc+PROC.pdt_0+4], eax |
337 | mov dword [sys_proc+PROC.pdt_0+4], eax |
321 | 338 | ||
322 | mov eax, cr3 |
339 | mov eax, cr3 |
323 | mov cr3, eax ; flush TLB |
340 | mov cr3, eax ; flush TLB |
324 | 341 | ||
325 | mov ecx, pg_data.mutex |
342 | mov ecx, pg_data.mutex |
326 | call mutex_init |
343 | call mutex_init |
327 | 344 | ||
328 | mov ecx, disk_list_mutex |
345 | mov ecx, disk_list_mutex |
329 | call mutex_init |
346 | call mutex_init |
330 | 347 | ||
331 | mov ecx, keyboard_list_mutex |
348 | mov ecx, keyboard_list_mutex |
332 | call mutex_init |
349 | call mutex_init |
333 | 350 | ||
334 | mov ecx, unpack_mutex |
351 | mov ecx, unpack_mutex |
335 | call mutex_init |
352 | call mutex_init |
336 | 353 | ||
337 | mov ecx, application_table_mutex |
354 | mov ecx, application_table_mutex |
338 | call mutex_init |
355 | call mutex_init |
339 | 356 | ||
340 | mov ecx, ide_mutex |
357 | mov ecx, ide_mutex |
341 | call mutex_init |
358 | call mutex_init |
342 | mov ecx, ide_channel1_mutex |
359 | mov ecx, ide_channel1_mutex |
343 | call mutex_init |
360 | call mutex_init |
344 | mov ecx, ide_channel2_mutex |
361 | mov ecx, ide_channel2_mutex |
345 | call mutex_init |
362 | call mutex_init |
346 | mov ecx, ide_channel3_mutex |
363 | mov ecx, ide_channel3_mutex |
347 | call mutex_init |
364 | call mutex_init |
348 | mov ecx, ide_channel4_mutex |
365 | mov ecx, ide_channel4_mutex |
349 | call mutex_init |
366 | call mutex_init |
350 | mov ecx, ide_channel5_mutex |
367 | mov ecx, ide_channel5_mutex |
351 | call mutex_init |
368 | call mutex_init |
352 | mov ecx, ide_channel6_mutex |
369 | mov ecx, ide_channel6_mutex |
353 | call mutex_init |
370 | call mutex_init |
354 | ;----------------------------------------------------------------------------- |
371 | ;----------------------------------------------------------------------------- |
355 | ; SAVE REAL MODE VARIABLES |
372 | ; SAVE REAL MODE VARIABLES |
356 | ;----------------------------------------------------------------------------- |
373 | ;----------------------------------------------------------------------------- |
357 | ; --------------- APM --------------------- |
374 | ; --------------- APM --------------------- |
358 | 375 | ||
359 | ; init selectors |
376 | ; init selectors |
360 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
377 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
361 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
378 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
362 | ; protected-mode 32-bit code segment |
379 | ; protected-mode 32-bit code segment |
363 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
380 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
364 | ; protected-mode 16-bit code segment |
381 | ; protected-mode 16-bit code segment |
365 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
382 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
366 | ; protected-mode 16-bit data segment |
383 | ; protected-mode 16-bit data segment |
367 | 384 | ||
368 | shl eax, 4 |
385 | shl eax, 4 |
369 | mov [dword apm_code_32 + 2], ax |
386 | mov [dword apm_code_32 + 2], ax |
370 | shr eax, 16 |
387 | shr eax, 16 |
371 | mov [dword apm_code_32 + 4], al |
388 | mov [dword apm_code_32 + 4], al |
372 | 389 | ||
373 | shl ecx, 4 |
390 | shl ecx, 4 |
374 | mov [dword apm_code_16 + 2], cx |
391 | mov [dword apm_code_16 + 2], cx |
375 | shr ecx, 16 |
392 | shr ecx, 16 |
376 | mov [dword apm_code_16 + 4], cl |
393 | mov [dword apm_code_16 + 4], cl |
377 | 394 | ||
378 | shl edx, 4 |
395 | shl edx, 4 |
379 | mov [dword apm_data_16 + 2], dx |
396 | mov [dword apm_data_16 + 2], dx |
380 | shr edx, 16 |
397 | shr edx, 16 |
381 | mov [dword apm_data_16 + 4], dl |
398 | mov [dword apm_data_16 + 4], dl |
382 | 399 | ||
383 | mov dword[apm_entry], ebx |
400 | mov dword[apm_entry], ebx |
384 | mov word [apm_entry + 4], apm_code_32 - gdts |
401 | mov word [apm_entry + 4], apm_code_32 - gdts |
385 | 402 | ||
386 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
403 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
387 | mov [apm_vf], eax |
404 | mov [apm_vf], eax |
388 | ; ----------------------------------------- |
405 | ; ----------------------------------------- |
389 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
406 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
390 | mov [allow_dma_access], al |
407 | mov [allow_dma_access], al |
391 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
408 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
392 | mov [_display.bpp], eax |
409 | mov [_display.bpp], eax |
393 | mov [_display.vrefresh], 60 |
410 | mov [_display.vrefresh], 60 |
394 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
411 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
395 | mov [debug_direct_print], al |
412 | mov [debug_direct_print], al |
396 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
413 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
397 | mov [launcher_start], al |
414 | mov [launcher_start], al |
398 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
415 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
399 | mov [_display.width], eax |
416 | mov [_display.width], eax |
400 | mov [display_width_standard], eax |
417 | mov [display_width_standard], eax |
401 | dec eax |
418 | dec eax |
402 | mov [Screen_Max_X], eax |
419 | mov [Screen_Max_X], eax |
403 | mov [screen_workarea.right], eax |
420 | mov [screen_workarea.right], eax |
404 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
421 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
405 | mov [_display.height], eax |
422 | mov [_display.height], eax |
406 | mov [display_height_standard], eax |
423 | mov [display_height_standard], eax |
407 | dec eax |
424 | dec eax |
408 | mov [Screen_Max_Y], eax |
425 | mov [Screen_Max_Y], eax |
409 | mov [screen_workarea.bottom], eax |
426 | mov [screen_workarea.bottom], eax |
410 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
427 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
411 | mov dword [SCR_MODE], eax |
428 | mov dword [SCR_MODE], eax |
412 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
429 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
413 | ; mov [BANK_SWITCH], eax |
430 | ; mov [BANK_SWITCH], eax |
414 | mov eax, 640 *4 ; Bytes PerScanLine |
431 | mov eax, 640 *4 ; Bytes PerScanLine |
415 | cmp [SCR_MODE], word 0x13 ; 320x200 |
432 | cmp [SCR_MODE], word 0x13 ; 320x200 |
416 | je @f |
433 | je @f |
417 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
434 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
418 | je @f |
435 | je @f |
419 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
436 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
420 | @@: |
437 | @@: |
421 | mov [_display.pitch], eax |
438 | mov [_display.pitch], eax |
422 | mov eax, [_display.width] |
439 | mov eax, [_display.width] |
423 | mul [_display.height] |
440 | mul [_display.height] |
424 | mov [_WinMapSize], eax |
441 | mov [_WinMapSize], eax |
425 | 442 | ||
426 | call calculate_fast_getting_offset_for_WinMapAddress |
443 | call calculate_fast_getting_offset_for_WinMapAddress |
427 | ; for Qemu or non standart video cards |
444 | ; for Qemu or non standart video cards |
428 | ; Unfortunately [BytesPerScanLine] does not always |
445 | ; Unfortunately [BytesPerScanLine] does not always |
429 | ; equal to [_display.width] * [ScreenBPP] / 8 |
446 | ; equal to [_display.width] * [ScreenBPP] / 8 |
430 | call calculate_fast_getting_offset_for_LFB |
447 | call calculate_fast_getting_offset_for_LFB |
431 | 448 | ||
432 | mov esi, BOOT_VARS+0x9080 |
449 | mov esi, BOOT_VARS+0x9080 |
433 | movzx ecx, byte [esi-1] |
450 | movzx ecx, byte [esi-1] |
434 | mov [NumBiosDisks], ecx |
451 | mov [NumBiosDisks], ecx |
435 | mov edi, BiosDisksData |
452 | mov edi, BiosDisksData |
436 | rep movsd |
453 | rep movsd |
437 | 454 | ||
438 | ; GRAPHICS ADDRESSES |
455 | ; GRAPHICS ADDRESSES |
439 | 456 | ||
440 | mov eax, [BOOT_VARS+BOOT_LFB] |
457 | mov eax, [BOOT_VARS+BOOT_LFB] |
441 | mov [LFBAddress], eax |
458 | mov [LFBAddress], eax |
442 | 459 | ||
443 | cmp [SCR_MODE], word 0100000000000000b |
460 | cmp [SCR_MODE], word 0100000000000000b |
444 | jge setvesa20 |
461 | jge setvesa20 |
445 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
462 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
446 | je v20ga32 |
463 | je v20ga32 |
447 | jmp v20ga24 |
464 | jmp v20ga24 |
448 | 465 | ||
449 | setvesa20: |
466 | setvesa20: |
450 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
467 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
451 | mov [GETPIXEL], dword Vesa20_getpixel24 |
468 | mov [GETPIXEL], dword Vesa20_getpixel24 |
452 | cmp byte [_display.bpp], 24 |
469 | cmp byte [_display.bpp], 24 |
453 | jz v20ga24 |
470 | jz v20ga24 |
454 | v20ga32: |
471 | v20ga32: |
455 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
472 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
456 | mov [GETPIXEL], dword Vesa20_getpixel32 |
473 | mov [GETPIXEL], dword Vesa20_getpixel32 |
457 | jmp no_mode_0x12 |
474 | jmp no_mode_0x12 |
458 | v20ga24: |
475 | v20ga24: |
459 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
476 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
460 | jne no_mode_0x12 |
477 | jne no_mode_0x12 |
461 | mov [PUTPIXEL], dword VGA_putpixel |
478 | mov [PUTPIXEL], dword VGA_putpixel |
462 | mov [GETPIXEL], dword Vesa20_getpixel32 |
479 | mov [GETPIXEL], dword Vesa20_getpixel32 |
463 | no_mode_0x12: |
480 | no_mode_0x12: |
464 | 481 | ||
465 | mov [MOUSE_PICTURE], dword mousepointer |
482 | mov [MOUSE_PICTURE], dword mousepointer |
466 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
483 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
467 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
484 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
468 | 485 | ||
469 | ; -------- Fast System Call init ---------- |
486 | ; -------- Fast System Call init ---------- |
470 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
487 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
471 | bt [cpu_caps], CAPS_SEP |
488 | bt [cpu_caps], CAPS_SEP |
472 | jnc .SEnP ; SysEnter not Present |
489 | jnc .SEnP ; SysEnter not Present |
473 | xor edx, edx |
490 | xor edx, edx |
474 | mov ecx, MSR_SYSENTER_CS |
491 | mov ecx, MSR_SYSENTER_CS |
475 | mov eax, os_code |
492 | mov eax, os_code |
476 | wrmsr |
493 | wrmsr |
477 | mov ecx, MSR_SYSENTER_ESP |
494 | mov ecx, MSR_SYSENTER_ESP |
478 | ; mov eax, sysenter_stack ; Check it |
495 | ; mov eax, sysenter_stack ; Check it |
479 | xor eax, eax |
496 | xor eax, eax |
480 | wrmsr |
497 | wrmsr |
481 | mov ecx, MSR_SYSENTER_EIP |
498 | mov ecx, MSR_SYSENTER_EIP |
482 | mov eax, sysenter_entry |
499 | mov eax, sysenter_entry |
483 | wrmsr |
500 | wrmsr |
484 | .SEnP: |
501 | .SEnP: |
485 | ; AMD SYSCALL/SYSRET |
502 | ; AMD SYSCALL/SYSRET |
486 | cmp byte[cpu_vendor], 'A' |
503 | cmp byte[cpu_vendor], 'A' |
487 | jne .noSYSCALL |
504 | jne .noSYSCALL |
488 | mov eax, 0x80000001 |
505 | mov eax, 0x80000001 |
489 | cpuid |
506 | cpuid |
490 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
507 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
491 | jz .noSYSCALL |
508 | jz .noSYSCALL |
492 | mov ecx, MSR_AMD_EFER |
509 | mov ecx, MSR_AMD_EFER |
493 | rdmsr |
510 | rdmsr |
494 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
511 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
495 | wrmsr |
512 | wrmsr |
496 | 513 | ||
497 | ; !!!! It`s dirty hack, fix it !!! |
514 | ; !!!! It`s dirty hack, fix it !!! |
498 | ; Bits of EDX : |
515 | ; Bits of EDX : |
499 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
516 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
500 | ; and the contents of this field, plus 8, are copied into the SS register. |
517 | ; and the contents of this field, plus 8, are copied into the SS register. |
501 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
518 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
502 | ; and the contents of this field, plus 8, are copied into the SS register. |
519 | ; and the contents of this field, plus 8, are copied into the SS register. |
503 | 520 | ||
504 | ; mov edx, (os_code + 16) * 65536 + os_code |
521 | ; mov edx, (os_code + 16) * 65536 + os_code |
505 | mov edx, 0x1B0008 |
522 | mov edx, 0x1B0008 |
506 | 523 | ||
507 | mov eax, syscall_entry |
524 | mov eax, syscall_entry |
508 | mov ecx, MSR_AMD_STAR |
525 | mov ecx, MSR_AMD_STAR |
509 | wrmsr |
526 | wrmsr |
510 | .noSYSCALL: |
527 | .noSYSCALL: |
511 | ; ----------------------------------------- |
528 | ; ----------------------------------------- |
512 | stdcall alloc_page |
529 | stdcall alloc_page |
513 | stdcall map_page, tss-0xF80, eax, PG_SW |
530 | stdcall map_page, tss-0xF80, eax, PG_SW |
514 | stdcall alloc_page |
531 | stdcall alloc_page |
515 | stdcall map_page, tss+0x80, eax, PG_SW |
532 | stdcall map_page, tss+0x80, eax, PG_SW |
516 | stdcall alloc_page |
533 | stdcall alloc_page |
517 | stdcall map_page, tss+0x1080, eax, PG_SW |
534 | stdcall map_page, tss+0x1080, eax, PG_SW |
518 | 535 | ||
519 | ; LOAD IDT |
536 | ; LOAD IDT |
520 | 537 | ||
521 | call build_interrupt_table ;lidt is executed |
538 | call build_interrupt_table ;lidt is executed |
522 | ;lidt [idtreg] |
539 | ;lidt [idtreg] |
523 | 540 | ||
524 | call init_kernel_heap |
541 | call init_kernel_heap |
525 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
542 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
526 | mov [os_stack_seg], eax |
543 | mov [os_stack_seg], eax |
527 | 544 | ||
528 | lea esp, [eax+RING0_STACK_SIZE] |
545 | lea esp, [eax+RING0_STACK_SIZE] |
529 | 546 | ||
530 | mov [tss._ss0], os_stack |
547 | mov [tss._ss0], os_stack |
531 | mov [tss._esp0], esp |
548 | mov [tss._esp0], esp |
532 | mov [tss._esp], esp |
549 | mov [tss._esp], esp |
533 | mov [tss._cs], os_code |
550 | mov [tss._cs], os_code |
534 | mov [tss._ss], os_stack |
551 | mov [tss._ss], os_stack |
535 | mov [tss._ds], app_data |
552 | mov [tss._ds], app_data |
536 | mov [tss._es], app_data |
553 | mov [tss._es], app_data |
537 | mov [tss._fs], app_data |
554 | mov [tss._fs], app_data |
538 | mov [tss._gs], app_data |
555 | mov [tss._gs], app_data |
539 | mov [tss._io], 128 |
556 | mov [tss._io], 128 |
540 | ;Add IO access table - bit array of permitted ports |
557 | ;Add IO access table - bit array of permitted ports |
541 | mov edi, tss._io_map_0 |
558 | mov edi, tss._io_map_0 |
542 | xor eax, eax |
559 | xor eax, eax |
543 | not eax |
560 | not eax |
544 | mov ecx, 8192/4 |
561 | mov ecx, 8192/4 |
545 | rep stosd ; access to 4096*8=65536 ports |
562 | rep stosd ; access to 4096*8=65536 ports |
546 | 563 | ||
547 | mov ax, tss0 |
564 | mov ax, tss0 |
548 | ltr ax |
565 | ltr ax |
549 | 566 | ||
550 | mov [LFBSize], 0xC00000 |
567 | mov [LFBSize], 0xC00000 |
551 | call init_LFB |
568 | call init_LFB |
552 | call init_fpu |
569 | call init_fpu |
553 | call init_malloc |
570 | call init_malloc |
554 | 571 | ||
555 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
572 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
556 | mov [default_io_map], eax |
573 | mov [default_io_map], eax |
557 | 574 | ||
558 | add eax, 0x2000 |
575 | add eax, 0x2000 |
559 | mov [ipc_tmp], eax |
576 | mov [ipc_tmp], eax |
560 | mov ebx, 0x1000 |
577 | mov ebx, 0x1000 |
561 | 578 | ||
562 | add eax, 0x40000 |
579 | add eax, 0x40000 |
563 | mov [proc_mem_map], eax |
580 | mov [proc_mem_map], eax |
564 | 581 | ||
565 | add eax, 0x8000 |
582 | add eax, 0x8000 |
566 | mov [proc_mem_pdir], eax |
583 | mov [proc_mem_pdir], eax |
567 | 584 | ||
568 | add eax, ebx |
585 | add eax, ebx |
569 | mov [proc_mem_tab], eax |
586 | mov [proc_mem_tab], eax |
570 | 587 | ||
571 | add eax, ebx |
588 | add eax, ebx |
572 | mov [tmp_task_ptab], eax |
589 | mov [tmp_task_ptab], eax |
573 | 590 | ||
574 | add eax, ebx |
591 | add eax, ebx |
575 | mov [ipc_pdir], eax |
592 | mov [ipc_pdir], eax |
576 | 593 | ||
577 | add eax, ebx |
594 | add eax, ebx |
578 | mov [ipc_ptab], eax |
595 | mov [ipc_ptab], eax |
579 | 596 | ||
580 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
597 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
581 | (unpack.lc+unpack.lp)))*4 |
598 | (unpack.lc+unpack.lp)))*4 |
582 | 599 | ||
583 | mov [unpack.p], eax |
600 | mov [unpack.p], eax |
584 | 601 | ||
585 | call init_events |
602 | call init_events |
586 | mov eax, srv.fd-SRV.fd |
603 | mov eax, srv.fd-SRV.fd |
587 | mov [srv.fd], eax |
604 | mov [srv.fd], eax |
588 | mov [srv.bk], eax |
605 | mov [srv.bk], eax |
589 | 606 | ||
590 | ;Set base of graphic segment to linear address of LFB |
607 | ;Set base of graphic segment to linear address of LFB |
591 | mov eax, [LFBAddress] ; set for gs |
608 | mov eax, [LFBAddress] ; set for gs |
592 | mov [graph_data_l+2], ax |
609 | mov [graph_data_l+2], ax |
593 | shr eax, 16 |
610 | shr eax, 16 |
594 | mov [graph_data_l+4], al |
611 | mov [graph_data_l+4], al |
595 | mov [graph_data_l+7], ah |
612 | mov [graph_data_l+7], ah |
596 | 613 | ||
597 | stdcall kernel_alloc, [_WinMapSize] |
614 | stdcall kernel_alloc, [_WinMapSize] |
598 | mov [_WinMapAddress], eax |
615 | mov [_WinMapAddress], eax |
599 | 616 | ||
600 | xor eax, eax |
617 | xor eax, eax |
601 | inc eax |
618 | inc eax |
602 | 619 | ||
603 | ; set background |
620 | ; set background |
604 | 621 | ||
605 | mov [BgrDrawMode], eax |
622 | mov [BgrDrawMode], eax |
606 | mov [BgrDataWidth], eax |
623 | mov [BgrDataWidth], eax |
607 | mov [BgrDataHeight], eax |
624 | mov [BgrDataHeight], eax |
608 | mov [mem_BACKGROUND], 4 |
625 | mov [mem_BACKGROUND], 4 |
609 | mov [img_background], static_background_data |
626 | mov [img_background], static_background_data |
610 | 627 | ||
611 | ; set clipboard |
628 | ; set clipboard |
612 | 629 | ||
613 | xor eax, eax |
630 | xor eax, eax |
614 | mov [clipboard_slots], eax |
631 | mov [clipboard_slots], eax |
615 | mov [clipboard_write_lock], eax |
632 | mov [clipboard_write_lock], eax |
616 | stdcall kernel_alloc, 4096 |
633 | stdcall kernel_alloc, 4096 |
617 | test eax, eax |
634 | test eax, eax |
618 | jnz @f |
635 | jnz @f |
619 | 636 | ||
620 | dec eax |
637 | dec eax |
621 | @@: |
638 | @@: |
622 | mov [clipboard_main_list], eax |
639 | mov [clipboard_main_list], eax |
623 | 640 | ||
624 | ; SET UP OS TASK |
641 | ; SET UP OS TASK |
625 | 642 | ||
626 | mov esi, boot_setostask |
643 | mov esi, boot_setostask |
627 | call boot_log |
644 | call boot_log |
628 | 645 | ||
629 | mov edi, sys_proc |
646 | mov edi, sys_proc |
630 | list_init edi |
647 | list_init edi |
631 | lea ecx, [edi+PROC.thr_list] |
648 | lea ecx, [edi+PROC.thr_list] |
632 | list_init ecx |
649 | list_init ecx |
633 | mov [edi+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
650 | mov [edi+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
634 | 651 | ||
635 | mov eax, -1 |
652 | mov eax, -1 |
636 | mov edi, thr_slot_map+4 |
653 | mov edi, thr_slot_map+4 |
637 | mov [edi-4], dword 0xFFFFFFF8 |
654 | mov [edi-4], dword 0xFFFFFFF8 |
638 | stosd |
655 | stosd |
639 | stosd |
656 | stosd |
640 | stosd |
657 | stosd |
641 | stosd |
658 | stosd |
642 | stosd |
659 | stosd |
643 | stosd |
660 | stosd |
644 | stosd |
661 | stosd |
645 | 662 | ||
646 | mov [current_process], sys_proc |
663 | mov [current_process], sys_proc |
647 | 664 | ||
648 | mov edx, SLOT_BASE+256*1 |
665 | mov edx, SLOT_BASE+256*1 |
649 | mov ebx, [os_stack_seg] |
666 | mov ebx, [os_stack_seg] |
650 | add ebx, 0x2000 |
667 | add ebx, 0x2000 |
651 | call setup_os_slot |
668 | call setup_os_slot |
652 | mov dword [edx], 'IDLE' |
669 | mov dword [edx], 'IDLE' |
653 | sub [edx+APPDATA.saved_esp], 4 |
670 | sub [edx+APPDATA.saved_esp], 4 |
654 | mov eax, [edx+APPDATA.saved_esp] |
671 | mov eax, [edx+APPDATA.saved_esp] |
655 | mov dword [eax], idle_thread |
672 | mov dword [eax], idle_thread |
656 | mov ecx, IDLE_PRIORITY |
673 | mov ecx, IDLE_PRIORITY |
657 | call scheduler_add_thread |
674 | call scheduler_add_thread |
658 | 675 | ||
659 | mov edx, SLOT_BASE+256*2 |
676 | mov edx, SLOT_BASE+256*2 |
660 | mov ebx, [os_stack_seg] |
677 | mov ebx, [os_stack_seg] |
661 | call setup_os_slot |
678 | call setup_os_slot |
662 | mov dword [edx], 'OS' |
679 | mov dword [edx], 'OS' |
663 | xor ecx, ecx |
680 | xor ecx, ecx |
664 | call scheduler_add_thread |
681 | call scheduler_add_thread |
665 | 682 | ||
666 | mov dword [CURRENT_TASK], 2 |
683 | mov dword [CURRENT_TASK], 2 |
667 | mov dword [TASK_COUNT], 2 |
684 | mov dword [TASK_COUNT], 2 |
668 | mov dword [current_slot], SLOT_BASE + 256*2 |
685 | mov dword [current_slot], SLOT_BASE + 256*2 |
669 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
686 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
- | 687 | ||
- | 688 | ; Move other CPUs to deep sleep, if it is useful |
|
- | 689 | uglobal |
|
- | 690 | use_mwait_for_idle db 0 |
|
- | 691 | endg |
|
- | 692 | cmp [cpu_vendor+8], 'ntel' |
|
- | 693 | jnz .no_wake_cpus |
|
- | 694 | bt [cpu_caps+4], CAPS_MONITOR-32 |
|
- | 695 | jnc .no_wake_cpus |
|
- | 696 | dbgstr 'using mwait for idle loop' |
|
- | 697 | inc [use_mwait_for_idle] |
|
- | 698 | mov ebx, [cpu_count] |
|
- | 699 | cmp ebx, 1 |
|
- | 700 | jbe .no_wake_cpus |
|
- | 701 | call create_trampoline_pgmap |
|
- | 702 | mov [cr3_ap+OS_BASE], eax |
|
- | 703 | mov eax, cr4 |
|
- | 704 | mov [cr4_ap+OS_BASE], eax |
|
- | 705 | mov esi, OS_BASE + ap_init16 |
|
- | 706 | mov edi, OS_BASE + 8000h |
|
- | 707 | mov ecx, (ap_init16_size + 3) / 4 |
|
- | 708 | rep movsd |
|
- | 709 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE |
|
- | 710 | mov [LAPIC_BASE], eax |
|
- | 711 | lea edi, [eax+300h] |
|
- | 712 | mov esi, smpt+4 |
|
- | 713 | dec ebx |
|
- | 714 | .wake_cpus_loop: |
|
- | 715 | lodsd |
|
- | 716 | push esi |
|
- | 717 | xor esi, esi |
|
- | 718 | inc esi |
|
- | 719 | shl eax, 24 |
|
- | 720 | mov [edi+10h], eax |
|
- | 721 | ; assert INIT IPI |
|
- | 722 | mov dword [edi], 0C500h |
|
- | 723 | call delay_ms |
|
- | 724 | @@: |
|
- | 725 | test dword [edi], 1000h |
|
- | 726 | jnz @b |
|
- | 727 | ; deassert INIT IPI |
|
- | 728 | mov dword [edi], 8500h |
|
- | 729 | call delay_ms |
|
- | 730 | @@: |
|
- | 731 | test dword [edi], 1000h |
|
- | 732 | jnz @b |
|
- | 733 | ; send STARTUP IPI |
|
- | 734 | mov dword [edi], 600h + (8000h shr 12) |
|
- | 735 | call delay_ms |
|
- | 736 | @@: |
|
- | 737 | test dword [edi], 1000h |
|
- | 738 | jnz @b |
|
- | 739 | pop esi |
|
- | 740 | dec ebx |
|
- | 741 | jnz .wake_cpus_loop |
|
- | 742 | mov eax, [cpu_count] |
|
- | 743 | dec eax |
|
- | 744 | @@: |
|
- | 745 | cmp [ap_initialized], eax |
|
- | 746 | jnz @b |
|
- | 747 | mov eax, [cr3_ap+OS_BASE] |
|
- | 748 | call free_page |
|
- | 749 | .no_wake_cpus: |
|
670 | 750 | ||
671 | 751 | ||
672 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
752 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
673 | mov esi, boot_initirq |
753 | mov esi, boot_initirq |
674 | call boot_log |
754 | call boot_log |
675 | call init_irqs |
755 | call init_irqs |
676 | 756 | ||
677 | mov esi, boot_picinit |
757 | mov esi, boot_picinit |
678 | call boot_log |
758 | call boot_log |
679 | call PIC_init |
759 | call PIC_init |
680 | 760 | ||
681 | mov esi, boot_v86machine |
761 | mov esi, boot_v86machine |
682 | call boot_log |
762 | call boot_log |
683 | ; Initialize system V86 machine |
763 | ; Initialize system V86 machine |
684 | ; call init_sys_v86 |
- | |
685 | - | ||
686 | xchg bx, bx |
- | |
687 | - | ||
688 | ; call v86_init |
- | |
689 | call init_sys_v86 |
764 | call init_sys_v86 |
690 | 765 | ||
691 | mov esi, boot_inittimer |
766 | mov esi, boot_inittimer |
692 | call boot_log |
767 | call boot_log |
693 | ; Initialize system timer (IRQ0) |
768 | ; Initialize system timer (IRQ0) |
694 | call PIT_init |
769 | call PIT_init |
695 | 770 | ||
696 | ; Register ramdisk file system |
771 | ; Register ramdisk file system |
697 | cmp [boot_dev+OS_BASE+0x10000], 1 |
772 | cmp [boot_dev+OS_BASE+0x10000], 1 |
698 | je @f |
773 | je @f |
699 | 774 | ||
700 | call register_ramdisk |
775 | call register_ramdisk |
701 | ;-------------------------------------- |
776 | ;-------------------------------------- |
702 | @@: |
777 | @@: |
703 | mov esi, boot_initapic |
778 | mov esi, boot_initapic |
704 | call boot_log |
779 | call boot_log |
705 | ; Try to Initialize APIC |
780 | ; Try to Initialize APIC |
706 | call APIC_init |
781 | call APIC_init |
707 | 782 | ||
708 | mov esi, boot_enableirq |
783 | mov esi, boot_enableirq |
709 | call boot_log |
784 | call boot_log |
710 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
785 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
711 | ; they are used: when partitions are scanned, hd_read relies on timer |
786 | ; they are used: when partitions are scanned, hd_read relies on timer |
712 | call unmask_timer |
787 | call unmask_timer |
713 | stdcall enable_irq, 2 ; @#$%! PIC |
788 | stdcall enable_irq, 2 ; @#$%! PIC |
714 | stdcall enable_irq, 13 ; co-processor |
789 | stdcall enable_irq, 13 ; co-processor |
715 | 790 | ||
716 | ; Setup serial output console (if enabled) |
791 | ; Setup serial output console (if enabled) |
717 | if defined debug_com_base |
792 | if defined debug_com_base |
718 | 793 | ||
719 | ; reserve port so nobody else will use it |
794 | ; reserve port so nobody else will use it |
720 | xor ebx, ebx |
795 | xor ebx, ebx |
721 | mov ecx, debug_com_base |
796 | mov ecx, debug_com_base |
722 | mov edx, debug_com_base+7 |
797 | mov edx, debug_com_base+7 |
723 | call r_f_port_area |
798 | call r_f_port_area |
724 | 799 | ||
725 | ; enable Divisor latch |
800 | ; enable Divisor latch |
726 | mov dx, debug_com_base+3 |
801 | mov dx, debug_com_base+3 |
727 | mov al, 1 shl 7 |
802 | mov al, 1 shl 7 |
728 | out dx, al |
803 | out dx, al |
729 | 804 | ||
730 | ; Set speed to 115200 baud (max speed) |
805 | ; Set speed to 115200 baud (max speed) |
731 | mov dx, debug_com_base |
806 | mov dx, debug_com_base |
732 | mov al, 0x01 |
807 | mov al, 0x01 |
733 | out dx, al |
808 | out dx, al |
734 | 809 | ||
735 | mov dx, debug_com_base+1 |
810 | mov dx, debug_com_base+1 |
736 | mov al, 0x00 |
811 | mov al, 0x00 |
737 | out dx, al |
812 | out dx, al |
738 | 813 | ||
739 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
814 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
740 | mov dx, debug_com_base+3 |
815 | mov dx, debug_com_base+3 |
741 | mov al, 3 |
816 | mov al, 3 |
742 | out dx, al |
817 | out dx, al |
743 | 818 | ||
744 | ; disable interrupts |
819 | ; disable interrupts |
745 | mov dx, debug_com_base+1 |
820 | mov dx, debug_com_base+1 |
746 | mov al, 0 |
821 | mov al, 0 |
747 | out dx, al |
822 | out dx, al |
748 | 823 | ||
749 | ; clear + enable fifo (64 bits) |
824 | ; clear + enable fifo (64 bits) |
750 | mov dx, debug_com_base+2 |
825 | mov dx, debug_com_base+2 |
751 | mov al, 0x7 + 1 shl 5 |
826 | mov al, 0x7 + 1 shl 5 |
752 | out dx, al |
827 | out dx, al |
753 | 828 | ||
754 | end if |
829 | end if |
755 | 830 | ||
756 | 831 | ||
757 | ;----------------------------------------------------------------------------- |
832 | ;----------------------------------------------------------------------------- |
758 | ; show SVN version of kernel on the message board |
833 | ; show SVN version of kernel on the message board |
759 | ;----------------------------------------------------------------------------- |
834 | ;----------------------------------------------------------------------------- |
760 | mov eax, [version_inf.rev] |
835 | mov eax, [version_inf.rev] |
761 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
836 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
762 | ;----------------------------------------------------------------------------- |
837 | ;----------------------------------------------------------------------------- |
763 | ; show CPU count on the message board |
838 | ; show CPU count on the message board |
764 | ;----------------------------------------------------------------------------- |
839 | ;----------------------------------------------------------------------------- |
765 | mov eax, [cpu_count] |
840 | mov eax, [cpu_count] |
766 | test eax, eax |
841 | test eax, eax |
767 | jnz @F |
842 | jnz @F |
768 | mov al, 1 ; at least one CPU |
843 | mov al, 1 ; at least one CPU |
769 | @@: |
844 | @@: |
770 | DEBUGF 1, "K : %d CPU detected\n", eax |
845 | DEBUGF 1, "K : %d CPU detected\n", eax |
771 | ;----------------------------------------------------------------------------- |
846 | ;----------------------------------------------------------------------------- |
772 | ; detect Floppy drives |
847 | ; detect Floppy drives |
773 | ;----------------------------------------------------------------------------- |
848 | ;----------------------------------------------------------------------------- |
774 | mov esi, boot_detectfloppy |
849 | mov esi, boot_detectfloppy |
775 | call boot_log |
850 | call boot_log |
776 | include 'detect/dev_fd.inc' |
851 | include 'detect/dev_fd.inc' |
777 | ;----------------------------------------------------------------------------- |
852 | ;----------------------------------------------------------------------------- |
778 | ; create pci-devices list |
853 | ; create pci-devices list |
779 | ;----------------------------------------------------------------------------- |
854 | ;----------------------------------------------------------------------------- |
780 | mov [pci_access_enabled], 1 |
855 | mov [pci_access_enabled], 1 |
781 | call pci_enum |
856 | call pci_enum |
782 | ;----------------------------------------------------------------------------- |
857 | ;----------------------------------------------------------------------------- |
783 | ; initialisation IDE ATA code |
858 | ; initialisation IDE ATA code |
784 | ;----------------------------------------------------------------------------- |
859 | ;----------------------------------------------------------------------------- |
785 | include 'detect/init_ata.inc' |
860 | include 'detect/init_ata.inc' |
786 | ;----------------------------------------------------------------------------- |
861 | ;----------------------------------------------------------------------------- |
787 | if 0 |
862 | if 0 |
788 | mov ax, [OS_BASE+0x10000+bx_from_load] |
863 | mov ax, [OS_BASE+0x10000+bx_from_load] |
789 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
864 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
790 | je no_lib_load |
865 | je no_lib_load |
791 | 866 | ||
792 | mov esi, boot_loadlibs |
867 | mov esi, boot_loadlibs |
793 | call boot_log |
868 | call boot_log |
794 | ; LOADING LIBRARES |
869 | ; LOADING LIBRARES |
795 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
870 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
796 | call load_file_parse_table ; prepare file parse table |
871 | call load_file_parse_table ; prepare file parse table |
797 | call set_kernel_conf ; configure devices and gui |
872 | call set_kernel_conf ; configure devices and gui |
798 | no_lib_load: |
873 | no_lib_load: |
799 | end if |
874 | end if |
800 | 875 | ||
801 | ; Display APIC status |
876 | ; Display APIC status |
802 | mov esi, boot_APIC_found |
877 | mov esi, boot_APIC_found |
803 | cmp [irq_mode], IRQ_APIC |
878 | cmp [irq_mode], IRQ_APIC |
804 | je @f |
879 | je @f |
805 | mov esi, boot_APIC_nfound |
880 | mov esi, boot_APIC_nfound |
806 | @@: |
881 | @@: |
807 | call boot_log |
882 | call boot_log |
808 | 883 | ||
809 | ; PRINT AMOUNT OF MEMORY |
884 | ; PRINT AMOUNT OF MEMORY |
810 | mov esi, boot_memdetect |
885 | mov esi, boot_memdetect |
811 | call boot_log |
886 | call boot_log |
812 | 887 | ||
813 | movzx ecx, word [boot_y] |
888 | movzx ecx, word [boot_y] |
814 | if lang eq ru |
889 | if lang eq ru |
815 | or ecx, (10+30*6) shl 16 |
890 | or ecx, (10+30*6) shl 16 |
816 | else if lang eq sp |
891 | else if lang eq sp |
817 | or ecx, (10+33*6) shl 16 |
892 | or ecx, (10+33*6) shl 16 |
818 | else |
893 | else |
819 | or ecx, (10+29*6) shl 16 |
894 | or ecx, (10+29*6) shl 16 |
820 | end if |
895 | end if |
821 | sub ecx, 10 |
896 | sub ecx, 10 |
822 | mov edx, 0xFFFFFF |
897 | mov edx, 0xFFFFFF |
823 | mov ebx, [MEM_AMOUNT] |
898 | mov ebx, [MEM_AMOUNT] |
824 | shr ebx, 20 |
899 | shr ebx, 20 |
825 | xor edi, edi |
900 | xor edi, edi |
826 | mov eax, 0x00040000 |
901 | mov eax, 0x00040000 |
827 | inc edi |
902 | inc edi |
828 | call display_number_force |
903 | call display_number_force |
829 | 904 | ||
830 | ; BUILD SCHEDULER |
905 | ; BUILD SCHEDULER |
831 | 906 | ||
832 | ; call build_scheduler; sys32.inc |
907 | ; call build_scheduler; sys32.inc |
833 | 908 | ||
834 | ; mov esi, boot_devices |
909 | ; mov esi, boot_devices |
835 | ; call boot_log |
910 | ; call boot_log |
836 | 911 | ||
837 | call clear_pci_ide_interrupts |
912 | call clear_pci_ide_interrupts |
838 | 913 | ||
839 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
914 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
840 | 915 | ||
841 | stdcall load_driver, szVidintel |
916 | stdcall load_pe_driver, szVidintel, 0 |
842 | 917 | ||
843 | call usb_init |
918 | call usb_init |
844 | 919 | ||
845 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
920 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
846 | 921 | ||
847 | mov esi, boot_windefs |
922 | mov esi, boot_windefs |
848 | call boot_log |
923 | call boot_log |
849 | call set_window_defaults |
924 | call set_window_defaults |
850 | 925 | ||
851 | ; SET BACKGROUND DEFAULTS |
926 | ; SET BACKGROUND DEFAULTS |
852 | 927 | ||
853 | mov esi, boot_bgr |
928 | mov esi, boot_bgr |
854 | call boot_log |
929 | call boot_log |
855 | call init_background |
930 | call init_background |
856 | call calculatebackground |
931 | call calculatebackground |
857 | 932 | ||
858 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
933 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
859 | 934 | ||
860 | mov esi, boot_resirqports |
935 | mov esi, boot_resirqports |
861 | call boot_log |
936 | call boot_log |
862 | call reserve_irqs_ports |
937 | call reserve_irqs_ports |
863 | 938 | ||
864 | call init_display |
939 | call init_display |
865 | mov eax, [def_cursor] |
940 | mov eax, [def_cursor] |
866 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
941 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
867 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
942 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
868 | 943 | ||
869 | ; PRINT CPU FREQUENCY |
944 | ; PRINT CPU FREQUENCY |
870 | 945 | ||
871 | mov esi, boot_cpufreq |
946 | mov esi, boot_cpufreq |
872 | call boot_log |
947 | call boot_log |
873 | 948 | ||
874 | cli ;FIXME check IF |
949 | cli ;FIXME check IF |
875 | rdtsc |
950 | rdtsc |
876 | mov ecx, eax |
951 | mov ecx, eax |
877 | mov esi, 250 ; wait 1/4 a second |
952 | mov esi, 250 ; wait 1/4 a second |
878 | call delay_ms |
953 | call delay_ms |
879 | rdtsc |
954 | rdtsc |
- | 955 | sti |
|
880 | 956 | ||
881 | sub eax, ecx |
957 | sub eax, ecx |
882 | xor edx, edx |
958 | xor edx, edx |
883 | shld edx, eax, 2 |
959 | shld edx, eax, 2 |
884 | shl eax, 2 |
960 | shl eax, 2 |
885 | mov dword [cpu_freq], eax |
961 | mov dword [cpu_freq], eax |
886 | mov dword [cpu_freq+4], edx |
962 | mov dword [cpu_freq+4], edx |
887 | mov ebx, 1000000 |
963 | mov ebx, 1000000 |
888 | div ebx |
964 | div ebx |
889 | mov ebx, eax |
965 | mov ebx, eax |
890 | 966 | ||
891 | movzx ecx, word [boot_y] |
967 | movzx ecx, word [boot_y] |
892 | if lang eq ru |
968 | if lang eq ru |
893 | add ecx, (10+19*6) shl 16 - 10 |
969 | add ecx, (10+19*6) shl 16 - 10 |
894 | else if lang eq sp |
970 | else if lang eq sp |
895 | add ecx, (10+25*6) shl 16 - 10 |
971 | add ecx, (10+25*6) shl 16 - 10 |
896 | else |
972 | else |
897 | add ecx, (10+17*6) shl 16 - 10 |
973 | add ecx, (10+17*6) shl 16 - 10 |
898 | end if |
974 | end if |
899 | 975 | ||
900 | mov edx, 0xFFFFFF |
976 | mov edx, 0xFFFFFF |
901 | xor edi, edi |
977 | xor edi, edi |
902 | mov eax, 0x00040000 |
978 | mov eax, 0x00040000 |
903 | inc edi |
979 | inc edi |
904 | call display_number_force |
980 | call display_number_force |
905 | 981 | ||
906 | ; SET VARIABLES |
982 | ; SET VARIABLES |
907 | 983 | ||
908 | call set_variables |
984 | call set_variables |
909 | 985 | ||
910 | ; STACK AND FDC |
986 | ; STACK AND FDC |
911 | 987 | ||
912 | call stack_init |
988 | call stack_init |
913 | call fdc_init |
989 | call fdc_init |
914 | 990 | ||
915 | ; PALETTE FOR 320x200 and 640x480 16 col |
991 | ; PALETTE FOR 320x200 and 640x480 16 col |
916 | 992 | ||
917 | cmp [SCR_MODE], word 0x12 |
993 | cmp [SCR_MODE], word 0x12 |
918 | jne no_pal_vga |
994 | jne no_pal_vga |
919 | mov esi, boot_pal_vga |
995 | mov esi, boot_pal_vga |
920 | call boot_log |
996 | call boot_log |
921 | call paletteVGA |
997 | call paletteVGA |
922 | no_pal_vga: |
998 | no_pal_vga: |
923 | 999 | ||
924 | cmp [SCR_MODE], word 0x13 |
1000 | cmp [SCR_MODE], word 0x13 |
925 | jne no_pal_ega |
1001 | jne no_pal_ega |
926 | mov esi, boot_pal_ega |
1002 | mov esi, boot_pal_ega |
927 | call boot_log |
1003 | call boot_log |
928 | call palette320x200 |
1004 | call palette320x200 |
929 | no_pal_ega: |
1005 | no_pal_ega: |
930 | 1006 | ||
931 | ; LOAD DEFAULT SKIN |
1007 | ; LOAD DEFAULT SKIN |
932 | 1008 | ||
933 | call load_default_skin |
1009 | call load_default_skin |
934 | 1010 | ||
935 | ;protect io permission map |
1011 | ;protect io permission map |
936 | 1012 | ||
937 | mov esi, [default_io_map] |
1013 | mov esi, [default_io_map] |
938 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1014 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
939 | add esi, 0x1000 |
1015 | add esi, 0x1000 |
940 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1016 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
941 | 1017 | ||
942 | stdcall map_page, tss._io_map_0, \ |
1018 | stdcall map_page, tss._io_map_0, \ |
943 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1019 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
944 | stdcall map_page, tss._io_map_1, \ |
1020 | stdcall map_page, tss._io_map_1, \ |
945 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1021 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
946 | - | ||
947 | ; LOAD FIRST APPLICATION |
- | |
948 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
- | |
949 | jnz first_app_found |
- | |
950 | - | ||
951 | cli |
- | |
952 | mov ebp, firstapp |
- | |
953 | call fs_execute_from_sysdir |
- | |
954 | test eax, eax |
- | |
955 | jns first_app_found |
- | |
956 | - | ||
957 | mov esi, boot_failed |
- | |
958 | call boot_log |
- | |
959 | - | ||
960 | mov eax, 0xDEADBEEF ; otherwise halt |
- | |
961 | hlt |
- | |
962 | - | ||
963 | first_app_found: |
- | |
964 | - | ||
965 | cli |
- | |
966 | 1022 | ||
967 | ; SET KEYBOARD PARAMETERS |
1023 | ; SET KEYBOARD PARAMETERS |
968 | mov al, 0xf6 ; reset keyboard, scan enabled |
1024 | mov al, 0xf6 ; reset keyboard, scan enabled |
969 | call kb_write |
1025 | call kb_write_wait_ack |
970 | test ah, ah |
1026 | test ah, ah |
971 | jnz .no_keyboard |
1027 | jnz .no_keyboard |
972 | - | ||
973 | ; wait until 8042 is ready |
- | |
974 | xor ecx, ecx |
- | |
975 | @@: |
- | |
976 | in al, 64h |
- | |
977 | and al, 00000010b |
- | |
978 | loopnz @b |
- | |
979 | 1028 | ||
980 | iglobal |
1029 | iglobal |
981 | align 4 |
1030 | align 4 |
982 | ps2_keyboard_functions: |
1031 | ps2_keyboard_functions: |
983 | dd .end - $ |
1032 | dd .end - $ |
984 | dd 0 ; no close |
1033 | dd 0 ; no close |
985 | dd ps2_set_lights |
1034 | dd ps2_set_lights |
986 | .end: |
1035 | .end: |
987 | endg |
1036 | endg |
988 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1037 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
989 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1038 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
990 | ; call kb_write |
1039 | ; call kb_write_wait_ack |
991 | ; call kb_read |
- | |
992 | ; mov al, 111b |
1040 | ; mov al, 111b |
993 | ; call kb_write |
1041 | ; call kb_write_wait_ack |
994 | ; call kb_read |
- | |
995 | 1042 | ||
996 | mov al, 0xF3 ; set repeat rate & delay |
1043 | mov al, 0xF3 ; set repeat rate & delay |
997 | call kb_write |
- | |
998 | ; call kb_read |
1044 | call kb_write_wait_ack |
999 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1045 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1000 | call kb_write |
- | |
1001 | ; call kb_read |
1046 | call kb_write_wait_ack |
1002 | ;// mike.dld [ |
1047 | ;// mike.dld [ |
1003 | call set_lights |
1048 | call set_lights |
1004 | ;// mike.dld ] |
1049 | ;// mike.dld ] |
1005 | stdcall attach_int_handler, 1, irq1, 0 |
1050 | stdcall attach_int_handler, 1, irq1, 0 |
1006 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1051 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1007 | .no_keyboard: |
1052 | .no_keyboard: |
1008 | 1053 | ||
1009 | ; Load PS/2 mouse driver |
1054 | ; Load PS/2 mouse driver |
1010 | 1055 | ||
1011 | stdcall load_driver, szPS2MDriver |
1056 | stdcall load_pe_driver, szPS2MDriver, 0 |
1012 | 1057 | ||
1013 | mov esi, boot_setmouse |
1058 | mov esi, boot_setmouse |
1014 | call boot_log |
1059 | call boot_log |
1015 | call setmouse |
1060 | call setmouse |
- | 1061 | ||
- | 1062 | ; LOAD FIRST APPLICATION |
|
- | 1063 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
|
- | 1064 | jnz first_app_found |
|
- | 1065 | ||
- | 1066 | cli |
|
- | 1067 | mov ebp, firstapp |
|
- | 1068 | call fs_execute_from_sysdir |
|
- | 1069 | test eax, eax |
|
- | 1070 | jns first_app_found |
|
- | 1071 | ||
- | 1072 | mov esi, boot_failed |
|
- | 1073 | call boot_log |
|
- | 1074 | ||
- | 1075 | mov eax, 0xDEADBEEF ; otherwise halt |
|
- | 1076 | hlt |
|
- | 1077 | ||
- | 1078 | first_app_found: |
|
1016 | 1079 | ||
1017 | ; START MULTITASKING |
1080 | ; START MULTITASKING |
1018 | 1081 | ||
1019 | ; A 'All set - press ESC to start' messages if need |
1082 | ; A 'All set - press ESC to start' messages if need |
1020 | if preboot_blogesc |
1083 | if preboot_blogesc |
1021 | mov esi, boot_tasking |
1084 | mov esi, boot_tasking |
1022 | call boot_log |
1085 | call boot_log |
1023 | .bll1: |
1086 | .bll1: |
1024 | in al, 0x60 ; wait for ESC key press |
1087 | in al, 0x60 ; wait for ESC key press |
1025 | cmp al, 129 |
1088 | cmp al, 129 |
1026 | jne .bll1 |
1089 | jne .bll1 |
1027 | end if |
1090 | end if |
1028 | 1091 | ||
1029 | mov [timer_ticks_enable], 1 ; for cd driver |
1092 | mov [timer_ticks_enable], 1 ; for cd driver |
1030 | 1093 | ||
1031 | sti |
1094 | sti |
1032 | 1095 | ||
1033 | call mtrr_validate |
1096 | call mtrr_validate |
1034 | 1097 | ||
1035 | jmp osloop |
1098 | jmp osloop |
1036 | 1099 | ||
1037 | 1100 | ||
1038 | ; Fly :) |
1101 | ; Fly :) |
- | 1102 | ||
- | 1103 | uglobal |
|
- | 1104 | align 4 |
|
- | 1105 | ap_initialized dd 0 |
|
- | 1106 | endg |
|
- | 1107 | ||
- | 1108 | ap_init_high: |
|
- | 1109 | mov ax, os_stack |
|
- | 1110 | mov bx, app_data |
|
- | 1111 | mov cx, app_tls |
|
- | 1112 | mov ss, ax |
|
- | 1113 | mov ds, bx |
|
- | 1114 | mov es, bx |
|
- | 1115 | mov fs, cx |
|
- | 1116 | mov gs, bx |
|
- | 1117 | xor esp, esp |
|
- | 1118 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
|
- | 1119 | mov cr3, eax |
|
- | 1120 | lock inc [ap_initialized] |
|
- | 1121 | jmp idle_loop |
|
- | 1122 | ||
1039 | 1123 | ||
1040 | include 'unpacker.inc' |
1124 | include 'unpacker.inc' |
1041 | 1125 | ||
1042 | align 4 |
1126 | align 4 |
1043 | boot_log: |
1127 | boot_log: |
1044 | pushad |
1128 | pushad |
1045 | 1129 | ||
1046 | mov ebx, 10*65536 |
1130 | mov ebx, 10*65536 |
1047 | mov bx, word [boot_y] |
1131 | mov bx, word [boot_y] |
1048 | add [boot_y], dword 10 |
1132 | add [boot_y], dword 10 |
1049 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1133 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1050 | xor edi, edi |
1134 | xor edi, edi |
1051 | mov edx, esi |
1135 | mov edx, esi |
1052 | inc edi |
1136 | inc edi |
1053 | call dtext |
1137 | call dtext |
1054 | 1138 | ||
1055 | mov [novesachecksum], 1000 |
1139 | mov [novesachecksum], 1000 |
1056 | call checkVga_N13 |
1140 | call checkVga_N13 |
1057 | 1141 | ||
1058 | popad |
1142 | popad |
1059 | 1143 | ||
1060 | ret |
1144 | ret |
1061 | 1145 | ||
1062 | ; in: edx -> APPDATA for OS/IDLE slot |
1146 | ; in: edx -> APPDATA for OS/IDLE slot |
1063 | ; in: ebx = stack base |
1147 | ; in: ebx = stack base |
1064 | proc setup_os_slot |
1148 | proc setup_os_slot |
1065 | xor eax, eax |
1149 | xor eax, eax |
1066 | mov ecx, 256/4 |
1150 | mov ecx, 256/4 |
1067 | mov edi, edx |
1151 | mov edi, edx |
1068 | rep stosd |
1152 | rep stosd |
1069 | 1153 | ||
1070 | mov eax, tss+0x80 |
1154 | mov eax, tss+0x80 |
1071 | call get_pg_addr |
1155 | call get_pg_addr |
1072 | inc eax |
1156 | inc eax |
1073 | mov [edx+APPDATA.io_map], eax |
1157 | mov [edx+APPDATA.io_map], eax |
1074 | mov eax, tss+0x1080 |
1158 | mov eax, tss+0x1080 |
1075 | call get_pg_addr |
1159 | call get_pg_addr |
1076 | inc eax |
1160 | inc eax |
1077 | mov [edx+APPDATA.io_map+4], eax |
1161 | mov [edx+APPDATA.io_map+4], eax |
1078 | 1162 | ||
1079 | mov dword [edx+APPDATA.pl0_stack], ebx |
1163 | mov dword [edx+APPDATA.pl0_stack], ebx |
1080 | lea edi, [ebx+0x2000-512] |
1164 | lea edi, [ebx+0x2000-512] |
1081 | mov dword [edx+APPDATA.fpu_state], edi |
1165 | mov dword [edx+APPDATA.fpu_state], edi |
1082 | mov dword [edx+APPDATA.saved_esp0], edi |
1166 | mov dword [edx+APPDATA.saved_esp0], edi |
1083 | mov dword [edx+APPDATA.saved_esp], edi |
1167 | mov dword [edx+APPDATA.saved_esp], edi |
1084 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1168 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1085 | 1169 | ||
1086 | mov esi, fpu_data |
1170 | mov esi, fpu_data |
1087 | mov ecx, 512/4 |
1171 | mov ecx, 512/4 |
1088 | cld |
1172 | cld |
1089 | rep movsd |
1173 | rep movsd |
1090 | 1174 | ||
1091 | lea eax, [edx+APP_OBJ_OFFSET] |
1175 | lea eax, [edx+APP_OBJ_OFFSET] |
1092 | mov dword [edx+APPDATA.fd_obj], eax |
1176 | mov dword [edx+APPDATA.fd_obj], eax |
1093 | mov dword [edx+APPDATA.bk_obj], eax |
1177 | mov dword [edx+APPDATA.bk_obj], eax |
1094 | 1178 | ||
1095 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1179 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1096 | 1180 | ||
1097 | mov [edx + APPDATA.process], sys_proc |
1181 | mov [edx + APPDATA.process], sys_proc |
1098 | 1182 | ||
1099 | mov eax, edx |
1183 | mov eax, edx |
1100 | shr eax, 3 |
1184 | shr eax, 3 |
1101 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1185 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1102 | mov [eax+TASKDATA.wnd_number], dh |
1186 | mov [eax+TASKDATA.wnd_number], dh |
1103 | mov byte [eax+TASKDATA.pid], dh |
1187 | mov byte [eax+TASKDATA.pid], dh |
1104 | 1188 | ||
1105 | ret |
1189 | ret |
1106 | endp |
1190 | endp |
1107 | 1191 | ||
1108 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1192 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1109 | ; ; |
1193 | ; ; |
1110 | ; MAIN OS LOOP START ; |
1194 | ; MAIN OS LOOP START ; |
1111 | ; ; |
1195 | ; ; |
1112 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1196 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1113 | align 32 |
1197 | align 32 |
1114 | osloop: |
1198 | osloop: |
1115 | mov edx, osloop_has_work? |
1199 | mov edx, osloop_has_work? |
1116 | xor ecx, ecx |
1200 | xor ecx, ecx |
1117 | call Wait_events |
1201 | call Wait_events |
1118 | xor eax, eax |
1202 | xor eax, eax |
1119 | xchg eax, [osloop_nonperiodic_work] |
1203 | xchg eax, [osloop_nonperiodic_work] |
1120 | test eax, eax |
1204 | test eax, eax |
1121 | jz .no_periodic |
1205 | jz .no_periodic |
1122 | 1206 | ||
1123 | call __sys_draw_pointer |
1207 | call __sys_draw_pointer |
1124 | call window_check_events |
1208 | call window_check_events |
1125 | call mouse_check_events |
1209 | call mouse_check_events |
1126 | call checkmisc |
1210 | call checkmisc |
1127 | call checkVga_N13 |
1211 | call checkVga_N13 |
1128 | ;-------------------------------------- |
1212 | ;-------------------------------------- |
1129 | .no_periodic: |
1213 | .no_periodic: |
1130 | call stack_handler |
1214 | call stack_handler |
1131 | call check_fdd_motor_status |
1215 | call check_fdd_motor_status |
1132 | call check_ATAPI_device_event |
1216 | call check_ATAPI_device_event |
1133 | call check_lights_state |
1217 | call check_lights_state |
1134 | call check_timers |
1218 | call check_timers |
1135 | 1219 | ||
1136 | jmp osloop |
1220 | jmp osloop |
1137 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1221 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1138 | ; ; |
1222 | ; ; |
1139 | ; MAIN OS LOOP END ; |
1223 | ; MAIN OS LOOP END ; |
1140 | ; ; |
1224 | ; ; |
1141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1225 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1142 | proc osloop_has_work? |
1226 | proc osloop_has_work? |
1143 | cmp [osloop_nonperiodic_work], 0 |
1227 | cmp [osloop_nonperiodic_work], 0 |
1144 | jnz .yes |
1228 | jnz .yes |
1145 | call stack_handler_has_work? |
1229 | call stack_handler_has_work? |
1146 | jnz .yes |
1230 | jnz .yes |
1147 | call check_fdd_motor_status_has_work? |
1231 | call check_fdd_motor_status_has_work? |
1148 | jnz .yes |
1232 | jnz .yes |
1149 | call check_ATAPI_device_event_has_work? |
1233 | call check_ATAPI_device_event_has_work? |
1150 | jnz .yes |
1234 | jnz .yes |
1151 | call check_lights_state_has_work? |
1235 | call check_lights_state_has_work? |
1152 | jnz .yes |
1236 | jnz .yes |
1153 | call check_timers_has_work? |
1237 | call check_timers_has_work? |
1154 | jnz .yes |
1238 | jnz .yes |
1155 | .no: |
1239 | .no: |
1156 | xor eax, eax |
1240 | xor eax, eax |
1157 | ret |
1241 | ret |
1158 | .yes: |
1242 | .yes: |
1159 | xor eax, eax |
1243 | xor eax, eax |
1160 | inc eax |
1244 | inc eax |
1161 | ret |
1245 | ret |
1162 | endp |
1246 | endp |
1163 | 1247 | ||
1164 | proc wakeup_osloop |
1248 | proc wakeup_osloop |
1165 | mov [osloop_nonperiodic_work], 1 |
1249 | mov [osloop_nonperiodic_work], 1 |
1166 | ret |
1250 | ret |
1167 | endp |
1251 | endp |
1168 | 1252 | ||
1169 | uglobal |
1253 | uglobal |
1170 | align 4 |
1254 | align 4 |
1171 | osloop_nonperiodic_work dd ? |
1255 | osloop_nonperiodic_work dd ? |
1172 | endg |
1256 | endg |
- | 1257 | ||
1173 | 1258 | uglobal |
|
- | 1259 | align 64 |
|
- | 1260 | idle_addr rb 64 |
|
- | 1261 | endg |
|
1174 | align 4 |
1262 | |
1175 | idle_thread: |
1263 | idle_thread: |
- | 1264 | sti |
|
- | 1265 | ||
- | 1266 | ; The following code can be executed by all CPUs in the system. |
|
- | 1267 | ; All other parts of the kernel do not expect multi-CPU. |
|
- | 1268 | ; Also, APs don't even have a stack here. |
|
1176 | sti |
1269 | ; Beware. Don't do anything here. Anything at all. |
- | 1270 | idle_loop: |
|
- | 1271 | cmp [use_mwait_for_idle], 0 |
|
- | 1272 | jnz idle_loop_mwait |
|
- | 1273 | ||
1177 | idle_loop: |
1274 | idle_loop_hlt: |
1178 | hlt |
1275 | hlt |
- | 1276 | jmp idle_loop_hlt |
|
- | 1277 | ||
- | 1278 | idle_loop_mwait: |
|
- | 1279 | mov eax, idle_addr |
|
- | 1280 | xor ecx, ecx |
|
- | 1281 | xor edx, edx |
|
- | 1282 | monitor |
|
- | 1283 | xor ecx, ecx |
|
- | 1284 | mov eax, 20h ; or 10h |
|
1179 | jmp idle_loop |
1285 | mwait |
1180 | 1286 | jmp idle_loop_mwait |
|
1181 | 1287 | ||
1182 | 1288 | ||
1183 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1289 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1184 | ; ; |
1290 | ; ; |
1185 | ; INCLUDED SYSTEM FILES ; |
1291 | ; INCLUDED SYSTEM FILES ; |
1186 | ; ; |
1292 | ; ; |
1187 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1293 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1188 | 1294 | ||
1189 | 1295 | ||
1190 | include "kernel32.inc" |
1296 | include "kernel32.inc" |
1191 | 1297 | ||
1192 | 1298 | ||
1193 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1299 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1194 | ; ; |
1300 | ; ; |
1195 | ; KERNEL FUNCTIONS ; |
1301 | ; KERNEL FUNCTIONS ; |
1196 | ; ; |
1302 | ; ; |
1197 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1303 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1198 | 1304 | ||
1199 | reserve_irqs_ports: |
1305 | reserve_irqs_ports: |
1200 | 1306 | ||
1201 | 1307 | ||
1202 | ; RESERVE PORTS |
1308 | ; RESERVE PORTS |
1203 | mov eax, RESERVED_PORTS |
1309 | mov eax, RESERVED_PORTS |
1204 | mov ecx, 1 |
1310 | mov ecx, 1 |
1205 | 1311 | ||
1206 | mov [eax], dword 4 |
1312 | mov [eax], dword 4 |
1207 | 1313 | ||
1208 | mov [eax+16], ecx |
1314 | mov [eax+16], ecx |
1209 | mov [eax+16+4], dword 0 |
1315 | mov [eax+16+4], dword 0 |
1210 | mov [eax+16+8], dword 0x2D |
1316 | mov [eax+16+8], dword 0x2D |
1211 | 1317 | ||
1212 | mov [eax+32], ecx |
1318 | mov [eax+32], ecx |
1213 | mov [eax+32+4], dword 0x30 |
1319 | mov [eax+32+4], dword 0x30 |
1214 | mov [eax+32+8], dword 0x4D |
1320 | mov [eax+32+8], dword 0x4D |
1215 | 1321 | ||
1216 | mov [eax+48], ecx |
1322 | mov [eax+48], ecx |
1217 | mov [eax+48+4], dword 0x50 |
1323 | mov [eax+48+4], dword 0x50 |
1218 | mov [eax+48+8], dword 0xDF |
1324 | mov [eax+48+8], dword 0xDF |
1219 | 1325 | ||
1220 | mov [eax+64], ecx |
1326 | mov [eax+64], ecx |
1221 | mov [eax+64+4], dword 0xE5 |
1327 | mov [eax+64+4], dword 0xE5 |
1222 | mov [eax+64+8], dword 0xFF |
1328 | mov [eax+64+8], dword 0xFF |
1223 | 1329 | ||
1224 | ret |
1330 | ret |
1225 | 1331 | ||
1226 | 1332 | ||
1227 | iglobal |
1333 | iglobal |
1228 | process_number dd 0x2 |
1334 | process_number dd 0x2 |
1229 | endg |
1335 | endg |
1230 | 1336 | ||
1231 | set_variables: |
1337 | set_variables: |
1232 | 1338 | ||
1233 | mov ecx, 0x16 ; flush port 0x60 |
1339 | mov ecx, 0x16 ; flush port 0x60 |
1234 | .fl60: |
1340 | .fl60: |
1235 | in al, 0x60 |
1341 | in al, 0x60 |
1236 | loop .fl60 |
1342 | loop .fl60 |
1237 | push eax |
1343 | push eax |
1238 | 1344 | ||
1239 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1345 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1240 | shr ax, 1 |
1346 | shr ax, 1 |
1241 | shl eax, 16 |
1347 | shl eax, 16 |
1242 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1348 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1243 | shr ax, 1 |
1349 | shr ax, 1 |
1244 | mov [MOUSE_X], eax |
1350 | mov [MOUSE_X], eax |
1245 | call wakeup_osloop |
1351 | call wakeup_osloop |
1246 | 1352 | ||
1247 | xor eax, eax |
1353 | xor eax, eax |
1248 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1354 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1249 | 1355 | ||
1250 | mov byte [KEY_COUNT], al ; keyboard buffer |
1356 | mov byte [KEY_COUNT], al ; keyboard buffer |
1251 | mov byte [BTN_COUNT], al ; button buffer |
1357 | mov byte [BTN_COUNT], al ; button buffer |
1252 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1358 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1253 | 1359 | ||
1254 | pop eax |
1360 | pop eax |
1255 | ret |
1361 | ret |
1256 | 1362 | ||
1257 | align 4 |
1363 | align 4 |
1258 | ;input eax=43,bl-byte of output, ecx - number of port |
1364 | ;input eax=43,bl-byte of output, ecx - number of port |
1259 | sys_outport: |
1365 | sys_outport: |
1260 | 1366 | ||
1261 | mov edi, ecx ; separate flag for read / write |
1367 | mov edi, ecx ; separate flag for read / write |
1262 | and ecx, 65535 |
1368 | and ecx, 65535 |
1263 | 1369 | ||
1264 | mov eax, [RESERVED_PORTS] |
1370 | mov eax, [RESERVED_PORTS] |
1265 | test eax, eax |
1371 | test eax, eax |
1266 | jnz .sopl8 |
1372 | jnz .sopl8 |
1267 | inc eax |
1373 | inc eax |
1268 | mov [esp+32], eax |
1374 | mov [esp+32], eax |
1269 | ret |
1375 | ret |
1270 | 1376 | ||
1271 | .sopl8: |
1377 | .sopl8: |
1272 | mov edx, [TASK_BASE] |
1378 | mov edx, [TASK_BASE] |
1273 | mov edx, [edx+0x4] |
1379 | mov edx, [edx+0x4] |
1274 | ;and ecx,65535 |
1380 | ;and ecx,65535 |
1275 | ;cld - set on interrupt 0x40 |
1381 | ;cld - set on interrupt 0x40 |
1276 | .sopl1: |
1382 | .sopl1: |
1277 | 1383 | ||
1278 | mov esi, eax |
1384 | mov esi, eax |
1279 | shl esi, 4 |
1385 | shl esi, 4 |
1280 | add esi, RESERVED_PORTS |
1386 | add esi, RESERVED_PORTS |
1281 | cmp edx, [esi+0] |
1387 | cmp edx, [esi+0] |
1282 | jne .sopl2 |
1388 | jne .sopl2 |
1283 | cmp ecx, [esi+4] |
1389 | cmp ecx, [esi+4] |
1284 | jb .sopl2 |
1390 | jb .sopl2 |
1285 | cmp ecx, [esi+8] |
1391 | cmp ecx, [esi+8] |
1286 | jg .sopl2 |
1392 | jg .sopl2 |
1287 | .sopl3: |
1393 | .sopl3: |
1288 | 1394 | ||
1289 | test edi, 0x80000000; read ? |
1395 | test edi, 0x80000000; read ? |
1290 | jnz .sopl4 |
1396 | jnz .sopl4 |
1291 | 1397 | ||
1292 | mov eax, ebx |
1398 | mov eax, ebx |
1293 | mov dx, cx ; write |
1399 | mov dx, cx ; write |
1294 | out dx, al |
1400 | out dx, al |
1295 | and [esp+32], dword 0 |
1401 | and [esp+32], dword 0 |
1296 | ret |
1402 | ret |
1297 | 1403 | ||
1298 | .sopl2: |
1404 | .sopl2: |
1299 | 1405 | ||
1300 | dec eax |
1406 | dec eax |
1301 | jnz .sopl1 |
1407 | jnz .sopl1 |
1302 | inc eax |
1408 | inc eax |
1303 | mov [esp+32], eax |
1409 | mov [esp+32], eax |
1304 | ret |
1410 | ret |
1305 | 1411 | ||
1306 | 1412 | ||
1307 | .sopl4: |
1413 | .sopl4: |
1308 | 1414 | ||
1309 | mov dx, cx ; read |
1415 | mov dx, cx ; read |
1310 | in al, dx |
1416 | in al, dx |
1311 | and eax, 0xff |
1417 | and eax, 0xff |
1312 | and [esp+32], dword 0 |
1418 | and [esp+32], dword 0 |
1313 | mov [esp+20], eax |
1419 | mov [esp+20], eax |
1314 | ret |
1420 | ret |
1315 | 1421 | ||
1316 | display_number: |
1422 | display_number: |
1317 | ;It is not optimization |
1423 | ;It is not optimization |
1318 | mov eax, ebx |
1424 | mov eax, ebx |
1319 | mov ebx, ecx |
1425 | mov ebx, ecx |
1320 | mov ecx, edx |
1426 | mov ecx, edx |
1321 | mov edx, esi |
1427 | mov edx, esi |
1322 | mov esi, edi |
1428 | mov esi, edi |
1323 | ; eax = print type, al=0 -> ebx is number |
1429 | ; eax = print type, al=0 -> ebx is number |
1324 | ; al=1 -> ebx is pointer |
1430 | ; al=1 -> ebx is pointer |
1325 | ; ah=0 -> display decimal |
1431 | ; ah=0 -> display decimal |
1326 | ; ah=1 -> display hexadecimal |
1432 | ; ah=1 -> display hexadecimal |
1327 | ; ah=2 -> display binary |
1433 | ; ah=2 -> display binary |
1328 | ; eax bits 16-21 = number of digits to display (0-32) |
1434 | ; eax bits 16-21 = number of digits to display (0-32) |
1329 | ; eax bits 22-31 = reserved |
1435 | ; eax bits 22-31 = reserved |
1330 | ; |
1436 | ; |
1331 | ; ebx = number or pointer |
1437 | ; ebx = number or pointer |
1332 | ; ecx = x shl 16 + y |
1438 | ; ecx = x shl 16 + y |
1333 | ; edx = color |
1439 | ; edx = color |
1334 | xor edi, edi |
1440 | xor edi, edi |
1335 | display_number_force: |
1441 | display_number_force: |
1336 | push eax |
1442 | push eax |
1337 | and eax, 0x3fffffff |
1443 | and eax, 0x3fffffff |
1338 | cmp eax, 0xffff ; length > 0 ? |
1444 | cmp eax, 0xffff ; length > 0 ? |
1339 | pop eax |
1445 | pop eax |
1340 | jge cont_displ |
1446 | jge cont_displ |
1341 | ret |
1447 | ret |
1342 | cont_displ: |
1448 | cont_displ: |
1343 | push eax |
1449 | push eax |
1344 | and eax, 0x3fffffff |
1450 | and eax, 0x3fffffff |
1345 | cmp eax, 61*0x10000 ; length <= 60 ? |
1451 | cmp eax, 61*0x10000 ; length <= 60 ? |
1346 | pop eax |
1452 | pop eax |
1347 | jb cont_displ2 |
1453 | jb cont_displ2 |
1348 | ret |
1454 | ret |
1349 | cont_displ2: |
1455 | cont_displ2: |
1350 | 1456 | ||
1351 | pushad |
1457 | pushad |
1352 | 1458 | ||
1353 | cmp al, 1 ; ecx is a pointer ? |
1459 | cmp al, 1 ; ecx is a pointer ? |
1354 | jne displnl1 |
1460 | jne displnl1 |
1355 | mov ebp, ebx |
1461 | mov ebp, ebx |
1356 | add ebp, 4 |
1462 | add ebp, 4 |
1357 | mov ebp, [ebp+std_application_base_address] |
1463 | mov ebp, [ebp+std_application_base_address] |
1358 | mov ebx, [ebx+std_application_base_address] |
1464 | mov ebx, [ebx+std_application_base_address] |
1359 | displnl1: |
1465 | displnl1: |
1360 | sub esp, 64 |
1466 | sub esp, 64 |
1361 | 1467 | ||
1362 | test ah, ah ; DECIMAL |
1468 | test ah, ah ; DECIMAL |
1363 | jnz no_display_desnum |
1469 | jnz no_display_desnum |
1364 | shr eax, 16 |
1470 | shr eax, 16 |
1365 | and eax, 0xC03f |
1471 | and eax, 0xC03f |
1366 | ; and eax,0x3f |
1472 | ; and eax,0x3f |
1367 | push eax |
1473 | push eax |
1368 | and eax, 0x3f |
1474 | and eax, 0x3f |
1369 | mov edi, esp |
1475 | mov edi, esp |
1370 | add edi, 4+64-1 |
1476 | add edi, 4+64-1 |
1371 | mov ecx, eax |
1477 | mov ecx, eax |
1372 | mov eax, ebx |
1478 | mov eax, ebx |
1373 | mov ebx, 10 |
1479 | mov ebx, 10 |
1374 | d_desnum: |
1480 | d_desnum: |
1375 | xor edx, edx |
1481 | xor edx, edx |
1376 | call division_64_bits |
1482 | call division_64_bits |
1377 | div ebx |
1483 | div ebx |
1378 | add dl, 48 |
1484 | add dl, 48 |
1379 | mov [edi], dl |
1485 | mov [edi], dl |
1380 | dec edi |
1486 | dec edi |
1381 | loop d_desnum |
1487 | loop d_desnum |
1382 | pop eax |
1488 | pop eax |
1383 | call normalize_number |
1489 | call normalize_number |
1384 | call draw_num_text |
1490 | call draw_num_text |
1385 | add esp, 64 |
1491 | add esp, 64 |
1386 | popad |
1492 | popad |
1387 | ret |
1493 | ret |
1388 | no_display_desnum: |
1494 | no_display_desnum: |
1389 | 1495 | ||
1390 | cmp ah, 0x01 ; HEXADECIMAL |
1496 | cmp ah, 0x01 ; HEXADECIMAL |
1391 | jne no_display_hexnum |
1497 | jne no_display_hexnum |
1392 | shr eax, 16 |
1498 | shr eax, 16 |
1393 | and eax, 0xC03f |
1499 | and eax, 0xC03f |
1394 | ; and eax,0x3f |
1500 | ; and eax,0x3f |
1395 | push eax |
1501 | push eax |
1396 | and eax, 0x3f |
1502 | and eax, 0x3f |
1397 | mov edi, esp |
1503 | mov edi, esp |
1398 | add edi, 4+64-1 |
1504 | add edi, 4+64-1 |
1399 | mov ecx, eax |
1505 | mov ecx, eax |
1400 | mov eax, ebx |
1506 | mov eax, ebx |
1401 | mov ebx, 16 |
1507 | mov ebx, 16 |
1402 | d_hexnum: |
1508 | d_hexnum: |
1403 | xor edx, edx |
1509 | xor edx, edx |
1404 | call division_64_bits |
1510 | call division_64_bits |
1405 | div ebx |
1511 | div ebx |
1406 | hexletters = __fdo_hexdigits |
1512 | hexletters = __fdo_hexdigits |
1407 | add edx, hexletters |
1513 | add edx, hexletters |
1408 | mov dl, [edx] |
1514 | mov dl, [edx] |
1409 | mov [edi], dl |
1515 | mov [edi], dl |
1410 | dec edi |
1516 | dec edi |
1411 | loop d_hexnum |
1517 | loop d_hexnum |
1412 | pop eax |
1518 | pop eax |
1413 | call normalize_number |
1519 | call normalize_number |
1414 | call draw_num_text |
1520 | call draw_num_text |
1415 | add esp, 64 |
1521 | add esp, 64 |
1416 | popad |
1522 | popad |
1417 | ret |
1523 | ret |
1418 | no_display_hexnum: |
1524 | no_display_hexnum: |
1419 | 1525 | ||
1420 | cmp ah, 0x02 ; BINARY |
1526 | cmp ah, 0x02 ; BINARY |
1421 | jne no_display_binnum |
1527 | jne no_display_binnum |
1422 | shr eax, 16 |
1528 | shr eax, 16 |
1423 | and eax, 0xC03f |
1529 | and eax, 0xC03f |
1424 | ; and eax,0x3f |
1530 | ; and eax,0x3f |
1425 | push eax |
1531 | push eax |
1426 | and eax, 0x3f |
1532 | and eax, 0x3f |
1427 | mov edi, esp |
1533 | mov edi, esp |
1428 | add edi, 4+64-1 |
1534 | add edi, 4+64-1 |
1429 | mov ecx, eax |
1535 | mov ecx, eax |
1430 | mov eax, ebx |
1536 | mov eax, ebx |
1431 | mov ebx, 2 |
1537 | mov ebx, 2 |
1432 | d_binnum: |
1538 | d_binnum: |
1433 | xor edx, edx |
1539 | xor edx, edx |
1434 | call division_64_bits |
1540 | call division_64_bits |
1435 | div ebx |
1541 | div ebx |
1436 | add dl, 48 |
1542 | add dl, 48 |
1437 | mov [edi], dl |
1543 | mov [edi], dl |
1438 | dec edi |
1544 | dec edi |
1439 | loop d_binnum |
1545 | loop d_binnum |
1440 | pop eax |
1546 | pop eax |
1441 | call normalize_number |
1547 | call normalize_number |
1442 | call draw_num_text |
1548 | call draw_num_text |
1443 | add esp, 64 |
1549 | add esp, 64 |
1444 | popad |
1550 | popad |
1445 | ret |
1551 | ret |
1446 | no_display_binnum: |
1552 | no_display_binnum: |
1447 | 1553 | ||
1448 | add esp, 64 |
1554 | add esp, 64 |
1449 | popad |
1555 | popad |
1450 | ret |
1556 | ret |
1451 | 1557 | ||
1452 | normalize_number: |
1558 | normalize_number: |
1453 | test ah, 0x80 |
1559 | test ah, 0x80 |
1454 | jz .continue |
1560 | jz .continue |
1455 | mov ecx, 48 |
1561 | mov ecx, 48 |
1456 | and eax, 0x3f |
1562 | and eax, 0x3f |
1457 | @@: |
1563 | @@: |
1458 | inc edi |
1564 | inc edi |
1459 | cmp [edi], cl |
1565 | cmp [edi], cl |
1460 | jne .continue |
1566 | jne .continue |
1461 | dec eax |
1567 | dec eax |
1462 | cmp eax, 1 |
1568 | cmp eax, 1 |
1463 | ja @r |
1569 | ja @r |
1464 | mov al, 1 |
1570 | mov al, 1 |
1465 | .continue: |
1571 | .continue: |
1466 | and eax, 0x3f |
1572 | and eax, 0x3f |
1467 | ret |
1573 | ret |
1468 | 1574 | ||
1469 | division_64_bits: |
1575 | division_64_bits: |
1470 | test [esp+1+4], byte 0x40 |
1576 | test [esp+1+4], byte 0x40 |
1471 | jz .continue |
1577 | jz .continue |
1472 | push eax |
1578 | push eax |
1473 | mov eax, ebp |
1579 | mov eax, ebp |
1474 | div ebx |
1580 | div ebx |
1475 | mov ebp, eax |
1581 | mov ebp, eax |
1476 | pop eax |
1582 | pop eax |
1477 | .continue: |
1583 | .continue: |
1478 | ret |
1584 | ret |
1479 | 1585 | ||
1480 | draw_num_text: |
1586 | draw_num_text: |
1481 | mov esi, eax |
1587 | mov esi, eax |
1482 | mov edx, 64+4 |
1588 | mov edx, 64+4 |
1483 | sub edx, eax |
1589 | sub edx, eax |
1484 | add edx, esp |
1590 | add edx, esp |
1485 | mov ebx, [esp+64+32-8+4] |
1591 | mov ebx, [esp+64+32-8+4] |
1486 | ; add window start x & y |
1592 | ; add window start x & y |
1487 | mov ecx, [TASK_BASE] |
1593 | mov ecx, [TASK_BASE] |
1488 | 1594 | ||
1489 | mov edi, [CURRENT_TASK] |
1595 | mov edi, [CURRENT_TASK] |
1490 | shl edi, 8 |
1596 | shl edi, 8 |
1491 | 1597 | ||
1492 | mov eax, [ecx-twdw+WDATA.box.left] |
1598 | mov eax, [ecx-twdw+WDATA.box.left] |
1493 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1599 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1494 | shl eax, 16 |
1600 | shl eax, 16 |
1495 | add eax, [ecx-twdw+WDATA.box.top] |
1601 | add eax, [ecx-twdw+WDATA.box.top] |
1496 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1602 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1497 | add ebx, eax |
1603 | add ebx, eax |
1498 | mov ecx, [esp+64+32-12+4] |
1604 | mov ecx, [esp+64+32-12+4] |
1499 | and ecx, not 0x80000000 ; force counted string |
1605 | and ecx, not 0x80000000 ; force counted string |
1500 | mov eax, [esp+64+8] ; background color (if given) |
1606 | mov eax, [esp+64+8] ; background color (if given) |
1501 | mov edi, [esp+64+4] |
1607 | mov edi, [esp+64+4] |
1502 | jmp dtext |
1608 | jmp dtext |
1503 | ;----------------------------------------------------------------------------- |
1609 | ;----------------------------------------------------------------------------- |
1504 | iglobal |
1610 | iglobal |
1505 | midi_base dw 0 |
1611 | midi_base dw 0 |
1506 | endg |
1612 | endg |
1507 | ;----------------------------------------------------------------------------- |
1613 | ;----------------------------------------------------------------------------- |
1508 | align 4 |
1614 | align 4 |
1509 | sys_setup: |
1615 | sys_setup: |
1510 | ; 1 = roland mpu midi base , base io address |
1616 | ; 1 = roland mpu midi base , base io address |
1511 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1617 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1512 | ; 3 = not used |
1618 | ; 3 = not used |
1513 | ; 4 = not used |
1619 | ; 4 = not used |
1514 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1620 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1515 | ; 6 = not used |
1621 | ; 6 = not used |
1516 | ; 7 = not used |
1622 | ; 7 = not used |
1517 | ; 8 = not used |
1623 | ; 8 = not used |
1518 | ; 9 = not used |
1624 | ; 9 = not used |
1519 | ; 10 = not used |
1625 | ; 10 = not used |
1520 | ; 11 = enable lba read |
1626 | ; 11 = enable lba read |
1521 | ; 12 = enable pci access |
1627 | ; 12 = enable pci access |
1522 | ;----------------------------------------------------------------------------- |
1628 | ;----------------------------------------------------------------------------- |
1523 | and [esp+32], dword 0 |
1629 | and [esp+32], dword 0 |
1524 | ; F.21.1 - set MPU MIDI base port |
1630 | ; F.21.1 - set MPU MIDI base port |
1525 | dec ebx |
1631 | dec ebx |
1526 | jnz @f |
1632 | jnz @f |
1527 | 1633 | ||
1528 | cmp ecx, 0x100 |
1634 | cmp ecx, 0x100 |
1529 | jb @f |
1635 | jb @f |
1530 | 1636 | ||
1531 | mov esi, 65535 |
1637 | mov esi, 65535 |
1532 | cmp esi, ecx |
1638 | cmp esi, ecx |
1533 | jb @f |
1639 | jb @f |
1534 | 1640 | ||
1535 | mov [midi_base], cx |
1641 | mov [midi_base], cx |
1536 | mov word [mididp], cx |
1642 | mov word [mididp], cx |
1537 | inc cx |
1643 | inc cx |
1538 | mov word [midisp], cx |
1644 | mov word [midisp], cx |
1539 | ret |
1645 | ret |
1540 | ;-------------------------------------- |
1646 | ;-------------------------------------- |
1541 | @@: |
1647 | @@: |
1542 | ; F.21.2 - set keyboard layout |
1648 | ; F.21.2 - set keyboard layout |
1543 | dec ebx |
1649 | dec ebx |
1544 | jnz @f |
1650 | jnz @f |
1545 | 1651 | ||
1546 | mov edi, [TASK_BASE] |
1652 | mov edi, [TASK_BASE] |
1547 | mov eax, [edi+TASKDATA.mem_start] |
1653 | mov eax, [edi+TASKDATA.mem_start] |
1548 | add eax, edx |
1654 | add eax, edx |
1549 | ; 1 = normal layout |
1655 | ; 1 = normal layout |
1550 | dec ecx |
1656 | dec ecx |
1551 | jnz .shift |
1657 | jnz .shift |
1552 | 1658 | ||
1553 | mov ebx, keymap |
1659 | mov ebx, keymap |
1554 | mov ecx, 128 |
1660 | mov ecx, 128 |
1555 | call memmove |
1661 | call memmove |
1556 | ret |
1662 | ret |
1557 | ;-------------------------------------- |
1663 | ;-------------------------------------- |
1558 | .shift: |
1664 | .shift: |
1559 | ; 2 = layout at pressed Shift |
1665 | ; 2 = layout at pressed Shift |
1560 | dec ecx |
1666 | dec ecx |
1561 | jnz .alt |
1667 | jnz .alt |
1562 | 1668 | ||
1563 | mov ebx, keymap_shift |
1669 | mov ebx, keymap_shift |
1564 | mov ecx, 128 |
1670 | mov ecx, 128 |
1565 | call memmove |
1671 | call memmove |
1566 | ret |
1672 | ret |
1567 | ;-------------------------------------- |
1673 | ;-------------------------------------- |
1568 | .alt: |
1674 | .alt: |
1569 | ; 3 = layout at pressed Alt |
1675 | ; 3 = layout at pressed Alt |
1570 | dec ecx |
1676 | dec ecx |
1571 | jnz .country |
1677 | jnz .country |
1572 | 1678 | ||
1573 | mov ebx, keymap_alt |
1679 | mov ebx, keymap_alt |
1574 | mov ecx, 128 |
1680 | mov ecx, 128 |
1575 | call memmove |
1681 | call memmove |
1576 | ret |
1682 | ret |
1577 | ;-------------------------------------- |
1683 | ;-------------------------------------- |
1578 | .country: |
1684 | .country: |
1579 | ; country identifier |
1685 | ; country identifier |
1580 | sub ecx, 6 |
1686 | sub ecx, 6 |
1581 | jnz .error |
1687 | jnz .error |
1582 | 1688 | ||
1583 | mov word [keyboard], dx |
1689 | mov word [keyboard], dx |
1584 | ret |
1690 | ret |
1585 | ;-------------------------------------- |
1691 | ;-------------------------------------- |
1586 | @@: |
1692 | @@: |
1587 | ; F.21.5 - set system language |
1693 | ; F.21.5 - set system language |
1588 | sub ebx, 3 |
1694 | sub ebx, 3 |
1589 | jnz @f |
1695 | jnz @f |
1590 | 1696 | ||
1591 | mov [syslang], ecx |
1697 | mov [syslang], ecx |
1592 | ret |
1698 | ret |
1593 | ;-------------------------------------- |
1699 | ;-------------------------------------- |
1594 | @@: |
1700 | @@: |
1595 | ; F.21.11 - enable/disable low-level access to HD |
1701 | ; F.21.11 - enable/disable low-level access to HD |
1596 | and ecx, 1 |
1702 | and ecx, 1 |
1597 | sub ebx, 6 |
1703 | sub ebx, 6 |
1598 | jnz @f |
1704 | jnz @f |
1599 | 1705 | ||
1600 | mov [lba_read_enabled], ecx |
1706 | mov [lba_read_enabled], ecx |
1601 | ret |
1707 | ret |
1602 | ;-------------------------------------- |
1708 | ;-------------------------------------- |
1603 | @@: |
1709 | @@: |
1604 | ; F.21.12 - enable/disable low-level access to PCI |
1710 | ; F.21.12 - enable/disable low-level access to PCI |
1605 | dec ebx |
1711 | dec ebx |
1606 | jnz .error |
1712 | jnz .error |
1607 | 1713 | ||
1608 | mov [pci_access_enabled], ecx |
1714 | mov [pci_access_enabled], ecx |
1609 | ret |
1715 | ret |
1610 | ;-------------------------------------- |
1716 | ;-------------------------------------- |
1611 | .error: |
1717 | .error: |
1612 | or [esp+32], dword -1 |
1718 | or [esp+32], dword -1 |
1613 | ret |
1719 | ret |
1614 | ;----------------------------------------------------------------------------- |
1720 | ;----------------------------------------------------------------------------- |
1615 | align 4 |
1721 | align 4 |
1616 | sys_getsetup: |
1722 | sys_getsetup: |
1617 | ; 1 = roland mpu midi base , base io address |
1723 | ; 1 = roland mpu midi base , base io address |
1618 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1724 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1619 | ; 3 = not used |
1725 | ; 3 = not used |
1620 | ; 4 = not used |
1726 | ; 4 = not used |
1621 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1727 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1622 | ; 6 = not used |
1728 | ; 6 = not used |
1623 | ; 7 = not used |
1729 | ; 7 = not used |
1624 | ; 8 = not used |
1730 | ; 8 = not used |
1625 | ; 9 = get hs timer tic |
1731 | ; 9 = get hs timer tic |
1626 | ; 10 = not used |
1732 | ; 10 = not used |
1627 | ; 11 = get the state "lba read" |
1733 | ; 11 = get the state "lba read" |
1628 | ; 12 = get the state "pci access" |
1734 | ; 12 = get the state "pci access" |
1629 | ;----------------------------------------------------------------------------- |
1735 | ;----------------------------------------------------------------------------- |
1630 | ; F.26.1 - get MPU MIDI base port |
1736 | ; F.26.1 - get MPU MIDI base port |
1631 | dec ebx |
1737 | dec ebx |
1632 | jnz @f |
1738 | jnz @f |
1633 | 1739 | ||
1634 | movzx eax, [midi_base] |
1740 | movzx eax, [midi_base] |
1635 | mov [esp+32], eax |
1741 | mov [esp+32], eax |
1636 | ret |
1742 | ret |
1637 | ;-------------------------------------- |
1743 | ;-------------------------------------- |
1638 | @@: |
1744 | @@: |
1639 | ; F.26.2 - get keyboard layout |
1745 | ; F.26.2 - get keyboard layout |
1640 | dec ebx |
1746 | dec ebx |
1641 | jnz @f |
1747 | jnz @f |
1642 | 1748 | ||
1643 | mov edi, [TASK_BASE] |
1749 | mov edi, [TASK_BASE] |
1644 | mov ebx, [edi+TASKDATA.mem_start] |
1750 | mov ebx, [edi+TASKDATA.mem_start] |
1645 | add ebx, edx |
1751 | add ebx, edx |
1646 | ; 1 = normal layout |
1752 | ; 1 = normal layout |
1647 | dec ecx |
1753 | dec ecx |
1648 | jnz .shift |
1754 | jnz .shift |
1649 | 1755 | ||
1650 | mov eax, keymap |
1756 | mov eax, keymap |
1651 | mov ecx, 128 |
1757 | mov ecx, 128 |
1652 | call memmove |
1758 | call memmove |
1653 | ret |
1759 | ret |
1654 | ;-------------------------------------- |
1760 | ;-------------------------------------- |
1655 | .shift: |
1761 | .shift: |
1656 | ; 2 = layout with pressed Shift |
1762 | ; 2 = layout with pressed Shift |
1657 | dec ecx |
1763 | dec ecx |
1658 | jnz .alt |
1764 | jnz .alt |
1659 | 1765 | ||
1660 | mov eax, keymap_shift |
1766 | mov eax, keymap_shift |
1661 | mov ecx, 128 |
1767 | mov ecx, 128 |
1662 | call memmove |
1768 | call memmove |
1663 | ret |
1769 | ret |
1664 | ;-------------------------------------- |
1770 | ;-------------------------------------- |
1665 | .alt: |
1771 | .alt: |
1666 | ; 3 = layout with pressed Alt |
1772 | ; 3 = layout with pressed Alt |
1667 | dec ecx |
1773 | dec ecx |
1668 | jne .country |
1774 | jne .country |
1669 | 1775 | ||
1670 | mov eax, keymap_alt |
1776 | mov eax, keymap_alt |
1671 | mov ecx, 128 |
1777 | mov ecx, 128 |
1672 | call memmove |
1778 | call memmove |
1673 | ret |
1779 | ret |
1674 | ;-------------------------------------- |
1780 | ;-------------------------------------- |
1675 | .country: |
1781 | .country: |
1676 | ; 9 = country identifier |
1782 | ; 9 = country identifier |
1677 | sub ecx, 6 |
1783 | sub ecx, 6 |
1678 | jnz .error |
1784 | jnz .error |
1679 | 1785 | ||
1680 | movzx eax, word [keyboard] |
1786 | movzx eax, word [keyboard] |
1681 | mov [esp+32], eax |
1787 | mov [esp+32], eax |
1682 | ret |
1788 | ret |
1683 | ;-------------------------------------- |
1789 | ;-------------------------------------- |
1684 | @@: |
1790 | @@: |
1685 | ; F.26.5 - get system language |
1791 | ; F.26.5 - get system language |
1686 | sub ebx, 3 |
1792 | sub ebx, 3 |
1687 | jnz @f |
1793 | jnz @f |
1688 | 1794 | ||
1689 | mov eax, [syslang] |
1795 | mov eax, [syslang] |
1690 | mov [esp+32], eax |
1796 | mov [esp+32], eax |
1691 | ret |
1797 | ret |
1692 | ;-------------------------------------- |
1798 | ;-------------------------------------- |
1693 | @@: |
1799 | @@: |
1694 | ; F.26.9 - get the value of the time counter |
1800 | ; F.26.9 - get the value of the time counter |
1695 | sub ebx, 4 |
1801 | sub ebx, 4 |
1696 | jnz @f |
1802 | jnz @f |
1697 | 1803 | ||
1698 | mov eax, [timer_ticks] |
1804 | mov eax, [timer_ticks] |
1699 | mov [esp+32], eax |
1805 | mov [esp+32], eax |
1700 | ret |
1806 | ret |
1701 | ;-------------------------------------- |
1807 | ;-------------------------------------- |
1702 | @@: |
1808 | @@: |
1703 | ; F.26.11 - Find out whether low-level HD access is enabled |
1809 | ; F.26.11 - Find out whether low-level HD access is enabled |
1704 | sub ebx, 2 |
1810 | sub ebx, 2 |
1705 | jnz @f |
1811 | jnz @f |
1706 | 1812 | ||
1707 | mov eax, [lba_read_enabled] |
1813 | mov eax, [lba_read_enabled] |
1708 | mov [esp+32], eax |
1814 | mov [esp+32], eax |
1709 | ret |
1815 | ret |
1710 | ;-------------------------------------- |
1816 | ;-------------------------------------- |
1711 | @@: |
1817 | @@: |
1712 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1818 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1713 | dec ebx |
1819 | dec ebx |
1714 | jnz .error |
1820 | jnz .error |
1715 | 1821 | ||
1716 | mov eax, [pci_access_enabled] |
1822 | mov eax, [pci_access_enabled] |
1717 | mov [esp+32], eax |
1823 | mov [esp+32], eax |
1718 | ret |
1824 | ret |
1719 | ;-------------------------------------- |
1825 | ;-------------------------------------- |
1720 | .error: |
1826 | .error: |
1721 | or [esp+32], dword -1 |
1827 | or [esp+32], dword -1 |
1722 | ret |
1828 | ret |
1723 | ;----------------------------------------------------------------------------- |
1829 | ;----------------------------------------------------------------------------- |
1724 | get_timer_ticks: |
1830 | get_timer_ticks: |
1725 | mov eax, [timer_ticks] |
1831 | mov eax, [timer_ticks] |
1726 | ret |
1832 | ret |
1727 | ;----------------------------------------------------------------------------- |
1833 | ;----------------------------------------------------------------------------- |
1728 | iglobal |
1834 | iglobal |
1729 | align 4 |
1835 | align 4 |
1730 | mousefn dd msscreen, mswin, msbutton, msset |
1836 | mousefn dd msscreen, mswin, msbutton, msset |
1731 | dd app_load_cursor |
1837 | dd app_load_cursor |
1732 | dd app_set_cursor |
1838 | dd app_set_cursor |
1733 | dd app_delete_cursor |
1839 | dd app_delete_cursor |
1734 | dd msz |
1840 | dd msz |
1735 | endg |
1841 | endg |
1736 | ;----------------------------------------------------------------------------- |
1842 | ;----------------------------------------------------------------------------- |
1737 | readmousepos: |
1843 | readmousepos: |
1738 | 1844 | ||
1739 | ; eax=0 screen relative |
1845 | ; eax=0 screen relative |
1740 | ; eax=1 window relative |
1846 | ; eax=1 window relative |
1741 | ; eax=2 buttons pressed |
1847 | ; eax=2 buttons pressed |
1742 | ; eax=3 set mouse pos ; reserved |
1848 | ; eax=3 set mouse pos ; reserved |
1743 | ; eax=4 load cursor |
1849 | ; eax=4 load cursor |
1744 | ; eax=5 set cursor |
1850 | ; eax=5 set cursor |
1745 | ; eax=6 delete cursor ; reserved |
1851 | ; eax=6 delete cursor ; reserved |
1746 | ; eax=7 get mouse_z |
1852 | ; eax=7 get mouse_z |
1747 | 1853 | ||
1748 | cmp ebx, 7 |
1854 | cmp ebx, 7 |
1749 | ja msset |
1855 | ja msset |
1750 | jmp [mousefn+ebx*4] |
1856 | jmp [mousefn+ebx*4] |
1751 | msscreen: |
1857 | msscreen: |
1752 | mov eax, [MOUSE_X] |
1858 | mov eax, [MOUSE_X] |
1753 | shl eax, 16 |
1859 | shl eax, 16 |
1754 | mov ax, [MOUSE_Y] |
1860 | mov ax, [MOUSE_Y] |
1755 | mov [esp+36-4], eax |
1861 | mov [esp+36-4], eax |
1756 | ret |
1862 | ret |
1757 | mswin: |
1863 | mswin: |
1758 | mov eax, [MOUSE_X] |
1864 | mov eax, [MOUSE_X] |
1759 | shl eax, 16 |
1865 | shl eax, 16 |
1760 | mov ax, [MOUSE_Y] |
1866 | mov ax, [MOUSE_Y] |
1761 | mov esi, [TASK_BASE] |
1867 | mov esi, [TASK_BASE] |
1762 | mov bx, word [esi-twdw+WDATA.box.left] |
1868 | mov bx, word [esi-twdw+WDATA.box.left] |
1763 | shl ebx, 16 |
1869 | shl ebx, 16 |
1764 | mov bx, word [esi-twdw+WDATA.box.top] |
1870 | mov bx, word [esi-twdw+WDATA.box.top] |
1765 | sub eax, ebx |
1871 | sub eax, ebx |
1766 | 1872 | ||
1767 | mov edi, [CURRENT_TASK] |
1873 | mov edi, [CURRENT_TASK] |
1768 | shl edi, 8 |
1874 | shl edi, 8 |
1769 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1875 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1770 | rol eax, 16 |
1876 | rol eax, 16 |
1771 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1877 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1772 | rol eax, 16 |
1878 | rol eax, 16 |
1773 | mov [esp+36-4], eax |
1879 | mov [esp+36-4], eax |
1774 | ret |
1880 | ret |
1775 | msbutton: |
1881 | msbutton: |
1776 | movzx eax, byte [BTN_DOWN] |
1882 | movzx eax, byte [BTN_DOWN] |
1777 | mov [esp+36-4], eax |
1883 | mov [esp+36-4], eax |
1778 | ret |
1884 | ret |
1779 | msz: |
1885 | msz: |
1780 | mov edi, [TASK_COUNT] |
1886 | mov edi, [TASK_COUNT] |
1781 | movzx edi, word [WIN_POS + edi*2] |
1887 | movzx edi, word [WIN_POS + edi*2] |
1782 | cmp edi, [CURRENT_TASK] |
1888 | cmp edi, [CURRENT_TASK] |
1783 | jne @f |
1889 | jne @f |
1784 | mov ax, [MOUSE_SCROLL_H] |
1890 | mov ax, [MOUSE_SCROLL_H] |
1785 | shl eax, 16 |
1891 | shl eax, 16 |
1786 | mov ax, [MOUSE_SCROLL_V] |
1892 | mov ax, [MOUSE_SCROLL_V] |
1787 | mov [esp+36-4], eax |
1893 | mov [esp+36-4], eax |
1788 | and [MOUSE_SCROLL_H], word 0 |
1894 | and [MOUSE_SCROLL_H], word 0 |
1789 | and [MOUSE_SCROLL_V], word 0 |
1895 | and [MOUSE_SCROLL_V], word 0 |
1790 | ret |
1896 | ret |
1791 | @@: |
1897 | @@: |
1792 | and [esp+36-4], dword 0 |
1898 | and [esp+36-4], dword 0 |
1793 | ; ret |
1899 | ; ret |
1794 | msset: |
1900 | msset: |
1795 | ret |
1901 | ret |
1796 | 1902 | ||
1797 | app_load_cursor: |
1903 | app_load_cursor: |
1798 | cmp ecx, OS_BASE |
1904 | cmp ecx, OS_BASE |
1799 | jae msset |
1905 | jae msset |
1800 | stdcall load_cursor, ecx, edx |
1906 | stdcall load_cursor, ecx, edx |
1801 | mov [esp+36-4], eax |
1907 | mov [esp+36-4], eax |
1802 | ret |
1908 | ret |
1803 | 1909 | ||
1804 | app_set_cursor: |
1910 | app_set_cursor: |
1805 | stdcall set_cursor, ecx |
1911 | stdcall set_cursor, ecx |
1806 | mov [esp+36-4], eax |
1912 | mov [esp+36-4], eax |
1807 | ret |
1913 | ret |
1808 | 1914 | ||
1809 | app_delete_cursor: |
1915 | app_delete_cursor: |
1810 | stdcall delete_cursor, ecx |
1916 | stdcall delete_cursor, ecx |
1811 | mov [esp+36-4], eax |
1917 | mov [esp+36-4], eax |
1812 | ret |
1918 | ret |
1813 | 1919 | ||
1814 | is_input: |
1920 | is_input: |
1815 | 1921 | ||
1816 | push edx |
1922 | push edx |
1817 | mov dx, word [midisp] |
1923 | mov dx, word [midisp] |
1818 | in al, dx |
1924 | in al, dx |
1819 | and al, 0x80 |
1925 | and al, 0x80 |
1820 | pop edx |
1926 | pop edx |
1821 | ret |
1927 | ret |
1822 | 1928 | ||
1823 | is_output: |
1929 | is_output: |
1824 | 1930 | ||
1825 | push edx |
1931 | push edx |
1826 | mov dx, word [midisp] |
1932 | mov dx, word [midisp] |
1827 | in al, dx |
1933 | in al, dx |
1828 | and al, 0x40 |
1934 | and al, 0x40 |
1829 | pop edx |
1935 | pop edx |
1830 | ret |
1936 | ret |
1831 | 1937 | ||
1832 | 1938 | ||
1833 | get_mpu_in: |
1939 | get_mpu_in: |
1834 | 1940 | ||
1835 | push edx |
1941 | push edx |
1836 | mov dx, word [mididp] |
1942 | mov dx, word [mididp] |
1837 | in al, dx |
1943 | in al, dx |
1838 | pop edx |
1944 | pop edx |
1839 | ret |
1945 | ret |
1840 | 1946 | ||
1841 | 1947 | ||
1842 | put_mpu_out: |
1948 | put_mpu_out: |
1843 | 1949 | ||
1844 | push edx |
1950 | push edx |
1845 | mov dx, word [mididp] |
1951 | mov dx, word [mididp] |
1846 | out dx, al |
1952 | out dx, al |
1847 | pop edx |
1953 | pop edx |
1848 | ret |
1954 | ret |
1849 | 1955 | ||
1850 | 1956 | ||
1851 | 1957 | ||
1852 | align 4 |
1958 | align 4 |
1853 | 1959 | ||
1854 | sys_midi: |
1960 | sys_midi: |
1855 | cmp [mididp], 0 |
1961 | cmp [mididp], 0 |
1856 | jnz sm0 |
1962 | jnz sm0 |
1857 | mov [esp+36], dword 1 |
1963 | mov [esp+36], dword 1 |
1858 | ret |
1964 | ret |
1859 | sm0: |
1965 | sm0: |
1860 | and [esp+36], dword 0 |
1966 | and [esp+36], dword 0 |
1861 | dec ebx |
1967 | dec ebx |
1862 | jnz smn1 |
1968 | jnz smn1 |
1863 | ; call setuart |
1969 | ; call setuart |
1864 | su1: |
1970 | su1: |
1865 | call is_output |
1971 | call is_output |
1866 | test al, al |
1972 | test al, al |
1867 | jnz su1 |
1973 | jnz su1 |
1868 | mov dx, word [midisp] |
1974 | mov dx, word [midisp] |
1869 | mov al, 0xff |
1975 | mov al, 0xff |
1870 | out dx, al |
1976 | out dx, al |
1871 | su2: |
1977 | su2: |
1872 | mov dx, word [midisp] |
1978 | mov dx, word [midisp] |
1873 | mov al, 0xff |
1979 | mov al, 0xff |
1874 | out dx, al |
1980 | out dx, al |
1875 | call is_input |
1981 | call is_input |
1876 | test al, al |
1982 | test al, al |
1877 | jnz su2 |
1983 | jnz su2 |
1878 | call get_mpu_in |
1984 | call get_mpu_in |
1879 | cmp al, 0xfe |
1985 | cmp al, 0xfe |
1880 | jnz su2 |
1986 | jnz su2 |
1881 | su3: |
1987 | su3: |
1882 | call is_output |
1988 | call is_output |
1883 | test al, al |
1989 | test al, al |
1884 | jnz su3 |
1990 | jnz su3 |
1885 | mov dx, word [midisp] |
1991 | mov dx, word [midisp] |
1886 | mov al, 0x3f |
1992 | mov al, 0x3f |
1887 | out dx, al |
1993 | out dx, al |
1888 | ret |
1994 | ret |
1889 | smn1: |
1995 | smn1: |
1890 | dec ebx |
1996 | dec ebx |
1891 | jnz smn2 |
1997 | jnz smn2 |
1892 | sm10: |
1998 | sm10: |
1893 | call get_mpu_in |
1999 | call get_mpu_in |
1894 | call is_output |
2000 | call is_output |
1895 | test al, al |
2001 | test al, al |
1896 | jnz sm10 |
2002 | jnz sm10 |
1897 | mov al, bl |
2003 | mov al, bl |
1898 | call put_mpu_out |
2004 | call put_mpu_out |
1899 | smn2: |
2005 | smn2: |
1900 | ret |
2006 | ret |
1901 | 2007 | ||
1902 | detect_devices: |
2008 | detect_devices: |
1903 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2009 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1904 | ;include 'detect/commouse.inc' |
2010 | ;include 'detect/commouse.inc' |
1905 | ;include 'detect/ps2mouse.inc' |
2011 | ;include 'detect/ps2mouse.inc' |
1906 | ;include 'detect/dev_fd.inc' |
2012 | ;include 'detect/dev_fd.inc' |
1907 | ;include 'detect/dev_hdcd.inc' |
2013 | ;include 'detect/dev_hdcd.inc' |
1908 | ;include 'detect/sear_par.inc' |
2014 | ;include 'detect/sear_par.inc' |
1909 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2015 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
1910 | ret |
2016 | ret |
1911 | 2017 | ||
1912 | sys_end: |
2018 | sys_end: |
1913 | ;-------------------------------------- |
2019 | ;-------------------------------------- |
1914 | cmp [_display.select_cursor], 0 |
2020 | cmp [_display.select_cursor], 0 |
1915 | je @f |
2021 | je @f |
1916 | ; restore default cursor before killing |
2022 | ; restore default cursor before killing |
1917 | pusha |
2023 | pusha |
1918 | mov ecx, [current_slot] |
2024 | mov ecx, [current_slot] |
1919 | call restore_default_cursor_before_killing |
2025 | call restore_default_cursor_before_killing |
1920 | popa |
2026 | popa |
1921 | @@: |
2027 | @@: |
1922 | ;-------------------------------------- |
2028 | ;-------------------------------------- |
1923 | ; kill all sockets this process owns |
2029 | ; kill all sockets this process owns |
1924 | pusha |
2030 | pusha |
1925 | mov edx, [TASK_BASE] |
2031 | mov edx, [TASK_BASE] |
1926 | mov edx, [edx+TASKDATA.pid] |
2032 | mov edx, [edx+TASKDATA.pid] |
1927 | call SOCKET_process_end |
2033 | call SOCKET_process_end |
1928 | popa |
2034 | popa |
1929 | ;-------------------------------------- |
2035 | ;-------------------------------------- |
1930 | mov ecx, [current_slot] |
2036 | mov ecx, [current_slot] |
1931 | mov eax, [ecx+APPDATA.tls_base] |
2037 | mov eax, [ecx+APPDATA.tls_base] |
1932 | test eax, eax |
2038 | test eax, eax |
1933 | jz @F |
2039 | jz @F |
1934 | 2040 | ||
1935 | stdcall user_free, eax |
2041 | stdcall user_free, eax |
1936 | @@: |
2042 | @@: |
1937 | 2043 | ||
1938 | mov eax, [TASK_BASE] |
2044 | mov eax, [TASK_BASE] |
1939 | mov [eax+TASKDATA.state], 3; terminate this program |
2045 | mov [eax+TASKDATA.state], 3; terminate this program |
1940 | call wakeup_osloop |
2046 | call wakeup_osloop |
1941 | 2047 | ||
1942 | .waitterm: ; wait here for termination |
2048 | .waitterm: ; wait here for termination |
1943 | call change_task |
2049 | call change_task |
1944 | jmp .waitterm |
2050 | jmp .waitterm |
1945 | ;------------------------------------------------------------------------------ |
2051 | ;------------------------------------------------------------------------------ |
1946 | align 4 |
2052 | align 4 |
1947 | restore_default_cursor_before_killing: |
2053 | restore_default_cursor_before_killing: |
1948 | pushfd |
2054 | pushfd |
1949 | cli |
2055 | cli |
1950 | mov eax, [def_cursor] |
2056 | mov eax, [def_cursor] |
1951 | mov [ecx+APPDATA.cursor], eax |
2057 | mov [ecx+APPDATA.cursor], eax |
1952 | 2058 | ||
1953 | movzx eax, word [MOUSE_Y] |
2059 | movzx eax, word [MOUSE_Y] |
1954 | movzx ebx, word [MOUSE_X] |
2060 | movzx ebx, word [MOUSE_X] |
1955 | mov eax, [d_width_calc_area + eax*4] |
2061 | mov eax, [d_width_calc_area + eax*4] |
1956 | 2062 | ||
1957 | add eax, [_WinMapAddress] |
2063 | add eax, [_WinMapAddress] |
1958 | movzx edx, byte [ebx+eax] |
2064 | movzx edx, byte [ebx+eax] |
1959 | shl edx, 8 |
2065 | shl edx, 8 |
1960 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2066 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
1961 | 2067 | ||
1962 | cmp esi, [current_cursor] |
2068 | cmp esi, [current_cursor] |
1963 | je @f |
2069 | je @f |
1964 | 2070 | ||
1965 | push esi |
2071 | push esi |
1966 | call [_display.select_cursor] |
2072 | call [_display.select_cursor] |
1967 | mov [current_cursor], esi |
2073 | mov [current_cursor], esi |
1968 | @@: |
2074 | @@: |
1969 | mov [redrawmouse_unconditional], 1 |
2075 | mov [redrawmouse_unconditional], 1 |
1970 | call wakeup_osloop |
2076 | call wakeup_osloop |
1971 | popfd |
2077 | popfd |
1972 | ret |
2078 | ret |
1973 | ;------------------------------------------------------------------------------ |
2079 | ;------------------------------------------------------------------------------ |
1974 | iglobal |
2080 | iglobal |
1975 | align 4 |
2081 | align 4 |
1976 | sys_system_table: |
2082 | sys_system_table: |
1977 | dd sysfn_deactivate ; 1 = deactivate window |
2083 | dd sysfn_deactivate ; 1 = deactivate window |
1978 | dd sysfn_terminate ; 2 = terminate thread |
2084 | dd sysfn_terminate ; 2 = terminate thread |
1979 | dd sysfn_activate ; 3 = activate window |
2085 | dd sysfn_activate ; 3 = activate window |
1980 | dd sysfn_getidletime ; 4 = get idle time |
2086 | dd sysfn_getidletime ; 4 = get idle time |
1981 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2087 | dd sysfn_getcpuclock ; 5 = get cpu clock |
1982 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2088 | dd sysfn_saveramdisk ; 6 = save ramdisk |
1983 | dd sysfn_getactive ; 7 = get active window |
2089 | dd sysfn_getactive ; 7 = get active window |
1984 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2090 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
1985 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2091 | dd sysfn_shutdown ; 9 = shutdown with parameter |
1986 | dd sysfn_minimize ; 10 = minimize window |
2092 | dd sysfn_minimize ; 10 = minimize window |
1987 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2093 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
1988 | dd sysfn_lastkey ; 12 = get last pressed key |
2094 | dd sysfn_lastkey ; 12 = get last pressed key |
1989 | dd sysfn_getversion ; 13 = get kernel version |
2095 | dd sysfn_getversion ; 13 = get kernel version |
1990 | dd sysfn_waitretrace ; 14 = wait retrace |
2096 | dd sysfn_waitretrace ; 14 = wait retrace |
1991 | dd sysfn_centermouse ; 15 = center mouse cursor |
2097 | dd sysfn_centermouse ; 15 = center mouse cursor |
1992 | dd sysfn_getfreemem ; 16 = get free memory size |
2098 | dd sysfn_getfreemem ; 16 = get free memory size |
1993 | dd sysfn_getallmem ; 17 = get total memory size |
2099 | dd sysfn_getallmem ; 17 = get total memory size |
1994 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2100 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
1995 | ; instead of slot |
2101 | ; instead of slot |
1996 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2102 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
1997 | dd sysfn_meminfo ; 20 = get extended memory info |
2103 | dd sysfn_meminfo ; 20 = get extended memory info |
1998 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2104 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
1999 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2105 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2000 | dd sysfn_min_windows ; 23 = minimize all windows |
2106 | dd sysfn_min_windows ; 23 = minimize all windows |
2001 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2107 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2002 | sysfn_num = ($ - sys_system_table)/4 |
2108 | sysfn_num = ($ - sys_system_table)/4 |
2003 | endg |
2109 | endg |
2004 | ;------------------------------------------------------------------------------ |
2110 | ;------------------------------------------------------------------------------ |
2005 | sys_system: |
2111 | sys_system: |
2006 | dec ebx |
2112 | dec ebx |
2007 | cmp ebx, sysfn_num |
2113 | cmp ebx, sysfn_num |
2008 | jae @f |
2114 | jae @f |
2009 | jmp dword [sys_system_table + ebx*4] |
2115 | jmp dword [sys_system_table + ebx*4] |
2010 | @@: |
2116 | @@: |
2011 | ret |
2117 | ret |
2012 | ;------------------------------------------------------------------------------ |
2118 | ;------------------------------------------------------------------------------ |
2013 | sysfn_shutdown: ; 18.9 = system shutdown |
2119 | sysfn_shutdown: ; 18.9 = system shutdown |
2014 | cmp ecx, 1 |
2120 | cmp ecx, 1 |
2015 | jl exit_for_anyone |
2121 | jl exit_for_anyone |
2016 | cmp ecx, 4 |
2122 | cmp ecx, 4 |
2017 | jg exit_for_anyone |
2123 | jg exit_for_anyone |
2018 | mov [BOOT_VARS+0x9030], cl |
2124 | mov [BOOT_VARS+0x9030], cl |
2019 | 2125 | ||
2020 | mov eax, [TASK_COUNT] |
2126 | mov eax, [TASK_COUNT] |
2021 | mov [SYS_SHUTDOWN], al |
2127 | mov [SYS_SHUTDOWN], al |
2022 | mov [shutdown_processes], eax |
2128 | mov [shutdown_processes], eax |
2023 | call wakeup_osloop |
2129 | call wakeup_osloop |
2024 | and dword [esp+32], 0 |
2130 | and dword [esp+32], 0 |
2025 | exit_for_anyone: |
2131 | exit_for_anyone: |
2026 | ret |
2132 | ret |
2027 | uglobal |
2133 | uglobal |
2028 | shutdown_processes: |
2134 | shutdown_processes: |
2029 | dd 0x0 |
2135 | dd 0x0 |
2030 | endg |
2136 | endg |
2031 | ;------------------------------------------------------------------------------ |
2137 | ;------------------------------------------------------------------------------ |
2032 | sysfn_terminate: ; 18.2 = TERMINATE |
2138 | sysfn_terminate: ; 18.2 = TERMINATE |
2033 | push ecx |
2139 | push ecx |
2034 | cmp ecx, 2 |
2140 | cmp ecx, 2 |
2035 | jb noprocessterminate |
2141 | jb noprocessterminate |
2036 | mov edx, [TASK_COUNT] |
2142 | mov edx, [TASK_COUNT] |
2037 | cmp ecx, edx |
2143 | cmp ecx, edx |
2038 | ja noprocessterminate |
2144 | ja noprocessterminate |
2039 | mov eax, [TASK_COUNT] |
2145 | mov eax, [TASK_COUNT] |
2040 | shl ecx, 5 |
2146 | shl ecx, 5 |
2041 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2147 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2042 | add ecx, CURRENT_TASK+TASKDATA.state |
2148 | add ecx, CURRENT_TASK+TASKDATA.state |
2043 | cmp byte [ecx], 9 |
2149 | cmp byte [ecx], 9 |
2044 | jz noprocessterminate |
2150 | jz noprocessterminate |
2045 | push ecx edx |
2151 | push ecx edx |
2046 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2152 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2047 | call request_terminate |
2153 | call request_terminate |
2048 | pop edx ecx |
2154 | pop edx ecx |
2049 | test eax, eax |
2155 | test eax, eax |
2050 | jz noprocessterminate |
2156 | jz noprocessterminate |
2051 | ;-------------------------------------- |
2157 | ;-------------------------------------- |
2052 | ; terminate all network sockets it used |
2158 | ; terminate all network sockets it used |
2053 | pusha |
2159 | pusha |
2054 | mov eax, edx |
2160 | mov eax, edx |
2055 | call SOCKET_process_end |
2161 | call SOCKET_process_end |
2056 | popa |
2162 | popa |
2057 | ;-------------------------------------- |
2163 | ;-------------------------------------- |
2058 | cmp [_display.select_cursor], 0 |
2164 | cmp [_display.select_cursor], 0 |
2059 | je .restore_end |
2165 | je .restore_end |
2060 | ; restore default cursor before killing |
2166 | ; restore default cursor before killing |
2061 | pusha |
2167 | pusha |
2062 | mov ecx, [esp+32] |
2168 | mov ecx, [esp+32] |
2063 | shl ecx, 8 |
2169 | shl ecx, 8 |
2064 | add ecx, SLOT_BASE |
2170 | add ecx, SLOT_BASE |
2065 | mov eax, [def_cursor] |
2171 | mov eax, [def_cursor] |
2066 | cmp [ecx+APPDATA.cursor], eax |
2172 | cmp [ecx+APPDATA.cursor], eax |
2067 | je @f |
2173 | je @f |
2068 | call restore_default_cursor_before_killing |
2174 | call restore_default_cursor_before_killing |
2069 | @@: |
2175 | @@: |
2070 | popa |
2176 | popa |
2071 | .restore_end: |
2177 | .restore_end: |
2072 | ;-------------------------------------- |
2178 | ;-------------------------------------- |
2073 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2179 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2074 | mov [ecx], byte 3; clear possible i40's |
2180 | mov [ecx], byte 3; clear possible i40's |
2075 | call wakeup_osloop |
2181 | call wakeup_osloop |
2076 | ;call MEM_Heap_UnLock |
2182 | ;call MEM_Heap_UnLock |
2077 | 2183 | ||
2078 | cmp edx, [application_table_owner]; clear app table stat |
2184 | cmp edx, [application_table_owner]; clear app table stat |
2079 | jne noatsc |
2185 | jne noatsc |
2080 | call unlock_application_table |
2186 | call unlock_application_table |
2081 | noatsc: |
2187 | noatsc: |
2082 | noprocessterminate: |
2188 | noprocessterminate: |
2083 | add esp, 4 |
2189 | add esp, 4 |
2084 | ret |
2190 | ret |
2085 | ;------------------------------------------------------------------------------ |
2191 | ;------------------------------------------------------------------------------ |
2086 | sysfn_terminate2: |
2192 | sysfn_terminate2: |
2087 | ;lock application_table_status mutex |
2193 | ;lock application_table_status mutex |
2088 | .table_status: |
2194 | .table_status: |
2089 | call lock_application_table |
2195 | call lock_application_table |
2090 | mov eax, ecx |
2196 | mov eax, ecx |
2091 | call pid_to_slot |
2197 | call pid_to_slot |
2092 | test eax, eax |
2198 | test eax, eax |
2093 | jz .not_found |
2199 | jz .not_found |
2094 | mov ecx, eax |
2200 | mov ecx, eax |
2095 | cli |
2201 | cli |
2096 | call sysfn_terminate |
2202 | call sysfn_terminate |
2097 | call unlock_application_table |
2203 | call unlock_application_table |
2098 | sti |
2204 | sti |
2099 | and dword [esp+32], 0 |
2205 | and dword [esp+32], 0 |
2100 | ret |
2206 | ret |
2101 | .not_found: |
2207 | .not_found: |
2102 | call unlock_application_table |
2208 | call unlock_application_table |
2103 | or dword [esp+32], -1 |
2209 | or dword [esp+32], -1 |
2104 | ret |
2210 | ret |
2105 | ;------------------------------------------------------------------------------ |
2211 | ;------------------------------------------------------------------------------ |
2106 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2212 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2107 | cmp ecx, 2 |
2213 | cmp ecx, 2 |
2108 | jb .nowindowdeactivate |
2214 | jb .nowindowdeactivate |
2109 | cmp ecx, [TASK_COUNT] |
2215 | cmp ecx, [TASK_COUNT] |
2110 | ja .nowindowdeactivate |
2216 | ja .nowindowdeactivate |
2111 | 2217 | ||
2112 | movzx esi, word [WIN_STACK + ecx*2] |
2218 | movzx esi, word [WIN_STACK + ecx*2] |
2113 | cmp esi, 1 |
2219 | cmp esi, 1 |
2114 | je .nowindowdeactivate ; already deactive |
2220 | je .nowindowdeactivate ; already deactive |
2115 | 2221 | ||
2116 | mov edi, ecx |
2222 | mov edi, ecx |
2117 | shl edi, 5 |
2223 | shl edi, 5 |
2118 | add edi, window_data |
2224 | add edi, window_data |
2119 | movzx esi, word [WIN_STACK + ecx * 2] |
2225 | movzx esi, word [WIN_STACK + ecx * 2] |
2120 | lea esi, [WIN_POS + esi * 2] |
2226 | lea esi, [WIN_POS + esi * 2] |
2121 | call window._.window_deactivate |
2227 | call window._.window_deactivate |
2122 | 2228 | ||
2123 | call syscall_display_settings._.calculate_whole_screen |
2229 | call syscall_display_settings._.calculate_whole_screen |
2124 | call syscall_display_settings._.redraw_whole_screen |
2230 | call syscall_display_settings._.redraw_whole_screen |
2125 | .nowindowdeactivate: |
2231 | .nowindowdeactivate: |
2126 | ret |
2232 | ret |
2127 | ;------------------------------------------------------------------------------ |
2233 | ;------------------------------------------------------------------------------ |
2128 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2234 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2129 | cmp ecx, 2 |
2235 | cmp ecx, 2 |
2130 | jb .nowindowactivate |
2236 | jb .nowindowactivate |
2131 | cmp ecx, [TASK_COUNT] |
2237 | cmp ecx, [TASK_COUNT] |
2132 | ja .nowindowactivate |
2238 | ja .nowindowactivate |
2133 | ;------------------------------------- |
2239 | ;------------------------------------- |
2134 | @@: |
2240 | @@: |
2135 | ; If the window is captured and moved by the user, |
2241 | ; If the window is captured and moved by the user, |
2136 | ; then you can't change the position in window stack!!! |
2242 | ; then you can't change the position in window stack!!! |
2137 | mov al, [mouse.active_sys_window.action] |
2243 | mov al, [mouse.active_sys_window.action] |
2138 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2244 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2139 | test al, al |
2245 | test al, al |
2140 | jz @f |
2246 | jz @f |
2141 | call change_task |
2247 | call change_task |
2142 | jmp @b |
2248 | jmp @b |
2143 | @@: |
2249 | @@: |
2144 | ;------------------------------------- |
2250 | ;------------------------------------- |
2145 | mov [window_minimize], 2; restore window if minimized |
2251 | mov [window_minimize], 2; restore window if minimized |
2146 | call wakeup_osloop |
2252 | call wakeup_osloop |
2147 | 2253 | ||
2148 | movzx esi, word [WIN_STACK + ecx*2] |
2254 | movzx esi, word [WIN_STACK + ecx*2] |
2149 | cmp esi, [TASK_COUNT] |
2255 | cmp esi, [TASK_COUNT] |
2150 | je .nowindowactivate; already active |
2256 | je .nowindowactivate; already active |
2151 | 2257 | ||
2152 | mov edi, ecx |
2258 | mov edi, ecx |
2153 | shl edi, 5 |
2259 | shl edi, 5 |
2154 | add edi, window_data |
2260 | add edi, window_data |
2155 | movzx esi, word [WIN_STACK + ecx * 2] |
2261 | movzx esi, word [WIN_STACK + ecx * 2] |
2156 | lea esi, [WIN_POS + esi * 2] |
2262 | lea esi, [WIN_POS + esi * 2] |
2157 | call waredraw |
2263 | call waredraw |
2158 | .nowindowactivate: |
2264 | .nowindowactivate: |
2159 | ret |
2265 | ret |
2160 | ;------------------------------------------------------------------------------ |
2266 | ;------------------------------------------------------------------------------ |
2161 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2267 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2162 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2268 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2163 | mov [esp+32], eax |
2269 | mov [esp+32], eax |
2164 | ret |
2270 | ret |
2165 | ;------------------------------------------------------------------------------ |
2271 | ;------------------------------------------------------------------------------ |
2166 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2272 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2167 | mov eax, dword [cpu_freq] |
2273 | mov eax, dword [cpu_freq] |
2168 | mov [esp+32], eax |
2274 | mov [esp+32], eax |
2169 | ret |
2275 | ret |
2170 | ;------------------------------------------------------------------------------ |
2276 | ;------------------------------------------------------------------------------ |
2171 | get_cpu_freq: |
2277 | get_cpu_freq: |
2172 | mov eax, dword [cpu_freq] |
2278 | mov eax, dword [cpu_freq] |
2173 | mov edx, dword [cpu_freq+4] |
2279 | mov edx, dword [cpu_freq+4] |
2174 | ret |
2280 | ret |
2175 | ; SAVE ramdisk to /hd/1/menuet.img |
2281 | ; SAVE ramdisk to /hd/1/menuet.img |
2176 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2282 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2177 | include 'blkdev/rdsave.inc' |
2283 | include 'blkdev/rdsave.inc' |
2178 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2284 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2179 | ;------------------------------------------------------------------------------ |
2285 | ;------------------------------------------------------------------------------ |
2180 | align 4 |
2286 | align 4 |
2181 | sysfn_getactive: ; 18.7 = get active window |
2287 | sysfn_getactive: ; 18.7 = get active window |
2182 | mov eax, [TASK_COUNT] |
2288 | mov eax, [TASK_COUNT] |
2183 | movzx eax, word [WIN_POS + eax*2] |
2289 | movzx eax, word [WIN_POS + eax*2] |
2184 | mov [esp+32], eax |
2290 | mov [esp+32], eax |
2185 | ret |
2291 | ret |
2186 | ;------------------------------------------------------------------------------ |
2292 | ;------------------------------------------------------------------------------ |
2187 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2293 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2188 | ; cmp ecx,1 |
2294 | ; cmp ecx,1 |
2189 | dec ecx |
2295 | dec ecx |
2190 | jnz nogetsoundflag |
2296 | jnz nogetsoundflag |
2191 | movzx eax, byte [sound_flag]; get sound_flag |
2297 | movzx eax, byte [sound_flag]; get sound_flag |
2192 | mov [esp+32], eax |
2298 | mov [esp+32], eax |
2193 | ret |
2299 | ret |
2194 | nogetsoundflag: |
2300 | nogetsoundflag: |
2195 | ; cmp ecx,2 |
2301 | ; cmp ecx,2 |
2196 | dec ecx |
2302 | dec ecx |
2197 | jnz nosoundflag |
2303 | jnz nosoundflag |
2198 | xor byte [sound_flag], 1 |
2304 | xor byte [sound_flag], 1 |
2199 | nosoundflag: |
2305 | nosoundflag: |
2200 | ret |
2306 | ret |
2201 | ;------------------------------------------------------------------------------ |
2307 | ;------------------------------------------------------------------------------ |
2202 | sysfn_minimize: ; 18.10 = minimize window |
2308 | sysfn_minimize: ; 18.10 = minimize window |
2203 | mov [window_minimize], 1 |
2309 | mov [window_minimize], 1 |
2204 | call wakeup_osloop |
2310 | call wakeup_osloop |
2205 | ret |
2311 | ret |
2206 | ;------------------------------------------------------------------------------ |
2312 | ;------------------------------------------------------------------------------ |
2207 | align 4 |
2313 | align 4 |
2208 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2314 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2209 | dec ecx |
2315 | dec ecx |
2210 | jnz .exit |
2316 | jnz .exit |
2211 | .small_table: |
2317 | .small_table: |
2212 | mov edi, edx |
2318 | mov edi, edx |
2213 | mov esi, DRIVE_DATA |
2319 | mov esi, DRIVE_DATA |
2214 | mov ecx, DRIVE_DATA_SIZE ;10 |
2320 | mov ecx, DRIVE_DATA_SIZE ;10 |
2215 | cld |
2321 | cld |
2216 | rep movsb |
2322 | rep movsb |
2217 | .exit: |
2323 | .exit: |
2218 | ret |
2324 | ret |
2219 | ;------------------------------------------------------------------------------ |
2325 | ;------------------------------------------------------------------------------ |
2220 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2326 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2221 | and dword [esp+32], 0 |
2327 | and dword [esp+32], 0 |
2222 | ret |
2328 | ret |
2223 | ;------------------------------------------------------------------------------ |
2329 | ;------------------------------------------------------------------------------ |
2224 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2330 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2225 | mov edi, ecx |
2331 | mov edi, ecx |
2226 | mov esi, version_inf |
2332 | mov esi, version_inf |
2227 | mov ecx, version_end-version_inf |
2333 | mov ecx, version_end-version_inf |
2228 | rep movsb |
2334 | rep movsb |
2229 | ret |
2335 | ret |
2230 | ;------------------------------------------------------------------------------ |
2336 | ;------------------------------------------------------------------------------ |
2231 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2337 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2232 | ;wait retrace functions |
2338 | ;wait retrace functions |
2233 | sys_wait_retrace: |
2339 | sys_wait_retrace: |
2234 | mov edx, 0x3da |
2340 | mov edx, 0x3da |
2235 | WaitRetrace_loop: |
2341 | WaitRetrace_loop: |
2236 | in al, dx |
2342 | in al, dx |
2237 | test al, 1000b |
2343 | test al, 1000b |
2238 | jz WaitRetrace_loop |
2344 | jz WaitRetrace_loop |
2239 | and [esp+32], dword 0 |
2345 | and [esp+32], dword 0 |
2240 | ret |
2346 | ret |
2241 | ;------------------------------------------------------------------------------ |
2347 | ;------------------------------------------------------------------------------ |
2242 | align 4 |
2348 | align 4 |
2243 | sysfn_centermouse: ; 18.15 = mouse centered |
2349 | sysfn_centermouse: ; 18.15 = mouse centered |
2244 | ; removed here by |
2350 | ; removed here by |
2245 | ; call mouse_centered |
2351 | ; call mouse_centered |
2246 | ;* mouse centered - start code- Mario79 |
2352 | ;* mouse centered - start code- Mario79 |
2247 | ;mouse_centered: |
2353 | ;mouse_centered: |
2248 | ; push eax |
2354 | ; push eax |
2249 | mov eax, [_display.width] |
2355 | mov eax, [Screen_Max_X] |
2250 | shr eax, 1 |
2356 | shr eax, 1 |
2251 | mov [MOUSE_X], ax |
2357 | mov [MOUSE_X], ax |
2252 | mov eax, [_display.height] |
2358 | mov eax, [Screen_Max_Y] |
2253 | shr eax, 1 |
2359 | shr eax, 1 |
2254 | mov [MOUSE_Y], ax |
2360 | mov [MOUSE_Y], ax |
2255 | call wakeup_osloop |
2361 | call wakeup_osloop |
2256 | ; ret |
2362 | ; ret |
2257 | ;* mouse centered - end code- Mario79 |
2363 | ;* mouse centered - end code- Mario79 |
2258 | xor eax, eax |
2364 | xor eax, eax |
2259 | and [esp+32], eax |
2365 | and [esp+32], eax |
2260 | ; pop eax |
2366 | ; pop eax |
2261 | ret |
2367 | ret |
2262 | ;------------------------------------------------------------------------------ |
2368 | ;------------------------------------------------------------------------------ |
2263 | align 4 |
2369 | align 4 |
2264 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2370 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2265 | test ecx, ecx; get mouse speed factor |
2371 | test ecx, ecx; get mouse speed factor |
2266 | jnz .set_mouse_acceleration |
2372 | jnz .set_mouse_acceleration |
2267 | xor eax, eax |
2373 | xor eax, eax |
2268 | mov ax, [mouse_speed_factor] |
2374 | mov ax, [mouse_speed_factor] |
2269 | mov [esp+32], eax |
2375 | mov [esp+32], eax |
2270 | ret |
2376 | ret |
2271 | .set_mouse_acceleration: |
2377 | .set_mouse_acceleration: |
2272 | ; cmp ecx,1 ; set mouse speed factor |
2378 | ; cmp ecx,1 ; set mouse speed factor |
2273 | dec ecx |
2379 | dec ecx |
2274 | jnz .get_mouse_delay |
2380 | jnz .get_mouse_delay |
2275 | mov [mouse_speed_factor], dx |
2381 | mov [mouse_speed_factor], dx |
2276 | ret |
2382 | ret |
2277 | .get_mouse_delay: |
2383 | .get_mouse_delay: |
2278 | ; cmp ecx,2 ; get mouse delay |
2384 | ; cmp ecx,2 ; get mouse delay |
2279 | dec ecx |
2385 | dec ecx |
2280 | jnz .set_mouse_delay |
2386 | jnz .set_mouse_delay |
2281 | mov eax, [mouse_delay] |
2387 | mov eax, [mouse_delay] |
2282 | mov [esp+32], eax |
2388 | mov [esp+32], eax |
2283 | ret |
2389 | ret |
2284 | .set_mouse_delay: |
2390 | .set_mouse_delay: |
2285 | ; cmp ecx,3 ; set mouse delay |
2391 | ; cmp ecx,3 ; set mouse delay |
2286 | dec ecx |
2392 | dec ecx |
2287 | jnz .set_pointer_position |
2393 | jnz .set_pointer_position |
2288 | mov [mouse_delay], edx |
2394 | mov [mouse_delay], edx |
2289 | ret |
2395 | ret |
2290 | .set_pointer_position: |
2396 | .set_pointer_position: |
2291 | ; cmp ecx,4 ; set mouse pointer position |
2397 | ; cmp ecx,4 ; set mouse pointer position |
2292 | dec ecx |
2398 | dec ecx |
2293 | jnz .set_mouse_button |
2399 | jnz .set_mouse_button |
2294 | cmp dx, word[_display.height] |
2400 | cmp dx, word[Screen_Max_Y] |
2295 | jae .end |
2401 | ja .end |
2296 | rol edx, 16 |
2402 | rol edx, 16 |
2297 | cmp dx, word[_display.width] |
2403 | cmp dx, word[Screen_Max_X] |
2298 | jae .end |
2404 | ja .end |
2299 | mov [MOUSE_X], edx |
2405 | mov [MOUSE_X], edx |
2300 | mov [mouse_active], 1 |
2406 | mov [mouse_active], 1 |
2301 | call wakeup_osloop |
2407 | call wakeup_osloop |
2302 | ret |
2408 | ret |
2303 | .set_mouse_button: |
2409 | .set_mouse_button: |
2304 | ; cmp ecx,5 ; set mouse button features |
2410 | ; cmp ecx,5 ; set mouse button features |
2305 | dec ecx |
2411 | dec ecx |
2306 | jnz .end |
2412 | jnz .end |
2307 | mov [BTN_DOWN], dl |
2413 | mov [BTN_DOWN], dl |
2308 | mov [mouse_active], 1 |
2414 | mov [mouse_active], 1 |
2309 | call wakeup_osloop |
2415 | call wakeup_osloop |
2310 | .end: |
2416 | .end: |
2311 | ret |
2417 | ret |
2312 | ;------------------------------------------------------------------------------ |
2418 | ;------------------------------------------------------------------------------ |
2313 | sysfn_getfreemem: |
2419 | sysfn_getfreemem: |
2314 | mov eax, [pg_data.pages_free] |
2420 | mov eax, [pg_data.pages_free] |
2315 | shl eax, 2 |
2421 | shl eax, 2 |
2316 | mov [esp+32], eax |
2422 | mov [esp+32], eax |
2317 | ret |
2423 | ret |
2318 | ;------------------------------------------------------------------------------ |
2424 | ;------------------------------------------------------------------------------ |
2319 | sysfn_getallmem: |
2425 | sysfn_getallmem: |
2320 | mov eax, [MEM_AMOUNT] |
2426 | mov eax, [MEM_AMOUNT] |
2321 | shr eax, 10 |
2427 | shr eax, 10 |
2322 | mov [esp+32], eax |
2428 | mov [esp+32], eax |
2323 | ret |
2429 | ret |
2324 | ;------------------------------------------------------------------------------ |
2430 | ;------------------------------------------------------------------------------ |
2325 | sysfn_pid_to_slot: |
2431 | sysfn_pid_to_slot: |
2326 | mov eax, ecx |
2432 | mov eax, ecx |
2327 | call pid_to_slot |
2433 | call pid_to_slot |
2328 | mov [esp+32], eax |
2434 | mov [esp+32], eax |
2329 | ret |
2435 | ret |
2330 | ;------------------------------------------------------------------------------ |
2436 | ;------------------------------------------------------------------------------ |
2331 | sysfn_min_rest_window: |
2437 | sysfn_min_rest_window: |
2332 | pushad |
2438 | pushad |
2333 | mov eax, edx ; ebx - operating |
2439 | mov eax, edx ; ebx - operating |
2334 | shr ecx, 1 |
2440 | shr ecx, 1 |
2335 | jnc @f |
2441 | jnc @f |
2336 | call pid_to_slot |
2442 | call pid_to_slot |
2337 | @@: |
2443 | @@: |
2338 | or eax, eax ; eax - number of slot |
2444 | or eax, eax ; eax - number of slot |
2339 | jz .error |
2445 | jz .error |
2340 | cmp eax, 255 ; varify maximal slot number |
2446 | cmp eax, 255 ; varify maximal slot number |
2341 | ja .error |
2447 | ja .error |
2342 | movzx eax, word [WIN_STACK + eax*2] |
2448 | movzx eax, word [WIN_STACK + eax*2] |
2343 | shr ecx, 1 |
2449 | shr ecx, 1 |
2344 | jc .restore |
2450 | jc .restore |
2345 | ; .minimize: |
2451 | ; .minimize: |
2346 | call minimize_window |
2452 | call minimize_window |
2347 | jmp .exit |
2453 | jmp .exit |
2348 | .restore: |
2454 | .restore: |
2349 | call restore_minimized_window |
2455 | call restore_minimized_window |
2350 | .exit: |
2456 | .exit: |
2351 | popad |
2457 | popad |
2352 | xor eax, eax |
2458 | xor eax, eax |
2353 | mov [esp+32], eax |
2459 | mov [esp+32], eax |
2354 | ret |
2460 | ret |
2355 | .error: |
2461 | .error: |
2356 | popad |
2462 | popad |
2357 | xor eax, eax |
2463 | xor eax, eax |
2358 | dec eax |
2464 | dec eax |
2359 | mov [esp+32], eax |
2465 | mov [esp+32], eax |
2360 | ret |
2466 | ret |
2361 | ;------------------------------------------------------------------------------ |
2467 | ;------------------------------------------------------------------------------ |
2362 | sysfn_min_windows: |
2468 | sysfn_min_windows: |
2363 | call minimize_all_window |
2469 | call minimize_all_window |
2364 | mov [esp+32], eax |
2470 | mov [esp+32], eax |
2365 | call change_task |
2471 | call change_task |
2366 | ret |
2472 | ret |
2367 | ;------------------------------------------------------------------------------ |
2473 | ;------------------------------------------------------------------------------ |
2368 | sysfn_set_screen_sizes: |
2474 | sysfn_set_screen_sizes: |
2369 | cmp [SCR_MODE], word 0x13 |
2475 | cmp [SCR_MODE], word 0x13 |
2370 | jbe .exit |
2476 | jbe .exit |
2371 | 2477 | ||
2372 | cmp [_display.select_cursor], select_cursor |
2478 | cmp [_display.select_cursor], select_cursor |
2373 | jne .exit |
2479 | jne .exit |
2374 | 2480 | ||
2375 | cmp ecx, [display_width_standard] |
2481 | cmp ecx, [display_width_standard] |
2376 | ja .exit |
2482 | ja .exit |
2377 | 2483 | ||
2378 | cmp edx, [display_height_standard] |
2484 | cmp edx, [display_height_standard] |
2379 | ja .exit |
2485 | ja .exit |
2380 | 2486 | ||
2381 | pushfd |
2487 | pushfd |
2382 | cli |
2488 | cli |
2383 | mov eax, ecx |
2489 | mov eax, ecx |
2384 | mov ecx, [_display.pitch] |
2490 | mov ecx, [_display.pitch] |
2385 | mov [_display.width], eax |
2491 | mov [_display.width], eax |
2386 | dec eax |
2492 | dec eax |
2387 | mov [_display.height], edx |
2493 | mov [_display.height], edx |
2388 | dec edx |
2494 | dec edx |
2389 | ; eax - new Screen_Max_X |
2495 | ; eax - new Screen_Max_X |
2390 | ; edx - new Screen_Max_Y |
2496 | ; edx - new Screen_Max_Y |
2391 | mov [do_not_touch_winmap], 1 |
2497 | mov [do_not_touch_winmap], 1 |
2392 | call set_screen |
2498 | call set_screen |
2393 | mov [do_not_touch_winmap], 0 |
2499 | mov [do_not_touch_winmap], 0 |
2394 | popfd |
2500 | popfd |
2395 | call change_task |
2501 | call change_task |
2396 | .exit: |
2502 | .exit: |
2397 | ret |
2503 | ret |
2398 | ;------------------------------------------------------------------------------ |
2504 | ;------------------------------------------------------------------------------ |
2399 | uglobal |
2505 | uglobal |
2400 | screen_workarea RECT |
2506 | screen_workarea RECT |
2401 | display_width_standard dd 0 |
2507 | display_width_standard dd 0 |
2402 | display_height_standard dd 0 |
2508 | display_height_standard dd 0 |
2403 | do_not_touch_winmap db 0 |
2509 | do_not_touch_winmap db 0 |
2404 | window_minimize db 0 |
2510 | window_minimize db 0 |
2405 | sound_flag db 0 |
2511 | sound_flag db 0 |
2406 | 2512 | ||
2407 | endg |
2513 | endg |
2408 | 2514 | ||
2409 | UID_NONE=0 |
2515 | UID_NONE=0 |
2410 | UID_MENUETOS=1 ;official |
2516 | UID_MENUETOS=1 ;official |
2411 | UID_KOLIBRI=2 ;russian |
2517 | UID_KOLIBRI=2 ;russian |
2412 | 2518 | ||
2413 | iglobal |
2519 | iglobal |
2414 | version_inf: |
2520 | version_inf: |
2415 | db 0,7,7,0 ; version 0.7.7.0 |
2521 | db 0,7,7,0 ; version 0.7.7.0 |
2416 | db 0 |
2522 | db 0 |
2417 | .rev dd __REV__ |
2523 | .rev dd __REV__ |
2418 | version_end: |
2524 | version_end: |
2419 | endg |
2525 | endg |
2420 | ;------------------------------------------------------------------------------ |
2526 | ;------------------------------------------------------------------------------ |
2421 | align 4 |
2527 | align 4 |
2422 | sys_cachetodiskette: |
2528 | sys_cachetodiskette: |
2423 | cmp ebx, 1 |
2529 | cmp ebx, 1 |
2424 | jb .no_floppy_save |
2530 | jb .no_floppy_save |
2425 | cmp ebx, 2 |
2531 | cmp ebx, 2 |
2426 | ja .no_floppy_save |
2532 | ja .no_floppy_save |
2427 | call save_image |
2533 | call save_image |
2428 | mov [esp + 32], eax |
2534 | mov [esp + 32], eax |
2429 | ret |
2535 | ret |
2430 | .no_floppy_save: |
2536 | .no_floppy_save: |
2431 | mov [esp + 32], dword 1 |
2537 | mov [esp + 32], dword 1 |
2432 | ret |
2538 | ret |
2433 | ;------------------------------------------------------------------------------ |
2539 | ;------------------------------------------------------------------------------ |
2434 | uglobal |
2540 | uglobal |
2435 | ; bgrchanged dd 0x0 |
2541 | ; bgrchanged dd 0x0 |
2436 | align 4 |
2542 | align 4 |
2437 | bgrlockpid dd 0 |
2543 | bgrlockpid dd 0 |
2438 | bgrlock db 0 |
2544 | bgrlock db 0 |
2439 | endg |
2545 | endg |
2440 | ;------------------------------------------------------------------------------ |
2546 | ;------------------------------------------------------------------------------ |
2441 | align 4 |
2547 | align 4 |
2442 | sys_background: |
2548 | sys_background: |
2443 | cmp ebx, 1 ; BACKGROUND SIZE |
2549 | cmp ebx, 1 ; BACKGROUND SIZE |
2444 | jnz nosb1 |
2550 | jnz nosb1 |
2445 | test ecx, ecx |
2551 | test ecx, ecx |
2446 | jz sbgrr |
2552 | jz sbgrr |
2447 | 2553 | ||
2448 | test edx, edx |
2554 | test edx, edx |
2449 | jz sbgrr |
2555 | jz sbgrr |
2450 | ;-------------------------------------- |
2556 | ;-------------------------------------- |
2451 | align 4 |
2557 | align 4 |
2452 | @@: |
2558 | @@: |
2453 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2559 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2454 | bts dword [bgrlock], 0 |
2560 | bts dword [bgrlock], 0 |
2455 | jnc @f |
2561 | jnc @f |
2456 | call change_task |
2562 | call change_task |
2457 | jmp @b |
2563 | jmp @b |
2458 | ;-------------------------------------- |
2564 | ;-------------------------------------- |
2459 | align 4 |
2565 | align 4 |
2460 | @@: |
2566 | @@: |
2461 | mov [BgrDataWidth], ecx |
2567 | mov [BgrDataWidth], ecx |
2462 | mov [BgrDataHeight], edx |
2568 | mov [BgrDataHeight], edx |
2463 | ; mov [bgrchanged],1 |
2569 | ; mov [bgrchanged],1 |
2464 | 2570 | ||
2465 | pushad |
2571 | pushad |
2466 | ; return memory for old background |
2572 | ; return memory for old background |
2467 | mov eax, [img_background] |
2573 | mov eax, [img_background] |
2468 | cmp eax, static_background_data |
2574 | cmp eax, static_background_data |
2469 | jz @f |
2575 | jz @f |
2470 | stdcall kernel_free, eax |
2576 | stdcall kernel_free, eax |
2471 | ;-------------------------------------- |
2577 | ;-------------------------------------- |
2472 | align 4 |
2578 | align 4 |
2473 | @@: |
2579 | @@: |
2474 | ; calculate RAW size |
2580 | ; calculate RAW size |
2475 | xor eax, eax |
2581 | xor eax, eax |
2476 | inc eax |
2582 | inc eax |
2477 | cmp [BgrDataWidth], eax |
2583 | cmp [BgrDataWidth], eax |
2478 | jae @f |
2584 | jae @f |
2479 | mov [BgrDataWidth], eax |
2585 | mov [BgrDataWidth], eax |
2480 | ;-------------------------------------- |
2586 | ;-------------------------------------- |
2481 | align 4 |
2587 | align 4 |
2482 | @@: |
2588 | @@: |
2483 | cmp [BgrDataHeight], eax |
2589 | cmp [BgrDataHeight], eax |
2484 | jae @f |
2590 | jae @f |
2485 | mov [BgrDataHeight], eax |
2591 | mov [BgrDataHeight], eax |
2486 | ;-------------------------------------- |
2592 | ;-------------------------------------- |
2487 | align 4 |
2593 | align 4 |
2488 | @@: |
2594 | @@: |
2489 | mov eax, [BgrDataWidth] |
2595 | mov eax, [BgrDataWidth] |
2490 | imul eax, [BgrDataHeight] |
2596 | imul eax, [BgrDataHeight] |
2491 | lea eax, [eax*3] |
2597 | lea eax, [eax*3] |
2492 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2598 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2493 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2599 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2494 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2600 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2495 | shr eax, 12 |
2601 | shr eax, 12 |
2496 | inc eax |
2602 | inc eax |
2497 | shl eax, 12 |
2603 | shl eax, 12 |
2498 | mov [mem_BACKGROUND], eax |
2604 | mov [mem_BACKGROUND], eax |
2499 | ; get memory for new background |
2605 | ; get memory for new background |
2500 | stdcall kernel_alloc, eax |
2606 | stdcall kernel_alloc, eax |
2501 | test eax, eax |
2607 | test eax, eax |
2502 | jz .memfailed |
2608 | jz .memfailed |
2503 | mov [img_background], eax |
2609 | mov [img_background], eax |
2504 | jmp .exit |
2610 | jmp .exit |
2505 | ;-------------------------------------- |
2611 | ;-------------------------------------- |
2506 | align 4 |
2612 | align 4 |
2507 | .memfailed: |
2613 | .memfailed: |
2508 | ; revert to static monotone data |
2614 | ; revert to static monotone data |
2509 | mov [img_background], static_background_data |
2615 | mov [img_background], static_background_data |
2510 | xor eax, eax |
2616 | xor eax, eax |
2511 | inc eax |
2617 | inc eax |
2512 | mov [BgrDataWidth], eax |
2618 | mov [BgrDataWidth], eax |
2513 | mov [BgrDataHeight], eax |
2619 | mov [BgrDataHeight], eax |
2514 | mov [mem_BACKGROUND], 4 |
2620 | mov [mem_BACKGROUND], 4 |
2515 | ;-------------------------------------- |
2621 | ;-------------------------------------- |
2516 | align 4 |
2622 | align 4 |
2517 | .exit: |
2623 | .exit: |
2518 | popad |
2624 | popad |
2519 | mov [bgrlock], 0 |
2625 | mov [bgrlock], 0 |
2520 | ;-------------------------------------- |
2626 | ;-------------------------------------- |
2521 | align 4 |
2627 | align 4 |
2522 | sbgrr: |
2628 | sbgrr: |
2523 | ret |
2629 | ret |
2524 | ;------------------------------------------------------------------------------ |
2630 | ;------------------------------------------------------------------------------ |
2525 | align 4 |
2631 | align 4 |
2526 | nosb1: |
2632 | nosb1: |
2527 | cmp ebx, 2 ; SET PIXEL |
2633 | cmp ebx, 2 ; SET PIXEL |
2528 | jnz nosb2 |
2634 | jnz nosb2 |
2529 | 2635 | ||
2530 | mov eax, [img_background] |
2636 | mov eax, [img_background] |
2531 | test ecx, ecx |
2637 | test ecx, ecx |
2532 | jz @f |
2638 | jz @f |
2533 | cmp eax, static_background_data |
2639 | cmp eax, static_background_data |
2534 | jz .ret |
2640 | jz .ret |
2535 | ;-------------------------------------- |
2641 | ;-------------------------------------- |
2536 | align 4 |
2642 | align 4 |
2537 | @@: |
2643 | @@: |
2538 | mov ebx, [mem_BACKGROUND] |
2644 | mov ebx, [mem_BACKGROUND] |
2539 | add ebx, 4095 |
2645 | add ebx, 4095 |
2540 | and ebx, -4096 |
2646 | and ebx, -4096 |
2541 | sub ebx, 4 |
2647 | sub ebx, 4 |
2542 | cmp ecx, ebx |
2648 | cmp ecx, ebx |
2543 | ja .ret |
2649 | ja .ret |
2544 | 2650 | ||
2545 | mov ebx, [eax+ecx] |
2651 | mov ebx, [eax+ecx] |
2546 | and ebx, 0xFF000000;255*256*256*256 |
2652 | and ebx, 0xFF000000;255*256*256*256 |
2547 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2653 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2548 | add edx, ebx |
2654 | add edx, ebx |
2549 | mov [eax+ecx], edx |
2655 | mov [eax+ecx], edx |
2550 | ;-------------------------------------- |
2656 | ;-------------------------------------- |
2551 | align 4 |
2657 | align 4 |
2552 | .ret: |
2658 | .ret: |
2553 | ret |
2659 | ret |
2554 | ;------------------------------------------------------------------------------ |
2660 | ;------------------------------------------------------------------------------ |
2555 | align 4 |
2661 | align 4 |
2556 | nosb2: |
2662 | nosb2: |
2557 | cmp ebx, 3 ; DRAW BACKGROUND |
2663 | cmp ebx, 3 ; DRAW BACKGROUND |
2558 | jnz nosb3 |
2664 | jnz nosb3 |
2559 | ;-------------------------------------- |
2665 | ;-------------------------------------- |
2560 | align 4 |
2666 | align 4 |
2561 | draw_background_temp: |
2667 | draw_background_temp: |
2562 | mov [background_defined], 1 |
2668 | mov [background_defined], 1 |
2563 | call force_redraw_background |
2669 | call force_redraw_background |
2564 | ;-------------------------------------- |
2670 | ;-------------------------------------- |
2565 | align 4 |
2671 | align 4 |
2566 | nosb31: |
2672 | nosb31: |
2567 | ret |
2673 | ret |
2568 | ;------------------------------------------------------------------------------ |
2674 | ;------------------------------------------------------------------------------ |
2569 | align 4 |
2675 | align 4 |
2570 | nosb3: |
2676 | nosb3: |
2571 | cmp ebx, 4 ; TILED / STRETCHED |
2677 | cmp ebx, 4 ; TILED / STRETCHED |
2572 | jnz nosb4 |
2678 | jnz nosb4 |
2573 | cmp ecx, [BgrDrawMode] |
2679 | cmp ecx, [BgrDrawMode] |
2574 | je nosb41 |
2680 | je nosb41 |
2575 | mov [BgrDrawMode], ecx |
2681 | mov [BgrDrawMode], ecx |
2576 | ;-------------------------------------- |
2682 | ;-------------------------------------- |
2577 | align 4 |
2683 | align 4 |
2578 | nosb41: |
2684 | nosb41: |
2579 | ret |
2685 | ret |
2580 | ;------------------------------------------------------------------------------ |
2686 | ;------------------------------------------------------------------------------ |
2581 | align 4 |
2687 | align 4 |
2582 | nosb4: |
2688 | nosb4: |
2583 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2689 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2584 | jnz nosb5 |
2690 | jnz nosb5 |
2585 | cmp [img_background], static_background_data |
2691 | cmp [img_background], static_background_data |
2586 | jnz @f |
2692 | jnz @f |
2587 | test edx, edx |
2693 | test edx, edx |
2588 | jnz .fin |
2694 | jnz .fin |
2589 | cmp esi, 4 |
2695 | cmp esi, 4 |
2590 | ja .fin |
2696 | ja .fin |
2591 | ;-------------------------------------- |
2697 | ;-------------------------------------- |
2592 | align 4 |
2698 | align 4 |
2593 | @@: |
2699 | @@: |
2594 | ; bughere |
2700 | ; bughere |
2595 | mov eax, ecx |
2701 | mov eax, ecx |
2596 | mov ebx, edx |
2702 | mov ebx, edx |
2597 | add ebx, [img_background];IMG_BACKGROUND |
2703 | add ebx, [img_background];IMG_BACKGROUND |
2598 | mov ecx, esi |
2704 | mov ecx, esi |
2599 | call memmove |
2705 | call memmove |
2600 | ;-------------------------------------- |
2706 | ;-------------------------------------- |
2601 | align 4 |
2707 | align 4 |
2602 | .fin: |
2708 | .fin: |
2603 | ret |
2709 | ret |
2604 | ;------------------------------------------------------------------------------ |
2710 | ;------------------------------------------------------------------------------ |
2605 | align 4 |
2711 | align 4 |
2606 | nosb5: |
2712 | nosb5: |
2607 | cmp ebx, 6 |
2713 | cmp ebx, 6 |
2608 | jnz nosb6 |
2714 | jnz nosb6 |
2609 | ;-------------------------------------- |
2715 | ;-------------------------------------- |
2610 | align 4 |
2716 | align 4 |
2611 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2717 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2612 | @@: |
2718 | @@: |
2613 | bts dword [bgrlock], 0 |
2719 | bts dword [bgrlock], 0 |
2614 | jnc @f |
2720 | jnc @f |
2615 | call change_task |
2721 | call change_task |
2616 | jmp @b |
2722 | jmp @b |
2617 | ;-------------------------------------- |
2723 | ;-------------------------------------- |
2618 | align 4 |
2724 | align 4 |
2619 | @@: |
2725 | @@: |
2620 | mov eax, [CURRENT_TASK] |
2726 | mov eax, [CURRENT_TASK] |
2621 | mov [bgrlockpid], eax |
2727 | mov [bgrlockpid], eax |
2622 | cmp [img_background], static_background_data |
2728 | cmp [img_background], static_background_data |
2623 | jz .nomem |
2729 | jz .nomem |
2624 | stdcall user_alloc, [mem_BACKGROUND] |
2730 | stdcall user_alloc, [mem_BACKGROUND] |
2625 | mov [esp+32], eax |
2731 | mov [esp+32], eax |
2626 | test eax, eax |
2732 | test eax, eax |
2627 | jz .nomem |
2733 | jz .nomem |
2628 | mov ebx, eax |
2734 | mov ebx, eax |
2629 | shr ebx, 12 |
2735 | shr ebx, 12 |
2630 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2736 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2631 | mov esi, [img_background] |
2737 | mov esi, [img_background] |
2632 | shr esi, 12 |
2738 | shr esi, 12 |
2633 | mov ecx, [mem_BACKGROUND] |
2739 | mov ecx, [mem_BACKGROUND] |
2634 | add ecx, 0xFFF |
2740 | add ecx, 0xFFF |
2635 | shr ecx, 12 |
2741 | shr ecx, 12 |
2636 | ;-------------------------------------- |
2742 | ;-------------------------------------- |
2637 | align 4 |
2743 | align 4 |
2638 | .z: |
2744 | .z: |
2639 | mov eax, [page_tabs+ebx*4] |
2745 | mov eax, [page_tabs+ebx*4] |
2640 | test al, 1 |
2746 | test al, 1 |
2641 | jz @f |
2747 | jz @f |
2642 | call free_page |
2748 | call free_page |
2643 | ;-------------------------------------- |
2749 | ;-------------------------------------- |
2644 | align 4 |
2750 | align 4 |
2645 | @@: |
2751 | @@: |
2646 | mov eax, [page_tabs+esi*4] |
2752 | mov eax, [page_tabs+esi*4] |
2647 | or al, PG_UW |
2753 | or al, PG_UW |
2648 | mov [page_tabs+ebx*4], eax |
2754 | mov [page_tabs+ebx*4], eax |
2649 | mov eax, ebx |
2755 | mov eax, ebx |
2650 | shl eax, 12 |
2756 | shl eax, 12 |
2651 | invlpg [eax] |
2757 | invlpg [eax] |
2652 | inc ebx |
2758 | inc ebx |
2653 | inc esi |
2759 | inc esi |
2654 | loop .z |
2760 | loop .z |
2655 | ret |
2761 | ret |
2656 | ;-------------------------------------- |
2762 | ;-------------------------------------- |
2657 | align 4 |
2763 | align 4 |
2658 | .nomem: |
2764 | .nomem: |
2659 | and [bgrlockpid], 0 |
2765 | and [bgrlockpid], 0 |
2660 | mov [bgrlock], 0 |
2766 | mov [bgrlock], 0 |
2661 | ;------------------------------------------------------------------------------ |
2767 | ;------------------------------------------------------------------------------ |
2662 | align 4 |
2768 | align 4 |
2663 | nosb6: |
2769 | nosb6: |
2664 | cmp ebx, 7 |
2770 | cmp ebx, 7 |
2665 | jnz nosb7 |
2771 | jnz nosb7 |
2666 | cmp [bgrlock], 0 |
2772 | cmp [bgrlock], 0 |
2667 | jz .err |
2773 | jz .err |
2668 | mov eax, [CURRENT_TASK] |
2774 | mov eax, [CURRENT_TASK] |
2669 | cmp [bgrlockpid], eax |
2775 | cmp [bgrlockpid], eax |
2670 | jnz .err |
2776 | jnz .err |
2671 | mov eax, ecx |
2777 | mov eax, ecx |
2672 | mov ebx, ecx |
2778 | mov ebx, ecx |
2673 | shr eax, 12 |
2779 | shr eax, 12 |
2674 | mov ecx, [page_tabs+(eax-1)*4] |
2780 | mov ecx, [page_tabs+(eax-1)*4] |
2675 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2781 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2676 | jz .err |
2782 | jz .err |
2677 | jnp .err |
2783 | jnp .err |
2678 | push eax |
2784 | push eax |
2679 | shr ecx, 12 |
2785 | shr ecx, 12 |
2680 | dec ecx |
2786 | dec ecx |
2681 | ;-------------------------------------- |
2787 | ;-------------------------------------- |
2682 | align 4 |
2788 | align 4 |
2683 | @@: |
2789 | @@: |
2684 | and dword [page_tabs+eax*4], 0 |
2790 | and dword [page_tabs+eax*4], 0 |
2685 | mov edx, eax |
2791 | mov edx, eax |
2686 | shl edx, 12 |
2792 | shl edx, 12 |
2687 | push eax |
2793 | push eax |
2688 | invlpg [edx] |
2794 | invlpg [edx] |
2689 | pop eax |
2795 | pop eax |
2690 | inc eax |
2796 | inc eax |
2691 | loop @b |
2797 | loop @b |
2692 | pop eax |
2798 | pop eax |
2693 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2799 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2694 | stdcall user_free, ebx |
2800 | stdcall user_free, ebx |
2695 | mov [esp+32], eax |
2801 | mov [esp+32], eax |
2696 | and [bgrlockpid], 0 |
2802 | and [bgrlockpid], 0 |
2697 | mov [bgrlock], 0 |
2803 | mov [bgrlock], 0 |
2698 | ret |
2804 | ret |
2699 | ;-------------------------------------- |
2805 | ;-------------------------------------- |
2700 | align 4 |
2806 | align 4 |
2701 | .err: |
2807 | .err: |
2702 | and dword [esp+32], 0 |
2808 | and dword [esp+32], 0 |
2703 | ret |
2809 | ret |
2704 | ;------------------------------------------------------------------------------ |
2810 | ;------------------------------------------------------------------------------ |
2705 | align 4 |
2811 | align 4 |
2706 | nosb7: |
2812 | nosb7: |
2707 | cmp ebx, 8 |
2813 | cmp ebx, 8 |
2708 | jnz nosb8 |
2814 | jnz nosb8 |
2709 | 2815 | ||
2710 | mov ecx, [current_slot] |
2816 | mov ecx, [current_slot] |
2711 | xor eax, eax |
2817 | xor eax, eax |
2712 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2818 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2713 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2819 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2714 | xor eax, eax |
2820 | xor eax, eax |
2715 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2821 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2716 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2822 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2717 | ret |
2823 | ret |
2718 | ;------------------------------------------------------------------------------ |
2824 | ;------------------------------------------------------------------------------ |
2719 | align 4 |
2825 | align 4 |
2720 | nosb8: |
2826 | nosb8: |
2721 | cmp ebx, 9 |
2827 | cmp ebx, 9 |
2722 | jnz nosb9 |
2828 | jnz nosb9 |
2723 | ; ecx = [left]*65536 + [right] |
2829 | ; ecx = [left]*65536 + [right] |
2724 | ; edx = [top]*65536 + [bottom] |
2830 | ; edx = [top]*65536 + [bottom] |
2725 | mov eax, [_display.width] |
2831 | mov eax, [Screen_Max_X] |
2726 | mov ebx, [_display.height] |
2832 | mov ebx, [Screen_Max_Y] |
2727 | ; check [right] |
2833 | ; check [right] |
2728 | cmp cx, ax |
2834 | cmp cx, ax |
2729 | jae .exit |
2835 | ja .exit |
2730 | ; check [left] |
2836 | ; check [left] |
2731 | ror ecx, 16 |
2837 | ror ecx, 16 |
2732 | cmp cx, ax |
2838 | cmp cx, ax |
2733 | jae .exit |
2839 | ja .exit |
2734 | ; check [bottom] |
2840 | ; check [bottom] |
2735 | cmp dx, bx |
2841 | cmp dx, bx |
2736 | jae .exit |
2842 | ja .exit |
2737 | ; check [top] |
2843 | ; check [top] |
2738 | ror edx, 16 |
2844 | ror edx, 16 |
2739 | cmp dx, bx |
2845 | cmp dx, bx |
2740 | jae .exit |
2846 | ja .exit |
2741 | 2847 | ||
2742 | movzx eax, cx ; [left] |
2848 | movzx eax, cx ; [left] |
2743 | movzx ebx, dx ; [top] |
2849 | movzx ebx, dx ; [top] |
2744 | 2850 | ||
2745 | shr ecx, 16 ; [right] |
2851 | shr ecx, 16 ; [right] |
2746 | shr edx, 16 ; [bottom] |
2852 | shr edx, 16 ; [bottom] |
2747 | 2853 | ||
2748 | mov [background_defined], 1 |
2854 | mov [background_defined], 1 |
2749 | 2855 | ||
2750 | mov [draw_data+32 + RECT.left], eax |
2856 | mov [draw_data+32 + RECT.left], eax |
2751 | mov [draw_data+32 + RECT.top], ebx |
2857 | mov [draw_data+32 + RECT.top], ebx |
2752 | 2858 | ||
2753 | mov [draw_data+32 + RECT.right], ecx |
2859 | mov [draw_data+32 + RECT.right], ecx |
2754 | mov [draw_data+32 + RECT.bottom], edx |
2860 | mov [draw_data+32 + RECT.bottom], edx |
2755 | 2861 | ||
2756 | inc byte[REDRAW_BACKGROUND] |
2862 | inc byte[REDRAW_BACKGROUND] |
2757 | call wakeup_osloop |
2863 | call wakeup_osloop |
2758 | ;-------------------------------------- |
2864 | ;-------------------------------------- |
2759 | align 4 |
2865 | align 4 |
2760 | .exit: |
2866 | .exit: |
2761 | ret |
2867 | ret |
2762 | ;------------------------------------------------------------------------------ |
2868 | ;------------------------------------------------------------------------------ |
2763 | align 4 |
2869 | align 4 |
2764 | nosb9: |
2870 | nosb9: |
2765 | ret |
2871 | ret |
2766 | ;------------------------------------------------------------------------------ |
2872 | ;------------------------------------------------------------------------------ |
2767 | align 4 |
2873 | align 4 |
2768 | uglobal |
2874 | uglobal |
2769 | BG_Rect_X_left_right dd 0x0 |
2875 | BG_Rect_X_left_right dd 0x0 |
2770 | BG_Rect_Y_top_bottom dd 0x0 |
2876 | BG_Rect_Y_top_bottom dd 0x0 |
2771 | endg |
2877 | endg |
2772 | ;------------------------------------------------------------------------------ |
2878 | ;------------------------------------------------------------------------------ |
2773 | align 4 |
2879 | align 4 |
2774 | force_redraw_background: |
2880 | force_redraw_background: |
2775 | and [draw_data+32 + RECT.left], 0 |
2881 | and [draw_data+32 + RECT.left], 0 |
2776 | and [draw_data+32 + RECT.top], 0 |
2882 | and [draw_data+32 + RECT.top], 0 |
2777 | push eax ebx |
2883 | push eax ebx |
2778 | mov eax, [Screen_Max_X] |
2884 | mov eax, [Screen_Max_X] |
2779 | mov ebx, [Screen_Max_Y] |
2885 | mov ebx, [Screen_Max_Y] |
2780 | mov [draw_data+32 + RECT.right], eax |
2886 | mov [draw_data+32 + RECT.right], eax |
2781 | mov [draw_data+32 + RECT.bottom], ebx |
2887 | mov [draw_data+32 + RECT.bottom], ebx |
2782 | pop ebx eax |
2888 | pop ebx eax |
2783 | inc byte[REDRAW_BACKGROUND] |
2889 | inc byte[REDRAW_BACKGROUND] |
2784 | call wakeup_osloop |
2890 | call wakeup_osloop |
2785 | ret |
2891 | ret |
2786 | ;------------------------------------------------------------------------------ |
2892 | ;------------------------------------------------------------------------------ |
2787 | align 4 |
2893 | align 4 |
2788 | sys_getbackground: |
2894 | sys_getbackground: |
2789 | ; cmp eax,1 ; SIZE |
2895 | ; cmp eax,1 ; SIZE |
2790 | dec ebx |
2896 | dec ebx |
2791 | jnz nogb1 |
2897 | jnz nogb1 |
2792 | mov eax, [BgrDataWidth] |
2898 | mov eax, [BgrDataWidth] |
2793 | shl eax, 16 |
2899 | shl eax, 16 |
2794 | mov ax, word [BgrDataHeight] |
2900 | mov ax, word [BgrDataHeight] |
2795 | mov [esp+32], eax |
2901 | mov [esp+32], eax |
2796 | ret |
2902 | ret |
2797 | ;------------------------------------------------------------------------------ |
2903 | ;------------------------------------------------------------------------------ |
2798 | align 4 |
2904 | align 4 |
2799 | nogb1: |
2905 | nogb1: |
2800 | ; cmp eax,2 ; PIXEL |
2906 | ; cmp eax,2 ; PIXEL |
2801 | dec ebx |
2907 | dec ebx |
2802 | jnz nogb2 |
2908 | jnz nogb2 |
2803 | 2909 | ||
2804 | mov eax, [img_background] |
2910 | mov eax, [img_background] |
2805 | test ecx, ecx |
2911 | test ecx, ecx |
2806 | jz @f |
2912 | jz @f |
2807 | cmp eax, static_background_data |
2913 | cmp eax, static_background_data |
2808 | jz .ret |
2914 | jz .ret |
2809 | ;-------------------------------------- |
2915 | ;-------------------------------------- |
2810 | align 4 |
2916 | align 4 |
2811 | @@: |
2917 | @@: |
2812 | mov ebx, [mem_BACKGROUND] |
2918 | mov ebx, [mem_BACKGROUND] |
2813 | add ebx, 4095 |
2919 | add ebx, 4095 |
2814 | and ebx, -4096 |
2920 | and ebx, -4096 |
2815 | sub ebx, 4 |
2921 | sub ebx, 4 |
2816 | cmp ecx, ebx |
2922 | cmp ecx, ebx |
2817 | ja .ret |
2923 | ja .ret |
2818 | 2924 | ||
2819 | mov eax, [ecx+eax] |
2925 | mov eax, [ecx+eax] |
2820 | 2926 | ||
2821 | and eax, 0xFFFFFF |
2927 | and eax, 0xFFFFFF |
2822 | mov [esp+32], eax |
2928 | mov [esp+32], eax |
2823 | ;-------------------------------------- |
2929 | ;-------------------------------------- |
2824 | align 4 |
2930 | align 4 |
2825 | .ret: |
2931 | .ret: |
2826 | ret |
2932 | ret |
2827 | ;------------------------------------------------------------------------------ |
2933 | ;------------------------------------------------------------------------------ |
2828 | align 4 |
2934 | align 4 |
2829 | nogb2: |
2935 | nogb2: |
2830 | 2936 | ||
2831 | ; cmp eax,4 ; TILED / STRETCHED |
2937 | ; cmp eax,4 ; TILED / STRETCHED |
2832 | dec ebx |
2938 | dec ebx |
2833 | dec ebx |
2939 | dec ebx |
2834 | jnz nogb4 |
2940 | jnz nogb4 |
2835 | mov eax, [BgrDrawMode] |
2941 | mov eax, [BgrDrawMode] |
2836 | ;-------------------------------------- |
2942 | ;-------------------------------------- |
2837 | align 4 |
2943 | align 4 |
2838 | nogb4: |
2944 | nogb4: |
2839 | mov [esp+32], eax |
2945 | mov [esp+32], eax |
2840 | ret |
2946 | ret |
2841 | ;------------------------------------------------------------------------------ |
2947 | ;------------------------------------------------------------------------------ |
2842 | align 4 |
2948 | align 4 |
2843 | sys_getkey: |
2949 | sys_getkey: |
2844 | mov [esp + 32], dword 1 |
2950 | mov [esp + 32], dword 1 |
2845 | ; test main buffer |
2951 | ; test main buffer |
2846 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2952 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2847 | movzx ecx, word [WIN_STACK + ebx * 2] |
2953 | movzx ecx, word [WIN_STACK + ebx * 2] |
2848 | mov edx, [TASK_COUNT] |
2954 | mov edx, [TASK_COUNT] |
2849 | cmp ecx, edx |
2955 | cmp ecx, edx |
2850 | jne .finish |
2956 | jne .finish |
2851 | cmp [KEY_COUNT], byte 0 |
2957 | cmp [KEY_COUNT], byte 0 |
2852 | je .finish |
2958 | je .finish |
2853 | movzx ax, byte [KEY_BUFF + 120 + 2] |
2959 | movzx ax, byte [KEY_BUFF + 120 + 2] |
2854 | shl eax, 8 |
2960 | shl eax, 8 |
2855 | mov al, byte [KEY_BUFF] |
2961 | mov al, byte [KEY_BUFF] |
2856 | shl eax, 8 |
2962 | shl eax, 8 |
2857 | push eax |
2963 | push eax |
2858 | dec byte [KEY_COUNT] |
2964 | dec byte [KEY_COUNT] |
2859 | and byte [KEY_COUNT], 127 |
2965 | and byte [KEY_COUNT], 127 |
2860 | movzx ecx, byte [KEY_COUNT] |
2966 | movzx ecx, byte [KEY_COUNT] |
2861 | add ecx, 2 |
2967 | add ecx, 2 |
2862 | mov eax, KEY_BUFF + 1 |
2968 | mov eax, KEY_BUFF + 1 |
2863 | mov ebx, KEY_BUFF |
2969 | mov ebx, KEY_BUFF |
2864 | call memmove |
2970 | call memmove |
2865 | add eax, 120 + 2 |
2971 | add eax, 120 + 2 |
2866 | add ebx, 120 + 2 |
2972 | add ebx, 120 + 2 |
2867 | call memmove |
2973 | call memmove |
2868 | pop eax |
2974 | pop eax |
2869 | ;-------------------------------------- |
2975 | ;-------------------------------------- |
2870 | align 4 |
2976 | align 4 |
2871 | .ret_eax: |
2977 | .ret_eax: |
2872 | mov [esp + 32], eax |
2978 | mov [esp + 32], eax |
2873 | ret |
2979 | ret |
2874 | ;-------------------------------------- |
2980 | ;-------------------------------------- |
2875 | align 4 |
2981 | align 4 |
2876 | .finish: |
2982 | .finish: |
2877 | ; test hotkeys buffer |
2983 | ; test hotkeys buffer |
2878 | mov ecx, hotkey_buffer |
2984 | mov ecx, hotkey_buffer |
2879 | ;-------------------------------------- |
2985 | ;-------------------------------------- |
2880 | align 4 |
2986 | align 4 |
2881 | @@: |
2987 | @@: |
2882 | cmp [ecx], ebx |
2988 | cmp [ecx], ebx |
2883 | jz .found |
2989 | jz .found |
2884 | add ecx, 8 |
2990 | add ecx, 8 |
2885 | cmp ecx, hotkey_buffer + 120 * 8 |
2991 | cmp ecx, hotkey_buffer + 120 * 8 |
2886 | jb @b |
2992 | jb @b |
2887 | ret |
2993 | ret |
2888 | ;-------------------------------------- |
2994 | ;-------------------------------------- |
2889 | align 4 |
2995 | align 4 |
2890 | .found: |
2996 | .found: |
2891 | mov ax, [ecx + 6] |
2997 | mov ax, [ecx + 6] |
2892 | shl eax, 16 |
2998 | shl eax, 16 |
2893 | mov ah, [ecx + 4] |
2999 | mov ah, [ecx + 4] |
2894 | mov al, 2 |
3000 | mov al, 2 |
2895 | and dword [ecx + 4], 0 |
3001 | and dword [ecx + 4], 0 |
2896 | and dword [ecx], 0 |
3002 | and dword [ecx], 0 |
2897 | jmp .ret_eax |
3003 | jmp .ret_eax |
2898 | ;------------------------------------------------------------------------------ |
3004 | ;------------------------------------------------------------------------------ |
2899 | align 4 |
3005 | align 4 |
2900 | sys_getbutton: |
3006 | sys_getbutton: |
2901 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3007 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2902 | mov [esp + 32], dword 1 |
3008 | mov [esp + 32], dword 1 |
2903 | movzx ecx, word [WIN_STACK + ebx * 2] |
3009 | movzx ecx, word [WIN_STACK + ebx * 2] |
2904 | mov edx, [TASK_COUNT] ; less than 256 processes |
3010 | mov edx, [TASK_COUNT] ; less than 256 processes |
2905 | cmp ecx, edx |
3011 | cmp ecx, edx |
2906 | jne .exit |
3012 | jne .exit |
2907 | movzx eax, byte [BTN_COUNT] |
3013 | movzx eax, byte [BTN_COUNT] |
2908 | test eax, eax |
3014 | test eax, eax |
2909 | jz .exit |
3015 | jz .exit |
2910 | mov eax, [BTN_BUFF] |
3016 | mov eax, [BTN_BUFF] |
2911 | and al, 0xFE ; delete left button bit |
3017 | and al, 0xFE ; delete left button bit |
2912 | mov [BTN_COUNT], byte 0 |
3018 | mov [BTN_COUNT], byte 0 |
2913 | mov [esp + 32], eax |
3019 | mov [esp + 32], eax |
2914 | ;-------------------------------------- |
3020 | ;-------------------------------------- |
2915 | align 4 |
3021 | align 4 |
2916 | .exit: |
3022 | .exit: |
2917 | ret |
3023 | ret |
2918 | ;------------------------------------------------------------------------------ |
3024 | ;------------------------------------------------------------------------------ |
2919 | align 4 |
3025 | align 4 |
2920 | sys_cpuusage: |
3026 | sys_cpuusage: |
2921 | 3027 | ||
2922 | ; RETURN: |
3028 | ; RETURN: |
2923 | ; |
3029 | ; |
2924 | ; +00 dword process cpu usage |
3030 | ; +00 dword process cpu usage |
2925 | ; +04 word position in windowing stack |
3031 | ; +04 word position in windowing stack |
2926 | ; +06 word windowing stack value at current position (cpu nro) |
3032 | ; +06 word windowing stack value at current position (cpu nro) |
2927 | ; +10 12 bytes name |
3033 | ; +10 12 bytes name |
2928 | ; +22 dword start in mem |
3034 | ; +22 dword start in mem |
2929 | ; +26 dword used mem |
3035 | ; +26 dword used mem |
2930 | ; +30 dword PID , process idenfification number |
3036 | ; +30 dword PID , process idenfification number |
2931 | ; |
3037 | ; |
2932 | 3038 | ||
2933 | cmp ecx, -1 ; who am I ? |
3039 | cmp ecx, -1 ; who am I ? |
2934 | jne .no_who_am_i |
3040 | jne .no_who_am_i |
2935 | mov ecx, [CURRENT_TASK] |
3041 | mov ecx, [CURRENT_TASK] |
2936 | .no_who_am_i: |
3042 | .no_who_am_i: |
2937 | cmp ecx, max_processes |
3043 | cmp ecx, max_processes |
2938 | ja .nofillbuf |
3044 | ja .nofillbuf |
2939 | 3045 | ||
2940 | ; +4: word: position of the window of thread in the window stack |
3046 | ; +4: word: position of the window of thread in the window stack |
2941 | mov ax, [WIN_STACK + ecx * 2] |
3047 | mov ax, [WIN_STACK + ecx * 2] |
2942 | mov [ebx+4], ax |
3048 | mov [ebx+4], ax |
2943 | ; +6: word: number of the thread slot, which window has in the window stack |
3049 | ; +6: word: number of the thread slot, which window has in the window stack |
2944 | ; position ecx (has no relation to the specific thread) |
3050 | ; position ecx (has no relation to the specific thread) |
2945 | mov ax, [WIN_POS + ecx * 2] |
3051 | mov ax, [WIN_POS + ecx * 2] |
2946 | mov [ebx+6], ax |
3052 | mov [ebx+6], ax |
2947 | 3053 | ||
2948 | shl ecx, 5 |
3054 | shl ecx, 5 |
2949 | 3055 | ||
2950 | ; +0: dword: memory usage |
3056 | ; +0: dword: memory usage |
2951 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3057 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2952 | mov [ebx], eax |
3058 | mov [ebx], eax |
2953 | ; +10: 11 bytes: name of the process |
3059 | ; +10: 11 bytes: name of the process |
2954 | push ecx |
3060 | push ecx |
2955 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3061 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
2956 | add ebx, 10 |
3062 | add ebx, 10 |
2957 | mov ecx, 11 |
3063 | mov ecx, 11 |
2958 | call memmove |
3064 | call memmove |
2959 | pop ecx |
3065 | pop ecx |
2960 | 3066 | ||
2961 | ; +22: address of the process in memory |
3067 | ; +22: address of the process in memory |
2962 | ; +26: size of used memory - 1 |
3068 | ; +26: size of used memory - 1 |
2963 | push edi |
3069 | push edi |
2964 | lea edi, [ebx+12] |
3070 | lea edi, [ebx+12] |
2965 | xor eax, eax |
3071 | xor eax, eax |
2966 | mov edx, 0x100000*16 |
3072 | mov edx, 0x100000*16 |
2967 | cmp ecx, 1 shl 5 |
3073 | cmp ecx, 1 shl 5 |
2968 | je .os_mem |
3074 | je .os_mem |
2969 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3075 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
2970 | mov edx, [edx+PROC.mem_used] |
3076 | mov edx, [edx+PROC.mem_used] |
2971 | mov eax, std_application_base_address |
3077 | mov eax, std_application_base_address |
2972 | .os_mem: |
3078 | .os_mem: |
2973 | stosd |
3079 | stosd |
2974 | lea eax, [edx-1] |
3080 | lea eax, [edx-1] |
2975 | stosd |
3081 | stosd |
2976 | 3082 | ||
2977 | ; +30: PID/TID |
3083 | ; +30: PID/TID |
2978 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3084 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2979 | stosd |
3085 | stosd |
2980 | 3086 | ||
2981 | ; window position and size |
3087 | ; window position and size |
2982 | push esi |
3088 | push esi |
2983 | lea esi, [ecx + window_data + WDATA.box] |
3089 | lea esi, [ecx + window_data + WDATA.box] |
2984 | movsd |
3090 | movsd |
2985 | movsd |
3091 | movsd |
2986 | movsd |
3092 | movsd |
2987 | movsd |
3093 | movsd |
2988 | 3094 | ||
2989 | ; Process state (+50) |
3095 | ; Process state (+50) |
2990 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3096 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
2991 | stosd |
3097 | stosd |
2992 | 3098 | ||
2993 | ; Window client area box |
3099 | ; Window client area box |
2994 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3100 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
2995 | movsd |
3101 | movsd |
2996 | movsd |
3102 | movsd |
2997 | movsd |
3103 | movsd |
2998 | movsd |
3104 | movsd |
2999 | 3105 | ||
3000 | ; Window state |
3106 | ; Window state |
3001 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3107 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3002 | stosb |
3108 | stosb |
3003 | 3109 | ||
3004 | ; Event mask (+71) |
3110 | ; Event mask (+71) |
3005 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3111 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3006 | stosd |
3112 | stosd |
3007 | 3113 | ||
3008 | ; Keyboard mode (+75) |
3114 | ; Keyboard mode (+75) |
3009 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3115 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3010 | stosb |
3116 | stosb |
3011 | 3117 | ||
3012 | pop esi |
3118 | pop esi |
3013 | pop edi |
3119 | pop edi |
3014 | 3120 | ||
3015 | .nofillbuf: |
3121 | .nofillbuf: |
3016 | ; return number of processes |
3122 | ; return number of processes |
3017 | 3123 | ||
3018 | mov eax, [TASK_COUNT] |
3124 | mov eax, [TASK_COUNT] |
3019 | mov [esp+32], eax |
3125 | mov [esp+32], eax |
3020 | ret |
3126 | ret |
3021 | 3127 | ||
3022 | align 4 |
3128 | align 4 |
3023 | sys_clock: |
3129 | sys_clock: |
3024 | cli |
3130 | cli |
3025 | ; Mikhail Lisovin xx Jan 2005 |
3131 | ; Mikhail Lisovin xx Jan 2005 |
3026 | @@: |
3132 | @@: |
3027 | mov al, 10 |
3133 | mov al, 10 |
3028 | out 0x70, al |
3134 | out 0x70, al |
3029 | in al, 0x71 |
3135 | in al, 0x71 |
3030 | test al, al |
3136 | test al, al |
3031 | jns @f |
3137 | jns @f |
3032 | mov esi, 1 |
3138 | mov esi, 1 |
3033 | call delay_ms |
3139 | call delay_ms |
3034 | jmp @b |
3140 | jmp @b |
3035 | @@: |
3141 | @@: |
3036 | ; end Lisovin's fix |
3142 | ; end Lisovin's fix |
3037 | 3143 | ||
3038 | xor al, al ; seconds |
3144 | xor al, al ; seconds |
3039 | out 0x70, al |
3145 | out 0x70, al |
3040 | in al, 0x71 |
3146 | in al, 0x71 |
3041 | movzx ecx, al |
3147 | movzx ecx, al |
3042 | mov al, 02 ; minutes |
3148 | mov al, 02 ; minutes |
3043 | shl ecx, 16 |
3149 | shl ecx, 16 |
3044 | out 0x70, al |
3150 | out 0x70, al |
3045 | in al, 0x71 |
3151 | in al, 0x71 |
3046 | movzx edx, al |
3152 | movzx edx, al |
3047 | mov al, 04 ; hours |
3153 | mov al, 04 ; hours |
3048 | shl edx, 8 |
3154 | shl edx, 8 |
3049 | out 0x70, al |
3155 | out 0x70, al |
3050 | in al, 0x71 |
3156 | in al, 0x71 |
3051 | add ecx, edx |
3157 | add ecx, edx |
3052 | movzx edx, al |
3158 | movzx edx, al |
3053 | add ecx, edx |
3159 | add ecx, edx |
3054 | sti |
3160 | sti |
3055 | mov [esp + 32], ecx |
3161 | mov [esp + 32], ecx |
3056 | ret |
3162 | ret |
3057 | 3163 | ||
3058 | 3164 | ||
3059 | align 4 |
3165 | align 4 |
3060 | 3166 | ||
3061 | sys_date: |
3167 | sys_date: |
3062 | 3168 | ||
3063 | cli |
3169 | cli |
3064 | @@: |
3170 | @@: |
3065 | mov al, 10 |
3171 | mov al, 10 |
3066 | out 0x70, al |
3172 | out 0x70, al |
3067 | in al, 0x71 |
3173 | in al, 0x71 |
3068 | test al, al |
3174 | test al, al |
3069 | jns @f |
3175 | jns @f |
3070 | mov esi, 1 |
3176 | mov esi, 1 |
3071 | call delay_ms |
3177 | call delay_ms |
3072 | jmp @b |
3178 | jmp @b |
3073 | @@: |
3179 | @@: |
3074 | 3180 | ||
3075 | mov ch, 0 |
3181 | mov ch, 0 |
3076 | mov al, 7 ; date |
3182 | mov al, 7 ; date |
3077 | out 0x70, al |
3183 | out 0x70, al |
3078 | in al, 0x71 |
3184 | in al, 0x71 |
3079 | mov cl, al |
3185 | mov cl, al |
3080 | mov al, 8 ; month |
3186 | mov al, 8 ; month |
3081 | shl ecx, 16 |
3187 | shl ecx, 16 |
3082 | out 0x70, al |
3188 | out 0x70, al |
3083 | in al, 0x71 |
3189 | in al, 0x71 |
3084 | mov ch, al |
3190 | mov ch, al |
3085 | mov al, 9 ; year |
3191 | mov al, 9 ; year |
3086 | out 0x70, al |
3192 | out 0x70, al |
3087 | in al, 0x71 |
3193 | in al, 0x71 |
3088 | mov cl, al |
3194 | mov cl, al |
3089 | sti |
3195 | sti |
3090 | mov [esp+32], ecx |
3196 | mov [esp+32], ecx |
3091 | ret |
3197 | ret |
3092 | 3198 | ||
3093 | 3199 | ||
3094 | ; redraw status |
3200 | ; redraw status |
3095 | 3201 | ||
3096 | sys_redrawstat: |
3202 | sys_redrawstat: |
3097 | cmp ebx, 1 |
3203 | cmp ebx, 1 |
3098 | jne no_widgets_away |
3204 | jne no_widgets_away |
3099 | ; buttons away |
3205 | ; buttons away |
3100 | mov ecx, [CURRENT_TASK] |
3206 | mov ecx, [CURRENT_TASK] |
3101 | sys_newba2: |
3207 | sys_newba2: |
3102 | mov edi, [BTN_ADDR] |
3208 | mov edi, [BTN_ADDR] |
3103 | cmp [edi], dword 0 ; empty button list ? |
3209 | cmp [edi], dword 0 ; empty button list ? |
3104 | je end_of_buttons_away |
3210 | je end_of_buttons_away |
3105 | movzx ebx, word [edi] |
3211 | movzx ebx, word [edi] |
3106 | inc ebx |
3212 | inc ebx |
3107 | mov eax, edi |
3213 | mov eax, edi |
3108 | sys_newba: |
3214 | sys_newba: |
3109 | dec ebx |
3215 | dec ebx |
3110 | jz end_of_buttons_away |
3216 | jz end_of_buttons_away |
3111 | 3217 | ||
3112 | add eax, 0x10 |
3218 | add eax, 0x10 |
3113 | cmp cx, [eax] |
3219 | cmp cx, [eax] |
3114 | jnz sys_newba |
3220 | jnz sys_newba |
3115 | 3221 | ||
3116 | push eax ebx ecx |
3222 | push eax ebx ecx |
3117 | mov ecx, ebx |
3223 | mov ecx, ebx |
3118 | inc ecx |
3224 | inc ecx |
3119 | shl ecx, 4 |
3225 | shl ecx, 4 |
3120 | mov ebx, eax |
3226 | mov ebx, eax |
3121 | add eax, 0x10 |
3227 | add eax, 0x10 |
3122 | call memmove |
3228 | call memmove |
3123 | dec dword [edi] |
3229 | dec dword [edi] |
3124 | pop ecx ebx eax |
3230 | pop ecx ebx eax |
3125 | 3231 | ||
3126 | jmp sys_newba2 |
3232 | jmp sys_newba2 |
3127 | 3233 | ||
3128 | end_of_buttons_away: |
3234 | end_of_buttons_away: |
3129 | 3235 | ||
3130 | ret |
3236 | ret |
3131 | 3237 | ||
3132 | no_widgets_away: |
3238 | no_widgets_away: |
3133 | 3239 | ||
3134 | cmp ebx, 2 |
3240 | cmp ebx, 2 |
3135 | jnz srl1 |
3241 | jnz srl1 |
3136 | 3242 | ||
3137 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3243 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3138 | add edx, draw_data - CURRENT_TASK |
3244 | add edx, draw_data - CURRENT_TASK |
3139 | mov [edx + RECT.left], 0 |
3245 | mov [edx + RECT.left], 0 |
3140 | mov [edx + RECT.top], 0 |
3246 | mov [edx + RECT.top], 0 |
3141 | mov eax, [Screen_Max_X] |
3247 | mov eax, [Screen_Max_X] |
3142 | mov [edx + RECT.right], eax |
3248 | mov [edx + RECT.right], eax |
3143 | mov eax, [Screen_Max_Y] |
3249 | mov eax, [Screen_Max_Y] |
3144 | mov [edx + RECT.bottom], eax |
3250 | mov [edx + RECT.bottom], eax |
3145 | 3251 | ||
3146 | srl1: |
3252 | srl1: |
3147 | ret |
3253 | ret |
3148 | 3254 | ||
3149 | ;ok - 100% work |
3255 | ;ok - 100% work |
3150 | ;nt - not tested |
3256 | ;nt - not tested |
3151 | ;--------------------------------------------------------------------------------------------- |
3257 | ;--------------------------------------------------------------------------------------------- |
3152 | ;eax |
3258 | ;eax |
3153 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3259 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3154 | ;1 - change task. Ret nothing. Block. ok. |
3260 | ;1 - change task. Ret nothing. Block. ok. |
3155 | ;2 - performance control |
3261 | ;2 - performance control |
3156 | ; ebx |
3262 | ; ebx |
3157 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3263 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3158 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3264 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3159 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3265 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3160 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3266 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3161 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3267 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3162 | ;eax |
3268 | ;eax |
3163 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3269 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3164 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3270 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3165 | ;--------------------------------------------------------------------------------------------- |
3271 | ;--------------------------------------------------------------------------------------------- |
3166 | iglobal |
3272 | iglobal |
3167 | align 4 |
3273 | align 4 |
3168 | sheduler: |
3274 | sheduler: |
3169 | dd sys_sheduler.00 |
3275 | dd sys_sheduler.00 |
3170 | dd change_task |
3276 | dd change_task |
3171 | dd sys_sheduler.02 |
3277 | dd sys_sheduler.02 |
3172 | dd sys_sheduler.03 |
3278 | dd sys_sheduler.03 |
3173 | dd sys_sheduler.04 |
3279 | dd sys_sheduler.04 |
3174 | endg |
3280 | endg |
3175 | sys_sheduler: |
3281 | sys_sheduler: |
3176 | ;rewritten by |
3282 | ;rewritten by |
3177 | jmp dword [sheduler+ebx*4] |
3283 | jmp dword [sheduler+ebx*4] |
3178 | ;.shed_counter: |
3284 | ;.shed_counter: |
3179 | .00: |
3285 | .00: |
3180 | mov eax, [context_counter] |
3286 | mov eax, [context_counter] |
3181 | mov [esp+32], eax |
3287 | mov [esp+32], eax |
3182 | ret |
3288 | ret |
3183 | 3289 | ||
3184 | .02: |
3290 | .02: |
3185 | ;.perf_control: |
3291 | ;.perf_control: |
3186 | inc ebx ;before ebx=2, ebx=3 |
3292 | inc ebx ;before ebx=2, ebx=3 |
3187 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3293 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3188 | jz cache_disable |
3294 | jz cache_disable |
3189 | 3295 | ||
3190 | dec ebx ;ebx=2 |
3296 | dec ebx ;ebx=2 |
3191 | cmp ebx, ecx ; |
3297 | cmp ebx, ecx ; |
3192 | jz cache_enable ;if ecx=2 and ebx=2 |
3298 | jz cache_enable ;if ecx=2 and ebx=2 |
3193 | 3299 | ||
3194 | dec ebx ;ebx=1 |
3300 | dec ebx ;ebx=1 |
3195 | cmp ebx, ecx |
3301 | cmp ebx, ecx |
3196 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3302 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3197 | 3303 | ||
3198 | dec ebx |
3304 | dec ebx |
3199 | test ebx, ecx ;ebx=0 and ecx=0 |
3305 | test ebx, ecx ;ebx=0 and ecx=0 |
3200 | jz modify_pce ;if ecx=0 |
3306 | jz modify_pce ;if ecx=0 |
3201 | 3307 | ||
3202 | ret |
3308 | ret |
3203 | 3309 | ||
3204 | .03: |
3310 | .03: |
3205 | ;.rdmsr_instr: |
3311 | ;.rdmsr_instr: |
3206 | ;now counter in ecx |
3312 | ;now counter in ecx |
3207 | ;(edx:eax) esi:edi => edx:esi |
3313 | ;(edx:eax) esi:edi => edx:esi |
3208 | mov eax, esi |
3314 | mov eax, esi |
3209 | mov ecx, edx |
3315 | mov ecx, edx |
3210 | rdmsr |
3316 | rdmsr |
3211 | mov [esp+32], eax |
3317 | mov [esp+32], eax |
3212 | mov [esp+20], edx ;ret in ebx? |
3318 | mov [esp+20], edx ;ret in ebx? |
3213 | ret |
3319 | ret |
3214 | 3320 | ||
3215 | .04: |
3321 | .04: |
3216 | ;.wrmsr_instr: |
3322 | ;.wrmsr_instr: |
3217 | ;now counter in ecx |
3323 | ;now counter in ecx |
3218 | ;(edx:eax) esi:edi => edx:esi |
3324 | ;(edx:eax) esi:edi => edx:esi |
3219 | ; Fast Call MSR can't be destroy |
3325 | ; Fast Call MSR can't be destroy |
3220 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3326 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3221 | ; включаются/выключаются расширенные возможности |
3327 | ; включаются/выключаются расширенные возможности |
3222 | cmp edx, MSR_SYSENTER_CS |
3328 | cmp edx, MSR_SYSENTER_CS |
3223 | je @f |
3329 | je @f |
3224 | cmp edx, MSR_SYSENTER_ESP |
3330 | cmp edx, MSR_SYSENTER_ESP |
3225 | je @f |
3331 | je @f |
3226 | cmp edx, MSR_SYSENTER_EIP |
3332 | cmp edx, MSR_SYSENTER_EIP |
3227 | je @f |
3333 | je @f |
3228 | cmp edx, MSR_AMD_STAR |
3334 | cmp edx, MSR_AMD_STAR |
3229 | je @f |
3335 | je @f |
3230 | 3336 | ||
3231 | mov eax, esi |
3337 | mov eax, esi |
3232 | mov ecx, edx |
3338 | mov ecx, edx |
3233 | wrmsr |
3339 | wrmsr |
3234 | ; mov [esp + 32], eax |
3340 | ; mov [esp + 32], eax |
3235 | ; mov [esp + 20], edx ;ret in ebx? |
3341 | ; mov [esp + 20], edx ;ret in ebx? |
3236 | @@: |
3342 | @@: |
3237 | ret |
3343 | ret |
3238 | 3344 | ||
3239 | cache_disable: |
3345 | cache_disable: |
3240 | mov eax, cr0 |
3346 | mov eax, cr0 |
3241 | or eax, 01100000000000000000000000000000b |
3347 | or eax, 01100000000000000000000000000000b |
3242 | mov cr0, eax |
3348 | mov cr0, eax |
3243 | wbinvd ;set MESI |
3349 | wbinvd ;set MESI |
3244 | ret |
3350 | ret |
3245 | 3351 | ||
3246 | cache_enable: |
3352 | cache_enable: |
3247 | mov eax, cr0 |
3353 | mov eax, cr0 |
3248 | and eax, 10011111111111111111111111111111b |
3354 | and eax, 10011111111111111111111111111111b |
3249 | mov cr0, eax |
3355 | mov cr0, eax |
3250 | ret |
3356 | ret |
3251 | 3357 | ||
3252 | is_cache_enabled: |
3358 | is_cache_enabled: |
3253 | mov eax, cr0 |
3359 | mov eax, cr0 |
3254 | mov ebx, eax |
3360 | mov ebx, eax |
3255 | and eax, 01100000000000000000000000000000b |
3361 | and eax, 01100000000000000000000000000000b |
3256 | jz cache_disabled |
3362 | jz cache_disabled |
3257 | mov [esp+32], ebx |
3363 | mov [esp+32], ebx |
3258 | cache_disabled: |
3364 | cache_disabled: |
3259 | mov dword [esp+32], eax;0 |
3365 | mov dword [esp+32], eax;0 |
3260 | ret |
3366 | ret |
3261 | 3367 | ||
3262 | modify_pce: |
3368 | modify_pce: |
3263 | mov eax, cr4 |
3369 | mov eax, cr4 |
3264 | ; mov ebx,0 |
3370 | ; mov ebx,0 |
3265 | ; or bx,100000000b ;pce |
3371 | ; or bx,100000000b ;pce |
3266 | ; xor eax,ebx ;invert pce |
3372 | ; xor eax,ebx ;invert pce |
3267 | bts eax, 8;pce=cr4[8] |
3373 | bts eax, 8;pce=cr4[8] |
3268 | mov cr4, eax |
3374 | mov cr4, eax |
3269 | mov [esp+32], eax |
3375 | mov [esp+32], eax |
3270 | ret |
3376 | ret |
3271 | ;--------------------------------------------------------------------------------------------- |
3377 | ;--------------------------------------------------------------------------------------------- |
3272 | 3378 | ||
3273 | 3379 | ||
3274 | iglobal |
3380 | iglobal |
3275 | cpustring db 'CPU',0 |
3381 | cpustring db 'CPU',0 |
3276 | endg |
3382 | endg |
3277 | 3383 | ||
3278 | uglobal |
3384 | uglobal |
3279 | background_defined db 0 ; diamond, 11.04.2006 |
3385 | background_defined db 0 ; diamond, 11.04.2006 |
3280 | endg |
3386 | endg |
3281 | ;----------------------------------------------------------------------------- |
3387 | ;----------------------------------------------------------------------------- |
3282 | align 4 |
3388 | align 4 |
3283 | checkmisc: |
3389 | checkmisc: |
3284 | cmp [ctrl_alt_del], 1 |
3390 | cmp [ctrl_alt_del], 1 |
3285 | jne nocpustart |
3391 | jne nocpustart |
3286 | 3392 | ||
3287 | mov ebp, cpustring |
3393 | mov ebp, cpustring |
3288 | call fs_execute_from_sysdir |
3394 | call fs_execute_from_sysdir |
3289 | 3395 | ||
3290 | mov [ctrl_alt_del], 0 |
3396 | mov [ctrl_alt_del], 0 |
3291 | ;-------------------------------------- |
3397 | ;-------------------------------------- |
3292 | align 4 |
3398 | align 4 |
3293 | nocpustart: |
3399 | nocpustart: |
3294 | cmp [mouse_active], 1 |
3400 | cmp [mouse_active], 1 |
3295 | jne mouse_not_active |
3401 | jne mouse_not_active |
3296 | mov [mouse_active], 0 |
3402 | mov [mouse_active], 0 |
3297 | 3403 | ||
3298 | xor edi, edi |
3404 | xor edi, edi |
3299 | mov ebx, CURRENT_TASK |
3405 | mov ebx, CURRENT_TASK |
3300 | 3406 | ||
3301 | mov ecx, [TASK_COUNT] |
3407 | mov ecx, [TASK_COUNT] |
3302 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3408 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3303 | shl eax, 8 |
3409 | shl eax, 8 |
3304 | push eax |
3410 | push eax |
3305 | 3411 | ||
3306 | movzx eax, word [MOUSE_X] |
3412 | movzx eax, word [MOUSE_X] |
3307 | movzx edx, word [MOUSE_Y] |
3413 | movzx edx, word [MOUSE_Y] |
3308 | ;-------------------------------------- |
3414 | ;-------------------------------------- |
3309 | align 4 |
3415 | align 4 |
3310 | .set_mouse_event: |
3416 | .set_mouse_event: |
3311 | add edi, 256 |
3417 | add edi, 256 |
3312 | add ebx, 32 |
3418 | add ebx, 32 |
3313 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3419 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3314 | jz .pos_filter |
3420 | jz .pos_filter |
3315 | 3421 | ||
3316 | cmp edi, [esp] ; skip if filtration active |
3422 | cmp edi, [esp] ; skip if filtration active |
3317 | jne .skip |
3423 | jne .skip |
3318 | ;-------------------------------------- |
3424 | ;-------------------------------------- |
3319 | align 4 |
3425 | align 4 |
3320 | .pos_filter: |
3426 | .pos_filter: |
3321 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3427 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3322 | jz .set |
3428 | jz .set |
3323 | 3429 | ||
3324 | mov esi, [ebx-twdw+WDATA.box.left] |
3430 | mov esi, [ebx-twdw+WDATA.box.left] |
3325 | cmp eax, esi |
3431 | cmp eax, esi |
3326 | jb .skip |
3432 | jb .skip |
3327 | add esi, [ebx-twdw+WDATA.box.width] |
3433 | add esi, [ebx-twdw+WDATA.box.width] |
3328 | cmp eax, esi |
3434 | cmp eax, esi |
3329 | ja .skip |
3435 | ja .skip |
3330 | 3436 | ||
3331 | mov esi, [ebx-twdw+WDATA.box.top] |
3437 | mov esi, [ebx-twdw+WDATA.box.top] |
3332 | cmp edx, esi |
3438 | cmp edx, esi |
3333 | jb .skip |
3439 | jb .skip |
3334 | add esi, [ebx-twdw+WDATA.box.height] |
3440 | add esi, [ebx-twdw+WDATA.box.height] |
3335 | cmp edx, esi |
3441 | cmp edx, esi |
3336 | ja .skip |
3442 | ja .skip |
3337 | ;-------------------------------------- |
3443 | ;-------------------------------------- |
3338 | align 4 |
3444 | align 4 |
3339 | .set: |
3445 | .set: |
3340 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3446 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3341 | ;-------------------------------------- |
3447 | ;-------------------------------------- |
3342 | align 4 |
3448 | align 4 |
3343 | .skip: |
3449 | .skip: |
3344 | loop .set_mouse_event |
3450 | loop .set_mouse_event |
3345 | 3451 | ||
3346 | pop eax |
3452 | pop eax |
3347 | ;-------------------------------------- |
3453 | ;-------------------------------------- |
3348 | align 4 |
3454 | align 4 |
3349 | mouse_not_active: |
3455 | mouse_not_active: |
3350 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3456 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3351 | jz nobackgr |
3457 | jz nobackgr |
3352 | 3458 | ||
3353 | cmp [background_defined], 0 |
3459 | cmp [background_defined], 0 |
3354 | jz nobackgr |
3460 | jz nobackgr |
3355 | ;-------------------------------------- |
3461 | ;-------------------------------------- |
3356 | align 4 |
3462 | align 4 |
3357 | backgr: |
3463 | backgr: |
3358 | mov eax, [draw_data+32 + RECT.left] |
3464 | mov eax, [draw_data+32 + RECT.left] |
3359 | shl eax, 16 |
3465 | shl eax, 16 |
3360 | add eax, [draw_data+32 + RECT.right] |
3466 | add eax, [draw_data+32 + RECT.right] |
3361 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3467 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3362 | 3468 | ||
3363 | mov eax, [draw_data+32 + RECT.top] |
3469 | mov eax, [draw_data+32 + RECT.top] |
3364 | shl eax, 16 |
3470 | shl eax, 16 |
3365 | add eax, [draw_data+32 + RECT.bottom] |
3471 | add eax, [draw_data+32 + RECT.bottom] |
3366 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3472 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3367 | 3473 | ||
3368 | call drawbackground |
3474 | call drawbackground |
3369 | ; DEBUGF 1, "K : drawbackground\n" |
3475 | ; DEBUGF 1, "K : drawbackground\n" |
3370 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3476 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3371 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3477 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3372 | ;--------- set event 5 start ---------- |
3478 | ;--------- set event 5 start ---------- |
3373 | push ecx edi |
3479 | push ecx edi |
3374 | xor edi, edi |
3480 | xor edi, edi |
3375 | mov ecx, [TASK_COUNT] |
3481 | mov ecx, [TASK_COUNT] |
3376 | ;-------------------------------------- |
3482 | ;-------------------------------------- |
3377 | align 4 |
3483 | align 4 |
3378 | set_bgr_event: |
3484 | set_bgr_event: |
3379 | add edi, 256 |
3485 | add edi, 256 |
3380 | mov eax, [BG_Rect_X_left_right] |
3486 | mov eax, [BG_Rect_X_left_right] |
3381 | mov edx, [BG_Rect_Y_top_bottom] |
3487 | mov edx, [BG_Rect_Y_top_bottom] |
3382 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3488 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3383 | jz .set |
3489 | jz .set |
3384 | .join: |
3490 | .join: |
3385 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3491 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3386 | jae @f |
3492 | jae @f |
3387 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3493 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3388 | @@: |
3494 | @@: |
3389 | shr eax, 16 |
3495 | shr eax, 16 |
3390 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3496 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3391 | jbe @f |
3497 | jbe @f |
3392 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3498 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3393 | @@: |
3499 | @@: |
3394 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3500 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3395 | jae @f |
3501 | jae @f |
3396 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3502 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3397 | @@: |
3503 | @@: |
3398 | shr edx, 16 |
3504 | shr edx, 16 |
3399 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3505 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3400 | jbe @f |
3506 | jbe @f |
3401 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3507 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3402 | @@: |
3508 | @@: |
3403 | jmp .common |
3509 | jmp .common |
3404 | .set: |
3510 | .set: |
3405 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3511 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3406 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3512 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3407 | .common: |
3513 | .common: |
3408 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3514 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3409 | loop set_bgr_event |
3515 | loop set_bgr_event |
3410 | pop edi ecx |
3516 | pop edi ecx |
3411 | ;--------- set event 5 stop ----------- |
3517 | ;--------- set event 5 stop ----------- |
3412 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3518 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3413 | jnz backgr |
3519 | jnz backgr |
3414 | 3520 | ||
3415 | xor eax, eax |
3521 | xor eax, eax |
3416 | mov [draw_data+32 + RECT.left], eax |
3522 | mov [draw_data+32 + RECT.left], eax |
3417 | mov [draw_data+32 + RECT.top], eax |
3523 | mov [draw_data+32 + RECT.top], eax |
3418 | mov [draw_data+32 + RECT.right], eax |
3524 | mov [draw_data+32 + RECT.right], eax |
3419 | mov [draw_data+32 + RECT.bottom], eax |
3525 | mov [draw_data+32 + RECT.bottom], eax |
3420 | ;-------------------------------------- |
3526 | ;-------------------------------------- |
3421 | align 4 |
3527 | align 4 |
3422 | nobackgr: |
3528 | nobackgr: |
3423 | ; system shutdown request |
3529 | ; system shutdown request |
3424 | cmp [SYS_SHUTDOWN], byte 0 |
3530 | cmp [SYS_SHUTDOWN], byte 0 |
3425 | je noshutdown |
3531 | je noshutdown |
3426 | 3532 | ||
3427 | mov edx, [shutdown_processes] |
3533 | mov edx, [shutdown_processes] |
3428 | 3534 | ||
3429 | cmp [SYS_SHUTDOWN], dl |
3535 | cmp [SYS_SHUTDOWN], dl |
3430 | jne noshutdown |
3536 | jne noshutdown |
3431 | 3537 | ||
3432 | lea ecx, [edx-1] |
3538 | lea ecx, [edx-1] |
3433 | mov edx, OS_BASE+0x3040 |
3539 | mov edx, OS_BASE+0x3040 |
3434 | jecxz no_mark_system_shutdown |
3540 | jecxz no_mark_system_shutdown |
3435 | ;-------------------------------------- |
3541 | ;-------------------------------------- |
3436 | align 4 |
3542 | align 4 |
3437 | markz: |
3543 | markz: |
3438 | push ecx edx |
3544 | push ecx edx |
3439 | cmp [edx+TASKDATA.state], 9 |
3545 | cmp [edx+TASKDATA.state], 9 |
3440 | jz .nokill |
3546 | jz .nokill |
3441 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3547 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3442 | cmp [edx+APPDATA.process], sys_proc |
3548 | cmp [edx+APPDATA.process], sys_proc |
3443 | jz .nokill |
3549 | jz .nokill |
3444 | call request_terminate |
3550 | call request_terminate |
3445 | jmp .common |
3551 | jmp .common |
3446 | .nokill: |
3552 | .nokill: |
3447 | dec byte [SYS_SHUTDOWN] |
3553 | dec byte [SYS_SHUTDOWN] |
3448 | xor eax, eax |
3554 | xor eax, eax |
3449 | .common: |
3555 | .common: |
3450 | pop edx ecx |
3556 | pop edx ecx |
3451 | test eax, eax |
3557 | test eax, eax |
3452 | jz @f |
3558 | jz @f |
3453 | mov [edx+TASKDATA.state], byte 3 |
3559 | mov [edx+TASKDATA.state], byte 3 |
3454 | @@: |
3560 | @@: |
3455 | add edx, 0x20 |
3561 | add edx, 0x20 |
3456 | loop markz |
3562 | loop markz |
3457 | call wakeup_osloop |
3563 | call wakeup_osloop |
3458 | ;-------------------------------------- |
3564 | ;-------------------------------------- |
3459 | align 4 |
3565 | align 4 |
3460 | @@: |
3566 | @@: |
3461 | no_mark_system_shutdown: |
3567 | no_mark_system_shutdown: |
3462 | dec byte [SYS_SHUTDOWN] |
3568 | dec byte [SYS_SHUTDOWN] |
3463 | je system_shutdown |
3569 | je system_shutdown |
3464 | ;-------------------------------------- |
3570 | ;-------------------------------------- |
3465 | align 4 |
3571 | align 4 |
3466 | noshutdown: |
3572 | noshutdown: |
3467 | mov eax, [TASK_COUNT] ; termination |
3573 | mov eax, [TASK_COUNT] ; termination |
3468 | mov ebx, TASK_DATA+TASKDATA.state |
3574 | mov ebx, TASK_DATA+TASKDATA.state |
3469 | mov esi, 1 |
3575 | mov esi, 1 |
3470 | ;-------------------------------------- |
3576 | ;-------------------------------------- |
3471 | align 4 |
3577 | align 4 |
3472 | newct: |
3578 | newct: |
3473 | mov cl, [ebx] |
3579 | mov cl, [ebx] |
3474 | cmp cl, byte 3 |
3580 | cmp cl, byte 3 |
3475 | jz .terminate |
3581 | jz .terminate |
3476 | 3582 | ||
3477 | cmp cl, byte 4 |
3583 | cmp cl, byte 4 |
3478 | jnz .noterminate |
3584 | jnz .noterminate |
3479 | .terminate: |
3585 | .terminate: |
3480 | pushad |
3586 | pushad |
3481 | mov ecx, eax |
3587 | mov ecx, eax |
3482 | shl ecx, 8 |
3588 | shl ecx, 8 |
3483 | add ecx, SLOT_BASE |
3589 | add ecx, SLOT_BASE |
3484 | call restore_default_cursor_before_killing |
3590 | call restore_default_cursor_before_killing |
3485 | popad |
3591 | popad |
3486 | 3592 | ||
3487 | pushad |
3593 | pushad |
3488 | call terminate |
3594 | call terminate |
3489 | popad |
3595 | popad |
3490 | cmp byte [SYS_SHUTDOWN], 0 |
3596 | cmp byte [SYS_SHUTDOWN], 0 |
3491 | jz .noterminate |
3597 | jz .noterminate |
3492 | dec byte [SYS_SHUTDOWN] |
3598 | dec byte [SYS_SHUTDOWN] |
3493 | je system_shutdown |
3599 | je system_shutdown |
3494 | 3600 | ||
3495 | .noterminate: |
3601 | .noterminate: |
3496 | add ebx, 0x20 |
3602 | add ebx, 0x20 |
3497 | inc esi |
3603 | inc esi |
3498 | dec eax |
3604 | dec eax |
3499 | jnz newct |
3605 | jnz newct |
3500 | ret |
3606 | ret |
3501 | ;----------------------------------------------------------------------------- |
3607 | ;----------------------------------------------------------------------------- |
3502 | align 4 |
3608 | align 4 |
3503 | redrawscreen: |
3609 | redrawscreen: |
3504 | ; eax , if process window_data base is eax, do not set flag/limits |
3610 | ; eax , if process window_data base is eax, do not set flag/limits |
3505 | 3611 | ||
3506 | pushad |
3612 | pushad |
3507 | push eax |
3613 | push eax |
3508 | 3614 | ||
3509 | ;;; mov ebx,2 |
3615 | ;;; mov ebx,2 |
3510 | ;;; call delay_hs |
3616 | ;;; call delay_hs |
3511 | 3617 | ||
3512 | ;mov ecx,0 ; redraw flags for apps |
3618 | ;mov ecx,0 ; redraw flags for apps |
3513 | xor ecx, ecx |
3619 | xor ecx, ecx |
3514 | ;-------------------------------------- |
3620 | ;-------------------------------------- |
3515 | align 4 |
3621 | align 4 |
3516 | newdw2: |
3622 | newdw2: |
3517 | inc ecx |
3623 | inc ecx |
3518 | push ecx |
3624 | push ecx |
3519 | 3625 | ||
3520 | mov eax, ecx |
3626 | mov eax, ecx |
3521 | shl eax, 5 |
3627 | shl eax, 5 |
3522 | add eax, window_data |
3628 | add eax, window_data |
3523 | 3629 | ||
3524 | cmp eax, [esp+4] |
3630 | cmp eax, [esp+4] |
3525 | je not_this_task |
3631 | je not_this_task |
3526 | ; check if window in redraw area |
3632 | ; check if window in redraw area |
3527 | mov edi, eax |
3633 | mov edi, eax |
3528 | 3634 | ||
3529 | cmp ecx, 1 ; limit for background |
3635 | cmp ecx, 1 ; limit for background |
3530 | jz bgli |
3636 | jz bgli |
3531 | 3637 | ||
3532 | mov eax, [edi + WDATA.box.left] |
3638 | mov eax, [edi + WDATA.box.left] |
3533 | mov ebx, [edi + WDATA.box.top] |
3639 | mov ebx, [edi + WDATA.box.top] |
3534 | 3640 | ||
3535 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3641 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3536 | cmp ecx, ebx |
3642 | cmp ecx, ebx |
3537 | jb ricino |
3643 | jb ricino |
3538 | 3644 | ||
3539 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3645 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3540 | cmp ecx, eax |
3646 | cmp ecx, eax |
3541 | jb ricino |
3647 | jb ricino |
3542 | 3648 | ||
3543 | mov eax, [edi + WDATA.box.left] |
3649 | mov eax, [edi + WDATA.box.left] |
3544 | mov ebx, [edi + WDATA.box.top] |
3650 | mov ebx, [edi + WDATA.box.top] |
3545 | mov ecx, [edi + WDATA.box.width] |
3651 | mov ecx, [edi + WDATA.box.width] |
3546 | mov edx, [edi + WDATA.box.height] |
3652 | mov edx, [edi + WDATA.box.height] |
3547 | add ecx, eax |
3653 | add ecx, eax |
3548 | add edx, ebx |
3654 | add edx, ebx |
3549 | 3655 | ||
3550 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3656 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3551 | cmp edx, eax |
3657 | cmp edx, eax |
3552 | jb ricino |
3658 | jb ricino |
3553 | 3659 | ||
3554 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3660 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3555 | cmp ecx, eax |
3661 | cmp ecx, eax |
3556 | jb ricino |
3662 | jb ricino |
3557 | ;-------------------------------------- |
3663 | ;-------------------------------------- |
3558 | align 4 |
3664 | align 4 |
3559 | bgli: |
3665 | bgli: |
3560 | cmp dword[esp], 1 |
3666 | cmp dword[esp], 1 |
3561 | jnz .az |
3667 | jnz .az |
3562 | 3668 | ||
3563 | cmp byte[REDRAW_BACKGROUND], 0 |
3669 | cmp byte[REDRAW_BACKGROUND], 0 |
3564 | jz .az |
3670 | jz .az |
3565 | 3671 | ||
3566 | mov dl, 0 |
3672 | mov dl, 0 |
3567 | lea eax, [edi+draw_data-window_data] |
3673 | lea eax, [edi+draw_data-window_data] |
3568 | mov ebx, [draw_limits.left] |
3674 | mov ebx, [draw_limits.left] |
3569 | cmp ebx, [eax+RECT.left] |
3675 | cmp ebx, [eax+RECT.left] |
3570 | jae @f |
3676 | jae @f |
3571 | 3677 | ||
3572 | mov [eax+RECT.left], ebx |
3678 | mov [eax+RECT.left], ebx |
3573 | mov dl, 1 |
3679 | mov dl, 1 |
3574 | ;-------------------------------------- |
3680 | ;-------------------------------------- |
3575 | align 4 |
3681 | align 4 |
3576 | @@: |
3682 | @@: |
3577 | mov ebx, [draw_limits.top] |
3683 | mov ebx, [draw_limits.top] |
3578 | cmp ebx, [eax+RECT.top] |
3684 | cmp ebx, [eax+RECT.top] |
3579 | jae @f |
3685 | jae @f |
3580 | 3686 | ||
3581 | mov [eax+RECT.top], ebx |
3687 | mov [eax+RECT.top], ebx |
3582 | mov dl, 1 |
3688 | mov dl, 1 |
3583 | ;-------------------------------------- |
3689 | ;-------------------------------------- |
3584 | align 4 |
3690 | align 4 |
3585 | @@: |
3691 | @@: |
3586 | mov ebx, [draw_limits.right] |
3692 | mov ebx, [draw_limits.right] |
3587 | cmp ebx, [eax+RECT.right] |
3693 | cmp ebx, [eax+RECT.right] |
3588 | jbe @f |
3694 | jbe @f |
3589 | 3695 | ||
3590 | mov [eax+RECT.right], ebx |
3696 | mov [eax+RECT.right], ebx |
3591 | mov dl, 1 |
3697 | mov dl, 1 |
3592 | ;-------------------------------------- |
3698 | ;-------------------------------------- |
3593 | align 4 |
3699 | align 4 |
3594 | @@: |
3700 | @@: |
3595 | mov ebx, [draw_limits.bottom] |
3701 | mov ebx, [draw_limits.bottom] |
3596 | cmp ebx, [eax+RECT.bottom] |
3702 | cmp ebx, [eax+RECT.bottom] |
3597 | jbe @f |
3703 | jbe @f |
3598 | 3704 | ||
3599 | mov [eax+RECT.bottom], ebx |
3705 | mov [eax+RECT.bottom], ebx |
3600 | mov dl, 1 |
3706 | mov dl, 1 |
3601 | ;-------------------------------------- |
3707 | ;-------------------------------------- |
3602 | align 4 |
3708 | align 4 |
3603 | @@: |
3709 | @@: |
3604 | add byte[REDRAW_BACKGROUND], dl |
3710 | add byte[REDRAW_BACKGROUND], dl |
3605 | call wakeup_osloop |
3711 | call wakeup_osloop |
3606 | jmp newdw8 |
3712 | jmp newdw8 |
3607 | ;-------------------------------------- |
3713 | ;-------------------------------------- |
3608 | align 4 |
3714 | align 4 |
3609 | .az: |
3715 | .az: |
3610 | mov eax, edi |
3716 | mov eax, edi |
3611 | add eax, draw_data-window_data |
3717 | add eax, draw_data-window_data |
3612 | 3718 | ||
3613 | mov ebx, [draw_limits.left] ; set limits |
3719 | mov ebx, [draw_limits.left] ; set limits |
3614 | mov [eax + RECT.left], ebx |
3720 | mov [eax + RECT.left], ebx |
3615 | mov ebx, [draw_limits.top] |
3721 | mov ebx, [draw_limits.top] |
3616 | mov [eax + RECT.top], ebx |
3722 | mov [eax + RECT.top], ebx |
3617 | mov ebx, [draw_limits.right] |
3723 | mov ebx, [draw_limits.right] |
3618 | mov [eax + RECT.right], ebx |
3724 | mov [eax + RECT.right], ebx |
3619 | mov ebx, [draw_limits.bottom] |
3725 | mov ebx, [draw_limits.bottom] |
3620 | mov [eax + RECT.bottom], ebx |
3726 | mov [eax + RECT.bottom], ebx |
3621 | 3727 | ||
3622 | sub eax, draw_data-window_data |
3728 | sub eax, draw_data-window_data |
3623 | 3729 | ||
3624 | cmp dword [esp], 1 |
3730 | cmp dword [esp], 1 |
3625 | jne nobgrd |
3731 | jne nobgrd |
3626 | inc byte[REDRAW_BACKGROUND] |
3732 | inc byte[REDRAW_BACKGROUND] |
3627 | call wakeup_osloop |
3733 | call wakeup_osloop |
3628 | ;-------------------------------------- |
3734 | ;-------------------------------------- |
3629 | align 4 |
3735 | align 4 |
3630 | newdw8: |
3736 | newdw8: |
3631 | nobgrd: |
3737 | nobgrd: |
3632 | ;-------------------------------------- |
3738 | ;-------------------------------------- |
3633 | push eax edi ebp |
3739 | push eax edi ebp |
3634 | mov edi, [esp+12] |
3740 | mov edi, [esp+12] |
3635 | cmp edi, 1 |
3741 | cmp edi, 1 |
3636 | je .found |
3742 | je .found |
3637 | 3743 | ||
3638 | mov eax, [draw_limits.left] |
3744 | mov eax, [draw_limits.left] |
3639 | mov ebx, [draw_limits.top] |
3745 | mov ebx, [draw_limits.top] |
3640 | mov ecx, [draw_limits.right] |
3746 | mov ecx, [draw_limits.right] |
3641 | sub ecx, eax |
3747 | sub ecx, eax |
3642 | test ecx, ecx |
3748 | test ecx, ecx |
3643 | jz .not_found |
3749 | jz .not_found |
3644 | 3750 | ||
3645 | mov edx, [draw_limits.bottom] |
3751 | mov edx, [draw_limits.bottom] |
3646 | sub edx, ebx |
3752 | sub edx, ebx |
3647 | test edx, edx |
3753 | test edx, edx |
3648 | jz .not_found |
3754 | jz .not_found |
3649 | 3755 | ||
3650 | ; eax - x, ebx - y |
3756 | ; eax - x, ebx - y |
3651 | ; ecx - size x, edx - size y |
3757 | ; ecx - size x, edx - size y |
3652 | add ebx, edx |
3758 | add ebx, edx |
3653 | ;-------------------------------------- |
3759 | ;-------------------------------------- |
3654 | align 4 |
3760 | align 4 |
3655 | .start_y: |
3761 | .start_y: |
3656 | push ecx |
3762 | push ecx |
3657 | ;-------------------------------------- |
3763 | ;-------------------------------------- |
3658 | align 4 |
3764 | align 4 |
3659 | .start_x: |
3765 | .start_x: |
3660 | add eax, ecx |
3766 | add eax, ecx |
3661 | mov ebp, [d_width_calc_area + ebx*4] |
3767 | mov ebp, [d_width_calc_area + ebx*4] |
3662 | add ebp, [_WinMapAddress] |
3768 | add ebp, [_WinMapAddress] |
3663 | movzx ebp, byte[eax+ebp] ; get value for current point |
3769 | movzx ebp, byte[eax+ebp] ; get value for current point |
3664 | cmp ebp, edi |
3770 | cmp ebp, edi |
3665 | jne @f |
3771 | jne @f |
3666 | 3772 | ||
3667 | pop ecx |
3773 | pop ecx |
3668 | jmp .found |
3774 | jmp .found |
3669 | ;-------------------------------------- |
3775 | ;-------------------------------------- |
3670 | align 4 |
3776 | align 4 |
3671 | @@: |
3777 | @@: |
3672 | sub eax, ecx |
3778 | sub eax, ecx |
3673 | 3779 | ||
3674 | dec ecx |
3780 | dec ecx |
3675 | jnz .start_x |
3781 | jnz .start_x |
3676 | 3782 | ||
3677 | pop ecx |
3783 | pop ecx |
3678 | dec ebx |
3784 | dec ebx |
3679 | dec edx |
3785 | dec edx |
3680 | jnz .start_y |
3786 | jnz .start_y |
3681 | ;-------------------------------------- |
3787 | ;-------------------------------------- |
3682 | align 4 |
3788 | align 4 |
3683 | .not_found: |
3789 | .not_found: |
3684 | pop ebp edi eax |
3790 | pop ebp edi eax |
3685 | jmp ricino |
3791 | jmp ricino |
3686 | ;-------------------------------------- |
3792 | ;-------------------------------------- |
3687 | align 4 |
3793 | align 4 |
3688 | .found: |
3794 | .found: |
3689 | pop ebp edi eax |
3795 | pop ebp edi eax |
3690 | 3796 | ||
3691 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3797 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3692 | ;-------------------------------------- |
3798 | ;-------------------------------------- |
3693 | align 4 |
3799 | align 4 |
3694 | ricino: |
3800 | ricino: |
3695 | not_this_task: |
3801 | not_this_task: |
3696 | pop ecx |
3802 | pop ecx |
3697 | 3803 | ||
3698 | cmp ecx, [TASK_COUNT] |
3804 | cmp ecx, [TASK_COUNT] |
3699 | jle newdw2 |
3805 | jle newdw2 |
3700 | 3806 | ||
3701 | pop eax |
3807 | pop eax |
3702 | popad |
3808 | popad |
3703 | ret |
3809 | ret |
3704 | ;----------------------------------------------------------------------------- |
3810 | ;----------------------------------------------------------------------------- |
3705 | align 4 |
3811 | align 4 |
3706 | calculatebackground: ; background |
3812 | calculatebackground: ; background |
3707 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3813 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3708 | mov eax, 0x01010101 |
3814 | mov eax, 0x01010101 |
3709 | mov ecx, [_WinMapSize] |
3815 | mov ecx, [_WinMapSize] |
3710 | shr ecx, 2 |
3816 | shr ecx, 2 |
3711 | rep stosd |
3817 | rep stosd |
3712 | 3818 | ||
3713 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3819 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3714 | ret |
3820 | ret |
3715 | ;----------------------------------------------------------------------------- |
3821 | ;----------------------------------------------------------------------------- |
3716 | uglobal |
3822 | uglobal |
3717 | imax dd 0x0 |
3823 | imax dd 0x0 |
3718 | endg |
3824 | endg |
3719 | ;----------------------------------------------------------------------------- |
3825 | ;----------------------------------------------------------------------------- |
3720 | align 4 |
3826 | align 4 |
3721 | delay_ms: ; delay in 1/1000 sec |
3827 | delay_ms: ; delay in 1/1000 sec |
3722 | push eax |
3828 | push eax |
3723 | push ecx |
3829 | push ecx |
3724 | 3830 | ||
3725 | mov ecx, esi |
3831 | mov ecx, esi |
3726 | ; |
3832 | ; |
3727 | imul ecx, 33941 |
3833 | imul ecx, 33941 |
3728 | shr ecx, 9 |
3834 | shr ecx, 9 |
3729 | ; |
3835 | ; |
3730 | 3836 | ||
3731 | in al, 0x61 |
3837 | in al, 0x61 |
3732 | and al, 0x10 |
3838 | and al, 0x10 |
3733 | mov ah, al |
3839 | mov ah, al |
3734 | cld |
3840 | cld |
3735 | ;-------------------------------------- |
3841 | ;-------------------------------------- |
3736 | align 4 |
3842 | align 4 |
3737 | cnt1: |
3843 | cnt1: |
3738 | in al, 0x61 |
3844 | in al, 0x61 |
3739 | and al, 0x10 |
3845 | and al, 0x10 |
3740 | cmp al, ah |
3846 | cmp al, ah |
3741 | jz cnt1 |
3847 | jz cnt1 |
3742 | 3848 | ||
3743 | mov ah, al |
3849 | mov ah, al |
3744 | loop cnt1 |
3850 | loop cnt1 |
3745 | 3851 | ||
3746 | pop ecx |
3852 | pop ecx |
3747 | pop eax |
3853 | pop eax |
3748 | ret |
3854 | ret |
3749 | ;----------------------------------------------------------------------------- |
3855 | ;----------------------------------------------------------------------------- |
3750 | align 4 |
3856 | align 4 |
3751 | set_app_param: |
3857 | set_app_param: |
3752 | mov edi, [TASK_BASE] |
3858 | mov edi, [TASK_BASE] |
3753 | mov eax, ebx |
3859 | mov eax, ebx |
3754 | btr eax, 3 ; move MOUSE_FILTRATION |
3860 | btr eax, 3 ; move MOUSE_FILTRATION |
3755 | mov ebx, [current_slot] ; bit into event_filter |
3861 | mov ebx, [current_slot] ; bit into event_filter |
3756 | setc byte [ebx+APPDATA.event_filter] |
3862 | setc byte [ebx+APPDATA.event_filter] |
3757 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3863 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3758 | mov [esp+32], eax ; return old mask value |
3864 | mov [esp+32], eax ; return old mask value |
3759 | ret |
3865 | ret |
3760 | ;----------------------------------------------------------------------------- |
3866 | ;----------------------------------------------------------------------------- |
3761 | 3867 | ||
3762 | ; this is for syscall |
3868 | ; this is for syscall |
3763 | proc delay_hs_unprotected |
3869 | proc delay_hs_unprotected |
3764 | call unprotect_from_terminate |
3870 | call unprotect_from_terminate |
3765 | call delay_hs |
3871 | call delay_hs |
3766 | call protect_from_terminate |
3872 | call protect_from_terminate |
3767 | ret |
3873 | ret |
3768 | endp |
3874 | endp |
3769 | 3875 | ||
3770 | if 1 |
3876 | if 1 |
3771 | align 4 |
3877 | align 4 |
3772 | delay_hs: ; delay in 1/100 secs |
3878 | delay_hs: ; delay in 1/100 secs |
3773 | ; ebx = delay time |
3879 | ; ebx = delay time |
3774 | 3880 | ||
3775 | pushad |
3881 | pushad |
3776 | push ebx |
3882 | push ebx |
3777 | xor esi, esi |
3883 | xor esi, esi |
3778 | mov ecx, MANUAL_DESTROY |
3884 | mov ecx, MANUAL_DESTROY |
3779 | call create_event |
3885 | call create_event |
3780 | test eax, eax |
3886 | test eax, eax |
3781 | jz .done |
3887 | jz .done |
3782 | 3888 | ||
3783 | mov ebx, edx |
3889 | mov ebx, edx |
3784 | mov ecx, [esp] |
3890 | mov ecx, [esp] |
3785 | push edx |
3891 | push edx |
3786 | push eax |
3892 | push eax |
3787 | call wait_event_timeout |
3893 | call wait_event_timeout |
3788 | pop eax |
3894 | pop eax |
3789 | pop ebx |
3895 | pop ebx |
3790 | call destroy_event |
3896 | call destroy_event |
3791 | .done: |
3897 | .done: |
3792 | add esp, 4 |
3898 | add esp, 4 |
3793 | popad |
3899 | popad |
3794 | ret |
3900 | ret |
3795 | 3901 | ||
3796 | else |
3902 | else |
3797 | 3903 | ||
3798 | align 4 |
3904 | align 4 |
3799 | delay_hs: ; delay in 1/100 secs |
3905 | delay_hs: ; delay in 1/100 secs |
3800 | ; ebx = delay time |
3906 | ; ebx = delay time |
3801 | push ecx |
3907 | push ecx |
3802 | push edx |
3908 | push edx |
3803 | 3909 | ||
3804 | mov edx, [timer_ticks] |
3910 | mov edx, [timer_ticks] |
3805 | ;-------------------------------------- |
3911 | ;-------------------------------------- |
3806 | align 4 |
3912 | align 4 |
3807 | newtic: |
3913 | newtic: |
3808 | mov ecx, [timer_ticks] |
3914 | mov ecx, [timer_ticks] |
3809 | sub ecx, edx |
3915 | sub ecx, edx |
3810 | cmp ecx, ebx |
3916 | cmp ecx, ebx |
3811 | jae zerodelay |
3917 | jae zerodelay |
3812 | 3918 | ||
3813 | call change_task |
3919 | call change_task |
3814 | 3920 | ||
3815 | jmp newtic |
3921 | jmp newtic |
3816 | ;-------------------------------------- |
3922 | ;-------------------------------------- |
3817 | align 4 |
3923 | align 4 |
3818 | zerodelay: |
3924 | zerodelay: |
3819 | pop edx |
3925 | pop edx |
3820 | pop ecx |
3926 | pop ecx |
3821 | ret |
3927 | ret |
3822 | end if |
3928 | end if |
3823 | 3929 | ||
3824 | ;----------------------------------------------------------------------------- |
3930 | ;----------------------------------------------------------------------------- |
3825 | align 16 ;very often call this subrutine |
3931 | align 16 ;very often call this subrutine |
3826 | memmove: ; memory move in bytes |
3932 | memmove: ; memory move in bytes |
3827 | ; eax = from |
3933 | ; eax = from |
3828 | ; ebx = to |
3934 | ; ebx = to |
3829 | ; ecx = no of bytes |
3935 | ; ecx = no of bytes |
3830 | test ecx, ecx |
3936 | test ecx, ecx |
3831 | jle .ret |
3937 | jle .ret |
3832 | 3938 | ||
3833 | push esi edi ecx |
3939 | push esi edi ecx |
3834 | 3940 | ||
3835 | mov edi, ebx |
3941 | mov edi, ebx |
3836 | mov esi, eax |
3942 | mov esi, eax |
3837 | 3943 | ||
3838 | test ecx, not 11b |
3944 | test ecx, not 11b |
3839 | jz @f |
3945 | jz @f |
3840 | 3946 | ||
3841 | push ecx |
3947 | push ecx |
3842 | shr ecx, 2 |
3948 | shr ecx, 2 |
3843 | rep movsd |
3949 | rep movsd |
3844 | pop ecx |
3950 | pop ecx |
3845 | and ecx, 11b |
3951 | and ecx, 11b |
3846 | jz .finish |
3952 | jz .finish |
3847 | ;-------------------------------------- |
3953 | ;-------------------------------------- |
3848 | align 4 |
3954 | align 4 |
3849 | @@: |
3955 | @@: |
3850 | rep movsb |
3956 | rep movsb |
3851 | ;-------------------------------------- |
3957 | ;-------------------------------------- |
3852 | align 4 |
3958 | align 4 |
3853 | .finish: |
3959 | .finish: |
3854 | pop ecx edi esi |
3960 | pop ecx edi esi |
3855 | ;-------------------------------------- |
3961 | ;-------------------------------------- |
3856 | align 4 |
3962 | align 4 |
3857 | .ret: |
3963 | .ret: |
3858 | ret |
3964 | ret |
3859 | ;----------------------------------------------------------------------------- |
3965 | ;----------------------------------------------------------------------------- |
3860 | ; |
3966 | ; |
3861 | ;align 4 |
3967 | ;align 4 |
3862 | ; |
3968 | ; |
3863 | ;read_floppy_file: |
3969 | ;read_floppy_file: |
3864 | ; |
3970 | ; |
3865 | ;; as input |
3971 | ;; as input |
3866 | ;; |
3972 | ;; |
3867 | ;; eax pointer to file |
3973 | ;; eax pointer to file |
3868 | ;; ebx file lenght |
3974 | ;; ebx file lenght |
3869 | ;; ecx start 512 byte block number |
3975 | ;; ecx start 512 byte block number |
3870 | ;; edx number of blocks to read |
3976 | ;; edx number of blocks to read |
3871 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3977 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
3872 | ;; |
3978 | ;; |
3873 | ;; |
3979 | ;; |
3874 | ;; on return |
3980 | ;; on return |
3875 | ;; |
3981 | ;; |
3876 | ;; eax = 0 command succesful |
3982 | ;; eax = 0 command succesful |
3877 | ;; 1 no fd base and/or partition defined |
3983 | ;; 1 no fd base and/or partition defined |
3878 | ;; 2 yet unsupported FS |
3984 | ;; 2 yet unsupported FS |
3879 | ;; 3 unknown FS |
3985 | ;; 3 unknown FS |
3880 | ;; 4 partition not defined at hd |
3986 | ;; 4 partition not defined at hd |
3881 | ;; 5 file not found |
3987 | ;; 5 file not found |
3882 | ;; ebx = size of file |
3988 | ;; ebx = size of file |
3883 | ; |
3989 | ; |
3884 | ; mov edi,[TASK_BASE] |
3990 | ; mov edi,[TASK_BASE] |
3885 | ; add edi,0x10 |
3991 | ; add edi,0x10 |
3886 | ; add esi,[edi] |
3992 | ; add esi,[edi] |
3887 | ; add eax,[edi] |
3993 | ; add eax,[edi] |
3888 | ; |
3994 | ; |
3889 | ; pushad |
3995 | ; pushad |
3890 | ; mov edi,esi |
3996 | ; mov edi,esi |
3891 | ; add edi,1024 |
3997 | ; add edi,1024 |
3892 | ; mov esi,0x100000+19*512 |
3998 | ; mov esi,0x100000+19*512 |
3893 | ; sub ecx,1 |
3999 | ; sub ecx,1 |
3894 | ; shl ecx,9 |
4000 | ; shl ecx,9 |
3895 | ; add esi,ecx |
4001 | ; add esi,ecx |
3896 | ; shl edx,9 |
4002 | ; shl edx,9 |
3897 | ; mov ecx,edx |
4003 | ; mov ecx,edx |
3898 | ; cld |
4004 | ; cld |
3899 | ; rep movsb |
4005 | ; rep movsb |
3900 | ; popad |
4006 | ; popad |
3901 | ; |
4007 | ; |
3902 | ; mov [esp+36],eax |
4008 | ; mov [esp+36],eax |
3903 | ; mov [esp+24],ebx |
4009 | ; mov [esp+24],ebx |
3904 | ; ret |
4010 | ; ret |
3905 | 4011 | ||
3906 | 4012 | ||
3907 | 4013 | ||
3908 | align 4 |
4014 | align 4 |
3909 | set_io_access_rights: |
4015 | set_io_access_rights: |
3910 | push edi eax |
4016 | push edi eax |
3911 | mov edi, tss._io_map_0 |
4017 | mov edi, tss._io_map_0 |
3912 | ; mov ecx,eax |
4018 | ; mov ecx,eax |
3913 | ; and ecx,7 ; offset in byte |
4019 | ; and ecx,7 ; offset in byte |
3914 | ; shr eax,3 ; number of byte |
4020 | ; shr eax,3 ; number of byte |
3915 | ; add edi,eax |
4021 | ; add edi,eax |
3916 | ; mov ebx,1 |
4022 | ; mov ebx,1 |
3917 | ; shl ebx,cl |
4023 | ; shl ebx,cl |
3918 | test ebp, ebp |
4024 | test ebp, ebp |
3919 | ; cmp ebp,0 ; enable access - ebp = 0 |
4025 | ; cmp ebp,0 ; enable access - ebp = 0 |
3920 | jnz .siar1 |
4026 | jnz .siar1 |
3921 | ; not ebx |
4027 | ; not ebx |
3922 | ; and [edi],byte bl |
4028 | ; and [edi],byte bl |
3923 | btr [edi], eax |
4029 | btr [edi], eax |
3924 | pop eax edi |
4030 | pop eax edi |
3925 | ret |
4031 | ret |
3926 | .siar1: |
4032 | .siar1: |
3927 | bts [edi], eax |
4033 | bts [edi], eax |
3928 | ; or [edi],byte bl ; disable access - ebp = 1 |
4034 | ; or [edi],byte bl ; disable access - ebp = 1 |
3929 | pop eax edi |
4035 | pop eax edi |
3930 | ret |
4036 | ret |
3931 | ;reserve/free group of ports |
4037 | ;reserve/free group of ports |
3932 | ; * eax = 46 - number function |
4038 | ; * eax = 46 - number function |
3933 | ; * ebx = 0 - reserve, 1 - free |
4039 | ; * ebx = 0 - reserve, 1 - free |
3934 | ; * ecx = number start arrea of ports |
4040 | ; * ecx = number start arrea of ports |
3935 | ; * edx = number end arrea of ports (include last number of port) |
4041 | ; * edx = number end arrea of ports (include last number of port) |
3936 | ;Return value: |
4042 | ;Return value: |
3937 | ; * eax = 0 - succesful |
4043 | ; * eax = 0 - succesful |
3938 | ; * eax = 1 - error |
4044 | ; * eax = 1 - error |
3939 | ; * The system has reserve this ports: |
4045 | ; * The system has reserve this ports: |
3940 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4046 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3941 | ;destroys eax,ebx, ebp |
4047 | ;destroys eax,ebx, ebp |
3942 | r_f_port_area: |
4048 | r_f_port_area: |
3943 | 4049 | ||
3944 | test ebx, ebx |
4050 | test ebx, ebx |
3945 | jnz free_port_area |
4051 | jnz free_port_area |
3946 | ; je r_port_area |
4052 | ; je r_port_area |
3947 | ; jmp free_port_area |
4053 | ; jmp free_port_area |
3948 | 4054 | ||
3949 | ; r_port_area: |
4055 | ; r_port_area: |
3950 | 4056 | ||
3951 | ; pushad |
4057 | ; pushad |
3952 | 4058 | ||
3953 | cmp ecx, edx ; beginning > end ? |
4059 | cmp ecx, edx ; beginning > end ? |
3954 | ja rpal1 |
4060 | ja rpal1 |
3955 | cmp edx, 65536 |
4061 | cmp edx, 65536 |
3956 | jae rpal1 |
4062 | jae rpal1 |
3957 | mov eax, [RESERVED_PORTS] |
4063 | mov eax, [RESERVED_PORTS] |
3958 | test eax, eax ; no reserved areas ? |
4064 | test eax, eax ; no reserved areas ? |
3959 | je rpal2 |
4065 | je rpal2 |
3960 | cmp eax, 255 ; max reserved |
4066 | cmp eax, 255 ; max reserved |
3961 | jae rpal1 |
4067 | jae rpal1 |
3962 | rpal3: |
4068 | rpal3: |
3963 | mov ebx, eax |
4069 | mov ebx, eax |
3964 | shl ebx, 4 |
4070 | shl ebx, 4 |
3965 | add ebx, RESERVED_PORTS |
4071 | add ebx, RESERVED_PORTS |
3966 | cmp ecx, [ebx+8] |
4072 | cmp ecx, [ebx+8] |
3967 | ja rpal4 |
4073 | ja rpal4 |
3968 | cmp edx, [ebx+4] |
4074 | cmp edx, [ebx+4] |
3969 | jae rpal1 |
4075 | jae rpal1 |
3970 | ; jb rpal4 |
4076 | ; jb rpal4 |
3971 | ; jmp rpal1 |
4077 | ; jmp rpal1 |
3972 | rpal4: |
4078 | rpal4: |
3973 | dec eax |
4079 | dec eax |
3974 | jnz rpal3 |
4080 | jnz rpal3 |
3975 | jmp rpal2 |
4081 | jmp rpal2 |
3976 | rpal1: |
4082 | rpal1: |
3977 | ; popad |
4083 | ; popad |
3978 | ; mov eax,1 |
4084 | ; mov eax,1 |
3979 | xor eax, eax |
4085 | xor eax, eax |
3980 | inc eax |
4086 | inc eax |
3981 | ret |
4087 | ret |
3982 | rpal2: |
4088 | rpal2: |
3983 | ; popad |
4089 | ; popad |
3984 | ; enable port access at port IO map |
4090 | ; enable port access at port IO map |
3985 | cli |
4091 | cli |
3986 | pushad ; start enable io map |
4092 | pushad ; start enable io map |
3987 | 4093 | ||
3988 | cmp edx, 65536;16384 |
4094 | cmp edx, 65536;16384 |
3989 | jae no_unmask_io; jge |
4095 | jae no_unmask_io; jge |
3990 | mov eax, ecx |
4096 | mov eax, ecx |
3991 | ; push ebp |
4097 | ; push ebp |
3992 | xor ebp, ebp ; enable - eax = port |
4098 | xor ebp, ebp ; enable - eax = port |
3993 | new_port_access: |
4099 | new_port_access: |
3994 | ; pushad |
4100 | ; pushad |
3995 | call set_io_access_rights |
4101 | call set_io_access_rights |
3996 | ; popad |
4102 | ; popad |
3997 | inc eax |
4103 | inc eax |
3998 | cmp eax, edx |
4104 | cmp eax, edx |
3999 | jbe new_port_access |
4105 | jbe new_port_access |
4000 | ; pop ebp |
4106 | ; pop ebp |
4001 | no_unmask_io: |
4107 | no_unmask_io: |
4002 | popad ; end enable io map |
4108 | popad ; end enable io map |
4003 | sti |
4109 | sti |
4004 | 4110 | ||
4005 | mov eax, [RESERVED_PORTS] |
4111 | mov eax, [RESERVED_PORTS] |
4006 | add eax, 1 |
4112 | add eax, 1 |
4007 | mov [RESERVED_PORTS], eax |
4113 | mov [RESERVED_PORTS], eax |
4008 | shl eax, 4 |
4114 | shl eax, 4 |
4009 | add eax, RESERVED_PORTS |
4115 | add eax, RESERVED_PORTS |
4010 | mov ebx, [TASK_BASE] |
4116 | mov ebx, [TASK_BASE] |
4011 | mov ebx, [ebx+TASKDATA.pid] |
4117 | mov ebx, [ebx+TASKDATA.pid] |
4012 | mov [eax], ebx |
4118 | mov [eax], ebx |
4013 | mov [eax+4], ecx |
4119 | mov [eax+4], ecx |
4014 | mov [eax+8], edx |
4120 | mov [eax+8], edx |
4015 | 4121 | ||
4016 | xor eax, eax |
4122 | xor eax, eax |
4017 | ret |
4123 | ret |
4018 | 4124 | ||
4019 | free_port_area: |
4125 | free_port_area: |
4020 | 4126 | ||
4021 | ; pushad |
4127 | ; pushad |
4022 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4128 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4023 | test eax, eax |
4129 | test eax, eax |
4024 | jz frpal2 |
4130 | jz frpal2 |
4025 | mov ebx, [TASK_BASE] |
4131 | mov ebx, [TASK_BASE] |
4026 | mov ebx, [ebx+TASKDATA.pid] |
4132 | mov ebx, [ebx+TASKDATA.pid] |
4027 | frpal3: |
4133 | frpal3: |
4028 | mov edi, eax |
4134 | mov edi, eax |
4029 | shl edi, 4 |
4135 | shl edi, 4 |
4030 | add edi, RESERVED_PORTS |
4136 | add edi, RESERVED_PORTS |
4031 | cmp ebx, [edi] |
4137 | cmp ebx, [edi] |
4032 | jne frpal4 |
4138 | jne frpal4 |
4033 | cmp ecx, [edi+4] |
4139 | cmp ecx, [edi+4] |
4034 | jne frpal4 |
4140 | jne frpal4 |
4035 | cmp edx, [edi+8] |
4141 | cmp edx, [edi+8] |
4036 | jne frpal4 |
4142 | jne frpal4 |
4037 | jmp frpal1 |
4143 | jmp frpal1 |
4038 | frpal4: |
4144 | frpal4: |
4039 | dec eax |
4145 | dec eax |
4040 | jnz frpal3 |
4146 | jnz frpal3 |
4041 | frpal2: |
4147 | frpal2: |
4042 | ; popad |
4148 | ; popad |
4043 | inc eax |
4149 | inc eax |
4044 | ret |
4150 | ret |
4045 | frpal1: |
4151 | frpal1: |
4046 | push ecx |
4152 | push ecx |
4047 | mov ecx, 256 |
4153 | mov ecx, 256 |
4048 | sub ecx, eax |
4154 | sub ecx, eax |
4049 | shl ecx, 4 |
4155 | shl ecx, 4 |
4050 | mov esi, edi |
4156 | mov esi, edi |
4051 | add esi, 16 |
4157 | add esi, 16 |
4052 | cld |
4158 | cld |
4053 | rep movsb |
4159 | rep movsb |
4054 | 4160 | ||
4055 | dec dword [RESERVED_PORTS] |
4161 | dec dword [RESERVED_PORTS] |
4056 | ;popad |
4162 | ;popad |
4057 | ;disable port access at port IO map |
4163 | ;disable port access at port IO map |
4058 | 4164 | ||
4059 | ; pushad ; start disable io map |
4165 | ; pushad ; start disable io map |
4060 | pop eax ;start port |
4166 | pop eax ;start port |
4061 | cmp edx, 65536;16384 |
4167 | cmp edx, 65536;16384 |
4062 | jge no_mask_io |
4168 | jge no_mask_io |
4063 | 4169 | ||
4064 | ; mov eax,ecx |
4170 | ; mov eax,ecx |
4065 | xor ebp, ebp |
4171 | xor ebp, ebp |
4066 | inc ebp |
4172 | inc ebp |
4067 | new_port_access_disable: |
4173 | new_port_access_disable: |
4068 | ; pushad |
4174 | ; pushad |
4069 | ; mov ebp,1 ; disable - eax = port |
4175 | ; mov ebp,1 ; disable - eax = port |
4070 | call set_io_access_rights |
4176 | call set_io_access_rights |
4071 | ; popad |
4177 | ; popad |
4072 | inc eax |
4178 | inc eax |
4073 | cmp eax, edx |
4179 | cmp eax, edx |
4074 | jbe new_port_access_disable |
4180 | jbe new_port_access_disable |
4075 | no_mask_io: |
4181 | no_mask_io: |
4076 | ; popad ; end disable io map |
4182 | ; popad ; end disable io map |
4077 | xor eax, eax |
4183 | xor eax, eax |
4078 | ret |
4184 | ret |
4079 | ;----------------------------------------------------------------------------- |
4185 | ;----------------------------------------------------------------------------- |
4080 | align 4 |
4186 | align 4 |
4081 | drawbackground: |
4187 | drawbackground: |
4082 | dbrv20: |
4188 | dbrv20: |
4083 | cmp [BgrDrawMode], dword 1 |
4189 | cmp [BgrDrawMode], dword 1 |
4084 | jne bgrstr |
4190 | jne bgrstr |
4085 | call vesa20_drawbackground_tiled |
4191 | call vesa20_drawbackground_tiled |
4086 | ; call [draw_pointer] |
4192 | ; call [draw_pointer] |
4087 | call __sys_draw_pointer |
4193 | call __sys_draw_pointer |
4088 | ret |
4194 | ret |
4089 | ;-------------------------------------- |
4195 | ;-------------------------------------- |
4090 | align 4 |
4196 | align 4 |
4091 | bgrstr: |
4197 | bgrstr: |
4092 | call vesa20_drawbackground_stretch |
4198 | call vesa20_drawbackground_stretch |
4093 | ; call [draw_pointer] |
4199 | ; call [draw_pointer] |
4094 | call __sys_draw_pointer |
4200 | call __sys_draw_pointer |
4095 | ret |
4201 | ret |
4096 | ;----------------------------------------------------------------------------- |
4202 | ;----------------------------------------------------------------------------- |
4097 | align 4 |
4203 | align 4 |
4098 | syscall_putimage: ; PutImage |
4204 | syscall_putimage: ; PutImage |
4099 | sys_putimage: |
4205 | sys_putimage: |
4100 | test ecx, 0x80008000 |
4206 | test ecx, 0x80008000 |
4101 | jnz .exit |
4207 | jnz .exit |
4102 | test ecx, 0x0000FFFF |
4208 | test ecx, 0x0000FFFF |
4103 | jz .exit |
4209 | jz .exit |
4104 | test ecx, 0xFFFF0000 |
4210 | test ecx, 0xFFFF0000 |
4105 | jnz @f |
4211 | jnz @f |
4106 | ;-------------------------------------- |
4212 | ;-------------------------------------- |
4107 | align 4 |
4213 | align 4 |
4108 | .exit: |
4214 | .exit: |
4109 | ret |
4215 | ret |
4110 | ;-------------------------------------- |
4216 | ;-------------------------------------- |
4111 | align 4 |
4217 | align 4 |
4112 | @@: |
4218 | @@: |
4113 | mov edi, [current_slot] |
4219 | mov edi, [current_slot] |
4114 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4220 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4115 | rol edx, 16 |
4221 | rol edx, 16 |
4116 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4222 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4117 | rol edx, 16 |
4223 | rol edx, 16 |
4118 | ;-------------------------------------- |
4224 | ;-------------------------------------- |
4119 | align 4 |
4225 | align 4 |
4120 | .forced: |
4226 | .forced: |
4121 | push ebp esi 0 |
4227 | push ebp esi 0 |
4122 | mov ebp, putimage_get24bpp |
4228 | mov ebp, putimage_get24bpp |
4123 | mov esi, putimage_init24bpp |
4229 | mov esi, putimage_init24bpp |
4124 | ;-------------------------------------- |
4230 | ;-------------------------------------- |
4125 | align 4 |
4231 | align 4 |
4126 | sys_putimage_bpp: |
4232 | sys_putimage_bpp: |
4127 | call vesa20_putimage |
4233 | call vesa20_putimage |
4128 | pop ebp esi ebp |
4234 | pop ebp esi ebp |
4129 | ret |
4235 | ret |
4130 | ; jmp [draw_pointer] |
4236 | ; jmp [draw_pointer] |
4131 | ;----------------------------------------------------------------------------- |
4237 | ;----------------------------------------------------------------------------- |
4132 | align 4 |
4238 | align 4 |
4133 | sys_putimage_palette: |
4239 | sys_putimage_palette: |
4134 | ; ebx = pointer to image |
4240 | ; ebx = pointer to image |
4135 | ; ecx = [xsize]*65536 + [ysize] |
4241 | ; ecx = [xsize]*65536 + [ysize] |
4136 | ; edx = [xstart]*65536 + [ystart] |
4242 | ; edx = [xstart]*65536 + [ystart] |
4137 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4243 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4138 | ; edi = pointer to palette |
4244 | ; edi = pointer to palette |
4139 | ; ebp = row delta |
4245 | ; ebp = row delta |
4140 | mov eax, [CURRENT_TASK] |
4246 | mov eax, [CURRENT_TASK] |
4141 | shl eax, 8 |
4247 | shl eax, 8 |
4142 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4248 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4143 | rol edx, 16 |
4249 | rol edx, 16 |
4144 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4250 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4145 | rol edx, 16 |
4251 | rol edx, 16 |
4146 | ;-------------------------------------- |
4252 | ;-------------------------------------- |
4147 | align 4 |
4253 | align 4 |
4148 | .forced: |
4254 | .forced: |
4149 | cmp esi, 1 |
4255 | cmp esi, 1 |
4150 | jnz @f |
4256 | jnz @f |
4151 | push edi |
4257 | push edi |
4152 | mov eax, [edi+4] |
4258 | mov eax, [edi+4] |
4153 | sub eax, [edi] |
4259 | sub eax, [edi] |
4154 | push eax |
4260 | push eax |
4155 | push dword [edi] |
4261 | push dword [edi] |
4156 | push 0ffffff80h |
4262 | push 0ffffff80h |
4157 | mov edi, esp |
4263 | mov edi, esp |
4158 | call put_mono_image |
4264 | call put_mono_image |
4159 | add esp, 12 |
4265 | add esp, 12 |
4160 | pop edi |
4266 | pop edi |
4161 | ret |
4267 | ret |
4162 | ;-------------------------------------- |
4268 | ;-------------------------------------- |
4163 | align 4 |
4269 | align 4 |
4164 | @@: |
4270 | @@: |
4165 | cmp esi, 2 |
4271 | cmp esi, 2 |
4166 | jnz @f |
4272 | jnz @f |
4167 | push edi |
4273 | push edi |
4168 | push 0ffffff80h |
4274 | push 0ffffff80h |
4169 | mov edi, esp |
4275 | mov edi, esp |
4170 | call put_2bit_image |
4276 | call put_2bit_image |
4171 | pop eax |
4277 | pop eax |
4172 | pop edi |
4278 | pop edi |
4173 | ret |
4279 | ret |
4174 | ;-------------------------------------- |
4280 | ;-------------------------------------- |
4175 | align 4 |
4281 | align 4 |
4176 | @@: |
4282 | @@: |
4177 | cmp esi, 4 |
4283 | cmp esi, 4 |
4178 | jnz @f |
4284 | jnz @f |
4179 | push edi |
4285 | push edi |
4180 | push 0ffffff80h |
4286 | push 0ffffff80h |
4181 | mov edi, esp |
4287 | mov edi, esp |
4182 | call put_4bit_image |
4288 | call put_4bit_image |
4183 | pop eax |
4289 | pop eax |
4184 | pop edi |
4290 | pop edi |
4185 | ret |
4291 | ret |
4186 | ;-------------------------------------- |
4292 | ;-------------------------------------- |
4187 | align 4 |
4293 | align 4 |
4188 | @@: |
4294 | @@: |
4189 | push ebp esi ebp |
4295 | push ebp esi ebp |
4190 | cmp esi, 8 |
4296 | cmp esi, 8 |
4191 | jnz @f |
4297 | jnz @f |
4192 | mov ebp, putimage_get8bpp |
4298 | mov ebp, putimage_get8bpp |
4193 | mov esi, putimage_init8bpp |
4299 | mov esi, putimage_init8bpp |
4194 | jmp sys_putimage_bpp |
4300 | jmp sys_putimage_bpp |
4195 | ;-------------------------------------- |
4301 | ;-------------------------------------- |
4196 | align 4 |
4302 | align 4 |
4197 | @@: |
4303 | @@: |
4198 | cmp esi, 9 |
4304 | cmp esi, 9 |
4199 | jnz @f |
4305 | jnz @f |
4200 | mov ebp, putimage_get9bpp |
4306 | mov ebp, putimage_get9bpp |
4201 | mov esi, putimage_init9bpp |
4307 | mov esi, putimage_init9bpp |
4202 | jmp sys_putimage_bpp |
4308 | jmp sys_putimage_bpp |
4203 | ;-------------------------------------- |
4309 | ;-------------------------------------- |
4204 | align 4 |
4310 | align 4 |
4205 | @@: |
4311 | @@: |
4206 | cmp esi, 15 |
4312 | cmp esi, 15 |
4207 | jnz @f |
4313 | jnz @f |
4208 | mov ebp, putimage_get15bpp |
4314 | mov ebp, putimage_get15bpp |
4209 | mov esi, putimage_init15bpp |
4315 | mov esi, putimage_init15bpp |
4210 | jmp sys_putimage_bpp |
4316 | jmp sys_putimage_bpp |
4211 | ;-------------------------------------- |
4317 | ;-------------------------------------- |
4212 | align 4 |
4318 | align 4 |
4213 | @@: |
4319 | @@: |
4214 | cmp esi, 16 |
4320 | cmp esi, 16 |
4215 | jnz @f |
4321 | jnz @f |
4216 | mov ebp, putimage_get16bpp |
4322 | mov ebp, putimage_get16bpp |
4217 | mov esi, putimage_init16bpp |
4323 | mov esi, putimage_init16bpp |
4218 | jmp sys_putimage_bpp |
4324 | jmp sys_putimage_bpp |
4219 | ;-------------------------------------- |
4325 | ;-------------------------------------- |
4220 | align 4 |
4326 | align 4 |
4221 | @@: |
4327 | @@: |
4222 | cmp esi, 24 |
4328 | cmp esi, 24 |
4223 | jnz @f |
4329 | jnz @f |
4224 | mov ebp, putimage_get24bpp |
4330 | mov ebp, putimage_get24bpp |
4225 | mov esi, putimage_init24bpp |
4331 | mov esi, putimage_init24bpp |
4226 | jmp sys_putimage_bpp |
4332 | jmp sys_putimage_bpp |
4227 | ;-------------------------------------- |
4333 | ;-------------------------------------- |
4228 | align 4 |
4334 | align 4 |
4229 | @@: |
4335 | @@: |
4230 | cmp esi, 32 |
4336 | cmp esi, 32 |
4231 | jnz @f |
4337 | jnz @f |
4232 | mov ebp, putimage_get32bpp |
4338 | mov ebp, putimage_get32bpp |
4233 | mov esi, putimage_init32bpp |
4339 | mov esi, putimage_init32bpp |
4234 | jmp sys_putimage_bpp |
4340 | jmp sys_putimage_bpp |
4235 | ;-------------------------------------- |
4341 | ;-------------------------------------- |
4236 | align 4 |
4342 | align 4 |
4237 | @@: |
4343 | @@: |
4238 | pop ebp esi ebp |
4344 | pop ebp esi ebp |
4239 | ret |
4345 | ret |
4240 | ;----------------------------------------------------------------------------- |
4346 | ;----------------------------------------------------------------------------- |
4241 | align 4 |
4347 | align 4 |
4242 | put_mono_image: |
4348 | put_mono_image: |
4243 | push ebp esi ebp |
4349 | push ebp esi ebp |
4244 | mov ebp, putimage_get1bpp |
4350 | mov ebp, putimage_get1bpp |
4245 | mov esi, putimage_init1bpp |
4351 | mov esi, putimage_init1bpp |
4246 | jmp sys_putimage_bpp |
4352 | jmp sys_putimage_bpp |
4247 | ;----------------------------------------------------------------------------- |
4353 | ;----------------------------------------------------------------------------- |
4248 | align 4 |
4354 | align 4 |
4249 | put_2bit_image: |
4355 | put_2bit_image: |
4250 | push ebp esi ebp |
4356 | push ebp esi ebp |
4251 | mov ebp, putimage_get2bpp |
4357 | mov ebp, putimage_get2bpp |
4252 | mov esi, putimage_init2bpp |
4358 | mov esi, putimage_init2bpp |
4253 | jmp sys_putimage_bpp |
4359 | jmp sys_putimage_bpp |
4254 | ;----------------------------------------------------------------------------- |
4360 | ;----------------------------------------------------------------------------- |
4255 | align 4 |
4361 | align 4 |
4256 | put_4bit_image: |
4362 | put_4bit_image: |
4257 | push ebp esi ebp |
4363 | push ebp esi ebp |
4258 | mov ebp, putimage_get4bpp |
4364 | mov ebp, putimage_get4bpp |
4259 | mov esi, putimage_init4bpp |
4365 | mov esi, putimage_init4bpp |
4260 | jmp sys_putimage_bpp |
4366 | jmp sys_putimage_bpp |
4261 | ;----------------------------------------------------------------------------- |
4367 | ;----------------------------------------------------------------------------- |
4262 | align 4 |
4368 | align 4 |
4263 | putimage_init24bpp: |
4369 | putimage_init24bpp: |
4264 | lea eax, [eax*3] |
4370 | lea eax, [eax*3] |
4265 | putimage_init8bpp: |
4371 | putimage_init8bpp: |
4266 | putimage_init9bpp: |
4372 | putimage_init9bpp: |
4267 | ret |
4373 | ret |
4268 | ;----------------------------------------------------------------------------- |
4374 | ;----------------------------------------------------------------------------- |
4269 | align 16 |
4375 | align 16 |
4270 | putimage_get24bpp: |
4376 | putimage_get24bpp: |
4271 | movzx eax, byte [esi+2] |
4377 | movzx eax, byte [esi+2] |
4272 | shl eax, 16 |
4378 | shl eax, 16 |
4273 | mov ax, [esi] |
4379 | mov ax, [esi] |
4274 | add esi, 3 |
4380 | add esi, 3 |
4275 | ret 4 |
4381 | ret 4 |
4276 | ;----------------------------------------------------------------------------- |
4382 | ;----------------------------------------------------------------------------- |
4277 | align 16 |
4383 | align 16 |
4278 | putimage_get8bpp: |
4384 | putimage_get8bpp: |
4279 | movzx eax, byte [esi] |
4385 | movzx eax, byte [esi] |
4280 | push edx |
4386 | push edx |
4281 | mov edx, [esp+8] |
4387 | mov edx, [esp+8] |
4282 | mov eax, [edx+eax*4] |
4388 | mov eax, [edx+eax*4] |
4283 | pop edx |
4389 | pop edx |
4284 | inc esi |
4390 | inc esi |
4285 | ret 4 |
4391 | ret 4 |
4286 | ;----------------------------------------------------------------------------- |
4392 | ;----------------------------------------------------------------------------- |
4287 | align 16 |
4393 | align 16 |
4288 | putimage_get9bpp: |
4394 | putimage_get9bpp: |
4289 | lodsb |
4395 | lodsb |
4290 | mov ah, al |
4396 | mov ah, al |
4291 | shl eax, 8 |
4397 | shl eax, 8 |
4292 | mov al, ah |
4398 | mov al, ah |
4293 | ret 4 |
4399 | ret 4 |
4294 | ;----------------------------------------------------------------------------- |
4400 | ;----------------------------------------------------------------------------- |
4295 | align 4 |
4401 | align 4 |
4296 | putimage_init1bpp: |
4402 | putimage_init1bpp: |
4297 | add eax, ecx |
4403 | add eax, ecx |
4298 | push ecx |
4404 | push ecx |
4299 | add eax, 7 |
4405 | add eax, 7 |
4300 | add ecx, 7 |
4406 | add ecx, 7 |
4301 | shr eax, 3 |
4407 | shr eax, 3 |
4302 | shr ecx, 3 |
4408 | shr ecx, 3 |
4303 | sub eax, ecx |
4409 | sub eax, ecx |
4304 | pop ecx |
4410 | pop ecx |
4305 | ret |
4411 | ret |
4306 | ;----------------------------------------------------------------------------- |
4412 | ;----------------------------------------------------------------------------- |
4307 | align 16 |
4413 | align 16 |
4308 | putimage_get1bpp: |
4414 | putimage_get1bpp: |
4309 | push edx |
4415 | push edx |
4310 | mov edx, [esp+8] |
4416 | mov edx, [esp+8] |
4311 | mov al, [edx] |
4417 | mov al, [edx] |
4312 | add al, al |
4418 | add al, al |
4313 | jnz @f |
4419 | jnz @f |
4314 | lodsb |
4420 | lodsb |
4315 | adc al, al |
4421 | adc al, al |
4316 | @@: |
4422 | @@: |
4317 | mov [edx], al |
4423 | mov [edx], al |
4318 | sbb eax, eax |
4424 | sbb eax, eax |
4319 | and eax, [edx+8] |
4425 | and eax, [edx+8] |
4320 | add eax, [edx+4] |
4426 | add eax, [edx+4] |
4321 | pop edx |
4427 | pop edx |
4322 | ret 4 |
4428 | ret 4 |
4323 | ;----------------------------------------------------------------------------- |
4429 | ;----------------------------------------------------------------------------- |
4324 | align 4 |
4430 | align 4 |
4325 | putimage_init2bpp: |
4431 | putimage_init2bpp: |
4326 | add eax, ecx |
4432 | add eax, ecx |
4327 | push ecx |
4433 | push ecx |
4328 | add ecx, 3 |
4434 | add ecx, 3 |
4329 | add eax, 3 |
4435 | add eax, 3 |
4330 | shr ecx, 2 |
4436 | shr ecx, 2 |
4331 | shr eax, 2 |
4437 | shr eax, 2 |
4332 | sub eax, ecx |
4438 | sub eax, ecx |
4333 | pop ecx |
4439 | pop ecx |
4334 | ret |
4440 | ret |
4335 | ;----------------------------------------------------------------------------- |
4441 | ;----------------------------------------------------------------------------- |
4336 | align 16 |
4442 | align 16 |
4337 | putimage_get2bpp: |
4443 | putimage_get2bpp: |
4338 | push edx |
4444 | push edx |
4339 | mov edx, [esp+8] |
4445 | mov edx, [esp+8] |
4340 | mov al, [edx] |
4446 | mov al, [edx] |
4341 | mov ah, al |
4447 | mov ah, al |
4342 | shr al, 6 |
4448 | shr al, 6 |
4343 | shl ah, 2 |
4449 | shl ah, 2 |
4344 | jnz .nonewbyte |
4450 | jnz .nonewbyte |
4345 | lodsb |
4451 | lodsb |
4346 | mov ah, al |
4452 | mov ah, al |
4347 | shr al, 6 |
4453 | shr al, 6 |
4348 | shl ah, 2 |
4454 | shl ah, 2 |
4349 | add ah, 1 |
4455 | add ah, 1 |
4350 | .nonewbyte: |
4456 | .nonewbyte: |
4351 | mov [edx], ah |
4457 | mov [edx], ah |
4352 | mov edx, [edx+4] |
4458 | mov edx, [edx+4] |
4353 | movzx eax, al |
4459 | movzx eax, al |
4354 | mov eax, [edx+eax*4] |
4460 | mov eax, [edx+eax*4] |
4355 | pop edx |
4461 | pop edx |
4356 | ret 4 |
4462 | ret 4 |
4357 | ;----------------------------------------------------------------------------- |
4463 | ;----------------------------------------------------------------------------- |
4358 | align 4 |
4464 | align 4 |
4359 | putimage_init4bpp: |
4465 | putimage_init4bpp: |
4360 | add eax, ecx |
4466 | add eax, ecx |
4361 | push ecx |
4467 | push ecx |
4362 | add ecx, 1 |
4468 | add ecx, 1 |
4363 | add eax, 1 |
4469 | add eax, 1 |
4364 | shr ecx, 1 |
4470 | shr ecx, 1 |
4365 | shr eax, 1 |
4471 | shr eax, 1 |
4366 | sub eax, ecx |
4472 | sub eax, ecx |
4367 | pop ecx |
4473 | pop ecx |
4368 | ret |
4474 | ret |
4369 | ;----------------------------------------------------------------------------- |
4475 | ;----------------------------------------------------------------------------- |
4370 | align 16 |
4476 | align 16 |
4371 | putimage_get4bpp: |
4477 | putimage_get4bpp: |
4372 | push edx |
4478 | push edx |
4373 | mov edx, [esp+8] |
4479 | mov edx, [esp+8] |
4374 | add byte [edx], 80h |
4480 | add byte [edx], 80h |
4375 | jc @f |
4481 | jc @f |
4376 | movzx eax, byte [edx+1] |
4482 | movzx eax, byte [edx+1] |
4377 | mov edx, [edx+4] |
4483 | mov edx, [edx+4] |
4378 | and eax, 0x0F |
4484 | and eax, 0x0F |
4379 | mov eax, [edx+eax*4] |
4485 | mov eax, [edx+eax*4] |
4380 | pop edx |
4486 | pop edx |
4381 | ret 4 |
4487 | ret 4 |
4382 | @@: |
4488 | @@: |
4383 | movzx eax, byte [esi] |
4489 | movzx eax, byte [esi] |
4384 | add esi, 1 |
4490 | add esi, 1 |
4385 | mov [edx+1], al |
4491 | mov [edx+1], al |
4386 | shr eax, 4 |
4492 | shr eax, 4 |
4387 | mov edx, [edx+4] |
4493 | mov edx, [edx+4] |
4388 | mov eax, [edx+eax*4] |
4494 | mov eax, [edx+eax*4] |
4389 | pop edx |
4495 | pop edx |
4390 | ret 4 |
4496 | ret 4 |
4391 | ;----------------------------------------------------------------------------- |
4497 | ;----------------------------------------------------------------------------- |
4392 | align 4 |
4498 | align 4 |
4393 | putimage_init32bpp: |
4499 | putimage_init32bpp: |
4394 | shl eax, 2 |
4500 | shl eax, 2 |
4395 | ret |
4501 | ret |
4396 | ;----------------------------------------------------------------------------- |
4502 | ;----------------------------------------------------------------------------- |
4397 | align 16 |
4503 | align 16 |
4398 | putimage_get32bpp: |
4504 | putimage_get32bpp: |
4399 | lodsd |
4505 | lodsd |
4400 | ret 4 |
4506 | ret 4 |
4401 | ;----------------------------------------------------------------------------- |
4507 | ;----------------------------------------------------------------------------- |
4402 | align 4 |
4508 | align 4 |
4403 | putimage_init15bpp: |
4509 | putimage_init15bpp: |
4404 | putimage_init16bpp: |
4510 | putimage_init16bpp: |
4405 | add eax, eax |
4511 | add eax, eax |
4406 | ret |
4512 | ret |
4407 | ;----------------------------------------------------------------------------- |
4513 | ;----------------------------------------------------------------------------- |
4408 | align 16 |
4514 | align 16 |
4409 | putimage_get15bpp: |
4515 | putimage_get15bpp: |
4410 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4516 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4411 | push ecx edx |
4517 | push ecx edx |
4412 | movzx eax, word [esi] |
4518 | movzx eax, word [esi] |
4413 | add esi, 2 |
4519 | add esi, 2 |
4414 | mov ecx, eax |
4520 | mov ecx, eax |
4415 | mov edx, eax |
4521 | mov edx, eax |
4416 | and eax, 0x1F |
4522 | and eax, 0x1F |
4417 | and ecx, 0x1F shl 5 |
4523 | and ecx, 0x1F shl 5 |
4418 | and edx, 0x1F shl 10 |
4524 | and edx, 0x1F shl 10 |
4419 | shl eax, 3 |
4525 | shl eax, 3 |
4420 | shl ecx, 6 |
4526 | shl ecx, 6 |
4421 | shl edx, 9 |
4527 | shl edx, 9 |
4422 | or eax, ecx |
4528 | or eax, ecx |
4423 | or eax, edx |
4529 | or eax, edx |
4424 | pop edx ecx |
4530 | pop edx ecx |
4425 | ret 4 |
4531 | ret 4 |
4426 | ;----------------------------------------------------------------------------- |
4532 | ;----------------------------------------------------------------------------- |
4427 | align 16 |
4533 | align 16 |
4428 | putimage_get16bpp: |
4534 | putimage_get16bpp: |
4429 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4535 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4430 | push ecx edx |
4536 | push ecx edx |
4431 | movzx eax, word [esi] |
4537 | movzx eax, word [esi] |
4432 | add esi, 2 |
4538 | add esi, 2 |
4433 | mov ecx, eax |
4539 | mov ecx, eax |
4434 | mov edx, eax |
4540 | mov edx, eax |
4435 | and eax, 0x1F |
4541 | and eax, 0x1F |
4436 | and ecx, 0x3F shl 5 |
4542 | and ecx, 0x3F shl 5 |
4437 | and edx, 0x1F shl 11 |
4543 | and edx, 0x1F shl 11 |
4438 | shl eax, 3 |
4544 | shl eax, 3 |
4439 | shl ecx, 5 |
4545 | shl ecx, 5 |
4440 | shl edx, 8 |
4546 | shl edx, 8 |
4441 | or eax, ecx |
4547 | or eax, ecx |
4442 | or eax, edx |
4548 | or eax, edx |
4443 | pop edx ecx |
4549 | pop edx ecx |
4444 | ret 4 |
4550 | ret 4 |
4445 | ;----------------------------------------------------------------------------- |
4551 | ;----------------------------------------------------------------------------- |
4446 | ;align 4 |
4552 | ;align 4 |
4447 | ; eax x beginning |
4553 | ; eax x beginning |
4448 | ; ebx y beginning |
4554 | ; ebx y beginning |
4449 | ; ecx x end |
4555 | ; ecx x end |
4450 | ; edx y end |
4556 | ; edx y end |
4451 | ; edi color |
4557 | ; edi color |
4452 | ;__sys_drawbar: |
4558 | ;__sys_drawbar: |
4453 | ; mov esi, [current_slot] |
4559 | ; mov esi, [current_slot] |
4454 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4560 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4455 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4561 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4456 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4562 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4457 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4563 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4458 | ;-------------------------------------- |
4564 | ;-------------------------------------- |
4459 | ;align 4 |
4565 | ;align 4 |
4460 | ;.forced: |
4566 | ;.forced: |
4461 | ; call vesa20_drawbar |
4567 | ; call vesa20_drawbar |
4462 | ; call [draw_pointer] |
4568 | ; call [draw_pointer] |
4463 | ; ret |
4569 | ; ret |
4464 | ;----------------------------------------------------------------------------- |
4570 | ;----------------------------------------------------------------------------- |
4465 | align 4 |
4571 | align 4 |
4466 | kb_read: |
- | |
4467 | - | ||
4468 | push ecx edx |
- | |
4469 | - | ||
4470 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
- | |
4471 | kr_loop: |
- | |
4472 | in al, 0x64 |
- | |
4473 | test al, 1 |
- | |
4474 | jnz kr_ready |
- | |
4475 | loop kr_loop |
- | |
4476 | mov ah, 1 |
- | |
4477 | jmp kr_exit |
- | |
4478 | kr_ready: |
- | |
4479 | push ecx |
- | |
4480 | mov ecx, 32 |
- | |
4481 | kr_delay: |
- | |
4482 | loop kr_delay |
- | |
4483 | pop ecx |
- | |
4484 | in al, 0x60 |
- | |
4485 | xor ah, ah |
- | |
4486 | kr_exit: |
- | |
4487 | - | ||
4488 | pop edx ecx |
- | |
4489 | - | ||
4490 | ret |
- | |
4491 | ;----------------------------------------------------------------------------- |
- | |
4492 | align 4 |
- | |
4493 | kb_write: |
4572 | kb_write_wait_ack: |
4494 | 4573 | ||
4495 | push ecx edx |
4574 | push ecx edx |
4496 | 4575 | ||
4497 | mov dl, al |
4576 | mov dl, al |
4498 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
- | |
4499 | ; kw_loop1: |
- | |
4500 | ; in al,0x64 |
- | |
4501 | ; test al,0x20 |
- | |
4502 | ; jz kw_ok1 |
- | |
4503 | ; loop kw_loop1 |
- | |
4504 | ; mov ah,1 |
- | |
4505 | ; jmp kw_exit |
- | |
4506 | ; kw_ok1: |
- | |
4507 | in al, 0x60 |
- | |
4508 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4577 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4509 | kw_loop: |
4578 | .wait_output_ready: |
4510 | in al, 0x64 |
4579 | in al, 0x64 |
4511 | test al, 2 |
4580 | test al, 2 |
4512 | jz kw_ok |
4581 | jz @f |
4513 | loop kw_loop |
4582 | loop .wait_output_ready |
4514 | mov ah, 1 |
4583 | mov ah, 1 |
4515 | jmp kw_exit |
4584 | jmp .nothing |
4516 | kw_ok: |
4585 | @@: |
4517 | mov al, dl |
4586 | mov al, dl |
4518 | out 0x60, al |
4587 | out 0x60, al |
4519 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4588 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4520 | kw_loop3: |
- | |
4521 | in al, 0x64 |
- | |
4522 | test al, 2 |
- | |
4523 | jz kw_ok3 |
- | |
4524 | loop kw_loop3 |
- | |
4525 | mov ah, 1 |
- | |
4526 | jmp kw_exit |
- | |
4527 | kw_ok3: |
4589 | .wait_ack: |
4528 | mov ah, 8 |
- | |
4529 | kw_loop4: |
- | |
4530 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
- | |
4531 | kw_loop5: |
- | |
4532 | in al, 0x64 |
4590 | in al, 0x64 |
4533 | test al, 1 |
4591 | test al, 1 |
4534 | jnz kw_ok4 |
4592 | jnz @f |
4535 | loop kw_loop5 |
4593 | loop .wait_ack |
4536 | dec ah |
4594 | mov ah, 1 |
4537 | jnz kw_loop4 |
4595 | jmp .nothing |
- | 4596 | @@: |
|
4538 | kw_ok4: |
4597 | in al, 0x60 |
4539 | xor ah, ah |
4598 | xor ah, ah |
4540 | kw_exit: |
- | |
- | 4599 | ||
4541 | 4600 | .nothing: |
|
4542 | pop edx ecx |
4601 | pop edx ecx |
4543 | 4602 | ||
4544 | ret |
4603 | ret |
4545 | ;----------------------------------------------------------------------------- |
4604 | ;----------------------------------------------------------------------------- |
4546 | align 4 |
- | |
4547 | kb_cmd: |
- | |
4548 | - | ||
4549 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
- | |
4550 | c_wait: |
- | |
4551 | in al, 0x64 |
- | |
4552 | test al, 2 |
- | |
4553 | jz c_send |
- | |
4554 | loop c_wait |
- | |
4555 | jmp c_error |
- | |
4556 | c_send: |
- | |
4557 | mov al, bl |
- | |
4558 | out 0x64, al |
- | |
4559 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
- | |
4560 | c_accept: |
- | |
4561 | in al, 0x64 |
- | |
4562 | test al, 2 |
- | |
4563 | jz c_ok |
- | |
4564 | loop c_accept |
- | |
4565 | c_error: |
- | |
4566 | mov ah, 1 |
- | |
4567 | jmp c_exit |
- | |
4568 | c_ok: |
- | |
4569 | xor ah, ah |
- | |
4570 | c_exit: |
- | |
4571 | ret |
- | |
4572 | - | ||
4573 | 4605 | ||
4574 | setmouse: ; set mousepicture -pointer |
4606 | setmouse: ; set mousepicture -pointer |
4575 | ; ps2 mouse enable |
4607 | ; ps2 mouse enable |
4576 | 4608 | ||
4577 | ; mov [MOUSE_PICTURE], dword mousepointer |
4609 | ; mov [MOUSE_PICTURE], dword mousepointer |
4578 | 4610 | ||
4579 | cli |
4611 | cli |
4580 | 4612 | ||
4581 | ret |
4613 | ret |
4582 | 4614 | ||
4583 | if used _rdtsc |
4615 | if used _rdtsc |
4584 | _rdtsc: |
4616 | _rdtsc: |
4585 | bt [cpu_caps], CAPS_TSC |
4617 | bt [cpu_caps], CAPS_TSC |
4586 | jnc ret_rdtsc |
4618 | jnc ret_rdtsc |
4587 | rdtsc |
4619 | rdtsc |
4588 | ret |
4620 | ret |
4589 | ret_rdtsc: |
4621 | ret_rdtsc: |
4590 | mov edx, 0xffffffff |
4622 | mov edx, 0xffffffff |
4591 | mov eax, 0xffffffff |
4623 | mov eax, 0xffffffff |
4592 | ret |
4624 | ret |
4593 | end if |
4625 | end if |
4594 | 4626 | ||
4595 | sys_msg_board_str: |
4627 | sys_msg_board_str: |
4596 | 4628 | ||
4597 | pushad |
4629 | pushad |
4598 | @@: |
4630 | @@: |
4599 | cmp [esi], byte 0 |
4631 | cmp [esi], byte 0 |
4600 | je @f |
4632 | je @f |
4601 | mov ebx, 1 |
4633 | mov ebx, 1 |
4602 | movzx ecx, byte [esi] |
4634 | movzx ecx, byte [esi] |
4603 | call sys_msg_board |
4635 | call sys_msg_board |
4604 | inc esi |
4636 | inc esi |
4605 | jmp @b |
4637 | jmp @b |
4606 | @@: |
4638 | @@: |
4607 | popad |
4639 | popad |
4608 | ret |
4640 | ret |
4609 | 4641 | ||
4610 | sys_msg_board_byte: |
4642 | sys_msg_board_byte: |
4611 | ; in: al = byte to display |
4643 | ; in: al = byte to display |
4612 | ; out: nothing |
4644 | ; out: nothing |
4613 | ; destroys: nothing |
4645 | ; destroys: nothing |
4614 | pushad |
4646 | pushad |
4615 | mov ecx, 2 |
4647 | mov ecx, 2 |
4616 | shl eax, 24 |
4648 | shl eax, 24 |
4617 | jmp @f |
4649 | jmp @f |
4618 | 4650 | ||
4619 | sys_msg_board_word: |
4651 | sys_msg_board_word: |
4620 | ; in: ax = word to display |
4652 | ; in: ax = word to display |
4621 | ; out: nothing |
4653 | ; out: nothing |
4622 | ; destroys: nothing |
4654 | ; destroys: nothing |
4623 | pushad |
4655 | pushad |
4624 | mov ecx, 4 |
4656 | mov ecx, 4 |
4625 | shl eax, 16 |
4657 | shl eax, 16 |
4626 | jmp @f |
4658 | jmp @f |
4627 | 4659 | ||
4628 | sys_msg_board_dword: |
4660 | sys_msg_board_dword: |
4629 | ; in: eax = dword to display |
4661 | ; in: eax = dword to display |
4630 | ; out: nothing |
4662 | ; out: nothing |
4631 | ; destroys: nothing |
4663 | ; destroys: nothing |
4632 | pushad |
4664 | pushad |
4633 | mov ecx, 8 |
4665 | mov ecx, 8 |
4634 | @@: |
4666 | @@: |
4635 | push ecx |
4667 | push ecx |
4636 | rol eax, 4 |
4668 | rol eax, 4 |
4637 | push eax |
4669 | push eax |
4638 | and al, 0xF |
4670 | and al, 0xF |
4639 | cmp al, 10 |
4671 | cmp al, 10 |
4640 | sbb al, 69h |
4672 | sbb al, 69h |
4641 | das |
4673 | das |
4642 | mov cl, al |
4674 | mov cl, al |
4643 | xor ebx, ebx |
4675 | xor ebx, ebx |
4644 | inc ebx |
4676 | inc ebx |
4645 | call sys_msg_board |
4677 | call sys_msg_board |
4646 | pop eax |
4678 | pop eax |
4647 | pop ecx |
4679 | pop ecx |
4648 | loop @b |
4680 | loop @b |
4649 | popad |
4681 | popad |
4650 | ret |
4682 | ret |
4651 | 4683 | ||
4652 | msg_board_data_size = 65536 ; Must be power of two |
4684 | msg_board_data_size = 65536 ; Must be power of two |
4653 | 4685 | ||
4654 | uglobal |
4686 | uglobal |
4655 | msg_board_data rb msg_board_data_size |
4687 | msg_board_data rb msg_board_data_size |
4656 | msg_board_count dd 0x0 |
4688 | msg_board_count dd 0x0 |
4657 | endg |
4689 | endg |
4658 | 4690 | ||
4659 | sys_msg_board: |
4691 | sys_msg_board: |
4660 | 4692 | ||
4661 | ; ebx=1 : write : bl byte to write |
4693 | ; ebx=1 : write : bl byte to write |
4662 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4694 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4663 | 4695 | ||
4664 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4696 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4665 | mov eax, ebx |
4697 | mov eax, ebx |
4666 | mov ebx, ecx |
4698 | mov ebx, ecx |
4667 | 4699 | ||
4668 | mov ecx, [msg_board_count] |
4700 | mov ecx, [msg_board_count] |
4669 | cmp eax, 1 |
4701 | cmp eax, 1 |
4670 | jne .smbl1 |
4702 | jne .smbl1 |
4671 | 4703 | ||
4672 | if defined debug_com_base |
4704 | if defined debug_com_base |
4673 | 4705 | ||
4674 | push dx ax |
4706 | push dx ax |
4675 | 4707 | ||
4676 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4708 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4677 | mov dx, debug_com_base+5 |
4709 | mov dx, debug_com_base+5 |
4678 | in al, dx |
4710 | in al, dx |
4679 | test al, 1 shl 5 |
4711 | test al, 1 shl 5 |
4680 | jz @r |
4712 | jz @r |
4681 | 4713 | ||
4682 | mov dx, debug_com_base ; Output the byte |
4714 | mov dx, debug_com_base ; Output the byte |
4683 | mov al, bl |
4715 | mov al, bl |
4684 | out dx, al |
4716 | out dx, al |
4685 | 4717 | ||
4686 | pop ax dx |
4718 | pop ax dx |
4687 | 4719 | ||
4688 | end if |
4720 | end if |
4689 | 4721 | ||
4690 | mov [msg_board_data+ecx], bl |
4722 | mov [msg_board_data+ecx], bl |
4691 | ; // if debug_direct_print == 1 |
4723 | ; // if debug_direct_print == 1 |
4692 | cmp byte [debug_direct_print], 1 |
4724 | cmp byte [debug_direct_print], 1 |
4693 | jnz @f |
4725 | jnz @f |
4694 | pusha |
4726 | pusha |
4695 | iglobal |
4727 | iglobal |
4696 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4728 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4697 | endg |
4729 | endg |
4698 | lea edx, [msg_board_data+ecx] |
4730 | lea edx, [msg_board_data+ecx] |
4699 | mov ecx, 0x40FFFFFF |
4731 | mov ecx, 0x40FFFFFF |
4700 | mov ebx, [msg_board_pos] |
4732 | mov ebx, [msg_board_pos] |
4701 | mov edi, 1 |
4733 | mov edi, 1 |
4702 | mov esi, 1 |
4734 | mov esi, 1 |
4703 | call dtext |
4735 | call dtext |
4704 | popa |
4736 | popa |
4705 | add word [msg_board_pos+2], 6 |
4737 | add word [msg_board_pos+2], 6 |
4706 | cmp bl, 10 |
4738 | cmp bl, 10 |
4707 | jnz @f |
4739 | jnz @f |
4708 | mov word [msg_board_pos+2], (42*6) |
4740 | mov word [msg_board_pos+2], (42*6) |
4709 | add word [msg_board_pos], 10 |
4741 | add word [msg_board_pos], 10 |
4710 | mov ax, word [_display.height] |
4742 | mov ax, word [Screen_Max_Y] |
4711 | cmp word [msg_board_pos], ax |
4743 | cmp word [msg_board_pos], ax |
4712 | jb @f |
4744 | jbe @f |
4713 | mov word [msg_board_pos], 10 |
4745 | mov word [msg_board_pos], 10 |
4714 | @@: |
4746 | @@: |
4715 | ; // end if |
4747 | ; // end if |
4716 | 4748 | ||
4717 | if 0 |
4749 | if 0 |
4718 | pusha |
4750 | pusha |
4719 | mov al, bl |
4751 | mov al, bl |
4720 | mov edx, 402h |
4752 | mov edx, 402h |
4721 | out dx, al |
4753 | out dx, al |
4722 | popa |
4754 | popa |
4723 | end if |
4755 | end if |
4724 | inc ecx |
4756 | inc ecx |
4725 | and ecx, msg_board_data_size - 1 |
4757 | and ecx, msg_board_data_size - 1 |
4726 | mov [msg_board_count], ecx |
4758 | mov [msg_board_count], ecx |
4727 | 4759 | ||
4728 | pop ebx eax |
4760 | pop ebx eax |
4729 | ret |
4761 | ret |
4730 | .smbl1: |
4762 | .smbl1: |
4731 | cmp eax, 2 |
4763 | cmp eax, 2 |
4732 | jne .smbl2 |
4764 | jne .smbl2 |
4733 | test ecx, ecx |
4765 | test ecx, ecx |
4734 | jz .smbl21 |
4766 | jz .smbl21 |
4735 | 4767 | ||
4736 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4768 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
4737 | mov eax, msg_board_data+1 |
4769 | mov eax, msg_board_data+1 |
4738 | mov ebx, msg_board_data |
4770 | mov ebx, msg_board_data |
4739 | movzx edx, byte [ebx] |
4771 | movzx edx, byte [ebx] |
4740 | call memmove |
4772 | call memmove |
4741 | dec [msg_board_count] |
4773 | dec [msg_board_count] |
4742 | mov [esp + 32], edx ;eax |
4774 | mov [esp + 32], edx ;eax |
4743 | mov [esp + 20], dword 1 |
4775 | mov [esp + 20], dword 1 |
4744 | ret |
4776 | ret |
4745 | .smbl21: |
4777 | .smbl21: |
4746 | mov [esp+32], ecx |
4778 | mov [esp+32], ecx |
4747 | mov [esp+20], ecx |
4779 | mov [esp+20], ecx |
4748 | .smbl2: |
4780 | .smbl2: |
4749 | pop ebx eax |
4781 | pop ebx eax |
4750 | ret |
4782 | ret |
4751 | 4783 | ||
4752 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4784 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4753 | ;; 66 sys function. ;; |
4785 | ;; 66 sys function. ;; |
4754 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4786 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4755 | ;; out eax ;; |
4787 | ;; out eax ;; |
4756 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4788 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4757 | iglobal |
4789 | iglobal |
4758 | align 4 |
4790 | align 4 |
4759 | f66call: |
4791 | f66call: |
4760 | dd sys_process_def.1 ; 1 = set keyboard mode |
4792 | dd sys_process_def.1 ; 1 = set keyboard mode |
4761 | dd sys_process_def.2 ; 2 = get keyboard mode |
4793 | dd sys_process_def.2 ; 2 = get keyboard mode |
4762 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4794 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4763 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4795 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4764 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4796 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4765 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4797 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4766 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4798 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4767 | endg |
4799 | endg |
4768 | ;----------------------------------------------------------------------------- |
4800 | ;----------------------------------------------------------------------------- |
4769 | align 4 |
4801 | align 4 |
4770 | sys_process_def: |
4802 | sys_process_def: |
4771 | dec ebx |
4803 | dec ebx |
4772 | cmp ebx, 7 |
4804 | cmp ebx, 7 |
4773 | jae .not_support ;if >=8 then or eax,-1 |
4805 | jae .not_support ;if >=8 then or eax,-1 |
4774 | 4806 | ||
4775 | mov edi, [CURRENT_TASK] |
4807 | mov edi, [CURRENT_TASK] |
4776 | jmp dword [f66call+ebx*4] |
4808 | jmp dword [f66call+ebx*4] |
4777 | 4809 | ||
4778 | .not_support: |
4810 | .not_support: |
4779 | or eax, -1 |
4811 | or eax, -1 |
4780 | ret |
4812 | ret |
4781 | ;----------------------------------------------------------------------------- |
4813 | ;----------------------------------------------------------------------------- |
4782 | align 4 |
4814 | align 4 |
4783 | .1: |
4815 | .1: |
4784 | shl edi, 8 |
4816 | shl edi, 8 |
4785 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4817 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4786 | 4818 | ||
4787 | ret |
4819 | ret |
4788 | ;----------------------------------------------------------------------------- |
4820 | ;----------------------------------------------------------------------------- |
4789 | align 4 |
4821 | align 4 |
4790 | .2: ; 2 = get keyboard mode |
4822 | .2: ; 2 = get keyboard mode |
4791 | shl edi, 8 |
4823 | shl edi, 8 |
4792 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4824 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4793 | mov [esp+32], eax |
4825 | mov [esp+32], eax |
4794 | ret |
4826 | ret |
4795 | ;----------------------------------------------------------------------------- |
4827 | ;----------------------------------------------------------------------------- |
4796 | align 4 |
4828 | align 4 |
4797 | .3: ;3 = get keyboard ctrl, alt, shift |
4829 | .3: ;3 = get keyboard ctrl, alt, shift |
4798 | mov eax, [kb_state] |
4830 | mov eax, [kb_state] |
4799 | mov [esp+32], eax |
4831 | mov [esp+32], eax |
4800 | ret |
4832 | ret |
4801 | ;----------------------------------------------------------------------------- |
4833 | ;----------------------------------------------------------------------------- |
4802 | align 4 |
4834 | align 4 |
4803 | .4: |
4835 | .4: |
4804 | mov eax, hotkey_list |
4836 | mov eax, hotkey_list |
4805 | @@: |
4837 | @@: |
4806 | cmp dword [eax+8], 0 |
4838 | cmp dword [eax+8], 0 |
4807 | jz .found_free |
4839 | jz .found_free |
4808 | add eax, 16 |
4840 | add eax, 16 |
4809 | cmp eax, hotkey_list+16*256 |
4841 | cmp eax, hotkey_list+16*256 |
4810 | jb @b |
4842 | jb @b |
4811 | mov dword [esp+32], 1 |
4843 | mov dword [esp+32], 1 |
4812 | ret |
4844 | ret |
4813 | .found_free: |
4845 | .found_free: |
4814 | mov [eax+8], edi |
4846 | mov [eax+8], edi |
4815 | mov [eax+4], edx |
4847 | mov [eax+4], edx |
4816 | movzx ecx, cl |
4848 | movzx ecx, cl |
4817 | lea ecx, [hotkey_scancodes+ecx*4] |
4849 | lea ecx, [hotkey_scancodes+ecx*4] |
4818 | mov edx, [ecx] |
4850 | mov edx, [ecx] |
4819 | mov [eax], edx |
4851 | mov [eax], edx |
4820 | mov [ecx], eax |
4852 | mov [ecx], eax |
4821 | mov [eax+12], ecx |
4853 | mov [eax+12], ecx |
4822 | test edx, edx |
4854 | test edx, edx |
4823 | jz @f |
4855 | jz @f |
4824 | mov [edx+12], eax |
4856 | mov [edx+12], eax |
4825 | @@: |
4857 | @@: |
4826 | and dword [esp+32], 0 |
4858 | and dword [esp+32], 0 |
4827 | ret |
4859 | ret |
4828 | ;----------------------------------------------------------------------------- |
4860 | ;----------------------------------------------------------------------------- |
4829 | align 4 |
4861 | align 4 |
4830 | .5: |
4862 | .5: |
4831 | movzx ebx, cl |
4863 | movzx ebx, cl |
4832 | lea ebx, [hotkey_scancodes+ebx*4] |
4864 | lea ebx, [hotkey_scancodes+ebx*4] |
4833 | mov eax, [ebx] |
4865 | mov eax, [ebx] |
4834 | .scan: |
4866 | .scan: |
4835 | test eax, eax |
4867 | test eax, eax |
4836 | jz .notfound |
4868 | jz .notfound |
4837 | cmp [eax+8], edi |
4869 | cmp [eax+8], edi |
4838 | jnz .next |
4870 | jnz .next |
4839 | cmp [eax+4], edx |
4871 | cmp [eax+4], edx |
4840 | jz .found |
4872 | jz .found |
4841 | .next: |
4873 | .next: |
4842 | mov eax, [eax] |
4874 | mov eax, [eax] |
4843 | jmp .scan |
4875 | jmp .scan |
4844 | .notfound: |
4876 | .notfound: |
4845 | mov dword [esp+32], 1 |
4877 | mov dword [esp+32], 1 |
4846 | ret |
4878 | ret |
4847 | .found: |
4879 | .found: |
4848 | mov ecx, [eax] |
4880 | mov ecx, [eax] |
4849 | jecxz @f |
4881 | jecxz @f |
4850 | mov edx, [eax+12] |
4882 | mov edx, [eax+12] |
4851 | mov [ecx+12], edx |
4883 | mov [ecx+12], edx |
4852 | @@: |
4884 | @@: |
4853 | mov ecx, [eax+12] |
4885 | mov ecx, [eax+12] |
4854 | mov edx, [eax] |
4886 | mov edx, [eax] |
4855 | mov [ecx], edx |
4887 | mov [ecx], edx |
4856 | xor edx, edx |
4888 | xor edx, edx |
4857 | mov [eax+4], edx |
4889 | mov [eax+4], edx |
4858 | mov [eax+8], edx |
4890 | mov [eax+8], edx |
4859 | mov [eax+12], edx |
4891 | mov [eax+12], edx |
4860 | mov [eax], edx |
4892 | mov [eax], edx |
4861 | mov [esp+32], edx |
4893 | mov [esp+32], edx |
4862 | ret |
4894 | ret |
4863 | ;----------------------------------------------------------------------------- |
4895 | ;----------------------------------------------------------------------------- |
4864 | align 4 |
4896 | align 4 |
4865 | .6: |
4897 | .6: |
4866 | pushfd |
4898 | pushfd |
4867 | cli |
4899 | cli |
4868 | mov eax, [PID_lock_input] |
4900 | mov eax, [PID_lock_input] |
4869 | test eax, eax |
4901 | test eax, eax |
4870 | jnz @f |
4902 | jnz @f |
4871 | ; get current PID |
4903 | ; get current PID |
4872 | mov eax, [CURRENT_TASK] |
4904 | mov eax, [CURRENT_TASK] |
4873 | shl eax, 5 |
4905 | shl eax, 5 |
4874 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4906 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4875 | ; set current PID for lock input |
4907 | ; set current PID for lock input |
4876 | mov [PID_lock_input], eax |
4908 | mov [PID_lock_input], eax |
4877 | @@: |
4909 | @@: |
4878 | popfd |
4910 | popfd |
4879 | ret |
4911 | ret |
4880 | ;----------------------------------------------------------------------------- |
4912 | ;----------------------------------------------------------------------------- |
4881 | align 4 |
4913 | align 4 |
4882 | .7: |
4914 | .7: |
4883 | mov eax, [PID_lock_input] |
4915 | mov eax, [PID_lock_input] |
4884 | test eax, eax |
4916 | test eax, eax |
4885 | jz @f |
4917 | jz @f |
4886 | ; get current PID |
4918 | ; get current PID |
4887 | mov ebx, [CURRENT_TASK] |
4919 | mov ebx, [CURRENT_TASK] |
4888 | shl ebx, 5 |
4920 | shl ebx, 5 |
4889 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4921 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
4890 | ; compare current lock input with current PID |
4922 | ; compare current lock input with current PID |
4891 | cmp ebx, eax |
4923 | cmp ebx, eax |
4892 | jne @f |
4924 | jne @f |
4893 | 4925 | ||
4894 | xor eax, eax |
4926 | xor eax, eax |
4895 | mov [PID_lock_input], eax |
4927 | mov [PID_lock_input], eax |
4896 | @@: |
4928 | @@: |
4897 | ret |
4929 | ret |
4898 | ;----------------------------------------------------------------------------- |
4930 | ;----------------------------------------------------------------------------- |
4899 | uglobal |
4931 | uglobal |
4900 | PID_lock_input dd 0x0 |
4932 | PID_lock_input dd 0x0 |
4901 | endg |
4933 | endg |
4902 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4934 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4903 | ;; 61 sys function. ;; |
4935 | ;; 61 sys function. ;; |
4904 | ;; in eax=61,ebx in [1..3] ;; |
4936 | ;; in eax=61,ebx in [1..3] ;; |
4905 | ;; out eax ;; |
4937 | ;; out eax ;; |
4906 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4938 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4907 | iglobal |
4939 | iglobal |
4908 | align 4 |
4940 | align 4 |
4909 | f61call: |
4941 | f61call: |
4910 | dd sys_gs.1 ; resolution |
4942 | dd sys_gs.1 ; resolution |
4911 | dd sys_gs.2 ; bits per pixel |
4943 | dd sys_gs.2 ; bits per pixel |
4912 | dd sys_gs.3 ; bytes per scanline |
4944 | dd sys_gs.3 ; bytes per scanline |
4913 | endg |
4945 | endg |
4914 | 4946 | ||
4915 | 4947 | ||
4916 | align 4 |
4948 | align 4 |
4917 | 4949 | ||
4918 | sys_gs: ; direct screen access |
4950 | sys_gs: ; direct screen access |
4919 | dec ebx |
4951 | dec ebx |
4920 | cmp ebx, 2 |
4952 | cmp ebx, 2 |
4921 | ja .not_support |
4953 | ja .not_support |
4922 | jmp dword [f61call+ebx*4] |
4954 | jmp dword [f61call+ebx*4] |
4923 | .not_support: |
4955 | .not_support: |
4924 | or [esp+32], dword -1 |
4956 | or [esp+32], dword -1 |
4925 | ret |
4957 | ret |
4926 | 4958 | ||
4927 | 4959 | ||
4928 | .1: ; resolution |
4960 | .1: ; resolution |
4929 | mov eax, [Screen_Max_X] |
4961 | mov eax, [Screen_Max_X] |
4930 | shl eax, 16 |
4962 | shl eax, 16 |
4931 | mov ax, word [Screen_Max_Y] |
4963 | mov ax, word [Screen_Max_Y] |
4932 | add eax, 0x00010001 |
4964 | add eax, 0x00010001 |
4933 | mov [esp+32], eax |
4965 | mov [esp+32], eax |
4934 | ret |
4966 | ret |
4935 | .2: ; bits per pixel |
4967 | .2: ; bits per pixel |
4936 | mov eax, [_display.bpp] |
4968 | mov eax, [_display.bpp] |
4937 | mov [esp+32], eax |
4969 | mov [esp+32], eax |
4938 | ret |
4970 | ret |
4939 | .3: ; bytes per scanline |
4971 | .3: ; bytes per scanline |
4940 | mov eax, [_display.pitch] |
4972 | mov eax, [_display.pitch] |
4941 | mov [esp+32], eax |
4973 | mov [esp+32], eax |
4942 | ret |
4974 | ret |
4943 | 4975 | ||
4944 | align 4 ; system functions |
4976 | align 4 ; system functions |
4945 | 4977 | ||
4946 | syscall_setpixel: ; SetPixel |
4978 | syscall_setpixel: ; SetPixel |
4947 | 4979 | ||
4948 | mov eax, ebx |
4980 | mov eax, ebx |
4949 | mov ebx, ecx |
4981 | mov ebx, ecx |
4950 | mov ecx, edx |
4982 | mov ecx, edx |
4951 | mov edx, [TASK_BASE] |
4983 | mov edx, [TASK_BASE] |
4952 | add eax, [edx-twdw+WDATA.box.left] |
4984 | add eax, [edx-twdw+WDATA.box.left] |
4953 | add ebx, [edx-twdw+WDATA.box.top] |
4985 | add ebx, [edx-twdw+WDATA.box.top] |
4954 | mov edi, [current_slot] |
4986 | mov edi, [current_slot] |
4955 | add eax, [edi+APPDATA.wnd_clientbox.left] |
4987 | add eax, [edi+APPDATA.wnd_clientbox.left] |
4956 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
4988 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
4957 | xor edi, edi ; no force |
4989 | xor edi, edi ; no force |
4958 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
4990 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
4959 | ; jmp [putpixel] |
4991 | ; jmp [putpixel] |
4960 | jmp __sys_putpixel |
4992 | jmp __sys_putpixel |
4961 | 4993 | ||
4962 | align 4 |
4994 | align 4 |
4963 | 4995 | ||
4964 | syscall_writetext: ; WriteText |
4996 | syscall_writetext: ; WriteText |
4965 | 4997 | ||
4966 | mov eax, [TASK_BASE] |
4998 | mov eax, [TASK_BASE] |
4967 | mov ebp, [eax-twdw+WDATA.box.left] |
4999 | mov ebp, [eax-twdw+WDATA.box.left] |
4968 | push esi |
5000 | push esi |
4969 | mov esi, [current_slot] |
5001 | mov esi, [current_slot] |
4970 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5002 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
4971 | shl ebp, 16 |
5003 | shl ebp, 16 |
4972 | add ebp, [eax-twdw+WDATA.box.top] |
5004 | add ebp, [eax-twdw+WDATA.box.top] |
4973 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5005 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
4974 | pop esi |
5006 | pop esi |
4975 | test ecx, 0x08000000 ; redirect the output to the user area |
5007 | test ecx, 0x08000000 ; redirect the output to the user area |
4976 | jnz @f |
5008 | jnz @f |
4977 | add ebx, ebp |
5009 | add ebx, ebp |
4978 | align 4 |
5010 | align 4 |
4979 | @@: |
5011 | @@: |
4980 | mov eax, edi |
5012 | mov eax, edi |
4981 | test ecx, 0x08000000 ; redirect the output to the user area |
5013 | test ecx, 0x08000000 ; redirect the output to the user area |
4982 | jnz dtext |
5014 | jnz dtext |
4983 | xor edi, edi |
5015 | xor edi, edi |
4984 | jmp dtext |
5016 | jmp dtext |
4985 | 5017 | ||
4986 | align 4 |
5018 | align 4 |
4987 | 5019 | ||
4988 | syscall_drawrect: ; DrawRect |
5020 | syscall_drawrect: ; DrawRect |
4989 | 5021 | ||
4990 | mov edi, edx ; color + gradient |
5022 | mov edi, edx ; color + gradient |
4991 | and edi, 0x80FFFFFF |
5023 | and edi, 0x80FFFFFF |
4992 | test bx, bx ; x.size |
5024 | test bx, bx ; x.size |
4993 | je .drectr |
5025 | je .drectr |
4994 | test cx, cx ; y.size |
5026 | test cx, cx ; y.size |
4995 | je .drectr |
5027 | je .drectr |
4996 | 5028 | ||
4997 | mov eax, ebx ; bad idea |
5029 | mov eax, ebx ; bad idea |
4998 | mov ebx, ecx |
5030 | mov ebx, ecx |
4999 | 5031 | ||
5000 | movzx ecx, ax ; ecx - x.size |
5032 | movzx ecx, ax ; ecx - x.size |
5001 | shr eax, 16 ; eax - x.coord |
5033 | shr eax, 16 ; eax - x.coord |
5002 | movzx edx, bx ; edx - y.size |
5034 | movzx edx, bx ; edx - y.size |
5003 | shr ebx, 16 ; ebx - y.coord |
5035 | shr ebx, 16 ; ebx - y.coord |
5004 | mov esi, [current_slot] |
5036 | mov esi, [current_slot] |
5005 | 5037 | ||
5006 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5038 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5007 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5039 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5008 | add ecx, eax |
5040 | add ecx, eax |
5009 | add edx, ebx |
5041 | add edx, ebx |
5010 | ; jmp [drawbar] |
5042 | ; jmp [drawbar] |
5011 | jmp vesa20_drawbar |
5043 | jmp vesa20_drawbar |
5012 | .drectr: |
5044 | .drectr: |
5013 | ret |
5045 | ret |
5014 | 5046 | ||
5015 | align 4 |
5047 | align 4 |
5016 | syscall_getscreensize: ; GetScreenSize |
5048 | syscall_getscreensize: ; GetScreenSize |
5017 | mov ax, word [Screen_Max_X] |
5049 | mov ax, word [Screen_Max_X] |
5018 | shl eax, 16 |
5050 | shl eax, 16 |
5019 | mov ax, word [Screen_Max_Y] |
5051 | mov ax, word [Screen_Max_Y] |
5020 | mov [esp + 32], eax |
5052 | mov [esp + 32], eax |
5021 | ret |
5053 | ret |
5022 | ;----------------------------------------------------------------------------- |
5054 | ;----------------------------------------------------------------------------- |
5023 | align 4 |
5055 | align 4 |
5024 | syscall_cdaudio: |
5056 | syscall_cdaudio: |
5025 | ; ECX - position of CD/DVD-drive |
5057 | ; ECX - position of CD/DVD-drive |
5026 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5058 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5027 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5059 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5028 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5060 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5029 | cmp ecx, 11 |
5061 | cmp ecx, 11 |
5030 | ja .exit |
5062 | ja .exit |
5031 | 5063 | ||
5032 | mov eax, ecx |
5064 | mov eax, ecx |
5033 | shr eax, 2 |
5065 | shr eax, 2 |
5034 | lea eax, [eax*5] |
5066 | lea eax, [eax*5] |
5035 | mov al, [eax+DRIVE_DATA+1] |
5067 | mov al, [eax+DRIVE_DATA+1] |
5036 | 5068 | ||
5037 | push ecx ebx |
5069 | push ecx ebx |
5038 | mov ebx, ecx |
5070 | mov ebx, ecx |
5039 | and ebx, 11b |
5071 | and ebx, 11b |
5040 | shl ebx, 1 |
5072 | shl ebx, 1 |
5041 | mov cl, 6 |
5073 | mov cl, 6 |
5042 | sub cl, bl |
5074 | sub cl, bl |
5043 | shr al, cl |
5075 | shr al, cl |
5044 | test al, 2 ; it's not an ATAPI device |
5076 | test al, 2 ; it's not an ATAPI device |
5045 | pop ebx ecx |
5077 | pop ebx ecx |
5046 | 5078 | ||
5047 | jz .exit |
5079 | jz .exit |
5048 | 5080 | ||
5049 | cmp ebx, 4 |
5081 | cmp ebx, 4 |
5050 | je .eject |
5082 | je .eject |
5051 | 5083 | ||
5052 | cmp ebx, 5 |
5084 | cmp ebx, 5 |
5053 | je .load |
5085 | je .load |
5054 | ;-------------------------------------- |
5086 | ;-------------------------------------- |
5055 | .exit: |
5087 | .exit: |
5056 | ret |
5088 | ret |
5057 | ;-------------------------------------- |
5089 | ;-------------------------------------- |
5058 | .load: |
5090 | .load: |
5059 | call .reserve |
5091 | call .reserve |
5060 | call LoadMedium |
5092 | call LoadMedium |
5061 | jmp .free |
5093 | jmp .free |
5062 | ;-------------------------------------- |
5094 | ;-------------------------------------- |
5063 | .eject: |
5095 | .eject: |
5064 | call .reserve |
5096 | call .reserve |
5065 | call clear_CD_cache |
5097 | call clear_CD_cache |
5066 | call allow_medium_removal |
5098 | call allow_medium_removal |
5067 | call EjectMedium |
5099 | call EjectMedium |
5068 | jmp .free |
5100 | jmp .free |
5069 | ;-------------------------------------- |
5101 | ;-------------------------------------- |
5070 | .reserve: |
5102 | .reserve: |
5071 | call reserve_cd |
5103 | call reserve_cd |
5072 | 5104 | ||
5073 | mov ebx, ecx |
5105 | mov ebx, ecx |
5074 | inc ebx |
5106 | inc ebx |
5075 | mov [cdpos], ebx |
5107 | mov [cdpos], ebx |
5076 | 5108 | ||
5077 | mov eax, ecx |
5109 | mov eax, ecx |
5078 | shr eax, 1 |
5110 | shr eax, 1 |
5079 | and eax, 1 |
5111 | and eax, 1 |
5080 | inc eax |
5112 | inc eax |
5081 | mov [ChannelNumber], ax |
5113 | mov [ChannelNumber], ax |
5082 | mov eax, ecx |
5114 | mov eax, ecx |
5083 | and eax, 1 |
5115 | and eax, 1 |
5084 | mov [DiskNumber], al |
5116 | mov [DiskNumber], al |
5085 | call reserve_cd_channel |
5117 | call reserve_cd_channel |
5086 | ret |
5118 | ret |
5087 | ;-------------------------------------- |
5119 | ;-------------------------------------- |
5088 | .free: |
5120 | .free: |
5089 | call free_cd_channel |
5121 | call free_cd_channel |
5090 | and [cd_status], 0 |
5122 | and [cd_status], 0 |
5091 | ret |
5123 | ret |
5092 | ;----------------------------------------------------------------------------- |
5124 | ;----------------------------------------------------------------------------- |
5093 | align 4 |
5125 | align 4 |
5094 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5126 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5095 | cmp ebx, [_display.width] |
5127 | cmp ebx, [Screen_Max_X] |
5096 | jb @f |
5128 | jbe @f |
5097 | cmp ecx, [_display.height] |
5129 | cmp ecx, [Screen_Max_Y] |
5098 | jb @f |
5130 | jbe @f |
5099 | xor eax, eax |
5131 | xor eax, eax |
5100 | jmp .store |
5132 | jmp .store |
5101 | ;-------------------------------------- |
5133 | ;-------------------------------------- |
5102 | align 4 |
5134 | align 4 |
5103 | @@: |
5135 | @@: |
5104 | mov eax, [d_width_calc_area + ecx*4] |
5136 | mov eax, [d_width_calc_area + ecx*4] |
5105 | add eax, [_WinMapAddress] |
5137 | add eax, [_WinMapAddress] |
5106 | movzx eax, byte[eax+ebx] ; get value for current point |
5138 | movzx eax, byte[eax+ebx] ; get value for current point |
5107 | ;-------------------------------------- |
5139 | ;-------------------------------------- |
5108 | align 4 |
5140 | align 4 |
5109 | .store: |
5141 | .store: |
5110 | mov [esp + 32], eax |
5142 | mov [esp + 32], eax |
5111 | ret |
5143 | ret |
5112 | ;----------------------------------------------------------------------------- |
5144 | ;----------------------------------------------------------------------------- |
5113 | align 4 |
5145 | align 4 |
5114 | syscall_getpixel: ; GetPixel |
5146 | syscall_getpixel: ; GetPixel |
5115 | mov ecx, [_display.width] |
5147 | mov ecx, [Screen_Max_X] |
- | 5148 | inc ecx |
|
5116 | xor edx, edx |
5149 | xor edx, edx |
5117 | mov eax, ebx |
5150 | mov eax, ebx |
5118 | div ecx |
5151 | div ecx |
5119 | mov ebx, edx |
5152 | mov ebx, edx |
5120 | xchg eax, ebx |
5153 | xchg eax, ebx |
5121 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5154 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5122 | call dword [GETPIXEL]; eax - x, ebx - y |
5155 | call dword [GETPIXEL]; eax - x, ebx - y |
5123 | mov [esp + 32], ecx |
5156 | mov [esp + 32], ecx |
5124 | ret |
5157 | ret |
5125 | ;----------------------------------------------------------------------------- |
5158 | ;----------------------------------------------------------------------------- |
5126 | align 4 |
5159 | align 4 |
5127 | syscall_getarea: |
5160 | syscall_getarea: |
5128 | ;eax = 36 |
5161 | ;eax = 36 |
5129 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5162 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5130 | ;ecx = [size x]*65536 + [size y] |
5163 | ;ecx = [size x]*65536 + [size y] |
5131 | ;edx = [start x]*65536 + [start y] |
5164 | ;edx = [start x]*65536 + [start y] |
5132 | pushad |
5165 | pushad |
5133 | mov edi, ebx |
5166 | mov edi, ebx |
5134 | mov eax, edx |
5167 | mov eax, edx |
5135 | shr eax, 16 |
5168 | shr eax, 16 |
5136 | mov ebx, edx |
5169 | mov ebx, edx |
5137 | and ebx, 0xffff |
5170 | and ebx, 0xffff |
5138 | dec eax |
5171 | dec eax |
5139 | dec ebx |
5172 | dec ebx |
5140 | ; eax - x, ebx - y |
5173 | ; eax - x, ebx - y |
5141 | mov edx, ecx |
5174 | mov edx, ecx |
5142 | 5175 | ||
5143 | shr ecx, 16 |
5176 | shr ecx, 16 |
5144 | and edx, 0xffff |
5177 | and edx, 0xffff |
5145 | mov esi, ecx |
5178 | mov esi, ecx |
5146 | ; ecx - size x, edx - size y |
5179 | ; ecx - size x, edx - size y |
5147 | 5180 | ||
5148 | mov ebp, edx |
5181 | mov ebp, edx |
5149 | dec ebp |
5182 | dec ebp |
5150 | lea ebp, [ebp*3] |
5183 | lea ebp, [ebp*3] |
5151 | 5184 | ||
5152 | imul ebp, esi |
5185 | imul ebp, esi |
5153 | 5186 | ||
5154 | mov esi, ecx |
5187 | mov esi, ecx |
5155 | dec esi |
5188 | dec esi |
5156 | lea esi, [esi*3] |
5189 | lea esi, [esi*3] |
5157 | 5190 | ||
5158 | add ebp, esi |
5191 | add ebp, esi |
5159 | add ebp, edi |
5192 | add ebp, edi |
5160 | 5193 | ||
5161 | add ebx, edx |
5194 | add ebx, edx |
5162 | ;-------------------------------------- |
5195 | ;-------------------------------------- |
5163 | align 4 |
5196 | align 4 |
5164 | .start_y: |
5197 | .start_y: |
5165 | push ecx edx |
5198 | push ecx edx |
5166 | ;-------------------------------------- |
5199 | ;-------------------------------------- |
5167 | align 4 |
5200 | align 4 |
5168 | .start_x: |
5201 | .start_x: |
5169 | push eax ebx ecx |
5202 | push eax ebx ecx |
5170 | add eax, ecx |
5203 | add eax, ecx |
5171 | 5204 | ||
5172 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5205 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5173 | call dword [GETPIXEL]; eax - x, ebx - y |
5206 | call dword [GETPIXEL]; eax - x, ebx - y |
5174 | 5207 | ||
5175 | mov [ebp], cx |
5208 | mov [ebp], cx |
5176 | shr ecx, 16 |
5209 | shr ecx, 16 |
5177 | mov [ebp+2], cl |
5210 | mov [ebp+2], cl |
5178 | 5211 | ||
5179 | pop ecx ebx eax |
5212 | pop ecx ebx eax |
5180 | sub ebp, 3 |
5213 | sub ebp, 3 |
5181 | dec ecx |
5214 | dec ecx |
5182 | jnz .start_x |
5215 | jnz .start_x |
5183 | pop edx ecx |
5216 | pop edx ecx |
5184 | dec ebx |
5217 | dec ebx |
5185 | dec edx |
5218 | dec edx |
5186 | jnz .start_y |
5219 | jnz .start_y |
5187 | popad |
5220 | popad |
5188 | ret |
5221 | ret |
5189 | ;----------------------------------------------------------------------------- |
5222 | ;----------------------------------------------------------------------------- |
5190 | align 4 |
5223 | align 4 |
5191 | syscall_putarea_backgr: |
5224 | syscall_putarea_backgr: |
5192 | ;eax = 25 |
5225 | ;eax = 25 |
5193 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5226 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5194 | ;ecx = [size x]*65536 + [size y] |
5227 | ;ecx = [size x]*65536 + [size y] |
5195 | ;edx = [start x]*65536 + [start y] |
5228 | ;edx = [start x]*65536 + [start y] |
5196 | pushad |
5229 | pushad |
5197 | mov edi, ebx |
5230 | mov edi, ebx |
5198 | mov eax, edx |
5231 | mov eax, edx |
5199 | shr eax, 16 |
5232 | shr eax, 16 |
5200 | mov ebx, edx |
5233 | mov ebx, edx |
5201 | and ebx, 0xffff |
5234 | and ebx, 0xffff |
5202 | dec eax |
5235 | dec eax |
5203 | dec ebx |
5236 | dec ebx |
5204 | ; eax - x, ebx - y |
5237 | ; eax - x, ebx - y |
5205 | mov edx, ecx |
5238 | mov edx, ecx |
5206 | shr ecx, 16 |
5239 | shr ecx, 16 |
5207 | and edx, 0xffff |
5240 | and edx, 0xffff |
5208 | mov esi, ecx |
5241 | mov esi, ecx |
5209 | ; ecx - size x, edx - size y |
5242 | ; ecx - size x, edx - size y |
5210 | mov ebp, edx |
5243 | mov ebp, edx |
5211 | dec ebp |
5244 | dec ebp |
5212 | shl ebp, 2 |
5245 | shl ebp, 2 |
5213 | 5246 | ||
5214 | imul ebp, esi |
5247 | imul ebp, esi |
5215 | 5248 | ||
5216 | mov esi, ecx |
5249 | mov esi, ecx |
5217 | dec esi |
5250 | dec esi |
5218 | shl esi, 2 |
5251 | shl esi, 2 |
5219 | 5252 | ||
5220 | add ebp, esi |
5253 | add ebp, esi |
5221 | add ebp, edi |
5254 | add ebp, edi |
5222 | 5255 | ||
5223 | add ebx, edx |
5256 | add ebx, edx |
5224 | ;-------------------------------------- |
5257 | ;-------------------------------------- |
5225 | align 4 |
5258 | align 4 |
5226 | .start_y: |
5259 | .start_y: |
5227 | push ecx edx |
5260 | push ecx edx |
5228 | ;-------------------------------------- |
5261 | ;-------------------------------------- |
5229 | align 4 |
5262 | align 4 |
5230 | .start_x: |
5263 | .start_x: |
5231 | push eax ecx |
5264 | push eax ecx |
5232 | add eax, ecx |
5265 | add eax, ecx |
5233 | 5266 | ||
5234 | mov ecx, [ebp] |
5267 | mov ecx, [ebp] |
5235 | rol ecx, 8 |
5268 | rol ecx, 8 |
5236 | test cl, cl ; transparensy = 0 |
5269 | test cl, cl ; transparensy = 0 |
5237 | jz .no_put |
5270 | jz .no_put |
5238 | 5271 | ||
5239 | xor cl, cl |
5272 | xor cl, cl |
5240 | ror ecx, 8 |
5273 | ror ecx, 8 |
5241 | 5274 | ||
5242 | pushad |
5275 | pushad |
5243 | mov edx, [d_width_calc_area + ebx*4] |
5276 | mov edx, [d_width_calc_area + ebx*4] |
5244 | add edx, [_WinMapAddress] |
5277 | add edx, [_WinMapAddress] |
5245 | movzx edx, byte [eax+edx] |
5278 | movzx edx, byte [eax+edx] |
5246 | cmp dl, byte 1 |
5279 | cmp dl, byte 1 |
5247 | jne @f |
5280 | jne @f |
5248 | 5281 | ||
5249 | call dword [PUTPIXEL]; eax - x, ebx - y |
5282 | call dword [PUTPIXEL]; eax - x, ebx - y |
5250 | ;-------------------------------------- |
5283 | ;-------------------------------------- |
5251 | align 4 |
5284 | align 4 |
5252 | @@: |
5285 | @@: |
5253 | popad |
5286 | popad |
5254 | ;-------------------------------------- |
5287 | ;-------------------------------------- |
5255 | align 4 |
5288 | align 4 |
5256 | .no_put: |
5289 | .no_put: |
5257 | pop ecx eax |
5290 | pop ecx eax |
5258 | 5291 | ||
5259 | sub ebp, 4 |
5292 | sub ebp, 4 |
5260 | dec ecx |
5293 | dec ecx |
5261 | jnz .start_x |
5294 | jnz .start_x |
5262 | 5295 | ||
5263 | pop edx ecx |
5296 | pop edx ecx |
5264 | dec ebx |
5297 | dec ebx |
5265 | dec edx |
5298 | dec edx |
5266 | jnz .start_y |
5299 | jnz .start_y |
5267 | 5300 | ||
5268 | popad |
5301 | popad |
5269 | ret |
5302 | ret |
5270 | ;----------------------------------------------------------------------------- |
5303 | ;----------------------------------------------------------------------------- |
5271 | align 4 |
5304 | align 4 |
5272 | syscall_drawline: ; DrawLine |
5305 | syscall_drawline: ; DrawLine |
5273 | 5306 | ||
5274 | mov edi, [TASK_BASE] |
5307 | mov edi, [TASK_BASE] |
5275 | movzx eax, word[edi-twdw+WDATA.box.left] |
5308 | movzx eax, word[edi-twdw+WDATA.box.left] |
5276 | mov ebp, eax |
5309 | mov ebp, eax |
5277 | mov esi, [current_slot] |
5310 | mov esi, [current_slot] |
5278 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5311 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5279 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5312 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5280 | add ebp, ebx |
5313 | add ebp, ebx |
5281 | shl eax, 16 |
5314 | shl eax, 16 |
5282 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5315 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5283 | add eax, ebp |
5316 | add eax, ebp |
5284 | mov ebp, ebx |
5317 | mov ebp, ebx |
5285 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5318 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5286 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5319 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5287 | add ebp, ecx |
5320 | add ebp, ecx |
5288 | shl ebx, 16 |
5321 | shl ebx, 16 |
5289 | xor edi, edi |
5322 | xor edi, edi |
5290 | add ebx, ebp |
5323 | add ebx, ebp |
5291 | mov ecx, edx |
5324 | mov ecx, edx |
5292 | ; jmp [draw_line] |
5325 | ; jmp [draw_line] |
5293 | jmp __sys_draw_line |
5326 | jmp __sys_draw_line |
5294 | 5327 | ||
5295 | 5328 | ||
5296 | align 4 |
5329 | align 4 |
5297 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5330 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5298 | 5331 | ||
5299 | call r_f_port_area |
5332 | call r_f_port_area |
5300 | mov [esp+32], eax |
5333 | mov [esp+32], eax |
5301 | ret |
5334 | ret |
5302 | 5335 | ||
5303 | align 4 |
5336 | align 4 |
5304 | syscall_threads: ; CreateThreads |
5337 | syscall_threads: ; CreateThreads |
5305 | ; |
5338 | ; |
5306 | ; ecx=thread entry point |
5339 | ; ecx=thread entry point |
5307 | ; edx=thread stack pointer |
5340 | ; edx=thread stack pointer |
5308 | ; |
5341 | ; |
5309 | ; on return : eax = pid |
5342 | ; on return : eax = pid |
5310 | 5343 | ||
5311 | xor ebx, ebx |
5344 | xor ebx, ebx |
5312 | call new_sys_threads |
5345 | call new_sys_threads |
5313 | 5346 | ||
5314 | mov [esp+32], eax |
5347 | mov [esp+32], eax |
5315 | ret |
5348 | ret |
5316 | 5349 | ||
5317 | align 4 |
5350 | align 4 |
5318 | 5351 | ||
5319 | paleholder: |
5352 | paleholder: |
5320 | ret |
5353 | ret |
5321 | ;------------------------------------------------------------------------------ |
5354 | ;------------------------------------------------------------------------------ |
5322 | align 4 |
5355 | align 4 |
5323 | calculate_fast_getting_offset_for_WinMapAddress: |
5356 | calculate_fast_getting_offset_for_WinMapAddress: |
5324 | ; calculate data area for fast getting offset to _WinMapAddress |
5357 | ; calculate data area for fast getting offset to _WinMapAddress |
5325 | xor eax, eax |
5358 | xor eax, eax |
5326 | mov ecx, [_display.height] |
5359 | mov ecx, [_display.height] |
5327 | mov edi, d_width_calc_area |
5360 | mov edi, d_width_calc_area |
5328 | cld |
5361 | cld |
5329 | @@: |
5362 | @@: |
5330 | stosd |
5363 | stosd |
5331 | add eax, [_display.width] |
5364 | add eax, [_display.width] |
5332 | dec ecx |
5365 | dec ecx |
5333 | jnz @r |
5366 | jnz @r |
5334 | ret |
5367 | ret |
5335 | ;------------------------------------------------------------------------------ |
5368 | ;------------------------------------------------------------------------------ |
5336 | align 4 |
5369 | align 4 |
5337 | calculate_fast_getting_offset_for_LFB: |
5370 | calculate_fast_getting_offset_for_LFB: |
5338 | ; calculate data area for fast getting offset to LFB |
5371 | ; calculate data area for fast getting offset to LFB |
5339 | xor eax, eax |
5372 | xor eax, eax |
5340 | mov ecx, [_display.height] |
5373 | mov ecx, [_display.height] |
5341 | mov edi, BPSLine_calc_area |
5374 | mov edi, BPSLine_calc_area |
5342 | cld |
5375 | cld |
5343 | @@: |
5376 | @@: |
5344 | stosd |
5377 | stosd |
5345 | add eax, [_display.pitch] |
5378 | add eax, [_display.pitch] |
5346 | dec ecx |
5379 | dec ecx |
5347 | jnz @r |
5380 | jnz @r |
5348 | ret |
5381 | ret |
5349 | ;------------------------------------------------------------------------------ |
5382 | ;------------------------------------------------------------------------------ |
5350 | align 4 |
5383 | align 4 |
5351 | set_screen: |
5384 | set_screen: |
5352 | ; in: |
5385 | ; in: |
5353 | ; eax - new Screen_Max_X |
5386 | ; eax - new Screen_Max_X |
5354 | ; ecx - new BytesPerScanLine |
5387 | ; ecx - new BytesPerScanLine |
5355 | ; edx - new Screen_Max_Y |
5388 | ; edx - new Screen_Max_Y |
5356 | 5389 | ||
5357 | pushfd |
5390 | pushfd |
5358 | cli |
5391 | cli |
5359 | 5392 | ||
5360 | mov [Screen_Max_X], eax |
5393 | mov [Screen_Max_X], eax |
5361 | mov [Screen_Max_Y], edx |
5394 | mov [Screen_Max_Y], edx |
5362 | mov [_display.pitch], ecx |
5395 | mov [_display.pitch], ecx |
5363 | 5396 | ||
5364 | mov [screen_workarea.right], eax |
5397 | mov [screen_workarea.right], eax |
5365 | mov [screen_workarea.bottom], edx |
5398 | mov [screen_workarea.bottom], edx |
5366 | 5399 | ||
5367 | push ebx |
5400 | push ebx |
5368 | push esi |
5401 | push esi |
5369 | push edi |
5402 | push edi |
5370 | 5403 | ||
5371 | pushad |
5404 | pushad |
5372 | 5405 | ||
5373 | cmp [do_not_touch_winmap], 1 |
5406 | cmp [do_not_touch_winmap], 1 |
5374 | je @f |
5407 | je @f |
5375 | 5408 | ||
5376 | stdcall kernel_free, [_WinMapAddress] |
5409 | stdcall kernel_free, [_WinMapAddress] |
5377 | 5410 | ||
5378 | mov eax, [_display.width] |
5411 | mov eax, [_display.width] |
5379 | mul [_display.height] |
5412 | mul [_display.height] |
5380 | mov [_WinMapSize], eax |
5413 | mov [_WinMapSize], eax |
5381 | 5414 | ||
5382 | stdcall kernel_alloc, eax |
5415 | stdcall kernel_alloc, eax |
5383 | mov [_WinMapAddress], eax |
5416 | mov [_WinMapAddress], eax |
5384 | test eax, eax |
5417 | test eax, eax |
5385 | jz .epic_fail |
5418 | jz .epic_fail |
5386 | ; store for f.18.24 |
5419 | ; store for f.18.24 |
5387 | mov eax, [_display.width] |
5420 | mov eax, [_display.width] |
5388 | mov [display_width_standard], eax |
5421 | mov [display_width_standard], eax |
5389 | 5422 | ||
5390 | mov eax, [_display.height] |
5423 | mov eax, [_display.height] |
5391 | mov [display_height_standard], eax |
5424 | mov [display_height_standard], eax |
5392 | @@: |
5425 | @@: |
5393 | call calculate_fast_getting_offset_for_WinMapAddress |
5426 | call calculate_fast_getting_offset_for_WinMapAddress |
5394 | ; for Qemu or non standart video cards |
5427 | ; for Qemu or non standart video cards |
5395 | ; Unfortunately [BytesPerScanLine] does not always |
5428 | ; Unfortunately [BytesPerScanLine] does not always |
5396 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5429 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5397 | call calculate_fast_getting_offset_for_LFB |
5430 | call calculate_fast_getting_offset_for_LFB |
5398 | popad |
5431 | popad |
5399 | 5432 | ||
5400 | call repos_windows |
5433 | call repos_windows |
5401 | xor eax, eax |
5434 | xor eax, eax |
5402 | xor ebx, ebx |
5435 | xor ebx, ebx |
5403 | mov ecx, [Screen_Max_X] |
5436 | mov ecx, [Screen_Max_X] |
5404 | mov edx, [Screen_Max_Y] |
5437 | mov edx, [Screen_Max_Y] |
5405 | call calculatescreen |
5438 | call calculatescreen |
5406 | pop edi |
5439 | pop edi |
5407 | pop esi |
5440 | pop esi |
5408 | pop ebx |
5441 | pop ebx |
5409 | 5442 | ||
5410 | popfd |
5443 | popfd |
5411 | ret |
5444 | ret |
5412 | 5445 | ||
5413 | .epic_fail: |
5446 | .epic_fail: |
5414 | hlt ; Houston, we've had a problem |
5447 | hlt ; Houston, we've had a problem |
5415 | 5448 | ||
5416 | ; --------------- APM --------------------- |
5449 | ; --------------- APM --------------------- |
5417 | uglobal |
5450 | uglobal |
5418 | apm_entry dp 0 |
5451 | apm_entry dp 0 |
5419 | apm_vf dd 0 |
5452 | apm_vf dd 0 |
5420 | endg |
5453 | endg |
5421 | 5454 | ||
5422 | align 4 |
5455 | align 4 |
5423 | sys_apm: |
5456 | sys_apm: |
5424 | xor eax, eax |
5457 | xor eax, eax |
5425 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5458 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5426 | jne @f |
5459 | jne @f |
5427 | inc eax |
5460 | inc eax |
5428 | or dword [esp + 44], eax ; error |
5461 | or dword [esp + 44], eax ; error |
5429 | add eax, 7 |
5462 | add eax, 7 |
5430 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5463 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5431 | ret |
5464 | ret |
5432 | 5465 | ||
5433 | @@: |
5466 | @@: |
5434 | ; xchg eax, ecx |
5467 | ; xchg eax, ecx |
5435 | ; xchg ebx, ecx |
5468 | ; xchg ebx, ecx |
5436 | 5469 | ||
5437 | cmp dx, 3 |
5470 | cmp dx, 3 |
5438 | ja @f |
5471 | ja @f |
5439 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5472 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5440 | mov eax, [apm_vf] |
5473 | mov eax, [apm_vf] |
5441 | mov [esp + 32], eax |
5474 | mov [esp + 32], eax |
5442 | shr eax, 16 |
5475 | shr eax, 16 |
5443 | mov [esp + 28], eax |
5476 | mov [esp + 28], eax |
5444 | ret |
5477 | ret |
5445 | 5478 | ||
5446 | @@: |
5479 | @@: |
5447 | 5480 | ||
5448 | mov esi, [master_tab+(OS_BASE shr 20)] |
5481 | mov esi, [master_tab+(OS_BASE shr 20)] |
5449 | xchg [master_tab], esi |
5482 | xchg [master_tab], esi |
5450 | push esi |
5483 | push esi |
5451 | mov edi, cr3 |
5484 | mov edi, cr3 |
5452 | mov cr3, edi ;flush TLB |
5485 | mov cr3, edi ;flush TLB |
5453 | 5486 | ||
5454 | call pword [apm_entry] ;call APM BIOS |
5487 | call pword [apm_entry] ;call APM BIOS |
5455 | 5488 | ||
5456 | xchg eax, [esp] |
5489 | xchg eax, [esp] |
5457 | mov [master_tab], eax |
5490 | mov [master_tab], eax |
5458 | mov eax, cr3 |
5491 | mov eax, cr3 |
5459 | mov cr3, eax |
5492 | mov cr3, eax |
5460 | pop eax |
5493 | pop eax |
5461 | 5494 | ||
5462 | mov [esp + 4 ], edi |
5495 | mov [esp + 4 ], edi |
5463 | mov [esp + 8], esi |
5496 | mov [esp + 8], esi |
5464 | mov [esp + 20], ebx |
5497 | mov [esp + 20], ebx |
5465 | mov [esp + 24], edx |
5498 | mov [esp + 24], edx |
5466 | mov [esp + 28], ecx |
5499 | mov [esp + 28], ecx |
5467 | mov [esp + 32], eax |
5500 | mov [esp + 32], eax |
5468 | setc al |
5501 | setc al |
5469 | and [esp + 44], byte 0xfe |
5502 | and [esp + 44], byte 0xfe |
5470 | or [esp + 44], al |
5503 | or [esp + 44], al |
5471 | ret |
5504 | ret |
5472 | ; ----------------------------------------- |
5505 | ; ----------------------------------------- |
5473 | 5506 | ||
5474 | align 4 |
5507 | align 4 |
5475 | 5508 | ||
5476 | undefined_syscall: ; Undefined system call |
5509 | undefined_syscall: ; Undefined system call |
5477 | mov [esp + 32], dword -1 |
5510 | mov [esp + 32], dword -1 |
5478 | ret |
5511 | ret |
5479 | 5512 | ||
5480 | align 4 |
5513 | align 4 |
5481 | system_shutdown: ; shut down the system |
5514 | system_shutdown: ; shut down the system |
5482 | 5515 | ||
5483 | cmp byte [BOOT_VARS+0x9030], 1 |
5516 | cmp byte [BOOT_VARS+0x9030], 1 |
5484 | jne @F |
5517 | jne @F |
5485 | ret |
5518 | ret |
5486 | @@: |
5519 | @@: |
5487 | call stop_all_services |
5520 | call stop_all_services |
5488 | 5521 | ||
5489 | yes_shutdown_param: |
5522 | yes_shutdown_param: |
- | 5523 | ; Shutdown other CPUs, if initialized |
|
- | 5524 | cmp [ap_initialized], 0 |
|
- | 5525 | jz .no_shutdown_cpus |
|
- | 5526 | mov edi, [LAPIC_BASE] |
|
- | 5527 | add edi, 300h |
|
- | 5528 | mov esi, smpt+4 |
|
- | 5529 | mov ebx, [cpu_count] |
|
- | 5530 | dec ebx |
|
- | 5531 | .shutdown_cpus_loop: |
|
- | 5532 | lodsd |
|
- | 5533 | push esi |
|
- | 5534 | xor esi, esi |
|
- | 5535 | inc esi |
|
- | 5536 | shl eax, 24 |
|
- | 5537 | mov [edi+10h], eax |
|
- | 5538 | ; assert INIT IPI |
|
- | 5539 | mov dword [edi], 0C500h |
|
- | 5540 | call delay_ms |
|
- | 5541 | @@: |
|
- | 5542 | test dword [edi], 1000h |
|
- | 5543 | jnz @b |
|
- | 5544 | ; deassert INIT IPI |
|
- | 5545 | mov dword [edi], 8500h |
|
- | 5546 | call delay_ms |
|
- | 5547 | @@: |
|
- | 5548 | test dword [edi], 1000h |
|
- | 5549 | jnz @b |
|
- | 5550 | ; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
|
- | 5551 | pop esi |
|
- | 5552 | dec ebx |
|
- | 5553 | jnz .shutdown_cpus_loop |
|
- | 5554 | .no_shutdown_cpus: |
|
- | 5555 | ||
5490 | cli |
5556 | cli |
5491 | 5557 | ||
5492 | if ~ defined extended_primary_loader |
5558 | if ~ defined extended_primary_loader |
5493 | ; load kernel.mnt to 0x7000:0 |
5559 | ; load kernel.mnt to 0x7000:0 |
5494 | mov ebx, kernel_file_load |
5560 | mov ebx, kernel_file_load |
5495 | pushad |
5561 | pushad |
5496 | call file_system_lfn |
5562 | call file_system_lfn |
5497 | popad |
5563 | popad |
5498 | 5564 | ||
5499 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5565 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5500 | mov edi, OS_BASE+0x40000 |
5566 | mov edi, OS_BASE+0x40000 |
5501 | mov ecx, 1000 |
5567 | mov ecx, 1000 |
5502 | rep movsb |
5568 | rep movsb |
5503 | end if |
5569 | end if |
5504 | 5570 | ||
5505 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5571 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5506 | ; mov edi, OS_BASE |
5572 | ; mov edi, OS_BASE |
5507 | ; mov ecx, 0x10000/4 |
5573 | ; mov ecx, 0x10000/4 |
5508 | ; cld |
5574 | ; cld |
5509 | ; rep movsd |
5575 | ; rep movsd |
5510 | 5576 | ||
5511 | call IRQ_mask_all |
5577 | call IRQ_mask_all |
5512 | - | ||
5513 | if 0 |
- | |
5514 | mov word [OS_BASE+0x467+0], pr_mode_exit |
- | |
5515 | mov word [OS_BASE+0x467+2], 0x1000 |
- | |
5516 | - | ||
5517 | mov al, 0x0F |
- | |
5518 | out 0x70, al |
- | |
5519 | mov al, 0x05 |
- | |
5520 | out 0x71, al |
- | |
5521 | - | ||
5522 | mov al, 0xFE |
- | |
5523 | out 0x64, al |
- | |
5524 | - | ||
5525 | hlt |
- | |
5526 | jmp $-1 |
- | |
5527 | - | ||
5528 | else |
5578 | |
5529 | cmp byte [OS_BASE + 0x9030], 2 |
5579 | cmp byte [OS_BASE + 0x9030], 2 |
5530 | jnz no_acpi_power_off |
5580 | jnz no_acpi_power_off |
5531 | 5581 | ||
5532 | ; scan for RSDP |
5582 | ; scan for RSDP |
5533 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5583 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5534 | movzx eax, word [OS_BASE + 0x40E] |
5584 | movzx eax, word [OS_BASE + 0x40E] |
5535 | shl eax, 4 |
5585 | shl eax, 4 |
5536 | jz @f |
5586 | jz @f |
5537 | mov ecx, 1024/16 |
5587 | mov ecx, 1024/16 |
5538 | call scan_rsdp |
5588 | call scan_rsdp |
5539 | jnc .rsdp_found |
5589 | jnc .rsdp_found |
5540 | @@: |
5590 | @@: |
5541 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5591 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5542 | mov eax, 0xE0000 |
5592 | mov eax, 0xE0000 |
5543 | mov ecx, 0x2000 |
5593 | mov ecx, 0x2000 |
5544 | call scan_rsdp |
5594 | call scan_rsdp |
5545 | jc no_acpi_power_off |
5595 | jc no_acpi_power_off |
5546 | .rsdp_found: |
5596 | .rsdp_found: |
5547 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5597 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5548 | mov ebp, [ipc_tmp] |
5598 | mov ebp, [ipc_tmp] |
5549 | stdcall map_page, ebp, esi, PG_MAP |
5599 | stdcall map_page, ebp, esi, PG_MAP |
5550 | lea eax, [esi+1000h] |
5600 | lea eax, [esi+1000h] |
5551 | lea edx, [ebp+1000h] |
5601 | lea edx, [ebp+1000h] |
5552 | stdcall map_page, edx, eax, PG_MAP |
5602 | stdcall map_page, edx, eax, PG_MAP |
5553 | and esi, 0xFFF |
5603 | and esi, 0xFFF |
5554 | add esi, ebp |
5604 | add esi, ebp |
5555 | cmp dword [esi], 'RSDT' |
5605 | cmp dword [esi], 'RSDT' |
5556 | jnz no_acpi_power_off |
5606 | jnz no_acpi_power_off |
5557 | mov ecx, [esi+4] |
5607 | mov ecx, [esi+4] |
5558 | sub ecx, 24h |
5608 | sub ecx, 24h |
5559 | jbe no_acpi_power_off |
5609 | jbe no_acpi_power_off |
5560 | shr ecx, 2 |
5610 | shr ecx, 2 |
5561 | add esi, 24h |
5611 | add esi, 24h |
5562 | .scan_fadt: |
5612 | .scan_fadt: |
5563 | lodsd |
5613 | lodsd |
5564 | mov ebx, eax |
5614 | mov ebx, eax |
5565 | lea eax, [ebp+2000h] |
5615 | lea eax, [ebp+2000h] |
5566 | stdcall map_page, eax, ebx, PG_MAP |
5616 | stdcall map_page, eax, ebx, PG_MAP |
5567 | lea eax, [ebp+3000h] |
5617 | lea eax, [ebp+3000h] |
5568 | add ebx, 0x1000 |
5618 | add ebx, 0x1000 |
5569 | stdcall map_page, eax, ebx, PG_MAP |
5619 | stdcall map_page, eax, ebx, PG_MAP |
5570 | and ebx, 0xFFF |
5620 | and ebx, 0xFFF |
5571 | lea ebx, [ebx+ebp+2000h] |
5621 | lea ebx, [ebx+ebp+2000h] |
5572 | cmp dword [ebx], 'FACP' |
5622 | cmp dword [ebx], 'FACP' |
5573 | jz .fadt_found |
5623 | jz .fadt_found |
5574 | loop .scan_fadt |
5624 | loop .scan_fadt |
5575 | jmp no_acpi_power_off |
5625 | jmp no_acpi_power_off |
5576 | .fadt_found: |
5626 | .fadt_found: |
5577 | ; ebx is linear address of FADT |
5627 | ; ebx is linear address of FADT |
5578 | mov edi, [ebx+40] ; physical address of the DSDT |
5628 | mov edi, [ebx+40] ; physical address of the DSDT |
5579 | lea eax, [ebp+4000h] |
5629 | lea eax, [ebp+4000h] |
5580 | stdcall map_page, eax, edi, PG_MAP |
5630 | stdcall map_page, eax, edi, PG_MAP |
5581 | lea eax, [ebp+5000h] |
5631 | lea eax, [ebp+5000h] |
5582 | lea esi, [edi+0x1000] |
5632 | lea esi, [edi+0x1000] |
5583 | stdcall map_page, eax, esi, PG_MAP |
5633 | stdcall map_page, eax, esi, PG_MAP |
5584 | and esi, 0xFFF |
5634 | and esi, 0xFFF |
5585 | sub edi, esi |
5635 | sub edi, esi |
5586 | cmp dword [esi+ebp+4000h], 'DSDT' |
5636 | cmp dword [esi+ebp+4000h], 'DSDT' |
5587 | jnz no_acpi_power_off |
5637 | jnz no_acpi_power_off |
5588 | mov eax, [esi+ebp+4004h] ; DSDT length |
5638 | mov eax, [esi+ebp+4004h] ; DSDT length |
5589 | sub eax, 36+4 |
5639 | sub eax, 36+4 |
5590 | jbe no_acpi_power_off |
5640 | jbe no_acpi_power_off |
5591 | add esi, 36 |
5641 | add esi, 36 |
5592 | .scan_dsdt: |
5642 | .scan_dsdt: |
5593 | cmp dword [esi+ebp+4000h], '_S5_' |
5643 | cmp dword [esi+ebp+4000h], '_S5_' |
5594 | jnz .scan_dsdt_cont |
5644 | jnz .scan_dsdt_cont |
5595 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5645 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5596 | jnz .scan_dsdt_cont |
5646 | jnz .scan_dsdt_cont |
5597 | mov dl, [esi+ebp+4000h+6] |
5647 | mov dl, [esi+ebp+4000h+6] |
5598 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5648 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5599 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5649 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5600 | ja .scan_dsdt_cont |
5650 | ja .scan_dsdt_cont |
5601 | cmp dl, 1 |
5651 | cmp dl, 1 |
5602 | jb .scan_dsdt_cont |
5652 | jb .scan_dsdt_cont |
5603 | lea esi, [esi+ebp+4000h+7] |
5653 | lea esi, [esi+ebp+4000h+7] |
5604 | xor ecx, ecx |
5654 | xor ecx, ecx |
5605 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5655 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5606 | jz @f |
5656 | jz @f |
5607 | cmp byte [esi], 0xA |
5657 | cmp byte [esi], 0xA |
5608 | jnz no_acpi_power_off |
5658 | jnz no_acpi_power_off |
5609 | inc esi |
5659 | inc esi |
5610 | mov cl, [esi] |
5660 | mov cl, [esi] |
5611 | @@: |
5661 | @@: |
5612 | inc esi |
5662 | inc esi |
5613 | cmp dl, 2 |
5663 | cmp dl, 2 |
5614 | jb @f |
5664 | jb @f |
5615 | cmp byte [esi], 0 |
5665 | cmp byte [esi], 0 |
5616 | jz @f |
5666 | jz @f |
5617 | cmp byte [esi], 0xA |
5667 | cmp byte [esi], 0xA |
5618 | jnz no_acpi_power_off |
5668 | jnz no_acpi_power_off |
5619 | inc esi |
5669 | inc esi |
5620 | mov ch, [esi] |
5670 | mov ch, [esi] |
5621 | @@: |
5671 | @@: |
5622 | jmp do_acpi_power_off |
5672 | jmp do_acpi_power_off |
5623 | .scan_dsdt_cont: |
5673 | .scan_dsdt_cont: |
5624 | inc esi |
5674 | inc esi |
5625 | cmp esi, 0x1000 |
5675 | cmp esi, 0x1000 |
5626 | jb @f |
5676 | jb @f |
5627 | sub esi, 0x1000 |
5677 | sub esi, 0x1000 |
5628 | add edi, 0x1000 |
5678 | add edi, 0x1000 |
5629 | push eax |
5679 | push eax |
5630 | lea eax, [ebp+4000h] |
5680 | lea eax, [ebp+4000h] |
5631 | stdcall map_page, eax, edi, PG_MAP |
5681 | stdcall map_page, eax, edi, PG_MAP |
5632 | push PG_MAP |
5682 | push PG_MAP |
5633 | lea eax, [edi+1000h] |
5683 | lea eax, [edi+1000h] |
5634 | push eax |
5684 | push eax |
5635 | lea eax, [ebp+5000h] |
5685 | lea eax, [ebp+5000h] |
5636 | push eax |
5686 | push eax |
5637 | stdcall map_page |
5687 | stdcall map_page |
5638 | pop eax |
5688 | pop eax |
5639 | @@: |
5689 | @@: |
5640 | dec eax |
5690 | dec eax |
5641 | jnz .scan_dsdt |
5691 | jnz .scan_dsdt |
5642 | jmp no_acpi_power_off |
5692 | jmp no_acpi_power_off |
5643 | do_acpi_power_off: |
5693 | do_acpi_power_off: |
5644 | mov edx, [ebx+48] |
5694 | mov edx, [ebx+48] |
5645 | test edx, edx |
5695 | test edx, edx |
5646 | jz .nosmi |
5696 | jz .nosmi |
5647 | mov al, [ebx+52] |
5697 | mov al, [ebx+52] |
5648 | out dx, al |
5698 | out dx, al |
5649 | mov edx, [ebx+64] |
5699 | mov edx, [ebx+64] |
5650 | @@: |
5700 | @@: |
5651 | in ax, dx |
5701 | in ax, dx |
5652 | test al, 1 |
5702 | test al, 1 |
5653 | jz @b |
5703 | jz @b |
5654 | .nosmi: |
5704 | .nosmi: |
5655 | and cx, 0x0707 |
5705 | and cx, 0x0707 |
5656 | shl cx, 2 |
5706 | shl cx, 2 |
5657 | or cx, 0x2020 |
5707 | or cx, 0x2020 |
5658 | mov edx, [ebx+64] |
5708 | mov edx, [ebx+64] |
5659 | in ax, dx |
5709 | in ax, dx |
5660 | and ax, 203h |
5710 | and ax, 203h |
5661 | or ah, cl |
5711 | or ah, cl |
5662 | out dx, ax |
5712 | out dx, ax |
5663 | mov edx, [ebx+68] |
5713 | mov edx, [ebx+68] |
5664 | test edx, edx |
5714 | test edx, edx |
5665 | jz @f |
5715 | jz @f |
5666 | in ax, dx |
5716 | in ax, dx |
5667 | and ax, 203h |
5717 | and ax, 203h |
5668 | or ah, ch |
5718 | or ah, ch |
5669 | out dx, ax |
5719 | out dx, ax |
5670 | @@: |
5720 | @@: |
5671 | jmp $ |
5721 | jmp $ |
5672 | 5722 | ||
5673 | - | ||
5674 | no_acpi_power_off: |
- | |
5675 | mov word [OS_BASE+0x467+0], pr_mode_exit |
- | |
5676 | mov word [OS_BASE+0x467+2], 0x1000 |
- | |
5677 | - | ||
5678 | mov al, 0x0F |
- | |
5679 | out 0x70, al |
- | |
5680 | mov al, 0x05 |
- | |
5681 | out 0x71, al |
- | |
5682 | - | ||
5683 | mov al, 0xFE |
- | |
5684 | out 0x64, al |
- | |
5685 | - | ||
5686 | hlt |
- | |
5687 | jmp $-1 |
- | |
5688 | 5723 | ||
5689 | scan_rsdp: |
5724 | scan_rsdp: |
5690 | add eax, OS_BASE |
5725 | add eax, OS_BASE |
5691 | .s: |
5726 | .s: |
5692 | cmp dword [eax], 'RSD ' |
5727 | cmp dword [eax], 'RSD ' |
5693 | jnz .n |
5728 | jnz .n |
5694 | cmp dword [eax+4], 'PTR ' |
5729 | cmp dword [eax+4], 'PTR ' |
5695 | jnz .n |
5730 | jnz .n |
5696 | xor edx, edx |
5731 | xor edx, edx |
5697 | xor esi, esi |
5732 | xor esi, esi |
5698 | @@: |
5733 | @@: |
5699 | add dl, [eax+esi] |
5734 | add dl, [eax+esi] |
5700 | inc esi |
5735 | inc esi |
5701 | cmp esi, 20 |
5736 | cmp esi, 20 |
5702 | jnz @b |
5737 | jnz @b |
5703 | test dl, dl |
5738 | test dl, dl |
5704 | jz .ok |
5739 | jz .ok |
5705 | .n: |
5740 | .n: |
5706 | add eax, 10h |
5741 | add eax, 10h |
5707 | loop .s |
5742 | loop .s |
5708 | stc |
5743 | stc |
5709 | .ok: |
5744 | .ok: |
5710 | ret |
5745 | ret |
- | 5746 | ||
- | 5747 | no_acpi_power_off: |
|
- | 5748 | call create_trampoline_pgmap |
|
- | 5749 | mov cr3, eax |
|
- | 5750 | jmp become_real+0x10000 |
|
- | 5751 | iglobal |
|
- | 5752 | align 4 |
|
- | 5753 | realmode_gdt: |
|
- | 5754 | ; selector 0 - not used |
|
- | 5755 | dw 23 |
|
- | 5756 | dd realmode_gdt-OS_BASE |
|
- | 5757 | dw 0 |
|
- | 5758 | ; selector 8 - code from 1000:0000 to 1000:FFFF |
|
- | 5759 | dw 0FFFFh |
|
- | 5760 | dw 0 |
|
- | 5761 | db 1 |
|
- | 5762 | db 10011011b |
|
- | 5763 | db 00000000b |
|
- | 5764 | db 0 |
|
- | 5765 | ; selector 10h - data from 1000:0000 to 1000:FFFF |
|
- | 5766 | dw 0FFFFh |
|
- | 5767 | dw 0 |
|
- | 5768 | db 1 |
|
- | 5769 | db 10010011b |
|
- | 5770 | db 00000000b |
|
- | 5771 | db 0 |
|
5711 | end if |
5772 | endg |
5712 | 5773 | ||
5713 | if ~ lang eq sp |
5774 | if ~ lang eq sp |
5714 | diff16 "end of .text segment",0,$ |
5775 | diff16 "end of .text segment",0,$ |
5715 | end if |
5776 | end if |
5716 | 5777 | ||
5717 | include "data32.inc" |
5778 | include "data32.inc" |
5718 | 5779 | ||
5719 | __REV__ = __REV |
5780 | __REV__ = __REV |
5720 | 5781 | ||
5721 | if ~ lang eq sp |
5782 | if ~ lang eq sp |
5722 | diff16 "end of kernel code",0,$ |
5783 | diff16 "end of kernel code",0,$ |
5723 | end if=> |
5784 | end if=> |