2022-06-27 19:36:56 +02:00
|
|
|
; SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
;
|
|
|
|
; UMKa - User-Mode KolibriOS developer tools
|
|
|
|
;
|
2023-01-17 01:49:11 +01:00
|
|
|
; Copyright (C) 2017-2023 Ivan Baravy <dunkaist@gmail.com>
|
2022-06-27 19:36:56 +02:00
|
|
|
; Copyright (C) 2021 Magomed Kostoev <mkostoevr@yandex.ru>
|
2020-12-09 15:15:54 +01:00
|
|
|
|
2021-12-13 13:58:19 +01:00
|
|
|
if HOST eq windows
|
2021-12-12 11:35:35 +01:00
|
|
|
format MS COFF
|
2021-12-13 13:58:19 +01:00
|
|
|
else if HOST eq linux
|
2021-12-12 11:35:35 +01:00
|
|
|
format ELF
|
2021-12-13 13:58:19 +01:00
|
|
|
else
|
|
|
|
error "Your OS is not supported"
|
2021-12-12 11:35:35 +01:00
|
|
|
end if
|
|
|
|
|
|
|
|
; win32:
|
|
|
|
; pubsym name -> public name as "_name"
|
|
|
|
; pubsym name, 20 -> public name as "_name@20"
|
|
|
|
; pubsym name, no_mangle -> public name
|
|
|
|
; pubsym name, "name" -> public name as "_name"
|
|
|
|
; pubsym name, "name", 20 -> public name as "_name@20"
|
|
|
|
; pubsym name, "name", no_mangle -> public name as "name"
|
|
|
|
; linux:
|
|
|
|
; pubsym name -> public name
|
|
|
|
; pubsym name, 20 -> public name
|
|
|
|
; pubsym name, no_mangle -> public name
|
|
|
|
; pubsym name, "name" -> public name as "name"
|
|
|
|
; pubsym name, "name", 20 -> public name as "name"
|
|
|
|
; pubsym name, "name", no_mangle -> public name as "name"
|
|
|
|
macro pubsym name, marg1, marg2 {
|
2021-12-13 13:58:19 +01:00
|
|
|
if HOST eq windows
|
2021-12-12 11:35:35 +01:00
|
|
|
if marg1 eq no_mangle
|
|
|
|
public name
|
|
|
|
else if marg1 eqtype 20
|
|
|
|
public name as '_' # `name # '@' # `marg1
|
|
|
|
else if marg1 eqtype 'string'
|
|
|
|
if marg2 eq no_mangle
|
|
|
|
public name as marg1
|
|
|
|
else if marg2 eqtype 20
|
|
|
|
public name as '_' # marg1 # '@' # `marg2
|
|
|
|
else
|
|
|
|
public name as '_' # marg1
|
|
|
|
end if
|
|
|
|
else
|
|
|
|
public name as '_' # `name
|
|
|
|
end if
|
2021-12-13 13:58:19 +01:00
|
|
|
else if HOST eq linux
|
2021-12-12 11:35:35 +01:00
|
|
|
if marg1 eqtype 'string'
|
|
|
|
public name as marg1
|
|
|
|
else
|
|
|
|
public name
|
|
|
|
end if
|
2021-12-13 13:58:19 +01:00
|
|
|
else
|
|
|
|
error "Your OS is not supported"
|
2021-12-12 11:35:35 +01:00
|
|
|
end if
|
|
|
|
}
|
|
|
|
|
|
|
|
; win32:
|
|
|
|
; extrn name -> extrn _name
|
|
|
|
; extrn name, 20 -> extrn _name@20
|
|
|
|
; linux:
|
|
|
|
; extrn name -> extrn name
|
|
|
|
; extrn name, 20 -> extrn name
|
|
|
|
macro extrn name, [argsize] {
|
2021-12-13 13:58:19 +01:00
|
|
|
if HOST eq windows
|
2021-12-12 11:35:35 +01:00
|
|
|
if argsize eqtype 20
|
|
|
|
extrn '_' # `name # '@' # `argsize as name
|
|
|
|
else
|
|
|
|
extrn '_' # `name as name
|
|
|
|
end if
|
2021-12-13 13:58:19 +01:00
|
|
|
else if HOST eq linux
|
2021-12-12 11:35:35 +01:00
|
|
|
extrn name
|
2021-12-13 13:58:19 +01:00
|
|
|
else
|
|
|
|
error "Your OS is not supported"
|
2021-12-12 11:35:35 +01:00
|
|
|
end if
|
|
|
|
}
|
2017-10-18 22:19:53 +02:00
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
__DEBUG__ = 1
|
2017-11-02 21:41:11 +01:00
|
|
|
__DEBUG_LEVEL__ = 1
|
2017-10-18 22:19:53 +02:00
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
UMKA_SHELL = 1
|
|
|
|
UMKA_FUSE = 2
|
|
|
|
UMKA_OS = 3
|
|
|
|
|
2020-12-29 10:45:24 +01:00
|
|
|
UMKA_MEMORY_BYTES = 256 SHL 20
|
2020-05-11 05:38:44 +02:00
|
|
|
|
2022-06-26 21:57:02 +02:00
|
|
|
pubsym irq_serv.irq_10, 'kos_irq_serv_irq10'
|
2023-01-18 03:58:09 +01:00
|
|
|
pubsym idts, 'kos_idts'
|
2022-06-26 21:57:02 +02:00
|
|
|
pubsym attach_int_handler, 'kos_attach_int_handler', 12
|
2022-06-27 14:32:29 +02:00
|
|
|
pubsym fs_execute, 'kos_fs_execute', 4
|
2023-02-05 09:06:14 +01:00
|
|
|
pubsym set_keyboard_data, 'kos_set_keyboard_data', no_mangle
|
2022-06-13 23:46:48 +02:00
|
|
|
pubsym KEY_COUNT, 'kos_key_count'
|
|
|
|
pubsym KEY_BUFF, 'kos_key_buff'
|
|
|
|
pubsym keyboard_mode, 'kos_keyboard_mode'
|
|
|
|
pubsym sys_getkey, 'kos_get_key'
|
|
|
|
pubsym syslang, 'kos_syslang'
|
|
|
|
pubsym keyboard, 'kos_keyboard'
|
2022-05-28 23:55:13 +02:00
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym disk_add, 16
|
|
|
|
pubsym disk_del, 4
|
|
|
|
pubsym disk_list
|
|
|
|
pubsym disk_media_changed, 8
|
|
|
|
|
|
|
|
pubsym xfs._.user_functions, 'xfs_user_functions'
|
|
|
|
pubsym ext_user_functions
|
|
|
|
pubsym fat_user_functions
|
2022-03-11 21:08:20 +01:00
|
|
|
pubsym exFAT_user_functions, 'exfat_user_functions'
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym ntfs_user_functions
|
|
|
|
|
|
|
|
pubsym i40, no_mangle
|
|
|
|
|
|
|
|
pubsym coverage_begin
|
|
|
|
pubsym coverage_end
|
|
|
|
|
|
|
|
pubsym sha3_256_oneshot, 'hash_oneshot'
|
|
|
|
pubsym kos_time_to_epoch
|
2023-02-05 11:08:11 +01:00
|
|
|
pubsym umka_init
|
2023-01-17 01:49:11 +01:00
|
|
|
pubsym umka_close, 4
|
2023-01-18 09:29:08 +01:00
|
|
|
pubsym umka_boot
|
2021-12-12 11:35:35 +01:00
|
|
|
|
|
|
|
pubsym current_process, 'kos_current_process'
|
|
|
|
pubsym current_slot, 'kos_current_slot'
|
|
|
|
pubsym current_slot_idx, 'kos_current_slot_idx'
|
|
|
|
|
|
|
|
pubsym thread_count, 'kos_thread_count'
|
|
|
|
pubsym SLOT_BASE, 'kos_slot_base'
|
|
|
|
pubsym window_data, 'kos_window_data'
|
|
|
|
|
|
|
|
pubsym WIN_STACK, 'kos_win_stack'
|
|
|
|
pubsym WIN_POS, 'kos_win_pos'
|
|
|
|
pubsym lfb_base, 'kos_lfb_base'
|
|
|
|
|
|
|
|
pubsym RAMDISK, 'kos_ramdisk'
|
|
|
|
pubsym ramdisk_init, 'kos_ramdisk_init'
|
|
|
|
|
|
|
|
pubsym enable_acpi, no_mangle
|
|
|
|
pubsym acpi.call_name, no_mangle
|
|
|
|
pubsym acpi_ssdt_cnt, 'kos_acpi_ssdt_cnt'
|
|
|
|
pubsym acpi_ssdt_base, 'kos_acpi_ssdt_base'
|
|
|
|
pubsym acpi_ssdt_size, 'kos_acpi_ssdt_size'
|
|
|
|
pubsym acpi_ctx
|
|
|
|
pubsym acpi_usage, 'kos_acpi_usage'
|
|
|
|
pubsym acpi_node_alloc_cnt, 'kos_acpi_node_alloc_cnt'
|
|
|
|
pubsym acpi_node_free_cnt, 'kos_acpi_node_free_cnt'
|
|
|
|
pubsym acpi.count_nodes, 'kos_acpi_count_nodes', 4
|
|
|
|
|
2023-02-06 15:16:35 +01:00
|
|
|
pubsym stack_init, 'kos_stack_init', no_mangle
|
|
|
|
pubsym net_add_device, no_mangle
|
2021-12-12 11:35:35 +01:00
|
|
|
|
|
|
|
pubsym draw_data
|
|
|
|
pubsym img_background
|
|
|
|
pubsym mem_BACKGROUND
|
|
|
|
pubsym sys_background
|
|
|
|
pubsym REDRAW_BACKGROUND, 'kos_redraw_background'
|
|
|
|
pubsym new_sys_threads, 'kos_new_sys_threads', no_mangle
|
2023-02-05 09:06:14 +01:00
|
|
|
pubsym osloop, 'kos_osloop', no_mangle
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym set_mouse_data, 'kos_set_mouse_data', 20
|
|
|
|
pubsym scheduler_current, 'kos_scheduler_current'
|
|
|
|
pubsym kos_eth_input
|
|
|
|
pubsym net_buff_alloc, 'kos_net_buff_alloc', 4
|
|
|
|
|
|
|
|
pubsym mem_block_list
|
|
|
|
pubsym pci_root, "kos_pci_root"
|
|
|
|
|
|
|
|
pubsym acpi.aml.init, "kos_acpi_aml_init"
|
|
|
|
pubsym acpi_root, "kos_acpi_root"
|
|
|
|
pubsym aml._.attach, "kos_aml_attach"
|
|
|
|
pubsym acpi.fill_pci_irqs, "kos_acpi_fill_pci_irqs"
|
|
|
|
pubsym pci.walk_tree, "kos_pci_walk_tree", 16
|
|
|
|
pubsym acpi.aml.new_thread, "kos_acpi_aml_new_thread"
|
|
|
|
pubsym aml._.alloc_node, "kos_aml_alloc_node"
|
|
|
|
pubsym aml._.constructor.integer, "kos_aml_constructor_integer"
|
|
|
|
pubsym aml._.constructor.package, "kos_aml_constructor_package"
|
|
|
|
pubsym acpi._.lookup_node, "kos_acpi_lookup_node"
|
|
|
|
pubsym acpi._.print_tree, "kos_acpi_print_tree"
|
|
|
|
pubsym acpi_dev_data, "kos_acpi_dev_data"
|
|
|
|
pubsym acpi_dev_size, "kos_acpi_dev_size"
|
|
|
|
pubsym acpi_dev_next, "kos_acpi_dev_next"
|
|
|
|
pubsym kernel_alloc, "kos_kernel_alloc"
|
|
|
|
|
2023-01-16 03:50:19 +01:00
|
|
|
pubsym create_event, "_kos_create_event"
|
|
|
|
pubsym destroy_event, "_kos_destroy_event"
|
|
|
|
pubsym wait_event, "_kos_wait_event"
|
|
|
|
pubsym Wait_events, "_kos_wait_events"
|
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym window._.set_screen, 'kos_window_set_screen'
|
|
|
|
pubsym _display, 'kos_display'
|
|
|
|
|
2023-01-30 07:24:23 +01:00
|
|
|
pubsym msg_board_data, "kos_msg_board_data"
|
|
|
|
pubsym msg_board_count, "kos_msg_board_count"
|
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym BOOT, 'kos_boot'
|
2021-11-02 10:46:36 +01:00
|
|
|
|
2022-05-24 21:22:12 +02:00
|
|
|
EFLAGS.ID = 1 SHL 21
|
|
|
|
|
2023-01-18 03:58:09 +01:00
|
|
|
macro lidt x {
|
|
|
|
}
|
|
|
|
|
2022-05-30 19:47:49 +02:00
|
|
|
macro invlpg addr {
|
|
|
|
}
|
|
|
|
|
2020-05-09 05:41:32 +02:00
|
|
|
macro cli {
|
|
|
|
pushfd
|
2022-05-24 21:22:12 +02:00
|
|
|
bts dword[esp], BSF EFLAGS.ID
|
2020-05-09 05:41:32 +02:00
|
|
|
popfd
|
|
|
|
}
|
|
|
|
|
|
|
|
macro sti {
|
|
|
|
pushfd
|
2022-05-24 21:22:12 +02:00
|
|
|
btr dword[esp], BSF EFLAGS.ID
|
2020-05-09 05:41:32 +02:00
|
|
|
popfd
|
|
|
|
}
|
|
|
|
|
2020-02-06 04:19:20 +01:00
|
|
|
iretd equ retd
|
2022-06-26 21:57:02 +02:00
|
|
|
iret equ ret
|
2020-02-04 22:53:24 +01:00
|
|
|
|
|
|
|
lang fix en
|
2020-02-10 06:09:17 +01:00
|
|
|
|
2020-02-08 19:27:29 +01:00
|
|
|
macro int n {
|
|
|
|
if n eq 0x40
|
|
|
|
call i40
|
|
|
|
else
|
|
|
|
int n
|
|
|
|
end if
|
|
|
|
}
|
2019-10-09 01:35:47 +02:00
|
|
|
|
2022-05-24 21:22:12 +02:00
|
|
|
section '.app' executable writable align 64
|
|
|
|
rb 64*1024
|
|
|
|
|
2021-07-17 00:54:33 +02:00
|
|
|
section '.text' executable align 64
|
2020-02-06 04:19:20 +01:00
|
|
|
|
2019-10-09 01:35:47 +02:00
|
|
|
coverage_begin:
|
|
|
|
|
2018-04-23 12:09:46 +02:00
|
|
|
include 'macros.inc'
|
2020-11-19 02:16:45 +01:00
|
|
|
|
2020-02-09 02:48:16 +01:00
|
|
|
macro diff16 msg,blah2,blah3 {
|
|
|
|
if msg eq "end of .data segment"
|
2021-12-13 13:58:19 +01:00
|
|
|
if HOST eq windows
|
2021-12-12 11:35:35 +01:00
|
|
|
section '.bss.8k' writeable align 8192
|
2021-12-13 13:58:19 +01:00
|
|
|
else if HOST eq linux
|
2021-12-12 11:35:35 +01:00
|
|
|
; fasm doesn't align on 65536, but ld script does
|
|
|
|
section '.bss.aligned65k' writeable align 65536
|
2021-12-13 13:58:19 +01:00
|
|
|
else
|
|
|
|
error "Your OS is not supported"
|
2021-12-12 11:35:35 +01:00
|
|
|
end if
|
2021-07-17 00:54:33 +02:00
|
|
|
bss_base:
|
2020-02-09 02:48:16 +01:00
|
|
|
end if
|
2020-02-04 22:53:24 +01:00
|
|
|
}
|
2017-10-18 22:19:53 +02:00
|
|
|
include 'proc32.inc'
|
|
|
|
include 'struct.inc'
|
2020-02-09 02:48:16 +01:00
|
|
|
macro BOOT_LO a {}
|
|
|
|
macro BOOT a {}
|
2020-10-21 16:57:54 +02:00
|
|
|
window_data equ __pew01
|
|
|
|
CDDataBuf equ __pew06
|
|
|
|
idts equ __pew07
|
|
|
|
WIN_STACK equ __pew08
|
|
|
|
WIN_POS equ __pew09
|
|
|
|
FDD_BUFF equ __pew10
|
|
|
|
WIN_TEMP_XY equ __pew11
|
|
|
|
KEY_COUNT equ __pew12
|
|
|
|
KEY_BUFF equ __pew13
|
|
|
|
BTN_COUNT equ __pew14
|
|
|
|
BTN_BUFF equ __pew15
|
|
|
|
BTN_ADDR equ __pew16
|
|
|
|
MEM_AMOUNT equ __pew17
|
|
|
|
SYS_SHUTDOWN equ __pew18
|
|
|
|
SLOT_BASE equ __pew20
|
|
|
|
sys_proc equ __pew21
|
|
|
|
VGABasePtr equ __pew22
|
2020-10-22 01:44:34 +02:00
|
|
|
HEAP_BASE equ __pew23
|
2022-05-30 19:47:49 +02:00
|
|
|
page_tabs equ page_tabs_pew
|
2020-09-18 05:00:32 +02:00
|
|
|
;macro OS_BASE [x] {
|
|
|
|
; OS_BASE equ os_base
|
|
|
|
;}
|
2023-01-18 03:58:09 +01:00
|
|
|
struct idt_entry
|
|
|
|
addr_lo dw ?
|
|
|
|
seg dw ?
|
|
|
|
flags dw ?
|
|
|
|
addr_hi dw ?
|
|
|
|
ends
|
|
|
|
|
|
|
|
NUM_EXCEPTIONS = 32
|
|
|
|
|
2022-06-27 14:32:29 +02:00
|
|
|
macro tss pew {}
|
2017-10-18 22:19:53 +02:00
|
|
|
include 'const.inc'
|
2022-06-27 14:32:29 +02:00
|
|
|
purge tss
|
2020-02-10 06:09:17 +01:00
|
|
|
restore window_data
|
2022-02-09 02:27:49 +01:00
|
|
|
restore CDDataBuf,idts,WIN_STACK,WIN_POS
|
2020-10-21 16:57:54 +02:00
|
|
|
restore FDD_BUFF,WIN_TEMP_XY,KEY_COUNT,KEY_BUFF,BTN_COUNT,BTN_BUFF,BTN_ADDR
|
|
|
|
restore MEM_AMOUNT,SYS_SHUTDOWN,SLOT_BASE,sys_proc,VGABasePtr
|
2020-10-22 01:44:34 +02:00
|
|
|
restore HEAP_BASE
|
2022-05-30 19:47:49 +02:00
|
|
|
restore page_tabs
|
2020-02-09 02:48:16 +01:00
|
|
|
purge BOOT_LO,BOOT
|
|
|
|
|
|
|
|
LFB_BASE = lfb_base
|
|
|
|
|
2020-09-17 19:51:03 +02:00
|
|
|
macro save_ring3_context {
|
|
|
|
pushad
|
|
|
|
}
|
|
|
|
|
|
|
|
macro restore_ring3_context {
|
|
|
|
popad
|
|
|
|
}
|
|
|
|
|
2021-04-02 03:22:22 +02:00
|
|
|
macro stdcall target, [args] {
|
|
|
|
common
|
|
|
|
if target eq is_region_userspace
|
2021-07-16 23:11:55 +02:00
|
|
|
cmp esp, esp ; ZF
|
2022-05-30 19:47:49 +02:00
|
|
|
else if target eq is_string_userspace
|
|
|
|
cmp esp, esp ; ZF
|
2021-04-02 03:22:22 +02:00
|
|
|
else
|
|
|
|
stdcall target, args
|
|
|
|
end if
|
|
|
|
}
|
|
|
|
|
2017-10-18 22:19:53 +02:00
|
|
|
include 'system.inc'
|
2019-10-13 03:17:29 +02:00
|
|
|
include 'fdo.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
|
2022-05-30 19:47:49 +02:00
|
|
|
OS_BASE equ 0
|
|
|
|
macro mov target, source {
|
|
|
|
if source eq (HEAP_BASE - 0 + HEAP_MIN_SIZE)/4096
|
|
|
|
push eax eax
|
|
|
|
mov eax, HEAP_BASE
|
|
|
|
add eax, HEAP_MIN_SIZE
|
|
|
|
shr eax, 12
|
|
|
|
mov [esp+4], eax
|
|
|
|
pop eax
|
|
|
|
pop target
|
|
|
|
else if target eq dword [sys_proc-0+PROC.pdt_0+(page_tabs shr 20)]
|
|
|
|
push eax ecx
|
|
|
|
mov eax, page_tabs
|
|
|
|
shr eax, 20
|
|
|
|
add eax, PROC.pdt_0
|
|
|
|
add eax, sys_proc
|
|
|
|
mov ecx, sys_proc+PROC.pdt_0+PG_SWR
|
|
|
|
mov [eax], ecx
|
|
|
|
pop ecx eax
|
|
|
|
else
|
|
|
|
mov target, source
|
|
|
|
end if
|
|
|
|
}
|
|
|
|
macro cmp target, source {
|
|
|
|
if source eq (HEAP_BASE - 0 + HEAP_MIN_SIZE)/4096
|
|
|
|
push eax eax
|
|
|
|
mov eax, HEAP_BASE
|
|
|
|
add eax, HEAP_MIN_SIZE
|
|
|
|
shr eax, 12
|
|
|
|
mov [esp], eax
|
|
|
|
mov eax, [esp+4]
|
|
|
|
cmp target, [esp]
|
|
|
|
pop eax eax
|
|
|
|
else
|
2022-05-31 15:43:41 +02:00
|
|
|
cmp target, source
|
2022-05-30 19:47:49 +02:00
|
|
|
end if
|
|
|
|
}
|
|
|
|
|
|
|
|
include 'init.inc'
|
|
|
|
purge cmp
|
|
|
|
purge mov
|
|
|
|
restore OS_BASE
|
2020-09-18 03:49:35 +02:00
|
|
|
include 'core/sync.inc'
|
2020-10-10 01:30:52 +02:00
|
|
|
macro call target {
|
|
|
|
if target eq do_change_task
|
|
|
|
call _do_change_task
|
2023-01-12 22:24:06 +01:00
|
|
|
else if target eq page_fault_handler
|
|
|
|
call _page_fault_handler
|
2020-10-10 01:30:52 +02:00
|
|
|
else
|
|
|
|
call target
|
|
|
|
end if
|
|
|
|
}
|
2023-01-12 22:24:06 +01:00
|
|
|
include 'core/sys32.inc'
|
2020-10-10 01:30:52 +02:00
|
|
|
do_change_task equ hjk
|
2022-06-27 14:32:29 +02:00
|
|
|
irq0 equ irq0_pew
|
|
|
|
tss._io_map_0 equ 0
|
|
|
|
tss._io_map_1 equ 0
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/sched.inc'
|
2022-06-27 14:32:29 +02:00
|
|
|
restore tss._io_map_0
|
|
|
|
restore tss._io_map_1
|
|
|
|
;purge mov
|
2020-10-10 01:30:52 +02:00
|
|
|
restore irq0
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/syscall.inc'
|
|
|
|
;include 'core/fpu.inc'
|
2022-05-30 19:47:49 +02:00
|
|
|
map_io_mem equ map_io_mem_pew
|
|
|
|
create_trampoline_pgmap equ create_trampoline_pgmap_pew
|
|
|
|
alloc_page equ alloc_page_pew
|
|
|
|
alloc_pages equ alloc_pages_pew
|
|
|
|
free_page equ free_page_pew
|
|
|
|
include 'core/memory.inc'
|
|
|
|
restore map_io_mem, free_page, create_trampoline_pgmap, alloc_page, alloc_pages
|
2020-09-18 04:31:10 +02:00
|
|
|
;include 'core/mtrr.inc'
|
2022-05-31 15:43:41 +02:00
|
|
|
;user_alloc_at equ user_alloc_at_pew
|
2020-02-08 16:10:45 +01:00
|
|
|
include 'core/heap.inc'
|
2022-05-31 15:43:41 +02:00
|
|
|
;restore user_alloc_at
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/malloc.inc'
|
2022-05-30 19:47:49 +02:00
|
|
|
macro mov target, source {
|
|
|
|
if target eq [edi - 4096 + (page_tabs shr 20)]
|
|
|
|
push eax ebx
|
|
|
|
mov ebx, eax
|
|
|
|
mov eax, page_tabs
|
|
|
|
shr eax, 20
|
|
|
|
sub eax, 4096
|
|
|
|
add eax, edi
|
|
|
|
mov [eax], ebx
|
|
|
|
pop ebx eax
|
|
|
|
else
|
|
|
|
mov target, source
|
|
|
|
end if
|
|
|
|
}
|
2020-02-08 16:10:45 +01:00
|
|
|
include 'core/taskman.inc'
|
2022-05-30 19:47:49 +02:00
|
|
|
purge mov
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/dll.inc'
|
2022-02-09 02:27:49 +01:00
|
|
|
macro call target {
|
|
|
|
if target eq pci_read_reg
|
2022-05-24 21:22:12 +02:00
|
|
|
call _pci_read_reg
|
2022-02-09 02:27:49 +01:00
|
|
|
else
|
|
|
|
call target
|
|
|
|
end if
|
|
|
|
}
|
|
|
|
include 'bus/pci/pci32.inc'
|
|
|
|
purge call
|
2020-09-18 04:31:10 +02:00
|
|
|
;include 'core/peload.inc'
|
|
|
|
;include 'core/exports.inc'
|
|
|
|
include 'core/string.inc'
|
|
|
|
;include 'core/v86.inc'
|
2022-06-26 21:57:02 +02:00
|
|
|
macro mov dst, src {
|
|
|
|
if dst eq ds
|
|
|
|
else if dst eq es
|
|
|
|
else
|
|
|
|
mov dst, src
|
|
|
|
end if
|
|
|
|
}
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/irq.inc'
|
2022-06-26 21:57:02 +02:00
|
|
|
purge mov
|
2022-06-27 14:32:29 +02:00
|
|
|
purge call
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/apic.inc'
|
2020-10-21 16:57:54 +02:00
|
|
|
include 'core/hpet.inc'
|
2020-02-10 06:09:17 +01:00
|
|
|
include 'core/timers.inc'
|
2020-02-09 02:48:16 +01:00
|
|
|
include 'core/clipboard.inc'
|
2020-06-05 20:24:57 +02:00
|
|
|
include 'core/slab.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
|
|
|
|
include 'posix/posix.inc'
|
|
|
|
|
|
|
|
;include 'boot/shutdown.inc'
|
|
|
|
|
2020-02-04 22:53:24 +01:00
|
|
|
include 'video/vesa20.inc'
|
2020-02-07 03:26:27 +01:00
|
|
|
include 'video/blitter.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'video/vga.inc'
|
2020-02-04 22:53:24 +01:00
|
|
|
include 'video/cursors.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'video/framebuffer.inc'
|
|
|
|
|
2020-02-04 22:53:24 +01:00
|
|
|
include 'gui/window.inc'
|
2020-02-07 03:26:27 +01:00
|
|
|
include 'gui/event.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'gui/font.inc'
|
|
|
|
include 'gui/button.inc'
|
2020-02-07 03:26:27 +01:00
|
|
|
include 'gui/mouse.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'gui/skincode.inc'
|
2022-02-09 02:27:49 +01:00
|
|
|
include 'gui/background.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
|
2020-02-07 03:26:27 +01:00
|
|
|
include 'hid/keyboard.inc'
|
2020-02-10 06:09:17 +01:00
|
|
|
include 'hid/mousedrv.inc'
|
2022-02-09 02:27:49 +01:00
|
|
|
include 'hid/set_dtc.inc' ; setting date,time,clock and alarm-clock
|
2020-09-18 04:31:10 +02:00
|
|
|
|
|
|
|
include 'sound/playnote.inc'
|
|
|
|
|
|
|
|
;include 'bus/pci/pci32.inc'
|
|
|
|
;include 'bus/usb/init.inc'
|
|
|
|
|
|
|
|
;include 'blkdev/flp_drv.inc' ; floppy driver
|
|
|
|
;include 'blkdev/fdc.inc'
|
|
|
|
;include 'blkdev/cd_drv.inc' ; CD driver
|
|
|
|
;include 'blkdev/ide_cache.inc' ; CD cache
|
|
|
|
;include 'blkdev/hd_drv.inc' ; HDD driver
|
|
|
|
;include 'blkdev/bd_drv.inc' ; BIOS disks driver
|
|
|
|
include 'blkdev/rd.inc' ; ramdisk driver
|
|
|
|
include 'blkdev/disk.inc'
|
|
|
|
include 'blkdev/disk_cache.inc'
|
|
|
|
|
|
|
|
include 'fs/fs_lfn.inc'
|
|
|
|
|
2020-02-10 06:09:17 +01:00
|
|
|
include 'network/stack.inc'
|
2020-02-20 04:41:53 +01:00
|
|
|
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'crc.inc'
|
|
|
|
include 'unicode.inc'
|
|
|
|
include 'acpi/acpi.inc'
|
|
|
|
|
|
|
|
include 'unpacker.inc'
|
|
|
|
|
2021-11-02 10:46:36 +01:00
|
|
|
LIBCRASH_CTX_LEN = 0x500 ; FIXME
|
2019-10-21 04:51:56 +02:00
|
|
|
include 'sha3.asm'
|
|
|
|
|
2020-09-18 03:49:35 +02:00
|
|
|
; TODO: stdcall attribute in umka.h
|
2019-10-21 04:51:56 +02:00
|
|
|
proc sha3_256_oneshot c uses ebx esi edi ebp, _ctx, _data, _len
|
|
|
|
stdcall sha3_256.oneshot, [_ctx], [_data], [_len]
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2019-10-13 03:17:29 +02:00
|
|
|
proc kos_time_to_epoch c uses ebx esi edi ebp, _time
|
|
|
|
mov esi, [_time]
|
2018-04-24 18:51:48 +02:00
|
|
|
call fsCalculateTime
|
2022-12-28 16:06:15 +01:00
|
|
|
xor edx, edx
|
|
|
|
add eax, UNIXTIME_TO_KOS_OFFSET
|
|
|
|
adc edx, 0
|
2018-04-24 18:51:48 +02:00
|
|
|
ret
|
2019-10-13 03:17:29 +02:00
|
|
|
endp
|
2018-04-24 18:51:48 +02:00
|
|
|
|
2020-10-22 01:44:34 +02:00
|
|
|
proc umka._.check_alignment
|
|
|
|
mov eax, HEAP_BASE
|
2021-07-17 00:54:33 +02:00
|
|
|
and eax, PAGE_SIZE - 1
|
2020-10-22 01:44:34 +02:00
|
|
|
jz @f
|
2021-07-17 00:54:33 +02:00
|
|
|
mov ecx, PAGE_SIZE
|
2020-11-19 02:16:45 +01:00
|
|
|
sub ecx, eax
|
2021-07-17 00:54:33 +02:00
|
|
|
DEBUGF 4, "HEAP_BASE must be aligned on PAGE_SIZE: 0x%x", HEAP_BASE
|
2020-11-19 02:16:45 +01:00
|
|
|
DEBUGF 4, ", add 0x%x or sub 0x%x\n", ecx, eax
|
2020-10-22 01:44:34 +02:00
|
|
|
int3
|
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym i40_asm
|
2021-12-04 18:58:16 +01:00
|
|
|
|
|
|
|
;void i40_asm(uint32_t _eax,
|
|
|
|
; uint32_t _ebx,
|
|
|
|
; uint32_t _ecx,
|
|
|
|
; uint32_t _edx,
|
|
|
|
; uint32_t _esi,
|
|
|
|
; uint32_t _edi,
|
|
|
|
; uint32_t _ebp,
|
|
|
|
; uint32_t *_eax_out,
|
|
|
|
; uint32_t _ebx_out)
|
|
|
|
i40_asm:
|
|
|
|
; Return address: esp
|
|
|
|
; First argument: esp + 4
|
|
|
|
push eax ebx ecx edx esi edi ebp
|
|
|
|
; First argument: esp + 4 + 7 * sizeof(dword) = esp + 8 + 7 * 4 = esp + 4 + 28 = esp + 32
|
|
|
|
mov eax, [esp + 32]
|
|
|
|
mov ebx, [esp + 36]
|
|
|
|
mov ecx, [esp + 40]
|
|
|
|
mov edx, [esp + 44]
|
|
|
|
mov esi, [esp + 48]
|
|
|
|
mov edi, [esp + 52]
|
|
|
|
mov ebp, [esp + 56]
|
|
|
|
call i40
|
|
|
|
mov edi, [esp + 60]
|
|
|
|
mov [edi], eax
|
|
|
|
mov edi, [esp + 64]
|
|
|
|
mov [edi], ebx
|
|
|
|
pop ebp edi esi edx ecx ebx eax
|
|
|
|
ret
|
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym set_eflags_tf
|
2021-12-04 18:58:16 +01:00
|
|
|
|
|
|
|
proc set_eflags_tf c uses ebx esi edi ebp, tf
|
|
|
|
mov ecx, [tf]
|
|
|
|
pushfd
|
|
|
|
pop eax
|
|
|
|
ror eax, 8
|
|
|
|
mov edx, eax
|
|
|
|
and edx, 1
|
|
|
|
and eax, 0xfffffffe
|
|
|
|
or eax, ecx
|
|
|
|
rol eax, 8
|
|
|
|
push eax
|
|
|
|
popfd
|
|
|
|
mov eax, edx
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
proc kos_eth_input c uses ebx esi edi ebp, buffer_ptr
|
|
|
|
push .retaddr
|
|
|
|
push [buffer_ptr]
|
|
|
|
jmp eth_input
|
|
|
|
.retaddr:
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2023-01-17 01:49:11 +01:00
|
|
|
struct umka_ctx
|
2023-01-18 09:29:08 +01:00
|
|
|
booted dd ?
|
|
|
|
running dd ?
|
2023-01-17 01:49:11 +01:00
|
|
|
ends
|
|
|
|
|
2023-01-18 09:29:08 +01:00
|
|
|
proc umka_init c uses ebx esi edi ebp
|
2020-10-22 01:44:34 +02:00
|
|
|
call umka._.check_alignment
|
2023-01-18 09:29:08 +01:00
|
|
|
mov eax, umka
|
|
|
|
mov [eax+umka_ctx.booted], 0
|
|
|
|
mov [eax+umka_ctx.running], 0
|
2023-01-17 01:49:11 +01:00
|
|
|
ret
|
|
|
|
endp
|
2020-10-22 01:44:34 +02:00
|
|
|
|
2023-01-17 01:49:11 +01:00
|
|
|
proc umka_close c, _ctx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2023-01-18 09:29:08 +01:00
|
|
|
proc umka_boot uses ebx esi edi ebp
|
|
|
|
mov [umka.booted], 1
|
2020-02-07 03:26:27 +01:00
|
|
|
mov edi, endofcode
|
|
|
|
mov ecx, uglobals_size
|
|
|
|
xor eax, eax
|
|
|
|
rep stosb
|
|
|
|
|
2022-05-31 15:43:41 +02:00
|
|
|
; call mem_test
|
|
|
|
; call init_mem
|
2022-05-30 19:47:49 +02:00
|
|
|
; call init_page_map
|
2022-06-26 21:57:02 +02:00
|
|
|
mov [irq_mode], IRQ_APIC
|
|
|
|
mov [IOAPIC_base], ioapic_data
|
|
|
|
mov [LAPIC_BASE], lapic_data
|
|
|
|
mov [ioapic_cnt], 1
|
2022-05-30 19:47:49 +02:00
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
mov [xsave_area_size], 0x1000
|
|
|
|
|
2020-09-18 03:49:35 +02:00
|
|
|
mov ecx, pg_data.mutex
|
|
|
|
call mutex_init
|
|
|
|
|
|
|
|
mov ecx, disk_list_mutex
|
|
|
|
call mutex_init
|
|
|
|
|
|
|
|
mov ecx, keyboard_list_mutex
|
|
|
|
call mutex_init
|
|
|
|
|
|
|
|
mov ecx, unpack_mutex
|
|
|
|
call mutex_init
|
|
|
|
|
|
|
|
mov ecx, application_table_mutex
|
|
|
|
call mutex_init
|
|
|
|
|
|
|
|
mov ecx, ide_mutex
|
|
|
|
call mutex_init
|
|
|
|
mov ecx, ide_channel1_mutex
|
|
|
|
call mutex_init
|
|
|
|
mov ecx, ide_channel2_mutex
|
|
|
|
call mutex_init
|
|
|
|
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
|
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
mov [pg_data.mem_amount], UMKA_MEMORY_BYTES
|
|
|
|
mov [pg_data.pages_count], UMKA_MEMORY_BYTES / PAGE_SIZE
|
|
|
|
mov [pg_data.pages_free], UMKA_MEMORY_BYTES / PAGE_SIZE
|
|
|
|
mov eax, UMKA_MEMORY_BYTES SHR 12
|
2020-02-08 16:10:45 +01:00
|
|
|
mov [pg_data.kernel_pages], eax
|
|
|
|
shr eax, 10
|
|
|
|
mov [pg_data.kernel_tables], eax
|
2023-01-18 03:58:09 +01:00
|
|
|
|
|
|
|
call build_interrupt_table
|
2020-02-08 16:10:45 +01:00
|
|
|
call init_kernel_heap
|
|
|
|
call init_malloc
|
2019-10-25 03:48:13 +02:00
|
|
|
|
2020-05-09 04:15:57 +02:00
|
|
|
mov eax, sys_proc
|
|
|
|
list_init eax
|
|
|
|
add eax, PROC.thr_list
|
|
|
|
list_init eax
|
|
|
|
|
2020-02-09 02:48:16 +01:00
|
|
|
mov [BOOT.lfb], LFB_BASE
|
|
|
|
call init_video
|
|
|
|
|
2020-10-14 05:30:01 +02:00
|
|
|
stdcall alloc_kernel_space, 0x50000 ; FIXME check size
|
|
|
|
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
|
|
|
|
|
2020-02-08 19:27:29 +01:00
|
|
|
stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \
|
|
|
|
(unpack.lc+unpack.lp)))*4
|
|
|
|
mov [unpack.p], eax
|
|
|
|
|
2020-02-09 02:48:16 +01:00
|
|
|
call init_events
|
|
|
|
mov eax, srv.fd-SRV.fd
|
|
|
|
mov [srv.fd], eax
|
|
|
|
mov [srv.bk], eax
|
|
|
|
|
|
|
|
stdcall kernel_alloc, [_display.win_map_size]
|
2020-02-04 22:53:24 +01:00
|
|
|
mov [_display.win_map], eax
|
|
|
|
|
2020-02-09 02:48:16 +01:00
|
|
|
; set background
|
|
|
|
movi eax, 1
|
2020-02-04 22:53:24 +01:00
|
|
|
mov [BgrDrawMode], eax
|
|
|
|
mov [BgrDataWidth], eax
|
|
|
|
mov [BgrDataHeight], eax
|
|
|
|
mov [mem_BACKGROUND], 4
|
|
|
|
mov [img_background], static_background_data
|
|
|
|
|
2020-02-09 02:48:16 +01:00
|
|
|
; set clipboard
|
|
|
|
xor eax, eax
|
|
|
|
mov [clipboard_slots], eax
|
|
|
|
mov [clipboard_write_lock], eax
|
|
|
|
stdcall kernel_alloc, 4096
|
|
|
|
test eax, eax
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
dec eax
|
|
|
|
@@:
|
|
|
|
mov [clipboard_main_list], eax
|
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
mov dword[sysdir_name], 'sys'
|
|
|
|
mov dword[sysdir_path], 'RD/1'
|
|
|
|
mov word[sysdir_path+4], 0
|
2020-02-09 02:48:16 +01:00
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
;call ramdisk_init
|
2020-05-09 04:15:57 +02:00
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
mov [X_UNDER], 500
|
|
|
|
mov [Y_UNDER], 500
|
2020-05-09 04:15:57 +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
|
|
|
|
|
2021-06-23 18:43:26 +02:00
|
|
|
mov [current_slot_idx], 0
|
|
|
|
mov [thread_count], 0
|
2020-05-09 04:15:57 +02:00
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
mov eax, [xsave_area_size]
|
|
|
|
add eax, RING0_STACK_SIZE
|
|
|
|
stdcall kernel_alloc, eax
|
2020-05-09 04:15:57 +02:00
|
|
|
mov ebx, eax
|
|
|
|
mov edx, SLOT_BASE+256*1
|
|
|
|
call setup_os_slot
|
2020-05-11 05:38:44 +02:00
|
|
|
mov dword[edx], 'IDLE'
|
2020-05-09 04:15:57 +02:00
|
|
|
sub [edx+APPDATA.saved_esp], 4
|
|
|
|
mov eax, [edx+APPDATA.saved_esp]
|
2020-05-11 05:38:44 +02:00
|
|
|
mov dword[eax], idle
|
2020-05-09 04:15:57 +02:00
|
|
|
mov ecx, IDLE_PRIORITY
|
2020-10-10 01:30:52 +02:00
|
|
|
call scheduler_add_thread
|
2020-05-09 04:15:57 +02:00
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
mov eax, [xsave_area_size]
|
|
|
|
add eax, RING0_STACK_SIZE
|
|
|
|
stdcall kernel_alloc, eax
|
2020-05-09 04:15:57 +02:00
|
|
|
mov ebx, eax
|
2022-02-09 02:27:49 +01:00
|
|
|
mov edx, SLOT_BASE+sizeof.APPDATA*2
|
2020-05-09 04:15:57 +02:00
|
|
|
call setup_os_slot
|
2020-05-11 05:38:44 +02:00
|
|
|
mov dword[edx], 'OS'
|
2020-05-09 04:15:57 +02:00
|
|
|
sub [edx+APPDATA.saved_esp], 4
|
|
|
|
mov eax, [edx+APPDATA.saved_esp]
|
|
|
|
mov dword[eax], 0
|
2022-05-24 21:22:12 +02:00
|
|
|
movi ecx, MAX_PRIORITY
|
2020-10-10 01:30:52 +02:00
|
|
|
call scheduler_add_thread
|
2020-05-09 04:15:57 +02:00
|
|
|
|
2021-06-23 18:43:26 +02:00
|
|
|
mov [current_slot_idx], 2
|
|
|
|
mov [thread_count], 2
|
2020-10-12 05:02:02 +02:00
|
|
|
mov [current_slot], SLOT_BASE+2*sizeof.APPDATA
|
2022-02-09 02:27:49 +01:00
|
|
|
mov [SLOT_BASE + 2*sizeof.APPDATA + APPDATA.tid], 2
|
2020-05-09 04:15:57 +02:00
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
call set_window_defaults
|
|
|
|
call init_background
|
|
|
|
call calculatebackground
|
|
|
|
call init_display
|
|
|
|
mov eax, [def_cursor]
|
2020-10-12 05:02:02 +02:00
|
|
|
mov [SLOT_BASE+APPDATA.cursor+sizeof.APPDATA], eax
|
|
|
|
mov [SLOT_BASE+APPDATA.cursor+sizeof.APPDATA*2], eax
|
2020-05-11 05:38:44 +02:00
|
|
|
|
|
|
|
; from set_variables
|
2022-05-28 23:55:13 +02:00
|
|
|
mov ax, [BOOT.y_res]
|
|
|
|
shr ax, 1
|
|
|
|
shl eax, 16
|
|
|
|
mov ax, [BOOT.x_res]
|
|
|
|
shr ax, 1
|
|
|
|
mov [MOUSE_X], eax
|
|
|
|
call wakeup_osloop
|
|
|
|
|
2020-05-11 05:38:44 +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
|
|
|
|
|
2020-10-12 05:02:02 +02:00
|
|
|
mov ebx, SLOT_BASE + 2*sizeof.APPDATA
|
2020-05-11 05:38:44 +02:00
|
|
|
mov word[cur_dir.path], '/'
|
|
|
|
mov [ebx+APPDATA.cur_dir], cur_dir
|
2022-06-26 21:57:02 +02:00
|
|
|
; end of set_variables
|
|
|
|
|
|
|
|
call init_irqs
|
2020-05-11 05:38:44 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym skin_udata
|
2020-05-11 05:38:44 +02:00
|
|
|
proc idle uses ebx esi edi
|
2023-01-12 22:24:06 +01:00
|
|
|
sti
|
2020-05-11 05:38:44 +02:00
|
|
|
@@:
|
2023-01-12 22:24:06 +01:00
|
|
|
; DEBUGF 1, "1 idle\n"
|
2023-01-21 08:49:13 +01:00
|
|
|
movi eax, SYS_PAUSE
|
|
|
|
int 0x80
|
|
|
|
jmp @b
|
2020-05-11 05:38:44 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
extrn pci_read, 20
|
2022-02-09 02:27:49 +01:00
|
|
|
proc _pci_read_reg uses ebx esi edi
|
2020-05-02 00:09:42 +02:00
|
|
|
mov ecx, eax
|
|
|
|
and ecx, 3
|
|
|
|
movi edx, 1
|
|
|
|
shl edx, cl
|
|
|
|
push edx ; len
|
|
|
|
movzx edx, bl
|
|
|
|
push edx ; offset
|
|
|
|
movzx edx, bh
|
|
|
|
and edx, 7
|
|
|
|
push edx ; fun
|
|
|
|
movzx edx, bh
|
|
|
|
shr edx, 3
|
|
|
|
push edx ; dev
|
|
|
|
movzx edx, ah
|
|
|
|
push edx ; bus
|
|
|
|
call pci_read
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2023-01-12 22:24:06 +01:00
|
|
|
proc _page_fault_handler
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2023-01-30 07:24:23 +01:00
|
|
|
proc s2ys_msg_board
|
2019-10-13 03:17:29 +02:00
|
|
|
cmp cl, 0x0d
|
|
|
|
jz @f
|
2021-12-13 13:58:19 +01:00
|
|
|
if HOST eq windows
|
2021-12-12 11:35:35 +01:00
|
|
|
extrn putchar
|
|
|
|
pushad
|
|
|
|
push ecx
|
|
|
|
call putchar
|
|
|
|
pop ecx
|
|
|
|
popad
|
2021-12-13 13:58:19 +01:00
|
|
|
else if HOST eq linux
|
2017-10-18 22:19:53 +02:00
|
|
|
pushad
|
|
|
|
mov eax, SYS_WRITE
|
|
|
|
mov ebx, STDOUT
|
|
|
|
push ecx
|
|
|
|
mov ecx, esp
|
|
|
|
mov edx, 1
|
|
|
|
int 0x80
|
|
|
|
pop ecx
|
|
|
|
popad
|
2021-12-13 13:58:19 +01:00
|
|
|
else
|
|
|
|
error "Your OS is not supported"
|
2021-12-12 11:35:35 +01:00
|
|
|
end if
|
2019-10-13 03:17:29 +02:00
|
|
|
@@:
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2020-10-10 01:30:52 +02:00
|
|
|
proc delay_ms
|
|
|
|
|
2020-05-02 00:09:42 +02:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym umka_cli
|
2020-10-14 19:56:28 +02:00
|
|
|
proc umka_cli
|
|
|
|
cli ; macro
|
|
|
|
ret
|
|
|
|
endp
|
2020-10-14 05:30:01 +02:00
|
|
|
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym umka_sti
|
2020-10-14 19:56:28 +02:00
|
|
|
proc umka_sti
|
|
|
|
sti ; macro
|
2020-10-14 05:30:01 +02:00
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2020-10-10 01:30:52 +02:00
|
|
|
extrn reset_procmask
|
|
|
|
extrn get_fake_if
|
2021-12-12 11:35:35 +01:00
|
|
|
pubsym irq0
|
2020-10-10 01:30:52 +02:00
|
|
|
proc irq0 c, _signo, _info, _context
|
2023-01-30 07:24:23 +01:00
|
|
|
DEBUGF 1, "### irq0\n"
|
2020-10-10 01:30:52 +02:00
|
|
|
pushfd
|
2020-10-14 05:30:01 +02:00
|
|
|
cli
|
2020-10-10 01:30:52 +02:00
|
|
|
pushad
|
|
|
|
|
2020-10-14 05:30:01 +02:00
|
|
|
inc [timer_ticks]
|
|
|
|
call updatecputimes
|
2022-05-24 21:22:12 +02:00
|
|
|
ccall reset_procmask ; kind of irq_eoi:ta
|
2020-10-10 01:30:52 +02:00
|
|
|
ccall get_fake_if, [_context]
|
|
|
|
test eax, eax
|
2020-10-14 05:30:01 +02:00
|
|
|
jnz @f
|
2023-01-30 07:24:23 +01:00
|
|
|
DEBUGF 1, "### cli\n"
|
2020-10-14 05:30:01 +02:00
|
|
|
jmp .done
|
|
|
|
@@:
|
2020-10-10 01:30:52 +02:00
|
|
|
|
|
|
|
mov bl, SCHEDULE_ANY_PRIORITY
|
|
|
|
call find_next_task
|
|
|
|
jz .done ; if there is only one running process
|
2020-10-12 05:02:02 +02:00
|
|
|
call _do_change_task
|
2020-10-10 01:30:52 +02:00
|
|
|
.done:
|
|
|
|
popad
|
|
|
|
popfd
|
2020-05-06 23:33:32 +02:00
|
|
|
ret
|
2020-10-10 01:30:52 +02:00
|
|
|
endp
|
2020-05-06 23:33:32 +02:00
|
|
|
|
2020-10-10 01:30:52 +02:00
|
|
|
proc _do_change_task
|
|
|
|
mov eax, [current_slot]
|
|
|
|
sub eax, SLOT_BASE
|
|
|
|
shr eax, 8
|
|
|
|
mov ecx, ebx
|
|
|
|
sub ecx, SLOT_BASE
|
|
|
|
shr ecx, 8
|
2023-01-30 07:24:23 +01:00
|
|
|
DEBUGF 1, "### switching task from %d to %d\n",eax,ecx
|
2020-10-10 01:30:52 +02:00
|
|
|
|
|
|
|
mov esi, ebx
|
|
|
|
xchg esi, [current_slot]
|
|
|
|
; set new stack after saving old
|
|
|
|
mov [esi+APPDATA.saved_esp], esp
|
|
|
|
mov esp, [ebx+APPDATA.saved_esp]
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
proc map_io_mem _base, _size, _flags
|
|
|
|
mov eax, [_base]
|
2020-05-09 06:34:28 +02:00
|
|
|
ret
|
|
|
|
endp
|
2020-02-27 22:22:44 +01:00
|
|
|
|
2022-05-31 15:43:41 +02:00
|
|
|
;proc user_alloc_at stdcall, address:dword, alloc_size:dword
|
|
|
|
; xor eax, eax
|
|
|
|
; ret
|
|
|
|
;endp
|
|
|
|
|
2022-05-24 21:22:12 +02:00
|
|
|
extrn system_shutdown
|
|
|
|
|
2020-02-10 06:09:17 +01:00
|
|
|
sysfn_saveramdisk:
|
2022-05-30 19:47:49 +02:00
|
|
|
;sysfn_meminfo:
|
2020-02-10 06:09:17 +01:00
|
|
|
check_fdd_motor_status:
|
|
|
|
check_ATAPI_device_event:
|
|
|
|
check_fdd_motor_status_has_work?:
|
|
|
|
check_ATAPI_device_event_has_work?:
|
|
|
|
LoadMedium:
|
|
|
|
clear_CD_cache:
|
|
|
|
allow_medium_removal:
|
|
|
|
EjectMedium:
|
|
|
|
save_image:
|
|
|
|
init_sys_v86:
|
2022-05-30 19:47:49 +02:00
|
|
|
;load_pe_driver:
|
2020-02-10 06:09:17 +01:00
|
|
|
usb_init:
|
|
|
|
fdc_init:
|
|
|
|
mtrr_validate:
|
2023-01-12 22:24:06 +01:00
|
|
|
; sys32.inc
|
|
|
|
;terminate:
|
|
|
|
;protect_from_terminate:
|
|
|
|
;unprotect_from_terminate:
|
|
|
|
;lock_application_table:
|
|
|
|
;unlock_application_table:
|
|
|
|
;sys_resize_app_memory:
|
|
|
|
;request_terminate:
|
|
|
|
v86_exc_c:
|
|
|
|
except_7:
|
2018-05-04 20:18:09 +02:00
|
|
|
ReadCDWRetr:
|
|
|
|
WaitUnitReady:
|
|
|
|
prevent_medium_removal:
|
|
|
|
Read_TOC:
|
2020-02-08 16:10:45 +01:00
|
|
|
free_page:
|
2020-02-10 06:09:17 +01:00
|
|
|
init_fpu:
|
|
|
|
init_mtrr:
|
|
|
|
create_trampoline_pgmap:
|
2020-02-27 22:22:44 +01:00
|
|
|
alloc_page:
|
|
|
|
|
2022-05-30 19:47:49 +02:00
|
|
|
;sys_IPC:
|
|
|
|
;f68:
|
2020-09-17 19:51:03 +02:00
|
|
|
v86_irq:
|
2022-05-30 19:47:49 +02:00
|
|
|
;test_cpu:
|
|
|
|
;acpi_locate:
|
|
|
|
;init_BIOS32:
|
|
|
|
;mem_test:
|
|
|
|
;init_mem:
|
|
|
|
;init_page_map:
|
2021-09-20 05:58:21 +02:00
|
|
|
ahci_init:
|
2021-12-01 20:17:02 +01:00
|
|
|
enable_acpi:
|
|
|
|
acpi.call_name:
|
|
|
|
acpi.count_nodes:
|
|
|
|
acpi.aml.init:
|
|
|
|
aml._.attach:
|
|
|
|
acpi.fill_pci_irqs:
|
|
|
|
pci.walk_tree:
|
|
|
|
acpi.aml.new_thread:
|
|
|
|
aml._.alloc_node:
|
|
|
|
aml._.constructor.integer:
|
|
|
|
aml._.constructor.package:
|
|
|
|
acpi._.lookup_node:
|
|
|
|
acpi._.print_tree:
|
2020-02-06 04:19:20 +01:00
|
|
|
ret
|
2018-05-04 20:18:09 +02:00
|
|
|
|
2022-05-30 19:47:49 +02:00
|
|
|
load_PE:
|
2020-02-27 22:22:44 +01:00
|
|
|
alloc_pages:
|
|
|
|
ret 4
|
2022-05-30 19:47:49 +02:00
|
|
|
;create_ring_buffer:
|
2020-02-27 22:22:44 +01:00
|
|
|
ret 8
|
2022-05-30 19:47:49 +02:00
|
|
|
;map_page:
|
2020-02-27 22:22:44 +01:00
|
|
|
ret 12
|
2022-05-30 19:47:49 +02:00
|
|
|
;map_memEx:
|
2020-02-27 22:22:44 +01:00
|
|
|
ret 20
|
2020-02-10 06:09:17 +01:00
|
|
|
|
2021-12-01 20:17:02 +01:00
|
|
|
uglobal
|
|
|
|
acpi_ctx dd ?
|
|
|
|
acpi_usage dd ?
|
|
|
|
acpi_node_alloc_cnt dd ?
|
|
|
|
acpi_node_free_cnt dd ?
|
|
|
|
pci_root dd ?
|
|
|
|
acpi_root dd ?
|
|
|
|
acpi_dev_next dd ?
|
|
|
|
endg
|
|
|
|
|
2020-12-09 15:15:54 +01:00
|
|
|
delay_ms equ __pex1
|
2020-02-10 06:09:17 +01:00
|
|
|
|
|
|
|
include fix pew
|
2020-02-27 22:22:44 +01:00
|
|
|
macro pew x {}
|
2020-02-29 02:04:32 +01:00
|
|
|
macro pew x {inclu#de `x}
|
2020-02-10 06:09:17 +01:00
|
|
|
macro org x {}
|
2020-02-27 22:22:44 +01:00
|
|
|
macro format [x] {}
|
2020-02-17 02:52:44 +01:00
|
|
|
|
2022-05-31 15:43:41 +02:00
|
|
|
bios32_entry equ bios32_entry_pew
|
|
|
|
tmp_page_tabs equ tmp_page_tabs_pew
|
2022-06-28 18:13:41 +02:00
|
|
|
macro jmp target {
|
|
|
|
if target eq osloop
|
2023-01-18 09:29:08 +01:00
|
|
|
cmp [umka.running], 1
|
|
|
|
jz osloop
|
2022-06-28 18:13:41 +02:00
|
|
|
ret
|
|
|
|
else
|
|
|
|
jmp target
|
|
|
|
end if
|
|
|
|
}
|
2020-02-29 02:04:32 +01:00
|
|
|
include 'kernel.asm'
|
2022-06-28 18:13:41 +02:00
|
|
|
purge jmp
|
2022-05-31 15:43:41 +02:00
|
|
|
restore bios32_entry, tmp_page_tabs
|
2023-01-30 07:24:23 +01:00
|
|
|
purge org,delay_ms
|
|
|
|
restore org,delay_ms
|
2020-02-10 06:09:17 +01:00
|
|
|
|
2019-10-09 01:35:47 +02:00
|
|
|
coverage_end:
|
|
|
|
|
2022-05-31 15:43:41 +02:00
|
|
|
|
2023-02-01 19:30:44 +01:00
|
|
|
; cov for coverage; otherwide fasm complains with 'name too long' for MS COFF
|
|
|
|
section '.bss.cov' executable writable align 64
|
2022-06-13 23:46:48 +02:00
|
|
|
struct coverage_branch
|
|
|
|
to_cnt DQ ?
|
|
|
|
from_cnt DQ ?
|
|
|
|
ends
|
|
|
|
|
|
|
|
COVERAGE_TABLE_SIZE = 512*1024 ; 512k should be enough for the kernel
|
|
|
|
|
|
|
|
coverage_table rb COVERAGE_TABLE_SIZE * sizeof.coverage_branch
|
|
|
|
pubsym coverage_table
|
|
|
|
|
|
|
|
|
2023-02-01 19:30:44 +01:00
|
|
|
; bt for boot; otherwide fasm complains with 'name too long' for MS COFF
|
|
|
|
section '.data.bt' writeable align 0x1000
|
2022-05-31 15:43:41 +02:00
|
|
|
BOOT boot_data
|
|
|
|
virtual at BOOT
|
|
|
|
BOOT_LO boot_data
|
|
|
|
end virtual
|
|
|
|
|
|
|
|
|
2021-12-13 13:58:19 +01:00
|
|
|
if HOST eq windows
|
2021-12-12 11:35:35 +01:00
|
|
|
section '.data.8k' writeable align 8192
|
2021-12-13 13:58:19 +01:00
|
|
|
else if HOST eq linux
|
2021-12-12 11:35:35 +01:00
|
|
|
; fasm doesn't align on 65536, but ld script does
|
|
|
|
section '.data.aligned65k' writeable align 65536
|
2021-12-13 13:58:19 +01:00
|
|
|
else
|
|
|
|
error "Your OS is not supported"
|
2021-12-12 11:35:35 +01:00
|
|
|
end if
|
2023-01-17 01:49:11 +01:00
|
|
|
|
2023-01-18 09:29:08 +01:00
|
|
|
umka umka_ctx
|
2020-02-08 16:10:45 +01:00
|
|
|
fpu_owner dd ?
|
2020-02-04 22:53:24 +01:00
|
|
|
|
2020-12-17 17:42:14 +01:00
|
|
|
uglobal
|
|
|
|
align 64
|
2021-07-17 02:03:36 +02:00
|
|
|
os_base: rb PAGE_SIZE
|
|
|
|
window_data: rb sizeof.WDATA * 256
|
2021-07-17 04:15:14 +02:00
|
|
|
CDDataBuf: rb 0x1000
|
2023-01-18 03:58:09 +01:00
|
|
|
idts rb (NUM_EXCEPTIONS + IRQ_RESERVED) * sizeof.idt_entry
|
2021-07-17 04:15:14 +02:00
|
|
|
WIN_STACK rw 0x200 ; why not 0x100?
|
|
|
|
WIN_POS rw 0x200
|
|
|
|
FDD_BUFF: rb 0x400
|
2020-12-17 17:42:14 +01:00
|
|
|
WIN_TEMP_XY rb 0x100
|
|
|
|
KEY_COUNT db ?
|
2022-05-28 23:55:13 +02:00
|
|
|
KEY_BUFF rb 244 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes
|
2020-12-17 17:42:14 +01:00
|
|
|
BTN_COUNT db ?
|
|
|
|
BTN_BUFF rd 0x261
|
|
|
|
BTN_ADDR dd ?
|
|
|
|
MEM_AMOUNT rd 0x1d
|
|
|
|
SYS_SHUTDOWN db ?
|
2021-07-17 04:15:14 +02:00
|
|
|
sys_proc: rb sizeof.PROC * 256
|
|
|
|
rb 0x10000 - (($-bss_base) AND (0x10000-1)) ; align on 0x10000
|
2021-07-17 02:03:36 +02:00
|
|
|
SLOT_BASE: rb sizeof.APPDATA * 256
|
2020-12-17 17:42:14 +01:00
|
|
|
VGABasePtr rb 640*480
|
2021-07-17 00:54:33 +02:00
|
|
|
rb PAGE_SIZE - (($-bss_base) AND (PAGE_SIZE-1)) ; align on page
|
|
|
|
HEAP_BASE rb UMKA_MEMORY_BYTES - (HEAP_BASE - os_base + \
|
|
|
|
PAGE_SIZE * sizeof.MEM_BLOCK)
|
2020-12-17 17:42:14 +01:00
|
|
|
endg
|
|
|
|
|
2020-02-09 02:48:16 +01:00
|
|
|
uglobal
|
2022-05-31 15:43:41 +02:00
|
|
|
align 4
|
|
|
|
bios32_entry dd ?
|
|
|
|
tmp_page_tabs dd ?
|
|
|
|
|
2022-05-30 19:47:49 +02:00
|
|
|
page_tabs:
|
|
|
|
rb 256*1024*1024
|
2020-09-17 19:51:03 +02:00
|
|
|
v86_irqhooks rd IRQ_RESERVED*2
|
2020-02-10 06:09:17 +01:00
|
|
|
cache_ide0 IDE_CACHE
|
|
|
|
cache_ide1 IDE_CACHE
|
2018-05-04 20:18:09 +02:00
|
|
|
DiskNumber db ?
|
|
|
|
ChannelNumber db ?
|
|
|
|
DevErrorCode dd ?
|
|
|
|
CDSectorAddress dd ?
|
|
|
|
CDDataBuf_pointer dd ?
|
2020-02-10 06:09:17 +01:00
|
|
|
allow_dma_access db ?
|
|
|
|
ide_mutex MUTEX
|
2018-05-18 09:09:05 +02:00
|
|
|
ide_channel1_mutex MUTEX
|
|
|
|
ide_channel2_mutex MUTEX
|
|
|
|
ide_channel3_mutex MUTEX
|
|
|
|
ide_channel4_mutex MUTEX
|
|
|
|
ide_channel5_mutex MUTEX
|
|
|
|
ide_channel6_mutex MUTEX
|
|
|
|
ide_channel7_mutex MUTEX
|
|
|
|
ide_channel8_mutex MUTEX
|
2020-11-19 02:16:45 +01:00
|
|
|
|
2022-06-26 21:57:02 +02:00
|
|
|
ioapic_data rb 0x400
|
|
|
|
lapic_data rb 0x400
|
2022-06-27 14:32:29 +02:00
|
|
|
tss TSS
|
2022-06-26 21:57:02 +02:00
|
|
|
|
2020-10-22 01:44:34 +02:00
|
|
|
lfb_base rd MAX_SCREEN_WIDTH*MAX_SCREEN_HEIGHT
|
|
|
|
|
2020-10-12 05:02:02 +02:00
|
|
|
align 4096
|
2019-10-25 03:48:13 +02:00
|
|
|
cur_dir:
|
|
|
|
.encoding rb 1
|
|
|
|
.path rb maxPathLength
|
2020-02-04 22:53:24 +01:00
|
|
|
|
|
|
|
BgrAuxTable rb 32768
|
|
|
|
BgrAuxTable equ
|
|
|
|
SB16Buffer rb 65536
|
|
|
|
SB16Buffer equ
|
|
|
|
BUTTON_INFO rb 64*1024
|
|
|
|
BUTTON_INFO equ
|
2020-02-09 02:48:16 +01:00
|
|
|
endg
|
2020-02-04 22:53:24 +01:00
|
|
|
|
2020-09-18 05:00:32 +02:00
|
|
|
macro org x {
|
|
|
|
if x eq (OS_BASE+0x0100000)
|
|
|
|
else
|
|
|
|
org x
|
|
|
|
end if
|
|
|
|
}
|
|
|
|
|
|
|
|
macro align x {
|
|
|
|
if x eq 65536
|
|
|
|
else if x eq 4096
|
|
|
|
else
|
|
|
|
align x
|
|
|
|
end if
|
|
|
|
}
|
|
|
|
|
2020-10-08 23:19:53 +02:00
|
|
|
macro assert [x] {}
|
2022-06-27 14:32:29 +02:00
|
|
|
macro dw [x] {
|
|
|
|
forward
|
|
|
|
if x eq tss and 0xFFFF
|
|
|
|
dw 0
|
|
|
|
else if x eq (tss shr 16) and 0xFF00
|
|
|
|
dw 0
|
2023-01-12 22:24:06 +01:00
|
|
|
else if x eq i40 and 0xFFFF
|
|
|
|
dw 0
|
|
|
|
else if x eq i40 shr 16
|
|
|
|
dw 0
|
2022-06-27 14:32:29 +02:00
|
|
|
else
|
|
|
|
dw x
|
|
|
|
end if
|
|
|
|
}
|
|
|
|
|
|
|
|
macro db [x] {
|
|
|
|
forward
|
|
|
|
if x eq (tss shr 16) and 0xFF
|
|
|
|
db 0
|
|
|
|
else
|
|
|
|
db x
|
|
|
|
end if
|
|
|
|
}
|
2020-02-29 02:04:32 +01:00
|
|
|
include 'data32.inc'
|