2011-10-14 23:38:50 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;;
|
2022-02-12 18:27:41 +01:00
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2022. All rights reserved.
|
2023-10-01 23:53:34 +02:00
|
|
|
|
;; Kernel programmers are acknowledged in CREDITS.TXT
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;;
|
|
|
|
|
;; Data in this file was originally part of MenuetOS project which is
|
|
|
|
|
;; distributed under the terms of GNU GPL. It is modified and redistributed as
|
|
|
|
|
;; part of KolibriOS project under the terms of GNU GPL.
|
|
|
|
|
;;
|
|
|
|
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa
|
|
|
|
|
;;
|
|
|
|
|
;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
;; WARRANTY. No author or distributor accepts responsibility to anyone for the
|
|
|
|
|
;; consequences of using it or for whether it serves any particular purpose or
|
|
|
|
|
;; works at all, unless he says so in writing. Refer to the GNU General Public
|
|
|
|
|
;; License (the "GPL") for full details.
|
|
|
|
|
;
|
|
|
|
|
;; Everyone is granted permission to copy, modify and redistribute KolibriOS,
|
|
|
|
|
;; but only under the conditions described in the GPL. A copy of this license
|
|
|
|
|
;; is supposed to have been given to you along with KolibriOS so you can know
|
|
|
|
|
;; your rights and responsibilities. It should be in a file named COPYING.
|
|
|
|
|
;; Among other things, the copyright notice and this notice must be preserved
|
|
|
|
|
;; on all copies.
|
|
|
|
|
;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
2013-03-17 19:58:28 +01:00
|
|
|
|
format binary as "mnt"
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
include 'macros.inc'
|
2012-02-22 16:46:09 +01:00
|
|
|
|
include 'struct.inc'
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
|
|
2017-12-20 02:07:10 +01:00
|
|
|
|
USE_COM_IRQ = 1 ; make irq 3 and irq 4 available for PCI devices
|
|
|
|
|
VESA_1_2_VIDEO = 0 ; enable vesa 1.2 bank switch functions
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; Enabling the next line will enable serial output console
|
2017-12-20 02:07:10 +01:00
|
|
|
|
;debug_com_base = 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
include "proc32.inc"
|
|
|
|
|
include "kglobals.inc"
|
|
|
|
|
include "lang.inc"
|
2013-05-28 00:16:00 +02:00
|
|
|
|
include "encoding.inc"
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
include "const.inc"
|
2013-07-08 01:12:01 +02:00
|
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
|
; The following variable, if equal to 1, duplicates debug output to the screen.
|
|
|
|
|
debug_direct_print db 0
|
|
|
|
|
; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no)
|
|
|
|
|
launcher_start db 1
|
|
|
|
|
endg
|
|
|
|
|
|
2017-12-20 02:07:10 +01:00
|
|
|
|
max_processes = 255
|
|
|
|
|
tss_step = 128 + 8192 ; tss & i/o - 65535 ports, * 256=557056*4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2017-12-20 02:07:10 +01:00
|
|
|
|
os_stack = os_data_l - gdts ; GDTs
|
|
|
|
|
os_code = os_code_l - gdts
|
|
|
|
|
graph_data = 3 + graph_data_l - gdts
|
|
|
|
|
tss0 = tss0_l - gdts
|
|
|
|
|
app_code = 3 + app_code_l - gdts
|
|
|
|
|
app_data = 3 + app_data_l - gdts
|
|
|
|
|
app_tls = 3 + tls_data_l - gdts
|
|
|
|
|
pci_code_sel = pci_code_32-gdts
|
|
|
|
|
pci_data_sel = pci_data_32-gdts
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;;
|
|
|
|
|
;; Included files:
|
|
|
|
|
;;
|
|
|
|
|
;; Kernel16.inc
|
|
|
|
|
;; - Booteng.inc English text for bootup
|
|
|
|
|
;; - Bootcode.inc Hardware setup
|
|
|
|
|
;; - Pci16.inc PCI functions
|
|
|
|
|
;;
|
|
|
|
|
;; Kernel32.inc
|
|
|
|
|
;; - Sys32.inc Process management
|
|
|
|
|
;; - Shutdown.inc Shutdown and restart
|
|
|
|
|
;; - Fat32.inc Read / write hd
|
|
|
|
|
;; - Vesa12.inc Vesa 1.2 driver
|
|
|
|
|
;; - Vesa20.inc Vesa 2.0 driver
|
|
|
|
|
;; - Vga.inc VGA driver
|
|
|
|
|
;; - Stack.inc Network interface
|
|
|
|
|
;; - Mouse.inc Mouse pointer
|
|
|
|
|
;; - Scincode.inc Window skinning
|
|
|
|
|
;; - Pci32.inc PCI functions
|
|
|
|
|
;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
2017-12-16 21:21:10 +01:00
|
|
|
|
; In bios boot mode the kernel code below is appended to bootbios.bin file.
|
|
|
|
|
; That is a loading and initialization code that also draws the blue screen
|
|
|
|
|
; menu with svn revision number near top right corner of the screen. This fasm
|
|
|
|
|
; preprocessor code searches for '****' signature inside bootbios.bin and
|
|
|
|
|
; places revision number there.
|
|
|
|
|
if ~ defined UEFI
|
|
|
|
|
bootbios:
|
2021-11-05 00:52:56 +01:00
|
|
|
|
if defined extended_primary_loader
|
2020-10-04 18:53:59 +02:00
|
|
|
|
file 'bootbios.bin.ext_loader'
|
2021-11-05 00:52:56 +01:00
|
|
|
|
else if defined pretest_build
|
|
|
|
|
file 'bootbios.bin.pretest'
|
|
|
|
|
else
|
|
|
|
|
file 'bootbios.bin'
|
2020-10-04 18:53:59 +02:00
|
|
|
|
end if
|
2017-12-16 21:21:10 +01:00
|
|
|
|
if __REV__ > 0
|
|
|
|
|
cur_pos = 0
|
|
|
|
|
cnt = 0
|
|
|
|
|
repeat $ - bootbios
|
|
|
|
|
load a byte from %
|
|
|
|
|
if a = '*'
|
|
|
|
|
cnt = cnt + 1
|
|
|
|
|
else
|
|
|
|
|
cnt = 0
|
|
|
|
|
end if
|
|
|
|
|
if cnt = 4
|
|
|
|
|
cur_pos = % - 1
|
|
|
|
|
break
|
|
|
|
|
end if
|
|
|
|
|
end repeat
|
|
|
|
|
store byte ' ' at cur_pos + 1
|
|
|
|
|
rev_var = __REV__
|
|
|
|
|
while rev_var > 0
|
|
|
|
|
store byte rev_var mod 10 + '0' at cur_pos
|
|
|
|
|
cur_pos = cur_pos - 1
|
|
|
|
|
rev_var = rev_var / 10
|
|
|
|
|
end while
|
|
|
|
|
store byte ' ' at cur_pos
|
|
|
|
|
store dword ' SVN' at cur_pos - 4
|
|
|
|
|
end if
|
2013-06-08 15:08:51 +02:00
|
|
|
|
end if
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
use32
|
|
|
|
|
org $+0x10000
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
B32:
|
|
|
|
|
mov ax, os_stack ; Selector for os
|
|
|
|
|
mov ds, ax
|
|
|
|
|
mov es, ax
|
|
|
|
|
mov fs, ax
|
|
|
|
|
mov gs, ax
|
|
|
|
|
mov ss, ax
|
2016-02-18 03:03:38 +01:00
|
|
|
|
mov esp, TMP_STACK_TOP ; Set stack
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; CLEAR 0x280000 - HEAP_BASE
|
|
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov edi, CLEAN_ZONE
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov ecx, (HEAP_BASE - OS_BASE - CLEAN_ZONE) / 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cld
|
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
|
|
; CLEAR KERNEL UNDEFINED GLOBALS
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov edi, endofcode - OS_BASE
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ecx, 0x90000
|
|
|
|
|
sub ecx, edi
|
|
|
|
|
shr ecx, 2
|
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
|
|
; SAVE & CLEAR 0-0xffff
|
|
|
|
|
|
|
|
|
|
mov edi, 0x1000
|
2013-06-29 10:26:56 +02:00
|
|
|
|
mov ecx, 0x8000 / 4
|
|
|
|
|
rep stosd
|
|
|
|
|
mov edi, 0xa000
|
|
|
|
|
mov ecx, 0x6000 / 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
|
|
call test_cpu
|
2022-02-12 18:27:41 +01:00
|
|
|
|
bts [cpu_caps - OS_BASE], CAPS_TSC ;force use rdtsc
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2020-10-21 16:23:51 +02:00
|
|
|
|
call acpi_locate
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call init_BIOS32
|
|
|
|
|
; MEMORY MODEL
|
|
|
|
|
call mem_test
|
|
|
|
|
call init_mem
|
|
|
|
|
call init_page_map
|
|
|
|
|
|
|
|
|
|
; ENABLE PAGING
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, sys_proc - OS_BASE + PROC.pdt_0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov cr3, eax
|
|
|
|
|
|
|
|
|
|
mov eax, cr0
|
2022-02-12 18:27:41 +01:00
|
|
|
|
or eax, CR0_PG + CR0_WP
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov cr0, eax
|
|
|
|
|
|
|
|
|
|
lgdt [gdts]
|
|
|
|
|
jmp pword os_code:high_code
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
bios32_entry dd ?
|
|
|
|
|
tmp_page_tabs dd ?
|
|
|
|
|
use16
|
2014-08-15 17:46:44 +02:00
|
|
|
|
ap_init16:
|
|
|
|
|
cli
|
2022-02-12 18:27:41 +01:00
|
|
|
|
lgdt [cs:gdts_ap - ap_init16]
|
|
|
|
|
mov eax, [cs:cr3_ap - ap_init16]
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov cr3, eax
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [cs:cr4_ap - ap_init16]
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov cr4, eax
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, CR0_PE + CR0_PG + CR0_WP
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov cr0, eax
|
|
|
|
|
jmp pword os_code:ap_init_high
|
|
|
|
|
align 16
|
|
|
|
|
gdts_ap:
|
|
|
|
|
dw gdte-gdts-1
|
|
|
|
|
dd gdts
|
|
|
|
|
dw 0
|
|
|
|
|
cr3_ap dd ?
|
|
|
|
|
cr4_ap dd ?
|
|
|
|
|
ap_init16_size = $ - ap_init16
|
2011-10-14 23:38:50 +02:00
|
|
|
|
use32
|
|
|
|
|
|
|
|
|
|
__DEBUG__ fix 1
|
|
|
|
|
__DEBUG_LEVEL__ fix 1
|
|
|
|
|
include 'init.inc'
|
|
|
|
|
|
|
|
|
|
org OS_BASE+$
|
|
|
|
|
|
2012-03-09 16:50:49 +01:00
|
|
|
|
include 'fdo.inc'
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
high_code:
|
|
|
|
|
mov ax, os_stack
|
|
|
|
|
mov bx, app_data
|
|
|
|
|
mov cx, app_tls
|
|
|
|
|
mov ss, ax
|
|
|
|
|
add esp, OS_BASE
|
|
|
|
|
|
|
|
|
|
mov ds, bx
|
|
|
|
|
mov es, bx
|
|
|
|
|
mov fs, cx
|
|
|
|
|
mov gs, bx
|
|
|
|
|
|
2015-01-07 00:07:34 +01:00
|
|
|
|
xor eax, eax
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov ebx, 0xFFFFF000 + PG_SHARED + PG_NOCACHE + PG_UWR
|
2015-01-07 00:07:34 +01:00
|
|
|
|
bt [cpu_caps], CAPS_PAT
|
|
|
|
|
setc al
|
|
|
|
|
shl eax, 7
|
|
|
|
|
or ebx, eax
|
|
|
|
|
|
2015-01-06 17:09:34 +01:00
|
|
|
|
mov eax, PG_GLOBAL
|
2011-10-14 23:38:50 +02:00
|
|
|
|
bt [cpu_caps], CAPS_PGE
|
|
|
|
|
jnc @F
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
or [sys_proc + PROC.pdt_0 + (OS_BASE shr 20)], eax
|
2015-01-07 00:07:34 +01:00
|
|
|
|
or ebx, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2015-01-07 00:07:34 +01:00
|
|
|
|
mov eax, cr4
|
|
|
|
|
or eax, CR4_PGE
|
|
|
|
|
mov cr4, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
2015-01-07 00:07:34 +01:00
|
|
|
|
mov [pte_valid_mask], ebx
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor eax, eax
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov dword [sys_proc + PROC.pdt_0], eax
|
|
|
|
|
mov dword [sys_proc + PROC.pdt_0+4], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, cr3
|
|
|
|
|
mov cr3, eax ; flush TLB
|
|
|
|
|
|
|
|
|
|
mov ecx, pg_data.mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
|
|
|
|
|
mov ecx, disk_list_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
|
2012-04-11 21:06:32 +02:00
|
|
|
|
mov ecx, keyboard_list_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
|
2012-03-21 23:48:54 +01:00
|
|
|
|
mov ecx, unpack_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
|
2013-05-27 11:02:35 +02:00
|
|
|
|
mov ecx, application_table_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
|
2013-07-01 18:29:16 +02:00
|
|
|
|
mov ecx, ide_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
mov ecx, ide_channel1_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
mov ecx, ide_channel2_mutex
|
|
|
|
|
call mutex_init
|
2014-03-27 21:44:32 +01:00
|
|
|
|
mov ecx, ide_channel3_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
mov ecx, ide_channel4_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
mov ecx, ide_channel5_mutex
|
|
|
|
|
call mutex_init
|
|
|
|
|
mov ecx, ide_channel6_mutex
|
|
|
|
|
call mutex_init
|
2013-07-07 04:10:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; SAVE REAL MODE VARIABLES
|
2013-07-07 04:10:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; --------------- APM ---------------------
|
|
|
|
|
|
|
|
|
|
; init selectors
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov ebx, [BOOT.apm_entry] ; offset of APM entry point
|
|
|
|
|
movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of
|
|
|
|
|
; protected-mode 32-bit code segment
|
|
|
|
|
movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of
|
|
|
|
|
; protected-mode 16-bit code segment
|
|
|
|
|
movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of
|
|
|
|
|
; protected-mode 16-bit data segment
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
shl eax, 4
|
|
|
|
|
mov [dword apm_code_32 + 2], ax
|
|
|
|
|
shr eax, 16
|
|
|
|
|
mov [dword apm_code_32 + 4], al
|
|
|
|
|
|
|
|
|
|
shl ecx, 4
|
|
|
|
|
mov [dword apm_code_16 + 2], cx
|
|
|
|
|
shr ecx, 16
|
|
|
|
|
mov [dword apm_code_16 + 4], cl
|
|
|
|
|
|
|
|
|
|
shl edx, 4
|
|
|
|
|
mov [dword apm_data_16 + 2], dx
|
|
|
|
|
shr edx, 16
|
|
|
|
|
mov [dword apm_data_16 + 4], dl
|
|
|
|
|
|
|
|
|
|
mov dword[apm_entry], ebx
|
|
|
|
|
mov word [apm_entry + 4], apm_code_32 - gdts
|
|
|
|
|
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov eax, dword[BOOT.apm_version] ; version & flags
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [apm_vf], eax
|
|
|
|
|
; -----------------------------------------
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov al, [BOOT.dma] ; DMA access
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [allow_dma_access], al
|
2016-02-20 10:57:44 +01:00
|
|
|
|
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen
|
2013-07-08 01:12:01 +02:00
|
|
|
|
mov [debug_direct_print], al
|
2016-02-20 10:57:44 +01:00
|
|
|
|
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded?
|
2013-07-08 01:12:01 +02:00
|
|
|
|
mov [launcher_start], al
|
2012-03-08 20:10:26 +01:00
|
|
|
|
|
2020-10-06 05:32:57 +02:00
|
|
|
|
mov eax, [BOOT.devicesdat_size]
|
|
|
|
|
mov [acpi_dev_size], eax
|
|
|
|
|
mov eax, [BOOT.devicesdat_data]
|
|
|
|
|
mov [acpi_dev_data], eax
|
|
|
|
|
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov esi, BOOT.bios_hd
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movzx ecx, byte [esi-1]
|
|
|
|
|
mov [NumBiosDisks], ecx
|
|
|
|
|
mov edi, BiosDisksData
|
2017-01-21 01:14:05 +01:00
|
|
|
|
shl ecx, 2
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep movsd
|
|
|
|
|
|
|
|
|
|
; -------- Fast System Call init ----------
|
|
|
|
|
; Intel SYSENTER/SYSEXIT (AMD CPU support it too)
|
|
|
|
|
bt [cpu_caps], CAPS_SEP
|
|
|
|
|
jnc .SEnP ; SysEnter not Present
|
|
|
|
|
xor edx, edx
|
|
|
|
|
mov ecx, MSR_SYSENTER_CS
|
|
|
|
|
mov eax, os_code
|
|
|
|
|
wrmsr
|
|
|
|
|
mov ecx, MSR_SYSENTER_ESP
|
|
|
|
|
; mov eax, sysenter_stack ; Check it
|
|
|
|
|
xor eax, eax
|
|
|
|
|
wrmsr
|
|
|
|
|
mov ecx, MSR_SYSENTER_EIP
|
|
|
|
|
mov eax, sysenter_entry
|
|
|
|
|
wrmsr
|
|
|
|
|
.SEnP:
|
|
|
|
|
; AMD SYSCALL/SYSRET
|
|
|
|
|
cmp byte[cpu_vendor], 'A'
|
|
|
|
|
jne .noSYSCALL
|
|
|
|
|
mov eax, 0x80000001
|
|
|
|
|
cpuid
|
|
|
|
|
test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support
|
|
|
|
|
jz .noSYSCALL
|
|
|
|
|
mov ecx, MSR_AMD_EFER
|
|
|
|
|
rdmsr
|
|
|
|
|
or eax, 1 ; bit_0 - System Call Extension (SCE)
|
|
|
|
|
wrmsr
|
|
|
|
|
|
|
|
|
|
; !!!! It`s dirty hack, fix it !!!
|
|
|
|
|
; Bits of EDX :
|
2013-05-28 00:16:00 +02:00
|
|
|
|
; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; and the contents of this field, plus 8, are copied into the SS register.
|
2013-05-28 00:16:00 +02:00
|
|
|
|
; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; and the contents of this field, plus 8, are copied into the SS register.
|
|
|
|
|
|
|
|
|
|
; mov edx, (os_code + 16) * 65536 + os_code
|
|
|
|
|
mov edx, 0x1B0008
|
|
|
|
|
|
|
|
|
|
mov eax, syscall_entry
|
|
|
|
|
mov ecx, MSR_AMD_STAR
|
|
|
|
|
wrmsr
|
|
|
|
|
.noSYSCALL:
|
|
|
|
|
; -----------------------------------------
|
|
|
|
|
stdcall alloc_page
|
2015-01-06 15:53:54 +01:00
|
|
|
|
stdcall map_page, tss-0xF80, eax, PG_SWR
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stdcall alloc_page
|
2015-01-06 15:53:54 +01:00
|
|
|
|
stdcall map_page, tss+0x80, eax, PG_SWR
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stdcall alloc_page
|
2015-01-06 15:53:54 +01:00
|
|
|
|
stdcall map_page, tss+0x1080, eax, PG_SWR
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; LOAD IDT
|
|
|
|
|
|
|
|
|
|
call build_interrupt_table ;lidt is executed
|
|
|
|
|
;lidt [idtreg]
|
|
|
|
|
|
|
|
|
|
call init_kernel_heap
|
2018-05-13 02:16:10 +02:00
|
|
|
|
call init_fpu
|
|
|
|
|
mov eax, [xsave_area_size]
|
|
|
|
|
lea eax, [eax*2 + RING0_STACK_SIZE*2]
|
|
|
|
|
stdcall kernel_alloc, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [os_stack_seg], eax
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
lea esp, [eax + RING0_STACK_SIZE]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov [tss._ss0], os_stack
|
|
|
|
|
mov [tss._esp0], esp
|
|
|
|
|
mov [tss._esp], esp
|
|
|
|
|
mov [tss._cs], os_code
|
|
|
|
|
mov [tss._ss], os_stack
|
|
|
|
|
mov [tss._ds], app_data
|
|
|
|
|
mov [tss._es], app_data
|
|
|
|
|
mov [tss._fs], app_data
|
|
|
|
|
mov [tss._gs], app_data
|
|
|
|
|
mov [tss._io], 128
|
|
|
|
|
;Add IO access table - bit array of permitted ports
|
|
|
|
|
mov edi, tss._io_map_0
|
|
|
|
|
xor eax, eax
|
|
|
|
|
not eax
|
|
|
|
|
mov ecx, 8192/4
|
|
|
|
|
rep stosd ; access to 4096*8=65536 ports
|
|
|
|
|
|
|
|
|
|
mov ax, tss0
|
|
|
|
|
ltr ax
|
|
|
|
|
|
2016-02-20 10:57:44 +01:00
|
|
|
|
mov eax, sys_proc
|
|
|
|
|
list_init eax
|
|
|
|
|
add eax, PROC.thr_list
|
|
|
|
|
list_init eax
|
|
|
|
|
|
|
|
|
|
call init_video
|
|
|
|
|
call init_mtrr
|
|
|
|
|
mov [LFBAddress], LFB_BASE
|
|
|
|
|
mov ecx, bios_fb
|
|
|
|
|
call set_framebuffer
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call init_malloc
|
|
|
|
|
|
2014-09-18 09:58:56 +02:00
|
|
|
|
stdcall alloc_kernel_space, 0x50000 ; FIXME check size
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [default_io_map], eax
|
|
|
|
|
|
|
|
|
|
add eax, 0x2000
|
|
|
|
|
mov [ipc_tmp], eax
|
|
|
|
|
mov ebx, 0x1000
|
|
|
|
|
|
|
|
|
|
add eax, 0x40000
|
|
|
|
|
mov [proc_mem_map], eax
|
|
|
|
|
|
|
|
|
|
add eax, 0x8000
|
|
|
|
|
mov [proc_mem_pdir], eax
|
|
|
|
|
|
|
|
|
|
add eax, ebx
|
|
|
|
|
mov [proc_mem_tab], eax
|
|
|
|
|
|
|
|
|
|
add eax, ebx
|
|
|
|
|
mov [tmp_task_ptab], eax
|
|
|
|
|
|
|
|
|
|
add eax, ebx
|
|
|
|
|
mov [ipc_pdir], eax
|
|
|
|
|
|
|
|
|
|
add eax, ebx
|
|
|
|
|
mov [ipc_ptab], eax
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE + (unpack.LZMA_LIT_SIZE shl \
|
|
|
|
|
(unpack.lc + unpack.lp)))*4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov [unpack.p], eax
|
|
|
|
|
|
|
|
|
|
call init_events
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, srv.fd - SRV.fd
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [srv.fd], eax
|
|
|
|
|
mov [srv.bk], eax
|
|
|
|
|
|
|
|
|
|
;Set base of graphic segment to linear address of LFB
|
|
|
|
|
mov eax, [LFBAddress] ; set for gs
|
|
|
|
|
mov [graph_data_l+2], ax
|
|
|
|
|
shr eax, 16
|
|
|
|
|
mov [graph_data_l+4], al
|
|
|
|
|
mov [graph_data_l+7], ah
|
|
|
|
|
|
2015-01-05 18:59:03 +01:00
|
|
|
|
stdcall kernel_alloc, [_display.win_map_size]
|
|
|
|
|
mov [_display.win_map], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
|
inc eax
|
|
|
|
|
|
|
|
|
|
; set background
|
|
|
|
|
|
|
|
|
|
mov [BgrDrawMode], eax
|
|
|
|
|
mov [BgrDataWidth], eax
|
|
|
|
|
mov [BgrDataHeight], eax
|
|
|
|
|
mov [mem_BACKGROUND], 4
|
|
|
|
|
mov [img_background], static_background_data
|
|
|
|
|
|
2013-11-10 05:10:03 +01:00
|
|
|
|
; set clipboard
|
|
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov [clipboard_slots], eax
|
|
|
|
|
mov [clipboard_write_lock], eax
|
2023-06-25 18:42:10 +02:00
|
|
|
|
stdcall kernel_alloc, PAGE_SIZE
|
2013-11-10 05:10:03 +01:00
|
|
|
|
test eax, eax
|
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
|
|
dec eax
|
|
|
|
|
@@:
|
|
|
|
|
mov [clipboard_main_list], eax
|
|
|
|
|
|
2020-10-21 16:23:51 +02:00
|
|
|
|
call check_acpi
|
|
|
|
|
|
2015-09-03 16:47:08 +02:00
|
|
|
|
mov eax, [hpet_base]
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz @F
|
2022-02-12 18:27:41 +01:00
|
|
|
|
stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL + PAT_UC + PG_SWR
|
2015-09-03 16:47:08 +02:00
|
|
|
|
mov [hpet_base], eax
|
2020-10-21 16:23:51 +02:00
|
|
|
|
mov eax, [eax+HPET_ID]
|
2015-09-03 16:47:08 +02:00
|
|
|
|
DEBUGF 1, "K : HPET caps %x\n", eax
|
2020-10-21 16:23:51 +02:00
|
|
|
|
call init_hpet
|
2015-09-03 16:47:08 +02:00
|
|
|
|
@@:
|
2013-02-28 23:03:45 +01:00
|
|
|
|
; SET UP OS TASK
|
|
|
|
|
|
|
|
|
|
mov esi, boot_setostask
|
|
|
|
|
call boot_log
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov edi, sys_proc + PROC.heap_lock
|
|
|
|
|
mov ecx, (PROC.ht_free - PROC.heap_lock)/4
|
2015-07-22 13:17:45 +02:00
|
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
|
cld
|
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
|
|
mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3
|
|
|
|
|
mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr
|
|
|
|
|
mov ecx, (PROC.pdt_0 - PROC.htab)/4
|
|
|
|
|
add edi, 8
|
|
|
|
|
inc eax
|
|
|
|
|
@@:
|
|
|
|
|
stosd
|
|
|
|
|
inc eax
|
|
|
|
|
cmp eax, ecx
|
|
|
|
|
jbe @B
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov [sys_proc + PROC.pdt_0_phys], sys_proc - OS_BASE + PROC.pdt_0
|
2014-09-18 09:58:56 +02:00
|
|
|
|
|
|
|
|
|
mov eax, -1
|
|
|
|
|
mov edi, thr_slot_map+4
|
|
|
|
|
mov [edi-4], dword 0xFFFFFFF8
|
|
|
|
|
stosd
|
|
|
|
|
stosd
|
|
|
|
|
stosd
|
|
|
|
|
stosd
|
|
|
|
|
stosd
|
|
|
|
|
stosd
|
|
|
|
|
stosd
|
|
|
|
|
|
|
|
|
|
mov [current_process], sys_proc
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov edx, SLOT_BASE + sizeof.APPDATA*1
|
2013-05-27 11:02:35 +02:00
|
|
|
|
mov ebx, [os_stack_seg]
|
2018-05-13 02:16:10 +02:00
|
|
|
|
add ebx, RING0_STACK_SIZE
|
|
|
|
|
add ebx, [xsave_area_size]
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call setup_os_slot
|
|
|
|
|
mov dword [edx], 'IDLE'
|
2022-02-12 18:27:41 +01:00
|
|
|
|
sub [edx + APPDATA.saved_esp], 4
|
|
|
|
|
mov eax, [edx + APPDATA.saved_esp]
|
2013-05-27 11:02:35 +02:00
|
|
|
|
mov dword [eax], idle_thread
|
|
|
|
|
mov ecx, IDLE_PRIORITY
|
|
|
|
|
call scheduler_add_thread
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov edx, SLOT_BASE + sizeof.APPDATA*2
|
2013-05-27 11:02:35 +02:00
|
|
|
|
mov ebx, [os_stack_seg]
|
|
|
|
|
call setup_os_slot
|
|
|
|
|
mov dword [edx], 'OS'
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
call scheduler_add_thread
|
2013-02-28 23:03:45 +01:00
|
|
|
|
|
2021-06-17 11:41:16 +02:00
|
|
|
|
mov dword [current_slot_idx], 2
|
2021-06-16 15:57:17 +02:00
|
|
|
|
mov [thread_count], 2
|
2020-10-12 04:54:44 +02:00
|
|
|
|
mov dword [current_slot], SLOT_BASE + sizeof.APPDATA*2
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2014-08-15 17:46:44 +02:00
|
|
|
|
; Move other CPUs to deep sleep, if it is useful
|
|
|
|
|
uglobal
|
|
|
|
|
use_mwait_for_idle db 0
|
|
|
|
|
endg
|
|
|
|
|
cmp [cpu_vendor+8], 'ntel'
|
|
|
|
|
jnz .no_wake_cpus
|
|
|
|
|
bt [cpu_caps+4], CAPS_MONITOR-32
|
|
|
|
|
jnc .no_wake_cpus
|
|
|
|
|
dbgstr 'using mwait for idle loop'
|
|
|
|
|
inc [use_mwait_for_idle]
|
|
|
|
|
mov ebx, [cpu_count]
|
|
|
|
|
cmp ebx, 1
|
|
|
|
|
jbe .no_wake_cpus
|
|
|
|
|
call create_trampoline_pgmap
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov [cr3_ap + OS_BASE], eax
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov eax, cr4
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov [cr4_ap + OS_BASE], eax
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov esi, OS_BASE + ap_init16
|
|
|
|
|
mov edi, OS_BASE + 8000h
|
|
|
|
|
mov ecx, (ap_init16_size + 3) / 4
|
|
|
|
|
rep movsd
|
2020-10-27 20:32:57 +01:00
|
|
|
|
mov eax, [LAPIC_BASE]
|
|
|
|
|
test eax, eax
|
|
|
|
|
jnz @f
|
2022-02-12 18:27:41 +01:00
|
|
|
|
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL + PG_NOCACHE + PG_SWR
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov [LAPIC_BASE], eax
|
2020-10-27 20:32:57 +01:00
|
|
|
|
@@:
|
2022-02-12 18:27:41 +01:00
|
|
|
|
lea edi, [eax + APIC_ICRL]
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov esi, smpt+4
|
|
|
|
|
dec ebx
|
|
|
|
|
.wake_cpus_loop:
|
|
|
|
|
lodsd
|
2014-08-21 14:41:24 +02:00
|
|
|
|
push esi
|
|
|
|
|
xor esi, esi
|
|
|
|
|
inc esi
|
2014-08-15 17:46:44 +02:00
|
|
|
|
shl eax, 24
|
|
|
|
|
mov [edi+10h], eax
|
|
|
|
|
; assert INIT IPI
|
|
|
|
|
mov dword [edi], 0C500h
|
2014-08-21 14:41:24 +02:00
|
|
|
|
call delay_ms
|
2014-08-15 17:46:44 +02:00
|
|
|
|
@@:
|
|
|
|
|
test dword [edi], 1000h
|
|
|
|
|
jnz @b
|
|
|
|
|
; deassert INIT IPI
|
|
|
|
|
mov dword [edi], 8500h
|
2014-08-21 14:41:24 +02:00
|
|
|
|
call delay_ms
|
2014-08-15 17:46:44 +02:00
|
|
|
|
@@:
|
|
|
|
|
test dword [edi], 1000h
|
|
|
|
|
jnz @b
|
|
|
|
|
; send STARTUP IPI
|
|
|
|
|
mov dword [edi], 600h + (8000h shr 12)
|
2014-08-21 14:41:24 +02:00
|
|
|
|
call delay_ms
|
2014-08-15 17:46:44 +02:00
|
|
|
|
@@:
|
|
|
|
|
test dword [edi], 1000h
|
|
|
|
|
jnz @b
|
2014-08-21 14:41:24 +02:00
|
|
|
|
pop esi
|
2014-08-15 17:46:44 +02:00
|
|
|
|
dec ebx
|
|
|
|
|
jnz .wake_cpus_loop
|
|
|
|
|
mov eax, [cpu_count]
|
|
|
|
|
dec eax
|
|
|
|
|
@@:
|
|
|
|
|
cmp [ap_initialized], eax
|
|
|
|
|
jnz @b
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [cr3_ap + OS_BASE]
|
2014-08-15 17:46:44 +02:00
|
|
|
|
call free_page
|
|
|
|
|
.no_wake_cpus:
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
|
2012-04-21 13:41:37 +02:00
|
|
|
|
mov esi, boot_initirq
|
|
|
|
|
call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call init_irqs
|
2012-04-21 13:41:37 +02:00
|
|
|
|
|
|
|
|
|
mov esi, boot_picinit
|
|
|
|
|
call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call PIC_init
|
|
|
|
|
|
2012-04-21 13:41:37 +02:00
|
|
|
|
mov esi, boot_v86machine
|
|
|
|
|
call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; Initialize system V86 machine
|
|
|
|
|
call init_sys_v86
|
|
|
|
|
|
2012-04-21 13:41:37 +02:00
|
|
|
|
mov esi, boot_inittimer
|
|
|
|
|
call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; Initialize system timer (IRQ0)
|
|
|
|
|
call PIT_init
|
|
|
|
|
|
2013-11-21 17:07:16 +01:00
|
|
|
|
; Register ramdisk file system
|
2020-10-04 18:53:59 +02:00
|
|
|
|
if ~ defined extended_primary_loader
|
2020-10-02 15:05:10 +02:00
|
|
|
|
cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD ; will be loaded later
|
2014-04-05 23:36:10 +02:00
|
|
|
|
je @f
|
2020-10-04 18:53:59 +02:00
|
|
|
|
end if
|
2020-10-02 15:05:10 +02:00
|
|
|
|
cmp [BOOT.rd_load_from], RD_LOAD_FROM_NONE
|
|
|
|
|
je @f
|
|
|
|
|
call register_ramdisk
|
2014-04-05 23:36:10 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2012-04-21 13:41:37 +02:00
|
|
|
|
mov esi, boot_initapic
|
|
|
|
|
call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; Try to Initialize APIC
|
|
|
|
|
call APIC_init
|
|
|
|
|
|
2012-04-21 13:41:37 +02:00
|
|
|
|
mov esi, boot_enableirq
|
|
|
|
|
call boot_log
|
2013-07-09 02:34:01 +02:00
|
|
|
|
; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13)
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; they are used: when partitions are scanned, hd_read relies on timer
|
|
|
|
|
call unmask_timer
|
2020-03-02 05:25:30 +01:00
|
|
|
|
; Prevent duplicate timer IRQs in APIC mode
|
|
|
|
|
cmp [irq_mode], IRQ_APIC
|
|
|
|
|
jz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stdcall enable_irq, 2 ; @#$%! PIC
|
2020-03-02 05:25:30 +01:00
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stdcall enable_irq, 13 ; co-processor
|
2014-04-03 19:56:55 +02:00
|
|
|
|
|
|
|
|
|
; Setup serial output console (if enabled)
|
|
|
|
|
if defined debug_com_base
|
|
|
|
|
|
|
|
|
|
; reserve port so nobody else will use it
|
|
|
|
|
xor ebx, ebx
|
|
|
|
|
mov ecx, debug_com_base
|
|
|
|
|
mov edx, debug_com_base+7
|
|
|
|
|
call r_f_port_area
|
|
|
|
|
|
|
|
|
|
; enable Divisor latch
|
|
|
|
|
mov dx, debug_com_base+3
|
|
|
|
|
mov al, 1 shl 7
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
; Set speed to 115200 baud (max speed)
|
|
|
|
|
mov dx, debug_com_base
|
|
|
|
|
mov al, 0x01
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
mov dx, debug_com_base+1
|
|
|
|
|
mov al, 0x00
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
; No parity, 8bits words, one stop bit, dlab bit back to 0
|
|
|
|
|
mov dx, debug_com_base+3
|
|
|
|
|
mov al, 3
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
; disable interrupts
|
|
|
|
|
mov dx, debug_com_base+1
|
|
|
|
|
mov al, 0
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
; clear + enable fifo (64 bits)
|
|
|
|
|
mov dx, debug_com_base+2
|
|
|
|
|
mov al, 0x7 + 1 shl 5
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
|
2014-02-19 00:01:02 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
; show SVN version of kernel on the message board
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
mov eax, [version_inf.rev]
|
|
|
|
|
DEBUGF 1, "K : kernel SVN r%d\n", eax
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
; show CPU count on the message board
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
mov eax, [cpu_count]
|
|
|
|
|
test eax, eax
|
|
|
|
|
jnz @F
|
|
|
|
|
mov al, 1 ; at least one CPU
|
|
|
|
|
@@:
|
|
|
|
|
DEBUGF 1, "K : %d CPU detected\n", eax
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
; detect Floppy drives
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
mov esi, boot_detectfloppy
|
|
|
|
|
call boot_log
|
|
|
|
|
include 'detect/dev_fd.inc'
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
|
; create pci-devices list
|
2014-02-19 00:01:02 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
|
mov [pci_access_enabled], 1
|
|
|
|
|
call pci_enum
|
2014-02-19 00:01:02 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
|
; initialisation IDE ATA code
|
2014-02-19 00:01:02 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
|
include 'detect/init_ata.inc'
|
2014-02-19 00:01:02 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2021-09-09 13:38:38 +02:00
|
|
|
|
; initialisation AHCI code
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
jmp ahci_code_end
|
|
|
|
|
include 'blkdev/ahci.inc'
|
|
|
|
|
ahci_code_end:
|
|
|
|
|
call ahci_init
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
if 0
|
2020-10-02 15:05:10 +02:00
|
|
|
|
mov ax, [BOOT.sys_disk]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba}
|
|
|
|
|
je no_lib_load
|
2012-04-21 13:41:37 +02:00
|
|
|
|
|
|
|
|
|
mov esi, boot_loadlibs
|
|
|
|
|
call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; LOADING LIBRARES
|
|
|
|
|
stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files)
|
|
|
|
|
call load_file_parse_table ; prepare file parse table
|
|
|
|
|
call set_kernel_conf ; configure devices and gui
|
|
|
|
|
no_lib_load:
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
; Display APIC status
|
|
|
|
|
mov esi, boot_APIC_found
|
|
|
|
|
cmp [irq_mode], IRQ_APIC
|
|
|
|
|
je @f
|
|
|
|
|
mov esi, boot_APIC_nfound
|
|
|
|
|
@@:
|
2012-04-21 13:41:37 +02:00
|
|
|
|
call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; PRINT AMOUNT OF MEMORY
|
|
|
|
|
mov esi, boot_memdetect
|
|
|
|
|
call boot_log
|
|
|
|
|
|
|
|
|
|
movzx ecx, word [boot_y]
|
|
|
|
|
if lang eq ru
|
|
|
|
|
or ecx, (10+30*6) shl 16
|
2013-02-26 19:29:14 +01:00
|
|
|
|
else if lang eq sp
|
|
|
|
|
or ecx, (10+33*6) shl 16
|
|
|
|
|
else
|
2011-10-14 23:38:50 +02:00
|
|
|
|
or ecx, (10+29*6) shl 16
|
2013-02-26 19:29:14 +01:00
|
|
|
|
end if
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sub ecx, 10
|
|
|
|
|
mov edx, 0xFFFFFF
|
|
|
|
|
mov ebx, [MEM_AMOUNT]
|
|
|
|
|
shr ebx, 20
|
|
|
|
|
xor edi, edi
|
|
|
|
|
mov eax, 0x00040000
|
|
|
|
|
inc edi
|
|
|
|
|
call display_number_force
|
|
|
|
|
|
|
|
|
|
; BUILD SCHEDULER
|
|
|
|
|
|
2012-04-21 13:41:37 +02:00
|
|
|
|
; call build_scheduler; sys32.inc
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2012-04-21 13:41:37 +02:00
|
|
|
|
; mov esi, boot_devices
|
|
|
|
|
; call boot_log
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2013-11-26 20:35:00 +01:00
|
|
|
|
include "detect/vortex86.inc" ; Vortex86 SoC detection code
|
|
|
|
|
|
2014-08-18 13:18:15 +02:00
|
|
|
|
stdcall load_pe_driver, szVidintel, 0
|
2013-05-15 20:03:17 +02:00
|
|
|
|
|
2013-05-18 01:53:28 +02:00
|
|
|
|
call usb_init
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; SET PRELIMINARY WINDOW STACK AND POSITIONS
|
|
|
|
|
|
|
|
|
|
mov esi, boot_windefs
|
|
|
|
|
call boot_log
|
|
|
|
|
call set_window_defaults
|
|
|
|
|
|
|
|
|
|
; SET BACKGROUND DEFAULTS
|
|
|
|
|
|
|
|
|
|
mov esi, boot_bgr
|
|
|
|
|
call boot_log
|
|
|
|
|
call init_background
|
|
|
|
|
call calculatebackground
|
|
|
|
|
|
|
|
|
|
; RESERVE SYSTEM IRQ'S JA PORT'S
|
|
|
|
|
|
|
|
|
|
mov esi, boot_resirqports
|
|
|
|
|
call boot_log
|
|
|
|
|
call reserve_irqs_ports
|
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [SLOT_BASE + APPDATA.window], window_data
|
|
|
|
|
mov [SLOT_BASE + sizeof.APPDATA + APPDATA.window], window_data + sizeof.WDATA
|
|
|
|
|
mov [SLOT_BASE + sizeof.APPDATA*2 + APPDATA.window], window_data + sizeof.WDATA*2
|
|
|
|
|
mov [window_data + WDATA.thread], SLOT_BASE
|
|
|
|
|
mov [window_data + sizeof.WDATA + WDATA.thread], SLOT_BASE + sizeof.APPDATA
|
|
|
|
|
mov [window_data + sizeof.WDATA*2 + WDATA.thread], SLOT_BASE + sizeof.APPDATA*2
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call init_display
|
|
|
|
|
mov eax, [def_cursor]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [window_data + sizeof.WDATA + WDATA.cursor], eax
|
|
|
|
|
mov [window_data + sizeof.WDATA*2 + WDATA.cursor], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2013-05-11 20:01:06 +02:00
|
|
|
|
; PRINT CPU FREQUENCY
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2013-05-11 20:01:06 +02:00
|
|
|
|
mov esi, boot_cpufreq
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call boot_log
|
2013-05-11 20:01:06 +02:00
|
|
|
|
|
2015-09-04 17:20:25 +02:00
|
|
|
|
cli
|
|
|
|
|
mov ebx, [hpet_base]
|
|
|
|
|
test ebx, ebx
|
|
|
|
|
jz @F
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov ebx, [ebx + HPET_COUNTER]
|
2015-09-04 17:20:25 +02:00
|
|
|
|
|
|
|
|
|
rdtsc
|
|
|
|
|
mov ecx, 1000
|
|
|
|
|
sub eax, [hpet_tsc_start]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
sbb edx, [hpet_tsc_start + 4]
|
2015-09-04 17:20:25 +02:00
|
|
|
|
shld edx, eax, 10
|
|
|
|
|
shl eax, 10
|
|
|
|
|
mov esi, eax
|
|
|
|
|
mov eax, edx
|
|
|
|
|
mul ecx
|
|
|
|
|
xchg eax, esi
|
|
|
|
|
mul ecx
|
|
|
|
|
adc edx, esi
|
|
|
|
|
div ebx
|
|
|
|
|
mul ecx
|
|
|
|
|
div [hpet_period]
|
|
|
|
|
mul ecx
|
|
|
|
|
DEBUGF 1, "K : cpu frequency %u Hz\n", eax
|
|
|
|
|
jmp .next
|
|
|
|
|
@@:
|
2013-05-11 20:01:06 +02:00
|
|
|
|
rdtsc
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ecx, eax
|
|
|
|
|
mov esi, 250 ; wait 1/4 a second
|
|
|
|
|
call delay_ms
|
2013-05-11 20:01:06 +02:00
|
|
|
|
rdtsc
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sub eax, ecx
|
2013-04-26 12:57:25 +02:00
|
|
|
|
xor edx, edx
|
|
|
|
|
shld edx, eax, 2
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shl eax, 2
|
2015-09-04 17:20:25 +02:00
|
|
|
|
.next:
|
2013-04-26 12:57:25 +02:00
|
|
|
|
mov dword [cpu_freq], eax
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov dword [cpu_freq + 4], edx
|
2013-05-11 22:53:01 +02:00
|
|
|
|
mov ebx, 1000000
|
|
|
|
|
div ebx
|
2013-05-11 20:01:06 +02:00
|
|
|
|
mov ebx, eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
movzx ecx, word [boot_y]
|
|
|
|
|
if lang eq ru
|
2013-05-11 20:01:06 +02:00
|
|
|
|
add ecx, (10+19*6) shl 16 - 10
|
2013-02-26 19:29:14 +01:00
|
|
|
|
else if lang eq sp
|
2013-05-11 20:01:06 +02:00
|
|
|
|
add ecx, (10+25*6) shl 16 - 10
|
2013-02-26 19:29:14 +01:00
|
|
|
|
else
|
2013-05-11 20:01:06 +02:00
|
|
|
|
add ecx, (10+17*6) shl 16 - 10
|
2013-02-26 19:29:14 +01:00
|
|
|
|
end if
|
2013-05-11 20:01:06 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov edx, 0xFFFFFF
|
|
|
|
|
xor edi, edi
|
|
|
|
|
mov eax, 0x00040000
|
|
|
|
|
inc edi
|
|
|
|
|
call display_number_force
|
|
|
|
|
|
|
|
|
|
; SET VARIABLES
|
|
|
|
|
|
|
|
|
|
call set_variables
|
|
|
|
|
|
|
|
|
|
; STACK AND FDC
|
|
|
|
|
|
|
|
|
|
call stack_init
|
|
|
|
|
call fdc_init
|
|
|
|
|
|
|
|
|
|
; PALETTE FOR 320x200 and 640x480 16 col
|
|
|
|
|
|
|
|
|
|
cmp [SCR_MODE], word 0x12
|
|
|
|
|
jne no_pal_vga
|
|
|
|
|
mov esi, boot_pal_vga
|
|
|
|
|
call boot_log
|
|
|
|
|
call paletteVGA
|
|
|
|
|
no_pal_vga:
|
|
|
|
|
|
|
|
|
|
cmp [SCR_MODE], word 0x13
|
|
|
|
|
jne no_pal_ega
|
|
|
|
|
mov esi, boot_pal_ega
|
|
|
|
|
call boot_log
|
|
|
|
|
call palette320x200
|
|
|
|
|
no_pal_ega:
|
|
|
|
|
|
|
|
|
|
; LOAD DEFAULT SKIN
|
|
|
|
|
|
|
|
|
|
call load_default_skin
|
|
|
|
|
|
2015-07-31 15:32:01 +02:00
|
|
|
|
; Protect I/O permission map
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov esi, [default_io_map]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add esi, 0x1000
|
2022-02-12 18:27:41 +01:00
|
|
|
|
stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
stdcall map_page, tss._io_map_0, \
|
2022-02-12 18:27:41 +01:00
|
|
|
|
[SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stdcall map_page, tss._io_map_1, \
|
2022-02-12 18:27:41 +01:00
|
|
|
|
[SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; SET KEYBOARD PARAMETERS
|
|
|
|
|
mov al, 0xf6 ; reset keyboard, scan enabled
|
2014-07-29 12:41:27 +02:00
|
|
|
|
call kb_write_wait_ack
|
2012-04-11 21:06:32 +02:00
|
|
|
|
test ah, ah
|
|
|
|
|
jnz .no_keyboard
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2012-04-11 21:06:32 +02:00
|
|
|
|
iglobal
|
|
|
|
|
align 4
|
|
|
|
|
ps2_keyboard_functions:
|
|
|
|
|
dd .end - $
|
|
|
|
|
dd 0 ; no close
|
|
|
|
|
dd ps2_set_lights
|
|
|
|
|
.end:
|
|
|
|
|
endg
|
|
|
|
|
stdcall register_keyboard, ps2_keyboard_functions, 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; mov al, 0xED ; Keyboard LEDs - only for testing!
|
2014-07-29 12:41:27 +02:00
|
|
|
|
; call kb_write_wait_ack
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; mov al, 111b
|
2014-07-29 12:41:27 +02:00
|
|
|
|
; call kb_write_wait_ack
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov al, 0xF3 ; set repeat rate & delay
|
2014-07-29 12:41:27 +02:00
|
|
|
|
call kb_write_wait_ack
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500
|
2014-07-29 12:41:27 +02:00
|
|
|
|
call kb_write_wait_ack
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;// mike.dld [
|
|
|
|
|
call set_lights
|
|
|
|
|
;// mike.dld ]
|
|
|
|
|
stdcall attach_int_handler, 1, irq1, 0
|
2014-04-02 22:55:06 +02:00
|
|
|
|
DEBUGF 1, "K : IRQ1 return code %x\n", eax
|
2012-04-11 21:06:32 +02:00
|
|
|
|
.no_keyboard:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2014-02-01 15:22:21 +01:00
|
|
|
|
; Load PS/2 mouse driver
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov esi, boot_setmouse
|
|
|
|
|
call boot_log
|
2021-12-28 16:19:24 +01:00
|
|
|
|
stdcall load_pe_driver, szPS2MDriver, 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2014-08-14 14:17:53 +02:00
|
|
|
|
; LOAD FIRST APPLICATION
|
|
|
|
|
cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes)
|
|
|
|
|
jnz first_app_found
|
|
|
|
|
|
|
|
|
|
cli
|
|
|
|
|
mov ebp, firstapp
|
|
|
|
|
call fs_execute_from_sysdir
|
|
|
|
|
test eax, eax
|
|
|
|
|
jns first_app_found
|
|
|
|
|
|
|
|
|
|
mov esi, boot_failed
|
|
|
|
|
call boot_log
|
|
|
|
|
|
|
|
|
|
mov eax, 0xDEADBEEF ; otherwise halt
|
|
|
|
|
hlt
|
|
|
|
|
|
|
|
|
|
first_app_found:
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; START MULTITASKING
|
2017-12-16 21:21:10 +01:00
|
|
|
|
preboot_blogesc = 0 ; start immediately after bootlog
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; A 'All set - press ESC to start' messages if need
|
|
|
|
|
if preboot_blogesc
|
|
|
|
|
mov esi, boot_tasking
|
|
|
|
|
call boot_log
|
|
|
|
|
.bll1:
|
|
|
|
|
in al, 0x60 ; wait for ESC key press
|
|
|
|
|
cmp al, 129
|
|
|
|
|
jne .bll1
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
mov [timer_ticks_enable], 1 ; for cd driver
|
|
|
|
|
sti
|
2014-03-04 14:58:20 +01:00
|
|
|
|
|
2014-04-02 22:55:06 +02:00
|
|
|
|
call mtrr_validate
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
jmp osloop
|
|
|
|
|
; Fly :)
|
|
|
|
|
|
2014-08-15 17:46:44 +02:00
|
|
|
|
uglobal
|
|
|
|
|
align 4
|
|
|
|
|
ap_initialized dd 0
|
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
ap_init_high:
|
|
|
|
|
mov ax, os_stack
|
|
|
|
|
mov bx, app_data
|
|
|
|
|
mov cx, app_tls
|
|
|
|
|
mov ss, ax
|
|
|
|
|
mov ds, bx
|
|
|
|
|
mov es, bx
|
|
|
|
|
mov fs, cx
|
|
|
|
|
mov gs, bx
|
|
|
|
|
xor esp, esp
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, sys_proc - OS_BASE + PROC.pdt_0
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov cr3, eax
|
|
|
|
|
lock inc [ap_initialized]
|
|
|
|
|
jmp idle_loop
|
|
|
|
|
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
include 'unpacker.inc'
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
boot_log:
|
|
|
|
|
pushad
|
|
|
|
|
|
|
|
|
|
mov ebx, 10*65536
|
|
|
|
|
mov bx, word [boot_y]
|
|
|
|
|
add [boot_y], dword 10
|
|
|
|
|
mov ecx, 0x80ffffff; ASCIIZ string with white color
|
|
|
|
|
xor edi, edi
|
|
|
|
|
mov edx, esi
|
|
|
|
|
inc edi
|
|
|
|
|
call dtext
|
|
|
|
|
|
|
|
|
|
mov [novesachecksum], 1000
|
|
|
|
|
call checkVga_N13
|
|
|
|
|
|
|
|
|
|
popad
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
2020-10-04 18:53:59 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
; Register ramdisk file system
|
|
|
|
|
register_ramdisk:
|
|
|
|
|
mov esi, boot_initramdisk
|
|
|
|
|
call boot_log
|
|
|
|
|
call ramdisk_init
|
|
|
|
|
ret
|
|
|
|
|
|
2013-05-27 11:02:35 +02:00
|
|
|
|
; in: edx -> APPDATA for OS/IDLE slot
|
|
|
|
|
; in: ebx = stack base
|
|
|
|
|
proc setup_os_slot
|
|
|
|
|
xor eax, eax
|
2020-10-12 04:54:44 +02:00
|
|
|
|
mov ecx, sizeof.APPDATA/4
|
2013-05-27 11:02:35 +02:00
|
|
|
|
mov edi, edx
|
|
|
|
|
rep stosd
|
|
|
|
|
|
2013-05-27 15:05:53 +02:00
|
|
|
|
mov eax, tss+0x80
|
|
|
|
|
call get_pg_addr
|
|
|
|
|
inc eax
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov [edx + APPDATA.io_map], eax
|
2013-05-27 15:05:53 +02:00
|
|
|
|
mov eax, tss+0x1080
|
|
|
|
|
call get_pg_addr
|
|
|
|
|
inc eax
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov [edx + APPDATA.io_map + 4], eax
|
2013-05-27 15:05:53 +02:00
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov dword [edx + APPDATA.pl0_stack], ebx
|
|
|
|
|
lea edi, [ebx + RING0_STACK_SIZE]
|
|
|
|
|
mov dword [edx + APPDATA.fpu_state], edi
|
|
|
|
|
mov dword [edx + APPDATA.saved_esp0], edi
|
|
|
|
|
mov dword [edx + APPDATA.saved_esp], edi
|
|
|
|
|
mov dword [edx + APPDATA.terminate_protection], 1 ; make unkillable
|
2013-05-27 11:02:35 +02:00
|
|
|
|
|
|
|
|
|
mov esi, fpu_data
|
2018-02-19 17:35:45 +01:00
|
|
|
|
mov ecx, [xsave_area_size]
|
|
|
|
|
add ecx, 3
|
|
|
|
|
shr ecx, 2
|
2013-05-27 11:02:35 +02:00
|
|
|
|
rep movsd
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
lea eax, [edx + APP_EV_OFFSET]
|
|
|
|
|
mov dword [edx + APPDATA.fd_ev], eax
|
|
|
|
|
mov dword [edx + APPDATA.bk_ev], eax
|
2020-10-02 14:30:11 +02:00
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
lea eax, [edx + APP_OBJ_OFFSET]
|
|
|
|
|
mov dword [edx + APPDATA.fd_obj], eax
|
|
|
|
|
mov dword [edx + APPDATA.bk_obj], eax
|
2013-05-27 11:02:35 +02:00
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov dword [edx + APPDATA.cur_dir], sysdir_path-2
|
2013-05-27 11:02:35 +02:00
|
|
|
|
|
2014-09-18 09:58:56 +02:00
|
|
|
|
mov [edx + APPDATA.process], sys_proc
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
lea ebx, [edx + APPDATA.list]
|
|
|
|
|
lea ecx, [sys_proc + PROC.thr_list]
|
2014-09-18 09:58:56 +02:00
|
|
|
|
list_add_tail ebx, ecx
|
2013-05-27 11:02:35 +02:00
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov [edx + APPDATA.wnd_number], dh
|
|
|
|
|
mov byte [edx + APPDATA.tid], dh
|
2023-08-18 22:51:33 +02:00
|
|
|
|
movzx eax, dh
|
|
|
|
|
shl eax, BSF sizeof.WDATA
|
|
|
|
|
add eax, window_data
|
|
|
|
|
mov [edx + APPDATA.window], eax
|
2013-05-27 11:02:35 +02:00
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; ;
|
|
|
|
|
; MAIN OS LOOP START ;
|
|
|
|
|
; ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
align 32
|
|
|
|
|
osloop:
|
2013-05-27 11:02:35 +02:00
|
|
|
|
mov edx, osloop_has_work?
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
call Wait_events
|
|
|
|
|
xor eax, eax
|
|
|
|
|
xchg eax, [osloop_nonperiodic_work]
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .no_periodic
|
2014-04-02 22:55:06 +02:00
|
|
|
|
|
2012-03-12 19:26:37 +01:00
|
|
|
|
call __sys_draw_pointer
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call window_check_events
|
|
|
|
|
call mouse_check_events
|
|
|
|
|
call checkmisc
|
|
|
|
|
call checkVga_N13
|
2014-04-02 22:55:06 +02:00
|
|
|
|
;--------------------------------------
|
2013-05-27 11:02:35 +02:00
|
|
|
|
.no_periodic:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call stack_handler
|
|
|
|
|
call check_fdd_motor_status
|
|
|
|
|
call check_ATAPI_device_event
|
2012-04-11 21:06:32 +02:00
|
|
|
|
call check_lights_state
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call check_timers
|
2014-04-02 22:55:06 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jmp osloop
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; ;
|
|
|
|
|
; MAIN OS LOOP END ;
|
|
|
|
|
; ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2013-05-27 11:02:35 +02:00
|
|
|
|
proc osloop_has_work?
|
|
|
|
|
cmp [osloop_nonperiodic_work], 0
|
|
|
|
|
jnz .yes
|
|
|
|
|
call stack_handler_has_work?
|
|
|
|
|
jnz .yes
|
2013-11-21 17:07:16 +01:00
|
|
|
|
call check_fdd_motor_status_has_work?
|
|
|
|
|
jnz .yes
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call check_ATAPI_device_event_has_work?
|
|
|
|
|
jnz .yes
|
|
|
|
|
call check_lights_state_has_work?
|
|
|
|
|
jnz .yes
|
|
|
|
|
call check_timers_has_work?
|
|
|
|
|
jnz .yes
|
|
|
|
|
.no:
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
|
|
|
|
.yes:
|
|
|
|
|
xor eax, eax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
proc wakeup_osloop
|
|
|
|
|
mov [osloop_nonperiodic_work], 1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2013-05-27 11:02:35 +02:00
|
|
|
|
endp
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
uglobal
|
2013-05-27 11:02:35 +02:00
|
|
|
|
align 4
|
|
|
|
|
osloop_nonperiodic_work dd ?
|
2011-10-14 23:38:50 +02:00
|
|
|
|
endg
|
|
|
|
|
|
2014-08-15 17:46:44 +02:00
|
|
|
|
uglobal
|
|
|
|
|
align 64
|
|
|
|
|
idle_addr rb 64
|
|
|
|
|
endg
|
|
|
|
|
|
2013-05-27 11:02:35 +02:00
|
|
|
|
idle_thread:
|
|
|
|
|
sti
|
2014-08-15 17:46:44 +02:00
|
|
|
|
|
|
|
|
|
; The following code can be executed by all CPUs in the system.
|
|
|
|
|
; All other parts of the kernel do not expect multi-CPU.
|
|
|
|
|
; Also, APs don't even have a stack here.
|
|
|
|
|
; Beware. Don't do anything here. Anything at all.
|
2013-05-27 11:02:35 +02:00
|
|
|
|
idle_loop:
|
2014-08-15 17:46:44 +02:00
|
|
|
|
cmp [use_mwait_for_idle], 0
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jnz .mwait
|
2014-08-15 17:46:44 +02:00
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.hlt:
|
2013-05-27 11:02:35 +02:00
|
|
|
|
hlt
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jmp .hlt
|
2013-05-27 11:02:35 +02:00
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.mwait:
|
2014-08-15 17:46:44 +02:00
|
|
|
|
mov eax, idle_addr
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor edx, edx
|
|
|
|
|
monitor
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
mov eax, 20h ; or 10h
|
|
|
|
|
mwait
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jmp .mwait
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; ;
|
|
|
|
|
; INCLUDED SYSTEM FILES ;
|
|
|
|
|
; ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
include "kernel32.inc"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
; ;
|
|
|
|
|
; KERNEL FUNCTIONS ;
|
|
|
|
|
; ;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
reserve_irqs_ports:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; RESERVE PORTS
|
|
|
|
|
mov eax, RESERVED_PORTS
|
|
|
|
|
mov ecx, 1
|
|
|
|
|
|
|
|
|
|
mov [eax], dword 4
|
|
|
|
|
|
|
|
|
|
mov [eax+16], ecx
|
|
|
|
|
mov [eax+16+4], dword 0
|
2013-03-26 21:10:37 +01:00
|
|
|
|
mov [eax+16+8], dword 0x2D
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov [eax+32], ecx
|
|
|
|
|
mov [eax+32+4], dword 0x30
|
|
|
|
|
mov [eax+32+8], dword 0x4D
|
|
|
|
|
|
|
|
|
|
mov [eax+48], ecx
|
|
|
|
|
mov [eax+48+4], dword 0x50
|
2013-03-26 21:10:37 +01:00
|
|
|
|
mov [eax+48+8], dword 0xDF
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov [eax+64], ecx
|
|
|
|
|
mov [eax+64+4], dword 0xE5
|
|
|
|
|
mov [eax+64+8], dword 0xFF
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iglobal
|
2013-05-27 11:02:35 +02:00
|
|
|
|
process_number dd 0x2
|
2011-10-14 23:38:50 +02:00
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
set_variables:
|
|
|
|
|
|
|
|
|
|
mov ecx, 0x16 ; flush port 0x60
|
2023-04-09 20:19:13 +02:00
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
in al, 0x60
|
2023-04-09 20:19:13 +02:00
|
|
|
|
loop @b
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push eax
|
|
|
|
|
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov ax, [BOOT.y_res]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr ax, 1
|
|
|
|
|
shl eax, 16
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov ax, [BOOT.x_res]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr ax, 1
|
|
|
|
|
mov [MOUSE_X], eax
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov [BTN_ADDR], dword BUTTON_INFO ; address of button list
|
|
|
|
|
|
|
|
|
|
mov byte [KEY_COUNT], al ; keyboard buffer
|
|
|
|
|
mov byte [BTN_COUNT], al ; button buffer
|
|
|
|
|
|
|
|
|
|
pop eax
|
|
|
|
|
ret
|
2021-12-27 16:42:05 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
display_number:
|
2021-05-09 15:27:00 +02:00
|
|
|
|
; add check pointers
|
|
|
|
|
test bl, bl
|
|
|
|
|
jz @f
|
2023-04-08 23:24:05 +02:00
|
|
|
|
bt ebx, 30 ; check 30 bit
|
|
|
|
|
jb @f
|
|
|
|
|
stdcall is_region_userspace, ecx, 4
|
|
|
|
|
jz @f
|
|
|
|
|
ret
|
|
|
|
|
@@:
|
|
|
|
|
jz @f
|
|
|
|
|
stdcall is_region_userspace, ecx, 8
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jz @f
|
2021-05-09 15:27:00 +02:00
|
|
|
|
ret
|
|
|
|
|
@@:
|
|
|
|
|
test esi, 0x08000000
|
|
|
|
|
jz @f
|
|
|
|
|
stdcall is_region_userspace, edi, 1
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jz @f
|
2021-05-09 15:27:00 +02:00
|
|
|
|
ret
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;It is not optimization
|
|
|
|
|
mov eax, ebx
|
|
|
|
|
mov ebx, ecx
|
|
|
|
|
mov ecx, edx
|
|
|
|
|
mov edx, esi
|
|
|
|
|
mov esi, edi
|
|
|
|
|
; eax = print type, al=0 -> ebx is number
|
|
|
|
|
; al=1 -> ebx is pointer
|
|
|
|
|
; ah=0 -> display decimal
|
|
|
|
|
; ah=1 -> display hexadecimal
|
|
|
|
|
; ah=2 -> display binary
|
|
|
|
|
; eax bits 16-21 = number of digits to display (0-32)
|
|
|
|
|
; eax bits 22-31 = reserved
|
|
|
|
|
;
|
|
|
|
|
; ebx = number or pointer
|
|
|
|
|
; ecx = x shl 16 + y
|
|
|
|
|
; edx = color
|
|
|
|
|
xor edi, edi
|
|
|
|
|
display_number_force:
|
|
|
|
|
push eax
|
|
|
|
|
and eax, 0x3fffffff
|
|
|
|
|
cmp eax, 0xffff ; length > 0 ?
|
|
|
|
|
pop eax
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jge .cont_displ
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.cont_displ:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push eax
|
|
|
|
|
and eax, 0x3fffffff
|
|
|
|
|
cmp eax, 61*0x10000 ; length <= 60 ?
|
|
|
|
|
pop eax
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jb .cont_displ2
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.cont_displ2:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
pushad
|
|
|
|
|
|
|
|
|
|
cmp al, 1 ; ecx is a pointer ?
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jne @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebp, ebx
|
|
|
|
|
add ebp, 4
|
2023-04-09 20:19:13 +02:00
|
|
|
|
mov ebp, [ebp] ;[ebp + std_application_base_address]
|
|
|
|
|
mov ebx, [ebx] ;[ebx + std_application_base_address]
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sub esp, 64
|
|
|
|
|
|
|
|
|
|
test ah, ah ; DECIMAL
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jnz .no_display_desnum
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr eax, 16
|
|
|
|
|
and eax, 0xC03f
|
|
|
|
|
; and eax,0x3f
|
|
|
|
|
push eax
|
|
|
|
|
and eax, 0x3f
|
|
|
|
|
mov edi, esp
|
|
|
|
|
add edi, 4+64-1
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
mov eax, ebx
|
|
|
|
|
mov ebx, 10
|
2023-04-09 20:19:13 +02:00
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor edx, edx
|
|
|
|
|
call division_64_bits
|
|
|
|
|
div ebx
|
|
|
|
|
add dl, 48
|
|
|
|
|
mov [edi], dl
|
|
|
|
|
dec edi
|
2023-04-09 20:19:13 +02:00
|
|
|
|
loop @b
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop eax
|
|
|
|
|
call normalize_number
|
|
|
|
|
call draw_num_text
|
|
|
|
|
add esp, 64
|
|
|
|
|
popad
|
|
|
|
|
ret
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.no_display_desnum:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
cmp ah, 0x01 ; HEXADECIMAL
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jne .no_display_hexnum
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr eax, 16
|
|
|
|
|
and eax, 0xC03f
|
|
|
|
|
; and eax,0x3f
|
|
|
|
|
push eax
|
|
|
|
|
and eax, 0x3f
|
|
|
|
|
mov edi, esp
|
|
|
|
|
add edi, 4+64-1
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
mov eax, ebx
|
|
|
|
|
mov ebx, 16
|
2023-04-09 20:19:13 +02:00
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor edx, edx
|
|
|
|
|
call division_64_bits
|
|
|
|
|
div ebx
|
2023-04-09 20:19:13 +02:00
|
|
|
|
;hexletters = __fdo_hexdigits
|
|
|
|
|
add edx, __fdo_hexdigits ;hexletters
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov dl, [edx]
|
|
|
|
|
mov [edi], dl
|
|
|
|
|
dec edi
|
2023-04-09 20:19:13 +02:00
|
|
|
|
loop @b
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop eax
|
|
|
|
|
call normalize_number
|
|
|
|
|
call draw_num_text
|
|
|
|
|
add esp, 64
|
|
|
|
|
popad
|
|
|
|
|
ret
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.no_display_hexnum:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
cmp ah, 0x02 ; BINARY
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jne .no_display_binnum
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr eax, 16
|
|
|
|
|
and eax, 0xC03f
|
|
|
|
|
; and eax,0x3f
|
|
|
|
|
push eax
|
|
|
|
|
and eax, 0x3f
|
|
|
|
|
mov edi, esp
|
|
|
|
|
add edi, 4+64-1
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
mov eax, ebx
|
|
|
|
|
mov ebx, 2
|
2023-04-09 20:19:13 +02:00
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor edx, edx
|
|
|
|
|
call division_64_bits
|
|
|
|
|
div ebx
|
|
|
|
|
add dl, 48
|
|
|
|
|
mov [edi], dl
|
|
|
|
|
dec edi
|
2023-04-09 20:19:13 +02:00
|
|
|
|
loop @b
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop eax
|
|
|
|
|
call normalize_number
|
|
|
|
|
call draw_num_text
|
|
|
|
|
add esp, 64
|
|
|
|
|
popad
|
|
|
|
|
ret
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.no_display_binnum:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
add esp, 64
|
|
|
|
|
popad
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
normalize_number:
|
|
|
|
|
test ah, 0x80
|
|
|
|
|
jz .continue
|
|
|
|
|
mov ecx, 48
|
|
|
|
|
and eax, 0x3f
|
|
|
|
|
@@:
|
|
|
|
|
inc edi
|
|
|
|
|
cmp [edi], cl
|
|
|
|
|
jne .continue
|
|
|
|
|
dec eax
|
|
|
|
|
cmp eax, 1
|
|
|
|
|
ja @r
|
|
|
|
|
mov al, 1
|
|
|
|
|
.continue:
|
|
|
|
|
and eax, 0x3f
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
division_64_bits:
|
|
|
|
|
test [esp+1+4], byte 0x40
|
|
|
|
|
jz .continue
|
|
|
|
|
push eax
|
|
|
|
|
mov eax, ebp
|
|
|
|
|
div ebx
|
|
|
|
|
mov ebp, eax
|
|
|
|
|
pop eax
|
|
|
|
|
.continue:
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
draw_num_text:
|
|
|
|
|
mov esi, eax
|
|
|
|
|
mov edx, 64+4
|
|
|
|
|
sub edx, eax
|
|
|
|
|
add edx, esp
|
|
|
|
|
mov ebx, [esp+64+32-8+4]
|
|
|
|
|
; add window start x & y
|
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov ecx, [current_slot]
|
|
|
|
|
mov ecx, [ecx + APPDATA.window]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov eax, [ecx + WDATA.box.left]
|
|
|
|
|
add eax, [ecx + WDATA.clientbox.left]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shl eax, 16
|
2023-08-18 22:51:33 +02:00
|
|
|
|
add eax, [ecx + WDATA.box.top]
|
|
|
|
|
add eax, [ecx + WDATA.clientbox.top]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add ebx, eax
|
|
|
|
|
mov ecx, [esp+64+32-12+4]
|
|
|
|
|
mov eax, [esp+64+8] ; background color (if given)
|
|
|
|
|
mov edi, [esp+64+4]
|
2016-02-21 01:05:15 +01:00
|
|
|
|
and ecx, 5FFFFFFFh
|
|
|
|
|
bt ecx, 27
|
|
|
|
|
jnc @f
|
|
|
|
|
mov edi, eax
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jmp dtext
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
sys_setup:
|
2014-03-27 21:44:32 +01:00
|
|
|
|
; 1 = roland mpu midi base , base io address
|
|
|
|
|
; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
|
|
|
|
|
; 3 = not used
|
|
|
|
|
; 4 = not used
|
|
|
|
|
; 5 = system language, 1eng 2fi 3ger 4rus
|
|
|
|
|
; 6 = not used
|
|
|
|
|
; 7 = not used
|
|
|
|
|
; 8 = not used
|
|
|
|
|
; 9 = not used
|
|
|
|
|
; 10 = not used
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; 11 = enable lba read
|
|
|
|
|
; 12 = enable pci access
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2022-06-05 16:41:51 +02:00
|
|
|
|
and [esp + SYSCALL_STACK.eax], dword 0
|
2014-03-27 21:44:32 +01:00
|
|
|
|
; F.21.1 - set MPU MIDI base port
|
|
|
|
|
dec ebx
|
|
|
|
|
jnz @f
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ecx, 0x100
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jb @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov esi, 65535
|
|
|
|
|
cmp esi, ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jb @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
|
mov [midi_base], cx
|
|
|
|
|
mov word [mididp], cx
|
|
|
|
|
inc cx
|
|
|
|
|
mov word [midisp], cx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.21.2 - set keyboard layout
|
|
|
|
|
dec ebx
|
|
|
|
|
jnz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2022-02-09 19:09:54 +01:00
|
|
|
|
mov eax, edx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
; 1 = normal layout
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .shift
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, keymap
|
|
|
|
|
mov ecx, 128
|
|
|
|
|
call memmove
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.shift:
|
|
|
|
|
; 2 = layout at pressed Shift
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .alt
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov ebx, keymap_shift
|
|
|
|
|
mov ecx, 128
|
|
|
|
|
call memmove
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.alt:
|
|
|
|
|
; 3 = layout at pressed Alt
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .country
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, keymap_alt
|
|
|
|
|
mov ecx, 128
|
|
|
|
|
call memmove
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.country:
|
|
|
|
|
; country identifier
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sub ecx, 6
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .error
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2014-03-27 21:44:32 +01:00
|
|
|
|
mov word [keyboard], dx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.21.5 - set system language
|
|
|
|
|
sub ebx, 3
|
|
|
|
|
jnz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov [syslang], ecx
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.21.11 - enable/disable low-level access to HD
|
2011-10-14 23:38:50 +02:00
|
|
|
|
and ecx, 1
|
2014-03-27 21:44:32 +01:00
|
|
|
|
sub ebx, 6
|
|
|
|
|
jnz @f
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [lba_read_enabled], ecx
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.21.12 - enable/disable low-level access to PCI
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ebx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .error
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [pci_access_enabled], ecx
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.error:
|
2022-06-05 16:41:51 +02:00
|
|
|
|
or [esp + SYSCALL_STACK.eax], dword -1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
sys_getsetup:
|
2014-03-27 21:44:32 +01:00
|
|
|
|
; 1 = roland mpu midi base , base io address
|
|
|
|
|
; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
|
|
|
|
|
; 3 = not used
|
|
|
|
|
; 4 = not used
|
|
|
|
|
; 5 = system language, 1eng 2fi 3ger 4rus
|
|
|
|
|
; 6 = not used
|
|
|
|
|
; 7 = not used
|
|
|
|
|
; 8 = not used
|
|
|
|
|
; 9 = get hs timer tic
|
|
|
|
|
; 10 = not used
|
|
|
|
|
; 11 = get the state "lba read"
|
|
|
|
|
; 12 = get the state "pci access"
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
; F.26.1 - get MPU MIDI base port
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ebx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz @f
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movzx eax, [midi_base]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.26.2 - get keyboard layout
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ebx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2022-02-09 19:09:54 +01:00
|
|
|
|
mov ebx, edx
|
2020-11-07 17:42:34 +01:00
|
|
|
|
; if given memory address belongs to kernel then error
|
2020-12-05 20:56:25 +01:00
|
|
|
|
stdcall is_region_userspace, ebx, 128
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jnz .addr_error
|
2022-02-09 19:09:54 +01:00
|
|
|
|
; 1 = normal layout
|
|
|
|
|
dec ecx
|
|
|
|
|
jnz .shift
|
2020-11-07 00:15:44 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, keymap
|
|
|
|
|
mov ecx, 128
|
|
|
|
|
call memmove
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.shift:
|
|
|
|
|
; 2 = layout with pressed Shift
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .alt
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, keymap_shift
|
|
|
|
|
mov ecx, 128
|
|
|
|
|
call memmove
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.alt:
|
|
|
|
|
; 3 = layout with pressed Alt
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ecx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jne .country
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, keymap_alt
|
|
|
|
|
mov ecx, 128
|
|
|
|
|
call memmove
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.country:
|
|
|
|
|
; 9 = country identifier
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sub ecx, 6
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .error
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movzx eax, word [keyboard]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2020-11-07 00:15:44 +01:00
|
|
|
|
|
|
|
|
|
.addr_error: ; if given memory address is illegal
|
2022-06-05 16:41:51 +02:00
|
|
|
|
or dword [esp + SYSCALL_STACK.eax], -1
|
2023-10-01 23:53:34 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.26.5 - get system language
|
|
|
|
|
sub ebx, 3
|
|
|
|
|
jnz @f
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, [syslang]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.26.9 - get the value of the time counter
|
2014-02-18 19:21:49 +01:00
|
|
|
|
sub ebx, 4
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
|
|
mov eax, [timer_ticks]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2015-09-04 18:27:40 +02:00
|
|
|
|
; F.26.10 - get the time from kernel launch in nanoseconds
|
2022-01-04 19:51:19 +01:00
|
|
|
|
dec ebx
|
2015-09-04 18:27:40 +02:00
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
|
|
call get_clock_ns
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.edx], edx
|
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2015-09-04 18:27:40 +02:00
|
|
|
|
ret
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
2014-03-27 21:44:32 +01:00
|
|
|
|
; F.26.11 - Find out whether low-level HD access is enabled
|
2022-01-04 19:51:19 +01:00
|
|
|
|
dec ebx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz @f
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, [lba_read_enabled]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; F.26.12 - Find out whether low-level PCI access is enabled
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ebx
|
2014-03-27 21:44:32 +01:00
|
|
|
|
jnz .error
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, [pci_access_enabled]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.error:
|
2022-06-05 16:41:51 +02:00
|
|
|
|
or [esp + SYSCALL_STACK.eax], dword -1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
get_timer_ticks:
|
|
|
|
|
mov eax, [timer_ticks]
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2023-04-09 20:19:13 +02:00
|
|
|
|
iglobal
|
|
|
|
|
midi_base dw 0
|
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
sys_midi:
|
|
|
|
|
cmp word [mididp], 0
|
|
|
|
|
jnz @f
|
|
|
|
|
mov [esp + SYSCALL_STACK.eax], 1
|
|
|
|
|
ret
|
|
|
|
|
@@:
|
|
|
|
|
and [esp + SYSCALL_STACK.eax], 0
|
|
|
|
|
dec ebx
|
|
|
|
|
jnz .smn1
|
|
|
|
|
; call setuart
|
|
|
|
|
@@:
|
|
|
|
|
call .is_output
|
|
|
|
|
test al, al
|
|
|
|
|
jnz @b
|
|
|
|
|
mov dx, word [midisp]
|
|
|
|
|
mov al, 0xff
|
|
|
|
|
out dx, al
|
|
|
|
|
@@:
|
|
|
|
|
mov dx, word [midisp]
|
|
|
|
|
mov al, 0xff
|
|
|
|
|
out dx, al
|
|
|
|
|
call .is_input
|
|
|
|
|
test al, al
|
|
|
|
|
jnz @b
|
|
|
|
|
call .get_mpu_in
|
|
|
|
|
cmp al, 0xfe
|
|
|
|
|
jnz @b
|
|
|
|
|
@@:
|
|
|
|
|
call .is_output
|
|
|
|
|
test al, al
|
|
|
|
|
jnz @b
|
|
|
|
|
mov dx, word [midisp]
|
|
|
|
|
mov al, 0x3f
|
|
|
|
|
out dx, al
|
|
|
|
|
ret
|
|
|
|
|
.smn1:
|
|
|
|
|
dec ebx
|
|
|
|
|
jnz .ret
|
|
|
|
|
@@:
|
|
|
|
|
call .get_mpu_in
|
|
|
|
|
call .is_output
|
|
|
|
|
test al, al
|
|
|
|
|
jnz @b
|
|
|
|
|
mov al, bl
|
|
|
|
|
call .put_mpu_out
|
|
|
|
|
.ret:
|
|
|
|
|
ret
|
2015-10-16 21:00:13 +02:00
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.is_input:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push edx
|
|
|
|
|
mov dx, word [midisp]
|
|
|
|
|
in al, dx
|
|
|
|
|
and al, 0x80
|
|
|
|
|
pop edx
|
|
|
|
|
ret
|
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.is_output:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push edx
|
|
|
|
|
mov dx, word [midisp]
|
|
|
|
|
in al, dx
|
|
|
|
|
and al, 0x40
|
|
|
|
|
pop edx
|
|
|
|
|
ret
|
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.get_mpu_in:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push edx
|
|
|
|
|
mov dx, word [mididp]
|
|
|
|
|
in al, dx
|
|
|
|
|
pop edx
|
|
|
|
|
ret
|
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.put_mpu_out:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push edx
|
|
|
|
|
mov dx, word [mididp]
|
|
|
|
|
out dx, al
|
|
|
|
|
pop edx
|
|
|
|
|
ret
|
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sys_end:
|
2012-03-07 16:50:41 +01:00
|
|
|
|
; restore default cursor before killing
|
|
|
|
|
pusha
|
|
|
|
|
mov ecx, [current_slot]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov ecx, [ecx + APPDATA.window]
|
2012-03-08 10:22:41 +01:00
|
|
|
|
call restore_default_cursor_before_killing
|
2012-03-07 16:50:41 +01:00
|
|
|
|
popa
|
2013-05-28 19:34:26 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
; kill all sockets this process owns
|
|
|
|
|
pusha
|
2022-01-10 23:29:14 +01:00
|
|
|
|
mov edx, [current_slot]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov edx, [edx + APPDATA.tid]
|
2015-12-27 16:37:31 +01:00
|
|
|
|
call socket_process_end
|
2013-05-28 19:34:26 +02:00
|
|
|
|
popa
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ecx, [current_slot]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [ecx + APPDATA.tls_base]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jz @F
|
|
|
|
|
|
|
|
|
|
stdcall user_free, eax
|
|
|
|
|
@@:
|
|
|
|
|
|
2022-01-10 23:29:14 +01:00
|
|
|
|
mov eax, [current_slot]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov [eax + APPDATA.state], TSTATE_ZOMBIE
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2013-06-04 10:04:42 +02:00
|
|
|
|
.waitterm: ; wait here for termination
|
|
|
|
|
call change_task
|
|
|
|
|
jmp .waitterm
|
2012-03-08 10:22:41 +01:00
|
|
|
|
;------------------------------------------------------------------------------
|
2012-03-12 12:16:00 +01:00
|
|
|
|
align 4
|
2023-08-18 22:51:33 +02:00
|
|
|
|
; ecx - ptr WDATA
|
2012-03-08 10:22:41 +01:00
|
|
|
|
restore_default_cursor_before_killing:
|
2012-03-15 17:38:53 +01:00
|
|
|
|
pushfd
|
|
|
|
|
cli
|
2012-03-08 10:22:41 +01:00
|
|
|
|
mov eax, [def_cursor]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [ecx + WDATA.cursor], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2012-03-08 10:22:41 +01:00
|
|
|
|
movzx eax, word [MOUSE_Y]
|
|
|
|
|
movzx ebx, word [MOUSE_X]
|
2012-03-10 12:37:42 +01:00
|
|
|
|
mov eax, [d_width_calc_area + eax*4]
|
|
|
|
|
|
2015-01-05 18:59:03 +01:00
|
|
|
|
add eax, [_display.win_map]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
movzx edx, byte [ebx + eax]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
shl edx, BSF sizeof.WDATA
|
|
|
|
|
mov esi, [window_data + edx + WDATA.cursor]
|
2012-03-12 12:16:00 +01:00
|
|
|
|
|
|
|
|
|
cmp esi, [current_cursor]
|
|
|
|
|
je @f
|
|
|
|
|
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp [_display.select_cursor], 0
|
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
|
|
stdcall [_display.select_cursor], esi
|
2012-03-08 10:22:41 +01:00
|
|
|
|
mov [current_cursor], esi
|
2012-03-12 12:16:00 +01:00
|
|
|
|
@@:
|
2012-03-11 19:04:22 +01:00
|
|
|
|
mov [redrawmouse_unconditional], 1
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2012-03-15 17:38:53 +01:00
|
|
|
|
popfd
|
2012-03-08 10:22:41 +01:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
iglobal
|
|
|
|
|
align 4
|
|
|
|
|
sys_system_table:
|
|
|
|
|
dd sysfn_deactivate ; 1 = deactivate window
|
|
|
|
|
dd sysfn_terminate ; 2 = terminate thread
|
|
|
|
|
dd sysfn_activate ; 3 = activate window
|
|
|
|
|
dd sysfn_getidletime ; 4 = get idle time
|
|
|
|
|
dd sysfn_getcpuclock ; 5 = get cpu clock
|
|
|
|
|
dd sysfn_saveramdisk ; 6 = save ramdisk
|
|
|
|
|
dd sysfn_getactive ; 7 = get active window
|
|
|
|
|
dd sysfn_sound_flag ; 8 = get/set sound_flag
|
|
|
|
|
dd sysfn_shutdown ; 9 = shutdown with parameter
|
|
|
|
|
dd sysfn_minimize ; 10 = minimize window
|
|
|
|
|
dd sysfn_getdiskinfo ; 11 = get disk subsystem info
|
2021-11-14 20:15:56 +01:00
|
|
|
|
dd undefined_syscall ; 12 = get last pressed key. function removed. sysfn_lastkey
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dd sysfn_getversion ; 13 = get kernel version
|
|
|
|
|
dd sysfn_waitretrace ; 14 = wait retrace
|
|
|
|
|
dd sysfn_centermouse ; 15 = center mouse cursor
|
|
|
|
|
dd sysfn_getfreemem ; 16 = get free memory size
|
|
|
|
|
dd sysfn_getallmem ; 17 = get total memory size
|
|
|
|
|
dd sysfn_terminate2 ; 18 = terminate thread using PID
|
|
|
|
|
; instead of slot
|
|
|
|
|
dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration
|
|
|
|
|
dd sysfn_meminfo ; 20 = get extended memory info
|
|
|
|
|
dd sysfn_pid_to_slot ; 21 = get slot number for pid
|
|
|
|
|
dd sysfn_min_rest_window ; 22 = minimize and restore any window
|
2012-04-26 16:21:46 +02:00
|
|
|
|
dd sysfn_min_windows ; 23 = minimize all windows
|
2012-05-01 00:07:24 +02:00
|
|
|
|
dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
|
|
|
|
dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sysfn_num = ($ - sys_system_table)/4
|
|
|
|
|
endg
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sys_system:
|
|
|
|
|
dec ebx
|
|
|
|
|
cmp ebx, sysfn_num
|
|
|
|
|
jae @f
|
|
|
|
|
jmp dword [sys_system_table + ebx*4]
|
|
|
|
|
@@:
|
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_shutdown: ; 18.9 = system shutdown
|
2017-11-29 23:03:58 +01:00
|
|
|
|
cmp ecx, SYSTEM_SHUTDOWN
|
2023-08-18 22:51:33 +02:00
|
|
|
|
jl .exit_for_anyone
|
2017-11-29 23:03:58 +01:00
|
|
|
|
cmp ecx, SYSTEM_RESTART
|
2023-08-18 22:51:33 +02:00
|
|
|
|
jg .exit_for_anyone
|
2017-12-17 03:12:53 +01:00
|
|
|
|
mov [BOOT.shutdown_type], cl
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov eax, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [SYS_SHUTDOWN], al
|
|
|
|
|
mov [shutdown_processes], eax
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2022-06-05 16:41:51 +02:00
|
|
|
|
and dword [esp + SYSCALL_STACK.eax], 0
|
2023-08-18 22:51:33 +02:00
|
|
|
|
.exit_for_anyone:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
uglobal
|
|
|
|
|
shutdown_processes:
|
|
|
|
|
dd 0x0
|
|
|
|
|
endg
|
|
|
|
|
;------------------------------------------------------------------------------
|
2020-11-28 13:57:10 +01:00
|
|
|
|
; in: eax -- APPDATA ptr
|
|
|
|
|
; out: Z/z -- is/not kernel thread
|
|
|
|
|
is_kernel_thread:
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [eax + APPDATA.process]
|
|
|
|
|
cmp eax, [SLOT_BASE + 2*sizeof.APPDATA + APPDATA.process] ; OS
|
2020-11-28 13:57:10 +01:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sysfn_terminate: ; 18.2 = TERMINATE
|
2012-03-16 19:12:05 +01:00
|
|
|
|
push ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ecx, 2
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jb .noprocessterminate
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov edx, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ecx, edx
|
2023-04-08 23:24:05 +02:00
|
|
|
|
ja .noprocessterminate
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov eax, [thread_count]
|
2022-02-09 18:07:51 +01:00
|
|
|
|
shl ecx, BSF sizeof.APPDATA
|
|
|
|
|
add ecx, SLOT_BASE
|
2023-04-09 20:19:13 +02:00
|
|
|
|
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov edx, [ecx + APPDATA.tid]
|
|
|
|
|
cmp byte [ecx + APPDATA.state], TSTATE_FREE
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jz .noprocessterminate
|
2020-11-28 13:57:10 +01:00
|
|
|
|
push eax
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov eax, ecx
|
2020-11-28 13:57:10 +01:00
|
|
|
|
call is_kernel_thread
|
|
|
|
|
pop eax
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jz .noprocessterminate
|
2013-02-28 23:03:45 +01:00
|
|
|
|
push ecx edx
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov edx, ecx
|
2013-02-28 23:03:45 +01:00
|
|
|
|
call request_terminate
|
|
|
|
|
pop edx ecx
|
|
|
|
|
test eax, eax
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jz .noprocessterminate
|
2013-05-28 19:34:26 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
; terminate all network sockets it used
|
|
|
|
|
pusha
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov eax, edx ;TODO: check function
|
2015-12-27 16:37:31 +01:00
|
|
|
|
call socket_process_end
|
2013-05-28 19:34:26 +02:00
|
|
|
|
popa
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
; restore default cursor before killing
|
|
|
|
|
pusha
|
|
|
|
|
mov ecx, [esp+32]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
shl ecx, BSF sizeof.WDATA
|
|
|
|
|
add ecx, window_data
|
2012-03-12 12:16:00 +01:00
|
|
|
|
mov eax, [def_cursor]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
cmp [ecx + WDATA.cursor], eax
|
2012-03-12 12:16:00 +01:00
|
|
|
|
je @f
|
2012-03-08 10:22:41 +01:00
|
|
|
|
call restore_default_cursor_before_killing
|
2012-03-07 16:50:41 +01:00
|
|
|
|
@@:
|
2012-03-12 12:16:00 +01:00
|
|
|
|
popa
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;call MEM_Heap_Lock ;guarantee that process isn't working with heap
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov [ecx + APPDATA.state], TSTATE_ZOMBIE; clear possible i40's
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;call MEM_Heap_UnLock
|
|
|
|
|
|
2013-05-27 11:02:35 +02:00
|
|
|
|
cmp edx, [application_table_owner]; clear app table stat
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .noatsc
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call unlock_application_table
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.noatsc:
|
|
|
|
|
.noprocessterminate:
|
2012-03-16 19:12:05 +01:00
|
|
|
|
add esp, 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_terminate2:
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call lock_application_table
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, ecx
|
|
|
|
|
call pid_to_slot
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .not_found
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
cli
|
|
|
|
|
call sysfn_terminate
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call unlock_application_table
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sti
|
2022-06-05 16:41:51 +02:00
|
|
|
|
and dword [esp + SYSCALL_STACK.eax], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
.not_found:
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call unlock_application_table
|
2022-06-05 16:41:51 +02:00
|
|
|
|
or dword [esp + SYSCALL_STACK.eax], -1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW
|
|
|
|
|
cmp ecx, 2
|
|
|
|
|
jb .nowindowdeactivate
|
2021-06-16 12:04:10 +02:00
|
|
|
|
cmp ecx, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ja .nowindowdeactivate
|
2012-02-26 05:10:05 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movzx esi, word [WIN_STACK + ecx*2]
|
|
|
|
|
cmp esi, 1
|
|
|
|
|
je .nowindowdeactivate ; already deactive
|
|
|
|
|
|
|
|
|
|
mov edi, ecx
|
2023-06-25 18:42:10 +02:00
|
|
|
|
shl edi, BSF sizeof.WDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add edi, window_data
|
|
|
|
|
movzx esi, word [WIN_STACK + ecx * 2]
|
|
|
|
|
lea esi, [WIN_POS + esi * 2]
|
|
|
|
|
call window._.window_deactivate
|
2016-12-18 04:13:18 +01:00
|
|
|
|
call syscall_display_settings.calculateScreen
|
|
|
|
|
call syscall_display_settings.redrawScreen
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.nowindowdeactivate:
|
|
|
|
|
ret
|
2013-04-07 18:11:35 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sysfn_activate: ; 18.3 = ACTIVATE WINDOW
|
2015-08-04 17:15:56 +02:00
|
|
|
|
cmp ecx, 2
|
|
|
|
|
jb .nowindowactivate
|
2021-06-16 12:04:10 +02:00
|
|
|
|
cmp ecx, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ja .nowindowactivate
|
2013-04-07 18:11:35 +02:00
|
|
|
|
;-------------------------------------
|
|
|
|
|
@@:
|
|
|
|
|
; If the window is captured and moved by the user,
|
|
|
|
|
; then you can't change the position in window stack!!!
|
|
|
|
|
mov al, [mouse.active_sys_window.action]
|
|
|
|
|
and al, WINDOW_MOVE_AND_RESIZE_FLAGS
|
|
|
|
|
test al, al
|
|
|
|
|
jz @f
|
|
|
|
|
call change_task
|
|
|
|
|
jmp @b
|
|
|
|
|
@@:
|
|
|
|
|
;-------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [window_minimize], 2; restore window if minimized
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
movzx esi, word [WIN_STACK + ecx*2]
|
2021-06-16 12:04:10 +02:00
|
|
|
|
cmp esi, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
je .nowindowactivate; already active
|
|
|
|
|
|
|
|
|
|
mov edi, ecx
|
2022-02-12 18:27:41 +01:00
|
|
|
|
shl edi, BSF sizeof.WDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add edi, window_data
|
|
|
|
|
movzx esi, word [WIN_STACK + ecx * 2]
|
|
|
|
|
lea esi, [WIN_POS + esi * 2]
|
|
|
|
|
call waredraw
|
|
|
|
|
.nowindowactivate:
|
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2015-10-27 21:29:29 +01:00
|
|
|
|
align 4
|
2015-10-09 15:59:11 +02:00
|
|
|
|
sysfn_zmodif:
|
|
|
|
|
;18,25,1 - get z_modif
|
|
|
|
|
;18,25,2 - set z_modif
|
|
|
|
|
;edx = -1(for current task) or TID
|
|
|
|
|
;esi(for 2) = new value z_modif
|
|
|
|
|
;return:
|
|
|
|
|
;1: eax = z_modif
|
|
|
|
|
;2: eax=0(fail),1(success) for set z_modif
|
|
|
|
|
|
|
|
|
|
cmp edx, -1
|
|
|
|
|
jne @f
|
2021-06-17 11:41:16 +02:00
|
|
|
|
mov edx, [current_slot_idx]
|
2015-10-09 15:59:11 +02:00
|
|
|
|
@@:
|
2021-06-16 12:04:10 +02:00
|
|
|
|
cmp edx, [thread_count]
|
2015-10-27 21:29:29 +01:00
|
|
|
|
ja .fail
|
2015-10-09 15:59:11 +02:00
|
|
|
|
cmp edx, 1
|
2015-10-27 21:29:29 +01:00
|
|
|
|
je .fail
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
2015-10-27 21:29:29 +01:00
|
|
|
|
mov eax, edx
|
2022-02-12 18:27:41 +01:00
|
|
|
|
shl edx, BSF sizeof.WDATA
|
2023-10-23 14:53:06 +02:00
|
|
|
|
add edx, window_data
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
2023-10-23 14:53:06 +02:00
|
|
|
|
test [edx + WDATA.fl_wstate], WSTATE_USED
|
2023-08-18 22:51:33 +02:00
|
|
|
|
jz .fail
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
|
|
|
|
cmp ecx, 1
|
|
|
|
|
jnz .set_zmod
|
|
|
|
|
|
2023-10-23 14:53:06 +02:00
|
|
|
|
movzx eax, [edx + WDATA.z_modif]
|
2015-10-09 15:59:11 +02:00
|
|
|
|
jmp .exit
|
2015-10-27 21:29:29 +01:00
|
|
|
|
|
2015-10-09 15:59:11 +02:00
|
|
|
|
.set_zmod:
|
|
|
|
|
cmp ecx, 2
|
2015-10-27 21:29:29 +01:00
|
|
|
|
jnz .fail
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
2015-10-27 21:29:29 +01:00
|
|
|
|
mov ebx, esi
|
|
|
|
|
mov esi, eax
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
2015-10-27 21:29:29 +01:00
|
|
|
|
cmp bl, ZPOS_ALWAYS_TOP
|
|
|
|
|
jg .fail
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
2023-10-23 14:53:06 +02:00
|
|
|
|
mov [edx + WDATA.z_modif], bl
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
2023-10-23 14:53:06 +02:00
|
|
|
|
mov eax, [edx + WDATA.box.left]
|
|
|
|
|
mov ebx, [edx + WDATA.box.top]
|
|
|
|
|
mov ecx, [edx + WDATA.box.width]
|
|
|
|
|
mov edx, [edx + WDATA.box.height]
|
2015-10-09 15:59:11 +02:00
|
|
|
|
add ecx, eax
|
|
|
|
|
add edx, ebx
|
2015-10-27 21:29:29 +01:00
|
|
|
|
call window._.set_screen
|
2015-10-09 15:59:11 +02:00
|
|
|
|
call window._.set_top_wnd
|
2015-10-27 21:29:29 +01:00
|
|
|
|
call window._.redraw_top_wnd
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
shl esi, BSF sizeof.WDATA
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [esi + window_data + WDATA.fl_redraw], WSTATE_REDRAW
|
2015-10-27 21:29:29 +01:00
|
|
|
|
|
2015-10-09 15:59:11 +02:00
|
|
|
|
|
|
|
|
|
mov eax, 1
|
2015-10-27 21:29:29 +01:00
|
|
|
|
jmp .exit
|
|
|
|
|
.fail:
|
|
|
|
|
xor eax, eax
|
2015-10-09 15:59:11 +02:00
|
|
|
|
.exit:
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2015-10-09 15:59:11 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sysfn_getidletime: ; 18.4 = GET IDLETIME
|
2023-08-20 23:54:50 +02:00
|
|
|
|
mov eax, [SLOT_BASE + sizeof.APPDATA + APPDATA.cpu_usage]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_getcpuclock: ; 18.5 = GET TSC/SEC
|
2013-04-26 12:57:25 +02:00
|
|
|
|
mov eax, dword [cpu_freq]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2013-04-26 12:57:25 +02:00
|
|
|
|
get_cpu_freq:
|
|
|
|
|
mov eax, dword [cpu_freq]
|
|
|
|
|
mov edx, dword [cpu_freq+4]
|
|
|
|
|
ret
|
2021-11-14 20:15:56 +01:00
|
|
|
|
; SAVE ramdisk to /hd/1/kolibri.img
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
include 'blkdev/rdsave.inc'
|
|
|
|
|
;!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
sysfn_getactive: ; 18.7 = get active window
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov eax, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movzx eax, word [WIN_POS + eax*2]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_sound_flag: ; 18.8 = get/set sound_flag
|
|
|
|
|
; cmp ecx,1
|
|
|
|
|
dec ecx
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jnz .set_flag
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movzx eax, byte [sound_flag]; get sound_flag
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.set_flag:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; cmp ecx,2
|
|
|
|
|
dec ecx
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jnz .err
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor byte [sound_flag], 1
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.err:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_minimize: ; 18.10 = minimize window
|
|
|
|
|
mov [window_minimize], 1
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
sysfn_getdiskinfo: ; 18.11 = get disk info table
|
|
|
|
|
dec ecx
|
2014-03-13 08:21:24 +01:00
|
|
|
|
jnz .exit
|
|
|
|
|
.small_table:
|
2021-02-21 10:59:47 +01:00
|
|
|
|
stdcall is_region_userspace, edx, DRIVE_DATA_SIZE
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jnz .exit
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov edi, edx
|
|
|
|
|
mov esi, DRIVE_DATA
|
2014-03-13 08:21:24 +01:00
|
|
|
|
mov ecx, DRIVE_DATA_SIZE ;10
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cld
|
2014-03-13 08:21:24 +01:00
|
|
|
|
rep movsb
|
|
|
|
|
.exit:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_getversion: ; 18.13 = get kernel ID and version
|
2020-11-24 13:49:42 +01:00
|
|
|
|
; if given memory address belongs to kernel then error
|
2023-06-17 20:40:54 +02:00
|
|
|
|
stdcall is_region_userspace, ecx, version_inf.size
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jnz .addr_error
|
2020-11-24 13:49:42 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov edi, ecx
|
|
|
|
|
mov esi, version_inf
|
2023-06-17 20:40:54 +02:00
|
|
|
|
mov ecx, version_inf.size
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep movsb
|
|
|
|
|
ret
|
2020-11-24 13:49:42 +01:00
|
|
|
|
.addr_error: ; if given memory address is illegal
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov dword [esp + SYSCALL_STACK.eax], -1
|
2023-10-01 23:53:34 +02:00
|
|
|
|
ret
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_waitretrace: ; 18.14 = sys wait retrace
|
2023-04-09 20:19:13 +02:00
|
|
|
|
;wait retrace functions
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov edx, 0x3da
|
2023-04-09 20:19:13 +02:00
|
|
|
|
.loop:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
in al, dx
|
|
|
|
|
test al, 1000b
|
2023-04-09 20:19:13 +02:00
|
|
|
|
jz .loop
|
2022-06-05 16:41:51 +02:00
|
|
|
|
and [esp + SYSCALL_STACK.eax], dword 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
sysfn_centermouse: ; 18.15 = mouse centered
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov eax, [_display.width]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr eax, 1
|
|
|
|
|
mov [MOUSE_X], ax
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov eax, [_display.height]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr eax, 1
|
|
|
|
|
mov [MOUSE_Y], ax
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor eax, eax
|
2022-06-05 16:41:51 +02:00
|
|
|
|
and [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2015-10-16 21:00:13 +02:00
|
|
|
|
sysfn_mouse_acceleration: ; 18.19 = set/get mouse features
|
|
|
|
|
cmp ecx, 8
|
|
|
|
|
jnc @f
|
2022-02-12 18:27:41 +01:00
|
|
|
|
jmp dword [.table + ecx*4]
|
2015-10-16 21:00:13 +02:00
|
|
|
|
.get_mouse_acceleration:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov ax, [mouse_speed_factor]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2015-10-16 21:00:13 +02:00
|
|
|
|
.set_mouse_acceleration:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [mouse_speed_factor], dx
|
|
|
|
|
ret
|
2015-10-16 21:00:13 +02:00
|
|
|
|
.get_mouse_delay:
|
2015-10-21 01:01:43 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
mov al, [mouse_delay]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2015-10-16 21:00:13 +02:00
|
|
|
|
.set_mouse_delay:
|
2015-10-21 01:01:43 +02:00
|
|
|
|
mov [mouse_delay], dl
|
2015-10-16 21:00:13 +02:00
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2015-10-16 21:00:13 +02:00
|
|
|
|
.set_pointer_position:
|
2015-01-05 18:18:45 +01:00
|
|
|
|
cmp dx, word[_display.height]
|
2015-10-16 21:00:13 +02:00
|
|
|
|
jae @b
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rol edx, 16
|
2015-01-05 18:18:45 +01:00
|
|
|
|
cmp dx, word[_display.width]
|
2015-10-16 21:00:13 +02:00
|
|
|
|
jae @b
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [MOUSE_X], edx
|
2013-12-19 14:21:35 +01:00
|
|
|
|
mov [mouse_active], 1
|
2015-10-16 21:00:13 +02:00
|
|
|
|
jmp wakeup_osloop
|
|
|
|
|
.set_mouse_button:
|
|
|
|
|
mov [BTN_DOWN], edx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [mouse_active], 1
|
2015-10-16 21:00:13 +02:00
|
|
|
|
jmp wakeup_osloop
|
|
|
|
|
.get_doubleclick_delay:
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov al, [mouse_doubleclick_delay]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2015-10-16 21:00:13 +02:00
|
|
|
|
ret
|
|
|
|
|
.set_doubleclick_delay:
|
|
|
|
|
mov [mouse_doubleclick_delay], dl
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2015-10-16 21:00:13 +02:00
|
|
|
|
align 4
|
|
|
|
|
.table:
|
|
|
|
|
dd .get_mouse_acceleration
|
|
|
|
|
dd .set_mouse_acceleration
|
|
|
|
|
dd .get_mouse_delay
|
|
|
|
|
dd .set_mouse_delay
|
|
|
|
|
dd .set_pointer_position
|
|
|
|
|
dd .set_mouse_button
|
|
|
|
|
dd .get_doubleclick_delay
|
|
|
|
|
dd .set_doubleclick_delay
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_getfreemem:
|
|
|
|
|
mov eax, [pg_data.pages_free]
|
|
|
|
|
shl eax, 2
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-04-26 16:21:46 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sysfn_getallmem:
|
|
|
|
|
mov eax, [MEM_AMOUNT]
|
|
|
|
|
shr eax, 10
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-04-26 16:21:46 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sysfn_pid_to_slot:
|
|
|
|
|
mov eax, ecx
|
|
|
|
|
call pid_to_slot
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-04-26 16:21:46 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sysfn_min_rest_window:
|
|
|
|
|
pushad
|
|
|
|
|
mov eax, edx ; ebx - operating
|
|
|
|
|
shr ecx, 1
|
|
|
|
|
jnc @f
|
|
|
|
|
call pid_to_slot
|
|
|
|
|
@@:
|
|
|
|
|
or eax, eax ; eax - number of slot
|
|
|
|
|
jz .error
|
2022-06-04 01:34:04 +02:00
|
|
|
|
cmp eax, max_processes ; varify maximal slot number
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ja .error
|
|
|
|
|
movzx eax, word [WIN_STACK + eax*2]
|
|
|
|
|
shr ecx, 1
|
|
|
|
|
jc .restore
|
|
|
|
|
; .minimize:
|
|
|
|
|
call minimize_window
|
|
|
|
|
jmp .exit
|
|
|
|
|
.restore:
|
|
|
|
|
call restore_minimized_window
|
|
|
|
|
.exit:
|
|
|
|
|
popad
|
|
|
|
|
xor eax, eax
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
.error:
|
|
|
|
|
popad
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec eax
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-04-26 16:21:46 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
sysfn_min_windows:
|
|
|
|
|
call minimize_all_window
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2012-04-26 16:21:46 +02:00
|
|
|
|
call change_task
|
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2012-05-01 00:07:24 +02:00
|
|
|
|
sysfn_set_screen_sizes:
|
|
|
|
|
cmp [SCR_MODE], word 0x13
|
|
|
|
|
jbe .exit
|
|
|
|
|
|
|
|
|
|
cmp [_display.select_cursor], select_cursor
|
|
|
|
|
jne .exit
|
|
|
|
|
|
|
|
|
|
cmp ecx, [display_width_standard]
|
|
|
|
|
ja .exit
|
|
|
|
|
|
|
|
|
|
cmp edx, [display_height_standard]
|
|
|
|
|
ja .exit
|
|
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
|
cli
|
|
|
|
|
mov eax, ecx
|
2015-01-05 18:59:03 +01:00
|
|
|
|
mov ecx, [_display.lfb_pitch]
|
2012-05-01 00:07:24 +02:00
|
|
|
|
mov [_display.width], eax
|
|
|
|
|
dec eax
|
|
|
|
|
mov [_display.height], edx
|
|
|
|
|
dec edx
|
|
|
|
|
; eax - new Screen_Max_X
|
|
|
|
|
; edx - new Screen_Max_Y
|
|
|
|
|
mov [do_not_touch_winmap], 1
|
|
|
|
|
call set_screen
|
|
|
|
|
mov [do_not_touch_winmap], 0
|
|
|
|
|
popfd
|
|
|
|
|
call change_task
|
|
|
|
|
.exit:
|
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
uglobal
|
|
|
|
|
screen_workarea RECT
|
2012-05-01 00:07:24 +02:00
|
|
|
|
display_width_standard dd 0
|
|
|
|
|
display_height_standard dd 0
|
|
|
|
|
do_not_touch_winmap db 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
window_minimize db 0
|
|
|
|
|
sound_flag db 0
|
2012-05-01 00:07:24 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
|
version_inf:
|
2013-04-07 13:24:02 +02:00
|
|
|
|
db 0,7,7,0 ; version 0.7.7.0
|
|
|
|
|
db 0
|
|
|
|
|
.rev dd __REV__
|
2023-06-17 20:40:54 +02:00
|
|
|
|
.size = $ - version_inf
|
2011-10-14 23:38:50 +02:00
|
|
|
|
endg
|
2012-03-28 18:32:08 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sys_cachetodiskette:
|
|
|
|
|
cmp ebx, 1
|
2013-11-21 17:07:16 +01:00
|
|
|
|
jb .no_floppy_save
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ebx, 2
|
2013-11-21 17:07:16 +01:00
|
|
|
|
ja .no_floppy_save
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call save_image
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2013-11-21 17:07:16 +01:00
|
|
|
|
ret
|
|
|
|
|
.no_floppy_save:
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], dword 1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-28 18:32:08 +02:00
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
sys_cpuusage:
|
|
|
|
|
|
|
|
|
|
; RETURN:
|
|
|
|
|
;
|
|
|
|
|
; +00 dword process cpu usage
|
|
|
|
|
; +04 word position in windowing stack
|
|
|
|
|
; +06 word windowing stack value at current position (cpu nro)
|
|
|
|
|
; +10 12 bytes name
|
|
|
|
|
; +22 dword start in mem
|
|
|
|
|
; +26 dword used mem
|
|
|
|
|
; +30 dword PID , process idenfification number
|
|
|
|
|
;
|
2020-11-23 19:52:56 +01:00
|
|
|
|
; if given memory address belongs to kernel then error
|
2020-12-05 20:56:25 +01:00
|
|
|
|
stdcall is_region_userspace, ebx, 0x4C
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jnz .addr_error
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
cmp ecx, -1 ; who am I ?
|
|
|
|
|
jne .no_who_am_i
|
2021-06-17 11:41:16 +02:00
|
|
|
|
mov ecx, [current_slot_idx]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.no_who_am_i:
|
|
|
|
|
cmp ecx, max_processes
|
|
|
|
|
ja .nofillbuf
|
|
|
|
|
|
|
|
|
|
; +4: word: position of the window of thread in the window stack
|
|
|
|
|
mov ax, [WIN_STACK + ecx * 2]
|
|
|
|
|
mov [ebx+4], ax
|
|
|
|
|
; +6: word: number of the thread slot, which window has in the window stack
|
|
|
|
|
; position ecx (has no relation to the specific thread)
|
|
|
|
|
mov ax, [WIN_POS + ecx * 2]
|
|
|
|
|
mov [ebx+6], ax
|
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
shl ecx, BSF sizeof.APPDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; +0: dword: memory usage
|
2023-08-20 23:54:50 +02:00
|
|
|
|
mov eax, [SLOT_BASE + ecx + APPDATA.cpu_usage]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [ebx], eax
|
|
|
|
|
; +10: 11 bytes: name of the process
|
|
|
|
|
push ecx
|
2022-02-12 18:27:41 +01:00
|
|
|
|
lea eax, [SLOT_BASE + ecx + APPDATA.app_name]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add ebx, 10
|
|
|
|
|
mov ecx, 11
|
|
|
|
|
call memmove
|
|
|
|
|
pop ecx
|
|
|
|
|
|
|
|
|
|
; +22: address of the process in memory
|
|
|
|
|
; +26: size of used memory - 1
|
|
|
|
|
push edi
|
|
|
|
|
lea edi, [ebx+12]
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov edx, 0x100000*16
|
2023-08-20 23:54:50 +02:00
|
|
|
|
cmp ecx, 1 shl BSF sizeof.APPDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
je .os_mem
|
2023-08-20 23:54:50 +02:00
|
|
|
|
mov edx, [SLOT_BASE + ecx + APPDATA.process]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov edx, [edx + PROC.mem_used]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, std_application_base_address
|
|
|
|
|
.os_mem:
|
|
|
|
|
stosd
|
|
|
|
|
lea eax, [edx-1]
|
|
|
|
|
stosd
|
|
|
|
|
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov edx, [SLOT_BASE + ecx + APPDATA.window]
|
2023-08-20 23:54:50 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; +30: PID/TID
|
2023-08-20 23:54:50 +02:00
|
|
|
|
mov eax, [SLOT_BASE + ecx + APPDATA.tid]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stosd
|
|
|
|
|
|
|
|
|
|
; window position and size
|
|
|
|
|
push esi
|
2023-09-22 18:31:40 +02:00
|
|
|
|
lea esi, [edx + WDATA.box]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movsd
|
|
|
|
|
movsd
|
|
|
|
|
movsd
|
|
|
|
|
movsd
|
|
|
|
|
|
|
|
|
|
; Process state (+50)
|
2023-08-20 23:54:50 +02:00
|
|
|
|
movzx eax, byte [SLOT_BASE + ecx + APPDATA.state]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stosd
|
|
|
|
|
|
|
|
|
|
; Window client area box
|
2023-09-22 18:31:40 +02:00
|
|
|
|
lea esi, [edx + WDATA.clientbox]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movsd
|
|
|
|
|
movsd
|
|
|
|
|
movsd
|
|
|
|
|
movsd
|
|
|
|
|
|
|
|
|
|
; Window state
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov al, [edx + WDATA.fl_wstate]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stosb
|
|
|
|
|
|
|
|
|
|
; Event mask (+71)
|
2023-08-20 23:54:50 +02:00
|
|
|
|
mov eax, dword [SLOT_BASE + ecx + APPDATA.event_mask]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
stosd
|
2013-11-24 08:01:31 +01:00
|
|
|
|
|
2013-11-20 22:11:15 +01:00
|
|
|
|
; Keyboard mode (+75)
|
2023-08-20 23:54:50 +02:00
|
|
|
|
mov al, byte [SLOT_BASE + ecx + APPDATA.keyboard_mode]
|
2013-11-24 08:01:31 +01:00
|
|
|
|
stosb
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
pop esi
|
|
|
|
|
pop edi
|
|
|
|
|
|
|
|
|
|
.nofillbuf:
|
|
|
|
|
; return number of processes
|
|
|
|
|
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov eax, [thread_count]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
2020-11-23 19:52:56 +01:00
|
|
|
|
.addr_error: ; if given memory address is illegal
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov dword [esp + SYSCALL_STACK.eax], -1
|
2023-10-01 23:53:34 +02:00
|
|
|
|
ret
|
2020-11-23 19:52:56 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
; redraw status
|
2022-01-10 23:29:14 +01:00
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sys_redrawstat:
|
|
|
|
|
cmp ebx, 1
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .no_widgets_away
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; buttons away
|
2021-06-17 11:41:16 +02:00
|
|
|
|
mov ecx, [current_slot_idx]
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.sys_newba2:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov edi, [BTN_ADDR]
|
|
|
|
|
cmp [edi], dword 0 ; empty button list ?
|
2023-04-08 23:24:05 +02:00
|
|
|
|
je .end_of_buttons_away
|
2011-10-14 23:38:50 +02:00
|
|
|
|
movzx ebx, word [edi]
|
|
|
|
|
inc ebx
|
|
|
|
|
mov eax, edi
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.sys_newba:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec ebx
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jz .end_of_buttons_away
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
add eax, 0x10
|
|
|
|
|
cmp cx, [eax]
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jnz .sys_newba
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
push eax ebx ecx
|
|
|
|
|
mov ecx, ebx
|
|
|
|
|
inc ecx
|
|
|
|
|
shl ecx, 4
|
|
|
|
|
mov ebx, eax
|
|
|
|
|
add eax, 0x10
|
|
|
|
|
call memmove
|
|
|
|
|
dec dword [edi]
|
|
|
|
|
pop ecx ebx eax
|
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jmp .sys_newba2
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.end_of_buttons_away:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.no_widgets_away:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
cmp ebx, 2
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jnz .srl1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov edx, [current_slot] ; return whole screen draw area for this app
|
|
|
|
|
mov edx, [edx + APPDATA.window]
|
|
|
|
|
mov [edx + WDATA.draw_data.left], 0
|
|
|
|
|
mov [edx + WDATA.draw_data.top], 0
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov eax, [_display.width]
|
|
|
|
|
dec eax
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [edx + WDATA.draw_data.right], eax
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov eax, [_display.height]
|
|
|
|
|
dec eax
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [edx + WDATA.draw_data.bottom], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.srl1:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;ok - 100% work
|
|
|
|
|
;nt - not tested
|
|
|
|
|
;---------------------------------------------------------------------------------------------
|
|
|
|
|
;eax
|
|
|
|
|
;0 - task switch counter. Ret switch counter in eax. Block. ok.
|
|
|
|
|
;1 - change task. Ret nothing. Block. ok.
|
|
|
|
|
;2 - performance control
|
|
|
|
|
; ebx
|
|
|
|
|
; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode.
|
|
|
|
|
; returned new cr4 in eax. Ret cr4 in eax. Block. ok.
|
|
|
|
|
; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok.
|
|
|
|
|
; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok.
|
|
|
|
|
; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok.
|
|
|
|
|
;eax
|
|
|
|
|
;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok.
|
|
|
|
|
;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok.
|
|
|
|
|
;---------------------------------------------------------------------------------------------
|
|
|
|
|
iglobal
|
|
|
|
|
align 4
|
|
|
|
|
sheduler:
|
|
|
|
|
dd sys_sheduler.00
|
|
|
|
|
dd change_task
|
|
|
|
|
dd sys_sheduler.02
|
|
|
|
|
dd sys_sheduler.03
|
|
|
|
|
dd sys_sheduler.04
|
|
|
|
|
endg
|
|
|
|
|
sys_sheduler:
|
|
|
|
|
;rewritten by <Lrz> 29.12.2009
|
2022-02-12 18:27:41 +01:00
|
|
|
|
jmp dword [sheduler + ebx*4]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;.shed_counter:
|
|
|
|
|
.00:
|
|
|
|
|
mov eax, [context_counter]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.02:
|
|
|
|
|
;.perf_control:
|
|
|
|
|
inc ebx ;before ebx=2, ebx=3
|
|
|
|
|
cmp ebx, ecx ;if ecx=3, ebx=3
|
|
|
|
|
jz cache_disable
|
|
|
|
|
|
|
|
|
|
dec ebx ;ebx=2
|
|
|
|
|
cmp ebx, ecx ;
|
|
|
|
|
jz cache_enable ;if ecx=2 and ebx=2
|
|
|
|
|
|
|
|
|
|
dec ebx ;ebx=1
|
|
|
|
|
cmp ebx, ecx
|
|
|
|
|
jz is_cache_enabled ;if ecx=1 and ebx=1
|
|
|
|
|
|
|
|
|
|
dec ebx
|
|
|
|
|
test ebx, ecx ;ebx=0 and ecx=0
|
|
|
|
|
jz modify_pce ;if ecx=0
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.03:
|
|
|
|
|
;.rdmsr_instr:
|
|
|
|
|
;now counter in ecx
|
|
|
|
|
;(edx:eax) esi:edi => edx:esi
|
|
|
|
|
mov eax, esi
|
|
|
|
|
mov ecx, edx
|
|
|
|
|
rdmsr
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
|
|
|
|
mov [esp + SYSCALL_STACK.ebx], edx ;ret in ebx?
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.04:
|
|
|
|
|
;.wrmsr_instr:
|
|
|
|
|
;now counter in ecx
|
|
|
|
|
;(edx:eax) esi:edi => edx:esi
|
|
|
|
|
; Fast Call MSR can't be destroy
|
2013-05-28 00:16:00 +02:00
|
|
|
|
; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш
|
|
|
|
|
; включаются/выключаются расширенные возможности
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp edx, MSR_SYSENTER_CS
|
|
|
|
|
je @f
|
|
|
|
|
cmp edx, MSR_SYSENTER_ESP
|
|
|
|
|
je @f
|
|
|
|
|
cmp edx, MSR_SYSENTER_EIP
|
|
|
|
|
je @f
|
|
|
|
|
cmp edx, MSR_AMD_STAR
|
|
|
|
|
je @f
|
|
|
|
|
|
|
|
|
|
mov eax, esi
|
|
|
|
|
mov ecx, edx
|
|
|
|
|
wrmsr
|
|
|
|
|
; mov [esp + 32], eax
|
|
|
|
|
; mov [esp + 20], edx ;ret in ebx?
|
|
|
|
|
@@:
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
cache_disable:
|
|
|
|
|
mov eax, cr0
|
2022-06-05 16:41:51 +02:00
|
|
|
|
or eax, 01100000_00000000_00000000_00000000b
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov cr0, eax
|
|
|
|
|
wbinvd ;set MESI
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
cache_enable:
|
|
|
|
|
mov eax, cr0
|
2022-06-05 16:41:51 +02:00
|
|
|
|
and eax, 10011111_11111111_11111111_11111111b
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov cr0, eax
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
is_cache_enabled:
|
|
|
|
|
mov eax, cr0
|
2022-06-05 16:41:51 +02:00
|
|
|
|
and eax, 01100000_00000000_00000000_00000000b
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
modify_pce:
|
|
|
|
|
mov eax, cr4
|
|
|
|
|
; mov ebx,0
|
|
|
|
|
; or bx,100000000b ;pce
|
|
|
|
|
; xor eax,ebx ;invert pce
|
|
|
|
|
bts eax, 8;pce=cr4[8]
|
|
|
|
|
mov cr4, eax
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
;---------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iglobal
|
|
|
|
|
cpustring db 'CPU',0
|
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
uglobal
|
|
|
|
|
background_defined db 0 ; diamond, 11.04.2006
|
|
|
|
|
endg
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
checkmisc:
|
|
|
|
|
cmp [ctrl_alt_del], 1
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .nocpustart
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov ebp, cpustring
|
|
|
|
|
call fs_execute_from_sysdir
|
|
|
|
|
|
|
|
|
|
mov [ctrl_alt_del], 0
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.nocpustart:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp [mouse_active], 1
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .mouse_not_active
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [mouse_active], 0
|
2012-02-27 08:04:31 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor edi, edi
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov ebx, window_data
|
2012-02-27 08:04:31 +01:00
|
|
|
|
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov ecx, [thread_count]
|
2012-02-26 05:10:05 +01:00
|
|
|
|
movzx eax, word [WIN_POS + ecx*2] ; active window
|
2023-06-22 05:32:33 +02:00
|
|
|
|
shl eax, BSF sizeof.APPDATA
|
2012-02-28 09:36:15 +01:00
|
|
|
|
push eax
|
|
|
|
|
|
|
|
|
|
movzx eax, word [MOUSE_X]
|
|
|
|
|
movzx edx, word [MOUSE_Y]
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
2012-02-26 05:10:05 +01:00
|
|
|
|
align 4
|
|
|
|
|
.set_mouse_event:
|
2020-10-12 04:54:44 +02:00
|
|
|
|
add edi, sizeof.APPDATA
|
2022-02-09 18:07:51 +01:00
|
|
|
|
add ebx, sizeof.WDATA
|
2023-06-17 20:40:54 +02:00
|
|
|
|
test [SLOT_BASE + edi + APPDATA.event_mask], EVM_MOUSE_FILTER
|
2012-02-28 09:36:15 +01:00
|
|
|
|
jz .pos_filter
|
2012-02-26 05:10:05 +01:00
|
|
|
|
|
2012-02-28 09:36:15 +01:00
|
|
|
|
cmp edi, [esp] ; skip if filtration active
|
2012-02-27 08:04:31 +01:00
|
|
|
|
jne .skip
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2012-02-28 09:36:15 +01:00
|
|
|
|
.pos_filter:
|
2023-06-17 20:40:54 +02:00
|
|
|
|
test [SLOT_BASE + edi + APPDATA.event_mask], EVM_CURSOR_FILTER
|
2012-02-28 09:36:15 +01:00
|
|
|
|
jz .set
|
|
|
|
|
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov esi, [ebx + WDATA.box.left]
|
2012-02-28 09:36:15 +01:00
|
|
|
|
cmp eax, esi
|
|
|
|
|
jb .skip
|
2022-02-09 18:07:51 +01:00
|
|
|
|
add esi, [ebx + WDATA.box.width]
|
2012-02-28 09:36:15 +01:00
|
|
|
|
cmp eax, esi
|
|
|
|
|
ja .skip
|
|
|
|
|
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov esi, [ebx + WDATA.box.top]
|
2012-02-28 09:36:15 +01:00
|
|
|
|
cmp edx, esi
|
|
|
|
|
jb .skip
|
2022-02-09 18:07:51 +01:00
|
|
|
|
add esi, [ebx + WDATA.box.height]
|
2012-02-28 09:36:15 +01:00
|
|
|
|
cmp edx, esi
|
|
|
|
|
ja .skip
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2012-02-27 08:04:31 +01:00
|
|
|
|
.set:
|
2022-02-12 18:27:41 +01:00
|
|
|
|
or [SLOT_BASE + edi + APPDATA.occurred_events], EVENT_MOUSE
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2012-02-27 08:04:31 +01:00
|
|
|
|
.skip:
|
2012-02-26 05:10:05 +01:00
|
|
|
|
loop .set_mouse_event
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2012-02-28 09:36:15 +01:00
|
|
|
|
pop eax
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.mouse_not_active:
|
2016-10-10 13:31:49 +02:00
|
|
|
|
cmp [REDRAW_BACKGROUND], 0 ; background update ?
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jz nobackgr
|
2012-03-29 22:44:29 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp [background_defined], 0
|
|
|
|
|
jz nobackgr
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2013-05-27 18:49:46 +02:00
|
|
|
|
backgr:
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov eax, [background_window + WDATA.draw_data.left]
|
2012-04-02 00:58:45 +02:00
|
|
|
|
shl eax, 16
|
2023-08-18 22:51:33 +02:00
|
|
|
|
add eax, [background_window + WDATA.draw_data.right]
|
2012-04-02 00:58:45 +02:00
|
|
|
|
mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right]
|
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov eax, [background_window + WDATA.draw_data.top]
|
2012-04-02 00:58:45 +02:00
|
|
|
|
shl eax, 16
|
2023-08-18 22:51:33 +02:00
|
|
|
|
add eax, [background_window + WDATA.draw_data.bottom]
|
2012-04-02 00:58:45 +02:00
|
|
|
|
mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom]
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call drawbackground
|
2012-04-06 21:54:26 +02:00
|
|
|
|
; DEBUGF 1, "K : drawbackground\n"
|
2012-04-17 18:32:18 +02:00
|
|
|
|
; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right]
|
|
|
|
|
; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom]
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------- set event 5 start ----------
|
|
|
|
|
push ecx edi
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov edi, window_data
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov ecx, [thread_count]
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
set_bgr_event:
|
2023-08-18 22:51:33 +02:00
|
|
|
|
add edi, sizeof.WDATA
|
2013-05-27 18:49:46 +02:00
|
|
|
|
mov eax, [BG_Rect_X_left_right]
|
|
|
|
|
mov edx, [BG_Rect_Y_top_bottom]
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp [edi + WDATA.draw_bgr_x], 0
|
2013-05-27 18:49:46 +02:00
|
|
|
|
jz .set
|
|
|
|
|
.join:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp word [edi + WDATA.draw_bgr_x], ax
|
2013-05-27 18:49:46 +02:00
|
|
|
|
jae @f
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov word [edi + WDATA.draw_bgr_x], ax
|
2013-05-27 18:49:46 +02:00
|
|
|
|
@@:
|
2013-06-06 12:50:52 +02:00
|
|
|
|
shr eax, 16
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp word [edi + WDATA.draw_bgr_x + 2], ax
|
2013-05-27 18:49:46 +02:00
|
|
|
|
jbe @f
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov word [edi + WDATA.draw_bgr_x + 2], ax
|
2013-05-27 18:49:46 +02:00
|
|
|
|
@@:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp word [edi + WDATA.draw_bgr_y], dx
|
2013-05-27 18:49:46 +02:00
|
|
|
|
jae @f
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov word [edi + WDATA.draw_bgr_y], dx
|
2013-06-06 12:50:52 +02:00
|
|
|
|
@@:
|
|
|
|
|
shr edx, 16
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp word [edi + WDATA.draw_bgr_y+2], dx
|
2013-06-06 12:50:52 +02:00
|
|
|
|
jbe @f
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov word [edi + WDATA.draw_bgr_y+2], dx
|
2013-05-27 18:49:46 +02:00
|
|
|
|
@@:
|
|
|
|
|
jmp .common
|
|
|
|
|
.set:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov [edi + WDATA.draw_bgr_x], eax
|
|
|
|
|
mov [edi + WDATA.draw_bgr_y], edx
|
2013-05-27 18:49:46 +02:00
|
|
|
|
.common:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov eax, [edi + WDATA.thread]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jz @f
|
|
|
|
|
or [eax + APPDATA.occurred_events], EVENT_BACKGROUND
|
|
|
|
|
@@:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
loop set_bgr_event
|
2012-03-27 22:02:50 +02:00
|
|
|
|
pop edi ecx
|
|
|
|
|
;--------- set event 5 stop -----------
|
2016-10-10 13:31:49 +02:00
|
|
|
|
dec [REDRAW_BACKGROUND] ; got new update request?
|
2013-05-27 18:49:46 +02:00
|
|
|
|
jnz backgr
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2013-05-27 18:49:46 +02:00
|
|
|
|
xor eax, eax
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [background_window + WDATA.draw_data.left], eax
|
|
|
|
|
mov [background_window + WDATA.draw_data.top], eax
|
|
|
|
|
mov [background_window + WDATA.draw_data.right], eax
|
|
|
|
|
mov [background_window + WDATA.draw_data.bottom], eax
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
nobackgr:
|
2012-03-27 22:02:50 +02:00
|
|
|
|
; system shutdown request
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp [SYS_SHUTDOWN], byte 0
|
|
|
|
|
je noshutdown
|
|
|
|
|
|
|
|
|
|
mov edx, [shutdown_processes]
|
|
|
|
|
|
|
|
|
|
cmp [SYS_SHUTDOWN], dl
|
2013-03-04 14:58:55 +01:00
|
|
|
|
jne noshutdown
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
lea ecx, [edx-1]
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov edx, SLOT_BASE + sizeof.APPDATA*2 ;OS_BASE+0x3040
|
2013-03-04 14:58:55 +01:00
|
|
|
|
jecxz no_mark_system_shutdown
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
markz:
|
2013-02-28 23:03:45 +01:00
|
|
|
|
push ecx edx
|
2022-02-09 18:07:51 +01:00
|
|
|
|
cmp [edx + APPDATA.state], TSTATE_FREE
|
2013-03-04 14:58:55 +01:00
|
|
|
|
jz .nokill
|
2022-02-12 18:27:41 +01:00
|
|
|
|
cmp [edx + APPDATA.process], sys_proc
|
2013-03-04 14:58:55 +01:00
|
|
|
|
jz .nokill
|
2013-02-28 23:03:45 +01:00
|
|
|
|
call request_terminate
|
2013-03-04 14:58:55 +01:00
|
|
|
|
jmp .common
|
|
|
|
|
.nokill:
|
|
|
|
|
dec byte [SYS_SHUTDOWN]
|
|
|
|
|
xor eax, eax
|
|
|
|
|
.common:
|
2013-02-28 23:03:45 +01:00
|
|
|
|
pop edx ecx
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz @f
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov [edx + APPDATA.state], TSTATE_ZOMBIE
|
2013-02-28 23:03:45 +01:00
|
|
|
|
@@:
|
2022-02-09 18:07:51 +01:00
|
|
|
|
add edx, sizeof.APPDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
loop markz
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
2012-03-27 22:02:50 +02:00
|
|
|
|
no_mark_system_shutdown:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec byte [SYS_SHUTDOWN]
|
|
|
|
|
je system_shutdown
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
noshutdown:
|
2021-06-16 12:04:10 +02:00
|
|
|
|
mov eax, [thread_count] ; termination
|
2022-02-09 18:07:51 +01:00
|
|
|
|
mov ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov esi, 1
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
newct:
|
|
|
|
|
mov cl, [ebx]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
cmp cl, TSTATE_ZOMBIE
|
2013-03-04 14:58:55 +01:00
|
|
|
|
jz .terminate
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2022-02-12 18:27:41 +01:00
|
|
|
|
cmp cl, TSTATE_TERMINATING
|
2013-03-04 14:58:55 +01:00
|
|
|
|
jnz .noterminate
|
|
|
|
|
.terminate:
|
2013-05-04 00:00:44 +02:00
|
|
|
|
pushad
|
2023-09-22 18:31:40 +02:00
|
|
|
|
push esi
|
|
|
|
|
mov ecx, dword[ebx - APPDATA.state + APPDATA.window]
|
2013-05-04 00:00:44 +02:00
|
|
|
|
call restore_default_cursor_before_killing
|
|
|
|
|
|
2023-09-22 18:31:40 +02:00
|
|
|
|
pop esi
|
2013-03-04 14:58:55 +01:00
|
|
|
|
call terminate
|
|
|
|
|
popad
|
|
|
|
|
cmp byte [SYS_SHUTDOWN], 0
|
|
|
|
|
jz .noterminate
|
|
|
|
|
dec byte [SYS_SHUTDOWN]
|
|
|
|
|
je system_shutdown
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2013-03-04 14:58:55 +01:00
|
|
|
|
.noterminate:
|
2022-02-09 18:07:51 +01:00
|
|
|
|
add ebx, sizeof.APPDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
inc esi
|
|
|
|
|
dec eax
|
|
|
|
|
jnz newct
|
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2023-09-22 18:31:40 +02:00
|
|
|
|
; eax - ptr to WDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
redrawscreen:
|
|
|
|
|
; eax , if process window_data base is eax, do not set flag/limits
|
|
|
|
|
|
|
|
|
|
pushad
|
|
|
|
|
push eax
|
|
|
|
|
|
|
|
|
|
;;; mov ebx,2
|
|
|
|
|
;;; call delay_hs
|
|
|
|
|
|
|
|
|
|
;mov ecx,0 ; redraw flags for apps
|
|
|
|
|
xor ecx, ecx
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
newdw2:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
inc ecx
|
|
|
|
|
push ecx
|
|
|
|
|
|
|
|
|
|
mov eax, ecx
|
2022-02-12 18:27:41 +01:00
|
|
|
|
shl eax, BSF sizeof.WDATA
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add eax, window_data
|
|
|
|
|
|
|
|
|
|
cmp eax, [esp+4]
|
|
|
|
|
je not_this_task
|
|
|
|
|
; check if window in redraw area
|
|
|
|
|
mov edi, eax
|
|
|
|
|
|
|
|
|
|
cmp ecx, 1 ; limit for background
|
|
|
|
|
jz bgli
|
|
|
|
|
|
2015-10-31 22:43:10 +01:00
|
|
|
|
mov eax, [esp+4] ;if upper in z-position - no redraw
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz @f
|
|
|
|
|
mov al, [eax + WDATA.z_modif]
|
|
|
|
|
cmp [edi + WDATA.z_modif], al
|
|
|
|
|
jg ricino
|
|
|
|
|
@@:
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, [edi + WDATA.box.left]
|
|
|
|
|
mov ebx, [edi + WDATA.box.top]
|
|
|
|
|
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp ebx, [draw_limits.bottom] ; ecx = area y end ebx = window y start
|
|
|
|
|
jae ricino
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp eax, [draw_limits.right] ; ecx = area x end eax = window x start
|
|
|
|
|
jae ricino
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, [edi + WDATA.box.left]
|
|
|
|
|
mov ebx, [edi + WDATA.box.top]
|
|
|
|
|
mov ecx, [edi + WDATA.box.width]
|
|
|
|
|
mov edx, [edi + WDATA.box.height]
|
|
|
|
|
add ecx, eax
|
|
|
|
|
add edx, ebx
|
|
|
|
|
|
|
|
|
|
mov eax, [draw_limits.top] ; eax = area y start edx = window y end
|
|
|
|
|
cmp edx, eax
|
|
|
|
|
jb ricino
|
|
|
|
|
|
|
|
|
|
mov eax, [draw_limits.left] ; eax = area x start ecx = window x end
|
|
|
|
|
cmp ecx, eax
|
|
|
|
|
jb ricino
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
bgli:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp dword[esp], 1 ; check index in window_data array, 1 - idle
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jnz .az
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2016-10-10 13:31:49 +02:00
|
|
|
|
cmp [REDRAW_BACKGROUND], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jz .az
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov dl, 0
|
|
|
|
|
mov ebx, [draw_limits.left]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
cmp ebx, [edi + WDATA.draw_data.left]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jae @f
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.left], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov dl, 1
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, [draw_limits.top]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
cmp ebx, [edi + WDATA.draw_data.top]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jae @f
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.top], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov dl, 1
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, [draw_limits.right]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
cmp ebx, [edi + WDATA.draw_data.right]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jbe @f
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.right], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov dl, 1
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, [draw_limits.bottom]
|
2023-08-18 22:51:33 +02:00
|
|
|
|
cmp ebx, [edi + WDATA.draw_data.bottom]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jbe @f
|
2012-03-27 22:02:50 +02:00
|
|
|
|
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.bottom], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov dl, 1
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
2016-10-10 13:31:49 +02:00
|
|
|
|
add [REDRAW_BACKGROUND], dl
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jmp newdw8
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.az:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, [draw_limits.left] ; set limits
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.left], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, [draw_limits.top]
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.top], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, [draw_limits.right]
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.right], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, [draw_limits.bottom]
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov [edi + WDATA.draw_data.bottom], ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2023-09-22 18:31:40 +02:00
|
|
|
|
cmp dword [esp], 1 ; check idle thread
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jne nobgrd
|
2016-10-10 13:31:49 +02:00
|
|
|
|
inc [REDRAW_BACKGROUND]
|
2013-05-27 11:02:35 +02:00
|
|
|
|
call wakeup_osloop
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
newdw8:
|
|
|
|
|
nobgrd:
|
2013-09-29 05:39:30 +02:00
|
|
|
|
;--------------------------------------
|
2023-09-22 18:31:40 +02:00
|
|
|
|
push edi ebp
|
|
|
|
|
mov edi, [esp+8]
|
2013-09-29 05:39:30 +02:00
|
|
|
|
cmp edi, 1
|
|
|
|
|
je .found
|
|
|
|
|
|
|
|
|
|
mov eax, [draw_limits.left]
|
|
|
|
|
mov ebx, [draw_limits.top]
|
|
|
|
|
mov ecx, [draw_limits.right]
|
|
|
|
|
sub ecx, eax
|
|
|
|
|
test ecx, ecx
|
|
|
|
|
jz .not_found
|
|
|
|
|
|
|
|
|
|
mov edx, [draw_limits.bottom]
|
|
|
|
|
sub edx, ebx
|
|
|
|
|
test edx, edx
|
|
|
|
|
jz .not_found
|
|
|
|
|
|
|
|
|
|
; eax - x, ebx - y
|
|
|
|
|
; ecx - size x, edx - size y
|
|
|
|
|
add ebx, edx
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.start_y:
|
|
|
|
|
push ecx
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.start_x:
|
|
|
|
|
add eax, ecx
|
|
|
|
|
mov ebp, [d_width_calc_area + ebx*4]
|
2015-01-05 18:59:03 +01:00
|
|
|
|
add ebp, [_display.win_map]
|
2013-09-29 05:39:30 +02:00
|
|
|
|
movzx ebp, byte[eax+ebp] ; get value for current point
|
|
|
|
|
cmp ebp, edi
|
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
|
|
pop ecx
|
|
|
|
|
jmp .found
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
|
|
|
|
sub eax, ecx
|
|
|
|
|
|
|
|
|
|
dec ecx
|
2021-10-18 18:23:18 +02:00
|
|
|
|
jns .start_x
|
2013-09-29 05:39:30 +02:00
|
|
|
|
|
|
|
|
|
pop ecx
|
|
|
|
|
dec ebx
|
|
|
|
|
dec edx
|
2021-10-18 18:23:18 +02:00
|
|
|
|
jns .start_y
|
2013-09-29 05:39:30 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.not_found:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
pop ebp edi
|
2013-09-29 05:39:30 +02:00
|
|
|
|
jmp ricino
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.found:
|
2023-09-22 18:31:40 +02:00
|
|
|
|
pop ebp edi
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2023-09-22 18:31:40 +02:00
|
|
|
|
mov [edi + WDATA.fl_redraw], WSTATE_REDRAW ; mark as redraw
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
ricino:
|
|
|
|
|
not_this_task:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop ecx
|
|
|
|
|
|
2021-06-16 12:04:10 +02:00
|
|
|
|
cmp ecx, [thread_count]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jle newdw2
|
|
|
|
|
|
|
|
|
|
pop eax
|
|
|
|
|
popad
|
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
calculatebackground: ; background
|
2015-01-05 18:59:03 +01:00
|
|
|
|
mov edi, [_display.win_map] ; set os to use all pixels
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, 0x01010101
|
2015-01-05 18:59:03 +01:00
|
|
|
|
mov ecx, [_display.win_map_size]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr ecx, 2
|
|
|
|
|
rep stosd
|
2023-08-18 22:51:33 +02:00
|
|
|
|
mov byte[background_window + WDATA.z_modif], ZPOS_DESKTOP
|
2016-10-10 13:31:49 +02:00
|
|
|
|
mov [REDRAW_BACKGROUND], 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
uglobal
|
|
|
|
|
imax dd 0x0
|
|
|
|
|
endg
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
delay_ms: ; delay in 1/1000 sec
|
2020-11-05 20:53:54 +01:00
|
|
|
|
pushad
|
|
|
|
|
|
|
|
|
|
cmp [hpet_base], 0
|
|
|
|
|
jz .no_hpet
|
|
|
|
|
mov eax, esi
|
2020-11-11 23:28:04 +01:00
|
|
|
|
mov edx, 1_000_000 ; ms to ns
|
2020-11-05 20:53:54 +01:00
|
|
|
|
mul edx
|
|
|
|
|
mov ebx, edx
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
|
|
|
|
|
push ecx
|
|
|
|
|
call get_clock_ns
|
|
|
|
|
pop ecx
|
|
|
|
|
mov edi, edx
|
|
|
|
|
mov esi, eax
|
|
|
|
|
.wait:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push ecx
|
2020-11-05 20:53:54 +01:00
|
|
|
|
call get_clock_ns
|
|
|
|
|
pop ecx
|
|
|
|
|
sub eax, esi
|
|
|
|
|
sbb edx, edi
|
|
|
|
|
sub eax, ecx
|
|
|
|
|
sbb edx, ebx
|
|
|
|
|
jc .wait
|
|
|
|
|
jmp .done
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2020-11-05 20:53:54 +01:00
|
|
|
|
.no_hpet:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ecx, esi
|
|
|
|
|
; <CPU clock fix by Sergey Kuzmin aka Wildwest>
|
|
|
|
|
imul ecx, 33941
|
|
|
|
|
shr ecx, 9
|
|
|
|
|
; </CPU clock fix>
|
|
|
|
|
|
|
|
|
|
in al, 0x61
|
|
|
|
|
and al, 0x10
|
|
|
|
|
mov ah, al
|
|
|
|
|
cld
|
2020-11-05 20:53:54 +01:00
|
|
|
|
|
|
|
|
|
.cnt1:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
in al, 0x61
|
|
|
|
|
and al, 0x10
|
|
|
|
|
cmp al, ah
|
2020-11-05 20:53:54 +01:00
|
|
|
|
jz .cnt1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov ah, al
|
2020-11-05 20:53:54 +01:00
|
|
|
|
loop .cnt1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2020-11-05 20:53:54 +01:00
|
|
|
|
.done:
|
|
|
|
|
popad
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2012-02-27 08:04:31 +01:00
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
set_app_param:
|
2022-01-10 23:29:14 +01:00
|
|
|
|
mov edi, [current_slot]
|
2022-01-11 21:38:19 +01:00
|
|
|
|
xchg ebx, [edi + APPDATA.event_mask] ; set new event mask
|
2023-01-30 04:33:03 +01:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], ebx ; return old mask value
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2013-03-01 11:27:19 +01:00
|
|
|
|
|
|
|
|
|
; this is for syscall
|
|
|
|
|
proc delay_hs_unprotected
|
|
|
|
|
call unprotect_from_terminate
|
|
|
|
|
call delay_hs
|
|
|
|
|
call protect_from_terminate
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2013-06-04 10:04:42 +02:00
|
|
|
|
if 1
|
2012-03-27 22:02:50 +02:00
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
delay_hs: ; delay in 1/100 secs
|
|
|
|
|
; ebx = delay time
|
2013-06-03 21:47:50 +02:00
|
|
|
|
pushad
|
|
|
|
|
push ebx
|
|
|
|
|
xor esi, esi
|
|
|
|
|
mov ecx, MANUAL_DESTROY
|
|
|
|
|
call create_event
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .done
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2013-06-03 21:47:50 +02:00
|
|
|
|
mov ebx, edx
|
|
|
|
|
mov ecx, [esp]
|
2013-06-04 10:04:42 +02:00
|
|
|
|
push edx
|
2013-06-03 21:47:50 +02:00
|
|
|
|
push eax
|
|
|
|
|
call wait_event_timeout
|
|
|
|
|
pop eax
|
2013-06-04 10:04:42 +02:00
|
|
|
|
pop ebx
|
2013-06-03 21:47:50 +02:00
|
|
|
|
call destroy_event
|
|
|
|
|
.done:
|
|
|
|
|
add esp, 4
|
|
|
|
|
popad
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2013-06-03 22:16:51 +02:00
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
delay_hs: ; delay in 1/100 secs
|
|
|
|
|
; ebx = delay time
|
|
|
|
|
push ecx
|
|
|
|
|
push edx
|
|
|
|
|
|
|
|
|
|
mov edx, [timer_ticks]
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.newtic:
|
2013-06-03 22:16:51 +02:00
|
|
|
|
mov ecx, [timer_ticks]
|
|
|
|
|
sub ecx, edx
|
|
|
|
|
cmp ecx, ebx
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jae .zerodelay
|
2013-06-03 22:16:51 +02:00
|
|
|
|
|
|
|
|
|
call change_task
|
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jmp .newtic
|
2013-06-03 22:16:51 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.zerodelay:
|
2013-06-03 22:16:51 +02:00
|
|
|
|
pop edx
|
|
|
|
|
pop ecx
|
|
|
|
|
ret
|
|
|
|
|
end if
|
|
|
|
|
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16 ;very often call this subrutine
|
|
|
|
|
memmove: ; memory move in bytes
|
|
|
|
|
; eax = from
|
|
|
|
|
; ebx = to
|
|
|
|
|
; ecx = no of bytes
|
|
|
|
|
test ecx, ecx
|
|
|
|
|
jle .ret
|
|
|
|
|
|
|
|
|
|
push esi edi ecx
|
|
|
|
|
|
|
|
|
|
mov edi, ebx
|
|
|
|
|
mov esi, eax
|
|
|
|
|
|
|
|
|
|
test ecx, not 11b
|
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
|
|
push ecx
|
|
|
|
|
shr ecx, 2
|
|
|
|
|
rep movsd
|
|
|
|
|
pop ecx
|
|
|
|
|
and ecx, 11b
|
|
|
|
|
jz .finish
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rep movsb
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.finish:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop ecx edi esi
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.ret:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-27 22:02:50 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2022-03-18 05:09:59 +01:00
|
|
|
|
; in: eax = port
|
|
|
|
|
; ebp = subfunction
|
|
|
|
|
; 0 - set access
|
|
|
|
|
; 1 - clear access
|
|
|
|
|
; out: not return value
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
set_io_access_rights:
|
|
|
|
|
push edi eax
|
|
|
|
|
mov edi, tss._io_map_0
|
2022-03-19 17:20:29 +01:00
|
|
|
|
|
2022-03-18 05:09:59 +01:00
|
|
|
|
test ebp, ebp ; enable access - ebp = 0
|
2011-10-14 23:38:50 +02:00
|
|
|
|
jnz .siar1
|
2022-03-19 17:20:29 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
btr [edi], eax
|
|
|
|
|
pop eax edi
|
|
|
|
|
ret
|
|
|
|
|
.siar1:
|
2022-03-18 05:09:59 +01:00
|
|
|
|
bts [edi], eax ; disable access - ebp = 1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop eax edi
|
|
|
|
|
ret
|
2021-11-16 19:54:17 +01:00
|
|
|
|
|
|
|
|
|
align 4
|
2022-03-19 17:20:29 +01:00
|
|
|
|
; @brief ReservePortArea and FreePortArea
|
|
|
|
|
; @param edx number end arrea of ports (include last number of port)
|
|
|
|
|
; @param ecx number start arrea of ports
|
|
|
|
|
; @param ebx sub function 0 - reserve, 1 - free
|
|
|
|
|
; @param eax 46 - number function
|
|
|
|
|
; @returns eax = 0 - succesful eax = 1 - error
|
|
|
|
|
syscall_reserveportarea: ; ReservePortArea and FreePortArea
|
2021-11-16 19:54:17 +01:00
|
|
|
|
|
|
|
|
|
call r_f_port_area
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2021-11-16 19:54:17 +01:00
|
|
|
|
ret
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;reserve/free group of ports
|
|
|
|
|
; * eax = 46 - number function
|
|
|
|
|
; * ebx = 0 - reserve, 1 - free
|
|
|
|
|
; * ecx = number start arrea of ports
|
|
|
|
|
; * edx = number end arrea of ports (include last number of port)
|
|
|
|
|
;Return value:
|
|
|
|
|
; * eax = 0 - succesful
|
|
|
|
|
; * eax = 1 - error
|
|
|
|
|
; * The system has reserve this ports:
|
|
|
|
|
; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port).
|
|
|
|
|
;destroys eax,ebx, ebp
|
|
|
|
|
r_f_port_area:
|
|
|
|
|
|
|
|
|
|
test ebx, ebx
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jnz .free_port_area
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
cmp ecx, edx ; beginning > end ?
|
2023-06-17 20:40:54 +02:00
|
|
|
|
ja .err
|
2022-03-19 17:20:29 +01:00
|
|
|
|
cmp edx, 65536 ;test ebx, not 0xffff
|
2023-06-17 20:40:54 +02:00
|
|
|
|
jae .err
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, [RESERVED_PORTS]
|
|
|
|
|
test eax, eax ; no reserved areas ?
|
2023-04-08 23:24:05 +02:00
|
|
|
|
je .rpal2
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp eax, 255 ; max reserved
|
2023-06-17 20:40:54 +02:00
|
|
|
|
jae .err
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.rpal3:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebx, eax
|
2022-03-19 17:20:29 +01:00
|
|
|
|
shl ebx, 4 ;16 byte is sizeof item in RESERVED_PORTS table
|
2011-10-14 23:38:50 +02:00
|
|
|
|
add ebx, RESERVED_PORTS
|
|
|
|
|
cmp ecx, [ebx+8]
|
2023-04-08 23:24:05 +02:00
|
|
|
|
ja .rpal4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp edx, [ebx+4]
|
2023-06-17 20:40:54 +02:00
|
|
|
|
jae .err
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.rpal4:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec eax
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jnz .rpal3
|
|
|
|
|
jmp .rpal2
|
2023-06-17 20:40:54 +02:00
|
|
|
|
.err:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2023-06-17 20:40:54 +02:00
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.rpal2:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; enable port access at port IO map
|
|
|
|
|
pushad ; start enable io map
|
|
|
|
|
mov eax, ecx
|
|
|
|
|
xor ebp, ebp ; enable - eax = port
|
2022-03-18 05:09:59 +01:00
|
|
|
|
cli
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.new_port_access:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call set_io_access_rights
|
2022-03-18 05:09:59 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
inc eax
|
|
|
|
|
cmp eax, edx
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jbe .new_port_access
|
2023-06-17 20:40:54 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sti
|
2022-03-18 05:09:59 +01:00
|
|
|
|
popad ; end enable io map
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, [RESERVED_PORTS]
|
2022-03-18 05:09:59 +01:00
|
|
|
|
inc eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [RESERVED_PORTS], eax
|
|
|
|
|
shl eax, 4
|
|
|
|
|
add eax, RESERVED_PORTS
|
2022-02-06 21:33:29 +01:00
|
|
|
|
mov ebx, [current_slot]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov ebx, [ebx + APPDATA.tid]
|
2022-03-19 17:20:29 +01:00
|
|
|
|
mov [eax], ebx ; tid
|
|
|
|
|
mov [eax+4], ecx ;start port
|
|
|
|
|
mov [eax+8], edx ;finish port
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
|
|
|
|
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.free_port_area:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, [RESERVED_PORTS]; no reserved areas ?
|
|
|
|
|
test eax, eax
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jz .frpal2
|
2022-02-06 21:33:29 +01:00
|
|
|
|
mov ebx, [current_slot]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov ebx, [ebx + APPDATA.tid]
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.frpal3:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov edi, eax
|
|
|
|
|
shl edi, 4
|
|
|
|
|
add edi, RESERVED_PORTS
|
|
|
|
|
cmp ebx, [edi]
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .frpal4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ecx, [edi+4]
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .frpal4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp edx, [edi+8]
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .frpal4
|
|
|
|
|
jmp .frpal1
|
|
|
|
|
.frpal4:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
dec eax
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jnz .frpal3
|
|
|
|
|
.frpal2:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
inc eax
|
|
|
|
|
ret
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.frpal1:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push ecx
|
|
|
|
|
mov ecx, 256
|
|
|
|
|
sub ecx, eax
|
|
|
|
|
shl ecx, 4
|
|
|
|
|
mov esi, edi
|
|
|
|
|
add esi, 16
|
|
|
|
|
cld
|
|
|
|
|
rep movsb
|
|
|
|
|
|
|
|
|
|
dec dword [RESERVED_PORTS]
|
|
|
|
|
;disable port access at port IO map
|
2022-03-18 05:09:59 +01:00
|
|
|
|
; start disable io map
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop eax ;start port
|
2022-03-18 05:09:59 +01:00
|
|
|
|
;cmp edx, 65536
|
|
|
|
|
;jge no_mask_io
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
xor ebp, ebp
|
|
|
|
|
inc ebp
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.new_port_access_disable: ; disable - eax = port
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call set_io_access_rights
|
2022-03-18 05:09:59 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
inc eax
|
|
|
|
|
cmp eax, edx
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jbe .new_port_access_disable
|
2023-06-17 20:40:54 +02:00
|
|
|
|
; end disable io map
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
drawbackground:
|
|
|
|
|
cmp [BgrDrawMode], dword 1
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jne .bgrstr
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call vesa20_drawbackground_tiled
|
2012-03-12 19:26:37 +01:00
|
|
|
|
call __sys_draw_pointer
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.bgrstr:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call vesa20_drawbackground_stretch
|
2012-03-12 19:26:37 +01:00
|
|
|
|
call __sys_draw_pointer
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
syscall_putimage: ; PutImage
|
2021-05-09 16:02:32 +02:00
|
|
|
|
; add check pointer
|
|
|
|
|
push ecx
|
|
|
|
|
mov ax, cx
|
|
|
|
|
shr ecx, 16
|
|
|
|
|
imul eax, ecx
|
|
|
|
|
lea eax, [eax*3]
|
|
|
|
|
stdcall is_region_userspace, ebx, eax
|
|
|
|
|
pop ecx
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jnz sys_putimage.exit
|
2021-05-09 16:02:32 +02:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sys_putimage:
|
|
|
|
|
test ecx, 0x80008000
|
|
|
|
|
jnz .exit
|
|
|
|
|
test ecx, 0x0000FFFF
|
|
|
|
|
jz .exit
|
|
|
|
|
test ecx, 0xFFFF0000
|
|
|
|
|
jnz @f
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.exit:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
@@:
|
2023-10-12 23:52:14 +02:00
|
|
|
|
mov edi, [current_slot]
|
2023-10-23 14:53:06 +02:00
|
|
|
|
mov edi, [edi + APPDATA.window]
|
2023-10-12 23:52:14 +02:00
|
|
|
|
add dx, word[edi + WDATA.clientbox.top]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rol edx, 16
|
2023-10-12 23:52:14 +02:00
|
|
|
|
add dx, word[edi + WDATA.clientbox.left]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rol edx, 16
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.forced:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
push ebp esi 0
|
|
|
|
|
mov ebp, putimage_get24bpp
|
|
|
|
|
mov esi, putimage_init24bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
sys_putimage_bpp:
|
2012-03-07 16:50:41 +01:00
|
|
|
|
call vesa20_putimage
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop ebp esi ebp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
ret
|
|
|
|
|
; jmp [draw_pointer]
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
sys_putimage_palette:
|
|
|
|
|
; ebx = pointer to image
|
|
|
|
|
; ecx = [xsize]*65536 + [ysize]
|
|
|
|
|
; edx = [xstart]*65536 + [ystart]
|
|
|
|
|
; esi = number of bits per pixel, must be 8, 24 or 32
|
|
|
|
|
; edi = pointer to palette
|
|
|
|
|
; ebp = row delta
|
2021-05-09 16:17:55 +02:00
|
|
|
|
; check pointer
|
2023-04-08 23:24:05 +02:00
|
|
|
|
push ecx esi
|
2021-05-09 16:17:55 +02:00
|
|
|
|
mov ax, cx
|
|
|
|
|
shr ecx, 16
|
|
|
|
|
imul eax, ecx
|
2023-04-08 23:24:05 +02:00
|
|
|
|
; imul eax, esi ; eax*count bit in 1 pixel
|
|
|
|
|
; shr eax, 3
|
2021-05-09 16:17:55 +02:00
|
|
|
|
stdcall is_region_userspace, ebx, eax
|
2023-04-08 23:24:05 +02:00
|
|
|
|
pop esi ecx
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jnz sys_putimage.exit
|
2021-05-09 16:17:55 +02:00
|
|
|
|
|
2023-10-23 14:53:06 +02:00
|
|
|
|
mov eax, [current_slot]
|
|
|
|
|
mov eax, [eax + APPDATA.window]
|
|
|
|
|
add dx, word [eax + WDATA.clientbox.top]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rol edx, 16
|
2023-10-23 14:53:06 +02:00
|
|
|
|
add dx, word [eax + WDATA.clientbox.left]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rol edx, 16
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.forced:
|
|
|
|
|
cmp esi, 1
|
|
|
|
|
jnz @f
|
|
|
|
|
push edi
|
|
|
|
|
mov eax, [edi+4]
|
|
|
|
|
sub eax, [edi]
|
|
|
|
|
push eax
|
|
|
|
|
push dword [edi]
|
|
|
|
|
push 0ffffff80h
|
|
|
|
|
mov edi, esp
|
|
|
|
|
call put_mono_image
|
|
|
|
|
add esp, 12
|
|
|
|
|
pop edi
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
cmp esi, 2
|
|
|
|
|
jnz @f
|
|
|
|
|
push edi
|
|
|
|
|
push 0ffffff80h
|
|
|
|
|
mov edi, esp
|
|
|
|
|
call put_2bit_image
|
|
|
|
|
pop eax
|
|
|
|
|
pop edi
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
cmp esi, 4
|
|
|
|
|
jnz @f
|
|
|
|
|
push edi
|
|
|
|
|
push 0ffffff80h
|
|
|
|
|
mov edi, esp
|
|
|
|
|
call put_4bit_image
|
|
|
|
|
pop eax
|
|
|
|
|
pop edi
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
push ebp esi ebp
|
|
|
|
|
cmp esi, 8
|
|
|
|
|
jnz @f
|
|
|
|
|
mov ebp, putimage_get8bpp
|
|
|
|
|
mov esi, putimage_init8bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2012-06-03 15:57:12 +02:00
|
|
|
|
@@:
|
|
|
|
|
cmp esi, 9
|
|
|
|
|
jnz @f
|
|
|
|
|
mov ebp, putimage_get9bpp
|
|
|
|
|
mov esi, putimage_init9bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
cmp esi, 15
|
|
|
|
|
jnz @f
|
|
|
|
|
mov ebp, putimage_get15bpp
|
|
|
|
|
mov esi, putimage_init15bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
cmp esi, 16
|
|
|
|
|
jnz @f
|
|
|
|
|
mov ebp, putimage_get16bpp
|
|
|
|
|
mov esi, putimage_init16bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
cmp esi, 24
|
|
|
|
|
jnz @f
|
|
|
|
|
mov ebp, putimage_get24bpp
|
|
|
|
|
mov esi, putimage_init24bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
cmp esi, 32
|
|
|
|
|
jnz @f
|
|
|
|
|
mov ebp, putimage_get32bpp
|
|
|
|
|
mov esi, putimage_init32bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
@@:
|
|
|
|
|
pop ebp esi ebp
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
put_mono_image:
|
|
|
|
|
push ebp esi ebp
|
|
|
|
|
mov ebp, putimage_get1bpp
|
|
|
|
|
mov esi, putimage_init1bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
put_2bit_image:
|
|
|
|
|
push ebp esi ebp
|
|
|
|
|
mov ebp, putimage_get2bpp
|
|
|
|
|
mov esi, putimage_init2bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
put_4bit_image:
|
|
|
|
|
push ebp esi ebp
|
|
|
|
|
mov ebp, putimage_get4bpp
|
|
|
|
|
mov esi, putimage_init4bpp
|
|
|
|
|
jmp sys_putimage_bpp
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
putimage_init24bpp:
|
|
|
|
|
lea eax, [eax*3]
|
|
|
|
|
putimage_init8bpp:
|
2012-06-03 15:57:12 +02:00
|
|
|
|
putimage_init9bpp:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get24bpp:
|
|
|
|
|
movzx eax, byte [esi+2]
|
|
|
|
|
shl eax, 16
|
|
|
|
|
mov ax, [esi]
|
|
|
|
|
add esi, 3
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get8bpp:
|
|
|
|
|
movzx eax, byte [esi]
|
|
|
|
|
push edx
|
|
|
|
|
mov edx, [esp+8]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [edx + eax*4]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop edx
|
|
|
|
|
inc esi
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2012-06-03 15:57:12 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get9bpp:
|
|
|
|
|
lodsb
|
|
|
|
|
mov ah, al
|
|
|
|
|
shl eax, 8
|
|
|
|
|
mov al, ah
|
|
|
|
|
ret 4
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2012-03-07 16:50:41 +01:00
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
putimage_init1bpp:
|
|
|
|
|
add eax, ecx
|
|
|
|
|
push ecx
|
|
|
|
|
add eax, 7
|
|
|
|
|
add ecx, 7
|
|
|
|
|
shr eax, 3
|
|
|
|
|
shr ecx, 3
|
|
|
|
|
sub eax, ecx
|
|
|
|
|
pop ecx
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get1bpp:
|
|
|
|
|
push edx
|
|
|
|
|
mov edx, [esp+8]
|
|
|
|
|
mov al, [edx]
|
|
|
|
|
add al, al
|
|
|
|
|
jnz @f
|
|
|
|
|
lodsb
|
|
|
|
|
adc al, al
|
|
|
|
|
@@:
|
|
|
|
|
mov [edx], al
|
|
|
|
|
sbb eax, eax
|
|
|
|
|
and eax, [edx+8]
|
|
|
|
|
add eax, [edx+4]
|
|
|
|
|
pop edx
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
putimage_init2bpp:
|
|
|
|
|
add eax, ecx
|
|
|
|
|
push ecx
|
|
|
|
|
add ecx, 3
|
|
|
|
|
add eax, 3
|
|
|
|
|
shr ecx, 2
|
|
|
|
|
shr eax, 2
|
|
|
|
|
sub eax, ecx
|
|
|
|
|
pop ecx
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get2bpp:
|
|
|
|
|
push edx
|
|
|
|
|
mov edx, [esp+8]
|
|
|
|
|
mov al, [edx]
|
|
|
|
|
mov ah, al
|
|
|
|
|
shr al, 6
|
|
|
|
|
shl ah, 2
|
|
|
|
|
jnz .nonewbyte
|
|
|
|
|
lodsb
|
|
|
|
|
mov ah, al
|
|
|
|
|
shr al, 6
|
|
|
|
|
shl ah, 2
|
|
|
|
|
add ah, 1
|
|
|
|
|
.nonewbyte:
|
|
|
|
|
mov [edx], ah
|
|
|
|
|
mov edx, [edx+4]
|
|
|
|
|
movzx eax, al
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [edx + eax*4]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop edx
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
putimage_init4bpp:
|
|
|
|
|
add eax, ecx
|
|
|
|
|
push ecx
|
|
|
|
|
add ecx, 1
|
2021-11-14 20:15:56 +01:00
|
|
|
|
inc eax ;add eax, 1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr ecx, 1
|
|
|
|
|
shr eax, 1
|
|
|
|
|
sub eax, ecx
|
|
|
|
|
pop ecx
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get4bpp:
|
|
|
|
|
push edx
|
|
|
|
|
mov edx, [esp+8]
|
|
|
|
|
add byte [edx], 80h
|
|
|
|
|
jc @f
|
|
|
|
|
movzx eax, byte [edx+1]
|
|
|
|
|
mov edx, [edx+4]
|
|
|
|
|
and eax, 0x0F
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [edx + eax*4]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop edx
|
|
|
|
|
ret 4
|
|
|
|
|
@@:
|
|
|
|
|
movzx eax, byte [esi]
|
|
|
|
|
add esi, 1
|
|
|
|
|
mov [edx+1], al
|
|
|
|
|
shr eax, 4
|
|
|
|
|
mov edx, [edx+4]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov eax, [edx + eax*4]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
pop edx
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
putimage_init32bpp:
|
|
|
|
|
shl eax, 2
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get32bpp:
|
|
|
|
|
lodsd
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
putimage_init15bpp:
|
|
|
|
|
putimage_init16bpp:
|
|
|
|
|
add eax, eax
|
|
|
|
|
ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get15bpp:
|
|
|
|
|
; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000
|
|
|
|
|
push ecx edx
|
|
|
|
|
movzx eax, word [esi]
|
|
|
|
|
add esi, 2
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
mov edx, eax
|
|
|
|
|
and eax, 0x1F
|
|
|
|
|
and ecx, 0x1F shl 5
|
|
|
|
|
and edx, 0x1F shl 10
|
|
|
|
|
shl eax, 3
|
|
|
|
|
shl ecx, 6
|
|
|
|
|
shl edx, 9
|
|
|
|
|
or eax, ecx
|
|
|
|
|
or eax, edx
|
|
|
|
|
pop edx ecx
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 16
|
|
|
|
|
putimage_get16bpp:
|
|
|
|
|
; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000
|
|
|
|
|
push ecx edx
|
|
|
|
|
movzx eax, word [esi]
|
|
|
|
|
add esi, 2
|
|
|
|
|
mov ecx, eax
|
|
|
|
|
mov edx, eax
|
|
|
|
|
and eax, 0x1F
|
|
|
|
|
and ecx, 0x3F shl 5
|
|
|
|
|
and edx, 0x1F shl 11
|
|
|
|
|
shl eax, 3
|
|
|
|
|
shl ecx, 5
|
|
|
|
|
shl edx, 8
|
|
|
|
|
or eax, ecx
|
|
|
|
|
or eax, edx
|
|
|
|
|
pop edx ecx
|
|
|
|
|
ret 4
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
;align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
; eax x beginning
|
|
|
|
|
; ebx y beginning
|
|
|
|
|
; ecx x end
|
|
|
|
|
; edx y end
|
|
|
|
|
; edi color
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;__sys_drawbar:
|
2023-10-23 14:53:06 +02:00
|
|
|
|
; mov esi, [current_slot]
|
|
|
|
|
; mov esi, [esi + APPDATA.window]
|
|
|
|
|
; add eax, [esi + WDATA.clientbox.left]
|
|
|
|
|
; add ecx, [esi + WDATA.clientbox.left]
|
|
|
|
|
; add ebx, [esi + WDATA.clientbox.top]
|
|
|
|
|
; add edx, [esi + WDATA.clientbox.top]
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
;align 4
|
|
|
|
|
;.forced:
|
|
|
|
|
; call vesa20_drawbar
|
2012-02-26 01:26:08 +01:00
|
|
|
|
; call [draw_pointer]
|
|
|
|
|
; ret
|
2012-03-07 16:50:41 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
if used _rdtsc
|
|
|
|
|
_rdtsc:
|
|
|
|
|
bt [cpu_caps], CAPS_TSC
|
2023-04-08 23:24:05 +02:00
|
|
|
|
jnc .ret_rdtsc
|
2011-10-14 23:38:50 +02:00
|
|
|
|
rdtsc
|
|
|
|
|
ret
|
2023-04-08 23:24:05 +02:00
|
|
|
|
.ret_rdtsc:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov edx, 0xffffffff
|
|
|
|
|
mov eax, 0xffffffff
|
|
|
|
|
ret
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
sys_msg_board_str:
|
|
|
|
|
|
|
|
|
|
pushad
|
|
|
|
|
@@:
|
|
|
|
|
cmp [esi], byte 0
|
|
|
|
|
je @f
|
2013-06-07 16:12:54 +02:00
|
|
|
|
mov ebx, 1
|
|
|
|
|
movzx ecx, byte [esi]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call sys_msg_board
|
|
|
|
|
inc esi
|
|
|
|
|
jmp @b
|
|
|
|
|
@@:
|
|
|
|
|
popad
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
sys_msg_board_byte:
|
|
|
|
|
; in: al = byte to display
|
|
|
|
|
; out: nothing
|
|
|
|
|
; destroys: nothing
|
|
|
|
|
pushad
|
|
|
|
|
mov ecx, 2
|
|
|
|
|
shl eax, 24
|
|
|
|
|
jmp @f
|
|
|
|
|
|
|
|
|
|
sys_msg_board_word:
|
|
|
|
|
; in: ax = word to display
|
|
|
|
|
; out: nothing
|
|
|
|
|
; destroys: nothing
|
|
|
|
|
pushad
|
|
|
|
|
mov ecx, 4
|
|
|
|
|
shl eax, 16
|
|
|
|
|
jmp @f
|
|
|
|
|
|
|
|
|
|
sys_msg_board_dword:
|
|
|
|
|
; in: eax = dword to display
|
|
|
|
|
; out: nothing
|
|
|
|
|
; destroys: nothing
|
|
|
|
|
pushad
|
|
|
|
|
mov ecx, 8
|
|
|
|
|
@@:
|
|
|
|
|
push ecx
|
|
|
|
|
rol eax, 4
|
|
|
|
|
push eax
|
|
|
|
|
and al, 0xF
|
|
|
|
|
cmp al, 10
|
|
|
|
|
sbb al, 69h
|
|
|
|
|
das
|
2013-06-07 16:12:54 +02:00
|
|
|
|
mov cl, al
|
|
|
|
|
xor ebx, ebx
|
|
|
|
|
inc ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call sys_msg_board
|
|
|
|
|
pop eax
|
|
|
|
|
pop ecx
|
|
|
|
|
loop @b
|
|
|
|
|
popad
|
|
|
|
|
ret
|
|
|
|
|
|
2013-03-19 18:07:12 +01:00
|
|
|
|
msg_board_data_size = 65536 ; Must be power of two
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
uglobal
|
2016-08-25 21:18:19 +02:00
|
|
|
|
msg_board_data rb msg_board_data_size
|
|
|
|
|
msg_board_count dd ?
|
2011-10-14 23:38:50 +02:00
|
|
|
|
endg
|
|
|
|
|
|
2016-08-25 21:18:19 +02:00
|
|
|
|
iglobal
|
|
|
|
|
msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen
|
|
|
|
|
endg
|
2013-06-07 16:12:54 +02:00
|
|
|
|
|
2016-08-25 21:18:19 +02:00
|
|
|
|
sys_msg_board:
|
|
|
|
|
; ebx=1 -> write, cl = byte to write
|
|
|
|
|
; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al
|
|
|
|
|
push eax ebx
|
2013-06-07 16:12:54 +02:00
|
|
|
|
mov eax, ebx
|
|
|
|
|
mov ebx, ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ecx, [msg_board_count]
|
|
|
|
|
cmp eax, 1
|
2016-08-25 21:18:19 +02:00
|
|
|
|
jne .read
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
if defined debug_com_base
|
|
|
|
|
push dx ax
|
2016-08-25 21:18:19 +02:00
|
|
|
|
@@: ; wait for empty transmit register
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov dx, debug_com_base+5
|
|
|
|
|
in al, dx
|
|
|
|
|
test al, 1 shl 5
|
|
|
|
|
jz @r
|
|
|
|
|
mov dx, debug_com_base ; Output the byte
|
|
|
|
|
mov al, bl
|
|
|
|
|
out dx, al
|
|
|
|
|
pop ax dx
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
mov [msg_board_data+ecx], bl
|
2013-07-08 01:12:01 +02:00
|
|
|
|
cmp byte [debug_direct_print], 1
|
2016-08-25 21:18:19 +02:00
|
|
|
|
jnz .end
|
2013-05-15 18:40:59 +02:00
|
|
|
|
pusha
|
|
|
|
|
lea edx, [msg_board_data+ecx]
|
|
|
|
|
mov ecx, 0x40FFFFFF
|
|
|
|
|
mov ebx, [msg_board_pos]
|
|
|
|
|
mov edi, 1
|
2021-11-14 20:15:56 +01:00
|
|
|
|
mov esi, edi ;1
|
2013-05-15 18:40:59 +02:00
|
|
|
|
call dtext
|
|
|
|
|
popa
|
|
|
|
|
add word [msg_board_pos+2], 6
|
2016-08-25 21:18:19 +02:00
|
|
|
|
cmp word [msg_board_pos+2], 105*6
|
|
|
|
|
jnc @f
|
2013-05-15 18:40:59 +02:00
|
|
|
|
cmp bl, 10
|
2016-08-25 21:18:19 +02:00
|
|
|
|
jnz .end
|
|
|
|
|
@@:
|
|
|
|
|
mov word [msg_board_pos+2], 42*6
|
2013-05-15 18:40:59 +02:00
|
|
|
|
add word [msg_board_pos], 10
|
2016-08-25 21:18:19 +02:00
|
|
|
|
mov eax, [_display.height]
|
|
|
|
|
sub eax, 10
|
|
|
|
|
cmp ax, word [msg_board_pos]
|
|
|
|
|
jnc @f
|
2013-05-15 18:40:59 +02:00
|
|
|
|
mov word [msg_board_pos], 10
|
|
|
|
|
@@:
|
2013-05-27 11:02:35 +02:00
|
|
|
|
pusha
|
2016-08-25 21:18:19 +02:00
|
|
|
|
mov eax, [msg_board_pos]
|
|
|
|
|
movzx ebx, ax
|
|
|
|
|
shr eax, 16
|
|
|
|
|
mov edx, 105*6
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
mov edi, 1
|
|
|
|
|
mov esi, 9
|
|
|
|
|
@@:
|
|
|
|
|
call hline
|
|
|
|
|
inc ebx
|
|
|
|
|
dec esi
|
|
|
|
|
jnz @b
|
2013-05-27 11:02:35 +02:00
|
|
|
|
popa
|
2016-08-25 21:18:19 +02:00
|
|
|
|
.end:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
inc ecx
|
2013-03-19 18:07:12 +01:00
|
|
|
|
and ecx, msg_board_data_size - 1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov [msg_board_count], ecx
|
2016-08-25 21:18:19 +02:00
|
|
|
|
.ret:
|
2013-06-07 16:12:54 +02:00
|
|
|
|
pop ebx eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2016-08-25 21:18:19 +02:00
|
|
|
|
|
|
|
|
|
.read:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp eax, 2
|
2016-08-25 21:18:19 +02:00
|
|
|
|
jne .ret
|
|
|
|
|
add esp, 8 ; returning data in ebx and eax, so no need to restore them
|
2023-01-30 04:33:03 +01:00
|
|
|
|
test ecx, ecx
|
|
|
|
|
jnz @f
|
|
|
|
|
mov [esp + SYSCALL_STACK.eax], ecx
|
|
|
|
|
mov [esp + SYSCALL_STACK.ebx], ecx
|
|
|
|
|
ret
|
|
|
|
|
@@:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, msg_board_data+1
|
|
|
|
|
mov ebx, msg_board_data
|
|
|
|
|
movzx edx, byte [ebx]
|
|
|
|
|
call memmove
|
|
|
|
|
dec [msg_board_count]
|
2023-01-30 04:33:03 +01:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], edx
|
|
|
|
|
mov [esp + SYSCALL_STACK.ebx], 1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; 61 sys function. ;;
|
|
|
|
|
;; in eax=61,ebx in [1..3] ;;
|
|
|
|
|
;; out eax ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
iglobal
|
|
|
|
|
align 4
|
|
|
|
|
f61call:
|
|
|
|
|
dd sys_gs.1 ; resolution
|
|
|
|
|
dd sys_gs.2 ; bits per pixel
|
|
|
|
|
dd sys_gs.3 ; bytes per scanline
|
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
|
|
|
|
|
sys_gs: ; direct screen access
|
|
|
|
|
dec ebx
|
|
|
|
|
cmp ebx, 2
|
|
|
|
|
ja .not_support
|
2022-02-12 18:27:41 +01:00
|
|
|
|
jmp dword [f61call + ebx*4]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.not_support:
|
2022-06-05 16:41:51 +02:00
|
|
|
|
or [esp + SYSCALL_STACK.eax], dword -1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.1: ; resolution
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov eax, [_display.width]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shl eax, 16
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov ax, word [_display.height]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
.2: ; bits per pixel
|
2014-11-01 18:26:42 +01:00
|
|
|
|
mov eax, [_display.bits_per_pixel]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
.3: ; bytes per scanline
|
2015-01-05 18:59:03 +01:00
|
|
|
|
mov eax, [_display.lfb_pitch]
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
syscall_getscreensize: ; GetScreenSize
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov ax, word [_display.width]
|
|
|
|
|
dec ax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shl eax, 16
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov ax, word [_display.height]
|
|
|
|
|
dec ax
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
2014-03-28 21:36:41 +01:00
|
|
|
|
syscall_cdaudio:
|
2014-03-28 21:04:31 +01:00
|
|
|
|
; ECX - position of CD/DVD-drive
|
|
|
|
|
; from 0=Primary Master to 3=Secondary Slave for first IDE contr.
|
|
|
|
|
; from 4=Primary Master to 7=Secondary Slave for second IDE contr.
|
|
|
|
|
; from 8=Primary Master to 11=Secondary Slave for third IDE contr.
|
|
|
|
|
cmp ecx, 11
|
|
|
|
|
ja .exit
|
|
|
|
|
|
|
|
|
|
mov eax, ecx
|
|
|
|
|
shr eax, 2
|
|
|
|
|
lea eax, [eax*5]
|
2022-02-12 18:27:41 +01:00
|
|
|
|
mov al, [eax + DRIVE_DATA + 1]
|
2014-03-28 21:04:31 +01:00
|
|
|
|
|
|
|
|
|
push ecx ebx
|
|
|
|
|
mov ebx, ecx
|
|
|
|
|
and ebx, 11b
|
|
|
|
|
shl ebx, 1
|
|
|
|
|
mov cl, 6
|
|
|
|
|
sub cl, bl
|
|
|
|
|
shr al, cl
|
|
|
|
|
test al, 2 ; it's not an ATAPI device
|
|
|
|
|
pop ebx ecx
|
|
|
|
|
|
|
|
|
|
jz .exit
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ebx, 4
|
2014-03-27 21:44:32 +01:00
|
|
|
|
je .eject
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
cmp ebx, 5
|
2014-03-27 21:44:32 +01:00
|
|
|
|
je .load
|
2014-03-28 21:04:31 +01:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
.exit:
|
2014-03-27 21:44:32 +01:00
|
|
|
|
ret
|
|
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.load:
|
|
|
|
|
call .reserve
|
|
|
|
|
call LoadMedium
|
|
|
|
|
jmp .free
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.eject:
|
|
|
|
|
call .reserve
|
|
|
|
|
call clear_CD_cache
|
|
|
|
|
call allow_medium_removal
|
|
|
|
|
call EjectMedium
|
|
|
|
|
jmp .free
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.reserve:
|
|
|
|
|
call reserve_cd
|
2014-03-27 21:44:32 +01:00
|
|
|
|
|
|
|
|
|
mov ebx, ecx
|
|
|
|
|
inc ebx
|
|
|
|
|
mov [cdpos], ebx
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, ecx
|
|
|
|
|
shr eax, 1
|
|
|
|
|
and eax, 1
|
|
|
|
|
inc eax
|
2016-07-29 13:12:13 +02:00
|
|
|
|
mov [ChannelNumber], al
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov eax, ecx
|
|
|
|
|
and eax, 1
|
|
|
|
|
mov [DiskNumber], al
|
|
|
|
|
call reserve_cd_channel
|
|
|
|
|
ret
|
2014-03-27 21:44:32 +01:00
|
|
|
|
;--------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.free:
|
|
|
|
|
call free_cd_channel
|
|
|
|
|
and [cd_status], 0
|
|
|
|
|
ret
|
2012-03-27 15:25:30 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
syscall_getpixel_WinMap: ; GetPixel WinMap
|
2023-10-12 23:52:14 +02:00
|
|
|
|
xor eax, eax
|
|
|
|
|
|
2015-01-05 18:18:45 +01:00
|
|
|
|
cmp ebx, [_display.width]
|
2023-10-12 23:52:14 +02:00
|
|
|
|
jae .store
|
2015-01-05 18:18:45 +01:00
|
|
|
|
cmp ecx, [_display.height]
|
2023-10-12 23:52:14 +02:00
|
|
|
|
jae .store
|
2012-03-27 15:25:30 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
mov eax, [d_width_calc_area + ecx*4]
|
2015-01-05 18:59:03 +01:00
|
|
|
|
add eax, [_display.win_map]
|
2012-03-27 15:25:30 +02:00
|
|
|
|
movzx eax, byte[eax+ebx] ; get value for current point
|
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
.store:
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2012-03-27 15:25:30 +02:00
|
|
|
|
ret
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
syscall_getpixel: ; GetPixel
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov ecx, [_display.width]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
xor edx, edx
|
|
|
|
|
mov eax, ebx
|
|
|
|
|
div ecx
|
|
|
|
|
mov ebx, edx
|
|
|
|
|
xchg eax, ebx
|
2012-03-07 16:50:41 +01:00
|
|
|
|
and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call dword [GETPIXEL]; eax - x, ebx - y
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
2012-03-26 23:10:43 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
|
|
|
|
syscall_getarea:
|
|
|
|
|
;eax = 36
|
|
|
|
|
;ebx = pointer to bufer for img BBGGRRBBGGRR...
|
|
|
|
|
;ecx = [size x]*65536 + [size y]
|
|
|
|
|
;edx = [start x]*65536 + [start y]
|
|
|
|
|
pushad
|
|
|
|
|
mov edi, ebx
|
|
|
|
|
mov eax, edx
|
|
|
|
|
shr eax, 16
|
|
|
|
|
mov ebx, edx
|
|
|
|
|
and ebx, 0xffff
|
|
|
|
|
dec eax
|
|
|
|
|
dec ebx
|
|
|
|
|
; eax - x, ebx - y
|
|
|
|
|
mov edx, ecx
|
|
|
|
|
|
|
|
|
|
shr ecx, 16
|
|
|
|
|
and edx, 0xffff
|
|
|
|
|
mov esi, ecx
|
|
|
|
|
; ecx - size x, edx - size y
|
|
|
|
|
|
2021-02-21 10:59:47 +01:00
|
|
|
|
mov ebp, edx
|
|
|
|
|
lea ebp, [ebp*3]
|
|
|
|
|
imul ebp, esi
|
|
|
|
|
stdcall is_region_userspace, edi, ebp
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jnz .exit
|
2021-02-21 10:59:47 +01:00
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
mov ebp, edx
|
|
|
|
|
dec ebp
|
|
|
|
|
lea ebp, [ebp*3]
|
|
|
|
|
|
|
|
|
|
imul ebp, esi
|
|
|
|
|
|
|
|
|
|
mov esi, ecx
|
|
|
|
|
dec esi
|
|
|
|
|
lea esi, [esi*3]
|
|
|
|
|
|
|
|
|
|
add ebp, esi
|
|
|
|
|
add ebp, edi
|
|
|
|
|
|
|
|
|
|
add ebx, edx
|
2012-03-26 23:10:43 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.start_y:
|
|
|
|
|
push ecx edx
|
2012-03-26 23:10:43 +02:00
|
|
|
|
;--------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
.start_x:
|
|
|
|
|
push eax ebx ecx
|
|
|
|
|
add eax, ecx
|
|
|
|
|
|
2012-03-07 16:50:41 +01:00
|
|
|
|
and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call dword [GETPIXEL]; eax - x, ebx - y
|
|
|
|
|
|
|
|
|
|
mov [ebp], cx
|
|
|
|
|
shr ecx, 16
|
|
|
|
|
mov [ebp+2], cl
|
|
|
|
|
|
|
|
|
|
pop ecx ebx eax
|
|
|
|
|
sub ebp, 3
|
|
|
|
|
dec ecx
|
|
|
|
|
jnz .start_x
|
|
|
|
|
pop edx ecx
|
|
|
|
|
dec ebx
|
|
|
|
|
dec edx
|
|
|
|
|
jnz .start_y
|
2023-10-01 23:53:34 +02:00
|
|
|
|
|
2021-02-21 10:59:47 +01:00
|
|
|
|
.exit:
|
2011-10-14 23:38:50 +02:00
|
|
|
|
popad
|
|
|
|
|
ret
|
2012-03-26 23:10:43 +02:00
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
syscall_threads: ; CreateThreads
|
|
|
|
|
;
|
2013-10-26 18:11:59 +02:00
|
|
|
|
; ecx=thread entry point
|
|
|
|
|
; edx=thread stack pointer
|
2011-10-14 23:38:50 +02:00
|
|
|
|
;
|
|
|
|
|
; on return : eax = pid
|
2013-10-26 18:11:59 +02:00
|
|
|
|
xor ebx, ebx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call new_sys_threads
|
|
|
|
|
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
2012-03-08 20:10:26 +01:00
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
align 4
|
|
|
|
|
calculate_fast_getting_offset_for_WinMapAddress:
|
|
|
|
|
; calculate data area for fast getting offset to _WinMapAddress
|
2012-03-10 12:37:42 +01:00
|
|
|
|
xor eax, eax
|
2012-03-08 20:10:26 +01:00
|
|
|
|
mov ecx, [_display.height]
|
|
|
|
|
mov edi, d_width_calc_area
|
|
|
|
|
cld
|
|
|
|
|
@@:
|
|
|
|
|
stosd
|
|
|
|
|
add eax, [_display.width]
|
|
|
|
|
dec ecx
|
|
|
|
|
jnz @r
|
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
2011-10-14 23:38:50 +02:00
|
|
|
|
align 4
|
2012-03-19 21:56:55 +01:00
|
|
|
|
calculate_fast_getting_offset_for_LFB:
|
|
|
|
|
; calculate data area for fast getting offset to LFB
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov ecx, [_display.height]
|
|
|
|
|
mov edi, BPSLine_calc_area
|
|
|
|
|
cld
|
|
|
|
|
@@:
|
|
|
|
|
stosd
|
2015-01-05 18:59:03 +01:00
|
|
|
|
add eax, [_display.lfb_pitch]
|
2012-03-19 21:56:55 +01:00
|
|
|
|
dec ecx
|
|
|
|
|
jnz @r
|
|
|
|
|
ret
|
|
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
|
align 4
|
2011-10-14 23:38:50 +02:00
|
|
|
|
set_screen:
|
2012-05-01 00:07:24 +02:00
|
|
|
|
; in:
|
|
|
|
|
; eax - new Screen_Max_X
|
|
|
|
|
; ecx - new BytesPerScanLine
|
|
|
|
|
; edx - new Screen_Max_Y
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
pushfd
|
|
|
|
|
cli
|
|
|
|
|
|
2015-01-05 18:59:03 +01:00
|
|
|
|
mov [_display.lfb_pitch], ecx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov [screen_workarea.right], eax
|
|
|
|
|
mov [screen_workarea.bottom], edx
|
|
|
|
|
|
|
|
|
|
push ebx
|
|
|
|
|
push esi
|
|
|
|
|
push edi
|
|
|
|
|
|
|
|
|
|
pushad
|
|
|
|
|
|
2012-05-01 00:07:24 +02:00
|
|
|
|
cmp [do_not_touch_winmap], 1
|
|
|
|
|
je @f
|
|
|
|
|
|
2015-01-05 18:59:03 +01:00
|
|
|
|
stdcall kernel_free, [_display.win_map]
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
mov eax, [_display.width]
|
|
|
|
|
mul [_display.height]
|
2015-01-05 18:59:03 +01:00
|
|
|
|
mov [_display.win_map_size], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
|
|
|
|
stdcall kernel_alloc, eax
|
2015-01-05 18:59:03 +01:00
|
|
|
|
mov [_display.win_map], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
test eax, eax
|
|
|
|
|
jz .epic_fail
|
2012-05-01 00:07:24 +02:00
|
|
|
|
; store for f.18.24
|
|
|
|
|
mov eax, [_display.width]
|
|
|
|
|
mov [display_width_standard], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2012-05-01 00:07:24 +02:00
|
|
|
|
mov eax, [_display.height]
|
|
|
|
|
mov [display_height_standard], eax
|
|
|
|
|
@@:
|
2012-03-08 20:10:26 +01:00
|
|
|
|
call calculate_fast_getting_offset_for_WinMapAddress
|
2012-04-02 20:59:09 +02:00
|
|
|
|
; for Qemu or non standart video cards
|
2012-10-22 22:42:00 +02:00
|
|
|
|
; Unfortunately [BytesPerScanLine] does not always
|
2012-04-02 20:59:09 +02:00
|
|
|
|
; equal to [_display.width] * [ScreenBPP] / 8
|
|
|
|
|
call calculate_fast_getting_offset_for_LFB
|
2011-10-14 23:38:50 +02:00
|
|
|
|
popad
|
|
|
|
|
|
|
|
|
|
call repos_windows
|
|
|
|
|
xor eax, eax
|
|
|
|
|
xor ebx, ebx
|
2015-01-05 18:18:45 +01:00
|
|
|
|
mov ecx, [_display.width]
|
|
|
|
|
mov edx, [_display.height]
|
|
|
|
|
dec ecx
|
|
|
|
|
dec edx
|
2011-10-14 23:38:50 +02:00
|
|
|
|
call calculatescreen
|
|
|
|
|
pop edi
|
|
|
|
|
pop esi
|
|
|
|
|
pop ebx
|
|
|
|
|
|
|
|
|
|
popfd
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.epic_fail:
|
|
|
|
|
hlt ; Houston, we've had a problem
|
|
|
|
|
|
|
|
|
|
; --------------- APM ---------------------
|
|
|
|
|
uglobal
|
|
|
|
|
apm_entry dp 0
|
|
|
|
|
apm_vf dd 0
|
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
sys_apm:
|
|
|
|
|
xor eax, eax
|
|
|
|
|
cmp word [apm_vf], ax ; Check APM BIOS enable
|
|
|
|
|
jne @f
|
|
|
|
|
inc eax
|
|
|
|
|
or dword [esp + 44], eax ; error
|
|
|
|
|
add eax, 7
|
2023-04-09 20:19:13 +02:00
|
|
|
|
mov dword [esp + SYSCALL_STACK.eax], eax ; 32-bit protected-mode interface not supported
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
@@:
|
|
|
|
|
; xchg eax, ecx
|
|
|
|
|
; xchg ebx, ecx
|
|
|
|
|
|
|
|
|
|
cmp dx, 3
|
|
|
|
|
ja @f
|
|
|
|
|
and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0
|
|
|
|
|
mov eax, [apm_vf]
|
2023-04-09 20:19:13 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
shr eax, 16
|
2023-04-09 20:19:13 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.ecx], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
@@:
|
|
|
|
|
|
|
|
|
|
mov esi, [master_tab+(OS_BASE shr 20)]
|
|
|
|
|
xchg [master_tab], esi
|
|
|
|
|
push esi
|
|
|
|
|
mov edi, cr3
|
|
|
|
|
mov cr3, edi ;flush TLB
|
|
|
|
|
|
|
|
|
|
call pword [apm_entry] ;call APM BIOS
|
|
|
|
|
|
|
|
|
|
xchg eax, [esp]
|
|
|
|
|
mov [master_tab], eax
|
|
|
|
|
mov eax, cr3
|
|
|
|
|
mov cr3, eax
|
|
|
|
|
pop eax
|
|
|
|
|
|
2023-04-09 20:19:13 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.edi], edi
|
|
|
|
|
mov [esp + SYSCALL_STACK.esi], esi
|
|
|
|
|
mov [esp + SYSCALL_STACK.ebx], ebx
|
|
|
|
|
mov [esp + SYSCALL_STACK.edx], edx
|
|
|
|
|
mov [esp + SYSCALL_STACK.ecx], ecx
|
|
|
|
|
mov [esp + SYSCALL_STACK.eax], eax
|
2011-10-14 23:38:50 +02:00
|
|
|
|
setc al
|
|
|
|
|
and [esp + 44], byte 0xfe
|
|
|
|
|
or [esp + 44], al
|
|
|
|
|
ret
|
|
|
|
|
; -----------------------------------------
|
|
|
|
|
|
|
|
|
|
align 4
|
|
|
|
|
undefined_syscall: ; Undefined system call
|
2022-06-05 16:41:51 +02:00
|
|
|
|
mov [esp + SYSCALL_STACK.eax], dword -1
|
2011-10-14 23:38:50 +02:00
|
|
|
|
ret
|
|
|
|
|
|
2020-12-05 20:56:25 +01:00
|
|
|
|
align 4
|
2021-06-29 11:37:40 +02:00
|
|
|
|
; @brief Check if given memory region lays in lower 2gb (userspace memory) or not
|
|
|
|
|
; @param base Base address of region
|
|
|
|
|
; @param len Lenght of region
|
|
|
|
|
; @return ZF = 1 if region in userspace memory,
|
|
|
|
|
; ZF = 0 otherwise
|
2020-12-05 20:56:25 +01:00
|
|
|
|
proc is_region_userspace stdcall, base:dword, len:dword
|
2021-07-09 11:22:44 +02:00
|
|
|
|
push eax
|
2020-12-05 20:56:25 +01:00
|
|
|
|
mov eax, [base]
|
2020-11-17 21:00:28 +01:00
|
|
|
|
|
2021-07-09 11:22:44 +02:00
|
|
|
|
cmp eax, OS_BASE-1
|
|
|
|
|
ja @f ; zf
|
2020-11-17 21:00:28 +01:00
|
|
|
|
|
2020-12-05 20:56:25 +01:00
|
|
|
|
add eax, [len]
|
2021-07-09 11:22:44 +02:00
|
|
|
|
jc @f ; zf
|
2020-11-07 17:42:34 +01:00
|
|
|
|
cmp eax, OS_BASE
|
2021-07-09 11:22:44 +02:00
|
|
|
|
ja @f ; zf
|
2020-11-07 17:42:34 +01:00
|
|
|
|
|
2021-07-09 11:22:44 +02:00
|
|
|
|
cmp eax, eax ; ZF
|
2020-11-07 17:42:34 +01:00
|
|
|
|
@@:
|
2021-07-09 11:22:44 +02:00
|
|
|
|
pop eax
|
2023-10-01 23:53:34 +02:00
|
|
|
|
ret
|
2020-12-05 20:56:25 +01:00
|
|
|
|
endp
|
2011-10-14 23:38:50 +02:00
|
|
|
|
|
2022-05-31 09:27:00 +02:00
|
|
|
|
align 4
|
|
|
|
|
; @brief Check whether given string lays in userspace memory, i.e. below OS_BASE
|
|
|
|
|
; @param base Base address of string
|
|
|
|
|
; @return ZF = 1 if string in userspace memory,
|
|
|
|
|
; zf = 0 otherwise
|
|
|
|
|
proc is_string_userspace stdcall, base:dword
|
|
|
|
|
push eax ecx edi
|
|
|
|
|
xor eax, eax
|
|
|
|
|
mov edi, [base]
|
|
|
|
|
|
|
|
|
|
mov ecx, OS_BASE-1
|
|
|
|
|
sub ecx, edi
|
|
|
|
|
jb .done ; zf
|
|
|
|
|
inc ecx
|
|
|
|
|
cmp ecx, 0x10000 ; don't allow strings larger than 64k?
|
|
|
|
|
jbe @f
|
|
|
|
|
mov ecx, 0x10000
|
|
|
|
|
@@:
|
|
|
|
|
repnz scasb
|
|
|
|
|
.done:
|
|
|
|
|
pop edi ecx eax
|
|
|
|
|
ret
|
|
|
|
|
endp
|
|
|
|
|
|
2013-06-08 15:08:51 +02:00
|
|
|
|
if ~ lang eq sp
|
|
|
|
|
diff16 "end of .text segment",0,$
|
|
|
|
|
end if
|
|
|
|
|
|
2011-10-14 23:38:50 +02:00
|
|
|
|
include "data32.inc"
|
|
|
|
|
|
|
|
|
|
__REV__ = __REV
|
|
|
|
|
|
2013-03-06 13:04:53 +01:00
|
|
|
|
if ~ lang eq sp
|
2011-10-14 23:38:50 +02:00
|
|
|
|
diff16 "end of kernel code",0,$
|
2013-02-27 23:34:38 +01:00
|
|
|
|
end if
|