Rev 9969 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9969 | Rev 10002 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. |
4 | ;; Kernel programmers are acknowledged in CREDITS.TXT |
4 | ;; Kernel programmers are acknowledged in CREDITS.TXT |
5 | ;; |
5 | ;; |
6 | ;; Data in this file was originally part of MenuetOS project which is |
6 | ;; Data in this file was originally part of MenuetOS project which is |
7 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
7 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
8 | ;; part of KolibriOS project under the terms of GNU GPL. |
8 | ;; part of KolibriOS project under the terms of GNU GPL. |
9 | ;; |
9 | ;; |
10 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
10 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
11 | ;; |
11 | ;; |
12 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
12 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
13 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
13 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
14 | ;; consequences of using it or for whether it serves any particular purpose or |
14 | ;; consequences of using it or for whether it serves any particular purpose or |
15 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
15 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
16 | ;; License (the "GPL") for full details. |
16 | ;; License (the "GPL") for full details. |
17 | ; |
17 | ; |
18 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
18 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
19 | ;; but only under the conditions described in the GPL. A copy of this license |
19 | ;; but only under the conditions described in the GPL. A copy of this license |
20 | ;; is supposed to have been given to you along with KolibriOS so you can know |
20 | ;; is supposed to have been given to you along with KolibriOS so you can know |
21 | ;; your rights and responsibilities. It should be in a file named COPYING. |
21 | ;; your rights and responsibilities. It should be in a file named COPYING. |
22 | ;; Among other things, the copyright notice and this notice must be preserved |
22 | ;; Among other things, the copyright notice and this notice must be preserved |
23 | ;; on all copies. |
23 | ;; on all copies. |
24 | ;; |
24 | ;; |
25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
25 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
26 | 26 | ||
27 | format binary as "mnt" |
27 | format binary as "mnt" |
28 | 28 | ||
29 | include 'macros.inc' |
29 | include 'macros.inc' |
30 | include 'struct.inc' |
30 | include 'struct.inc' |
31 | 31 | ||
32 | $Revision: 9969 $ |
32 | $Revision: 10002 $ |
33 | 33 | ||
34 | 34 | ||
35 | USE_COM_IRQ = 1 ; make irq 3 and irq 4 available for PCI devices |
35 | USE_COM_IRQ = 1 ; make irq 3 and irq 4 available for PCI devices |
36 | VESA_1_2_VIDEO = 0 ; enable vesa 1.2 bank switch functions |
36 | VESA_1_2_VIDEO = 0 ; enable vesa 1.2 bank switch functions |
37 | 37 | ||
38 | ; Enabling the next line will enable serial output console |
38 | ; Enabling the next line will enable serial output console |
39 | ;debug_com_base = 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, |
39 | ;debug_com_base = 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, |
40 | ; 0x2e8 is com4, no irq's are used |
40 | ; 0x2e8 is com4, no irq's are used |
41 | 41 | ||
42 | include "proc32.inc" |
42 | include "proc32.inc" |
43 | include "kglobals.inc" |
43 | include "kglobals.inc" |
44 | include "lang.inc" |
44 | include "lang.inc" |
45 | include "encoding.inc" |
45 | include "encoding.inc" |
46 | 46 | ||
47 | include "const.inc" |
47 | include "const.inc" |
48 | 48 | ||
49 | iglobal |
49 | iglobal |
50 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
50 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
51 | debug_direct_print db 0 |
51 | debug_direct_print db 0 |
52 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
52 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
53 | launcher_start db 1 |
53 | launcher_start db 1 |
54 | endg |
54 | endg |
55 | 55 | ||
56 | max_processes = 255 |
56 | max_processes = 255 |
57 | tss_step = 128 + 8192 ; tss & i/o - 65535 ports, * 256=557056*4 |
57 | tss_step = 128 + 8192 ; tss & i/o - 65535 ports, * 256=557056*4 |
58 | 58 | ||
59 | os_stack = os_data_l - gdts ; GDTs |
59 | os_stack = os_data_l - gdts ; GDTs |
60 | os_code = os_code_l - gdts |
60 | os_code = os_code_l - gdts |
61 | graph_data = 3 + graph_data_l - gdts |
61 | graph_data = 3 + graph_data_l - gdts |
62 | tss0 = tss0_l - gdts |
62 | tss0 = tss0_l - gdts |
63 | app_code = 3 + app_code_l - gdts |
63 | app_code = 3 + app_code_l - gdts |
64 | app_data = 3 + app_data_l - gdts |
64 | app_data = 3 + app_data_l - gdts |
65 | app_tls = 3 + tls_data_l - gdts |
65 | app_tls = 3 + tls_data_l - gdts |
66 | pci_code_sel = pci_code_32-gdts |
66 | pci_code_sel = pci_code_32-gdts |
67 | pci_data_sel = pci_data_32-gdts |
67 | pci_data_sel = pci_data_32-gdts |
68 | 68 | ||
69 | 69 | ||
70 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
70 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
71 | ;; |
71 | ;; |
72 | ;; Included files: |
72 | ;; Included files: |
73 | ;; |
73 | ;; |
74 | ;; Kernel16.inc |
74 | ;; Kernel16.inc |
75 | ;; - Booteng.inc English text for bootup |
75 | ;; - Booteng.inc English text for bootup |
76 | ;; - Bootcode.inc Hardware setup |
76 | ;; - Bootcode.inc Hardware setup |
77 | ;; - Pci16.inc PCI functions |
77 | ;; - Pci16.inc PCI functions |
78 | ;; |
78 | ;; |
79 | ;; Kernel32.inc |
79 | ;; Kernel32.inc |
80 | ;; - Sys32.inc Process management |
80 | ;; - Sys32.inc Process management |
81 | ;; - Shutdown.inc Shutdown and restart |
81 | ;; - Shutdown.inc Shutdown and restart |
82 | ;; - Fat32.inc Read / write hd |
82 | ;; - Fat32.inc Read / write hd |
83 | ;; - Vesa12.inc Vesa 1.2 driver |
83 | ;; - Vesa12.inc Vesa 1.2 driver |
84 | ;; - Vesa20.inc Vesa 2.0 driver |
84 | ;; - Vesa20.inc Vesa 2.0 driver |
85 | ;; - Vga.inc VGA driver |
85 | ;; - Vga.inc VGA driver |
86 | ;; - Stack.inc Network interface |
86 | ;; - Stack.inc Network interface |
87 | ;; - Mouse.inc Mouse pointer |
87 | ;; - Mouse.inc Mouse pointer |
88 | ;; - Scincode.inc Window skinning |
88 | ;; - Scincode.inc Window skinning |
89 | ;; - Pci32.inc PCI functions |
89 | ;; - Pci32.inc PCI functions |
90 | ;; |
90 | ;; |
91 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
91 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
92 | 92 | ||
93 | ; That is a loading and initialization code that also draws the blue screen |
93 | ; That is a loading and initialization code that also draws the blue screen |
94 | ; menu with svn revision number near top right corner of the screen. |
94 | ; menu with svn revision number near top right corner of the screen. |
95 | include "bootbios.inc" |
95 | include "bootbios.inc" |
96 | 96 | ||
97 | use32 |
97 | use32 |
98 | org $+KERNEL_BASE |
98 | org $+KERNEL_BASE |
99 | 99 | ||
100 | align 4 |
100 | align 4 |
101 | B32: |
101 | B32: |
102 | mov ax, os_stack ; Selector for os |
102 | mov ax, os_stack ; Selector for os |
103 | mov ds, ax |
103 | mov ds, ax |
104 | mov es, ax |
104 | mov es, ax |
105 | mov fs, ax |
105 | mov fs, ax |
106 | mov gs, ax |
106 | mov gs, ax |
107 | mov ss, ax |
107 | mov ss, ax |
108 | mov esp, TMP_STACK_TOP ; Set stack |
108 | mov esp, TMP_STACK_TOP ; Set stack |
109 | 109 | ||
110 | ; CLEAR 0x280000 - HEAP_BASE |
110 | ; CLEAR 0x280000 - HEAP_BASE |
111 | 111 | ||
112 | xor eax, eax |
112 | xor eax, eax |
113 | mov edi, CLEAN_ZONE |
113 | mov edi, CLEAN_ZONE |
114 | mov ecx, (HEAP_BASE - OS_BASE - CLEAN_ZONE) / 4 |
114 | mov ecx, (HEAP_BASE - OS_BASE - CLEAN_ZONE) / 4 |
115 | cld |
115 | cld |
116 | rep stosd |
116 | rep stosd |
117 | 117 | ||
118 | ; Clear kernel undefined globals and some more (what exactly?) |
118 | ; Clear kernel undefined globals and some more (what exactly?) |
119 | mov edi, endofcode - OS_BASE |
119 | mov edi, endofcode - OS_BASE |
120 | mov ecx, 0x90000 ; why uglobals_size isn't enough? |
120 | mov ecx, 0x90000 ; why uglobals_size isn't enough? |
121 | sub ecx, edi |
121 | sub ecx, edi |
122 | shr ecx, 2 |
122 | shr ecx, 2 |
123 | rep stosd |
123 | rep stosd |
124 | 124 | ||
125 | ; SAVE & CLEAR 0-0xffff |
125 | ; SAVE & CLEAR 0-0xffff |
126 | 126 | ||
127 | mov edi, 0x1000 |
127 | mov edi, 0x1000 |
128 | mov ecx, 0x8000 / 4 |
128 | mov ecx, 0x8000 / 4 |
129 | rep stosd |
129 | rep stosd |
130 | mov edi, 0xa000 |
130 | mov edi, 0xa000 |
131 | mov ecx, 0x6000 / 4 |
131 | mov ecx, 0x6000 / 4 |
132 | rep stosd |
132 | rep stosd |
133 | 133 | ||
134 | call test_cpu |
134 | call test_cpu |
135 | bts [cpu_caps - OS_BASE], CAPS_TSC ;force use rdtsc |
135 | bts [cpu_caps - OS_BASE], CAPS_TSC ;force use rdtsc |
136 | 136 | ||
137 | call acpi_locate |
137 | call acpi_locate |
138 | call init_BIOS32 |
138 | call init_BIOS32 |
139 | ; MEMORY MODEL |
139 | ; MEMORY MODEL |
140 | call mem_test |
140 | call mem_test |
141 | call init_mem |
141 | call init_mem |
142 | call init_page_map |
142 | call init_page_map |
143 | 143 | ||
144 | ; ENABLE PAGING |
144 | ; ENABLE PAGING |
145 | 145 | ||
146 | mov eax, sys_proc - OS_BASE + PROC.pdt_0 |
146 | mov eax, sys_proc - OS_BASE + PROC.pdt_0 |
147 | mov cr3, eax |
147 | mov cr3, eax |
148 | 148 | ||
149 | mov eax, cr0 |
149 | mov eax, cr0 |
150 | or eax, CR0_PG + CR0_WP |
150 | or eax, CR0_PG + CR0_WP |
151 | mov cr0, eax |
151 | mov cr0, eax |
152 | 152 | ||
153 | lgdt [gdts] |
153 | lgdt [gdts] |
154 | jmp pword os_code:high_code |
154 | jmp pword os_code:high_code |
155 | 155 | ||
156 | align 4 |
156 | align 4 |
157 | bios32_entry dd ? |
157 | bios32_entry dd ? |
158 | tmp_page_tabs dd ? |
158 | tmp_page_tabs dd ? |
159 | use16 |
159 | use16 |
160 | ap_init16: |
160 | ap_init16: |
161 | cli |
161 | cli |
162 | lgdt [cs:gdts_ap - ap_init16] |
162 | lgdt [cs:gdts_ap - ap_init16] |
163 | mov eax, [cs:cr3_ap - ap_init16] |
163 | mov eax, [cs:cr3_ap - ap_init16] |
164 | mov cr3, eax |
164 | mov cr3, eax |
165 | mov eax, [cs:cr4_ap - ap_init16] |
165 | mov eax, [cs:cr4_ap - ap_init16] |
166 | mov cr4, eax |
166 | mov cr4, eax |
167 | mov eax, CR0_PE + CR0_PG + CR0_WP |
167 | mov eax, CR0_PE + CR0_PG + CR0_WP |
168 | mov cr0, eax |
168 | mov cr0, eax |
169 | jmp pword os_code:ap_init_high |
169 | jmp pword os_code:ap_init_high |
170 | align 16 |
170 | align 16 |
171 | gdts_ap: |
171 | gdts_ap: |
172 | dw gdte-gdts-1 |
172 | dw gdte-gdts-1 |
173 | dd gdts |
173 | dd gdts |
174 | dw 0 |
174 | dw 0 |
175 | cr3_ap dd ? |
175 | cr3_ap dd ? |
176 | cr4_ap dd ? |
176 | cr4_ap dd ? |
177 | ap_init16_size = $ - ap_init16 |
177 | ap_init16_size = $ - ap_init16 |
178 | use32 |
178 | use32 |
179 | 179 | ||
180 | __DEBUG__ fix 1 |
180 | __DEBUG__ fix 1 |
181 | __DEBUG_LEVEL__ fix 1 |
181 | __DEBUG_LEVEL__ fix 1 |
182 | include 'init.inc' |
182 | include 'init.inc' |
183 | 183 | ||
184 | org OS_BASE+$ |
184 | org OS_BASE+$ |
185 | 185 | ||
186 | include 'fdo.inc' |
186 | include 'fdo.inc' |
187 | 187 | ||
188 | align 4 |
188 | align 4 |
189 | high_code: |
189 | high_code: |
190 | mov ax, os_stack |
190 | mov ax, os_stack |
191 | mov bx, app_data |
191 | mov bx, app_data |
192 | mov cx, app_tls |
192 | mov cx, app_tls |
193 | mov ss, ax |
193 | mov ss, ax |
194 | add esp, OS_BASE |
194 | add esp, OS_BASE |
195 | 195 | ||
196 | mov ds, bx |
196 | mov ds, bx |
197 | mov es, bx |
197 | mov es, bx |
198 | mov fs, cx |
198 | mov fs, cx |
199 | mov gs, bx |
199 | mov gs, bx |
200 | 200 | ||
201 | xor eax, eax |
201 | xor eax, eax |
202 | mov ebx, 0xFFFFF000 + PG_SHARED + PG_NOCACHE + PG_UWR |
202 | mov ebx, 0xFFFFF000 + PG_SHARED + PG_NOCACHE + PG_UWR |
203 | bt [cpu_caps], CAPS_PAT |
203 | bt [cpu_caps], CAPS_PAT |
204 | setc al |
204 | setc al |
205 | shl eax, 7 |
205 | shl eax, 7 |
206 | or ebx, eax |
206 | or ebx, eax |
207 | 207 | ||
208 | mov eax, PG_GLOBAL |
208 | mov eax, PG_GLOBAL |
209 | bt [cpu_caps], CAPS_PGE |
209 | bt [cpu_caps], CAPS_PGE |
210 | jnc @F |
210 | jnc @F |
211 | 211 | ||
212 | or [sys_proc + PROC.pdt_0 + (OS_BASE shr 20)], eax |
212 | or [sys_proc + PROC.pdt_0 + (OS_BASE shr 20)], eax |
213 | or ebx, eax |
213 | or ebx, eax |
214 | 214 | ||
215 | mov eax, cr4 |
215 | mov eax, cr4 |
216 | or eax, CR4_PGE |
216 | or eax, CR4_PGE |
217 | mov cr4, eax |
217 | mov cr4, eax |
218 | @@: |
218 | @@: |
219 | mov [pte_valid_mask], ebx |
219 | mov [pte_valid_mask], ebx |
220 | 220 | ||
221 | xor eax, eax |
221 | xor eax, eax |
222 | mov [sys_proc + PROC.pdt_0], eax |
222 | mov [sys_proc + PROC.pdt_0], eax |
223 | mov [sys_proc + PROC.pdt_0+4], eax |
223 | mov [sys_proc + PROC.pdt_0+4], eax |
224 | 224 | ||
225 | mov eax, cr3 |
225 | mov eax, cr3 |
226 | mov cr3, eax ; flush TLB |
226 | mov cr3, eax ; flush TLB |
227 | 227 | ||
228 | mov ecx, pg_data.mutex |
228 | mov ecx, pg_data.mutex |
229 | call mutex_init |
229 | call mutex_init |
230 | 230 | ||
231 | mov ecx, disk_list_mutex |
231 | mov ecx, disk_list_mutex |
232 | call mutex_init |
232 | call mutex_init |
233 | 233 | ||
234 | mov ecx, keyboard_list_mutex |
234 | mov ecx, keyboard_list_mutex |
235 | call mutex_init |
235 | call mutex_init |
236 | 236 | ||
237 | mov ecx, unpack_mutex |
237 | mov ecx, unpack_mutex |
238 | call mutex_init |
238 | call mutex_init |
239 | 239 | ||
240 | mov ecx, application_table_mutex |
240 | mov ecx, application_table_mutex |
241 | call mutex_init |
241 | call mutex_init |
242 | 242 | ||
243 | mov ecx, ide_mutex |
243 | mov ecx, ide_mutex |
244 | call mutex_init |
244 | call mutex_init |
245 | mov ecx, ide_channel1_mutex |
245 | mov ecx, ide_channel1_mutex |
246 | call mutex_init |
246 | call mutex_init |
247 | mov ecx, ide_channel2_mutex |
247 | mov ecx, ide_channel2_mutex |
248 | call mutex_init |
248 | call mutex_init |
249 | mov ecx, ide_channel3_mutex |
249 | mov ecx, ide_channel3_mutex |
250 | call mutex_init |
250 | call mutex_init |
251 | mov ecx, ide_channel4_mutex |
251 | mov ecx, ide_channel4_mutex |
252 | call mutex_init |
252 | call mutex_init |
253 | mov ecx, ide_channel5_mutex |
253 | mov ecx, ide_channel5_mutex |
254 | call mutex_init |
254 | call mutex_init |
255 | mov ecx, ide_channel6_mutex |
255 | mov ecx, ide_channel6_mutex |
256 | call mutex_init |
256 | call mutex_init |
257 | ;----------------------------------------------------------------------------- |
257 | ;----------------------------------------------------------------------------- |
258 | ; SAVE REAL MODE VARIABLES |
258 | ; SAVE REAL MODE VARIABLES |
259 | ;----------------------------------------------------------------------------- |
259 | ;----------------------------------------------------------------------------- |
260 | ; --------------- APM --------------------- |
260 | ; --------------- APM --------------------- |
261 | 261 | ||
262 | ; init selectors |
262 | ; init selectors |
263 | mov ebx, [BOOT.apm_entry] ; offset of APM entry point |
263 | mov ebx, [BOOT.apm_entry] ; offset of APM entry point |
264 | movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of |
264 | movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of |
265 | ; protected-mode 32-bit code segment |
265 | ; protected-mode 32-bit code segment |
266 | movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of |
266 | movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of |
267 | ; protected-mode 16-bit code segment |
267 | ; protected-mode 16-bit code segment |
268 | movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of |
268 | movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of |
269 | ; protected-mode 16-bit data segment |
269 | ; protected-mode 16-bit data segment |
270 | 270 | ||
271 | shl eax, 4 |
271 | shl eax, 4 |
272 | mov [dword apm_code_32 + 2], ax |
272 | mov [dword apm_code_32 + 2], ax |
273 | shr eax, 16 |
273 | shr eax, 16 |
274 | mov [dword apm_code_32 + 4], al |
274 | mov [dword apm_code_32 + 4], al |
275 | 275 | ||
276 | shl ecx, 4 |
276 | shl ecx, 4 |
277 | mov [dword apm_code_16 + 2], cx |
277 | mov [dword apm_code_16 + 2], cx |
278 | shr ecx, 16 |
278 | shr ecx, 16 |
279 | mov [dword apm_code_16 + 4], cl |
279 | mov [dword apm_code_16 + 4], cl |
280 | 280 | ||
281 | shl edx, 4 |
281 | shl edx, 4 |
282 | mov [dword apm_data_16 + 2], dx |
282 | mov [dword apm_data_16 + 2], dx |
283 | shr edx, 16 |
283 | shr edx, 16 |
284 | mov [dword apm_data_16 + 4], dl |
284 | mov [dword apm_data_16 + 4], dl |
285 | 285 | ||
286 | mov dword[apm_entry], ebx |
286 | mov dword[apm_entry], ebx |
287 | mov word [apm_entry + 4], apm_code_32 - gdts |
287 | mov word [apm_entry + 4], apm_code_32 - gdts |
288 | 288 | ||
289 | mov eax, dword[BOOT.apm_version] ; version & flags |
289 | mov eax, dword[BOOT.apm_version] ; version & flags |
290 | mov [apm_vf], eax |
290 | mov [apm_vf], eax |
291 | ; ----------------------------------------- |
291 | ; ----------------------------------------- |
292 | mov al, [BOOT.dma] ; DMA access |
292 | mov al, [BOOT.dma] ; DMA access |
293 | mov [allow_dma_access], al |
293 | mov [allow_dma_access], al |
294 | 294 | ||
295 | mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen |
295 | mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen |
296 | mov [debug_direct_print], al |
296 | mov [debug_direct_print], al |
297 | 297 | ||
298 | mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded? |
298 | mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded? |
299 | mov [launcher_start], al |
299 | mov [launcher_start], al |
300 | 300 | ||
301 | mov eax, [BOOT.devicesdat_size] |
301 | mov eax, [BOOT.devicesdat_size] |
302 | mov [acpi_dev_size], eax |
302 | mov [acpi_dev_size], eax |
303 | mov eax, [BOOT.devicesdat_data] |
303 | mov eax, [BOOT.devicesdat_data] |
304 | mov [acpi_dev_data], eax |
304 | mov [acpi_dev_data], eax |
305 | 305 | ||
306 | mov esi, BOOT.bios_hd |
306 | mov esi, BOOT.bios_hd |
307 | movzx ecx, byte [esi-1] |
307 | movzx ecx, byte [esi-1] |
308 | mov [NumBiosDisks], ecx |
308 | mov [NumBiosDisks], ecx |
309 | mov edi, BiosDisksData |
309 | mov edi, BiosDisksData |
310 | shl ecx, 2 |
310 | shl ecx, 2 |
311 | rep movsd |
311 | rep movsd |
312 | 312 | ||
313 | ; -------- Fast System Call init ---------- |
313 | ; -------- Fast System Call init ---------- |
314 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
314 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
315 | bt [cpu_caps], CAPS_SEP |
315 | bt [cpu_caps], CAPS_SEP |
316 | jnc .SEnP ; SysEnter not Present |
316 | jnc .SEnP ; SysEnter not Present |
317 | xor edx, edx |
317 | xor edx, edx |
318 | mov ecx, MSR_SYSENTER_CS |
318 | mov ecx, MSR_SYSENTER_CS |
319 | mov eax, os_code |
319 | mov eax, os_code |
320 | wrmsr |
320 | wrmsr |
321 | mov ecx, MSR_SYSENTER_ESP |
321 | mov ecx, MSR_SYSENTER_ESP |
322 | ; mov eax, sysenter_stack ; Check it |
322 | ; mov eax, sysenter_stack ; Check it |
323 | xor eax, eax |
323 | xor eax, eax |
324 | wrmsr |
324 | wrmsr |
325 | mov ecx, MSR_SYSENTER_EIP |
325 | mov ecx, MSR_SYSENTER_EIP |
326 | mov eax, sysenter_entry |
326 | mov eax, sysenter_entry |
327 | wrmsr |
327 | wrmsr |
328 | .SEnP: |
328 | .SEnP: |
329 | ; AMD SYSCALL/SYSRET |
329 | ; AMD SYSCALL/SYSRET |
330 | cmp byte[cpu_vendor], 'A' |
330 | cmp byte[cpu_vendor], 'A' |
331 | jne .noSYSCALL |
331 | jne .noSYSCALL |
332 | mov eax, 0x80000001 |
332 | mov eax, 0x80000001 |
333 | cpuid |
333 | cpuid |
334 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
334 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
335 | jz .noSYSCALL |
335 | jz .noSYSCALL |
336 | mov ecx, MSR_AMD_EFER |
336 | mov ecx, MSR_AMD_EFER |
337 | rdmsr |
337 | rdmsr |
338 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
338 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
339 | wrmsr |
339 | wrmsr |
340 | 340 | ||
341 | ; !!!! It`s dirty hack, fix it !!! |
341 | ; !!!! It`s dirty hack, fix it !!! |
342 | ; Bits of EDX : |
342 | ; Bits of EDX : |
343 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
343 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
344 | ; and the contents of this field, plus 8, are copied into the SS register. |
344 | ; and the contents of this field, plus 8, are copied into the SS register. |
345 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
345 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
346 | ; and the contents of this field, plus 8, are copied into the SS register. |
346 | ; and the contents of this field, plus 8, are copied into the SS register. |
347 | 347 | ||
348 | ; mov edx, (os_code + 16) * 65536 + os_code |
348 | ; mov edx, (os_code + 16) * 65536 + os_code |
349 | mov edx, 0x1B0008 |
349 | mov edx, 0x1B0008 |
350 | 350 | ||
351 | mov eax, syscall_entry |
351 | mov eax, syscall_entry |
352 | mov ecx, MSR_AMD_STAR |
352 | mov ecx, MSR_AMD_STAR |
353 | wrmsr |
353 | wrmsr |
354 | .noSYSCALL: |
354 | .noSYSCALL: |
355 | ; ----------------------------------------- |
355 | ; ----------------------------------------- |
356 | stdcall alloc_page |
356 | stdcall alloc_page |
357 | stdcall map_page, tss-0xF80, eax, PG_SWR |
357 | stdcall map_page, tss-0xF80, eax, PG_SWR |
358 | stdcall alloc_page |
358 | stdcall alloc_page |
359 | stdcall map_page, tss+0x80, eax, PG_SWR |
359 | stdcall map_page, tss+0x80, eax, PG_SWR |
360 | stdcall alloc_page |
360 | stdcall alloc_page |
361 | stdcall map_page, tss+0x1080, eax, PG_SWR |
361 | stdcall map_page, tss+0x1080, eax, PG_SWR |
362 | 362 | ||
363 | ; LOAD IDT |
363 | ; LOAD IDT |
364 | 364 | ||
365 | call build_interrupt_table ;lidt is executed |
365 | call build_interrupt_table ;lidt is executed |
366 | ;lidt [idtreg] |
366 | ;lidt [idtreg] |
367 | 367 | ||
368 | call init_kernel_heap |
368 | call init_kernel_heap |
369 | call init_fpu |
369 | call init_fpu |
370 | mov eax, [xsave_area_size] |
370 | mov eax, [xsave_area_size] |
371 | lea eax, [eax*2 + RING0_STACK_SIZE*2] |
371 | lea eax, [eax*2 + RING0_STACK_SIZE*2] |
372 | stdcall kernel_alloc, eax |
372 | stdcall kernel_alloc, eax |
373 | mov [os_stack_seg], eax |
373 | mov [os_stack_seg], eax |
374 | 374 | ||
375 | lea esp, [eax + RING0_STACK_SIZE] |
375 | lea esp, [eax + RING0_STACK_SIZE] |
376 | 376 | ||
377 | mov [tss._ss0], os_stack |
377 | mov [tss._ss0], os_stack |
378 | mov [tss._esp0], esp |
378 | mov [tss._esp0], esp |
379 | mov [tss._esp], esp |
379 | mov [tss._esp], esp |
380 | mov [tss._cs], os_code |
380 | mov [tss._cs], os_code |
381 | mov [tss._ss], os_stack |
381 | mov [tss._ss], os_stack |
382 | mov [tss._ds], app_data |
382 | mov [tss._ds], app_data |
383 | mov [tss._es], app_data |
383 | mov [tss._es], app_data |
384 | mov [tss._fs], app_data |
384 | mov [tss._fs], app_data |
385 | mov [tss._gs], app_data |
385 | mov [tss._gs], app_data |
386 | mov [tss._io], 128 |
386 | mov [tss._io], 128 |
387 | ;Add IO access table - bit array of permitted ports |
387 | ;Add IO access table - bit array of permitted ports |
388 | mov edi, tss._io_map_0 |
388 | mov edi, tss._io_map_0 |
389 | xor eax, eax |
389 | xor eax, eax |
390 | not eax |
390 | not eax |
391 | mov ecx, 8192/4 |
391 | mov ecx, 8192/4 |
392 | rep stosd ; access to 4096*8=65536 ports |
392 | rep stosd ; access to 4096*8=65536 ports |
393 | 393 | ||
394 | mov ax, tss0 |
394 | mov ax, tss0 |
395 | ltr ax |
395 | ltr ax |
396 | 396 | ||
397 | mov eax, sys_proc |
397 | mov eax, sys_proc |
398 | list_init eax |
398 | list_init eax |
399 | add eax, PROC.thr_list |
399 | add eax, PROC.thr_list |
400 | list_init eax |
400 | list_init eax |
401 | 401 | ||
402 | call init_video |
402 | call init_video |
403 | call init_pat_mtrr |
403 | call init_pat_mtrr |
404 | mov [LFBAddress], LFB_BASE |
404 | mov [LFBAddress], LFB_BASE |
405 | mov ecx, bios_fb |
405 | mov ecx, bios_fb |
406 | call set_framebuffer |
406 | call set_framebuffer |
407 | call init_malloc |
407 | call init_malloc |
408 | 408 | ||
409 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
409 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
410 | mov [default_io_map], eax |
410 | mov [default_io_map], eax |
411 | 411 | ||
412 | add eax, 0x2000 |
412 | add eax, 0x2000 |
413 | mov [ipc_tmp], eax |
413 | mov [ipc_tmp], eax |
414 | mov ebx, 0x1000 |
414 | mov ebx, 0x1000 |
415 | 415 | ||
416 | add eax, 0x40000 |
416 | add eax, 0x40000 |
417 | mov [proc_mem_map], eax |
417 | mov [proc_mem_map], eax |
418 | 418 | ||
419 | add eax, 0x8000 |
419 | add eax, 0x8000 |
420 | mov [proc_mem_pdir], eax |
420 | mov [proc_mem_pdir], eax |
421 | 421 | ||
422 | add eax, ebx |
422 | add eax, ebx |
423 | mov [proc_mem_tab], eax |
423 | mov [proc_mem_tab], eax |
424 | 424 | ||
425 | add eax, ebx |
425 | add eax, ebx |
426 | mov [tmp_task_ptab], eax |
426 | mov [tmp_task_ptab], eax |
427 | 427 | ||
428 | add eax, ebx |
428 | add eax, ebx |
429 | mov [ipc_pdir], eax |
429 | mov [ipc_pdir], eax |
430 | 430 | ||
431 | add eax, ebx |
431 | add eax, ebx |
432 | mov [ipc_ptab], eax |
432 | mov [ipc_ptab], eax |
433 | 433 | ||
434 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE + (unpack.LZMA_LIT_SIZE shl \ |
434 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE + (unpack.LZMA_LIT_SIZE shl \ |
435 | (unpack.lc + unpack.lp)))*4 |
435 | (unpack.lc + unpack.lp)))*4 |
436 | 436 | ||
437 | mov [unpack.p], eax |
437 | mov [unpack.p], eax |
438 | 438 | ||
439 | call init_events |
439 | call init_events |
440 | mov eax, srv.fd - SRV.fd |
440 | mov eax, srv.fd - SRV.fd |
441 | mov [srv.fd], eax |
441 | mov [srv.fd], eax |
442 | mov [srv.bk], eax |
442 | mov [srv.bk], eax |
443 | 443 | ||
444 | ;Set base of graphic segment to linear address of LFB |
444 | ;Set base of graphic segment to linear address of LFB |
445 | mov eax, [LFBAddress] ; set for gs |
445 | mov eax, [LFBAddress] ; set for gs |
446 | mov [graph_data_l+2], ax |
446 | mov [graph_data_l+2], ax |
447 | shr eax, 16 |
447 | shr eax, 16 |
448 | mov [graph_data_l+4], al |
448 | mov [graph_data_l+4], al |
449 | mov [graph_data_l+7], ah |
449 | mov [graph_data_l+7], ah |
450 | 450 | ||
451 | stdcall kernel_alloc, [_display.win_map_size] |
451 | stdcall kernel_alloc, [_display.win_map_size] |
452 | mov [_display.win_map], eax |
452 | mov [_display.win_map], eax |
453 | 453 | ||
454 | xor eax, eax |
454 | xor eax, eax |
455 | inc eax |
455 | inc eax |
456 | 456 | ||
457 | ; set background |
457 | ; set background |
458 | 458 | ||
459 | mov [BgrDrawMode], eax |
459 | mov [BgrDrawMode], eax |
460 | mov [BgrDataWidth], eax |
460 | mov [BgrDataWidth], eax |
461 | mov [BgrDataHeight], eax |
461 | mov [BgrDataHeight], eax |
462 | mov [mem_BACKGROUND], 4 |
462 | mov [mem_BACKGROUND], 4 |
463 | mov [img_background], static_background_data |
463 | mov [img_background], static_background_data |
464 | 464 | ||
465 | ; set clipboard |
465 | ; set clipboard |
466 | 466 | ||
467 | xor eax, eax |
467 | xor eax, eax |
468 | mov [clipboard_slots], eax |
468 | mov [clipboard_slots], eax |
469 | mov [clipboard_write_lock], eax |
469 | mov [clipboard_write_lock], eax |
470 | stdcall kernel_alloc, PAGE_SIZE |
470 | stdcall kernel_alloc, PAGE_SIZE |
471 | test eax, eax |
471 | test eax, eax |
472 | jnz @f |
472 | jnz @f |
473 | 473 | ||
474 | dec eax |
474 | dec eax |
475 | @@: |
475 | @@: |
476 | mov [clipboard_main_list], eax |
476 | mov [clipboard_main_list], eax |
477 | 477 | ||
478 | call check_acpi |
478 | call check_acpi |
479 | 479 | ||
480 | mov eax, [hpet_base] |
480 | mov eax, [hpet_base] |
481 | test eax, eax |
481 | test eax, eax |
482 | jz @F |
482 | jz @F |
483 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL + PAT_UC + PG_SWR |
483 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL + PAT_UC + PG_SWR |
484 | mov [hpet_base], eax |
484 | mov [hpet_base], eax |
485 | mov eax, [eax+HPET_ID] |
485 | mov eax, [eax+HPET_ID] |
486 | DEBUGF 1, "K : HPET caps %x\n", eax |
486 | DEBUGF 1, "K : HPET caps %x\n", eax |
487 | call init_hpet |
487 | call init_hpet |
488 | @@: |
488 | @@: |
489 | ; SET UP OS TASK |
489 | ; SET UP OS TASK |
490 | 490 | ||
491 | mov esi, boot_setostask |
491 | mov esi, boot_setostask |
492 | call boot_log |
492 | call boot_log |
493 | 493 | ||
494 | mov edi, sys_proc + PROC.heap_lock |
494 | mov edi, sys_proc + PROC.heap_lock |
495 | mov ecx, (PROC.ht_free - PROC.heap_lock)/4 |
495 | mov ecx, (PROC.ht_free - PROC.heap_lock)/4 |
496 | 496 | ||
497 | xor eax, eax |
497 | xor eax, eax |
498 | cld |
498 | cld |
499 | rep stosd |
499 | rep stosd |
500 | 500 | ||
501 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
501 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
502 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
502 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
503 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
503 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
504 | add edi, 8 |
504 | add edi, 8 |
505 | inc eax |
505 | inc eax |
506 | @@: |
506 | @@: |
507 | stosd |
507 | stosd |
508 | inc eax |
508 | inc eax |
509 | cmp eax, ecx |
509 | cmp eax, ecx |
510 | jbe @B |
510 | jbe @B |
511 | 511 | ||
512 | mov [sys_proc + PROC.pdt_0_phys], sys_proc - OS_BASE + PROC.pdt_0 |
512 | mov [sys_proc + PROC.pdt_0_phys], sys_proc - OS_BASE + PROC.pdt_0 |
513 | 513 | ||
514 | mov eax, -1 |
514 | mov eax, -1 |
515 | mov edi, thr_slot_map+4 |
515 | mov edi, thr_slot_map+4 |
516 | mov [edi-4], dword 0xFFFFFFF8 |
516 | mov [edi-4], dword 0xFFFFFFF8 |
517 | stosd |
517 | stosd |
518 | stosd |
518 | stosd |
519 | stosd |
519 | stosd |
520 | stosd |
520 | stosd |
521 | stosd |
521 | stosd |
522 | stosd |
522 | stosd |
523 | stosd |
523 | stosd |
524 | 524 | ||
525 | mov [current_process], sys_proc |
525 | mov [current_process], sys_proc |
526 | 526 | ||
527 | ; set all the threads state to free |
527 | ; set all the threads state to free |
528 | mov edi, SLOT_BASE |
528 | mov edi, SLOT_BASE |
529 | movi eax, TSTATE_FREE |
529 | movi eax, TSTATE_FREE |
530 | movi ecx, max_processes |
530 | movi ecx, max_processes |
531 | @@: |
531 | @@: |
532 | mov [edi+APPDATA.state], TSTATE_FREE |
532 | mov [edi+APPDATA.state], TSTATE_FREE |
533 | add edi, sizeof.APPDATA |
533 | add edi, sizeof.APPDATA |
534 | dec ecx |
534 | dec ecx |
535 | jns @b |
535 | jns @b |
536 | 536 | ||
537 | mov edx, SLOT_BASE + sizeof.APPDATA*1 |
537 | mov edx, SLOT_BASE + sizeof.APPDATA*1 |
538 | mov ebx, [os_stack_seg] |
538 | mov ebx, [os_stack_seg] |
539 | add ebx, RING0_STACK_SIZE |
539 | add ebx, RING0_STACK_SIZE |
540 | add ebx, [xsave_area_size] |
540 | add ebx, [xsave_area_size] |
541 | call setup_os_slot |
541 | call setup_os_slot |
542 | mov dword [edx], 'IDLE' |
542 | mov dword [edx], 'IDLE' |
543 | sub [edx + APPDATA.saved_esp], 4 |
543 | sub [edx + APPDATA.saved_esp], 4 |
544 | mov eax, [edx + APPDATA.saved_esp] |
544 | mov eax, [edx + APPDATA.saved_esp] |
545 | mov dword [eax], idle_thread |
545 | mov dword [eax], idle_thread |
546 | mov ecx, IDLE_PRIORITY |
546 | mov ecx, IDLE_PRIORITY |
547 | call scheduler_add_thread |
547 | call scheduler_add_thread |
548 | 548 | ||
549 | mov edx, SLOT_BASE + sizeof.APPDATA*2 |
549 | mov edx, SLOT_BASE + sizeof.APPDATA*2 |
550 | mov ebx, [os_stack_seg] |
550 | mov ebx, [os_stack_seg] |
551 | call setup_os_slot |
551 | call setup_os_slot |
552 | mov dword [edx], 'OS' |
552 | mov dword [edx], 'OS' |
553 | xor ecx, ecx |
553 | xor ecx, ecx |
554 | call scheduler_add_thread |
554 | call scheduler_add_thread |
555 | 555 | ||
556 | mov [current_slot_idx], 2 |
556 | mov [current_slot_idx], 2 |
557 | mov [thread_count], 2 |
557 | mov [thread_count], 2 |
558 | mov [current_slot], SLOT_BASE + sizeof.APPDATA*2 |
558 | mov [current_slot], SLOT_BASE + sizeof.APPDATA*2 |
559 | 559 | ||
560 | ; Move other CPUs to deep sleep, if it is useful |
560 | ; Move other CPUs to deep sleep, if it is useful |
561 | uglobal |
561 | uglobal |
562 | use_mwait_for_idle db 0 |
562 | use_mwait_for_idle db 0 |
563 | endg |
563 | endg |
564 | cmp [cpu_vendor+8], 'ntel' |
564 | cmp [cpu_vendor+8], 'ntel' |
565 | jnz .no_wake_cpus |
565 | jnz .no_wake_cpus |
566 | bt [cpu_caps+4], CAPS_MONITOR-32 |
566 | bt [cpu_caps+4], CAPS_MONITOR-32 |
567 | jnc .no_wake_cpus |
567 | jnc .no_wake_cpus |
568 | dbgstr 'using mwait for idle loop' |
568 | dbgstr 'using mwait for idle loop' |
569 | inc [use_mwait_for_idle] |
569 | inc [use_mwait_for_idle] |
570 | mov ebx, [cpu_count] |
570 | mov ebx, [cpu_count] |
571 | cmp ebx, 1 |
571 | cmp ebx, 1 |
572 | jbe .no_wake_cpus |
572 | jbe .no_wake_cpus |
573 | call create_trampoline_pgmap |
573 | call create_trampoline_pgmap |
574 | mov [cr3_ap + OS_BASE], eax |
574 | mov [cr3_ap + OS_BASE], eax |
575 | mov eax, cr4 |
575 | mov eax, cr4 |
576 | mov [cr4_ap + OS_BASE], eax |
576 | mov [cr4_ap + OS_BASE], eax |
577 | mov esi, OS_BASE + ap_init16 |
577 | mov esi, OS_BASE + ap_init16 |
578 | mov edi, OS_BASE + 8000h |
578 | mov edi, OS_BASE + 8000h |
579 | mov ecx, (ap_init16_size + 3) / 4 |
579 | mov ecx, (ap_init16_size + 3) / 4 |
580 | rep movsd |
580 | rep movsd |
581 | mov eax, [LAPIC_BASE] |
581 | mov eax, [LAPIC_BASE] |
582 | test eax, eax |
582 | test eax, eax |
583 | jnz @f |
583 | jnz @f |
584 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL + PG_NOCACHE + PG_SWR |
584 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL + PG_NOCACHE + PG_SWR |
585 | mov [LAPIC_BASE], eax |
585 | mov [LAPIC_BASE], eax |
586 | @@: |
586 | @@: |
587 | lea edi, [eax + APIC_ICRL] |
587 | lea edi, [eax + APIC_ICRL] |
588 | mov esi, smpt+4 |
588 | mov esi, smpt+4 |
589 | dec ebx |
589 | dec ebx |
590 | .wake_cpus_loop: |
590 | .wake_cpus_loop: |
591 | lodsd |
591 | lodsd |
592 | push esi |
592 | push esi |
593 | xor esi, esi |
593 | xor esi, esi |
594 | inc esi |
594 | inc esi |
595 | shl eax, 24 |
595 | shl eax, 24 |
596 | mov [edi+10h], eax |
596 | mov [edi+10h], eax |
597 | ; assert INIT IPI |
597 | ; assert INIT IPI |
598 | mov dword [edi], 0C500h |
598 | mov dword [edi], 0C500h |
599 | call delay_ms |
599 | call delay_ms |
600 | @@: |
600 | @@: |
601 | test dword [edi], 1000h |
601 | test dword [edi], 1000h |
602 | jnz @b |
602 | jnz @b |
603 | ; deassert INIT IPI |
603 | ; deassert INIT IPI |
604 | mov dword [edi], 8500h |
604 | mov dword [edi], 8500h |
605 | call delay_ms |
605 | call delay_ms |
606 | @@: |
606 | @@: |
607 | test dword [edi], 1000h |
607 | test dword [edi], 1000h |
608 | jnz @b |
608 | jnz @b |
609 | ; send STARTUP IPI |
609 | ; send STARTUP IPI |
610 | mov dword [edi], 600h + (8000h shr 12) |
610 | mov dword [edi], 600h + (8000h shr 12) |
611 | call delay_ms |
611 | call delay_ms |
612 | @@: |
612 | @@: |
613 | test dword [edi], 1000h |
613 | test dword [edi], 1000h |
614 | jnz @b |
614 | jnz @b |
615 | pop esi |
615 | pop esi |
616 | dec ebx |
616 | dec ebx |
617 | jnz .wake_cpus_loop |
617 | jnz .wake_cpus_loop |
618 | mov eax, [cpu_count] |
618 | mov eax, [cpu_count] |
619 | dec eax |
619 | dec eax |
620 | @@: |
620 | @@: |
621 | cmp [ap_initialized], eax |
621 | cmp [ap_initialized], eax |
622 | jnz @b |
622 | jnz @b |
623 | mov eax, [cr3_ap + OS_BASE] |
623 | mov eax, [cr3_ap + OS_BASE] |
624 | call free_page |
624 | call free_page |
625 | .no_wake_cpus: |
625 | .no_wake_cpus: |
626 | 626 | ||
627 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
627 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
628 | mov esi, boot_initirq |
628 | mov esi, boot_initirq |
629 | call boot_log |
629 | call boot_log |
630 | call init_irqs |
630 | call init_irqs |
631 | 631 | ||
632 | mov esi, boot_picinit |
632 | mov esi, boot_picinit |
633 | call boot_log |
633 | call boot_log |
634 | call PIC_init |
634 | call PIC_init |
635 | 635 | ||
636 | mov esi, boot_v86machine |
636 | mov esi, boot_v86machine |
637 | call boot_log |
637 | call boot_log |
638 | ; Initialize system V86 machine |
638 | ; Initialize system V86 machine |
639 | call init_sys_v86 |
639 | call init_sys_v86 |
640 | 640 | ||
641 | mov esi, boot_inittimer |
641 | mov esi, boot_inittimer |
642 | call boot_log |
642 | call boot_log |
643 | ; Initialize system timer (IRQ0) |
643 | ; Initialize system timer (IRQ0) |
644 | call PIT_init |
644 | call PIT_init |
645 | 645 | ||
646 | ; Register ramdisk file system |
646 | ; Register ramdisk file system |
647 | if ~ defined extended_primary_loader |
647 | if ~ defined extended_primary_loader |
648 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD ; will be loaded later |
648 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD ; will be loaded later |
649 | je @f |
649 | je @f |
650 | end if |
650 | end if |
651 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_NONE |
651 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_NONE |
652 | je @f |
652 | je @f |
653 | call register_ramdisk |
653 | call register_ramdisk |
654 | ;-------------------------------------- |
654 | ;-------------------------------------- |
655 | @@: |
655 | @@: |
656 | mov esi, boot_initapic |
656 | mov esi, boot_initapic |
657 | call boot_log |
657 | call boot_log |
658 | ; Try to Initialize APIC |
658 | ; Try to Initialize APIC |
659 | call APIC_init |
659 | call APIC_init |
660 | 660 | ||
661 | mov esi, boot_enableirq |
661 | mov esi, boot_enableirq |
662 | call boot_log |
662 | call boot_log |
663 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
663 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
664 | ; they are used: when partitions are scanned, hd_read relies on timer |
664 | ; they are used: when partitions are scanned, hd_read relies on timer |
665 | call unmask_timer |
665 | call unmask_timer |
666 | ; Prevent duplicate timer IRQs in APIC mode |
666 | ; Prevent duplicate timer IRQs in APIC mode |
667 | cmp [irq_mode], IRQ_APIC |
667 | cmp [irq_mode], IRQ_APIC |
668 | jz @f |
668 | jz @f |
669 | stdcall enable_irq, 2 ; @#$%! PIC |
669 | stdcall enable_irq, 2 ; @#$%! PIC |
670 | @@: |
670 | @@: |
671 | stdcall enable_irq, 13 ; co-processor |
671 | stdcall enable_irq, 13 ; co-processor |
672 | 672 | ||
673 | ; Setup serial output console (if enabled) |
673 | ; Setup serial output console (if enabled) |
674 | if defined debug_com_base |
674 | if defined debug_com_base |
675 | 675 | ||
676 | ; reserve port so nobody else will use it |
676 | ; reserve port so nobody else will use it |
677 | xor ebx, ebx |
677 | xor ebx, ebx |
678 | mov ecx, debug_com_base |
678 | mov ecx, debug_com_base |
679 | mov edx, debug_com_base+7 |
679 | mov edx, debug_com_base+7 |
680 | call r_f_port_area |
680 | call r_f_port_area |
681 | 681 | ||
682 | ; enable Divisor latch |
682 | ; enable Divisor latch |
683 | mov dx, debug_com_base+3 |
683 | mov dx, debug_com_base+3 |
684 | mov al, 1 shl 7 |
684 | mov al, 1 shl 7 |
685 | out dx, al |
685 | out dx, al |
686 | 686 | ||
687 | ; Set speed to 115200 baud (max speed) |
687 | ; Set speed to 115200 baud (max speed) |
688 | mov dx, debug_com_base |
688 | mov dx, debug_com_base |
689 | mov al, 0x01 |
689 | mov al, 0x01 |
690 | out dx, al |
690 | out dx, al |
691 | 691 | ||
692 | mov dx, debug_com_base+1 |
692 | mov dx, debug_com_base+1 |
693 | mov al, 0x00 |
693 | mov al, 0x00 |
694 | out dx, al |
694 | out dx, al |
695 | 695 | ||
696 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
696 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
697 | mov dx, debug_com_base+3 |
697 | mov dx, debug_com_base+3 |
698 | mov al, 3 |
698 | mov al, 3 |
699 | out dx, al |
699 | out dx, al |
700 | 700 | ||
701 | ; disable interrupts |
701 | ; disable interrupts |
702 | mov dx, debug_com_base+1 |
702 | mov dx, debug_com_base+1 |
703 | mov al, 0 |
703 | mov al, 0 |
704 | out dx, al |
704 | out dx, al |
705 | 705 | ||
706 | ; clear + enable fifo (64 bits) |
706 | ; clear + enable fifo (64 bits) |
707 | mov dx, debug_com_base+2 |
707 | mov dx, debug_com_base+2 |
708 | mov al, 0x7 + 1 shl 5 |
708 | mov al, 0x7 + 1 shl 5 |
709 | out dx, al |
709 | out dx, al |
710 | 710 | ||
711 | end if |
711 | end if |
712 | 712 | ||
713 | 713 | ||
714 | ;----------------------------------------------------------------------------- |
714 | ;----------------------------------------------------------------------------- |
715 | ; show SVN version of kernel on the message board |
715 | ; show SVN version of kernel on the message board |
716 | ;----------------------------------------------------------------------------- |
716 | ;----------------------------------------------------------------------------- |
717 | mov eax, [version_inf.rev] |
717 | mov eax, [version_inf.rev] |
718 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
718 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
719 | ;----------------------------------------------------------------------------- |
719 | ;----------------------------------------------------------------------------- |
720 | ; show CPU count on the message board |
720 | ; show CPU count on the message board |
721 | ;----------------------------------------------------------------------------- |
721 | ;----------------------------------------------------------------------------- |
722 | mov eax, [cpu_count] |
722 | mov eax, [cpu_count] |
723 | test eax, eax |
723 | test eax, eax |
724 | jnz @F |
724 | jnz @F |
725 | mov al, 1 ; at least one CPU |
725 | mov al, 1 ; at least one CPU |
726 | @@: |
726 | @@: |
727 | DEBUGF 1, "K : %d CPU detected\n", eax |
727 | DEBUGF 1, "K : %d CPU detected\n", eax |
728 | ;----------------------------------------------------------------------------- |
728 | ;----------------------------------------------------------------------------- |
729 | ; detect Floppy drives |
729 | ; detect Floppy drives |
730 | ;----------------------------------------------------------------------------- |
730 | ;----------------------------------------------------------------------------- |
731 | mov esi, boot_detectfloppy |
731 | mov esi, boot_detectfloppy |
732 | call boot_log |
732 | call boot_log |
733 | include 'detect/dev_fd.inc' |
733 | include 'detect/dev_fd.inc' |
734 | ;----------------------------------------------------------------------------- |
734 | ;----------------------------------------------------------------------------- |
735 | ; create pci-devices list |
735 | ; create pci-devices list |
736 | ;----------------------------------------------------------------------------- |
736 | ;----------------------------------------------------------------------------- |
737 | mov [pci_access_enabled], 1 |
737 | mov [pci_access_enabled], 1 |
738 | call pci_enum |
738 | call pci_enum |
739 | ;----------------------------------------------------------------------------- |
739 | ;----------------------------------------------------------------------------- |
740 | ; initialisation IDE ATA code |
740 | ; initialisation IDE ATA code |
741 | ;----------------------------------------------------------------------------- |
741 | ;----------------------------------------------------------------------------- |
742 | include 'detect/init_ata.inc' |
742 | include 'detect/init_ata.inc' |
743 | ;----------------------------------------------------------------------------- |
743 | ;----------------------------------------------------------------------------- |
744 | ; initialisation AHCI code |
744 | ; initialisation AHCI code |
745 | ;----------------------------------------------------------------------------- |
745 | ;----------------------------------------------------------------------------- |
746 | jmp ahci_code_end |
746 | jmp ahci_code_end |
747 | include 'blkdev/ahci.inc' |
747 | include 'blkdev/ahci.inc' |
748 | ahci_code_end: |
748 | ahci_code_end: |
749 | call ahci_init |
749 | call ahci_init |
750 | ;----------------------------------------------------------------------------- |
750 | ;----------------------------------------------------------------------------- |
751 | if 0 |
751 | if 0 |
752 | mov ax, [BOOT.sys_disk] |
752 | mov ax, [BOOT.sys_disk] |
753 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
753 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
754 | je no_lib_load |
754 | je no_lib_load |
755 | 755 | ||
756 | mov esi, boot_loadlibs |
756 | mov esi, boot_loadlibs |
757 | call boot_log |
757 | call boot_log |
758 | ; LOADING LIBRARES |
758 | ; LOADING LIBRARES |
759 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
759 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
760 | call load_file_parse_table ; prepare file parse table |
760 | call load_file_parse_table ; prepare file parse table |
761 | call set_kernel_conf ; configure devices and gui |
761 | call set_kernel_conf ; configure devices and gui |
762 | no_lib_load: |
762 | no_lib_load: |
763 | end if |
763 | end if |
764 | 764 | ||
765 | ; Display APIC status |
765 | ; Display APIC status |
766 | mov esi, boot_APIC_found |
766 | mov esi, boot_APIC_found |
767 | cmp [irq_mode], IRQ_APIC |
767 | cmp [irq_mode], IRQ_APIC |
768 | je @f |
768 | je @f |
769 | mov esi, boot_APIC_nfound |
769 | mov esi, boot_APIC_nfound |
770 | @@: |
770 | @@: |
771 | call boot_log |
771 | call boot_log |
772 | 772 | ||
773 | ; PRINT AMOUNT OF MEMORY |
773 | ; PRINT AMOUNT OF MEMORY |
774 | mov esi, boot_memdetect |
774 | mov esi, boot_memdetect |
775 | call boot_log |
775 | call boot_log |
776 | 776 | ||
777 | movzx ecx, word [boot_y] |
777 | movzx ecx, word [boot_y] |
778 | if lang eq ru |
778 | if lang eq ru |
779 | or ecx, (10+30*6) shl 16 |
779 | or ecx, (10+30*6) shl 16 |
780 | else if lang eq sp |
780 | else if lang eq sp |
781 | or ecx, (10+33*6) shl 16 |
781 | or ecx, (10+33*6) shl 16 |
782 | else |
782 | else |
783 | or ecx, (10+29*6) shl 16 |
783 | or ecx, (10+29*6) shl 16 |
784 | end if |
784 | end if |
785 | sub ecx, 10 |
785 | sub ecx, 10 |
786 | mov edx, 0xFFFFFF |
786 | mov edx, 0xFFFFFF |
787 | mov ebx, [MEM_AMOUNT] |
787 | mov ebx, [MEM_AMOUNT] |
788 | shr ebx, 20 |
788 | shr ebx, 20 |
789 | xor edi, edi |
789 | xor edi, edi |
790 | mov eax, 0x00040000 |
790 | mov eax, 0x00040000 |
791 | inc edi |
791 | inc edi |
792 | call display_number_force |
792 | call display_number_force |
793 | 793 | ||
794 | ; BUILD SCHEDULER |
794 | ; BUILD SCHEDULER |
795 | 795 | ||
796 | ; call build_scheduler; sys32.inc |
796 | ; call build_scheduler; sys32.inc |
797 | 797 | ||
798 | ; mov esi, boot_devices |
798 | ; mov esi, boot_devices |
799 | ; call boot_log |
799 | ; call boot_log |
800 | 800 | ||
801 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
801 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
802 | 802 | ||
803 | stdcall load_pe_driver, szVidintel, 0 |
803 | stdcall load_pe_driver, szVidintel, 0 |
804 | 804 | ||
805 | call usb_init |
805 | call usb_init |
806 | 806 | ||
807 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
807 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
808 | 808 | ||
809 | mov esi, boot_windefs |
809 | mov esi, boot_windefs |
810 | call boot_log |
810 | call boot_log |
811 | call set_window_defaults |
811 | call set_window_defaults |
812 | 812 | ||
813 | ; SET BACKGROUND DEFAULTS |
813 | ; SET BACKGROUND DEFAULTS |
814 | 814 | ||
815 | mov esi, boot_bgr |
815 | mov esi, boot_bgr |
816 | call boot_log |
816 | call boot_log |
817 | call init_background |
817 | call init_background |
818 | call calculatebackground |
818 | call calculatebackground |
819 | 819 | ||
820 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
820 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
821 | 821 | ||
822 | mov esi, boot_resirqports |
822 | mov esi, boot_resirqports |
823 | call boot_log |
823 | call boot_log |
824 | call reserve_irqs_ports |
824 | call reserve_irqs_ports |
825 | 825 | ||
826 | mov [SLOT_BASE + APPDATA.window], window_data |
826 | mov [SLOT_BASE + APPDATA.window], window_data |
827 | mov [SLOT_BASE + sizeof.APPDATA + APPDATA.window], window_data + sizeof.WDATA |
827 | mov [SLOT_BASE + sizeof.APPDATA + APPDATA.window], window_data + sizeof.WDATA |
828 | mov [SLOT_BASE + sizeof.APPDATA*2 + APPDATA.window], window_data + sizeof.WDATA*2 |
828 | mov [SLOT_BASE + sizeof.APPDATA*2 + APPDATA.window], window_data + sizeof.WDATA*2 |
829 | mov [window_data + WDATA.thread], SLOT_BASE |
829 | mov [window_data + WDATA.thread], SLOT_BASE |
830 | mov [window_data + sizeof.WDATA + WDATA.thread], SLOT_BASE + sizeof.APPDATA |
830 | mov [window_data + sizeof.WDATA + WDATA.thread], SLOT_BASE + sizeof.APPDATA |
831 | mov [window_data + sizeof.WDATA*2 + WDATA.thread], SLOT_BASE + sizeof.APPDATA*2 |
831 | mov [window_data + sizeof.WDATA*2 + WDATA.thread], SLOT_BASE + sizeof.APPDATA*2 |
832 | 832 | ||
833 | call init_display |
833 | call init_display |
834 | mov eax, [def_cursor] |
834 | mov eax, [def_cursor] |
835 | mov [window_data + sizeof.WDATA + WDATA.cursor], eax |
835 | mov [window_data + sizeof.WDATA + WDATA.cursor], eax |
836 | mov [window_data + sizeof.WDATA*2 + WDATA.cursor], eax |
836 | mov [window_data + sizeof.WDATA*2 + WDATA.cursor], eax |
837 | 837 | ||
838 | ; PRINT CPU FREQUENCY |
838 | ; PRINT CPU FREQUENCY |
839 | 839 | ||
840 | mov esi, boot_cpufreq |
840 | mov esi, boot_cpufreq |
841 | call boot_log |
841 | call boot_log |
842 | 842 | ||
843 | cli |
843 | cli |
844 | mov ebx, [hpet_base] |
844 | mov ebx, [hpet_base] |
845 | test ebx, ebx |
845 | test ebx, ebx |
846 | jz @F |
846 | jz @F |
847 | mov ebx, [ebx + HPET_COUNTER] |
847 | mov ebx, [ebx + HPET_COUNTER] |
848 | 848 | ||
849 | rdtsc |
849 | rdtsc |
850 | mov ecx, 1000 |
850 | mov ecx, 1000 |
851 | sub eax, [hpet_tsc_start] |
851 | sub eax, [hpet_tsc_start] |
852 | sbb edx, [hpet_tsc_start + 4] |
852 | sbb edx, [hpet_tsc_start + 4] |
853 | shld edx, eax, 10 |
853 | shld edx, eax, 10 |
854 | shl eax, 10 |
854 | shl eax, 10 |
855 | mov esi, eax |
855 | mov esi, eax |
856 | mov eax, edx |
856 | mov eax, edx |
857 | mul ecx |
857 | mul ecx |
858 | xchg eax, esi |
858 | xchg eax, esi |
859 | mul ecx |
859 | mul ecx |
860 | adc edx, esi |
860 | adc edx, esi |
861 | div ebx |
861 | div ebx |
862 | mul ecx |
862 | mul ecx |
863 | div [hpet_period] |
863 | div [hpet_period] |
864 | mul ecx |
864 | mul ecx |
865 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
865 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
866 | jmp .next |
866 | jmp .next |
867 | @@: |
867 | @@: |
868 | rdtsc |
868 | rdtsc |
869 | mov ecx, eax |
869 | mov ecx, eax |
870 | mov esi, 250 ; wait 1/4 a second |
870 | mov esi, 250 ; wait 1/4 a second |
871 | call delay_ms |
871 | call delay_ms |
872 | rdtsc |
872 | rdtsc |
873 | 873 | ||
874 | sub eax, ecx |
874 | sub eax, ecx |
875 | xor edx, edx |
875 | xor edx, edx |
876 | shld edx, eax, 2 |
876 | shld edx, eax, 2 |
877 | shl eax, 2 |
877 | shl eax, 2 |
878 | .next: |
878 | .next: |
879 | mov dword [cpu_freq], eax |
879 | mov dword [cpu_freq], eax |
880 | mov dword [cpu_freq + 4], edx |
880 | mov dword [cpu_freq + 4], edx |
881 | mov ebx, 1000000 |
881 | mov ebx, 1000000 |
882 | div ebx |
882 | div ebx |
883 | mov ebx, eax |
883 | mov ebx, eax |
884 | 884 | ||
885 | movzx ecx, word [boot_y] |
885 | movzx ecx, word [boot_y] |
886 | if lang eq ru |
886 | if lang eq ru |
887 | add ecx, (10+19*6) shl 16 - 10 |
887 | add ecx, (10+19*6) shl 16 - 10 |
888 | else if lang eq sp |
888 | else if lang eq sp |
889 | add ecx, (10+25*6) shl 16 - 10 |
889 | add ecx, (10+25*6) shl 16 - 10 |
890 | else |
890 | else |
891 | add ecx, (10+17*6) shl 16 - 10 |
891 | add ecx, (10+17*6) shl 16 - 10 |
892 | end if |
892 | end if |
893 | 893 | ||
894 | mov edx, 0xFFFFFF |
894 | mov edx, 0xFFFFFF |
895 | xor edi, edi |
895 | xor edi, edi |
896 | mov eax, 0x00040000 |
896 | mov eax, 0x00040000 |
897 | inc edi |
897 | inc edi |
898 | call display_number_force |
898 | call display_number_force |
899 | 899 | ||
900 | ; SET VARIABLES |
900 | ; SET VARIABLES |
901 | 901 | ||
902 | call set_variables |
902 | call set_variables |
903 | 903 | ||
904 | ; STACK AND FDC |
904 | ; STACK AND FDC |
905 | 905 | ||
906 | call stack_init |
906 | call stack_init |
907 | call fdc_init |
907 | call fdc_init |
908 | 908 | ||
909 | ; PALETTE FOR 320x200 and 640x480 16 col |
909 | ; PALETTE FOR 320x200 and 640x480 16 col |
910 | 910 | ||
911 | cmp [SCR_MODE], word 0x12 |
911 | cmp [SCR_MODE], word 0x12 |
912 | jne no_pal_vga |
912 | jne no_pal_vga |
913 | mov esi, boot_pal_vga |
913 | mov esi, boot_pal_vga |
914 | call boot_log |
914 | call boot_log |
915 | call paletteVGA |
915 | call paletteVGA |
916 | no_pal_vga: |
916 | no_pal_vga: |
917 | 917 | ||
918 | cmp [SCR_MODE], word 0x13 |
918 | cmp [SCR_MODE], word 0x13 |
919 | jne no_pal_ega |
919 | jne no_pal_ega |
920 | mov esi, boot_pal_ega |
920 | mov esi, boot_pal_ega |
921 | call boot_log |
921 | call boot_log |
922 | call palette320x200 |
922 | call palette320x200 |
923 | no_pal_ega: |
923 | no_pal_ega: |
924 | 924 | ||
925 | ; LOAD DEFAULT SKIN |
925 | ; LOAD DEFAULT SKIN |
926 | 926 | ||
927 | call load_default_skin |
927 | call load_default_skin |
928 | 928 | ||
929 | ; Protect I/O permission map |
929 | ; Protect I/O permission map |
930 | 930 | ||
931 | mov esi, [default_io_map] |
931 | mov esi, [default_io_map] |
932 | stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ |
932 | stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ |
933 | add esi, 0x1000 |
933 | add esi, 0x1000 |
934 | stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ |
934 | stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ |
935 | 935 | ||
936 | stdcall map_page, tss._io_map_0, \ |
936 | stdcall map_page, tss._io_map_0, \ |
937 | [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ |
937 | [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ |
938 | stdcall map_page, tss._io_map_1, \ |
938 | stdcall map_page, tss._io_map_1, \ |
939 | [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ |
939 | [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ |
940 | 940 | ||
941 | ; SET KEYBOARD PARAMETERS |
941 | ; SET KEYBOARD PARAMETERS |
942 | mov al, 0xf6 ; reset keyboard, scan enabled |
942 | mov al, 0xf6 ; reset keyboard, scan enabled |
943 | call kb_write_wait_ack |
943 | call kb_write_wait_ack |
944 | test ah, ah |
944 | test ah, ah |
945 | jnz .no_keyboard |
945 | jnz .no_keyboard |
946 | 946 | ||
947 | iglobal |
947 | iglobal |
948 | align 4 |
948 | align 4 |
949 | ps2_keyboard_functions: |
949 | ps2_keyboard_functions: |
950 | dd .end - $ |
950 | dd .end - $ |
951 | dd 0 ; no close |
951 | dd 0 ; no close |
952 | dd ps2_set_lights |
952 | dd ps2_set_lights |
953 | .end: |
953 | .end: |
954 | endg |
954 | endg |
955 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
955 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
956 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
956 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
957 | ; call kb_write_wait_ack |
957 | ; call kb_write_wait_ack |
958 | ; mov al, 111b |
958 | ; mov al, 111b |
959 | ; call kb_write_wait_ack |
959 | ; call kb_write_wait_ack |
960 | 960 | ||
961 | mov al, 0xF3 ; set repeat rate & delay |
961 | mov al, 0xF3 ; set repeat rate & delay |
962 | call kb_write_wait_ack |
962 | call kb_write_wait_ack |
963 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
963 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
964 | call kb_write_wait_ack |
964 | call kb_write_wait_ack |
965 | ;// mike.dld [ |
965 | ;// mike.dld [ |
966 | call set_lights |
966 | call set_lights |
967 | ;// mike.dld ] |
967 | ;// mike.dld ] |
968 | stdcall attach_int_handler, 1, irq1, 0 |
968 | stdcall attach_int_handler, 1, irq1, 0 |
969 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
969 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
970 | .no_keyboard: |
970 | .no_keyboard: |
971 | 971 | ||
972 | ; Load PS/2 mouse driver |
972 | ; Load PS/2 mouse driver |
973 | mov esi, boot_setmouse |
973 | mov esi, boot_setmouse |
974 | call boot_log |
974 | call boot_log |
975 | stdcall load_pe_driver, szPS2MDriver, 0 |
975 | stdcall load_pe_driver, szPS2MDriver, 0 |
976 | 976 | ||
977 | ; LOAD FIRST APPLICATION |
977 | ; LOAD FIRST APPLICATION |
978 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
978 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
979 | jnz first_app_found |
979 | jnz first_app_found |
980 | 980 | ||
981 | cli |
981 | cli |
982 | mov ebp, firstapp |
982 | mov ebp, firstapp |
983 | call fs_execute_from_sysdir |
983 | call fs_execute_from_sysdir |
984 | test eax, eax |
984 | test eax, eax |
985 | jns first_app_found |
985 | jns first_app_found |
986 | 986 | ||
987 | mov esi, boot_failed |
987 | mov esi, boot_failed |
988 | call boot_log |
988 | call boot_log |
989 | 989 | ||
990 | mov eax, 0xDEADBEEF ; otherwise halt |
990 | mov eax, 0xDEADBEEF ; otherwise halt |
991 | hlt |
991 | hlt |
992 | 992 | ||
993 | first_app_found: |
993 | first_app_found: |
994 | 994 | ||
995 | ; START MULTITASKING |
995 | ; START MULTITASKING |
996 | preboot_blogesc = 0 ; start immediately after bootlog |
996 | preboot_blogesc = 0 ; start immediately after bootlog |
997 | 997 | ||
998 | ; A 'All set - press ESC to start' messages if need |
998 | ; A 'All set - press ESC to start' messages if need |
999 | if preboot_blogesc |
999 | if preboot_blogesc |
1000 | mov esi, boot_tasking |
1000 | mov esi, boot_tasking |
1001 | call boot_log |
1001 | call boot_log |
1002 | .bll1: |
1002 | .bll1: |
1003 | in al, 0x60 ; wait for ESC key press |
1003 | in al, 0x60 ; wait for ESC key press |
1004 | cmp al, 129 |
1004 | cmp al, 129 |
1005 | jne .bll1 |
1005 | jne .bll1 |
1006 | end if |
1006 | end if |
1007 | 1007 | ||
1008 | mov [timer_ticks_enable], 1 ; for cd driver |
1008 | mov [timer_ticks_enable], 1 ; for cd driver |
1009 | sti |
1009 | sti |
1010 | 1010 | ||
1011 | call mtrr_validate |
1011 | call mtrr_validate |
1012 | 1012 | ||
1013 | jmp osloop |
1013 | jmp osloop |
1014 | ; Fly :) |
1014 | ; Fly :) |
1015 | 1015 | ||
1016 | uglobal |
1016 | uglobal |
1017 | align 4 |
1017 | align 4 |
1018 | ap_initialized dd 0 |
1018 | ap_initialized dd 0 |
1019 | endg |
1019 | endg |
1020 | 1020 | ||
1021 | ap_init_high: |
1021 | ap_init_high: |
1022 | mov ax, os_stack |
1022 | mov ax, os_stack |
1023 | mov bx, app_data |
1023 | mov bx, app_data |
1024 | mov cx, app_tls |
1024 | mov cx, app_tls |
1025 | mov ss, ax |
1025 | mov ss, ax |
1026 | mov ds, bx |
1026 | mov ds, bx |
1027 | mov es, bx |
1027 | mov es, bx |
1028 | mov fs, cx |
1028 | mov fs, cx |
1029 | mov gs, bx |
1029 | mov gs, bx |
1030 | xor esp, esp |
1030 | xor esp, esp |
1031 | mov eax, sys_proc - OS_BASE + PROC.pdt_0 |
1031 | mov eax, sys_proc - OS_BASE + PROC.pdt_0 |
1032 | mov cr3, eax |
1032 | mov cr3, eax |
1033 | lock inc [ap_initialized] |
1033 | lock inc [ap_initialized] |
1034 | jmp idle_loop |
1034 | jmp idle_loop |
1035 | 1035 | ||
1036 | 1036 | ||
1037 | include 'unpacker.inc' |
1037 | include 'unpacker.inc' |
1038 | 1038 | ||
1039 | align 4 |
1039 | align 4 |
1040 | boot_log: |
1040 | boot_log: |
1041 | pushad |
1041 | pushad |
1042 | 1042 | ||
1043 | mov ebx, 10*65536 |
1043 | mov ebx, 10*65536 |
1044 | mov bx, word [boot_y] |
1044 | mov bx, word [boot_y] |
1045 | add [boot_y], dword 10 |
1045 | add [boot_y], dword 10 |
1046 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1046 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1047 | xor edi, edi |
1047 | xor edi, edi |
1048 | mov edx, esi |
1048 | mov edx, esi |
1049 | inc edi |
1049 | inc edi |
1050 | call dtext |
1050 | call dtext |
1051 | 1051 | ||
1052 | mov [novesachecksum], 1000 |
1052 | mov [novesachecksum], 1000 |
1053 | call checkVga_N13 |
1053 | call checkVga_N13 |
1054 | 1054 | ||
1055 | popad |
1055 | popad |
1056 | 1056 | ||
1057 | ret |
1057 | ret |
1058 | 1058 | ||
1059 | ;----------------------------------------------------------------------------- |
1059 | ;----------------------------------------------------------------------------- |
1060 | ; Register ramdisk file system |
1060 | ; Register ramdisk file system |
1061 | register_ramdisk: |
1061 | register_ramdisk: |
1062 | mov esi, boot_initramdisk |
1062 | mov esi, boot_initramdisk |
1063 | call boot_log |
1063 | call boot_log |
1064 | call ramdisk_init |
1064 | call ramdisk_init |
1065 | ret |
1065 | ret |
1066 | 1066 | ||
1067 | ; in: edx -> APPDATA for OS/IDLE slot |
1067 | ; in: edx -> APPDATA for OS/IDLE slot |
1068 | ; in: ebx = stack base |
1068 | ; in: ebx = stack base |
1069 | proc setup_os_slot |
1069 | proc setup_os_slot |
1070 | xor eax, eax |
1070 | xor eax, eax |
1071 | mov ecx, sizeof.APPDATA/4 |
1071 | mov ecx, sizeof.APPDATA/4 |
1072 | mov edi, edx |
1072 | mov edi, edx |
1073 | rep stosd |
1073 | rep stosd |
1074 | 1074 | ||
1075 | mov eax, tss+0x80 |
1075 | mov eax, tss+0x80 |
1076 | call get_pg_addr |
1076 | call get_pg_addr |
1077 | inc eax |
1077 | inc eax |
1078 | mov [edx + APPDATA.io_map], eax |
1078 | mov [edx + APPDATA.io_map], eax |
1079 | mov eax, tss+0x1080 |
1079 | mov eax, tss+0x1080 |
1080 | call get_pg_addr |
1080 | call get_pg_addr |
1081 | inc eax |
1081 | inc eax |
1082 | mov [edx + APPDATA.io_map + 4], eax |
1082 | mov [edx + APPDATA.io_map + 4], eax |
1083 | 1083 | ||
1084 | mov [edx + APPDATA.pl0_stack], ebx |
1084 | mov [edx + APPDATA.pl0_stack], ebx |
1085 | lea edi, [ebx + RING0_STACK_SIZE] |
1085 | lea edi, [ebx + RING0_STACK_SIZE] |
1086 | mov [edx + APPDATA.fpu_state], edi |
1086 | mov [edx + APPDATA.fpu_state], edi |
1087 | mov [edx + APPDATA.saved_esp0], edi |
1087 | mov [edx + APPDATA.saved_esp0], edi |
1088 | mov [edx + APPDATA.saved_esp], edi |
1088 | mov [edx + APPDATA.saved_esp], edi |
1089 | mov [edx + APPDATA.terminate_protection], 1 ; make unkillable |
1089 | mov [edx + APPDATA.terminate_protection], 1 ; make unkillable |
1090 | 1090 | ||
1091 | mov esi, fpu_data |
1091 | mov esi, fpu_data |
1092 | mov ecx, [xsave_area_size] |
1092 | mov ecx, [xsave_area_size] |
1093 | add ecx, 3 |
1093 | add ecx, 3 |
1094 | shr ecx, 2 |
1094 | shr ecx, 2 |
1095 | rep movsd |
1095 | rep movsd |
1096 | 1096 | ||
1097 | lea eax, [edx + APP_EV_OFFSET] |
1097 | lea eax, [edx + APP_EV_OFFSET] |
1098 | mov [edx + APPDATA.fd_ev], eax |
1098 | mov [edx + APPDATA.fd_ev], eax |
1099 | mov [edx + APPDATA.bk_ev], eax |
1099 | mov [edx + APPDATA.bk_ev], eax |
1100 | 1100 | ||
1101 | lea eax, [edx + APP_OBJ_OFFSET] |
1101 | lea eax, [edx + APP_OBJ_OFFSET] |
1102 | mov [edx + APPDATA.fd_obj], eax |
1102 | mov [edx + APPDATA.fd_obj], eax |
1103 | mov [edx + APPDATA.bk_obj], eax |
1103 | mov [edx + APPDATA.bk_obj], eax |
1104 | 1104 | ||
1105 | mov [edx + APPDATA.cur_dir], sysdir_path-2 |
1105 | mov [edx + APPDATA.cur_dir], sysdir_path-2 |
1106 | 1106 | ||
1107 | mov [edx + APPDATA.process], sys_proc |
1107 | mov [edx + APPDATA.process], sys_proc |
1108 | 1108 | ||
1109 | lea ebx, [edx + APPDATA.list] |
1109 | lea ebx, [edx + APPDATA.list] |
1110 | lea ecx, [sys_proc + PROC.thr_list] |
1110 | lea ecx, [sys_proc + PROC.thr_list] |
1111 | list_add_tail ebx, ecx |
1111 | list_add_tail ebx, ecx |
1112 | 1112 | ||
1113 | mov [edx + APPDATA.wnd_number], dh |
1113 | mov [edx + APPDATA.wnd_number], dh |
1114 | mov byte [edx + APPDATA.tid], dh |
1114 | mov byte [edx + APPDATA.tid], dh |
1115 | movzx eax, dh |
1115 | movzx eax, dh |
1116 | shl eax, BSF sizeof.WDATA |
1116 | shl eax, BSF sizeof.WDATA |
1117 | add eax, window_data |
1117 | add eax, window_data |
1118 | mov [edx + APPDATA.window], eax |
1118 | mov [edx + APPDATA.window], eax |
1119 | 1119 | ||
1120 | ret |
1120 | ret |
1121 | endp |
1121 | endp |
1122 | 1122 | ||
1123 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1123 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1124 | ; ; |
1124 | ; ; |
1125 | ; MAIN OS LOOP START ; |
1125 | ; MAIN OS LOOP START ; |
1126 | ; ; |
1126 | ; ; |
1127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1128 | align 32 |
1128 | align 32 |
1129 | osloop: |
1129 | osloop: |
1130 | mov edx, osloop_has_work? |
1130 | mov edx, osloop_has_work? |
1131 | xor ecx, ecx |
1131 | xor ecx, ecx |
1132 | call Wait_events |
1132 | call Wait_events |
1133 | xor eax, eax |
1133 | xor eax, eax |
1134 | xchg eax, [osloop_nonperiodic_work] |
1134 | xchg eax, [osloop_nonperiodic_work] |
1135 | test eax, eax |
1135 | test eax, eax |
1136 | jz .no_periodic |
1136 | jz .no_periodic |
1137 | 1137 | ||
1138 | call __sys_draw_pointer |
1138 | call __sys_draw_pointer |
1139 | call window_check_events |
1139 | call window_check_events |
1140 | call mouse_check_events |
1140 | call mouse_check_events |
1141 | call checkmisc |
1141 | call checkmisc |
1142 | call checkVga_N13 |
1142 | call checkVga_N13 |
1143 | ;-------------------------------------- |
1143 | ;-------------------------------------- |
1144 | .no_periodic: |
1144 | .no_periodic: |
1145 | call stack_handler |
1145 | call stack_handler |
1146 | call check_fdd_motor_status |
1146 | call check_fdd_motor_status |
1147 | call check_ATAPI_device_event |
1147 | call check_ATAPI_device_event |
1148 | call check_lights_state |
1148 | call check_lights_state |
1149 | call check_timers |
1149 | call check_timers |
1150 | 1150 | ||
1151 | jmp osloop |
1151 | jmp osloop |
1152 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1152 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1153 | ; ; |
1153 | ; ; |
1154 | ; MAIN OS LOOP END ; |
1154 | ; MAIN OS LOOP END ; |
1155 | ; ; |
1155 | ; ; |
1156 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1156 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1157 | proc osloop_has_work? |
1157 | proc osloop_has_work? |
1158 | cmp [osloop_nonperiodic_work], 0 |
1158 | cmp [osloop_nonperiodic_work], 0 |
1159 | jnz .yes |
1159 | jnz .yes |
1160 | call stack_handler_has_work? |
1160 | call stack_handler_has_work? |
1161 | jnz .yes |
1161 | jnz .yes |
1162 | call check_fdd_motor_status_has_work? |
1162 | call check_fdd_motor_status_has_work? |
1163 | jnz .yes |
1163 | jnz .yes |
1164 | call check_ATAPI_device_event_has_work? |
1164 | call check_ATAPI_device_event_has_work? |
1165 | jnz .yes |
1165 | jnz .yes |
1166 | call check_lights_state_has_work? |
1166 | call check_lights_state_has_work? |
1167 | jnz .yes |
1167 | jnz .yes |
1168 | call check_timers_has_work? |
1168 | call check_timers_has_work? |
1169 | jnz .yes |
1169 | jnz .yes |
1170 | .no: |
1170 | .no: |
1171 | xor eax, eax |
1171 | xor eax, eax |
1172 | ret |
1172 | ret |
1173 | .yes: |
1173 | .yes: |
1174 | xor eax, eax |
1174 | xor eax, eax |
1175 | inc eax |
1175 | inc eax |
1176 | ret |
1176 | ret |
1177 | endp |
1177 | endp |
1178 | 1178 | ||
1179 | proc wakeup_osloop |
1179 | proc wakeup_osloop |
1180 | mov [osloop_nonperiodic_work], 1 |
1180 | mov [osloop_nonperiodic_work], 1 |
1181 | ret |
1181 | ret |
1182 | endp |
1182 | endp |
1183 | 1183 | ||
1184 | uglobal |
1184 | uglobal |
1185 | align 4 |
1185 | align 4 |
1186 | osloop_nonperiodic_work dd ? |
1186 | osloop_nonperiodic_work dd ? |
1187 | endg |
1187 | endg |
1188 | 1188 | ||
1189 | uglobal |
1189 | uglobal |
1190 | align 64 |
1190 | align 64 |
1191 | idle_addr rb 64 |
1191 | idle_addr rb 64 |
1192 | endg |
1192 | endg |
1193 | 1193 | ||
1194 | idle_thread: |
1194 | idle_thread: |
1195 | sti |
1195 | sti |
1196 | 1196 | ||
1197 | ; The following code can be executed by all CPUs in the system. |
1197 | ; The following code can be executed by all CPUs in the system. |
1198 | ; All other parts of the kernel do not expect multi-CPU. |
1198 | ; All other parts of the kernel do not expect multi-CPU. |
1199 | ; Also, APs don't even have a stack here. |
1199 | ; Also, APs don't even have a stack here. |
1200 | ; Beware. Don't do anything here. Anything at all. |
1200 | ; Beware. Don't do anything here. Anything at all. |
1201 | idle_loop: |
1201 | idle_loop: |
1202 | cmp [use_mwait_for_idle], 0 |
1202 | cmp [use_mwait_for_idle], 0 |
1203 | jnz .mwait |
1203 | jnz .mwait |
1204 | 1204 | ||
1205 | .hlt: |
1205 | .hlt: |
1206 | hlt |
1206 | hlt |
1207 | jmp .hlt |
1207 | jmp .hlt |
1208 | 1208 | ||
1209 | .mwait: |
1209 | .mwait: |
1210 | mov eax, idle_addr |
1210 | mov eax, idle_addr |
1211 | xor ecx, ecx |
1211 | xor ecx, ecx |
1212 | xor edx, edx |
1212 | xor edx, edx |
1213 | monitor |
1213 | monitor |
1214 | xor ecx, ecx |
1214 | xor ecx, ecx |
1215 | mov eax, 20h ; or 10h |
1215 | mov eax, 20h ; or 10h |
1216 | mwait |
1216 | mwait |
1217 | jmp .mwait |
1217 | jmp .mwait |
1218 | 1218 | ||
1219 | 1219 | ||
1220 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1220 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1221 | ; ; |
1221 | ; ; |
1222 | ; INCLUDED SYSTEM FILES ; |
1222 | ; INCLUDED SYSTEM FILES ; |
1223 | ; ; |
1223 | ; ; |
1224 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1224 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1225 | 1225 | ||
1226 | 1226 | ||
1227 | include "kernel32.inc" |
1227 | include "kernel32.inc" |
1228 | 1228 | ||
1229 | 1229 | ||
1230 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1230 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1231 | ; ; |
1231 | ; ; |
1232 | ; KERNEL FUNCTIONS ; |
1232 | ; KERNEL FUNCTIONS ; |
1233 | ; ; |
1233 | ; ; |
1234 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1234 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1235 | 1235 | ||
1236 | reserve_irqs_ports: |
1236 | reserve_irqs_ports: |
1237 | 1237 | ||
1238 | 1238 | ||
1239 | ; RESERVE PORTS |
1239 | ; RESERVE PORTS |
1240 | mov eax, RESERVED_PORTS |
1240 | mov eax, RESERVED_PORTS |
1241 | mov ecx, 1 |
1241 | mov ecx, 1 |
1242 | 1242 | ||
1243 | mov [eax], dword 4 |
1243 | mov [eax], dword 4 |
1244 | 1244 | ||
1245 | mov [eax+16], ecx |
1245 | mov [eax+16], ecx |
1246 | mov [eax+16+4], dword 0 |
1246 | mov [eax+16+4], dword 0 |
1247 | mov [eax+16+8], dword 0x2D |
1247 | mov [eax+16+8], dword 0x2D |
1248 | 1248 | ||
1249 | mov [eax+32], ecx |
1249 | mov [eax+32], ecx |
1250 | mov [eax+32+4], dword 0x30 |
1250 | mov [eax+32+4], dword 0x30 |
1251 | mov [eax+32+8], dword 0x4D |
1251 | mov [eax+32+8], dword 0x4D |
1252 | 1252 | ||
1253 | mov [eax+48], ecx |
1253 | mov [eax+48], ecx |
1254 | mov [eax+48+4], dword 0x50 |
1254 | mov [eax+48+4], dword 0x50 |
1255 | mov [eax+48+8], dword 0xDF |
1255 | mov [eax+48+8], dword 0xDF |
1256 | 1256 | ||
1257 | mov [eax+64], ecx |
1257 | mov [eax+64], ecx |
1258 | mov [eax+64+4], dword 0xE5 |
1258 | mov [eax+64+4], dword 0xE5 |
1259 | mov [eax+64+8], dword 0xFF |
1259 | mov [eax+64+8], dword 0xFF |
1260 | 1260 | ||
1261 | ret |
1261 | ret |
1262 | 1262 | ||
1263 | 1263 | ||
1264 | iglobal |
1264 | iglobal |
1265 | process_number dd 0x2 |
1265 | process_number dd 0x2 |
1266 | endg |
1266 | endg |
1267 | 1267 | ||
1268 | set_variables: |
1268 | set_variables: |
1269 | 1269 | ||
1270 | mov ecx, 0x16 ; flush port 0x60 |
1270 | mov ecx, 0x16 ; flush port 0x60 |
1271 | @@: |
1271 | @@: |
1272 | in al, 0x60 |
1272 | in al, 0x60 |
1273 | loop @b |
1273 | loop @b |
1274 | push eax |
1274 | push eax |
1275 | 1275 | ||
1276 | mov ax, [BOOT.y_res] |
1276 | mov ax, [BOOT.y_res] |
1277 | shr ax, 1 |
1277 | shr ax, 1 |
1278 | shl eax, 16 |
1278 | shl eax, 16 |
1279 | mov ax, [BOOT.x_res] |
1279 | mov ax, [BOOT.x_res] |
1280 | shr ax, 1 |
1280 | shr ax, 1 |
1281 | mov [MOUSE_X], eax |
1281 | mov [MOUSE_X], eax |
1282 | call wakeup_osloop |
1282 | call wakeup_osloop |
1283 | 1283 | ||
1284 | xor eax, eax |
1284 | xor eax, eax |
1285 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1285 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1286 | 1286 | ||
1287 | mov byte [KEY_COUNT], al ; keyboard buffer |
1287 | mov byte [KEY_COUNT], al ; keyboard buffer |
1288 | mov byte [BTN_COUNT], al ; button buffer |
1288 | mov byte [BTN_COUNT], al ; button buffer |
1289 | 1289 | ||
1290 | pop eax |
1290 | pop eax |
1291 | ret |
1291 | ret |
1292 | ;----------------------------------------------------------------------------- |
1292 | ;----------------------------------------------------------------------------- |
1293 | 1293 | ||
1294 | align 4 |
1294 | align 4 |
1295 | display_number: |
1295 | display_number: |
1296 | ; add check pointers |
1296 | ; add check pointers |
1297 | test bl, bl |
1297 | test bl, bl |
1298 | jz @f |
1298 | jz @f |
1299 | bt ebx, 30 ; check 30 bit |
1299 | bt ebx, 30 ; check 30 bit |
1300 | jb @f |
1300 | jb @f |
1301 | stdcall is_region_userspace, ecx, 4 |
1301 | stdcall is_region_userspace, ecx, 4 |
1302 | jz @f |
1302 | jz @f |
1303 | ret |
1303 | ret |
1304 | @@: |
1304 | @@: |
1305 | jz @f |
1305 | jz @f |
1306 | stdcall is_region_userspace, ecx, 8 |
1306 | stdcall is_region_userspace, ecx, 8 |
1307 | jz @f |
1307 | jz @f |
1308 | ret |
1308 | ret |
1309 | @@: |
1309 | @@: |
1310 | test esi, 0x08000000 |
1310 | test esi, 0x08000000 |
1311 | jz @f |
1311 | jz @f |
1312 | stdcall is_region_userspace, edi, 1 |
1312 | stdcall is_region_userspace, edi, 1 |
1313 | jz @f |
1313 | jz @f |
1314 | ret |
1314 | ret |
1315 | @@: |
1315 | @@: |
1316 | ;It is not optimization |
1316 | ;It is not optimization |
1317 | mov eax, ebx |
1317 | mov eax, ebx |
1318 | mov ebx, ecx |
1318 | mov ebx, ecx |
1319 | mov ecx, edx |
1319 | mov ecx, edx |
1320 | mov edx, esi |
1320 | mov edx, esi |
1321 | mov esi, edi |
1321 | mov esi, edi |
1322 | ; eax = print type, al=0 -> ebx is number |
1322 | ; eax = print type, al=0 -> ebx is number |
1323 | ; al=1 -> ebx is pointer |
1323 | ; al=1 -> ebx is pointer |
1324 | ; ah=0 -> display decimal |
1324 | ; ah=0 -> display decimal |
1325 | ; ah=1 -> display hexadecimal |
1325 | ; ah=1 -> display hexadecimal |
1326 | ; ah=2 -> display binary |
1326 | ; ah=2 -> display binary |
1327 | ; eax bits 16-21 = number of digits to display (0-32) |
1327 | ; eax bits 16-21 = number of digits to display (0-32) |
1328 | ; eax bits 22-31 = reserved |
1328 | ; eax bits 22-31 = reserved |
1329 | ; |
1329 | ; |
1330 | ; ebx = number or pointer |
1330 | ; ebx = number or pointer |
1331 | ; ecx = x shl 16 + y |
1331 | ; ecx = x shl 16 + y |
1332 | ; edx = color |
1332 | ; edx = color |
1333 | xor edi, edi |
1333 | xor edi, edi |
1334 | display_number_force: |
1334 | display_number_force: |
1335 | push eax |
1335 | push eax |
1336 | and eax, 0x3fffffff |
1336 | and eax, 0x3fffffff |
1337 | cmp eax, 0xffff ; length > 0 ? |
1337 | cmp eax, 0xffff ; length > 0 ? |
1338 | pop eax |
1338 | pop eax |
1339 | jge .cont_displ |
1339 | jge .cont_displ |
1340 | ret |
1340 | ret |
1341 | .cont_displ: |
1341 | .cont_displ: |
1342 | push eax |
1342 | push eax |
1343 | and eax, 0x3fffffff |
1343 | and eax, 0x3fffffff |
1344 | cmp eax, 61*0x10000 ; length <= 60 ? |
1344 | cmp eax, 61*0x10000 ; length <= 60 ? |
1345 | pop eax |
1345 | pop eax |
1346 | jb .cont_displ2 |
1346 | jb .cont_displ2 |
1347 | ret |
1347 | ret |
1348 | .cont_displ2: |
1348 | .cont_displ2: |
1349 | 1349 | ||
1350 | pushad |
1350 | pushad |
1351 | 1351 | ||
1352 | cmp al, 1 ; ecx is a pointer ? |
1352 | cmp al, 1 ; ecx is a pointer ? |
1353 | jne @f |
1353 | jne @f |
1354 | mov ebp, ebx |
1354 | mov ebp, ebx |
1355 | add ebp, 4 |
1355 | add ebp, 4 |
1356 | mov ebp, [ebp] ;[ebp + std_application_base_address] |
1356 | mov ebp, [ebp] ;[ebp + std_application_base_address] |
1357 | mov ebx, [ebx] ;[ebx + std_application_base_address] |
1357 | mov ebx, [ebx] ;[ebx + std_application_base_address] |
1358 | @@: |
1358 | @@: |
1359 | sub esp, 64 |
1359 | sub esp, 64 |
1360 | 1360 | ||
1361 | test ah, ah ; DECIMAL |
1361 | test ah, ah ; DECIMAL |
1362 | jnz .no_display_desnum |
1362 | jnz .no_display_desnum |
1363 | 1363 | ||
1364 | shr eax, 16 |
1364 | shr eax, 16 |
1365 | and eax, 0xC03f |
1365 | and eax, 0xC03f |
1366 | ; and eax,0x3f |
1366 | ; and eax,0x3f |
1367 | push eax |
1367 | push eax |
1368 | and eax, 0x3f |
1368 | and eax, 0x3f |
1369 | mov edi, esp |
1369 | mov edi, esp |
1370 | add edi, 4+64-1 |
1370 | add edi, 4+64-1 |
1371 | mov ecx, eax |
1371 | mov ecx, eax |
1372 | mov eax, ebx |
1372 | mov eax, ebx |
1373 | mov ebx, 10 |
1373 | mov ebx, 10 |
1374 | @@: |
1374 | @@: |
1375 | xor edx, edx |
1375 | xor edx, edx |
1376 | call division_64_bits |
1376 | call division_64_bits |
1377 | div ebx |
1377 | div ebx |
1378 | add dl, 48 |
1378 | add dl, 48 |
1379 | mov [edi], dl |
1379 | mov [edi], dl |
1380 | dec edi |
1380 | dec edi |
1381 | loop @b |
1381 | loop @b |
1382 | 1382 | ||
1383 | pop eax |
1383 | pop eax |
1384 | call normalize_number |
1384 | call normalize_number |
1385 | call draw_num_text |
1385 | call draw_num_text |
1386 | add esp, 64 |
1386 | add esp, 64 |
1387 | popad |
1387 | popad |
1388 | ret |
1388 | ret |
1389 | .no_display_desnum: |
1389 | .no_display_desnum: |
1390 | 1390 | ||
1391 | cmp ah, 0x01 ; HEXADECIMAL |
1391 | cmp ah, 0x01 ; HEXADECIMAL |
1392 | jne .no_display_hexnum |
1392 | jne .no_display_hexnum |
1393 | 1393 | ||
1394 | shr eax, 16 |
1394 | shr eax, 16 |
1395 | and eax, 0xC03f |
1395 | and eax, 0xC03f |
1396 | ; and eax,0x3f |
1396 | ; and eax,0x3f |
1397 | push eax |
1397 | push eax |
1398 | and eax, 0x3f |
1398 | and eax, 0x3f |
1399 | mov edi, esp |
1399 | mov edi, esp |
1400 | add edi, 4+64-1 |
1400 | add edi, 4+64-1 |
1401 | mov ecx, eax |
1401 | mov ecx, eax |
1402 | mov eax, ebx |
1402 | mov eax, ebx |
1403 | mov ebx, 16 |
1403 | mov ebx, 16 |
1404 | @@: |
1404 | @@: |
1405 | xor edx, edx |
1405 | xor edx, edx |
1406 | call division_64_bits |
1406 | call division_64_bits |
1407 | div ebx |
1407 | div ebx |
1408 | ;hexletters = __fdo_hexdigits |
1408 | ;hexletters = __fdo_hexdigits |
1409 | add edx, __fdo_hexdigits ;hexletters |
1409 | add edx, __fdo_hexdigits ;hexletters |
1410 | mov dl, [edx] |
1410 | mov dl, [edx] |
1411 | mov [edi], dl |
1411 | mov [edi], dl |
1412 | dec edi |
1412 | dec edi |
1413 | loop @b |
1413 | loop @b |
1414 | 1414 | ||
1415 | pop eax |
1415 | pop eax |
1416 | call normalize_number |
1416 | call normalize_number |
1417 | call draw_num_text |
1417 | call draw_num_text |
1418 | add esp, 64 |
1418 | add esp, 64 |
1419 | popad |
1419 | popad |
1420 | ret |
1420 | ret |
1421 | .no_display_hexnum: |
1421 | .no_display_hexnum: |
1422 | 1422 | ||
1423 | cmp ah, 0x02 ; BINARY |
1423 | cmp ah, 0x02 ; BINARY |
1424 | jne .no_display_binnum |
1424 | jne .no_display_binnum |
1425 | 1425 | ||
1426 | shr eax, 16 |
1426 | shr eax, 16 |
1427 | and eax, 0xC03f |
1427 | and eax, 0xC03f |
1428 | ; and eax,0x3f |
1428 | ; and eax,0x3f |
1429 | push eax |
1429 | push eax |
1430 | and eax, 0x3f |
1430 | and eax, 0x3f |
1431 | mov edi, esp |
1431 | mov edi, esp |
1432 | add edi, 4+64-1 |
1432 | add edi, 4+64-1 |
1433 | mov ecx, eax |
1433 | mov ecx, eax |
1434 | mov eax, ebx |
1434 | mov eax, ebx |
1435 | mov ebx, 2 |
1435 | mov ebx, 2 |
1436 | @@: |
1436 | @@: |
1437 | xor edx, edx |
1437 | xor edx, edx |
1438 | call division_64_bits |
1438 | call division_64_bits |
1439 | div ebx |
1439 | div ebx |
1440 | add dl, 48 |
1440 | add dl, 48 |
1441 | mov [edi], dl |
1441 | mov [edi], dl |
1442 | dec edi |
1442 | dec edi |
1443 | loop @b |
1443 | loop @b |
1444 | 1444 | ||
1445 | pop eax |
1445 | pop eax |
1446 | call normalize_number |
1446 | call normalize_number |
1447 | call draw_num_text |
1447 | call draw_num_text |
1448 | add esp, 64 |
1448 | add esp, 64 |
1449 | popad |
1449 | popad |
1450 | ret |
1450 | ret |
1451 | .no_display_binnum: |
1451 | .no_display_binnum: |
1452 | 1452 | ||
1453 | add esp, 64 |
1453 | add esp, 64 |
1454 | popad |
1454 | popad |
1455 | ret |
1455 | ret |
1456 | 1456 | ||
1457 | normalize_number: |
1457 | normalize_number: |
1458 | test ah, 0x80 |
1458 | test ah, 0x80 |
1459 | jz .continue |
1459 | jz .continue |
1460 | mov ecx, 48 |
1460 | mov ecx, 48 |
1461 | and eax, 0x3f |
1461 | and eax, 0x3f |
1462 | @@: |
1462 | @@: |
1463 | inc edi |
1463 | inc edi |
1464 | cmp [edi], cl |
1464 | cmp [edi], cl |
1465 | jne .continue |
1465 | jne .continue |
1466 | dec eax |
1466 | dec eax |
1467 | cmp eax, 1 |
1467 | cmp eax, 1 |
1468 | ja @r |
1468 | ja @r |
1469 | mov al, 1 |
1469 | mov al, 1 |
1470 | .continue: |
1470 | .continue: |
1471 | and eax, 0x3f |
1471 | and eax, 0x3f |
1472 | ret |
1472 | ret |
1473 | 1473 | ||
1474 | division_64_bits: |
1474 | division_64_bits: |
1475 | test [esp+1+4], byte 0x40 |
1475 | test [esp+1+4], byte 0x40 |
1476 | jz .continue |
1476 | jz .continue |
1477 | push eax |
1477 | push eax |
1478 | mov eax, ebp |
1478 | mov eax, ebp |
1479 | div ebx |
1479 | div ebx |
1480 | mov ebp, eax |
1480 | mov ebp, eax |
1481 | pop eax |
1481 | pop eax |
1482 | .continue: |
1482 | .continue: |
1483 | ret |
1483 | ret |
1484 | 1484 | ||
1485 | draw_num_text: |
1485 | draw_num_text: |
1486 | mov esi, eax |
1486 | mov esi, eax |
1487 | mov edx, 64+4 |
1487 | mov edx, 64+4 |
1488 | sub edx, eax |
1488 | sub edx, eax |
1489 | add edx, esp |
1489 | add edx, esp |
1490 | mov ebx, [esp+64+32-8+4] |
1490 | mov ebx, [esp+64+32-8+4] |
1491 | ; add window start x & y |
1491 | ; add window start x & y |
1492 | 1492 | ||
1493 | mov ecx, [current_slot] |
1493 | mov ecx, [current_slot] |
1494 | mov ecx, [ecx + APPDATA.window] |
1494 | mov ecx, [ecx + APPDATA.window] |
1495 | 1495 | ||
1496 | mov eax, [ecx + WDATA.box.left] |
1496 | mov eax, [ecx + WDATA.box.left] |
1497 | add eax, [ecx + WDATA.clientbox.left] |
1497 | add eax, [ecx + WDATA.clientbox.left] |
1498 | shl eax, 16 |
1498 | shl eax, 16 |
1499 | add eax, [ecx + WDATA.box.top] |
1499 | add eax, [ecx + WDATA.box.top] |
1500 | add eax, [ecx + WDATA.clientbox.top] |
1500 | add eax, [ecx + WDATA.clientbox.top] |
1501 | add ebx, eax |
1501 | add ebx, eax |
1502 | mov ecx, [esp+64+32-12+4] |
1502 | mov ecx, [esp+64+32-12+4] |
1503 | mov eax, [esp+64+8] ; background color (if given) |
1503 | mov eax, [esp+64+8] ; background color (if given) |
1504 | mov edi, [esp+64+4] |
1504 | mov edi, [esp+64+4] |
1505 | and ecx, 5FFFFFFFh |
1505 | and ecx, 5FFFFFFFh |
1506 | bt ecx, 27 |
1506 | bt ecx, 27 |
1507 | jnc @f |
1507 | jnc @f |
1508 | mov edi, eax |
1508 | mov edi, eax |
1509 | @@: |
1509 | @@: |
1510 | jmp dtext |
1510 | jmp dtext |
1511 | ;----------------------------------------------------------------------------- |
1511 | ;----------------------------------------------------------------------------- |
1512 | align 4 |
1512 | align 4 |
1513 | sys_setup: |
1513 | sys_setup: |
1514 | ; 1 = roland mpu midi base , base io address |
1514 | ; 1 = roland mpu midi base , base io address |
1515 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1515 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1516 | ; 3 = not used |
1516 | ; 3 = not used |
1517 | ; 4 = not used |
1517 | ; 4 = not used |
1518 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1518 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1519 | ; 6 = not used |
1519 | ; 6 = not used |
1520 | ; 7 = not used |
1520 | ; 7 = not used |
1521 | ; 8 = not used |
1521 | ; 8 = not used |
1522 | ; 9 = not used |
1522 | ; 9 = not used |
1523 | ; 10 = not used |
1523 | ; 10 = not used |
1524 | ; 11 = enable lba read |
1524 | ; 11 = enable lba read |
1525 | ; 12 = enable pci access |
1525 | ; 12 = enable pci access |
1526 | ;----------------------------------------------------------------------------- |
1526 | ;----------------------------------------------------------------------------- |
1527 | and [esp + SYSCALL_STACK.eax], 0 |
1527 | and [esp + SYSCALL_STACK.eax], 0 |
1528 | ; F.21.1 - set MPU MIDI base port |
1528 | ; F.21.1 - set MPU MIDI base port |
1529 | dec ebx |
1529 | dec ebx |
1530 | jnz @f |
1530 | jnz @f |
1531 | 1531 | ||
1532 | cmp ecx, 0x100 |
1532 | cmp ecx, 0x100 |
1533 | jb @f |
1533 | jb @f |
1534 | 1534 | ||
1535 | mov esi, 65535 |
1535 | mov esi, 65535 |
1536 | cmp esi, ecx |
1536 | cmp esi, ecx |
1537 | jb @f |
1537 | jb @f |
1538 | 1538 | ||
1539 | mov [midi_base], cx |
1539 | mov [midi_base], cx |
1540 | mov word [mididp], cx |
1540 | mov word [mididp], cx |
1541 | inc cx |
1541 | inc cx |
1542 | mov word [midisp], cx |
1542 | mov word [midisp], cx |
1543 | ret |
1543 | ret |
1544 | ;-------------------------------------- |
1544 | ;-------------------------------------- |
1545 | @@: |
1545 | @@: |
1546 | ; F.21.2 - set keyboard layout |
1546 | ; F.21.2 - set keyboard layout |
1547 | dec ebx |
1547 | dec ebx |
1548 | jnz @f |
1548 | jnz @f |
1549 | 1549 | ||
1550 | mov eax, edx |
1550 | mov eax, edx |
1551 | ; 1 = normal layout |
1551 | ; 1 = normal layout |
1552 | dec ecx |
1552 | dec ecx |
1553 | jnz .shift |
1553 | jnz .shift |
1554 | 1554 | ||
1555 | mov ebx, keymap |
1555 | mov ebx, keymap |
1556 | mov ecx, 128 |
1556 | mov ecx, 128 |
1557 | call memmove |
1557 | call memmove |
1558 | ret |
1558 | ret |
1559 | ;-------------------------------------- |
1559 | ;-------------------------------------- |
1560 | .shift: |
1560 | .shift: |
1561 | ; 2 = layout at pressed Shift |
1561 | ; 2 = layout at pressed Shift |
1562 | dec ecx |
1562 | dec ecx |
1563 | jnz .alt |
1563 | jnz .alt |
1564 | 1564 | ||
1565 | mov ebx, keymap_shift |
1565 | mov ebx, keymap_shift |
1566 | mov ecx, 128 |
1566 | mov ecx, 128 |
1567 | call memmove |
1567 | call memmove |
1568 | ret |
1568 | ret |
1569 | ;-------------------------------------- |
1569 | ;-------------------------------------- |
1570 | .alt: |
1570 | .alt: |
1571 | ; 3 = layout at pressed Alt |
1571 | ; 3 = layout at pressed Alt |
1572 | dec ecx |
1572 | dec ecx |
1573 | jnz .country |
1573 | jnz .country |
1574 | 1574 | ||
1575 | mov ebx, keymap_alt |
1575 | mov ebx, keymap_alt |
1576 | mov ecx, 128 |
1576 | mov ecx, 128 |
1577 | call memmove |
1577 | call memmove |
1578 | ret |
1578 | ret |
1579 | ;-------------------------------------- |
1579 | ;-------------------------------------- |
1580 | .country: |
1580 | .country: |
1581 | ; country identifier |
1581 | ; country identifier |
1582 | sub ecx, 6 |
1582 | sub ecx, 6 |
1583 | jnz .error |
1583 | jnz .error |
1584 | 1584 | ||
1585 | mov word [keyboard], dx |
1585 | mov word [keyboard], dx |
1586 | ret |
1586 | ret |
1587 | ;-------------------------------------- |
1587 | ;-------------------------------------- |
1588 | @@: |
1588 | @@: |
1589 | ; F.21.5 - set system language |
1589 | ; F.21.5 - set system language |
1590 | sub ebx, 3 |
1590 | sub ebx, 3 |
1591 | jnz @f |
1591 | jnz @f |
1592 | 1592 | ||
1593 | mov [syslang], ecx |
1593 | mov [syslang], ecx |
1594 | ret |
1594 | ret |
1595 | ;-------------------------------------- |
1595 | ;-------------------------------------- |
1596 | @@: |
1596 | @@: |
1597 | ; F.21.11 - enable/disable low-level access to HD |
1597 | ; F.21.11 - enable/disable low-level access to HD |
1598 | and ecx, 1 |
1598 | and ecx, 1 |
1599 | sub ebx, 6 |
1599 | sub ebx, 6 |
1600 | jnz @f |
1600 | jnz @f |
1601 | 1601 | ||
1602 | mov [lba_read_enabled], ecx |
1602 | mov [lba_read_enabled], ecx |
1603 | ret |
1603 | ret |
1604 | ;-------------------------------------- |
1604 | ;-------------------------------------- |
1605 | @@: |
1605 | @@: |
1606 | ; F.21.12 - enable/disable low-level access to PCI |
1606 | ; F.21.12 - enable/disable low-level access to PCI |
1607 | dec ebx |
1607 | dec ebx |
1608 | jnz .error |
1608 | jnz .error |
1609 | 1609 | ||
1610 | mov [pci_access_enabled], ecx |
1610 | mov [pci_access_enabled], ecx |
1611 | ret |
1611 | ret |
1612 | ;-------------------------------------- |
1612 | ;-------------------------------------- |
1613 | .error: |
1613 | .error: |
1614 | or [esp + SYSCALL_STACK.eax], -1 |
1614 | or [esp + SYSCALL_STACK.eax], -1 |
1615 | ret |
1615 | ret |
1616 | ;----------------------------------------------------------------------------- |
1616 | ;----------------------------------------------------------------------------- |
1617 | align 4 |
1617 | align 4 |
1618 | sys_getsetup: |
1618 | sys_getsetup: |
1619 | ; 1 = roland mpu midi base , base io address |
1619 | ; 1 = roland mpu midi base , base io address |
1620 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1620 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1621 | ; 3 = not used |
1621 | ; 3 = not used |
1622 | ; 4 = not used |
1622 | ; 4 = not used |
1623 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1623 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1624 | ; 6 = not used |
1624 | ; 6 = not used |
1625 | ; 7 = not used |
1625 | ; 7 = not used |
1626 | ; 8 = not used |
1626 | ; 8 = not used |
1627 | ; 9 = get hs timer tic |
1627 | ; 9 = get hs timer tic |
1628 | ; 10 = not used |
1628 | ; 10 = not used |
1629 | ; 11 = get the state "lba read" |
1629 | ; 11 = get the state "lba read" |
1630 | ; 12 = get the state "pci access" |
1630 | ; 12 = get the state "pci access" |
1631 | ;----------------------------------------------------------------------------- |
1631 | ;----------------------------------------------------------------------------- |
1632 | ; F.26.1 - get MPU MIDI base port |
1632 | ; F.26.1 - get MPU MIDI base port |
1633 | dec ebx |
1633 | dec ebx |
1634 | jnz @f |
1634 | jnz @f |
1635 | 1635 | ||
1636 | movzx eax, [midi_base] |
1636 | movzx eax, [midi_base] |
1637 | mov [esp + SYSCALL_STACK.eax], eax |
1637 | mov [esp + SYSCALL_STACK.eax], eax |
1638 | ret |
1638 | ret |
1639 | ;-------------------------------------- |
1639 | ;-------------------------------------- |
1640 | @@: |
1640 | @@: |
1641 | ; F.26.2 - get keyboard layout |
1641 | ; F.26.2 - get keyboard layout |
1642 | dec ebx |
1642 | dec ebx |
1643 | jnz @f |
1643 | jnz @f |
1644 | 1644 | ||
1645 | mov ebx, edx |
1645 | mov ebx, edx |
1646 | ; if given memory address belongs to kernel then error |
1646 | ; if given memory address belongs to kernel then error |
1647 | stdcall is_region_userspace, ebx, 128 |
1647 | stdcall is_region_userspace, ebx, 128 |
1648 | jnz .addr_error |
1648 | jnz .addr_error |
1649 | ; 1 = normal layout |
1649 | ; 1 = normal layout |
1650 | dec ecx |
1650 | dec ecx |
1651 | jnz .shift |
1651 | jnz .shift |
1652 | 1652 | ||
1653 | mov eax, keymap |
1653 | mov eax, keymap |
1654 | mov ecx, 128 |
1654 | mov ecx, 128 |
1655 | call memmove |
1655 | call memmove |
1656 | ret |
1656 | ret |
1657 | ;-------------------------------------- |
1657 | ;-------------------------------------- |
1658 | .shift: |
1658 | .shift: |
1659 | ; 2 = layout with pressed Shift |
1659 | ; 2 = layout with pressed Shift |
1660 | dec ecx |
1660 | dec ecx |
1661 | jnz .alt |
1661 | jnz .alt |
1662 | 1662 | ||
1663 | mov eax, keymap_shift |
1663 | mov eax, keymap_shift |
1664 | mov ecx, 128 |
1664 | mov ecx, 128 |
1665 | call memmove |
1665 | call memmove |
1666 | ret |
1666 | ret |
1667 | ;-------------------------------------- |
1667 | ;-------------------------------------- |
1668 | .alt: |
1668 | .alt: |
1669 | ; 3 = layout with pressed Alt |
1669 | ; 3 = layout with pressed Alt |
1670 | dec ecx |
1670 | dec ecx |
1671 | jne .country |
1671 | jne .country |
1672 | 1672 | ||
1673 | mov eax, keymap_alt |
1673 | mov eax, keymap_alt |
1674 | mov ecx, 128 |
1674 | mov ecx, 128 |
1675 | call memmove |
1675 | call memmove |
1676 | ret |
1676 | ret |
1677 | ;-------------------------------------- |
1677 | ;-------------------------------------- |
1678 | .country: |
1678 | .country: |
1679 | ; 9 = country identifier |
1679 | ; 9 = country identifier |
1680 | sub ecx, 6 |
1680 | sub ecx, 6 |
1681 | jnz .error |
1681 | jnz .error |
1682 | 1682 | ||
1683 | movzx eax, word [keyboard] |
1683 | movzx eax, word [keyboard] |
1684 | mov [esp + SYSCALL_STACK.eax], eax |
1684 | mov [esp + SYSCALL_STACK.eax], eax |
1685 | ret |
1685 | ret |
1686 | 1686 | ||
1687 | .addr_error: ; if given memory address is illegal |
1687 | .addr_error: ; if given memory address is illegal |
1688 | or [esp + SYSCALL_STACK.eax], -1 |
1688 | or [esp + SYSCALL_STACK.eax], -1 |
1689 | ret |
1689 | ret |
1690 | ;-------------------------------------- |
1690 | ;-------------------------------------- |
1691 | @@: |
1691 | @@: |
1692 | ; F.26.5 - get system language |
1692 | ; F.26.5 - get system language |
1693 | sub ebx, 3 |
1693 | sub ebx, 3 |
1694 | jnz @f |
1694 | jnz @f |
1695 | 1695 | ||
1696 | mov eax, [syslang] |
1696 | mov eax, [syslang] |
1697 | mov [esp + SYSCALL_STACK.eax], eax |
1697 | mov [esp + SYSCALL_STACK.eax], eax |
1698 | ret |
1698 | ret |
1699 | ;-------------------------------------- |
1699 | ;-------------------------------------- |
1700 | @@: |
1700 | @@: |
1701 | ; F.26.9 - get the value of the time counter |
1701 | ; F.26.9 - get the value of the time counter |
1702 | sub ebx, 4 |
1702 | sub ebx, 4 |
1703 | jnz @f |
1703 | jnz @f |
1704 | 1704 | ||
1705 | mov eax, [timer_ticks] |
1705 | mov eax, [timer_ticks] |
1706 | mov [esp + SYSCALL_STACK.eax], eax |
1706 | mov [esp + SYSCALL_STACK.eax], eax |
1707 | ret |
1707 | ret |
1708 | ;-------------------------------------- |
1708 | ;-------------------------------------- |
1709 | @@: |
1709 | @@: |
1710 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1710 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1711 | dec ebx |
1711 | dec ebx |
1712 | jnz @f |
1712 | jnz @f |
1713 | 1713 | ||
1714 | call get_clock_ns |
1714 | call get_clock_ns |
1715 | mov [esp + SYSCALL_STACK.edx], edx |
1715 | mov [esp + SYSCALL_STACK.edx], edx |
1716 | mov [esp + SYSCALL_STACK.eax], eax |
1716 | mov [esp + SYSCALL_STACK.eax], eax |
1717 | ret |
1717 | ret |
1718 | ;-------------------------------------- |
1718 | ;-------------------------------------- |
1719 | @@: |
1719 | @@: |
1720 | ; F.26.11 - Find out whether low-level HD access is enabled |
1720 | ; F.26.11 - Find out whether low-level HD access is enabled |
1721 | dec ebx |
1721 | dec ebx |
1722 | jnz @f |
1722 | jnz @f |
1723 | 1723 | ||
1724 | mov eax, [lba_read_enabled] |
1724 | mov eax, [lba_read_enabled] |
1725 | mov [esp + SYSCALL_STACK.eax], eax |
1725 | mov [esp + SYSCALL_STACK.eax], eax |
1726 | ret |
1726 | ret |
1727 | ;-------------------------------------- |
1727 | ;-------------------------------------- |
1728 | @@: |
1728 | @@: |
1729 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1729 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1730 | dec ebx |
1730 | dec ebx |
1731 | jnz .error |
1731 | jnz .error |
1732 | 1732 | ||
1733 | mov eax, [pci_access_enabled] |
1733 | mov eax, [pci_access_enabled] |
1734 | mov [esp + SYSCALL_STACK.eax], eax |
1734 | mov [esp + SYSCALL_STACK.eax], eax |
1735 | ret |
1735 | ret |
1736 | ;-------------------------------------- |
1736 | ;-------------------------------------- |
1737 | .error: |
1737 | .error: |
1738 | or [esp + SYSCALL_STACK.eax], -1 |
1738 | or [esp + SYSCALL_STACK.eax], -1 |
1739 | ret |
1739 | ret |
1740 | ;----------------------------------------------------------------------------- |
1740 | ;----------------------------------------------------------------------------- |
1741 | get_timer_ticks: |
1741 | get_timer_ticks: |
1742 | mov eax, [timer_ticks] |
1742 | mov eax, [timer_ticks] |
1743 | ret |
1743 | ret |
1744 | ;----------------------------------------------------------------------------- |
1744 | ;----------------------------------------------------------------------------- |
1745 | iglobal |
1745 | iglobal |
1746 | midi_base dw 0 |
1746 | midi_base dw 0 |
1747 | endg |
1747 | endg |
1748 | 1748 | ||
1749 | align 4 |
1749 | align 4 |
1750 | sys_midi: |
1750 | sys_midi: |
1751 | cmp word [mididp], 0 |
1751 | cmp word [mididp], 0 |
1752 | jnz @f |
1752 | jnz @f |
1753 | mov [esp + SYSCALL_STACK.eax], 1 |
1753 | mov [esp + SYSCALL_STACK.eax], 1 |
1754 | ret |
1754 | ret |
1755 | @@: |
1755 | @@: |
1756 | and [esp + SYSCALL_STACK.eax], 0 |
1756 | and [esp + SYSCALL_STACK.eax], 0 |
1757 | dec ebx |
1757 | dec ebx |
1758 | jnz .smn1 |
1758 | jnz .smn1 |
1759 | ; call setuart |
1759 | ; call setuart |
1760 | @@: |
1760 | @@: |
1761 | call .is_output |
1761 | call .is_output |
1762 | test al, al |
1762 | test al, al |
1763 | jnz @b |
1763 | jnz @b |
1764 | mov dx, word [midisp] |
1764 | mov dx, word [midisp] |
1765 | mov al, 0xff |
1765 | mov al, 0xff |
1766 | out dx, al |
1766 | out dx, al |
1767 | @@: |
1767 | @@: |
1768 | mov dx, word [midisp] |
1768 | mov dx, word [midisp] |
1769 | mov al, 0xff |
1769 | mov al, 0xff |
1770 | out dx, al |
1770 | out dx, al |
1771 | call .is_input |
1771 | call .is_input |
1772 | test al, al |
1772 | test al, al |
1773 | jnz @b |
1773 | jnz @b |
1774 | call .get_mpu_in |
1774 | call .get_mpu_in |
1775 | cmp al, 0xfe |
1775 | cmp al, 0xfe |
1776 | jnz @b |
1776 | jnz @b |
1777 | @@: |
1777 | @@: |
1778 | call .is_output |
1778 | call .is_output |
1779 | test al, al |
1779 | test al, al |
1780 | jnz @b |
1780 | jnz @b |
1781 | mov dx, word [midisp] |
1781 | mov dx, word [midisp] |
1782 | mov al, 0x3f |
1782 | mov al, 0x3f |
1783 | out dx, al |
1783 | out dx, al |
1784 | ret |
1784 | ret |
1785 | .smn1: |
1785 | .smn1: |
1786 | dec ebx |
1786 | dec ebx |
1787 | jnz .ret |
1787 | jnz .ret |
1788 | @@: |
1788 | @@: |
1789 | call .get_mpu_in |
1789 | call .get_mpu_in |
1790 | call .is_output |
1790 | call .is_output |
1791 | test al, al |
1791 | test al, al |
1792 | jnz @b |
1792 | jnz @b |
1793 | mov al, bl |
1793 | mov al, bl |
1794 | call .put_mpu_out |
1794 | call .put_mpu_out |
1795 | .ret: |
1795 | .ret: |
1796 | ret |
1796 | ret |
1797 | 1797 | ||
1798 | .is_input: |
1798 | .is_input: |
1799 | push edx |
1799 | push edx |
1800 | mov dx, word [midisp] |
1800 | mov dx, word [midisp] |
1801 | in al, dx |
1801 | in al, dx |
1802 | and al, 0x80 |
1802 | and al, 0x80 |
1803 | pop edx |
1803 | pop edx |
1804 | ret |
1804 | ret |
1805 | 1805 | ||
1806 | .is_output: |
1806 | .is_output: |
1807 | push edx |
1807 | push edx |
1808 | mov dx, word [midisp] |
1808 | mov dx, word [midisp] |
1809 | in al, dx |
1809 | in al, dx |
1810 | and al, 0x40 |
1810 | and al, 0x40 |
1811 | pop edx |
1811 | pop edx |
1812 | ret |
1812 | ret |
1813 | 1813 | ||
1814 | .get_mpu_in: |
1814 | .get_mpu_in: |
1815 | push edx |
1815 | push edx |
1816 | mov dx, word [mididp] |
1816 | mov dx, word [mididp] |
1817 | in al, dx |
1817 | in al, dx |
1818 | pop edx |
1818 | pop edx |
1819 | ret |
1819 | ret |
1820 | 1820 | ||
1821 | .put_mpu_out: |
1821 | .put_mpu_out: |
1822 | push edx |
1822 | push edx |
1823 | mov dx, word [mididp] |
1823 | mov dx, word [mididp] |
1824 | out dx, al |
1824 | out dx, al |
1825 | pop edx |
1825 | pop edx |
1826 | ret |
1826 | ret |
1827 | 1827 | ||
1828 | ;----------------------------------------------------------------------------- |
1828 | ;----------------------------------------------------------------------------- |
1829 | sys_end: |
1829 | sys_end: |
1830 | ; restore default cursor before killing |
1830 | ; restore default cursor before killing |
1831 | pusha |
1831 | pusha |
1832 | mov ecx, [current_slot] |
1832 | mov ecx, [current_slot] |
1833 | mov ecx, [ecx + APPDATA.window] |
1833 | mov ecx, [ecx + APPDATA.window] |
1834 | call restore_default_cursor_before_killing |
1834 | call restore_default_cursor_before_killing |
1835 | popa |
1835 | popa |
1836 | ;-------------------------------------- |
1836 | ;-------------------------------------- |
1837 | ; kill all sockets this process owns |
1837 | ; kill all sockets this process owns |
1838 | pusha |
1838 | pusha |
1839 | mov edx, [current_slot] |
1839 | mov edx, [current_slot] |
1840 | mov edx, [edx + APPDATA.tid] |
1840 | mov edx, [edx + APPDATA.tid] |
1841 | call socket_process_end |
1841 | call socket_process_end |
1842 | popa |
1842 | popa |
1843 | ;-------------------------------------- |
1843 | ;-------------------------------------- |
1844 | mov ecx, [current_slot] |
1844 | mov ecx, [current_slot] |
1845 | mov eax, [ecx + APPDATA.tls_base] |
1845 | mov eax, [ecx + APPDATA.tls_base] |
1846 | test eax, eax |
1846 | test eax, eax |
1847 | jz @F |
1847 | jz @F |
1848 | 1848 | ||
1849 | stdcall user_free, eax |
1849 | stdcall user_free, eax |
1850 | @@: |
1850 | @@: |
1851 | 1851 | ||
1852 | mov eax, [current_slot] |
1852 | mov eax, [current_slot] |
1853 | mov [eax + APPDATA.state], TSTATE_ZOMBIE |
1853 | mov [eax + APPDATA.state], TSTATE_ZOMBIE |
1854 | call wakeup_osloop |
1854 | call wakeup_osloop |
1855 | 1855 | ||
1856 | .waitterm: ; wait here for termination |
1856 | .waitterm: ; wait here for termination |
1857 | call change_task |
1857 | call change_task |
1858 | jmp .waitterm |
1858 | jmp .waitterm |
1859 | ;------------------------------------------------------------------------------ |
1859 | ;------------------------------------------------------------------------------ |
1860 | align 4 |
1860 | align 4 |
1861 | ; ecx - ptr WDATA |
1861 | ; ecx - ptr WDATA |
1862 | restore_default_cursor_before_killing: |
1862 | restore_default_cursor_before_killing: |
1863 | pushfd |
1863 | pushfd |
1864 | cli |
1864 | cli |
1865 | mov eax, [def_cursor] |
1865 | mov eax, [def_cursor] |
1866 | mov [ecx + WDATA.cursor], eax |
1866 | mov [ecx + WDATA.cursor], eax |
1867 | 1867 | ||
1868 | movzx eax, word [MOUSE_Y] |
1868 | movzx eax, word [MOUSE_Y] |
1869 | movzx ebx, word [MOUSE_X] |
1869 | movzx ebx, word [MOUSE_X] |
1870 | mov eax, [d_width_calc_area + eax*4] |
1870 | mov eax, [d_width_calc_area + eax*4] |
1871 | 1871 | ||
1872 | add eax, [_display.win_map] |
1872 | add eax, [_display.win_map] |
1873 | movzx edx, byte [ebx + eax] |
1873 | movzx edx, byte [ebx + eax] |
1874 | shl edx, BSF sizeof.WDATA |
1874 | shl edx, BSF sizeof.WDATA |
1875 | mov esi, [window_data + edx + WDATA.cursor] |
1875 | mov esi, [window_data + edx + WDATA.cursor] |
1876 | 1876 | ||
1877 | cmp esi, [current_cursor] |
1877 | cmp esi, [current_cursor] |
1878 | je @f |
1878 | je @f |
1879 | 1879 | ||
1880 | cmp [_display.select_cursor], 0 |
1880 | cmp [_display.select_cursor], 0 |
1881 | jz @f |
1881 | jz @f |
1882 | 1882 | ||
1883 | stdcall [_display.select_cursor], esi |
1883 | stdcall [_display.select_cursor], esi |
1884 | mov [current_cursor], esi |
1884 | mov [current_cursor], esi |
1885 | @@: |
1885 | @@: |
1886 | mov [redrawmouse_unconditional], 1 |
1886 | mov [redrawmouse_unconditional], 1 |
1887 | call wakeup_osloop |
1887 | call wakeup_osloop |
1888 | popfd |
1888 | popfd |
1889 | ret |
1889 | ret |
1890 | ;------------------------------------------------------------------------------ |
1890 | ;------------------------------------------------------------------------------ |
1891 | iglobal |
1891 | iglobal |
1892 | align 4 |
1892 | align 4 |
1893 | sys_system_table: |
1893 | sys_system_table: |
1894 | dd sysfn_deactivate ; 1 = deactivate window |
1894 | dd sysfn_deactivate ; 1 = deactivate window |
1895 | dd sysfn_terminate ; 2 = terminate thread |
1895 | dd sysfn_terminate ; 2 = terminate thread |
1896 | dd sysfn_activate ; 3 = activate window |
1896 | dd sysfn_activate ; 3 = activate window |
1897 | dd sysfn_getidletime ; 4 = get idle time |
1897 | dd sysfn_getidletime ; 4 = get idle time |
1898 | dd sysfn_getcpuclock ; 5 = get cpu clock |
1898 | dd sysfn_getcpuclock ; 5 = get cpu clock |
1899 | dd sysfn_saveramdisk ; 6 = save ramdisk |
1899 | dd sysfn_saveramdisk ; 6 = save ramdisk |
1900 | dd sysfn_getactive ; 7 = get active window |
1900 | dd sysfn_getactive ; 7 = get active window |
1901 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
1901 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
1902 | dd sysfn_shutdown ; 9 = shutdown with parameter |
1902 | dd sysfn_shutdown ; 9 = shutdown with parameter |
1903 | dd sysfn_minimize ; 10 = minimize window |
1903 | dd sysfn_minimize ; 10 = minimize window |
1904 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
1904 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
1905 | dd undefined_syscall ; 12 = get last pressed key. function removed. sysfn_lastkey |
1905 | dd undefined_syscall ; 12 = get last pressed key. function removed. sysfn_lastkey |
1906 | dd sysfn_getversion ; 13 = get kernel version |
1906 | dd sysfn_getversion ; 13 = get kernel version |
1907 | dd sysfn_waitretrace ; 14 = wait retrace |
1907 | dd sysfn_waitretrace ; 14 = wait retrace |
1908 | dd sysfn_centermouse ; 15 = center mouse cursor |
1908 | dd sysfn_centermouse ; 15 = center mouse cursor |
1909 | dd sysfn_getfreemem ; 16 = get free memory size |
1909 | dd sysfn_getfreemem ; 16 = get free memory size |
1910 | dd sysfn_getallmem ; 17 = get total memory size |
1910 | dd sysfn_getallmem ; 17 = get total memory size |
1911 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
1911 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
1912 | ; instead of slot |
1912 | ; instead of slot |
1913 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
1913 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
1914 | dd sysfn_meminfo ; 20 = get extended memory info |
1914 | dd sysfn_meminfo ; 20 = get extended memory info |
1915 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
1915 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
1916 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
1916 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
1917 | dd sysfn_min_windows ; 23 = minimize all windows |
1917 | dd sysfn_min_windows ; 23 = minimize all windows |
1918 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
1918 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
1919 | 1919 | ||
1920 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
1920 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
1921 | sysfn_num = ($ - sys_system_table)/4 |
1921 | sysfn_num = ($ - sys_system_table)/4 |
1922 | endg |
1922 | endg |
1923 | ;------------------------------------------------------------------------------ |
1923 | ;------------------------------------------------------------------------------ |
1924 | sys_system: |
1924 | sys_system: |
1925 | dec ebx |
1925 | dec ebx |
1926 | cmp ebx, sysfn_num |
1926 | cmp ebx, sysfn_num |
1927 | jae @f |
1927 | jae @f |
1928 | jmp dword [sys_system_table + ebx*4] |
1928 | jmp dword [sys_system_table + ebx*4] |
1929 | @@: |
1929 | @@: |
1930 | ret |
1930 | ret |
1931 | ;------------------------------------------------------------------------------ |
1931 | ;------------------------------------------------------------------------------ |
1932 | sysfn_shutdown: ; 18.9 = system shutdown |
1932 | sysfn_shutdown: ; 18.9 = system shutdown |
1933 | cmp ecx, SYSTEM_SHUTDOWN |
1933 | cmp ecx, SYSTEM_SHUTDOWN |
1934 | jl .exit_for_anyone |
1934 | jl .exit_for_anyone |
1935 | cmp ecx, SYSTEM_RESTART |
1935 | cmp ecx, SYSTEM_RESTART |
1936 | jg .exit_for_anyone |
1936 | jg .exit_for_anyone |
1937 | mov [BOOT.shutdown_type], cl |
1937 | mov [BOOT.shutdown_type], cl |
1938 | 1938 | ||
1939 | mov eax, [thread_count] |
1939 | mov eax, [thread_count] |
1940 | mov [SYS_SHUTDOWN], al |
1940 | mov [SYS_SHUTDOWN], al |
1941 | mov [shutdown_processes], eax |
1941 | mov [shutdown_processes], eax |
1942 | call wakeup_osloop |
1942 | call wakeup_osloop |
1943 | and [esp + SYSCALL_STACK.eax], 0 |
1943 | and [esp + SYSCALL_STACK.eax], 0 |
1944 | .exit_for_anyone: |
1944 | .exit_for_anyone: |
1945 | ret |
1945 | ret |
1946 | uglobal |
1946 | uglobal |
1947 | shutdown_processes: |
1947 | shutdown_processes: |
1948 | dd 0x0 |
1948 | dd 0x0 |
1949 | endg |
1949 | endg |
1950 | ;------------------------------------------------------------------------------ |
1950 | ;------------------------------------------------------------------------------ |
1951 | ; in: eax -- APPDATA ptr |
1951 | ; in: eax -- APPDATA ptr |
1952 | ; out: Z/z -- is/not kernel thread |
1952 | ; out: Z/z -- is/not kernel thread |
1953 | is_kernel_thread: |
1953 | is_kernel_thread: |
1954 | mov eax, [eax + APPDATA.process] |
1954 | mov eax, [eax + APPDATA.process] |
1955 | cmp eax, [SLOT_BASE + 2*sizeof.APPDATA + APPDATA.process] ; OS |
1955 | cmp eax, [SLOT_BASE + 2*sizeof.APPDATA + APPDATA.process] ; OS |
1956 | ret |
1956 | ret |
1957 | ;------------------------------------------------------------------------------ |
1957 | ;------------------------------------------------------------------------------ |
1958 | sysfn_terminate: ; 18.2 = TERMINATE |
1958 | sysfn_terminate: ; 18.2 = TERMINATE |
1959 | push ecx |
1959 | push ecx |
1960 | cmp ecx, 2 |
1960 | cmp ecx, 2 |
1961 | jb .noprocessterminate |
1961 | jb .noprocessterminate |
1962 | mov edx, [thread_count] |
1962 | mov edx, [thread_count] |
1963 | cmp ecx, edx |
1963 | cmp ecx, edx |
1964 | ja .noprocessterminate |
1964 | ja .noprocessterminate |
1965 | mov eax, [thread_count] |
1965 | mov eax, [thread_count] |
1966 | shl ecx, BSF sizeof.APPDATA |
1966 | shl ecx, BSF sizeof.APPDATA |
1967 | add ecx, SLOT_BASE |
1967 | add ecx, SLOT_BASE |
1968 | 1968 | ||
1969 | mov edx, [ecx + APPDATA.tid] |
1969 | mov edx, [ecx + APPDATA.tid] |
1970 | cmp byte [ecx + APPDATA.state], TSTATE_FREE |
1970 | cmp byte [ecx + APPDATA.state], TSTATE_FREE |
1971 | jz .noprocessterminate |
1971 | jz .noprocessterminate |
1972 | push eax |
1972 | push eax |
1973 | mov eax, ecx |
1973 | mov eax, ecx |
1974 | call is_kernel_thread |
1974 | call is_kernel_thread |
1975 | pop eax |
1975 | pop eax |
1976 | jz .noprocessterminate |
1976 | jz .noprocessterminate |
1977 | push ecx edx |
1977 | push ecx edx |
1978 | mov edx, ecx |
1978 | mov edx, ecx |
1979 | call request_terminate |
1979 | call request_terminate |
1980 | pop edx ecx |
1980 | pop edx ecx |
1981 | test eax, eax |
1981 | test eax, eax |
1982 | jz .noprocessterminate |
1982 | jz .noprocessterminate |
1983 | ;-------------------------------------- |
1983 | ;-------------------------------------- |
1984 | ; terminate all network sockets it used |
1984 | ; terminate all network sockets it used |
1985 | pusha |
1985 | pusha |
1986 | mov eax, edx ;TODO: check function |
1986 | mov eax, edx ;TODO: check function |
1987 | call socket_process_end |
1987 | call socket_process_end |
1988 | popa |
1988 | popa |
1989 | ;-------------------------------------- |
1989 | ;-------------------------------------- |
1990 | ; restore default cursor before killing |
1990 | ; restore default cursor before killing |
1991 | pusha |
1991 | pusha |
1992 | mov ecx, [esp+32] |
1992 | mov ecx, [esp+32] |
1993 | shl ecx, BSF sizeof.WDATA |
1993 | shl ecx, BSF sizeof.WDATA |
1994 | add ecx, window_data |
1994 | add ecx, window_data |
1995 | mov eax, [def_cursor] |
1995 | mov eax, [def_cursor] |
1996 | cmp [ecx + WDATA.cursor], eax |
1996 | cmp [ecx + WDATA.cursor], eax |
1997 | je @f |
1997 | je @f |
1998 | call restore_default_cursor_before_killing |
1998 | call restore_default_cursor_before_killing |
1999 | @@: |
1999 | @@: |
2000 | popa |
2000 | popa |
2001 | ;-------------------------------------- |
2001 | ;-------------------------------------- |
2002 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2002 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2003 | mov [ecx + APPDATA.state], TSTATE_ZOMBIE; clear possible i40's |
2003 | mov [ecx + APPDATA.state], TSTATE_ZOMBIE; clear possible i40's |
2004 | call wakeup_osloop |
2004 | call wakeup_osloop |
2005 | ;call MEM_Heap_UnLock |
2005 | ;call MEM_Heap_UnLock |
2006 | 2006 | ||
2007 | cmp edx, [application_table_owner]; clear app table stat |
2007 | cmp edx, [application_table_owner]; clear app table stat |
2008 | jne .noatsc |
2008 | jne .noatsc |
2009 | call unlock_application_table |
2009 | call unlock_application_table |
2010 | .noatsc: |
2010 | .noatsc: |
2011 | .noprocessterminate: |
2011 | .noprocessterminate: |
2012 | add esp, 4 |
2012 | add esp, 4 |
2013 | ret |
2013 | ret |
2014 | ;------------------------------------------------------------------------------ |
2014 | ;------------------------------------------------------------------------------ |
2015 | sysfn_terminate2: |
2015 | sysfn_terminate2: |
2016 | call lock_application_table |
2016 | call lock_application_table |
2017 | mov eax, ecx |
2017 | mov eax, ecx |
2018 | call pid_to_slot |
2018 | call pid_to_slot |
2019 | test eax, eax |
2019 | test eax, eax |
2020 | jz .not_found |
2020 | jz .not_found |
2021 | mov ecx, eax |
2021 | mov ecx, eax |
2022 | cli |
2022 | cli |
2023 | call sysfn_terminate |
2023 | call sysfn_terminate |
2024 | call unlock_application_table |
2024 | call unlock_application_table |
2025 | sti |
2025 | sti |
2026 | and [esp + SYSCALL_STACK.eax], 0 |
2026 | and [esp + SYSCALL_STACK.eax], 0 |
2027 | ret |
2027 | ret |
2028 | .not_found: |
2028 | .not_found: |
2029 | call unlock_application_table |
2029 | call unlock_application_table |
2030 | or [esp + SYSCALL_STACK.eax], -1 |
2030 | or [esp + SYSCALL_STACK.eax], -1 |
2031 | ret |
2031 | ret |
2032 | ;------------------------------------------------------------------------------ |
2032 | ;------------------------------------------------------------------------------ |
2033 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2033 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2034 | cmp ecx, 2 |
2034 | cmp ecx, 2 |
2035 | jb .nowindowdeactivate |
2035 | jb .nowindowdeactivate |
2036 | cmp ecx, [thread_count] |
2036 | cmp ecx, [thread_count] |
2037 | ja .nowindowdeactivate |
2037 | ja .nowindowdeactivate |
2038 | 2038 | ||
2039 | movzx esi, word [WIN_STACK + ecx*2] |
2039 | movzx esi, word [WIN_STACK + ecx*2] |
2040 | cmp esi, 1 |
2040 | cmp esi, 1 |
2041 | je .nowindowdeactivate ; already deactive |
2041 | je .nowindowdeactivate ; already deactive |
2042 | 2042 | ||
2043 | mov edi, ecx |
2043 | mov edi, ecx |
2044 | shl edi, BSF sizeof.WDATA |
2044 | shl edi, BSF sizeof.WDATA |
2045 | add edi, window_data |
2045 | add edi, window_data |
2046 | movzx esi, word [WIN_STACK + ecx * 2] |
2046 | movzx esi, word [WIN_STACK + ecx * 2] |
2047 | lea esi, [WIN_POS + esi * 2] |
2047 | lea esi, [WIN_POS + esi * 2] |
2048 | call window._.window_deactivate |
2048 | call window._.window_deactivate |
2049 | call syscall_display_settings.calculateScreen |
2049 | call syscall_display_settings.calculateScreen |
2050 | call syscall_display_settings.redrawScreen |
2050 | call syscall_display_settings.redrawScreen |
2051 | .nowindowdeactivate: |
2051 | .nowindowdeactivate: |
2052 | ret |
2052 | ret |
2053 | ;------------------------------------------------------------------------------ |
2053 | ;------------------------------------------------------------------------------ |
2054 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2054 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2055 | cmp ecx, 2 |
2055 | cmp ecx, 2 |
2056 | jb .nowindowactivate |
2056 | jb .nowindowactivate |
2057 | cmp ecx, [thread_count] |
2057 | cmp ecx, [thread_count] |
2058 | ja .nowindowactivate |
2058 | ja .nowindowactivate |
2059 | ;------------------------------------- |
2059 | ;------------------------------------- |
2060 | @@: |
2060 | @@: |
2061 | ; If the window is captured and moved by the user, |
2061 | ; If the window is captured and moved by the user, |
2062 | ; then you can't change the position in window stack!!! |
2062 | ; then you can't change the position in window stack!!! |
2063 | mov al, [mouse.active_sys_window.action] |
2063 | mov al, [mouse.active_sys_window.action] |
2064 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2064 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2065 | test al, al |
2065 | test al, al |
2066 | jz @f |
2066 | jz @f |
2067 | call change_task |
2067 | call change_task |
2068 | jmp @b |
2068 | jmp @b |
2069 | @@: |
2069 | @@: |
2070 | ;------------------------------------- |
2070 | ;------------------------------------- |
2071 | mov [window_minimize], 2; restore window if minimized |
2071 | mov [window_minimize], 2; restore window if minimized |
2072 | call wakeup_osloop |
2072 | call wakeup_osloop |
2073 | 2073 | ||
2074 | movzx esi, word [WIN_STACK + ecx*2] |
2074 | movzx esi, word [WIN_STACK + ecx*2] |
2075 | cmp esi, [thread_count] |
2075 | cmp esi, [thread_count] |
2076 | je .nowindowactivate; already active |
2076 | je .nowindowactivate; already active |
2077 | 2077 | ||
2078 | mov edi, ecx |
2078 | mov edi, ecx |
2079 | shl edi, BSF sizeof.WDATA |
2079 | shl edi, BSF sizeof.WDATA |
2080 | add edi, window_data |
2080 | add edi, window_data |
2081 | movzx esi, word [WIN_STACK + ecx * 2] |
2081 | movzx esi, word [WIN_STACK + ecx * 2] |
2082 | lea esi, [WIN_POS + esi * 2] |
2082 | lea esi, [WIN_POS + esi * 2] |
2083 | call waredraw |
2083 | call waredraw |
2084 | .nowindowactivate: |
2084 | .nowindowactivate: |
2085 | ret |
2085 | ret |
2086 | ;------------------------------------------------------------------------------ |
2086 | ;------------------------------------------------------------------------------ |
2087 | align 4 |
2087 | align 4 |
2088 | sysfn_zmodif: |
2088 | sysfn_zmodif: |
2089 | ;18,25,1 - get z_modif |
2089 | ;18,25,1 - get z_modif |
2090 | ;18,25,2 - set z_modif |
2090 | ;18,25,2 - set z_modif |
2091 | ;edx = -1(for current task) or TID |
2091 | ;edx = -1(for current task) or TID |
2092 | ;esi(for 2) = new value z_modif |
2092 | ;esi(for 2) = new value z_modif |
2093 | ;return: |
2093 | ;return: |
2094 | ;1: eax = z_modif |
2094 | ;1: eax = z_modif |
2095 | ;2: eax=0(fail),1(success) for set z_modif |
2095 | ;2: eax=0(fail),1(success) for set z_modif |
2096 | 2096 | ||
2097 | cmp edx, -1 |
2097 | cmp edx, -1 |
2098 | jne @f |
2098 | jne @f |
2099 | mov edx, [current_slot_idx] |
2099 | mov edx, [current_slot_idx] |
2100 | @@: |
2100 | @@: |
2101 | cmp edx, [thread_count] |
2101 | cmp edx, [thread_count] |
2102 | ja .fail |
2102 | ja .fail |
2103 | cmp edx, 1 |
2103 | cmp edx, 1 |
2104 | je .fail |
2104 | je .fail |
2105 | 2105 | ||
2106 | mov eax, edx |
2106 | mov eax, edx |
2107 | shl edx, BSF sizeof.WDATA |
2107 | shl edx, BSF sizeof.WDATA |
2108 | add edx, window_data |
2108 | add edx, window_data |
2109 | 2109 | ||
2110 | test [edx + WDATA.fl_wstate], WSTATE_USED |
2110 | test [edx + WDATA.fl_wstate], WSTATE_USED |
2111 | jz .fail |
2111 | jz .fail |
2112 | 2112 | ||
2113 | cmp ecx, 1 |
2113 | cmp ecx, 1 |
2114 | jnz .set_zmod |
2114 | jnz .set_zmod |
2115 | 2115 | ||
2116 | movzx eax, [edx + WDATA.z_modif] |
2116 | movzx eax, [edx + WDATA.z_modif] |
2117 | jmp .exit |
2117 | jmp .exit |
2118 | 2118 | ||
2119 | .set_zmod: |
2119 | .set_zmod: |
2120 | cmp ecx, 2 |
2120 | cmp ecx, 2 |
2121 | jnz .fail |
2121 | jnz .fail |
2122 | 2122 | ||
2123 | mov ebx, esi |
2123 | mov ebx, esi |
2124 | mov esi, eax |
2124 | mov esi, eax |
2125 | 2125 | ||
2126 | cmp bl, ZPOS_ALWAYS_TOP |
2126 | cmp bl, ZPOS_ALWAYS_TOP |
2127 | jg .fail |
2127 | jg .fail |
2128 | 2128 | ||
2129 | mov [edx + WDATA.z_modif], bl |
2129 | mov [edx + WDATA.z_modif], bl |
2130 | 2130 | ||
2131 | mov eax, [edx + WDATA.box.left] |
2131 | mov eax, [edx + WDATA.box.left] |
2132 | mov ebx, [edx + WDATA.box.top] |
2132 | mov ebx, [edx + WDATA.box.top] |
2133 | mov ecx, [edx + WDATA.box.width] |
2133 | mov ecx, [edx + WDATA.box.width] |
2134 | mov edx, [edx + WDATA.box.height] |
2134 | mov edx, [edx + WDATA.box.height] |
2135 | add ecx, eax |
2135 | add ecx, eax |
2136 | add edx, ebx |
2136 | add edx, ebx |
2137 | call window._.set_screen |
2137 | call window._.set_screen |
2138 | call window._.set_top_wnd |
2138 | call window._.set_top_wnd |
2139 | call window._.redraw_top_wnd |
2139 | call window._.redraw_top_wnd |
2140 | 2140 | ||
2141 | shl esi, BSF sizeof.WDATA |
2141 | shl esi, BSF sizeof.WDATA |
2142 | mov [esi + window_data + WDATA.fl_redraw], WSTATE_REDRAW |
2142 | mov [esi + window_data + WDATA.fl_redraw], WSTATE_REDRAW |
2143 | 2143 | ||
2144 | 2144 | ||
2145 | mov eax, 1 |
2145 | mov eax, 1 |
2146 | jmp .exit |
2146 | jmp .exit |
2147 | .fail: |
2147 | .fail: |
2148 | xor eax, eax |
2148 | xor eax, eax |
2149 | .exit: |
2149 | .exit: |
2150 | mov [esp + SYSCALL_STACK.eax], eax |
2150 | mov [esp + SYSCALL_STACK.eax], eax |
2151 | ret |
2151 | ret |
2152 | 2152 | ||
2153 | ;------------------------------------------------------------------------------ |
2153 | ;------------------------------------------------------------------------------ |
2154 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2154 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2155 | mov eax, [SLOT_BASE + sizeof.APPDATA + APPDATA.cpu_usage] |
2155 | mov eax, [SLOT_BASE + sizeof.APPDATA + APPDATA.cpu_usage] |
2156 | mov [esp + SYSCALL_STACK.eax], eax |
2156 | mov [esp + SYSCALL_STACK.eax], eax |
2157 | ret |
2157 | ret |
2158 | ;------------------------------------------------------------------------------ |
2158 | ;------------------------------------------------------------------------------ |
2159 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2159 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2160 | mov eax, dword [cpu_freq] |
2160 | mov eax, dword [cpu_freq] |
2161 | mov [esp + SYSCALL_STACK.eax], eax |
2161 | mov [esp + SYSCALL_STACK.eax], eax |
2162 | ret |
2162 | ret |
2163 | ;------------------------------------------------------------------------------ |
2163 | ;------------------------------------------------------------------------------ |
2164 | get_cpu_freq: |
2164 | get_cpu_freq: |
2165 | mov eax, dword [cpu_freq] |
2165 | mov eax, dword [cpu_freq] |
2166 | mov edx, dword [cpu_freq+4] |
2166 | mov edx, dword [cpu_freq+4] |
2167 | ret |
2167 | ret |
2168 | ; SAVE ramdisk to /hd/1/kolibri.img |
2168 | ; SAVE ramdisk to /hd/1/kolibri.img |
2169 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2169 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2170 | include 'blkdev/rdsave.inc' |
2170 | include 'blkdev/rdsave.inc' |
2171 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2171 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2172 | ;------------------------------------------------------------------------------ |
2172 | ;------------------------------------------------------------------------------ |
2173 | align 4 |
2173 | align 4 |
2174 | sysfn_getactive: ; 18.7 = get active window |
2174 | sysfn_getactive: ; 18.7 = get active window |
2175 | mov eax, [thread_count] |
2175 | mov eax, [thread_count] |
2176 | movzx eax, word [WIN_POS + eax*2] |
2176 | movzx eax, word [WIN_POS + eax*2] |
2177 | mov [esp + SYSCALL_STACK.eax], eax |
2177 | mov [esp + SYSCALL_STACK.eax], eax |
2178 | ret |
2178 | ret |
2179 | ;------------------------------------------------------------------------------ |
2179 | ;------------------------------------------------------------------------------ |
2180 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2180 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2181 | ; cmp ecx,1 |
2181 | ; cmp ecx,1 |
2182 | dec ecx |
2182 | dec ecx |
2183 | jnz .set_flag |
2183 | jnz .set_flag |
2184 | movzx eax, byte [sound_flag]; get sound_flag |
2184 | movzx eax, byte [sound_flag]; get sound_flag |
2185 | mov [esp + SYSCALL_STACK.eax], eax |
2185 | mov [esp + SYSCALL_STACK.eax], eax |
2186 | ret |
2186 | ret |
2187 | .set_flag: |
2187 | .set_flag: |
2188 | ; cmp ecx,2 |
2188 | ; cmp ecx,2 |
2189 | dec ecx |
2189 | dec ecx |
2190 | jnz .err |
2190 | jnz .err |
2191 | xor byte [sound_flag], 1 |
2191 | xor byte [sound_flag], 1 |
2192 | .err: |
2192 | .err: |
2193 | ret |
2193 | ret |
2194 | ;------------------------------------------------------------------------------ |
2194 | ;------------------------------------------------------------------------------ |
2195 | sysfn_minimize: ; 18.10 = minimize window |
2195 | sysfn_minimize: ; 18.10 = minimize window |
2196 | mov [window_minimize], 1 |
2196 | mov [window_minimize], 1 |
2197 | call wakeup_osloop |
2197 | call wakeup_osloop |
2198 | ret |
2198 | ret |
2199 | ;------------------------------------------------------------------------------ |
2199 | ;------------------------------------------------------------------------------ |
2200 | align 4 |
2200 | align 4 |
2201 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2201 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2202 | dec ecx |
2202 | dec ecx |
2203 | jnz .exit |
2203 | jnz .exit |
2204 | .small_table: |
2204 | .small_table: |
2205 | stdcall is_region_userspace, edx, DRIVE_DATA_SIZE |
2205 | stdcall is_region_userspace, edx, DRIVE_DATA_SIZE |
2206 | jnz .exit |
2206 | jnz .exit |
2207 | mov edi, edx |
2207 | mov edi, edx |
2208 | mov esi, DRIVE_DATA |
2208 | mov esi, DRIVE_DATA |
2209 | mov ecx, DRIVE_DATA_SIZE ;10 |
2209 | mov ecx, DRIVE_DATA_SIZE ;10 |
2210 | cld |
2210 | cld |
2211 | rep movsb |
2211 | rep movsb |
2212 | .exit: |
2212 | .exit: |
2213 | ret |
2213 | ret |
2214 | ;------------------------------------------------------------------------------ |
2214 | ;------------------------------------------------------------------------------ |
2215 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2215 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2216 | ; if given memory address belongs to kernel then error |
2216 | ; if given memory address belongs to kernel then error |
2217 | stdcall is_region_userspace, ecx, version_inf.size |
2217 | stdcall is_region_userspace, ecx, version_inf.size |
2218 | jnz .addr_error |
2218 | jnz .addr_error |
2219 | 2219 | ||
2220 | mov edi, ecx |
2220 | mov edi, ecx |
2221 | mov esi, version_inf |
2221 | mov esi, version_inf |
2222 | mov ecx, version_inf.size |
2222 | mov ecx, version_inf.size |
2223 | rep movsb |
2223 | rep movsb |
2224 | ret |
2224 | ret |
2225 | .addr_error: ; if given memory address is illegal |
2225 | .addr_error: ; if given memory address is illegal |
2226 | mov [esp + SYSCALL_STACK.eax], -1 |
2226 | mov [esp + SYSCALL_STACK.eax], -1 |
2227 | ret |
2227 | ret |
2228 | ;------------------------------------------------------------------------------ |
2228 | ;------------------------------------------------------------------------------ |
2229 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2229 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2230 | ;wait retrace functions |
2230 | ;wait retrace functions |
2231 | mov edx, 0x3da |
2231 | mov edx, 0x3da |
2232 | .loop: |
2232 | .loop: |
2233 | in al, dx |
2233 | in al, dx |
2234 | test al, 1000b |
2234 | test al, 1000b |
2235 | jz .loop |
2235 | jz .loop |
2236 | and [esp + SYSCALL_STACK.eax], 0 |
2236 | and [esp + SYSCALL_STACK.eax], 0 |
2237 | ret |
2237 | ret |
2238 | ;------------------------------------------------------------------------------ |
2238 | ;------------------------------------------------------------------------------ |
2239 | align 4 |
2239 | align 4 |
2240 | sysfn_centermouse: ; 18.15 = mouse centered |
2240 | sysfn_centermouse: ; 18.15 = mouse centered |
2241 | mov eax, [_display.width] |
2241 | mov eax, [_display.width] |
2242 | shr eax, 1 |
2242 | shr eax, 1 |
2243 | mov [MOUSE_X], ax |
2243 | mov [MOUSE_X], ax |
2244 | mov eax, [_display.height] |
2244 | mov eax, [_display.height] |
2245 | shr eax, 1 |
2245 | shr eax, 1 |
2246 | mov [MOUSE_Y], ax |
2246 | mov [MOUSE_Y], ax |
2247 | call wakeup_osloop |
2247 | call wakeup_osloop |
2248 | xor eax, eax |
2248 | xor eax, eax |
2249 | and [esp + SYSCALL_STACK.eax], eax |
2249 | and [esp + SYSCALL_STACK.eax], eax |
2250 | ret |
2250 | ret |
2251 | ;------------------------------------------------------------------------------ |
2251 | ;------------------------------------------------------------------------------ |
2252 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2252 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2253 | cmp ecx, 8 |
2253 | cmp ecx, 8 |
2254 | jnc @f |
2254 | jnc @f |
2255 | jmp dword [.table + ecx*4] |
2255 | jmp dword [.table + ecx*4] |
2256 | .get_mouse_acceleration: |
2256 | .get_mouse_acceleration: |
2257 | xor eax, eax |
2257 | xor eax, eax |
2258 | mov ax, [mouse_speed_factor] |
2258 | mov ax, [mouse_speed_factor] |
2259 | mov [esp + SYSCALL_STACK.eax], eax |
2259 | mov [esp + SYSCALL_STACK.eax], eax |
2260 | ret |
2260 | ret |
2261 | .set_mouse_acceleration: |
2261 | .set_mouse_acceleration: |
2262 | mov [mouse_speed_factor], dx |
2262 | mov [mouse_speed_factor], dx |
2263 | ret |
2263 | ret |
2264 | .get_mouse_delay: |
2264 | .get_mouse_delay: |
2265 | xor eax, eax |
2265 | xor eax, eax |
2266 | mov al, [mouse_delay] |
2266 | mov al, [mouse_delay] |
2267 | mov [esp + SYSCALL_STACK.eax], eax |
2267 | mov [esp + SYSCALL_STACK.eax], eax |
2268 | ret |
2268 | ret |
2269 | .set_mouse_delay: |
2269 | .set_mouse_delay: |
2270 | mov [mouse_delay], dl |
2270 | mov [mouse_delay], dl |
2271 | @@: |
2271 | @@: |
2272 | ret |
2272 | ret |
2273 | .set_pointer_position: |
2273 | .set_pointer_position: |
2274 | cmp dx, word[_display.height] |
2274 | cmp dx, word[_display.height] |
2275 | jae @b |
2275 | jae @b |
2276 | rol edx, 16 |
2276 | rol edx, 16 |
2277 | cmp dx, word[_display.width] |
2277 | cmp dx, word[_display.width] |
2278 | jae @b |
2278 | jae @b |
2279 | mov [MOUSE_X], edx |
2279 | mov [MOUSE_X], edx |
2280 | mov [mouse_active], 1 |
2280 | mov [mouse_active], 1 |
2281 | jmp wakeup_osloop |
2281 | jmp wakeup_osloop |
2282 | .set_mouse_button: |
2282 | .set_mouse_button: |
2283 | mov [BTN_DOWN], edx |
2283 | mov [BTN_DOWN], edx |
2284 | mov [mouse_active], 1 |
2284 | mov [mouse_active], 1 |
2285 | jmp wakeup_osloop |
2285 | jmp wakeup_osloop |
2286 | .get_doubleclick_delay: |
2286 | .get_doubleclick_delay: |
2287 | xor eax, eax |
2287 | xor eax, eax |
2288 | mov al, [mouse_doubleclick_delay] |
2288 | mov al, [mouse_doubleclick_delay] |
2289 | mov [esp + SYSCALL_STACK.eax], eax |
2289 | mov [esp + SYSCALL_STACK.eax], eax |
2290 | ret |
2290 | ret |
2291 | .set_doubleclick_delay: |
2291 | .set_doubleclick_delay: |
2292 | mov [mouse_doubleclick_delay], dl |
2292 | mov [mouse_doubleclick_delay], dl |
2293 | ret |
2293 | ret |
2294 | align 4 |
2294 | align 4 |
2295 | .table: |
2295 | .table: |
2296 | dd .get_mouse_acceleration |
2296 | dd .get_mouse_acceleration |
2297 | dd .set_mouse_acceleration |
2297 | dd .set_mouse_acceleration |
2298 | dd .get_mouse_delay |
2298 | dd .get_mouse_delay |
2299 | dd .set_mouse_delay |
2299 | dd .set_mouse_delay |
2300 | dd .set_pointer_position |
2300 | dd .set_pointer_position |
2301 | dd .set_mouse_button |
2301 | dd .set_mouse_button |
2302 | dd .get_doubleclick_delay |
2302 | dd .get_doubleclick_delay |
2303 | dd .set_doubleclick_delay |
2303 | dd .set_doubleclick_delay |
2304 | ;------------------------------------------------------------------------------ |
2304 | ;------------------------------------------------------------------------------ |
2305 | sysfn_getfreemem: |
2305 | sysfn_getfreemem: |
2306 | mov eax, [pg_data.pages_free] |
2306 | mov eax, [pg_data.pages_free] |
2307 | shl eax, 2 |
2307 | shl eax, 2 |
2308 | mov [esp + SYSCALL_STACK.eax], eax |
2308 | mov [esp + SYSCALL_STACK.eax], eax |
2309 | ret |
2309 | ret |
2310 | ;------------------------------------------------------------------------------ |
2310 | ;------------------------------------------------------------------------------ |
2311 | sysfn_getallmem: |
2311 | sysfn_getallmem: |
2312 | mov eax, [MEM_AMOUNT] |
2312 | mov eax, [MEM_AMOUNT] |
2313 | shr eax, 10 |
2313 | shr eax, 10 |
2314 | mov [esp + SYSCALL_STACK.eax], eax |
2314 | mov [esp + SYSCALL_STACK.eax], eax |
2315 | ret |
2315 | ret |
2316 | ;------------------------------------------------------------------------------ |
2316 | ;------------------------------------------------------------------------------ |
2317 | sysfn_pid_to_slot: |
2317 | sysfn_pid_to_slot: |
2318 | mov eax, ecx |
2318 | mov eax, ecx |
2319 | call pid_to_slot |
2319 | call pid_to_slot |
2320 | mov [esp + SYSCALL_STACK.eax], eax |
2320 | mov [esp + SYSCALL_STACK.eax], eax |
2321 | ret |
2321 | ret |
2322 | ;------------------------------------------------------------------------------ |
2322 | ;------------------------------------------------------------------------------ |
2323 | sysfn_min_rest_window: |
2323 | sysfn_min_rest_window: |
2324 | pushad |
2324 | pushad |
2325 | mov eax, edx ; ebx - operating |
2325 | mov eax, edx ; ebx - operating |
2326 | shr ecx, 1 |
2326 | shr ecx, 1 |
2327 | jnc @f |
2327 | jnc @f |
2328 | call pid_to_slot |
2328 | call pid_to_slot |
2329 | @@: |
2329 | @@: |
2330 | or eax, eax ; eax - number of slot |
2330 | or eax, eax ; eax - number of slot |
2331 | jz .error |
2331 | jz .error |
2332 | cmp eax, max_processes ; varify maximal slot number |
2332 | cmp eax, max_processes ; varify maximal slot number |
2333 | ja .error |
2333 | ja .error |
2334 | movzx eax, word [WIN_STACK + eax*2] |
2334 | movzx eax, word [WIN_STACK + eax*2] |
2335 | shr ecx, 1 |
2335 | shr ecx, 1 |
2336 | jc .restore |
2336 | jc .restore |
2337 | ; .minimize: |
2337 | ; .minimize: |
2338 | call minimize_window |
2338 | call minimize_window |
2339 | jmp .exit |
2339 | jmp .exit |
2340 | .restore: |
2340 | .restore: |
2341 | call restore_minimized_window |
2341 | call restore_minimized_window |
2342 | .exit: |
2342 | .exit: |
2343 | popad |
2343 | popad |
2344 | xor eax, eax |
2344 | xor eax, eax |
2345 | mov [esp + SYSCALL_STACK.eax], eax |
2345 | mov [esp + SYSCALL_STACK.eax], eax |
2346 | ret |
2346 | ret |
2347 | .error: |
2347 | .error: |
2348 | popad |
2348 | popad |
2349 | xor eax, eax |
2349 | xor eax, eax |
2350 | dec eax |
2350 | dec eax |
2351 | mov [esp + SYSCALL_STACK.eax], eax |
2351 | mov [esp + SYSCALL_STACK.eax], eax |
2352 | ret |
2352 | ret |
2353 | ;------------------------------------------------------------------------------ |
2353 | ;------------------------------------------------------------------------------ |
2354 | sysfn_min_windows: |
2354 | sysfn_min_windows: |
2355 | call minimize_all_window |
2355 | call minimize_all_window |
2356 | mov [esp + SYSCALL_STACK.eax], eax |
2356 | mov [esp + SYSCALL_STACK.eax], eax |
2357 | call change_task |
2357 | call change_task |
2358 | ret |
2358 | ret |
2359 | ;------------------------------------------------------------------------------ |
2359 | ;------------------------------------------------------------------------------ |
2360 | sysfn_set_screen_sizes: |
2360 | sysfn_set_screen_sizes: |
2361 | cmp [SCR_MODE], word 0x13 |
2361 | cmp [SCR_MODE], word 0x13 |
2362 | jbe .exit |
2362 | jbe .exit |
2363 | 2363 | ||
2364 | cmp [_display.select_cursor], select_cursor |
2364 | cmp [_display.select_cursor], select_cursor |
2365 | jne .exit |
2365 | jne .exit |
2366 | 2366 | ||
2367 | cmp ecx, [display_width_standard] |
2367 | cmp ecx, [display_width_standard] |
2368 | ja .exit |
2368 | ja .exit |
2369 | 2369 | ||
2370 | cmp edx, [display_height_standard] |
2370 | cmp edx, [display_height_standard] |
2371 | ja .exit |
2371 | ja .exit |
2372 | 2372 | ||
2373 | pushfd |
2373 | pushfd |
2374 | cli |
2374 | cli |
2375 | mov eax, ecx |
2375 | mov eax, ecx |
2376 | mov ecx, [_display.lfb_pitch] |
2376 | mov ecx, [_display.lfb_pitch] |
2377 | mov [_display.width], eax |
2377 | mov [_display.width], eax |
2378 | dec eax |
2378 | dec eax |
2379 | mov [_display.height], edx |
2379 | mov [_display.height], edx |
2380 | dec edx |
2380 | dec edx |
2381 | ; eax - new Screen_Max_X |
2381 | ; eax - new Screen_Max_X |
2382 | ; edx - new Screen_Max_Y |
2382 | ; edx - new Screen_Max_Y |
2383 | mov [do_not_touch_winmap], 1 |
2383 | mov [do_not_touch_winmap], 1 |
2384 | call set_screen |
2384 | call set_screen |
2385 | mov [do_not_touch_winmap], 0 |
2385 | mov [do_not_touch_winmap], 0 |
2386 | popfd |
2386 | popfd |
2387 | call change_task |
2387 | call change_task |
2388 | .exit: |
2388 | .exit: |
2389 | ret |
2389 | ret |
2390 | ;------------------------------------------------------------------------------ |
2390 | ;------------------------------------------------------------------------------ |
2391 | uglobal |
2391 | uglobal |
2392 | screen_workarea RECT |
2392 | screen_workarea RECT |
2393 | display_width_standard dd 0 |
2393 | display_width_standard dd 0 |
2394 | display_height_standard dd 0 |
2394 | display_height_standard dd 0 |
2395 | do_not_touch_winmap db 0 |
2395 | do_not_touch_winmap db 0 |
2396 | window_minimize db 0 |
2396 | window_minimize db 0 |
2397 | sound_flag db 0 |
2397 | sound_flag db 0 |
2398 | 2398 | ||
2399 | endg |
2399 | endg |
2400 | 2400 | ||
2401 | iglobal |
2401 | iglobal |
2402 | version_inf: |
2402 | version_inf: |
2403 | db 0,7,7,0 ; version 0.7.7.0 |
2403 | db 0,7,7,0 ; version 0.7.7.0 |
2404 | db 0 |
2404 | db 0 |
2405 | .rev dd __REV__ |
2405 | .rev dd __REV__ |
2406 | .size = $ - version_inf |
2406 | .size = $ - version_inf |
2407 | endg |
2407 | endg |
2408 | ;------------------------------------------------------------------------------ |
2408 | ;------------------------------------------------------------------------------ |
2409 | align 4 |
2409 | align 4 |
2410 | sys_cachetodiskette: |
2410 | sys_cachetodiskette: |
2411 | cmp ebx, 1 |
2411 | cmp ebx, 1 |
2412 | jb .no_floppy_save |
2412 | jb .no_floppy_save |
2413 | cmp ebx, 2 |
2413 | cmp ebx, 2 |
2414 | ja .no_floppy_save |
2414 | ja .no_floppy_save |
2415 | call save_image |
2415 | call save_image |
2416 | mov [esp + SYSCALL_STACK.eax], eax |
2416 | mov [esp + SYSCALL_STACK.eax], eax |
2417 | ret |
2417 | ret |
2418 | .no_floppy_save: |
2418 | .no_floppy_save: |
2419 | mov [esp + SYSCALL_STACK.eax], 1 |
2419 | mov [esp + SYSCALL_STACK.eax], 1 |
2420 | ret |
2420 | ret |
2421 | ;------------------------------------------------------------------------------ |
2421 | ;------------------------------------------------------------------------------ |
2422 | align 4 |
2422 | align 4 |
2423 | sys_cpuusage: |
2423 | sys_cpuusage: |
2424 | 2424 | ||
2425 | ; RETURN: process_information structure |
2425 | ; RETURN: process_information structure |
2426 | ; |
2426 | ; |
2427 | ; if given memory address belongs to kernel then error |
2427 | ; if given memory address belongs to kernel then error |
2428 | stdcall is_region_userspace, ebx, sizeof.process_information |
2428 | stdcall is_region_userspace, ebx, sizeof.process_information |
2429 | jnz .addr_error |
2429 | jnz .addr_error |
2430 | 2430 | ||
2431 | cmp ecx, -1 ; who am I ? |
2431 | cmp ecx, -1 ; who am I ? |
2432 | jne .no_who_am_i |
2432 | jne .no_who_am_i |
2433 | mov ecx, [current_slot_idx] |
2433 | mov ecx, [current_slot_idx] |
2434 | .no_who_am_i: |
2434 | .no_who_am_i: |
2435 | jecxz .empty_slot |
2435 | jecxz .empty_slot |
2436 | cmp ecx, max_processes |
2436 | cmp ecx, max_processes |
2437 | ja .empty_slot |
2437 | ja .empty_slot |
2438 | mov edx, ecx |
2438 | mov edx, ecx |
2439 | shl edx, BSF sizeof.APPDATA |
2439 | shl edx, BSF sizeof.APPDATA |
2440 | cmp [SLOT_BASE+edx+APPDATA.state], TSTATE_FREE |
2440 | cmp [SLOT_BASE+edx+APPDATA.state], TSTATE_FREE |
2441 | jnz .thread_found |
2441 | jnz .thread_found |
2442 | .empty_slot: |
2442 | .empty_slot: |
2443 | ; zero buffer for an empty slot |
2443 | ; zero buffer for an empty slot |
2444 | push edi |
2444 | push edi |
2445 | xor eax, eax |
2445 | xor eax, eax |
2446 | mov edi, ebx |
2446 | mov edi, ebx |
2447 | movi ecx, sizeof.process_information |
2447 | movi ecx, sizeof.process_information |
2448 | rep stosb |
2448 | rep stosb |
2449 | pop edi |
2449 | pop edi |
2450 | jmp .nofillbuf |
2450 | jmp .nofillbuf |
2451 | .thread_found: |
2451 | .thread_found: |
2452 | ; +4: word: position of the window of thread in the window stack |
2452 | ; +4: word: position of the window of thread in the window stack |
2453 | mov ax, [WIN_STACK + ecx * 2] |
2453 | mov ax, [WIN_STACK + ecx * 2] |
2454 | mov [ebx+process_information.window_stack_position], ax |
2454 | mov [ebx+process_information.window_stack_position], ax |
2455 | ; +6: word: number of the thread slot, which window has in the window stack |
2455 | ; +6: word: number of the thread slot, which window has in the window stack |
2456 | ; position ecx (has no relation to the specific thread) |
2456 | ; position ecx (has no relation to the specific thread) |
2457 | mov ax, [WIN_POS + ecx * 2] |
2457 | mov ax, [WIN_POS + ecx * 2] |
2458 | mov [ebx+process_information.window_stack_value], ax |
2458 | mov [ebx+process_information.window_stack_value], ax |
2459 | 2459 | ||
2460 | shl ecx, BSF sizeof.APPDATA |
2460 | shl ecx, BSF sizeof.APPDATA |
2461 | 2461 | ||
2462 | ; +0: dword: memory usage |
2462 | ; +0: dword: memory usage |
2463 | mov eax, [SLOT_BASE + ecx + APPDATA.cpu_usage] |
2463 | mov eax, [SLOT_BASE + ecx + APPDATA.cpu_usage] |
2464 | mov [ebx+process_information.cpu_usage], eax |
2464 | mov [ebx+process_information.cpu_usage], eax |
2465 | ; +10: 11 bytes: name of the process |
2465 | ; +10: 11 bytes: name of the process |
2466 | push ecx |
2466 | push ecx |
2467 | lea eax, [SLOT_BASE + ecx + APPDATA.app_name] |
2467 | lea eax, [SLOT_BASE + ecx + APPDATA.app_name] |
2468 | add ebx, process_information.process_name |
2468 | add ebx, process_information.process_name |
2469 | mov ecx, 11 |
2469 | mov ecx, 11 |
2470 | call memmove |
2470 | call memmove |
2471 | pop ecx |
2471 | pop ecx |
2472 | 2472 | ||
2473 | ; +22: address of the process in memory |
2473 | ; +22: address of the process in memory |
2474 | ; +26: size of used memory - 1 |
2474 | ; +26: size of used memory - 1 |
2475 | push edi |
2475 | push edi |
2476 | lea edi, [ebx+12] |
2476 | lea edi, [ebx+12] |
2477 | xor eax, eax |
2477 | xor eax, eax |
2478 | mov edx, 0x100000*16 |
2478 | mov edx, 0x100000*16 |
2479 | cmp ecx, 1 shl BSF sizeof.APPDATA |
2479 | cmp ecx, 1 shl BSF sizeof.APPDATA |
2480 | je .os_mem |
2480 | je .os_mem |
2481 | mov edx, [SLOT_BASE + ecx + APPDATA.process] |
2481 | mov edx, [SLOT_BASE + ecx + APPDATA.process] |
2482 | mov edx, [edx + PROC.mem_used] |
2482 | mov edx, [edx + PROC.mem_used] |
2483 | mov eax, std_application_base_address |
2483 | mov eax, std_application_base_address |
2484 | .os_mem: |
2484 | .os_mem: |
2485 | stosd |
2485 | stosd |
2486 | lea eax, [edx-1] |
2486 | lea eax, [edx-1] |
2487 | stosd |
2487 | stosd |
2488 | 2488 | ||
2489 | mov edx, [SLOT_BASE + ecx + APPDATA.window] |
2489 | mov edx, [SLOT_BASE + ecx + APPDATA.window] |
2490 | 2490 | ||
2491 | ; +30: PID/TID |
2491 | ; +30: PID/TID |
2492 | mov eax, [SLOT_BASE + ecx + APPDATA.tid] |
2492 | mov eax, [SLOT_BASE + ecx + APPDATA.tid] |
2493 | stosd |
2493 | stosd |
2494 | 2494 | ||
2495 | ; window position and size |
2495 | ; window position and size |
2496 | push esi |
2496 | push esi |
2497 | lea esi, [edx + WDATA.box] |
2497 | lea esi, [edx + WDATA.box] |
2498 | movsd |
2498 | movsd |
2499 | movsd |
2499 | movsd |
2500 | movsd |
2500 | movsd |
2501 | movsd |
2501 | movsd |
2502 | 2502 | ||
2503 | ; Process state (+50) |
2503 | ; Process state (+50) |
2504 | movzx eax, byte [SLOT_BASE + ecx + APPDATA.state] |
2504 | movzx eax, byte [SLOT_BASE + ecx + APPDATA.state] |
2505 | stosd |
2505 | stosd |
2506 | 2506 | ||
2507 | ; Window client area box |
2507 | ; Window client area box |
2508 | lea esi, [edx + WDATA.clientbox] |
2508 | lea esi, [edx + WDATA.clientbox] |
2509 | movsd |
2509 | movsd |
2510 | movsd |
2510 | movsd |
2511 | movsd |
2511 | movsd |
2512 | movsd |
2512 | movsd |
2513 | 2513 | ||
2514 | ; Window state |
2514 | ; Window state |
2515 | mov al, [edx + WDATA.fl_wstate] |
2515 | mov al, [edx + WDATA.fl_wstate] |
2516 | stosb |
2516 | stosb |
2517 | 2517 | ||
2518 | ; Event mask (+71) |
2518 | ; Event mask (+71) |
2519 | mov eax, [SLOT_BASE + ecx + APPDATA.event_mask] |
2519 | mov eax, [SLOT_BASE + ecx + APPDATA.event_mask] |
2520 | stosd |
2520 | stosd |
2521 | 2521 | ||
2522 | ; Keyboard mode (+75) |
2522 | ; Keyboard mode (+75) |
2523 | mov al, [SLOT_BASE + ecx + APPDATA.keyboard_mode] |
2523 | mov al, [SLOT_BASE + ecx + APPDATA.keyboard_mode] |
2524 | stosb |
2524 | stosb |
2525 | 2525 | ||
2526 | pop esi |
2526 | pop esi |
2527 | pop edi |
2527 | pop edi |
2528 | 2528 | ||
2529 | .nofillbuf: |
2529 | .nofillbuf: |
2530 | ; return number of processes |
2530 | ; return number of processes |
2531 | 2531 | ||
2532 | mov eax, [thread_count] |
2532 | mov eax, [thread_count] |
2533 | mov [esp + SYSCALL_STACK.eax], eax |
2533 | mov [esp + SYSCALL_STACK.eax], eax |
2534 | ret |
2534 | ret |
2535 | 2535 | ||
2536 | .addr_error: ; if given memory address is illegal |
2536 | .addr_error: ; if given memory address is illegal |
2537 | mov [esp + SYSCALL_STACK.eax], -1 |
2537 | mov [esp + SYSCALL_STACK.eax], -1 |
2538 | ret |
2538 | ret |
2539 | 2539 | ||
2540 | 2540 | ||
2541 | ; redraw status |
2541 | ; redraw status |
2542 | align 4 |
2542 | align 4 |
2543 | sys_redrawstat: |
2543 | sys_redrawstat: |
2544 | cmp ebx, 1 |
2544 | cmp ebx, 1 |
2545 | jne .no_widgets_away |
2545 | jne .no_widgets_away |
2546 | ; buttons away |
2546 | ; buttons away |
2547 | mov ecx, [current_slot_idx] |
2547 | mov ecx, [current_slot_idx] |
2548 | .sys_newba2: |
2548 | .sys_newba2: |
2549 | mov edi, [BTN_ADDR] |
2549 | mov edi, [BTN_ADDR] |
2550 | cmp [edi], dword 0 ; empty button list ? |
2550 | cmp [edi], dword 0 ; empty button list ? |
2551 | je .end_of_buttons_away |
2551 | je .end_of_buttons_away |
2552 | movzx ebx, word [edi] |
2552 | movzx ebx, word [edi] |
2553 | inc ebx |
2553 | inc ebx |
2554 | mov eax, edi |
2554 | mov eax, edi |
2555 | .sys_newba: |
2555 | .sys_newba: |
2556 | dec ebx |
2556 | dec ebx |
2557 | jz .end_of_buttons_away |
2557 | jz .end_of_buttons_away |
2558 | 2558 | ||
2559 | add eax, 0x10 |
2559 | add eax, 0x10 |
2560 | cmp cx, [eax] |
2560 | cmp cx, [eax] |
2561 | jnz .sys_newba |
2561 | jnz .sys_newba |
2562 | 2562 | ||
2563 | push eax ebx ecx |
2563 | push eax ebx ecx |
2564 | mov ecx, ebx |
2564 | mov ecx, ebx |
2565 | inc ecx |
2565 | inc ecx |
2566 | shl ecx, 4 |
2566 | shl ecx, 4 |
2567 | mov ebx, eax |
2567 | mov ebx, eax |
2568 | add eax, 0x10 |
2568 | add eax, 0x10 |
2569 | call memmove |
2569 | call memmove |
2570 | dec dword [edi] |
2570 | dec dword [edi] |
2571 | pop ecx ebx eax |
2571 | pop ecx ebx eax |
2572 | 2572 | ||
2573 | jmp .sys_newba2 |
2573 | jmp .sys_newba2 |
2574 | 2574 | ||
2575 | .end_of_buttons_away: |
2575 | .end_of_buttons_away: |
2576 | ret |
2576 | ret |
2577 | 2577 | ||
2578 | .no_widgets_away: |
2578 | .no_widgets_away: |
2579 | 2579 | ||
2580 | cmp ebx, 2 |
2580 | cmp ebx, 2 |
2581 | jnz .srl1 |
2581 | jnz .srl1 |
2582 | 2582 | ||
2583 | mov edx, [current_slot] ; return whole screen draw area for this app |
2583 | mov edx, [current_slot] ; return whole screen draw area for this app |
2584 | mov edx, [edx + APPDATA.window] |
2584 | mov edx, [edx + APPDATA.window] |
2585 | mov [edx + WDATA.draw_data.left], 0 |
2585 | mov [edx + WDATA.draw_data.left], 0 |
2586 | mov [edx + WDATA.draw_data.top], 0 |
2586 | mov [edx + WDATA.draw_data.top], 0 |
2587 | mov eax, [_display.width] |
2587 | mov eax, [_display.width] |
2588 | dec eax |
2588 | dec eax |
2589 | mov [edx + WDATA.draw_data.right], eax |
2589 | mov [edx + WDATA.draw_data.right], eax |
2590 | mov eax, [_display.height] |
2590 | mov eax, [_display.height] |
2591 | dec eax |
2591 | dec eax |
2592 | mov [edx + WDATA.draw_data.bottom], eax |
2592 | mov [edx + WDATA.draw_data.bottom], eax |
2593 | 2593 | ||
2594 | .srl1: |
2594 | .srl1: |
2595 | ret |
2595 | ret |
2596 | 2596 | ||
2597 | ;ok - 100% work |
2597 | ;ok - 100% work |
2598 | ;nt - not tested |
2598 | ;nt - not tested |
2599 | ;--------------------------------------------------------------------------------------------- |
2599 | ;--------------------------------------------------------------------------------------------- |
2600 | ;eax |
2600 | ;eax |
2601 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
2601 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
2602 | ;1 - change task. Ret nothing. Block. ok. |
2602 | ;1 - change task. Ret nothing. Block. ok. |
2603 | ;2 - performance control |
2603 | ;2 - performance control |
2604 | ; ebx |
2604 | ; ebx |
2605 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
2605 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
2606 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
2606 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
2607 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
2607 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
2608 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
2608 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
2609 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
2609 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
2610 | ;eax |
2610 | ;eax |
2611 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
2611 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
2612 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
2612 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
2613 | ;--------------------------------------------------------------------------------------------- |
2613 | ;--------------------------------------------------------------------------------------------- |
2614 | iglobal |
2614 | iglobal |
2615 | align 4 |
2615 | align 4 |
2616 | sheduler: |
2616 | sheduler: |
2617 | dd sys_sheduler.00 |
2617 | dd sys_sheduler.00 |
2618 | dd change_task |
2618 | dd change_task |
2619 | dd sys_sheduler.02 |
2619 | dd sys_sheduler.02 |
2620 | dd sys_sheduler.03 |
2620 | dd sys_sheduler.03 |
2621 | dd sys_sheduler.04 |
2621 | dd sys_sheduler.04 |
2622 | endg |
2622 | endg |
2623 | sys_sheduler: |
2623 | sys_sheduler: |
2624 | ;rewritten by |
2624 | ;rewritten by |
2625 | jmp dword [sheduler + ebx*4] |
2625 | jmp dword [sheduler + ebx*4] |
2626 | ;.shed_counter: |
2626 | ;.shed_counter: |
2627 | .00: |
2627 | .00: |
2628 | mov eax, [context_counter] |
2628 | mov eax, [context_counter] |
2629 | mov [esp + SYSCALL_STACK.eax], eax |
2629 | mov [esp + SYSCALL_STACK.eax], eax |
2630 | ret |
2630 | ret |
2631 | 2631 | ||
2632 | .02: |
2632 | .02: |
2633 | ;.perf_control: |
2633 | ;.perf_control: |
2634 | inc ebx ;before ebx=2, ebx=3 |
2634 | inc ebx ;before ebx=2, ebx=3 |
2635 | cmp ebx, ecx ;if ecx=3, ebx=3 |
2635 | cmp ebx, ecx ;if ecx=3, ebx=3 |
2636 | jz cache_disable |
2636 | jz cache_disable |
2637 | 2637 | ||
2638 | dec ebx ;ebx=2 |
2638 | dec ebx ;ebx=2 |
2639 | cmp ebx, ecx ; |
2639 | cmp ebx, ecx ; |
2640 | jz cache_enable ;if ecx=2 and ebx=2 |
2640 | jz cache_enable ;if ecx=2 and ebx=2 |
2641 | 2641 | ||
2642 | dec ebx ;ebx=1 |
2642 | dec ebx ;ebx=1 |
2643 | cmp ebx, ecx |
2643 | cmp ebx, ecx |
2644 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
2644 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
2645 | 2645 | ||
2646 | dec ebx |
2646 | dec ebx |
2647 | test ebx, ecx ;ebx=0 and ecx=0 |
2647 | test ebx, ecx ;ebx=0 and ecx=0 |
2648 | jz modify_pce ;if ecx=0 |
2648 | jz modify_pce ;if ecx=0 |
2649 | 2649 | ||
2650 | ret |
2650 | ret |
2651 | 2651 | ||
2652 | .03: |
2652 | .03: |
2653 | ;.rdmsr_instr: |
2653 | ;.rdmsr_instr: |
2654 | ;now counter in ecx |
2654 | ;now counter in ecx |
2655 | ;(edx:eax) esi:edi => edx:esi |
2655 | ;(edx:eax) esi:edi => edx:esi |
2656 | mov eax, esi |
2656 | mov eax, esi |
2657 | mov ecx, edx |
2657 | mov ecx, edx |
2658 | rdmsr |
2658 | rdmsr |
2659 | mov [esp + SYSCALL_STACK.eax], eax |
2659 | mov [esp + SYSCALL_STACK.eax], eax |
2660 | mov [esp + SYSCALL_STACK.ebx], edx ;ret in ebx? |
2660 | mov [esp + SYSCALL_STACK.ebx], edx ;ret in ebx? |
2661 | ret |
2661 | ret |
2662 | 2662 | ||
2663 | .04: |
2663 | .04: |
2664 | ;.wrmsr_instr: |
2664 | ;.wrmsr_instr: |
2665 | ;now counter in ecx |
2665 | ;now counter in ecx |
2666 | ;(edx:eax) esi:edi => edx:esi |
2666 | ;(edx:eax) esi:edi => edx:esi |
2667 | ; Fast Call MSR can't be destroy |
2667 | ; Fast Call MSR can't be destroy |
2668 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
2668 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
2669 | ; включаются/выключаются расширенные возможности |
2669 | ; включаются/выключаются расширенные возможности |
2670 | cmp edx, MSR_SYSENTER_CS |
2670 | cmp edx, MSR_SYSENTER_CS |
2671 | je @f |
2671 | je @f |
2672 | cmp edx, MSR_SYSENTER_ESP |
2672 | cmp edx, MSR_SYSENTER_ESP |
2673 | je @f |
2673 | je @f |
2674 | cmp edx, MSR_SYSENTER_EIP |
2674 | cmp edx, MSR_SYSENTER_EIP |
2675 | je @f |
2675 | je @f |
2676 | cmp edx, MSR_AMD_STAR |
2676 | cmp edx, MSR_AMD_STAR |
2677 | je @f |
2677 | je @f |
2678 | 2678 | ||
2679 | mov eax, esi |
2679 | mov eax, esi |
2680 | mov ecx, edx |
2680 | mov ecx, edx |
2681 | wrmsr |
2681 | wrmsr |
2682 | ; mov [esp + 32], eax |
2682 | ; mov [esp + 32], eax |
2683 | ; mov [esp + 20], edx ;ret in ebx? |
2683 | ; mov [esp + 20], edx ;ret in ebx? |
2684 | @@: |
2684 | @@: |
2685 | ret |
2685 | ret |
2686 | 2686 | ||
2687 | cache_disable: |
2687 | cache_disable: |
2688 | mov eax, cr0 |
2688 | mov eax, cr0 |
2689 | or eax, 01100000_00000000_00000000_00000000b |
2689 | or eax, 01100000_00000000_00000000_00000000b |
2690 | mov cr0, eax |
2690 | mov cr0, eax |
2691 | wbinvd ;set MESI |
2691 | wbinvd ;set MESI |
2692 | ret |
2692 | ret |
2693 | 2693 | ||
2694 | cache_enable: |
2694 | cache_enable: |
2695 | mov eax, cr0 |
2695 | mov eax, cr0 |
2696 | and eax, 10011111_11111111_11111111_11111111b |
2696 | and eax, 10011111_11111111_11111111_11111111b |
2697 | mov cr0, eax |
2697 | mov cr0, eax |
2698 | ret |
2698 | ret |
2699 | 2699 | ||
2700 | is_cache_enabled: |
2700 | is_cache_enabled: |
2701 | mov eax, cr0 |
2701 | mov eax, cr0 |
2702 | and eax, 01100000_00000000_00000000_00000000b |
2702 | and eax, 01100000_00000000_00000000_00000000b |
2703 | mov [esp + SYSCALL_STACK.eax], eax |
2703 | mov [esp + SYSCALL_STACK.eax], eax |
2704 | ret |
2704 | ret |
2705 | 2705 | ||
2706 | modify_pce: |
2706 | modify_pce: |
2707 | mov eax, cr4 |
2707 | mov eax, cr4 |
2708 | ; mov ebx,0 |
2708 | ; mov ebx,0 |
2709 | ; or bx,100000000b ;pce |
2709 | ; or bx,100000000b ;pce |
2710 | ; xor eax,ebx ;invert pce |
2710 | ; xor eax,ebx ;invert pce |
2711 | bts eax, 8;pce=cr4[8] |
2711 | bts eax, 8;pce=cr4[8] |
2712 | mov cr4, eax |
2712 | mov cr4, eax |
2713 | mov [esp + SYSCALL_STACK.eax], eax |
2713 | mov [esp + SYSCALL_STACK.eax], eax |
2714 | ret |
2714 | ret |
2715 | ;--------------------------------------------------------------------------------------------- |
2715 | ;--------------------------------------------------------------------------------------------- |
2716 | 2716 | ||
2717 | 2717 | ||
2718 | iglobal |
2718 | iglobal |
2719 | cpustring db 'CPU',0 |
2719 | cpustring db 'CPU',0 |
2720 | endg |
2720 | endg |
2721 | 2721 | ||
2722 | uglobal |
2722 | uglobal |
2723 | background_defined db 0 ; diamond, 11.04.2006 |
2723 | background_defined db 0 ; diamond, 11.04.2006 |
2724 | endg |
2724 | endg |
2725 | ;----------------------------------------------------------------------------- |
2725 | ;----------------------------------------------------------------------------- |
2726 | align 4 |
2726 | align 4 |
2727 | checkmisc: |
2727 | checkmisc: |
2728 | cmp [ctrl_alt_del], 1 |
2728 | cmp [ctrl_alt_del], 1 |
2729 | jne .nocpustart |
2729 | jne .nocpustart |
2730 | 2730 | ||
2731 | mov ebp, cpustring |
2731 | mov ebp, cpustring |
2732 | call fs_execute_from_sysdir |
2732 | call fs_execute_from_sysdir |
2733 | 2733 | ||
2734 | mov [ctrl_alt_del], 0 |
2734 | mov [ctrl_alt_del], 0 |
2735 | ;-------------------------------------- |
2735 | ;-------------------------------------- |
2736 | align 4 |
2736 | align 4 |
2737 | .nocpustart: |
2737 | .nocpustart: |
2738 | cmp [mouse_active], 1 |
2738 | cmp [mouse_active], 1 |
2739 | jne .mouse_not_active |
2739 | jne .mouse_not_active |
2740 | mov [mouse_active], 0 |
2740 | mov [mouse_active], 0 |
2741 | 2741 | ||
2742 | xor edi, edi |
2742 | xor edi, edi |
2743 | mov ebx, window_data |
2743 | mov ebx, window_data |
2744 | 2744 | ||
2745 | mov ecx, [thread_count] |
2745 | mov ecx, [thread_count] |
2746 | movzx eax, word [WIN_POS + ecx*2] ; active window |
2746 | movzx eax, word [WIN_POS + ecx*2] ; active window |
2747 | shl eax, BSF sizeof.APPDATA |
2747 | shl eax, BSF sizeof.APPDATA |
2748 | push eax |
2748 | push eax |
2749 | 2749 | ||
2750 | movzx eax, word [MOUSE_X] |
2750 | movzx eax, word [MOUSE_X] |
2751 | movzx edx, word [MOUSE_Y] |
2751 | movzx edx, word [MOUSE_Y] |
2752 | ;-------------------------------------- |
2752 | ;-------------------------------------- |
2753 | align 4 |
2753 | align 4 |
2754 | .set_mouse_event: |
2754 | .set_mouse_event: |
2755 | add edi, sizeof.APPDATA |
2755 | add edi, sizeof.APPDATA |
2756 | add ebx, sizeof.WDATA |
2756 | add ebx, sizeof.WDATA |
2757 | test [SLOT_BASE + edi + APPDATA.event_mask], EVM_MOUSE_FILTER |
2757 | test [SLOT_BASE + edi + APPDATA.event_mask], EVM_MOUSE_FILTER |
2758 | jz .pos_filter |
2758 | jz .pos_filter |
2759 | 2759 | ||
2760 | cmp edi, [esp] ; skip if filtration active |
2760 | cmp edi, [esp] ; skip if filtration active |
2761 | jne .skip |
2761 | jne .skip |
2762 | ;-------------------------------------- |
2762 | ;-------------------------------------- |
2763 | align 4 |
2763 | align 4 |
2764 | .pos_filter: |
2764 | .pos_filter: |
2765 | test [SLOT_BASE + edi + APPDATA.event_mask], EVM_CURSOR_FILTER |
2765 | test [SLOT_BASE + edi + APPDATA.event_mask], EVM_CURSOR_FILTER |
2766 | jz .set |
2766 | jz .set |
2767 | 2767 | ||
2768 | mov esi, [ebx + WDATA.box.left] |
2768 | mov esi, [ebx + WDATA.box.left] |
2769 | cmp eax, esi |
2769 | cmp eax, esi |
2770 | jb .skip |
2770 | jb .skip |
2771 | add esi, [ebx + WDATA.box.width] |
2771 | add esi, [ebx + WDATA.box.width] |
2772 | cmp eax, esi |
2772 | cmp eax, esi |
2773 | ja .skip |
2773 | ja .skip |
2774 | 2774 | ||
2775 | mov esi, [ebx + WDATA.box.top] |
2775 | mov esi, [ebx + WDATA.box.top] |
2776 | cmp edx, esi |
2776 | cmp edx, esi |
2777 | jb .skip |
2777 | jb .skip |
2778 | add esi, [ebx + WDATA.box.height] |
2778 | add esi, [ebx + WDATA.box.height] |
2779 | cmp edx, esi |
2779 | cmp edx, esi |
2780 | ja .skip |
2780 | ja .skip |
2781 | ;-------------------------------------- |
2781 | ;-------------------------------------- |
2782 | align 4 |
2782 | align 4 |
2783 | .set: |
2783 | .set: |
2784 | or [SLOT_BASE + edi + APPDATA.occurred_events], EVENT_MOUSE |
2784 | or [SLOT_BASE + edi + APPDATA.occurred_events], EVENT_MOUSE |
2785 | ;-------------------------------------- |
2785 | ;-------------------------------------- |
2786 | align 4 |
2786 | align 4 |
2787 | .skip: |
2787 | .skip: |
2788 | loop .set_mouse_event |
2788 | loop .set_mouse_event |
2789 | 2789 | ||
2790 | pop eax |
2790 | pop eax |
2791 | ;-------------------------------------- |
2791 | ;-------------------------------------- |
2792 | align 4 |
2792 | align 4 |
2793 | .mouse_not_active: |
2793 | .mouse_not_active: |
2794 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
2794 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
2795 | jz nobackgr |
2795 | jz nobackgr |
2796 | 2796 | ||
2797 | cmp [background_defined], 0 |
2797 | cmp [background_defined], 0 |
2798 | jz nobackgr |
2798 | jz nobackgr |
2799 | ;-------------------------------------- |
2799 | ;-------------------------------------- |
2800 | align 4 |
2800 | align 4 |
2801 | backgr: |
2801 | backgr: |
2802 | mov eax, [background_window + WDATA.draw_data.left] |
2802 | mov eax, [background_window + WDATA.draw_data.left] |
2803 | shl eax, 16 |
2803 | shl eax, 16 |
2804 | add eax, [background_window + WDATA.draw_data.right] |
2804 | add eax, [background_window + WDATA.draw_data.right] |
2805 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
2805 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
2806 | 2806 | ||
2807 | mov eax, [background_window + WDATA.draw_data.top] |
2807 | mov eax, [background_window + WDATA.draw_data.top] |
2808 | shl eax, 16 |
2808 | shl eax, 16 |
2809 | add eax, [background_window + WDATA.draw_data.bottom] |
2809 | add eax, [background_window + WDATA.draw_data.bottom] |
2810 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
2810 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
2811 | 2811 | ||
2812 | call drawbackground |
2812 | call drawbackground |
2813 | ; DEBUGF 1, "K : drawbackground\n" |
2813 | ; DEBUGF 1, "K : drawbackground\n" |
2814 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
2814 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
2815 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
2815 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
2816 | ;--------- set event 5 start ---------- |
2816 | ;--------- set event 5 start ---------- |
2817 | push ecx edi |
2817 | push ecx edi |
2818 | mov edi, window_data |
2818 | mov edi, window_data |
2819 | mov ecx, [thread_count] |
2819 | mov ecx, [thread_count] |
2820 | ;-------------------------------------- |
2820 | ;-------------------------------------- |
2821 | align 4 |
2821 | align 4 |
2822 | set_bgr_event: |
2822 | set_bgr_event: |
2823 | add edi, sizeof.WDATA |
2823 | add edi, sizeof.WDATA |
2824 | mov eax, [BG_Rect_X_left_right] |
2824 | mov eax, [BG_Rect_X_left_right] |
2825 | mov edx, [BG_Rect_Y_top_bottom] |
2825 | mov edx, [BG_Rect_Y_top_bottom] |
2826 | cmp [edi + WDATA.draw_bgr_x], 0 |
2826 | cmp [edi + WDATA.draw_bgr_x], 0 |
2827 | jz .set |
2827 | jz .set |
2828 | .join: |
2828 | .join: |
2829 | cmp word [edi + WDATA.draw_bgr_x], ax |
2829 | cmp word [edi + WDATA.draw_bgr_x], ax |
2830 | jae @f |
2830 | jae @f |
2831 | mov word [edi + WDATA.draw_bgr_x], ax |
2831 | mov word [edi + WDATA.draw_bgr_x], ax |
2832 | @@: |
2832 | @@: |
2833 | shr eax, 16 |
2833 | shr eax, 16 |
2834 | cmp word [edi + WDATA.draw_bgr_x + 2], ax |
2834 | cmp word [edi + WDATA.draw_bgr_x + 2], ax |
2835 | jbe @f |
2835 | jbe @f |
2836 | mov word [edi + WDATA.draw_bgr_x + 2], ax |
2836 | mov word [edi + WDATA.draw_bgr_x + 2], ax |
2837 | @@: |
2837 | @@: |
2838 | cmp word [edi + WDATA.draw_bgr_y], dx |
2838 | cmp word [edi + WDATA.draw_bgr_y], dx |
2839 | jae @f |
2839 | jae @f |
2840 | mov word [edi + WDATA.draw_bgr_y], dx |
2840 | mov word [edi + WDATA.draw_bgr_y], dx |
2841 | @@: |
2841 | @@: |
2842 | shr edx, 16 |
2842 | shr edx, 16 |
2843 | cmp word [edi + WDATA.draw_bgr_y+2], dx |
2843 | cmp word [edi + WDATA.draw_bgr_y+2], dx |
2844 | jbe @f |
2844 | jbe @f |
2845 | mov word [edi + WDATA.draw_bgr_y+2], dx |
2845 | mov word [edi + WDATA.draw_bgr_y+2], dx |
2846 | @@: |
2846 | @@: |
2847 | jmp .common |
2847 | jmp .common |
2848 | .set: |
2848 | .set: |
2849 | mov [edi + WDATA.draw_bgr_x], eax |
2849 | mov [edi + WDATA.draw_bgr_x], eax |
2850 | mov [edi + WDATA.draw_bgr_y], edx |
2850 | mov [edi + WDATA.draw_bgr_y], edx |
2851 | .common: |
2851 | .common: |
2852 | mov eax, [edi + WDATA.thread] |
2852 | mov eax, [edi + WDATA.thread] |
2853 | test eax, eax |
2853 | test eax, eax |
2854 | jz @f |
2854 | jz @f |
2855 | or [eax + APPDATA.occurred_events], EVENT_BACKGROUND |
2855 | or [eax + APPDATA.occurred_events], EVENT_BACKGROUND |
2856 | @@: |
2856 | @@: |
2857 | loop set_bgr_event |
2857 | loop set_bgr_event |
2858 | pop edi ecx |
2858 | pop edi ecx |
2859 | ;--------- set event 5 stop ----------- |
2859 | ;--------- set event 5 stop ----------- |
2860 | dec [REDRAW_BACKGROUND] ; got new update request? |
2860 | dec [REDRAW_BACKGROUND] ; got new update request? |
2861 | jnz backgr |
2861 | jnz backgr |
2862 | 2862 | ||
2863 | xor eax, eax |
2863 | xor eax, eax |
2864 | mov [background_window + WDATA.draw_data.left], eax |
2864 | mov [background_window + WDATA.draw_data.left], eax |
2865 | mov [background_window + WDATA.draw_data.top], eax |
2865 | mov [background_window + WDATA.draw_data.top], eax |
2866 | mov [background_window + WDATA.draw_data.right], eax |
2866 | mov [background_window + WDATA.draw_data.right], eax |
2867 | mov [background_window + WDATA.draw_data.bottom], eax |
2867 | mov [background_window + WDATA.draw_data.bottom], eax |
2868 | ;-------------------------------------- |
2868 | ;-------------------------------------- |
2869 | align 4 |
2869 | align 4 |
2870 | nobackgr: |
2870 | nobackgr: |
2871 | ; system shutdown request |
2871 | ; system shutdown request |
2872 | cmp [SYS_SHUTDOWN], byte 0 |
2872 | cmp [SYS_SHUTDOWN], byte 0 |
2873 | je noshutdown |
2873 | je noshutdown |
2874 | 2874 | ||
2875 | mov edx, [shutdown_processes] |
2875 | mov edx, [shutdown_processes] |
2876 | 2876 | ||
2877 | cmp [SYS_SHUTDOWN], dl |
2877 | cmp [SYS_SHUTDOWN], dl |
2878 | jne noshutdown |
2878 | jne noshutdown |
2879 | 2879 | ||
2880 | lea ecx, [edx-1] |
2880 | lea ecx, [edx-1] |
2881 | mov edx, SLOT_BASE + sizeof.APPDATA*2 ;OS_BASE+0x3040 |
2881 | mov edx, SLOT_BASE + sizeof.APPDATA*2 ;OS_BASE+0x3040 |
2882 | jecxz no_mark_system_shutdown |
2882 | jecxz no_mark_system_shutdown |
2883 | ;-------------------------------------- |
2883 | ;-------------------------------------- |
2884 | align 4 |
2884 | align 4 |
2885 | markz: |
2885 | markz: |
2886 | push ecx edx |
2886 | push ecx edx |
2887 | cmp [edx + APPDATA.state], TSTATE_FREE |
2887 | cmp [edx + APPDATA.state], TSTATE_FREE |
2888 | jz .nokill |
2888 | jz .nokill |
2889 | cmp [edx + APPDATA.process], sys_proc |
2889 | cmp [edx + APPDATA.process], sys_proc |
2890 | jz .nokill |
2890 | jz .nokill |
2891 | call request_terminate |
2891 | call request_terminate |
2892 | jmp .common |
2892 | jmp .common |
2893 | .nokill: |
2893 | .nokill: |
2894 | dec byte [SYS_SHUTDOWN] |
2894 | dec byte [SYS_SHUTDOWN] |
2895 | xor eax, eax |
2895 | xor eax, eax |
2896 | .common: |
2896 | .common: |
2897 | pop edx ecx |
2897 | pop edx ecx |
2898 | test eax, eax |
2898 | test eax, eax |
2899 | jz @f |
2899 | jz @f |
2900 | mov [edx + APPDATA.state], TSTATE_ZOMBIE |
2900 | mov [edx + APPDATA.state], TSTATE_ZOMBIE |
2901 | @@: |
2901 | @@: |
2902 | add edx, sizeof.APPDATA |
2902 | add edx, sizeof.APPDATA |
2903 | loop markz |
2903 | loop markz |
2904 | call wakeup_osloop |
2904 | call wakeup_osloop |
2905 | ;-------------------------------------- |
2905 | ;-------------------------------------- |
2906 | align 4 |
2906 | align 4 |
2907 | @@: |
2907 | @@: |
2908 | no_mark_system_shutdown: |
2908 | no_mark_system_shutdown: |
2909 | dec byte [SYS_SHUTDOWN] |
2909 | dec byte [SYS_SHUTDOWN] |
2910 | je system_shutdown |
2910 | je system_shutdown |
2911 | ;-------------------------------------- |
2911 | ;-------------------------------------- |
2912 | align 4 |
2912 | align 4 |
2913 | noshutdown: |
2913 | noshutdown: |
2914 | mov eax, [thread_count] ; termination |
2914 | mov eax, [thread_count] ; termination |
2915 | mov ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state |
2915 | mov ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state |
2916 | mov esi, 1 |
2916 | mov esi, 1 |
2917 | ;-------------------------------------- |
2917 | ;-------------------------------------- |
2918 | align 4 |
2918 | align 4 |
2919 | newct: |
2919 | newct: |
2920 | mov cl, [ebx] |
2920 | mov cl, [ebx] |
2921 | cmp cl, TSTATE_ZOMBIE |
2921 | cmp cl, TSTATE_ZOMBIE |
2922 | jz .terminate |
2922 | jz .terminate |
2923 | 2923 | ||
2924 | cmp cl, TSTATE_TERMINATING |
2924 | cmp cl, TSTATE_TERMINATING |
2925 | jnz .noterminate |
2925 | jnz .noterminate |
2926 | .terminate: |
2926 | .terminate: |
2927 | pushad |
2927 | pushad |
2928 | push esi |
2928 | push esi |
2929 | mov ecx, dword[ebx - APPDATA.state + APPDATA.window] |
2929 | mov ecx, dword[ebx - APPDATA.state + APPDATA.window] |
2930 | call restore_default_cursor_before_killing |
2930 | call restore_default_cursor_before_killing |
2931 | 2931 | ||
2932 | pop esi |
2932 | pop esi |
2933 | call terminate |
2933 | call terminate |
2934 | popad |
2934 | popad |
2935 | cmp byte [SYS_SHUTDOWN], 0 |
2935 | cmp byte [SYS_SHUTDOWN], 0 |
2936 | jz .noterminate |
2936 | jz .noterminate |
2937 | dec byte [SYS_SHUTDOWN] |
2937 | dec byte [SYS_SHUTDOWN] |
2938 | je system_shutdown |
2938 | je system_shutdown |
2939 | 2939 | ||
2940 | .noterminate: |
2940 | .noterminate: |
2941 | add ebx, sizeof.APPDATA |
2941 | add ebx, sizeof.APPDATA |
2942 | inc esi |
2942 | inc esi |
2943 | dec eax |
2943 | dec eax |
2944 | jnz newct |
2944 | jnz newct |
2945 | ret |
2945 | ret |
2946 | ;----------------------------------------------------------------------------- |
2946 | ;----------------------------------------------------------------------------- |
2947 | align 4 |
2947 | align 4 |
2948 | ; eax - ptr to WDATA |
2948 | ; eax - ptr to WDATA |
2949 | redrawscreen: |
2949 | redrawscreen: |
2950 | ; eax , if process window_data base is eax, do not set flag/limits |
2950 | ; eax , if process window_data base is eax, do not set flag/limits |
2951 | 2951 | ||
2952 | pushad |
2952 | pushad |
2953 | push eax |
2953 | push eax |
2954 | 2954 | ||
2955 | ;;; mov ebx,2 |
2955 | ;;; mov ebx,2 |
2956 | ;;; call delay_hs |
2956 | ;;; call delay_hs |
2957 | 2957 | ||
2958 | ;mov ecx,0 ; redraw flags for apps |
2958 | ;mov ecx,0 ; redraw flags for apps |
2959 | xor ecx, ecx |
2959 | xor ecx, ecx |
2960 | ;-------------------------------------- |
2960 | ;-------------------------------------- |
2961 | align 4 |
2961 | align 4 |
2962 | newdw2: |
2962 | newdw2: |
2963 | inc ecx |
2963 | inc ecx |
2964 | push ecx |
2964 | push ecx |
2965 | 2965 | ||
2966 | mov eax, ecx |
2966 | mov eax, ecx |
2967 | shl eax, BSF sizeof.WDATA |
2967 | shl eax, BSF sizeof.WDATA |
2968 | add eax, window_data |
2968 | add eax, window_data |
2969 | 2969 | ||
2970 | cmp eax, [esp+4] |
2970 | cmp eax, [esp+4] |
2971 | je not_this_task |
2971 | je not_this_task |
2972 | ; check if window in redraw area |
2972 | ; check if window in redraw area |
2973 | mov edi, eax |
2973 | mov edi, eax |
2974 | 2974 | ||
2975 | cmp ecx, 1 ; limit for background |
2975 | cmp ecx, 1 ; limit for background |
2976 | jz bgli |
2976 | jz bgli |
2977 | 2977 | ||
2978 | mov eax, [esp+4] ;if upper in z-position - no redraw |
2978 | mov eax, [esp+4] ;if upper in z-position - no redraw |
2979 | test eax, eax |
2979 | test eax, eax |
2980 | jz @f |
2980 | jz @f |
2981 | mov al, [eax + WDATA.z_modif] |
2981 | mov al, [eax + WDATA.z_modif] |
2982 | cmp [edi + WDATA.z_modif], al |
2982 | cmp [edi + WDATA.z_modif], al |
2983 | jg ricino |
2983 | jg ricino |
2984 | @@: |
2984 | @@: |
2985 | 2985 | ||
2986 | mov eax, [edi + WDATA.box.left] |
2986 | mov eax, [edi + WDATA.box.left] |
2987 | mov ebx, [edi + WDATA.box.top] |
2987 | mov ebx, [edi + WDATA.box.top] |
2988 | 2988 | ||
2989 | cmp ebx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
2989 | cmp ebx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
2990 | jae ricino |
2990 | jae ricino |
2991 | 2991 | ||
2992 | cmp eax, [draw_limits.right] ; ecx = area x end eax = window x start |
2992 | cmp eax, [draw_limits.right] ; ecx = area x end eax = window x start |
2993 | jae ricino |
2993 | jae ricino |
2994 | 2994 | ||
2995 | mov eax, [edi + WDATA.box.left] |
2995 | mov eax, [edi + WDATA.box.left] |
2996 | mov ebx, [edi + WDATA.box.top] |
2996 | mov ebx, [edi + WDATA.box.top] |
2997 | mov ecx, [edi + WDATA.box.width] |
2997 | mov ecx, [edi + WDATA.box.width] |
2998 | mov edx, [edi + WDATA.box.height] |
2998 | mov edx, [edi + WDATA.box.height] |
2999 | add ecx, eax |
2999 | add ecx, eax |
3000 | add edx, ebx |
3000 | add edx, ebx |
3001 | 3001 | ||
3002 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3002 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3003 | cmp edx, eax |
3003 | cmp edx, eax |
3004 | jb ricino |
3004 | jb ricino |
3005 | 3005 | ||
3006 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3006 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3007 | cmp ecx, eax |
3007 | cmp ecx, eax |
3008 | jb ricino |
3008 | jb ricino |
3009 | ;-------------------------------------- |
3009 | ;-------------------------------------- |
3010 | align 4 |
3010 | align 4 |
3011 | bgli: |
3011 | bgli: |
3012 | cmp dword[esp], 1 ; check index in window_data array, 1 - idle |
3012 | cmp dword[esp], 1 ; check index in window_data array, 1 - idle |
3013 | jnz .az |
3013 | jnz .az |
3014 | 3014 | ||
3015 | cmp [REDRAW_BACKGROUND], 0 |
3015 | cmp [REDRAW_BACKGROUND], 0 |
3016 | jz .az |
3016 | jz .az |
3017 | 3017 | ||
3018 | mov dl, 0 |
3018 | mov dl, 0 |
3019 | mov ebx, [draw_limits.left] |
3019 | mov ebx, [draw_limits.left] |
3020 | cmp ebx, [edi + WDATA.draw_data.left] |
3020 | cmp ebx, [edi + WDATA.draw_data.left] |
3021 | jae @f |
3021 | jae @f |
3022 | 3022 | ||
3023 | mov [edi + WDATA.draw_data.left], ebx |
3023 | mov [edi + WDATA.draw_data.left], ebx |
3024 | mov dl, 1 |
3024 | mov dl, 1 |
3025 | ;-------------------------------------- |
3025 | ;-------------------------------------- |
3026 | align 4 |
3026 | align 4 |
3027 | @@: |
3027 | @@: |
3028 | mov ebx, [draw_limits.top] |
3028 | mov ebx, [draw_limits.top] |
3029 | cmp ebx, [edi + WDATA.draw_data.top] |
3029 | cmp ebx, [edi + WDATA.draw_data.top] |
3030 | jae @f |
3030 | jae @f |
3031 | 3031 | ||
3032 | mov [edi + WDATA.draw_data.top], ebx |
3032 | mov [edi + WDATA.draw_data.top], ebx |
3033 | mov dl, 1 |
3033 | mov dl, 1 |
3034 | ;-------------------------------------- |
3034 | ;-------------------------------------- |
3035 | align 4 |
3035 | align 4 |
3036 | @@: |
3036 | @@: |
3037 | mov ebx, [draw_limits.right] |
3037 | mov ebx, [draw_limits.right] |
3038 | cmp ebx, [edi + WDATA.draw_data.right] |
3038 | cmp ebx, [edi + WDATA.draw_data.right] |
3039 | jbe @f |
3039 | jbe @f |
3040 | 3040 | ||
3041 | mov [edi + WDATA.draw_data.right], ebx |
3041 | mov [edi + WDATA.draw_data.right], ebx |
3042 | mov dl, 1 |
3042 | mov dl, 1 |
3043 | ;-------------------------------------- |
3043 | ;-------------------------------------- |
3044 | align 4 |
3044 | align 4 |
3045 | @@: |
3045 | @@: |
3046 | mov ebx, [draw_limits.bottom] |
3046 | mov ebx, [draw_limits.bottom] |
3047 | cmp ebx, [edi + WDATA.draw_data.bottom] |
3047 | cmp ebx, [edi + WDATA.draw_data.bottom] |
3048 | jbe @f |
3048 | jbe @f |
3049 | 3049 | ||
3050 | mov [edi + WDATA.draw_data.bottom], ebx |
3050 | mov [edi + WDATA.draw_data.bottom], ebx |
3051 | mov dl, 1 |
3051 | mov dl, 1 |
3052 | ;-------------------------------------- |
3052 | ;-------------------------------------- |
3053 | align 4 |
3053 | align 4 |
3054 | @@: |
3054 | @@: |
3055 | add [REDRAW_BACKGROUND], dl |
3055 | add [REDRAW_BACKGROUND], dl |
3056 | call wakeup_osloop |
3056 | call wakeup_osloop |
3057 | jmp newdw8 |
3057 | jmp newdw8 |
3058 | ;-------------------------------------- |
3058 | ;-------------------------------------- |
3059 | align 4 |
3059 | align 4 |
3060 | .az: |
3060 | .az: |
3061 | mov ebx, [draw_limits.left] ; set limits |
3061 | mov ebx, [draw_limits.left] ; set limits |
3062 | mov [edi + WDATA.draw_data.left], ebx |
3062 | mov [edi + WDATA.draw_data.left], ebx |
3063 | mov ebx, [draw_limits.top] |
3063 | mov ebx, [draw_limits.top] |
3064 | mov [edi + WDATA.draw_data.top], ebx |
3064 | mov [edi + WDATA.draw_data.top], ebx |
3065 | mov ebx, [draw_limits.right] |
3065 | mov ebx, [draw_limits.right] |
3066 | mov [edi + WDATA.draw_data.right], ebx |
3066 | mov [edi + WDATA.draw_data.right], ebx |
3067 | mov ebx, [draw_limits.bottom] |
3067 | mov ebx, [draw_limits.bottom] |
3068 | mov [edi + WDATA.draw_data.bottom], ebx |
3068 | mov [edi + WDATA.draw_data.bottom], ebx |
3069 | 3069 | ||
3070 | cmp dword [esp], 1 ; check idle thread |
3070 | cmp dword [esp], 1 ; check idle thread |
3071 | jne nobgrd |
3071 | jne nobgrd |
3072 | inc [REDRAW_BACKGROUND] |
3072 | inc [REDRAW_BACKGROUND] |
3073 | call wakeup_osloop |
3073 | call wakeup_osloop |
3074 | ;-------------------------------------- |
3074 | ;-------------------------------------- |
3075 | align 4 |
3075 | align 4 |
3076 | newdw8: |
3076 | newdw8: |
3077 | nobgrd: |
3077 | nobgrd: |
3078 | ;-------------------------------------- |
3078 | ;-------------------------------------- |
3079 | push edi ebp |
3079 | push edi ebp |
3080 | mov edi, [esp+8] |
3080 | mov edi, [esp+8] |
3081 | cmp edi, 1 |
3081 | cmp edi, 1 |
3082 | je .found |
3082 | je .found |
3083 | 3083 | ||
3084 | mov eax, [draw_limits.left] |
3084 | mov eax, [draw_limits.left] |
3085 | mov ebx, [draw_limits.top] |
3085 | mov ebx, [draw_limits.top] |
3086 | mov ecx, [draw_limits.right] |
3086 | mov ecx, [draw_limits.right] |
3087 | sub ecx, eax |
3087 | sub ecx, eax |
3088 | test ecx, ecx |
3088 | test ecx, ecx |
3089 | jz .not_found |
3089 | jz .not_found |
3090 | 3090 | ||
3091 | mov edx, [draw_limits.bottom] |
3091 | mov edx, [draw_limits.bottom] |
3092 | sub edx, ebx |
3092 | sub edx, ebx |
3093 | test edx, edx |
3093 | test edx, edx |
3094 | jz .not_found |
3094 | jz .not_found |
3095 | 3095 | ||
3096 | ; eax - x, ebx - y |
3096 | ; eax - x, ebx - y |
3097 | ; ecx - size x, edx - size y |
3097 | ; ecx - size x, edx - size y |
3098 | add ebx, edx |
3098 | add ebx, edx |
3099 | ;-------------------------------------- |
3099 | ;-------------------------------------- |
3100 | align 4 |
3100 | align 4 |
3101 | .start_y: |
3101 | .start_y: |
3102 | push ecx |
3102 | push ecx |
3103 | ;-------------------------------------- |
3103 | ;-------------------------------------- |
3104 | align 4 |
3104 | align 4 |
3105 | .start_x: |
3105 | .start_x: |
3106 | add eax, ecx |
3106 | add eax, ecx |
3107 | mov ebp, [d_width_calc_area + ebx*4] |
3107 | mov ebp, [d_width_calc_area + ebx*4] |
3108 | add ebp, [_display.win_map] |
3108 | add ebp, [_display.win_map] |
3109 | movzx ebp, byte[eax+ebp] ; get value for current point |
3109 | movzx ebp, byte[eax+ebp] ; get value for current point |
3110 | cmp ebp, edi |
3110 | cmp ebp, edi |
3111 | jne @f |
3111 | jne @f |
3112 | 3112 | ||
3113 | pop ecx |
3113 | pop ecx |
3114 | jmp .found |
3114 | jmp .found |
3115 | ;-------------------------------------- |
3115 | ;-------------------------------------- |
3116 | align 4 |
3116 | align 4 |
3117 | @@: |
3117 | @@: |
3118 | sub eax, ecx |
3118 | sub eax, ecx |
3119 | 3119 | ||
3120 | dec ecx |
3120 | dec ecx |
3121 | jns .start_x |
3121 | jns .start_x |
3122 | 3122 | ||
3123 | pop ecx |
3123 | pop ecx |
3124 | dec ebx |
3124 | dec ebx |
3125 | dec edx |
3125 | dec edx |
3126 | jns .start_y |
3126 | jns .start_y |
3127 | ;-------------------------------------- |
3127 | ;-------------------------------------- |
3128 | align 4 |
3128 | align 4 |
3129 | .not_found: |
3129 | .not_found: |
3130 | pop ebp edi |
3130 | pop ebp edi |
3131 | jmp ricino |
3131 | jmp ricino |
3132 | ;-------------------------------------- |
3132 | ;-------------------------------------- |
3133 | align 4 |
3133 | align 4 |
3134 | .found: |
3134 | .found: |
3135 | pop ebp edi |
3135 | pop ebp edi |
3136 | 3136 | ||
3137 | mov [edi + WDATA.fl_redraw], WSTATE_REDRAW ; mark as redraw |
3137 | mov [edi + WDATA.fl_redraw], WSTATE_REDRAW ; mark as redraw |
3138 | ;-------------------------------------- |
3138 | ;-------------------------------------- |
3139 | align 4 |
3139 | align 4 |
3140 | ricino: |
3140 | ricino: |
3141 | not_this_task: |
3141 | not_this_task: |
3142 | pop ecx |
3142 | pop ecx |
3143 | 3143 | ||
3144 | cmp ecx, [thread_count] |
3144 | cmp ecx, [thread_count] |
3145 | jle newdw2 |
3145 | jle newdw2 |
3146 | 3146 | ||
3147 | pop eax |
3147 | pop eax |
3148 | popad |
3148 | popad |
3149 | ret |
3149 | ret |
3150 | ;----------------------------------------------------------------------------- |
3150 | ;----------------------------------------------------------------------------- |
3151 | align 4 |
3151 | align 4 |
3152 | calculatebackground: ; background |
3152 | calculatebackground: ; background |
3153 | mov edi, [_display.win_map] ; set os to use all pixels |
3153 | mov edi, [_display.win_map] ; set os to use all pixels |
3154 | mov eax, 0x01010101 |
3154 | mov eax, 0x01010101 |
3155 | mov ecx, [_display.win_map_size] |
3155 | mov ecx, [_display.win_map_size] |
3156 | shr ecx, 2 |
3156 | shr ecx, 2 |
3157 | rep stosd |
3157 | rep stosd |
3158 | mov byte[background_window + WDATA.z_modif], ZPOS_DESKTOP |
3158 | mov byte[background_window + WDATA.z_modif], ZPOS_DESKTOP |
3159 | mov [REDRAW_BACKGROUND], 0 |
3159 | mov [REDRAW_BACKGROUND], 0 |
3160 | ret |
3160 | ret |
3161 | ;----------------------------------------------------------------------------- |
3161 | ;----------------------------------------------------------------------------- |
3162 | uglobal |
3162 | uglobal |
3163 | imax dd 0x0 |
3163 | imax dd 0x0 |
3164 | endg |
3164 | endg |
3165 | ;----------------------------------------------------------------------------- |
3165 | ;----------------------------------------------------------------------------- |
3166 | align 4 |
3166 | align 4 |
3167 | delay_ms: ; delay in 1/1000 sec |
3167 | delay_ms: ; delay in 1/1000 sec |
3168 | pushad |
3168 | pushad |
3169 | 3169 | ||
3170 | cmp [hpet_base], 0 |
3170 | cmp [hpet_base], 0 |
3171 | jz .no_hpet |
3171 | jz .no_hpet |
3172 | mov eax, esi |
3172 | mov eax, esi |
3173 | mov edx, 1_000_000 ; ms to ns |
3173 | mov edx, 1_000_000 ; ms to ns |
3174 | mul edx |
3174 | mul edx |
3175 | mov ebx, edx |
3175 | mov ebx, edx |
3176 | mov ecx, eax |
3176 | mov ecx, eax |
3177 | 3177 | ||
3178 | push ecx |
3178 | push ecx |
3179 | call get_clock_ns |
3179 | call get_clock_ns |
3180 | pop ecx |
3180 | pop ecx |
3181 | mov edi, edx |
3181 | mov edi, edx |
3182 | mov esi, eax |
3182 | mov esi, eax |
3183 | .wait: |
3183 | .wait: |
3184 | push ecx |
3184 | push ecx |
3185 | call get_clock_ns |
3185 | call get_clock_ns |
3186 | pop ecx |
3186 | pop ecx |
3187 | sub eax, esi |
3187 | sub eax, esi |
3188 | sbb edx, edi |
3188 | sbb edx, edi |
3189 | sub eax, ecx |
3189 | sub eax, ecx |
3190 | sbb edx, ebx |
3190 | sbb edx, ebx |
3191 | jc .wait |
3191 | jc .wait |
3192 | jmp .done |
3192 | jmp .done |
3193 | 3193 | ||
3194 | .no_hpet: |
3194 | .no_hpet: |
3195 | mov ecx, esi |
3195 | mov ecx, esi |
3196 | ; |
3196 | ; |
3197 | imul ecx, 33941 |
3197 | imul ecx, 33941 |
3198 | shr ecx, 9 |
3198 | shr ecx, 9 |
3199 | ; |
3199 | ; |
3200 | 3200 | ||
3201 | in al, 0x61 |
3201 | in al, 0x61 |
3202 | and al, 0x10 |
3202 | and al, 0x10 |
3203 | mov ah, al |
3203 | mov ah, al |
3204 | cld |
3204 | cld |
3205 | 3205 | ||
3206 | .cnt1: |
3206 | .cnt1: |
3207 | in al, 0x61 |
3207 | in al, 0x61 |
3208 | and al, 0x10 |
3208 | and al, 0x10 |
3209 | cmp al, ah |
3209 | cmp al, ah |
3210 | jz .cnt1 |
3210 | jz .cnt1 |
3211 | 3211 | ||
3212 | mov ah, al |
3212 | mov ah, al |
3213 | loop .cnt1 |
3213 | loop .cnt1 |
3214 | 3214 | ||
3215 | .done: |
3215 | .done: |
3216 | popad |
3216 | popad |
3217 | ret |
3217 | ret |
3218 | ;----------------------------------------------------------------------------- |
3218 | ;----------------------------------------------------------------------------- |
3219 | align 4 |
3219 | align 4 |
3220 | set_app_param: |
3220 | set_app_param: |
3221 | mov edi, [current_slot] |
3221 | mov edi, [current_slot] |
3222 | xchg ebx, [edi + APPDATA.event_mask] ; set new event mask |
3222 | xchg ebx, [edi + APPDATA.event_mask] ; set new event mask |
3223 | mov [esp + SYSCALL_STACK.eax], ebx ; return old mask value |
3223 | mov [esp + SYSCALL_STACK.eax], ebx ; return old mask value |
3224 | ret |
3224 | ret |
3225 | ;----------------------------------------------------------------------------- |
3225 | ;----------------------------------------------------------------------------- |
3226 | 3226 | ||
3227 | ; this is for syscall |
3227 | ; this is for syscall |
3228 | proc delay_hs_unprotected |
3228 | proc delay_hs_unprotected |
3229 | call unprotect_from_terminate |
3229 | call unprotect_from_terminate |
3230 | call delay_hs |
3230 | call delay_hs |
3231 | call protect_from_terminate |
3231 | call protect_from_terminate |
3232 | ret |
3232 | ret |
3233 | endp |
3233 | endp |
3234 | 3234 | ||
3235 | if 1 |
3235 | if 1 |
3236 | align 4 |
3236 | align 4 |
3237 | delay_hs: ; delay in 1/100 secs |
3237 | delay_hs: ; delay in 1/100 secs |
3238 | ; ebx = delay time |
3238 | ; ebx = delay time |
3239 | pushad |
3239 | pushad |
3240 | push ebx |
3240 | push ebx |
3241 | xor esi, esi |
3241 | xor esi, esi |
3242 | mov ecx, MANUAL_DESTROY |
3242 | mov ecx, MANUAL_DESTROY |
3243 | call create_event |
3243 | call create_event |
3244 | test eax, eax |
3244 | test eax, eax |
3245 | jz .done |
3245 | jz .done |
3246 | 3246 | ||
3247 | mov ebx, edx |
3247 | mov ebx, edx |
3248 | mov ecx, [esp] |
3248 | mov ecx, [esp] |
3249 | push edx |
3249 | push edx |
3250 | push eax |
3250 | push eax |
3251 | call wait_event_timeout |
3251 | call wait_event_timeout |
3252 | pop eax |
3252 | pop eax |
3253 | pop ebx |
3253 | pop ebx |
3254 | call destroy_event |
3254 | call destroy_event |
3255 | .done: |
3255 | .done: |
3256 | add esp, 4 |
3256 | add esp, 4 |
3257 | popad |
3257 | popad |
3258 | ret |
3258 | ret |
3259 | 3259 | ||
3260 | else |
3260 | else |
3261 | 3261 | ||
3262 | align 4 |
3262 | align 4 |
3263 | delay_hs: ; delay in 1/100 secs |
3263 | delay_hs: ; delay in 1/100 secs |
3264 | ; ebx = delay time |
3264 | ; ebx = delay time |
3265 | push ecx |
3265 | push ecx |
3266 | push edx |
3266 | push edx |
3267 | 3267 | ||
3268 | mov edx, [timer_ticks] |
3268 | mov edx, [timer_ticks] |
3269 | ;-------------------------------------- |
3269 | ;-------------------------------------- |
3270 | align 4 |
3270 | align 4 |
3271 | .newtic: |
3271 | .newtic: |
3272 | mov ecx, [timer_ticks] |
3272 | mov ecx, [timer_ticks] |
3273 | sub ecx, edx |
3273 | sub ecx, edx |
3274 | cmp ecx, ebx |
3274 | cmp ecx, ebx |
3275 | jae .zerodelay |
3275 | jae .zerodelay |
3276 | 3276 | ||
3277 | call change_task |
3277 | call change_task |
3278 | 3278 | ||
3279 | jmp .newtic |
3279 | jmp .newtic |
3280 | ;-------------------------------------- |
3280 | ;-------------------------------------- |
3281 | align 4 |
3281 | align 4 |
3282 | .zerodelay: |
3282 | .zerodelay: |
3283 | pop edx |
3283 | pop edx |
3284 | pop ecx |
3284 | pop ecx |
3285 | ret |
3285 | ret |
3286 | end if |
3286 | end if |
3287 | 3287 | ||
3288 | ;----------------------------------------------------------------------------- |
3288 | ;----------------------------------------------------------------------------- |
3289 | align 16 ;very often call this subrutine |
3289 | align 16 ;very often call this subrutine |
3290 | memmove: ; memory move in bytes |
3290 | memmove: ; memory move in bytes |
3291 | ; eax = from |
3291 | ; eax = from |
3292 | ; ebx = to |
3292 | ; ebx = to |
3293 | ; ecx = no of bytes |
3293 | ; ecx = no of bytes |
3294 | test ecx, ecx |
3294 | test ecx, ecx |
3295 | jle .ret |
3295 | jle .ret |
3296 | 3296 | ||
3297 | push esi edi ecx |
3297 | push esi edi ecx |
3298 | 3298 | ||
3299 | mov edi, ebx |
3299 | mov edi, ebx |
3300 | mov esi, eax |
3300 | mov esi, eax |
3301 | 3301 | ||
3302 | test ecx, not 11b |
3302 | test ecx, not 11b |
3303 | jz @f |
3303 | jz @f |
3304 | 3304 | ||
3305 | push ecx |
3305 | push ecx |
3306 | shr ecx, 2 |
3306 | shr ecx, 2 |
3307 | rep movsd |
3307 | rep movsd |
3308 | pop ecx |
3308 | pop ecx |
3309 | and ecx, 11b |
3309 | and ecx, 11b |
3310 | jz .finish |
3310 | jz .finish |
3311 | ;-------------------------------------- |
3311 | ;-------------------------------------- |
3312 | align 4 |
3312 | align 4 |
3313 | @@: |
3313 | @@: |
3314 | rep movsb |
3314 | rep movsb |
3315 | ;-------------------------------------- |
3315 | ;-------------------------------------- |
3316 | align 4 |
3316 | align 4 |
3317 | .finish: |
3317 | .finish: |
3318 | pop ecx edi esi |
3318 | pop ecx edi esi |
3319 | ;-------------------------------------- |
3319 | ;-------------------------------------- |
3320 | align 4 |
3320 | align 4 |
3321 | .ret: |
3321 | .ret: |
3322 | ret |
3322 | ret |
3323 | ;----------------------------------------------------------------------------- |
3323 | ;----------------------------------------------------------------------------- |
3324 | 3324 | ||
3325 | ; in: eax = port |
3325 | ; in: eax = port |
3326 | ; ebp = subfunction |
3326 | ; ebp = subfunction |
3327 | ; 0 - set access |
3327 | ; 0 - set access |
3328 | ; 1 - clear access |
3328 | ; 1 - clear access |
3329 | ; out: not return value |
3329 | ; out: not return value |
3330 | align 4 |
3330 | align 4 |
3331 | set_io_access_rights: |
3331 | set_io_access_rights: |
3332 | push edi eax |
3332 | push edi eax |
3333 | mov edi, tss._io_map_0 |
3333 | mov edi, tss._io_map_0 |
3334 | 3334 | ||
3335 | test ebp, ebp ; enable access - ebp = 0 |
3335 | test ebp, ebp ; enable access - ebp = 0 |
3336 | jnz .siar1 |
3336 | jnz .siar1 |
3337 | 3337 | ||
3338 | btr [edi], eax |
3338 | btr [edi], eax |
3339 | pop eax edi |
3339 | pop eax edi |
3340 | ret |
3340 | ret |
3341 | .siar1: |
3341 | .siar1: |
3342 | bts [edi], eax ; disable access - ebp = 1 |
3342 | bts [edi], eax ; disable access - ebp = 1 |
3343 | pop eax edi |
3343 | pop eax edi |
3344 | ret |
3344 | ret |
3345 | 3345 | ||
3346 | align 4 |
3346 | align 4 |
3347 | ; @brief ReservePortArea and FreePortArea |
3347 | ; @brief ReservePortArea and FreePortArea |
3348 | ; @param edx number end arrea of ports (include last number of port) |
3348 | ; @param edx number end arrea of ports (include last number of port) |
3349 | ; @param ecx number start arrea of ports |
3349 | ; @param ecx number start arrea of ports |
3350 | ; @param ebx sub function 0 - reserve, 1 - free |
3350 | ; @param ebx sub function 0 - reserve, 1 - free |
3351 | ; @param eax 46 - number function |
3351 | ; @param eax 46 - number function |
3352 | ; @returns eax = 0 - succesful eax = 1 - error |
3352 | ; @returns eax = 0 - succesful eax = 1 - error |
3353 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
3353 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
3354 | 3354 | ||
3355 | call r_f_port_area |
3355 | call r_f_port_area |
3356 | mov [esp + SYSCALL_STACK.eax], eax |
3356 | mov [esp + SYSCALL_STACK.eax], eax |
3357 | ret |
3357 | ret |
3358 | 3358 | ||
3359 | ;reserve/free group of ports |
3359 | ;reserve/free group of ports |
3360 | ; * eax = 46 - number function |
3360 | ; * eax = 46 - number function |
3361 | ; * ebx = 0 - reserve, 1 - free |
3361 | ; * ebx = 0 - reserve, 1 - free |
3362 | ; * ecx = number start arrea of ports |
3362 | ; * ecx = number start arrea of ports |
3363 | ; * edx = number end arrea of ports (include last number of port) |
3363 | ; * edx = number end arrea of ports (include last number of port) |
3364 | ;Return value: |
3364 | ;Return value: |
3365 | ; * eax = 0 - succesful |
3365 | ; * eax = 0 - succesful |
3366 | ; * eax = 1 - error |
3366 | ; * eax = 1 - error |
3367 | ; * The system has reserve this ports: |
3367 | ; * The system has reserve this ports: |
3368 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3368 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
3369 | ;destroys eax,ebx, ebp |
3369 | ;destroys eax,ebx, ebp |
3370 | r_f_port_area: |
3370 | r_f_port_area: |
3371 | 3371 | ||
3372 | test ebx, ebx |
3372 | test ebx, ebx |
3373 | jnz .free_port_area |
3373 | jnz .free_port_area |
3374 | 3374 | ||
3375 | cmp ecx, edx ; beginning > end ? |
3375 | cmp ecx, edx ; beginning > end ? |
3376 | ja .err |
3376 | ja .err |
3377 | cmp edx, 65536 ;test ebx, not 0xffff |
3377 | cmp edx, 65536 ;test ebx, not 0xffff |
3378 | jae .err |
3378 | jae .err |
3379 | mov eax, [RESERVED_PORTS] |
3379 | mov eax, [RESERVED_PORTS] |
3380 | test eax, eax ; no reserved areas ? |
3380 | test eax, eax ; no reserved areas ? |
3381 | je .rpal2 |
3381 | je .rpal2 |
3382 | cmp eax, 255 ; max reserved |
3382 | cmp eax, 255 ; max reserved |
3383 | jae .err |
3383 | jae .err |
3384 | .rpal3: |
3384 | .rpal3: |
3385 | mov ebx, eax |
3385 | mov ebx, eax |
3386 | shl ebx, 4 ;16 byte is sizeof item in RESERVED_PORTS table |
3386 | shl ebx, 4 ;16 byte is sizeof item in RESERVED_PORTS table |
3387 | add ebx, RESERVED_PORTS |
3387 | add ebx, RESERVED_PORTS |
3388 | cmp ecx, [ebx+8] |
3388 | cmp ecx, [ebx+8] |
3389 | ja .rpal4 |
3389 | ja .rpal4 |
3390 | cmp edx, [ebx+4] |
3390 | cmp edx, [ebx+4] |
3391 | jae .err |
3391 | jae .err |
3392 | .rpal4: |
3392 | .rpal4: |
3393 | dec eax |
3393 | dec eax |
3394 | jnz .rpal3 |
3394 | jnz .rpal3 |
3395 | jmp .rpal2 |
3395 | jmp .rpal2 |
3396 | .err: |
3396 | .err: |
3397 | xor eax, eax |
3397 | xor eax, eax |
3398 | inc eax |
3398 | inc eax |
3399 | ret |
3399 | ret |
3400 | 3400 | ||
3401 | .rpal2: |
3401 | .rpal2: |
3402 | ; enable port access at port IO map |
3402 | ; enable port access at port IO map |
3403 | pushad ; start enable io map |
3403 | pushad ; start enable io map |
3404 | mov eax, ecx |
3404 | mov eax, ecx |
3405 | xor ebp, ebp ; enable - eax = port |
3405 | xor ebp, ebp ; enable - eax = port |
3406 | cli |
3406 | cli |
3407 | .new_port_access: |
3407 | .new_port_access: |
3408 | call set_io_access_rights |
3408 | call set_io_access_rights |
3409 | 3409 | ||
3410 | inc eax |
3410 | inc eax |
3411 | cmp eax, edx |
3411 | cmp eax, edx |
3412 | jbe .new_port_access |
3412 | jbe .new_port_access |
3413 | 3413 | ||
3414 | sti |
3414 | sti |
3415 | popad ; end enable io map |
3415 | popad ; end enable io map |
3416 | 3416 | ||
3417 | mov eax, [RESERVED_PORTS] |
3417 | mov eax, [RESERVED_PORTS] |
3418 | inc eax |
3418 | inc eax |
3419 | mov [RESERVED_PORTS], eax |
3419 | mov [RESERVED_PORTS], eax |
3420 | shl eax, 4 |
3420 | shl eax, 4 |
3421 | add eax, RESERVED_PORTS |
3421 | add eax, RESERVED_PORTS |
3422 | mov ebx, [current_slot] |
3422 | mov ebx, [current_slot] |
3423 | mov ebx, [ebx + APPDATA.tid] |
3423 | mov ebx, [ebx + APPDATA.tid] |
3424 | mov [eax], ebx ; tid |
3424 | mov [eax], ebx ; tid |
3425 | mov [eax+4], ecx ;start port |
3425 | mov [eax+4], ecx ;start port |
3426 | mov [eax+8], edx ;finish port |
3426 | mov [eax+8], edx ;finish port |
3427 | 3427 | ||
3428 | xor eax, eax |
3428 | xor eax, eax |
3429 | ret |
3429 | ret |
3430 | 3430 | ||
3431 | .free_port_area: |
3431 | .free_port_area: |
3432 | 3432 | ||
3433 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
3433 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
3434 | test eax, eax |
3434 | test eax, eax |
3435 | jz .frpal2 |
3435 | jz .frpal2 |
3436 | mov ebx, [current_slot] |
3436 | mov ebx, [current_slot] |
3437 | mov ebx, [ebx + APPDATA.tid] |
3437 | mov ebx, [ebx + APPDATA.tid] |
3438 | .frpal3: |
3438 | .frpal3: |
3439 | mov edi, eax |
3439 | mov edi, eax |
3440 | shl edi, 4 |
3440 | shl edi, 4 |
3441 | add edi, RESERVED_PORTS |
3441 | add edi, RESERVED_PORTS |
3442 | cmp ebx, [edi] |
3442 | cmp ebx, [edi] |
3443 | jne .frpal4 |
3443 | jne .frpal4 |
3444 | cmp ecx, [edi+4] |
3444 | cmp ecx, [edi+4] |
3445 | jne .frpal4 |
3445 | jne .frpal4 |
3446 | cmp edx, [edi+8] |
3446 | cmp edx, [edi+8] |
3447 | jne .frpal4 |
3447 | jne .frpal4 |
3448 | jmp .frpal1 |
3448 | jmp .frpal1 |
3449 | .frpal4: |
3449 | .frpal4: |
3450 | dec eax |
3450 | dec eax |
3451 | jnz .frpal3 |
3451 | jnz .frpal3 |
3452 | .frpal2: |
3452 | .frpal2: |
3453 | inc eax |
3453 | inc eax |
3454 | ret |
3454 | ret |
3455 | .frpal1: |
3455 | .frpal1: |
3456 | push ecx |
3456 | push ecx |
3457 | mov ecx, 256 |
3457 | mov ecx, 256 |
3458 | sub ecx, eax |
3458 | sub ecx, eax |
3459 | shl ecx, 4 |
3459 | shl ecx, 4 |
3460 | mov esi, edi |
3460 | mov esi, edi |
3461 | add esi, 16 |
3461 | add esi, 16 |
3462 | cld |
3462 | cld |
3463 | rep movsb |
3463 | rep movsb |
3464 | 3464 | ||
3465 | dec dword [RESERVED_PORTS] |
3465 | dec dword [RESERVED_PORTS] |
3466 | ;disable port access at port IO map |
3466 | ;disable port access at port IO map |
3467 | ; start disable io map |
3467 | ; start disable io map |
3468 | pop eax ;start port |
3468 | pop eax ;start port |
3469 | ;cmp edx, 65536 |
3469 | ;cmp edx, 65536 |
3470 | ;jge no_mask_io |
3470 | ;jge no_mask_io |
3471 | 3471 | ||
3472 | xor ebp, ebp |
3472 | xor ebp, ebp |
3473 | inc ebp |
3473 | inc ebp |
3474 | .new_port_access_disable: ; disable - eax = port |
3474 | .new_port_access_disable: ; disable - eax = port |
3475 | call set_io_access_rights |
3475 | call set_io_access_rights |
3476 | 3476 | ||
3477 | inc eax |
3477 | inc eax |
3478 | cmp eax, edx |
3478 | cmp eax, edx |
3479 | jbe .new_port_access_disable |
3479 | jbe .new_port_access_disable |
3480 | ; end disable io map |
3480 | ; end disable io map |
3481 | xor eax, eax |
3481 | xor eax, eax |
3482 | ret |
3482 | ret |
3483 | ;----------------------------------------------------------------------------- |
3483 | ;----------------------------------------------------------------------------- |
3484 | align 4 |
3484 | align 4 |
3485 | drawbackground: |
3485 | drawbackground: |
3486 | cmp [BgrDrawMode], 1 |
3486 | cmp [BgrDrawMode], 1 |
3487 | jne .bgrstr |
3487 | jne .bgrstr |
3488 | call vesa20_drawbackground_tiled |
3488 | call vesa20_drawbackground_tiled |
3489 | call __sys_draw_pointer |
3489 | call __sys_draw_pointer |
3490 | ret |
3490 | ret |
3491 | ;-------------------------------------- |
3491 | ;-------------------------------------- |
3492 | align 4 |
3492 | align 4 |
3493 | .bgrstr: |
3493 | .bgrstr: |
3494 | call vesa20_drawbackground_stretch |
3494 | call vesa20_drawbackground_stretch |
3495 | call __sys_draw_pointer |
3495 | call __sys_draw_pointer |
3496 | ret |
3496 | ret |
3497 | ;----------------------------------------------------------------------------- |
3497 | ;----------------------------------------------------------------------------- |
3498 | align 4 |
3498 | align 4 |
3499 | syscall_putimage: ; PutImage |
3499 | syscall_putimage: ; PutImage |
3500 | ; add check pointer |
3500 | ; add check pointer |
3501 | push ecx |
3501 | push ecx |
3502 | mov ax, cx |
3502 | mov ax, cx |
3503 | shr ecx, 16 |
3503 | shr ecx, 16 |
3504 | imul eax, ecx |
3504 | imul eax, ecx |
3505 | lea eax, [eax*3] |
3505 | lea eax, [eax*3] |
3506 | stdcall is_region_userspace, ebx, eax |
3506 | stdcall is_region_userspace, ebx, eax |
3507 | pop ecx |
3507 | pop ecx |
3508 | jnz sys_putimage.exit |
3508 | jnz sys_putimage.exit |
3509 | 3509 | ||
3510 | sys_putimage: |
3510 | sys_putimage: |
3511 | test ecx, 0x80008000 |
3511 | test ecx, 0x80008000 |
3512 | jnz .exit |
3512 | jnz .exit |
3513 | test ecx, 0x0000FFFF |
3513 | test ecx, 0x0000FFFF |
3514 | jz .exit |
3514 | jz .exit |
3515 | test ecx, 0xFFFF0000 |
3515 | test ecx, 0xFFFF0000 |
3516 | jnz @f |
3516 | jnz @f |
3517 | ;-------------------------------------- |
3517 | ;-------------------------------------- |
3518 | align 4 |
3518 | align 4 |
3519 | .exit: |
3519 | .exit: |
3520 | ret |
3520 | ret |
3521 | ;-------------------------------------- |
3521 | ;-------------------------------------- |
3522 | align 4 |
3522 | align 4 |
3523 | @@: |
3523 | @@: |
3524 | mov edi, [current_slot] |
3524 | mov edi, [current_slot] |
3525 | mov edi, [edi + APPDATA.window] |
3525 | mov edi, [edi + APPDATA.window] |
3526 | add dx, word[edi + WDATA.clientbox.top] |
3526 | add dx, word[edi + WDATA.clientbox.top] |
3527 | rol edx, 16 |
3527 | rol edx, 16 |
3528 | add dx, word[edi + WDATA.clientbox.left] |
3528 | add dx, word[edi + WDATA.clientbox.left] |
3529 | rol edx, 16 |
3529 | rol edx, 16 |
3530 | ;-------------------------------------- |
3530 | ;-------------------------------------- |
3531 | align 4 |
3531 | align 4 |
3532 | .forced: |
3532 | .forced: |
3533 | push ebp esi 0 |
3533 | push ebp esi 0 |
3534 | mov ebp, putimage_get24bpp |
3534 | mov ebp, putimage_get24bpp |
3535 | mov esi, putimage_init24bpp |
3535 | mov esi, putimage_init24bpp |
3536 | ;-------------------------------------- |
3536 | ;-------------------------------------- |
3537 | align 4 |
3537 | align 4 |
3538 | sys_putimage_bpp: |
3538 | sys_putimage_bpp: |
3539 | call vesa20_putimage |
3539 | call vesa20_putimage |
3540 | pop ebp esi ebp |
3540 | pop ebp esi ebp |
3541 | ret |
3541 | ret |
3542 | ; jmp [draw_pointer] |
3542 | ; jmp [draw_pointer] |
3543 | ;----------------------------------------------------------------------------- |
3543 | ;----------------------------------------------------------------------------- |
3544 | align 4 |
3544 | align 4 |
3545 | sys_putimage_palette: |
3545 | sys_putimage_palette: |
3546 | ; ebx = pointer to image |
3546 | ; ebx = pointer to image |
3547 | ; ecx = [xsize]*65536 + [ysize] |
3547 | ; ecx = [xsize]*65536 + [ysize] |
3548 | ; edx = [xstart]*65536 + [ystart] |
3548 | ; edx = [xstart]*65536 + [ystart] |
3549 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
3549 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
3550 | ; edi = pointer to palette |
3550 | ; edi = pointer to palette |
3551 | ; ebp = row delta |
3551 | ; ebp = row delta |
3552 | ; check pointer |
3552 | ; check pointer |
3553 | push ecx esi |
3553 | push ecx esi |
3554 | mov ax, cx |
3554 | mov ax, cx |
3555 | shr ecx, 16 |
3555 | shr ecx, 16 |
3556 | imul eax, ecx |
3556 | imul eax, ecx |
3557 | ; imul eax, esi ; eax*count bit in 1 pixel |
3557 | ; imul eax, esi ; eax*count bit in 1 pixel |
3558 | ; shr eax, 3 |
3558 | ; shr eax, 3 |
3559 | stdcall is_region_userspace, ebx, eax |
3559 | stdcall is_region_userspace, ebx, eax |
3560 | pop esi ecx |
3560 | pop esi ecx |
3561 | jnz sys_putimage.exit |
3561 | jnz sys_putimage.exit |
3562 | 3562 | ||
3563 | mov eax, [current_slot] |
3563 | mov eax, [current_slot] |
3564 | mov eax, [eax + APPDATA.window] |
3564 | mov eax, [eax + APPDATA.window] |
3565 | add dx, word [eax + WDATA.clientbox.top] |
3565 | add dx, word [eax + WDATA.clientbox.top] |
3566 | rol edx, 16 |
3566 | rol edx, 16 |
3567 | add dx, word [eax + WDATA.clientbox.left] |
3567 | add dx, word [eax + WDATA.clientbox.left] |
3568 | rol edx, 16 |
3568 | rol edx, 16 |
3569 | ;-------------------------------------- |
3569 | ;-------------------------------------- |
3570 | align 4 |
3570 | align 4 |
3571 | .forced: |
3571 | .forced: |
3572 | cmp esi, 1 |
3572 | cmp esi, 1 |
3573 | jnz @f |
3573 | jnz @f |
3574 | push edi |
3574 | push edi |
3575 | mov eax, [edi+4] |
3575 | mov eax, [edi+4] |
3576 | sub eax, [edi] |
3576 | sub eax, [edi] |
3577 | push eax |
3577 | push eax |
3578 | push dword [edi] |
3578 | push dword [edi] |
3579 | push 0ffffff80h |
3579 | push 0ffffff80h |
3580 | mov edi, esp |
3580 | mov edi, esp |
3581 | call put_mono_image |
3581 | call put_mono_image |
3582 | add esp, 12 |
3582 | add esp, 12 |
3583 | pop edi |
3583 | pop edi |
3584 | ret |
3584 | ret |
3585 | ;-------------------------------------- |
3585 | ;-------------------------------------- |
3586 | align 4 |
3586 | align 4 |
3587 | @@: |
3587 | @@: |
3588 | cmp esi, 2 |
3588 | cmp esi, 2 |
3589 | jnz @f |
3589 | jnz @f |
3590 | push edi |
3590 | push edi |
3591 | push 0ffffff80h |
3591 | push 0ffffff80h |
3592 | mov edi, esp |
3592 | mov edi, esp |
3593 | call put_2bit_image |
3593 | call put_2bit_image |
3594 | pop eax |
3594 | pop eax |
3595 | pop edi |
3595 | pop edi |
3596 | ret |
3596 | ret |
3597 | ;-------------------------------------- |
3597 | ;-------------------------------------- |
3598 | align 4 |
3598 | align 4 |
3599 | @@: |
3599 | @@: |
3600 | cmp esi, 4 |
3600 | cmp esi, 4 |
3601 | jnz @f |
3601 | jnz @f |
3602 | push edi |
3602 | push edi |
3603 | push 0ffffff80h |
3603 | push 0ffffff80h |
3604 | mov edi, esp |
3604 | mov edi, esp |
3605 | call put_4bit_image |
3605 | call put_4bit_image |
3606 | pop eax |
3606 | pop eax |
3607 | pop edi |
3607 | pop edi |
3608 | ret |
3608 | ret |
3609 | ;-------------------------------------- |
3609 | ;-------------------------------------- |
3610 | align 4 |
3610 | align 4 |
3611 | @@: |
3611 | @@: |
3612 | push ebp esi ebp |
3612 | push ebp esi ebp |
3613 | cmp esi, 8 |
3613 | cmp esi, 8 |
3614 | jnz @f |
3614 | jnz @f |
3615 | mov ebp, putimage_get8bpp |
3615 | mov ebp, putimage_get8bpp |
3616 | mov esi, putimage_init8bpp |
3616 | mov esi, putimage_init8bpp |
3617 | jmp sys_putimage_bpp |
3617 | jmp sys_putimage_bpp |
3618 | ;-------------------------------------- |
3618 | ;-------------------------------------- |
3619 | align 4 |
3619 | align 4 |
3620 | @@: |
3620 | @@: |
3621 | cmp esi, 9 |
3621 | cmp esi, 9 |
3622 | jnz @f |
3622 | jnz @f |
3623 | mov ebp, putimage_get9bpp |
3623 | mov ebp, putimage_get9bpp |
3624 | mov esi, putimage_init9bpp |
3624 | mov esi, putimage_init9bpp |
3625 | jmp sys_putimage_bpp |
3625 | jmp sys_putimage_bpp |
3626 | ;-------------------------------------- |
3626 | ;-------------------------------------- |
3627 | align 4 |
3627 | align 4 |
3628 | @@: |
3628 | @@: |
3629 | cmp esi, 15 |
3629 | cmp esi, 15 |
3630 | jnz @f |
3630 | jnz @f |
3631 | mov ebp, putimage_get15bpp |
3631 | mov ebp, putimage_get15bpp |
3632 | mov esi, putimage_init15bpp |
3632 | mov esi, putimage_init15bpp |
3633 | jmp sys_putimage_bpp |
3633 | jmp sys_putimage_bpp |
3634 | ;-------------------------------------- |
3634 | ;-------------------------------------- |
3635 | align 4 |
3635 | align 4 |
3636 | @@: |
3636 | @@: |
3637 | cmp esi, 16 |
3637 | cmp esi, 16 |
3638 | jnz @f |
3638 | jnz @f |
3639 | mov ebp, putimage_get16bpp |
3639 | mov ebp, putimage_get16bpp |
3640 | mov esi, putimage_init16bpp |
3640 | mov esi, putimage_init16bpp |
3641 | jmp sys_putimage_bpp |
3641 | jmp sys_putimage_bpp |
3642 | ;-------------------------------------- |
3642 | ;-------------------------------------- |
3643 | align 4 |
3643 | align 4 |
3644 | @@: |
3644 | @@: |
3645 | cmp esi, 24 |
3645 | cmp esi, 24 |
3646 | jnz @f |
3646 | jnz @f |
3647 | mov ebp, putimage_get24bpp |
3647 | mov ebp, putimage_get24bpp |
3648 | mov esi, putimage_init24bpp |
3648 | mov esi, putimage_init24bpp |
3649 | jmp sys_putimage_bpp |
3649 | jmp sys_putimage_bpp |
3650 | ;-------------------------------------- |
3650 | ;-------------------------------------- |
3651 | align 4 |
3651 | align 4 |
3652 | @@: |
3652 | @@: |
3653 | cmp esi, 32 |
3653 | cmp esi, 32 |
3654 | jnz @f |
3654 | jnz @f |
3655 | mov ebp, putimage_get32bpp |
3655 | mov ebp, putimage_get32bpp |
3656 | mov esi, putimage_init32bpp |
3656 | mov esi, putimage_init32bpp |
3657 | jmp sys_putimage_bpp |
3657 | jmp sys_putimage_bpp |
3658 | ;-------------------------------------- |
3658 | ;-------------------------------------- |
3659 | align 4 |
3659 | align 4 |
3660 | @@: |
3660 | @@: |
3661 | pop ebp esi ebp |
3661 | pop ebp esi ebp |
3662 | ret |
3662 | ret |
3663 | ;----------------------------------------------------------------------------- |
3663 | ;----------------------------------------------------------------------------- |
3664 | align 4 |
3664 | align 4 |
3665 | put_mono_image: |
3665 | put_mono_image: |
3666 | push ebp esi ebp |
3666 | push ebp esi ebp |
3667 | mov ebp, putimage_get1bpp |
3667 | mov ebp, putimage_get1bpp |
3668 | mov esi, putimage_init1bpp |
3668 | mov esi, putimage_init1bpp |
3669 | jmp sys_putimage_bpp |
3669 | jmp sys_putimage_bpp |
3670 | ;----------------------------------------------------------------------------- |
3670 | ;----------------------------------------------------------------------------- |
3671 | align 4 |
3671 | align 4 |
3672 | put_2bit_image: |
3672 | put_2bit_image: |
3673 | push ebp esi ebp |
3673 | push ebp esi ebp |
3674 | mov ebp, putimage_get2bpp |
3674 | mov ebp, putimage_get2bpp |
3675 | mov esi, putimage_init2bpp |
3675 | mov esi, putimage_init2bpp |
3676 | jmp sys_putimage_bpp |
3676 | jmp sys_putimage_bpp |
3677 | ;----------------------------------------------------------------------------- |
3677 | ;----------------------------------------------------------------------------- |
3678 | align 4 |
3678 | align 4 |
3679 | put_4bit_image: |
3679 | put_4bit_image: |
3680 | push ebp esi ebp |
3680 | push ebp esi ebp |
3681 | mov ebp, putimage_get4bpp |
3681 | mov ebp, putimage_get4bpp |
3682 | mov esi, putimage_init4bpp |
3682 | mov esi, putimage_init4bpp |
3683 | jmp sys_putimage_bpp |
3683 | jmp sys_putimage_bpp |
3684 | ;----------------------------------------------------------------------------- |
3684 | ;----------------------------------------------------------------------------- |
3685 | align 4 |
3685 | align 4 |
3686 | putimage_init24bpp: |
3686 | putimage_init24bpp: |
3687 | lea eax, [eax*3] |
3687 | lea eax, [eax*3] |
3688 | putimage_init8bpp: |
3688 | putimage_init8bpp: |
3689 | putimage_init9bpp: |
3689 | putimage_init9bpp: |
3690 | ret |
3690 | ret |
3691 | ;----------------------------------------------------------------------------- |
3691 | ;----------------------------------------------------------------------------- |
3692 | align 16 |
3692 | align 16 |
3693 | putimage_get24bpp: |
3693 | putimage_get24bpp: |
3694 | movzx eax, byte [esi+2] |
3694 | movzx eax, byte [esi+2] |
3695 | shl eax, 16 |
3695 | shl eax, 16 |
3696 | mov ax, [esi] |
3696 | mov ax, [esi] |
3697 | add esi, 3 |
3697 | add esi, 3 |
3698 | ret 4 |
3698 | ret 4 |
3699 | ;----------------------------------------------------------------------------- |
3699 | ;----------------------------------------------------------------------------- |
3700 | align 16 |
3700 | align 16 |
3701 | putimage_get8bpp: |
3701 | putimage_get8bpp: |
3702 | movzx eax, byte [esi] |
3702 | movzx eax, byte [esi] |
3703 | push edx |
3703 | push edx |
3704 | mov edx, [esp+8] |
3704 | mov edx, [esp+8] |
3705 | mov eax, [edx + eax*4] |
3705 | mov eax, [edx + eax*4] |
3706 | pop edx |
3706 | pop edx |
3707 | inc esi |
3707 | inc esi |
3708 | ret 4 |
3708 | ret 4 |
3709 | ;----------------------------------------------------------------------------- |
3709 | ;----------------------------------------------------------------------------- |
3710 | align 16 |
3710 | align 16 |
3711 | putimage_get9bpp: |
3711 | putimage_get9bpp: |
3712 | lodsb |
3712 | lodsb |
3713 | mov ah, al |
3713 | mov ah, al |
3714 | shl eax, 8 |
3714 | shl eax, 8 |
3715 | mov al, ah |
3715 | mov al, ah |
3716 | ret 4 |
3716 | ret 4 |
3717 | ;----------------------------------------------------------------------------- |
3717 | ;----------------------------------------------------------------------------- |
3718 | align 4 |
3718 | align 4 |
3719 | putimage_init1bpp: |
3719 | putimage_init1bpp: |
3720 | add eax, ecx |
3720 | add eax, ecx |
3721 | push ecx |
3721 | push ecx |
3722 | add eax, 7 |
3722 | add eax, 7 |
3723 | add ecx, 7 |
3723 | add ecx, 7 |
3724 | shr eax, 3 |
3724 | shr eax, 3 |
3725 | shr ecx, 3 |
3725 | shr ecx, 3 |
3726 | sub eax, ecx |
3726 | sub eax, ecx |
3727 | pop ecx |
3727 | pop ecx |
3728 | ret |
3728 | ret |
3729 | ;----------------------------------------------------------------------------- |
3729 | ;----------------------------------------------------------------------------- |
3730 | align 16 |
3730 | align 16 |
3731 | putimage_get1bpp: |
3731 | putimage_get1bpp: |
3732 | push edx |
3732 | push edx |
3733 | mov edx, [esp+8] |
3733 | mov edx, [esp+8] |
3734 | mov al, [edx] |
3734 | mov al, [edx] |
3735 | add al, al |
3735 | add al, al |
3736 | jnz @f |
3736 | jnz @f |
3737 | lodsb |
3737 | lodsb |
3738 | adc al, al |
3738 | adc al, al |
3739 | @@: |
3739 | @@: |
3740 | mov [edx], al |
3740 | mov [edx], al |
3741 | sbb eax, eax |
3741 | sbb eax, eax |
3742 | and eax, [edx+8] |
3742 | and eax, [edx+8] |
3743 | add eax, [edx+4] |
3743 | add eax, [edx+4] |
3744 | pop edx |
3744 | pop edx |
3745 | ret 4 |
3745 | ret 4 |
3746 | ;----------------------------------------------------------------------------- |
3746 | ;----------------------------------------------------------------------------- |
3747 | align 4 |
3747 | align 4 |
3748 | putimage_init2bpp: |
3748 | putimage_init2bpp: |
3749 | add eax, ecx |
3749 | add eax, ecx |
3750 | push ecx |
3750 | push ecx |
3751 | add ecx, 3 |
3751 | add ecx, 3 |
3752 | add eax, 3 |
3752 | add eax, 3 |
3753 | shr ecx, 2 |
3753 | shr ecx, 2 |
3754 | shr eax, 2 |
3754 | shr eax, 2 |
3755 | sub eax, ecx |
3755 | sub eax, ecx |
3756 | pop ecx |
3756 | pop ecx |
3757 | ret |
3757 | ret |
3758 | ;----------------------------------------------------------------------------- |
3758 | ;----------------------------------------------------------------------------- |
3759 | align 16 |
3759 | align 16 |
3760 | putimage_get2bpp: |
3760 | putimage_get2bpp: |
3761 | push edx |
3761 | push edx |
3762 | mov edx, [esp+8] |
3762 | mov edx, [esp+8] |
3763 | mov al, [edx] |
3763 | mov al, [edx] |
3764 | mov ah, al |
3764 | mov ah, al |
3765 | shr al, 6 |
3765 | shr al, 6 |
3766 | shl ah, 2 |
3766 | shl ah, 2 |
3767 | jnz .nonewbyte |
3767 | jnz .nonewbyte |
3768 | lodsb |
3768 | lodsb |
3769 | mov ah, al |
3769 | mov ah, al |
3770 | shr al, 6 |
3770 | shr al, 6 |
3771 | shl ah, 2 |
3771 | shl ah, 2 |
3772 | add ah, 1 |
3772 | add ah, 1 |
3773 | .nonewbyte: |
3773 | .nonewbyte: |
3774 | mov [edx], ah |
3774 | mov [edx], ah |
3775 | mov edx, [edx+4] |
3775 | mov edx, [edx+4] |
3776 | movzx eax, al |
3776 | movzx eax, al |
3777 | mov eax, [edx + eax*4] |
3777 | mov eax, [edx + eax*4] |
3778 | pop edx |
3778 | pop edx |
3779 | ret 4 |
3779 | ret 4 |
3780 | ;----------------------------------------------------------------------------- |
3780 | ;----------------------------------------------------------------------------- |
3781 | align 4 |
3781 | align 4 |
3782 | putimage_init4bpp: |
3782 | putimage_init4bpp: |
3783 | add eax, ecx |
3783 | add eax, ecx |
3784 | push ecx |
3784 | push ecx |
3785 | add ecx, 1 |
3785 | add ecx, 1 |
3786 | inc eax ;add eax, 1 |
3786 | inc eax ;add eax, 1 |
3787 | shr ecx, 1 |
3787 | shr ecx, 1 |
3788 | shr eax, 1 |
3788 | shr eax, 1 |
3789 | sub eax, ecx |
3789 | sub eax, ecx |
3790 | pop ecx |
3790 | pop ecx |
3791 | ret |
3791 | ret |
3792 | ;----------------------------------------------------------------------------- |
3792 | ;----------------------------------------------------------------------------- |
3793 | align 16 |
3793 | align 16 |
3794 | putimage_get4bpp: |
3794 | putimage_get4bpp: |
3795 | push edx |
3795 | push edx |
3796 | mov edx, [esp+8] |
3796 | mov edx, [esp+8] |
3797 | add byte [edx], 80h |
3797 | add byte [edx], 80h |
3798 | jc @f |
3798 | jc @f |
3799 | movzx eax, byte [edx+1] |
3799 | movzx eax, byte [edx+1] |
3800 | mov edx, [edx+4] |
3800 | mov edx, [edx+4] |
3801 | and eax, 0x0F |
3801 | and eax, 0x0F |
3802 | mov eax, [edx + eax*4] |
3802 | mov eax, [edx + eax*4] |
3803 | pop edx |
3803 | pop edx |
3804 | ret 4 |
3804 | ret 4 |
3805 | @@: |
3805 | @@: |
3806 | movzx eax, byte [esi] |
3806 | movzx eax, byte [esi] |
3807 | add esi, 1 |
3807 | add esi, 1 |
3808 | mov [edx+1], al |
3808 | mov [edx+1], al |
3809 | shr eax, 4 |
3809 | shr eax, 4 |
3810 | mov edx, [edx+4] |
3810 | mov edx, [edx+4] |
3811 | mov eax, [edx + eax*4] |
3811 | mov eax, [edx + eax*4] |
3812 | pop edx |
3812 | pop edx |
3813 | ret 4 |
3813 | ret 4 |
3814 | ;----------------------------------------------------------------------------- |
3814 | ;----------------------------------------------------------------------------- |
3815 | align 4 |
3815 | align 4 |
3816 | putimage_init32bpp: |
3816 | putimage_init32bpp: |
3817 | shl eax, 2 |
3817 | shl eax, 2 |
3818 | ret |
3818 | ret |
3819 | ;----------------------------------------------------------------------------- |
3819 | ;----------------------------------------------------------------------------- |
3820 | align 16 |
3820 | align 16 |
3821 | putimage_get32bpp: |
3821 | putimage_get32bpp: |
3822 | lodsd |
3822 | lodsd |
3823 | ret 4 |
3823 | ret 4 |
3824 | ;----------------------------------------------------------------------------- |
3824 | ;----------------------------------------------------------------------------- |
3825 | align 4 |
3825 | align 4 |
3826 | putimage_init15bpp: |
3826 | putimage_init15bpp: |
3827 | putimage_init16bpp: |
3827 | putimage_init16bpp: |
3828 | add eax, eax |
3828 | add eax, eax |
3829 | ret |
3829 | ret |
3830 | ;----------------------------------------------------------------------------- |
3830 | ;----------------------------------------------------------------------------- |
3831 | align 16 |
3831 | align 16 |
3832 | putimage_get15bpp: |
3832 | putimage_get15bpp: |
3833 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
3833 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
3834 | push ecx edx |
3834 | push ecx edx |
3835 | movzx eax, word [esi] |
3835 | movzx eax, word [esi] |
3836 | add esi, 2 |
3836 | add esi, 2 |
3837 | mov ecx, eax |
3837 | mov ecx, eax |
3838 | mov edx, eax |
3838 | mov edx, eax |
3839 | and eax, 0x1F |
3839 | and eax, 0x1F |
3840 | and ecx, 0x1F shl 5 |
3840 | and ecx, 0x1F shl 5 |
3841 | and edx, 0x1F shl 10 |
3841 | and edx, 0x1F shl 10 |
3842 | shl eax, 3 |
3842 | shl eax, 3 |
3843 | shl ecx, 6 |
3843 | shl ecx, 6 |
3844 | shl edx, 9 |
3844 | shl edx, 9 |
3845 | or eax, ecx |
3845 | or eax, ecx |
3846 | or eax, edx |
3846 | or eax, edx |
3847 | pop edx ecx |
3847 | pop edx ecx |
3848 | ret 4 |
3848 | ret 4 |
3849 | ;----------------------------------------------------------------------------- |
3849 | ;----------------------------------------------------------------------------- |
3850 | align 16 |
3850 | align 16 |
3851 | putimage_get16bpp: |
3851 | putimage_get16bpp: |
3852 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
3852 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
3853 | push ecx edx |
3853 | push ecx edx |
3854 | movzx eax, word [esi] |
3854 | movzx eax, word [esi] |
3855 | add esi, 2 |
3855 | add esi, 2 |
3856 | mov ecx, eax |
3856 | mov ecx, eax |
3857 | mov edx, eax |
3857 | mov edx, eax |
3858 | and eax, 0x1F |
3858 | and eax, 0x1F |
3859 | and ecx, 0x3F shl 5 |
3859 | and ecx, 0x3F shl 5 |
3860 | and edx, 0x1F shl 11 |
3860 | and edx, 0x1F shl 11 |
3861 | shl eax, 3 |
3861 | shl eax, 3 |
3862 | shl ecx, 5 |
3862 | shl ecx, 5 |
3863 | shl edx, 8 |
3863 | shl edx, 8 |
3864 | or eax, ecx |
3864 | or eax, ecx |
3865 | or eax, edx |
3865 | or eax, edx |
3866 | pop edx ecx |
3866 | pop edx ecx |
3867 | ret 4 |
3867 | ret 4 |
3868 | ;----------------------------------------------------------------------------- |
3868 | ;----------------------------------------------------------------------------- |
3869 | ;align 4 |
3869 | ;align 4 |
3870 | ; eax x beginning |
3870 | ; eax x beginning |
3871 | ; ebx y beginning |
3871 | ; ebx y beginning |
3872 | ; ecx x end |
3872 | ; ecx x end |
3873 | ; edx y end |
3873 | ; edx y end |
3874 | ; edi color |
3874 | ; edi color |
3875 | ;__sys_drawbar: |
3875 | ;__sys_drawbar: |
3876 | ; mov esi, [current_slot] |
3876 | ; mov esi, [current_slot] |
3877 | ; mov esi, [esi + APPDATA.window] |
3877 | ; mov esi, [esi + APPDATA.window] |
3878 | ; add eax, [esi + WDATA.clientbox.left] |
3878 | ; add eax, [esi + WDATA.clientbox.left] |
3879 | ; add ecx, [esi + WDATA.clientbox.left] |
3879 | ; add ecx, [esi + WDATA.clientbox.left] |
3880 | ; add ebx, [esi + WDATA.clientbox.top] |
3880 | ; add ebx, [esi + WDATA.clientbox.top] |
3881 | ; add edx, [esi + WDATA.clientbox.top] |
3881 | ; add edx, [esi + WDATA.clientbox.top] |
3882 | ;-------------------------------------- |
3882 | ;-------------------------------------- |
3883 | ;align 4 |
3883 | ;align 4 |
3884 | ;.forced: |
3884 | ;.forced: |
3885 | ; call vesa20_drawbar |
3885 | ; call vesa20_drawbar |
3886 | ; call [draw_pointer] |
3886 | ; call [draw_pointer] |
3887 | ; ret |
3887 | ; ret |
3888 | ;----------------------------------------------------------------------------- |
3888 | ;----------------------------------------------------------------------------- |
3889 | if used _rdtsc |
3889 | if used _rdtsc |
3890 | _rdtsc: |
3890 | _rdtsc: |
3891 | bt [cpu_caps], CAPS_TSC |
3891 | bt [cpu_caps], CAPS_TSC |
3892 | jnc .ret_rdtsc |
3892 | jnc .ret_rdtsc |
3893 | rdtsc |
3893 | rdtsc |
3894 | ret |
3894 | ret |
3895 | .ret_rdtsc: |
3895 | .ret_rdtsc: |
3896 | mov edx, 0xffffffff |
3896 | mov edx, 0xffffffff |
3897 | mov eax, 0xffffffff |
3897 | mov eax, 0xffffffff |
3898 | ret |
3898 | ret |
3899 | end if |
3899 | end if |
3900 | 3900 | ||
3901 | sys_msg_board_str: |
3901 | sys_msg_board_str: |
3902 | 3902 | ||
3903 | pushad |
3903 | pushad |
3904 | @@: |
3904 | @@: |
3905 | cmp [esi], byte 0 |
3905 | cmp [esi], byte 0 |
3906 | je @f |
3906 | je @f |
3907 | mov ebx, 1 |
3907 | mov ebx, 1 |
3908 | movzx ecx, byte [esi] |
3908 | movzx ecx, byte [esi] |
3909 | call sys_msg_board |
3909 | call sys_msg_board |
3910 | inc esi |
3910 | inc esi |
3911 | jmp @b |
3911 | jmp @b |
3912 | @@: |
3912 | @@: |
3913 | popad |
3913 | popad |
3914 | ret |
3914 | ret |
3915 | 3915 | ||
3916 | sys_msg_board_byte: |
3916 | sys_msg_board_byte: |
3917 | ; in: al = byte to display |
3917 | ; in: al = byte to display |
3918 | ; out: nothing |
3918 | ; out: nothing |
3919 | ; destroys: nothing |
3919 | ; destroys: nothing |
3920 | pushad |
3920 | pushad |
3921 | mov ecx, 2 |
3921 | mov ecx, 2 |
3922 | shl eax, 24 |
3922 | shl eax, 24 |
3923 | jmp @f |
3923 | jmp @f |
3924 | 3924 | ||
3925 | sys_msg_board_word: |
3925 | sys_msg_board_word: |
3926 | ; in: ax = word to display |
3926 | ; in: ax = word to display |
3927 | ; out: nothing |
3927 | ; out: nothing |
3928 | ; destroys: nothing |
3928 | ; destroys: nothing |
3929 | pushad |
3929 | pushad |
3930 | mov ecx, 4 |
3930 | mov ecx, 4 |
3931 | shl eax, 16 |
3931 | shl eax, 16 |
3932 | jmp @f |
3932 | jmp @f |
3933 | 3933 | ||
3934 | sys_msg_board_dword: |
3934 | sys_msg_board_dword: |
3935 | ; in: eax = dword to display |
3935 | ; in: eax = dword to display |
3936 | ; out: nothing |
3936 | ; out: nothing |
3937 | ; destroys: nothing |
3937 | ; destroys: nothing |
3938 | pushad |
3938 | pushad |
3939 | mov ecx, 8 |
3939 | mov ecx, 8 |
3940 | @@: |
3940 | @@: |
3941 | push ecx |
3941 | push ecx |
3942 | rol eax, 4 |
3942 | rol eax, 4 |
3943 | push eax |
3943 | push eax |
3944 | and al, 0xF |
3944 | and al, 0xF |
3945 | cmp al, 10 |
3945 | cmp al, 10 |
3946 | sbb al, 69h |
3946 | sbb al, 69h |
3947 | das |
3947 | das |
3948 | mov cl, al |
3948 | mov cl, al |
3949 | xor ebx, ebx |
3949 | xor ebx, ebx |
3950 | inc ebx |
3950 | inc ebx |
3951 | call sys_msg_board |
3951 | call sys_msg_board |
3952 | pop eax |
3952 | pop eax |
3953 | pop ecx |
3953 | pop ecx |
3954 | loop @b |
3954 | loop @b |
3955 | popad |
3955 | popad |
3956 | ret |
3956 | ret |
3957 | 3957 | ||
3958 | msg_board_data_size = 65536 ; Must be power of two |
3958 | msg_board_data_size = 65536 ; Must be power of two |
3959 | 3959 | ||
3960 | uglobal |
3960 | uglobal |
3961 | msg_board_data rb msg_board_data_size |
3961 | msg_board_data rb msg_board_data_size |
3962 | msg_board_count dd ? |
3962 | msg_board_count dd ? |
3963 | endg |
3963 | endg |
3964 | 3964 | ||
3965 | iglobal |
3965 | iglobal |
3966 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
3966 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
3967 | endg |
3967 | endg |
3968 | 3968 | ||
3969 | sys_msg_board: |
3969 | sys_msg_board: |
3970 | ; ebx=1 -> write, cl = byte to write |
3970 | ; ebx=1 -> write, cl = byte to write |
3971 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
3971 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
3972 | push eax ebx |
3972 | push eax ebx |
3973 | mov eax, ebx |
3973 | mov eax, ebx |
3974 | mov ebx, ecx |
3974 | mov ebx, ecx |
3975 | mov ecx, [msg_board_count] |
3975 | mov ecx, [msg_board_count] |
3976 | cmp eax, 1 |
3976 | cmp eax, 1 |
3977 | jne .read |
3977 | jne .read |
3978 | 3978 | ||
3979 | if defined debug_com_base |
3979 | if defined debug_com_base |
3980 | push dx ax |
3980 | push dx ax |
3981 | @@: ; wait for empty transmit register |
3981 | @@: ; wait for empty transmit register |
3982 | mov dx, debug_com_base+5 |
3982 | mov dx, debug_com_base+5 |
3983 | in al, dx |
3983 | in al, dx |
3984 | test al, 1 shl 5 |
3984 | test al, 1 shl 5 |
3985 | jz @r |
3985 | jz @r |
3986 | mov dx, debug_com_base ; Output the byte |
3986 | mov dx, debug_com_base ; Output the byte |
3987 | mov al, bl |
3987 | mov al, bl |
3988 | out dx, al |
3988 | out dx, al |
3989 | pop ax dx |
3989 | pop ax dx |
3990 | end if |
3990 | end if |
3991 | 3991 | ||
3992 | mov [msg_board_data+ecx], bl |
3992 | mov [msg_board_data+ecx], bl |
3993 | cmp byte [debug_direct_print], 1 |
3993 | cmp byte [debug_direct_print], 1 |
3994 | jnz .end |
3994 | jnz .end |
3995 | pusha |
3995 | pusha |
3996 | lea edx, [msg_board_data+ecx] |
3996 | lea edx, [msg_board_data+ecx] |
3997 | mov ecx, 0x40FFFFFF |
3997 | mov ecx, 0x40FFFFFF |
3998 | mov ebx, [msg_board_pos] |
3998 | mov ebx, [msg_board_pos] |
3999 | mov edi, 1 |
3999 | mov edi, 1 |
4000 | mov esi, edi ;1 |
4000 | mov esi, edi ;1 |
4001 | call dtext |
4001 | call dtext |
4002 | popa |
4002 | popa |
4003 | add word [msg_board_pos+2], 6 |
4003 | add word [msg_board_pos+2], 6 |
4004 | cmp word [msg_board_pos+2], 105*6 |
4004 | cmp word [msg_board_pos+2], 105*6 |
4005 | jnc @f |
4005 | jnc @f |
4006 | cmp bl, 10 |
4006 | cmp bl, 10 |
4007 | jnz .end |
4007 | jnz .end |
4008 | @@: |
4008 | @@: |
4009 | mov word [msg_board_pos+2], 42*6 |
4009 | mov word [msg_board_pos+2], 42*6 |
4010 | add word [msg_board_pos], 10 |
4010 | add word [msg_board_pos], 10 |
4011 | mov eax, [_display.height] |
4011 | mov eax, [_display.height] |
4012 | sub eax, 10 |
4012 | sub eax, 10 |
4013 | cmp ax, word [msg_board_pos] |
4013 | cmp ax, word [msg_board_pos] |
4014 | jnc @f |
4014 | jnc @f |
4015 | mov word [msg_board_pos], 10 |
4015 | mov word [msg_board_pos], 10 |
4016 | @@: |
4016 | @@: |
4017 | pusha |
4017 | pusha |
4018 | mov eax, [msg_board_pos] |
4018 | mov eax, [msg_board_pos] |
4019 | movzx ebx, ax |
4019 | movzx ebx, ax |
4020 | shr eax, 16 |
4020 | shr eax, 16 |
4021 | mov edx, 105*6 |
4021 | mov edx, 105*6 |
4022 | xor ecx, ecx |
4022 | xor ecx, ecx |
4023 | mov edi, 1 |
4023 | mov edi, 1 |
4024 | mov esi, 9 |
4024 | mov esi, 9 |
4025 | @@: |
4025 | @@: |
4026 | call hline |
4026 | call hline |
4027 | inc ebx |
4027 | inc ebx |
4028 | dec esi |
4028 | dec esi |
4029 | jnz @b |
4029 | jnz @b |
4030 | popa |
4030 | popa |
4031 | .end: |
4031 | .end: |
4032 | inc ecx |
4032 | inc ecx |
4033 | and ecx, msg_board_data_size - 1 |
4033 | and ecx, msg_board_data_size - 1 |
4034 | mov [msg_board_count], ecx |
4034 | mov [msg_board_count], ecx |
4035 | .ret: |
4035 | .ret: |
4036 | pop ebx eax |
4036 | pop ebx eax |
4037 | ret |
4037 | ret |
4038 | 4038 | ||
4039 | .read: |
4039 | .read: |
4040 | cmp eax, 2 |
4040 | cmp eax, 2 |
4041 | jne .ret |
4041 | jne .ret |
4042 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4042 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4043 | test ecx, ecx |
4043 | test ecx, ecx |
4044 | jnz @f |
4044 | jnz @f |
4045 | mov [esp + SYSCALL_STACK.eax], ecx |
4045 | mov [esp + SYSCALL_STACK.eax], ecx |
4046 | mov [esp + SYSCALL_STACK.ebx], ecx |
4046 | mov [esp + SYSCALL_STACK.ebx], ecx |
4047 | ret |
4047 | ret |
4048 | @@: |
4048 | @@: |
4049 | mov eax, msg_board_data+1 |
4049 | mov eax, msg_board_data+1 |
4050 | mov ebx, msg_board_data |
4050 | mov ebx, msg_board_data |
4051 | movzx edx, byte [ebx] |
4051 | movzx edx, byte [ebx] |
4052 | call memmove |
4052 | call memmove |
4053 | dec [msg_board_count] |
4053 | dec [msg_board_count] |
4054 | mov [esp + SYSCALL_STACK.eax], edx |
4054 | mov [esp + SYSCALL_STACK.eax], edx |
4055 | mov [esp + SYSCALL_STACK.ebx], 1 |
4055 | mov [esp + SYSCALL_STACK.ebx], 1 |
4056 | ret |
4056 | ret |
4057 | 4057 | ||
4058 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4058 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4059 | ;; 61 sys function. ;; |
4059 | ;; 61 sys function. ;; |
4060 | ;; in eax=61,ebx in [1..3] ;; |
4060 | ;; in eax=61,ebx in [1..3] ;; |
4061 | ;; out eax ;; |
4061 | ;; out eax ;; |
4062 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4062 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4063 | iglobal |
4063 | iglobal |
4064 | align 4 |
4064 | align 4 |
4065 | f61call: |
4065 | f61call: |
4066 | dd sys_gs.1 ; resolution |
4066 | dd sys_gs.1 ; resolution |
4067 | dd sys_gs.2 ; bits per pixel |
4067 | dd sys_gs.2 ; bits per pixel |
4068 | dd sys_gs.3 ; bytes per scanline |
4068 | dd sys_gs.3 ; bytes per scanline |
4069 | endg |
4069 | endg |
4070 | 4070 | ||
4071 | 4071 | ||
4072 | align 4 |
4072 | align 4 |
4073 | 4073 | ||
4074 | sys_gs: ; direct screen access |
4074 | sys_gs: ; direct screen access |
4075 | dec ebx |
4075 | dec ebx |
4076 | cmp ebx, 2 |
4076 | cmp ebx, 2 |
4077 | ja .not_support |
4077 | ja .not_support |
4078 | jmp dword [f61call + ebx*4] |
4078 | jmp dword [f61call + ebx*4] |
4079 | .not_support: |
4079 | .not_support: |
4080 | or [esp + SYSCALL_STACK.eax], -1 |
4080 | or [esp + SYSCALL_STACK.eax], -1 |
4081 | ret |
4081 | ret |
4082 | 4082 | ||
4083 | 4083 | ||
4084 | .1: ; resolution |
4084 | .1: ; resolution |
4085 | mov eax, [_display.width] |
4085 | mov eax, [_display.width] |
4086 | shl eax, 16 |
4086 | shl eax, 16 |
4087 | mov ax, word [_display.height] |
4087 | mov ax, word [_display.height] |
4088 | mov [esp + SYSCALL_STACK.eax], eax |
4088 | mov [esp + SYSCALL_STACK.eax], eax |
4089 | ret |
4089 | ret |
4090 | .2: ; bits per pixel |
4090 | .2: ; bits per pixel |
4091 | mov eax, [_display.bits_per_pixel] |
4091 | mov eax, [_display.bits_per_pixel] |
4092 | mov [esp + SYSCALL_STACK.eax], eax |
4092 | mov [esp + SYSCALL_STACK.eax], eax |
4093 | ret |
4093 | ret |
4094 | .3: ; bytes per scanline |
4094 | .3: ; bytes per scanline |
4095 | mov eax, [_display.lfb_pitch] |
4095 | mov eax, [_display.lfb_pitch] |
4096 | mov [esp + SYSCALL_STACK.eax], eax |
4096 | mov [esp + SYSCALL_STACK.eax], eax |
4097 | ret |
4097 | ret |
4098 | 4098 | ||
4099 | align 4 |
4099 | align 4 |
4100 | syscall_getscreensize: ; GetScreenSize |
4100 | syscall_getscreensize: ; GetScreenSize |
4101 | mov ax, word [_display.width] |
4101 | mov ax, word [_display.width] |
4102 | dec ax |
4102 | dec ax |
4103 | shl eax, 16 |
4103 | shl eax, 16 |
4104 | mov ax, word [_display.height] |
4104 | mov ax, word [_display.height] |
4105 | dec ax |
4105 | dec ax |
4106 | mov [esp + SYSCALL_STACK.eax], eax |
4106 | mov [esp + SYSCALL_STACK.eax], eax |
4107 | ret |
4107 | ret |
4108 | ;----------------------------------------------------------------------------- |
4108 | ;----------------------------------------------------------------------------- |
4109 | align 4 |
4109 | align 4 |
4110 | syscall_cdaudio: |
4110 | syscall_cdaudio: |
4111 | ; ECX - position of CD/DVD-drive |
4111 | ; ECX - position of CD/DVD-drive |
4112 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
4112 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
4113 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
4113 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
4114 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
4114 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
4115 | cmp ecx, 11 |
4115 | cmp ecx, 11 |
4116 | ja .exit |
4116 | ja .exit |
4117 | 4117 | ||
4118 | mov eax, ecx |
4118 | mov eax, ecx |
4119 | shr eax, 2 |
4119 | shr eax, 2 |
4120 | lea eax, [eax*5] |
4120 | lea eax, [eax*5] |
4121 | mov al, [eax + DRIVE_DATA + 1] |
4121 | mov al, [eax + DRIVE_DATA + 1] |
4122 | 4122 | ||
4123 | push ecx ebx |
4123 | push ecx ebx |
4124 | mov ebx, ecx |
4124 | mov ebx, ecx |
4125 | and ebx, 11b |
4125 | and ebx, 11b |
4126 | shl ebx, 1 |
4126 | shl ebx, 1 |
4127 | mov cl, 6 |
4127 | mov cl, 6 |
4128 | sub cl, bl |
4128 | sub cl, bl |
4129 | shr al, cl |
4129 | shr al, cl |
4130 | test al, 2 ; it's not an ATAPI device |
4130 | test al, 2 ; it's not an ATAPI device |
4131 | pop ebx ecx |
4131 | pop ebx ecx |
4132 | 4132 | ||
4133 | jz .exit |
4133 | jz .exit |
4134 | 4134 | ||
4135 | cmp ebx, 4 |
4135 | cmp ebx, 4 |
4136 | je .eject |
4136 | je .eject |
4137 | 4137 | ||
4138 | cmp ebx, 5 |
4138 | cmp ebx, 5 |
4139 | je .load |
4139 | je .load |
4140 | ;-------------------------------------- |
4140 | ;-------------------------------------- |
4141 | .exit: |
4141 | .exit: |
4142 | ret |
4142 | ret |
4143 | ;-------------------------------------- |
4143 | ;-------------------------------------- |
4144 | .load: |
4144 | .load: |
4145 | call .reserve |
4145 | call .reserve |
4146 | call LoadMedium |
4146 | call LoadMedium |
4147 | jmp .free |
4147 | jmp .free |
4148 | ;-------------------------------------- |
4148 | ;-------------------------------------- |
4149 | .eject: |
4149 | .eject: |
4150 | call .reserve |
4150 | call .reserve |
4151 | call clear_CD_cache |
4151 | call clear_CD_cache |
4152 | call allow_medium_removal |
4152 | call allow_medium_removal |
4153 | call EjectMedium |
4153 | call EjectMedium |
4154 | jmp .free |
4154 | jmp .free |
4155 | ;-------------------------------------- |
4155 | ;-------------------------------------- |
4156 | .reserve: |
4156 | .reserve: |
4157 | call reserve_cd |
4157 | call reserve_cd |
4158 | 4158 | ||
4159 | mov ebx, ecx |
4159 | mov ebx, ecx |
4160 | inc ebx |
4160 | inc ebx |
4161 | mov [cdpos], ebx |
4161 | mov [cdpos], ebx |
4162 | 4162 | ||
4163 | mov eax, ecx |
4163 | mov eax, ecx |
4164 | shr eax, 1 |
4164 | shr eax, 1 |
4165 | and eax, 1 |
4165 | and eax, 1 |
4166 | inc eax |
4166 | inc eax |
4167 | mov [ChannelNumber], al |
4167 | mov [ChannelNumber], al |
4168 | mov eax, ecx |
4168 | mov eax, ecx |
4169 | and eax, 1 |
4169 | and eax, 1 |
4170 | mov [DiskNumber], al |
4170 | mov [DiskNumber], al |
4171 | call reserve_cd_channel |
4171 | call reserve_cd_channel |
4172 | ret |
4172 | ret |
4173 | ;-------------------------------------- |
4173 | ;-------------------------------------- |
4174 | .free: |
4174 | .free: |
4175 | call free_cd_channel |
4175 | call free_cd_channel |
4176 | and [cd_status], 0 |
4176 | and [cd_status], 0 |
4177 | ret |
4177 | ret |
4178 | ;----------------------------------------------------------------------------- |
4178 | ;----------------------------------------------------------------------------- |
4179 | align 4 |
4179 | align 4 |
4180 | syscall_getpixel_WinMap: ; GetPixel WinMap |
4180 | syscall_getpixel_WinMap: ; GetPixel WinMap |
4181 | xor eax, eax |
4181 | xor eax, eax |
4182 | 4182 | ||
4183 | cmp ebx, [_display.width] |
4183 | cmp ebx, [_display.width] |
4184 | jae .store |
4184 | jae .store |
4185 | cmp ecx, [_display.height] |
4185 | cmp ecx, [_display.height] |
4186 | jae .store |
4186 | jae .store |
4187 | ;-------------------------------------- |
4187 | ;-------------------------------------- |
4188 | mov eax, [d_width_calc_area + ecx*4] |
4188 | mov eax, [d_width_calc_area + ecx*4] |
4189 | add eax, [_display.win_map] |
4189 | add eax, [_display.win_map] |
4190 | movzx eax, byte[eax+ebx] ; get value for current point |
4190 | movzx eax, byte[eax+ebx] ; get value for current point |
4191 | ;-------------------------------------- |
4191 | ;-------------------------------------- |
4192 | align 4 |
4192 | align 4 |
4193 | .store: |
4193 | .store: |
4194 | mov [esp + SYSCALL_STACK.eax], eax |
4194 | mov [esp + SYSCALL_STACK.eax], eax |
4195 | ret |
4195 | ret |
4196 | ;----------------------------------------------------------------------------- |
4196 | ;----------------------------------------------------------------------------- |
4197 | align 4 |
4197 | align 4 |
4198 | syscall_getpixel: ; GetPixel |
4198 | syscall_getpixel: ; GetPixel |
4199 | mov ecx, [_display.width] |
4199 | mov ecx, [_display.width] |
4200 | xor edx, edx |
4200 | xor edx, edx |
4201 | mov eax, ebx |
4201 | mov eax, ebx |
4202 | div ecx |
4202 | div ecx |
4203 | mov ebx, edx |
4203 | mov ebx, edx |
4204 | xchg eax, ebx |
4204 | xchg eax, ebx |
4205 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4205 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4206 | call dword [GETPIXEL]; eax - x, ebx - y |
4206 | call dword [GETPIXEL]; eax - x, ebx - y |
4207 | mov [esp + SYSCALL_STACK.eax], ecx |
4207 | mov [esp + SYSCALL_STACK.eax], ecx |
4208 | ret |
4208 | ret |
4209 | ;----------------------------------------------------------------------------- |
4209 | ;----------------------------------------------------------------------------- |
4210 | align 4 |
4210 | align 4 |
4211 | syscall_getarea: |
4211 | syscall_getarea: |
4212 | ;eax = 36 |
4212 | ;eax = 36 |
4213 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
4213 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
4214 | ;ecx = [size x]*65536 + [size y] |
4214 | ;ecx = [size x]*65536 + [size y] |
4215 | ;edx = [start x]*65536 + [start y] |
4215 | ;edx = [start x]*65536 + [start y] |
4216 | pushad |
4216 | pushad |
4217 | mov edi, ebx |
4217 | mov edi, ebx |
4218 | mov eax, edx |
4218 | mov eax, edx |
4219 | shr eax, 16 |
4219 | shr eax, 16 |
4220 | mov ebx, edx |
4220 | mov ebx, edx |
4221 | and ebx, 0xffff |
4221 | and ebx, 0xffff |
4222 | dec eax |
4222 | dec eax |
4223 | dec ebx |
4223 | dec ebx |
4224 | ; eax - x, ebx - y |
4224 | ; eax - x, ebx - y |
4225 | mov edx, ecx |
4225 | mov edx, ecx |
4226 | 4226 | ||
4227 | shr ecx, 16 |
4227 | shr ecx, 16 |
4228 | and edx, 0xffff |
4228 | and edx, 0xffff |
4229 | mov esi, ecx |
4229 | mov esi, ecx |
4230 | ; ecx - size x, edx - size y |
4230 | ; ecx - size x, edx - size y |
4231 | 4231 | ||
4232 | mov ebp, edx |
4232 | mov ebp, edx |
4233 | lea ebp, [ebp*3] |
4233 | lea ebp, [ebp*3] |
4234 | imul ebp, esi |
4234 | imul ebp, esi |
4235 | stdcall is_region_userspace, edi, ebp |
4235 | stdcall is_region_userspace, edi, ebp |
4236 | jnz .exit |
4236 | jnz .exit |
4237 | 4237 | ||
4238 | mov ebp, edx |
4238 | mov ebp, edx |
4239 | dec ebp |
4239 | dec ebp |
4240 | lea ebp, [ebp*3] |
4240 | lea ebp, [ebp*3] |
4241 | 4241 | ||
4242 | imul ebp, esi |
4242 | imul ebp, esi |
4243 | 4243 | ||
4244 | mov esi, ecx |
4244 | mov esi, ecx |
4245 | dec esi |
4245 | dec esi |
4246 | lea esi, [esi*3] |
4246 | lea esi, [esi*3] |
4247 | 4247 | ||
4248 | add ebp, esi |
4248 | add ebp, esi |
4249 | add ebp, edi |
4249 | add ebp, edi |
4250 | 4250 | ||
4251 | add ebx, edx |
4251 | add ebx, edx |
4252 | ;-------------------------------------- |
4252 | ;-------------------------------------- |
4253 | align 4 |
4253 | align 4 |
4254 | .start_y: |
4254 | .start_y: |
4255 | push ecx edx |
4255 | push ecx edx |
4256 | ;-------------------------------------- |
4256 | ;-------------------------------------- |
4257 | align 4 |
4257 | align 4 |
4258 | .start_x: |
4258 | .start_x: |
4259 | push eax ebx ecx |
4259 | push eax ebx ecx |
4260 | add eax, ecx |
4260 | add eax, ecx |
4261 | 4261 | ||
4262 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4262 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4263 | call dword [GETPIXEL]; eax - x, ebx - y |
4263 | call dword [GETPIXEL]; eax - x, ebx - y |
4264 | 4264 | ||
4265 | mov [ebp], cx |
4265 | mov [ebp], cx |
4266 | shr ecx, 16 |
4266 | shr ecx, 16 |
4267 | mov [ebp+2], cl |
4267 | mov [ebp+2], cl |
4268 | 4268 | ||
4269 | pop ecx ebx eax |
4269 | pop ecx ebx eax |
4270 | sub ebp, 3 |
4270 | sub ebp, 3 |
4271 | dec ecx |
4271 | dec ecx |
4272 | jnz .start_x |
4272 | jnz .start_x |
4273 | pop edx ecx |
4273 | pop edx ecx |
4274 | dec ebx |
4274 | dec ebx |
4275 | dec edx |
4275 | dec edx |
4276 | jnz .start_y |
4276 | jnz .start_y |
4277 | 4277 | ||
4278 | .exit: |
4278 | .exit: |
4279 | popad |
4279 | popad |
4280 | ret |
4280 | ret |
4281 | ;----------------------------------------------------------------------------- |
4281 | ;----------------------------------------------------------------------------- |
4282 | 4282 | ||
4283 | align 4 |
4283 | align 4 |
4284 | syscall_threads: ; CreateThreads |
4284 | syscall_threads: |
4285 | ; |
4285 | ; eax = 51 |
- | 4286 | ; if ebx = 1 CreateThreads |
|
4286 | ; ecx=thread entry point |
4287 | ; ecx = thread entry point |
4287 | ; edx=thread stack pointer |
4288 | ; edx = thread stack pointer |
- | 4289 | ; return eax = pid |
|
- | 4290 | ||
- | 4291 | ; if ebx = 2 GetCurrentThreadId |
|
- | 4292 | ; return eax = current id slot |
|
4288 | ; |
4293 | |
- | 4294 | ; if ebx = 3 GetThreadPriority |
|
- | 4295 | ; ecx = -1 curr slot or id slot |
|
4289 | ; on return : eax = pid |
4296 | ; return eax = priority |
- | 4297 | ||
- | 4298 | ; if ebx = 4 SetThreadPriority |
|
- | 4299 | ; ecx = -1 curr slot or id slot |
|
- | 4300 | ; edx = set priority |
|
- | 4301 | ; return eax = old priority |
|
- | 4302 | ||
- | 4303 | dec ebx |
|
- | 4304 | jz .create |
|
- | 4305 | mov eax, [current_slot_idx] |
|
- | 4306 | dec ebx |
|
- | 4307 | jz .end ;get_curr_slot |
|
- | 4308 | ||
- | 4309 | test ecx, ecx ;-1 curr slot |
|
- | 4310 | jl .cur_slot |
|
4290 | xor ebx, ebx |
4311 | mov eax, ecx |
- | 4312 | .cur_slot: |
|
- | 4313 | shl eax, BSF sizeof.APPDATA |
|
- | 4314 | add eax, SLOT_BASE |
|
- | 4315 | ||
- | 4316 | test ecx, ecx ;-1 curr slot |
|
- | 4317 | jl .curr_slot |
|
- | 4318 | ||
- | 4319 | mov esi, .err_exit |
|
- | 4320 | mov edi, CONTROL_EXCEPTION |
|
- | 4321 | ||
- | 4322 | movzx ecx, [eax+APPDATA.state] |
|
- | 4323 | test ecx, ecx |
|
- | 4324 | jnz .check_state |
|
- | 4325 | ||
- | 4326 | cmp [eax+APPDATA.tid], ecx |
|
- | 4327 | jnz .curr_slot |
|
- | 4328 | jmp .err_exit |
|
- | 4329 | ||
- | 4330 | .check_state: |
|
- | 4331 | sub ecx, 3 ;TSTATE_ZOMBIE |
|
- | 4332 | jl .curr_slot |
|
- | 4333 | je .err_exit |
|
- | 4334 | dec ecx ; 4 TSTATE_TERMINATING |
|
- | 4335 | dec ecx ; 5 TSTATE_WAITING |
|
- | 4336 | jnz .err_exit |
|
- | 4337 | ||
- | 4338 | .curr_slot: |
|
- | 4339 | dec ebx |
|
- | 4340 | jz .get_priority |
|
- | 4341 | dec ebx |
|
- | 4342 | jz .set_priority |
|
- | 4343 | ||
- | 4344 | .err_exit: |
|
- | 4345 | push -1 |
|
- | 4346 | pop eax |
|
- | 4347 | jmp .end |
|
- | 4348 | ||
- | 4349 | .set_priority: ;;sysfn 51,4 |
|
- | 4350 | mov dh, dl |
|
- | 4351 | lock xchg word [eax+APPDATA.def_priority], dx |
|
- | 4352 | movzx eax, dl ;old priority |
|
- | 4353 | jmp .end |
|
- | 4354 | ||
- | 4355 | .get_priority: ;;sysfn 51,3 |
|
- | 4356 | movzx eax, [eax+APPDATA.def_priority] |
|
- | 4357 | jmp .end |
|
- | 4358 | ||
- | 4359 | .create: ;sysfn 51,1 |
|
4291 | call new_sys_threads |
4360 | call new_sys_threads |
- | 4361 | ||
4292 | 4362 | .end: |
|
4293 | mov [esp + SYSCALL_STACK.eax], eax |
4363 | mov [esp + SYSCALL_STACK.eax], eax |
4294 | ret |
4364 | ret |
4295 | 4365 | ||
4296 | ;------------------------------------------------------------------------------ |
4366 | ;------------------------------------------------------------------------------ |
4297 | align 4 |
4367 | align 4 |
4298 | calculate_fast_getting_offset_for_WinMapAddress: |
4368 | calculate_fast_getting_offset_for_WinMapAddress: |
4299 | ; calculate data area for fast getting offset to _WinMapAddress |
4369 | ; calculate data area for fast getting offset to _WinMapAddress |
4300 | xor eax, eax |
4370 | xor eax, eax |
4301 | mov ecx, [_display.height] |
4371 | mov ecx, [_display.height] |
4302 | mov edi, d_width_calc_area |
4372 | mov edi, d_width_calc_area |
4303 | cld |
4373 | cld |
4304 | @@: |
4374 | @@: |
4305 | stosd |
4375 | stosd |
4306 | add eax, [_display.width] |
4376 | add eax, [_display.width] |
4307 | dec ecx |
4377 | dec ecx |
4308 | jnz @r |
4378 | jnz @r |
4309 | ret |
4379 | ret |
4310 | ;------------------------------------------------------------------------------ |
4380 | ;------------------------------------------------------------------------------ |
4311 | align 4 |
4381 | align 4 |
4312 | calculate_fast_getting_offset_for_LFB: |
4382 | calculate_fast_getting_offset_for_LFB: |
4313 | ; calculate data area for fast getting offset to LFB |
4383 | ; calculate data area for fast getting offset to LFB |
4314 | xor eax, eax |
4384 | xor eax, eax |
4315 | mov ecx, [_display.height] |
4385 | mov ecx, [_display.height] |
4316 | mov edi, BPSLine_calc_area |
4386 | mov edi, BPSLine_calc_area |
4317 | cld |
4387 | cld |
4318 | @@: |
4388 | @@: |
4319 | stosd |
4389 | stosd |
4320 | add eax, [_display.lfb_pitch] |
4390 | add eax, [_display.lfb_pitch] |
4321 | dec ecx |
4391 | dec ecx |
4322 | jnz @r |
4392 | jnz @r |
4323 | ret |
4393 | ret |
4324 | ;------------------------------------------------------------------------------ |
4394 | ;------------------------------------------------------------------------------ |
4325 | align 4 |
4395 | align 4 |
4326 | set_screen: |
4396 | set_screen: |
4327 | ; in: |
4397 | ; in: |
4328 | ; eax - new Screen_Max_X |
4398 | ; eax - new Screen_Max_X |
4329 | ; ecx - new BytesPerScanLine |
4399 | ; ecx - new BytesPerScanLine |
4330 | ; edx - new Screen_Max_Y |
4400 | ; edx - new Screen_Max_Y |
4331 | 4401 | ||
4332 | pushfd |
4402 | pushfd |
4333 | cli |
4403 | cli |
4334 | 4404 | ||
4335 | mov [_display.lfb_pitch], ecx |
4405 | mov [_display.lfb_pitch], ecx |
4336 | 4406 | ||
4337 | mov [screen_workarea.right], eax |
4407 | mov [screen_workarea.right], eax |
4338 | mov [screen_workarea.bottom], edx |
4408 | mov [screen_workarea.bottom], edx |
4339 | 4409 | ||
4340 | push ebx |
4410 | push ebx |
4341 | push esi |
4411 | push esi |
4342 | push edi |
4412 | push edi |
4343 | 4413 | ||
4344 | pushad |
4414 | pushad |
4345 | 4415 | ||
4346 | cmp [do_not_touch_winmap], 1 |
4416 | cmp [do_not_touch_winmap], 1 |
4347 | je @f |
4417 | je @f |
4348 | 4418 | ||
4349 | stdcall kernel_free, [_display.win_map] |
4419 | stdcall kernel_free, [_display.win_map] |
4350 | 4420 | ||
4351 | mov eax, [_display.width] |
4421 | mov eax, [_display.width] |
4352 | mul [_display.height] |
4422 | mul [_display.height] |
4353 | mov [_display.win_map_size], eax |
4423 | mov [_display.win_map_size], eax |
4354 | 4424 | ||
4355 | stdcall kernel_alloc, eax |
4425 | stdcall kernel_alloc, eax |
4356 | mov [_display.win_map], eax |
4426 | mov [_display.win_map], eax |
4357 | test eax, eax |
4427 | test eax, eax |
4358 | jz .epic_fail |
4428 | jz .epic_fail |
4359 | ; store for f.18.24 |
4429 | ; store for f.18.24 |
4360 | mov eax, [_display.width] |
4430 | mov eax, [_display.width] |
4361 | mov [display_width_standard], eax |
4431 | mov [display_width_standard], eax |
4362 | 4432 | ||
4363 | mov eax, [_display.height] |
4433 | mov eax, [_display.height] |
4364 | mov [display_height_standard], eax |
4434 | mov [display_height_standard], eax |
4365 | @@: |
4435 | @@: |
4366 | call calculate_fast_getting_offset_for_WinMapAddress |
4436 | call calculate_fast_getting_offset_for_WinMapAddress |
4367 | ; for Qemu or non standart video cards |
4437 | ; for Qemu or non standart video cards |
4368 | ; Unfortunately [BytesPerScanLine] does not always |
4438 | ; Unfortunately [BytesPerScanLine] does not always |
4369 | ; equal to [_display.width] * [ScreenBPP] / 8 |
4439 | ; equal to [_display.width] * [ScreenBPP] / 8 |
4370 | call calculate_fast_getting_offset_for_LFB |
4440 | call calculate_fast_getting_offset_for_LFB |
4371 | popad |
4441 | popad |
4372 | 4442 | ||
4373 | call repos_windows |
4443 | call repos_windows |
4374 | xor eax, eax |
4444 | xor eax, eax |
4375 | xor ebx, ebx |
4445 | xor ebx, ebx |
4376 | mov ecx, [_display.width] |
4446 | mov ecx, [_display.width] |
4377 | mov edx, [_display.height] |
4447 | mov edx, [_display.height] |
4378 | dec ecx |
4448 | dec ecx |
4379 | dec edx |
4449 | dec edx |
4380 | call calculatescreen |
4450 | call calculatescreen |
4381 | pop edi |
4451 | pop edi |
4382 | pop esi |
4452 | pop esi |
4383 | pop ebx |
4453 | pop ebx |
4384 | 4454 | ||
4385 | popfd |
4455 | popfd |
4386 | ret |
4456 | ret |
4387 | 4457 | ||
4388 | .epic_fail: |
4458 | .epic_fail: |
4389 | hlt ; Houston, we've had a problem |
4459 | hlt ; Houston, we've had a problem |
4390 | 4460 | ||
4391 | ; --------------- APM --------------------- |
4461 | ; --------------- APM --------------------- |
4392 | uglobal |
4462 | uglobal |
4393 | apm_entry dp 0 |
4463 | apm_entry dp 0 |
4394 | apm_vf dd 0 |
4464 | apm_vf dd 0 |
4395 | endg |
4465 | endg |
4396 | 4466 | ||
4397 | align 4 |
4467 | align 4 |
4398 | sys_apm: |
4468 | sys_apm: |
4399 | xor eax, eax |
4469 | xor eax, eax |
4400 | cmp word [apm_vf], ax ; Check APM BIOS enable |
4470 | cmp word [apm_vf], ax ; Check APM BIOS enable |
4401 | jne @f |
4471 | jne @f |
4402 | inc eax |
4472 | inc eax |
4403 | or dword [esp + 44], eax ; error |
4473 | or dword [esp + 44], eax ; error |
4404 | add eax, 7 |
4474 | add eax, 7 |
4405 | mov [esp + SYSCALL_STACK.eax], eax ; 32-bit protected-mode |
4475 | mov [esp + SYSCALL_STACK.eax], eax ; 32-bit protected-mode |
4406 | ; interface not supported |
4476 | ; interface not supported |
4407 | ret |
4477 | ret |
4408 | 4478 | ||
4409 | @@: |
4479 | @@: |
4410 | ; xchg eax, ecx |
4480 | ; xchg eax, ecx |
4411 | ; xchg ebx, ecx |
4481 | ; xchg ebx, ecx |
4412 | 4482 | ||
4413 | cmp dx, 3 |
4483 | cmp dx, 3 |
4414 | ja @f |
4484 | ja @f |
4415 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
4485 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
4416 | mov eax, [apm_vf] |
4486 | mov eax, [apm_vf] |
4417 | mov [esp + SYSCALL_STACK.eax], eax |
4487 | mov [esp + SYSCALL_STACK.eax], eax |
4418 | shr eax, 16 |
4488 | shr eax, 16 |
4419 | mov [esp + SYSCALL_STACK.ecx], eax |
4489 | mov [esp + SYSCALL_STACK.ecx], eax |
4420 | ret |
4490 | ret |
4421 | 4491 | ||
4422 | @@: |
4492 | @@: |
4423 | 4493 | ||
4424 | mov esi, [master_tab+(OS_BASE shr 20)] |
4494 | mov esi, [master_tab+(OS_BASE shr 20)] |
4425 | xchg [master_tab], esi |
4495 | xchg [master_tab], esi |
4426 | push esi |
4496 | push esi |
4427 | mov edi, cr3 |
4497 | mov edi, cr3 |
4428 | mov cr3, edi ;flush TLB |
4498 | mov cr3, edi ;flush TLB |
4429 | 4499 | ||
4430 | call pword [apm_entry] ;call APM BIOS |
4500 | call pword [apm_entry] ;call APM BIOS |
4431 | 4501 | ||
4432 | xchg eax, [esp] |
4502 | xchg eax, [esp] |
4433 | mov [master_tab], eax |
4503 | mov [master_tab], eax |
4434 | mov eax, cr3 |
4504 | mov eax, cr3 |
4435 | mov cr3, eax |
4505 | mov cr3, eax |
4436 | pop eax |
4506 | pop eax |
4437 | 4507 | ||
4438 | mov [esp + SYSCALL_STACK.edi], edi |
4508 | mov [esp + SYSCALL_STACK.edi], edi |
4439 | mov [esp + SYSCALL_STACK.esi], esi |
4509 | mov [esp + SYSCALL_STACK.esi], esi |
4440 | mov [esp + SYSCALL_STACK.ebx], ebx |
4510 | mov [esp + SYSCALL_STACK.ebx], ebx |
4441 | mov [esp + SYSCALL_STACK.edx], edx |
4511 | mov [esp + SYSCALL_STACK.edx], edx |
4442 | mov [esp + SYSCALL_STACK.ecx], ecx |
4512 | mov [esp + SYSCALL_STACK.ecx], ecx |
4443 | mov [esp + SYSCALL_STACK.eax], eax |
4513 | mov [esp + SYSCALL_STACK.eax], eax |
4444 | setc al |
4514 | setc al |
4445 | and [esp + 44], byte 0xfe |
4515 | and [esp + 44], byte 0xfe |
4446 | or [esp + 44], al |
4516 | or [esp + 44], al |
4447 | ret |
4517 | ret |
4448 | ; ----------------------------------------- |
4518 | ; ----------------------------------------- |
4449 | 4519 | ||
4450 | align 4 |
4520 | align 4 |
4451 | undefined_syscall: ; Undefined system call |
4521 | undefined_syscall: ; Undefined system call |
4452 | mov [esp + SYSCALL_STACK.eax], -1 |
4522 | mov [esp + SYSCALL_STACK.eax], -1 |
4453 | ret |
4523 | ret |
4454 | 4524 | ||
4455 | align 4 |
4525 | align 4 |
4456 | ; @brief Check if given memory region lays in lower 2gb (userspace memory) or not |
4526 | ; @brief Check if given memory region lays in lower 2gb (userspace memory) or not |
4457 | ; @param base Base address of region |
4527 | ; @param base Base address of region |
4458 | ; @param len Lenght of region |
4528 | ; @param len Lenght of region |
4459 | ; @return ZF = 1 if region in userspace memory, |
4529 | ; @return ZF = 1 if region in userspace memory, |
4460 | ; ZF = 0 otherwise |
4530 | ; ZF = 0 otherwise |
4461 | proc is_region_userspace stdcall, base:dword, len:dword |
4531 | proc is_region_userspace stdcall, base:dword, len:dword |
4462 | push eax |
4532 | push eax |
4463 | mov eax, [base] |
4533 | mov eax, [base] |
4464 | 4534 | ||
4465 | cmp eax, OS_BASE-1 |
4535 | cmp eax, OS_BASE-1 |
4466 | ja @f ; zf |
4536 | ja @f ; zf |
4467 | 4537 | ||
4468 | add eax, [len] |
4538 | add eax, [len] |
4469 | jc @f ; zf |
4539 | jc @f ; zf |
4470 | cmp eax, OS_BASE |
4540 | cmp eax, OS_BASE |
4471 | ja @f ; zf |
4541 | ja @f ; zf |
4472 | 4542 | ||
4473 | cmp eax, eax ; ZF |
4543 | cmp eax, eax ; ZF |
4474 | @@: |
4544 | @@: |
4475 | pop eax |
4545 | pop eax |
4476 | ret |
4546 | ret |
4477 | endp |
4547 | endp |
4478 | 4548 | ||
4479 | align 4 |
4549 | align 4 |
4480 | ; @brief Check whether given string lays in userspace memory, i.e. below OS_BASE |
4550 | ; @brief Check whether given string lays in userspace memory, i.e. below OS_BASE |
4481 | ; @param base Base address of string |
4551 | ; @param base Base address of string |
4482 | ; @return ZF = 1 if string in userspace memory, |
4552 | ; @return ZF = 1 if string in userspace memory, |
4483 | ; zf = 0 otherwise |
4553 | ; zf = 0 otherwise |
4484 | proc is_string_userspace stdcall, base:dword |
4554 | proc is_string_userspace stdcall, base:dword |
4485 | push eax ecx edi |
4555 | push eax ecx edi |
4486 | xor eax, eax |
4556 | xor eax, eax |
4487 | mov edi, [base] |
4557 | mov edi, [base] |
4488 | 4558 | ||
4489 | mov ecx, OS_BASE-1 |
4559 | mov ecx, OS_BASE-1 |
4490 | sub ecx, edi |
4560 | sub ecx, edi |
4491 | jb .done ; zf |
4561 | jb .done ; zf |
4492 | inc ecx |
4562 | inc ecx |
4493 | cmp ecx, 0x10000 ; don't allow strings larger than 64k? |
4563 | cmp ecx, 0x10000 ; don't allow strings larger than 64k? |
4494 | jbe @f |
4564 | jbe @f |
4495 | mov ecx, 0x10000 |
4565 | mov ecx, 0x10000 |
4496 | @@: |
4566 | @@: |
4497 | repnz scasb |
4567 | repnz scasb |
4498 | .done: |
4568 | .done: |
4499 | pop edi ecx eax |
4569 | pop edi ecx eax |
4500 | ret |
4570 | ret |
4501 | endp |
4571 | endp |
4502 | 4572 | ||
4503 | if ~ lang eq sp |
4573 | if ~ lang eq sp |
4504 | diff16 "end of .text segment",0,$ |
4574 | diff16 "end of .text segment",0,$ |
4505 | end if |
4575 | end if |
4506 | 4576 | ||
4507 | include "data32.inc" |
4577 | include "data32.inc" |
4508 | 4578 | ||
4509 | __REV__ = __REV |
4579 | __REV__ = __REV |
4510 | 4580 | ||
4511 | if ~ lang eq sp |
4581 | if ~ lang eq sp |
4512 | diff16 "end of kernel code",0,$ |
4582 | diff16 "end of kernel code",0,$ |
4513 | end if=> |
4583 | end if=> |