2020-12-09 15:15:54 +01:00
|
|
|
; TODO: SPDX
|
|
|
|
|
2017-10-18 22:19:53 +02:00
|
|
|
format ELF
|
|
|
|
|
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
|
|
|
UMKA_DISPLAY_WIDTH = 400
|
|
|
|
UMKA_DISPLAY_HEIGHT = 300
|
|
|
|
|
2020-02-21 00:18:40 +01:00
|
|
|
public disk_add
|
|
|
|
public disk_del
|
|
|
|
public disk_list
|
|
|
|
public disk_media_changed
|
|
|
|
|
|
|
|
public xfs._.user_functions as 'xfs_user_functions'
|
|
|
|
public ext_user_functions
|
|
|
|
public fat_user_functions
|
|
|
|
public ntfs_user_functions
|
|
|
|
|
|
|
|
public i40
|
|
|
|
|
|
|
|
public coverage_begin
|
|
|
|
public coverage_end
|
|
|
|
|
|
|
|
public sha3_256_oneshot as 'hash_oneshot'
|
|
|
|
public kos_time_to_epoch
|
2020-10-14 19:56:28 +02:00
|
|
|
public umka_init
|
2020-02-21 00:18:40 +01:00
|
|
|
|
2021-07-17 04:15:14 +02:00
|
|
|
public current_process as 'kos_current_process'
|
|
|
|
public current_slot as 'kos_current_slot'
|
|
|
|
public current_slot_idx as 'kos_current_slot_idx'
|
|
|
|
|
2021-06-23 18:43:26 +02:00
|
|
|
public thread_count as 'kos_thread_count'
|
2021-07-17 04:15:14 +02:00
|
|
|
public TASK_TABLE as 'kos_task_table'
|
2020-05-10 06:21:49 +02:00
|
|
|
public TASK_BASE as 'kos_task_base'
|
2020-09-17 03:40:25 +02:00
|
|
|
public TASK_DATA as 'kos_task_data'
|
|
|
|
public SLOT_BASE as 'kos_slot_base'
|
2020-05-09 04:15:57 +02:00
|
|
|
|
2020-09-17 03:40:25 +02:00
|
|
|
public WIN_STACK as 'kos_win_stack'
|
|
|
|
public WIN_POS as 'kos_win_pos'
|
|
|
|
public lfb_base as 'kos_lfb_base'
|
2019-10-09 01:35:47 +02:00
|
|
|
|
2020-09-18 05:00:32 +02:00
|
|
|
public RAMDISK as 'kos_ramdisk'
|
2020-09-18 14:26:51 +02:00
|
|
|
public ramdisk_init as 'kos_ramdisk_init'
|
2020-09-18 05:00:32 +02:00
|
|
|
|
2020-05-06 23:33:32 +02:00
|
|
|
public enable_acpi
|
2020-09-17 03:40:25 +02:00
|
|
|
public acpi.call_name
|
2020-05-02 00:09:42 +02:00
|
|
|
public acpi_ssdt_cnt as 'kos_acpi_ssdt_cnt'
|
2020-09-17 03:40:25 +02:00
|
|
|
public acpi_ssdt_base as 'kos_acpi_ssdt_base'
|
|
|
|
public acpi_ssdt_size as 'kos_acpi_ssdt_size'
|
|
|
|
public acpi_ctx
|
2020-05-20 13:03:22 +02:00
|
|
|
public acpi_usage as 'kos_acpi_usage'
|
2021-05-31 16:32:04 +02:00
|
|
|
public acpi_node_alloc_cnt as 'kos_acpi_node_alloc_cnt'
|
|
|
|
public acpi_node_free_cnt as 'kos_acpi_node_free_cnt'
|
|
|
|
public acpi.count_nodes as 'kos_acpi_count_nodes'
|
2020-05-02 00:09:42 +02:00
|
|
|
|
2020-10-14 19:56:28 +02:00
|
|
|
public stack_init as 'kos_stack_init'
|
2020-05-06 23:33:32 +02:00
|
|
|
public net_add_device
|
|
|
|
|
2020-05-11 05:38:44 +02:00
|
|
|
public draw_data
|
|
|
|
public img_background
|
|
|
|
public mem_BACKGROUND
|
|
|
|
public sys_background
|
|
|
|
public REDRAW_BACKGROUND
|
2020-10-14 19:56:28 +02:00
|
|
|
public new_sys_threads as 'kos_new_sys_threads'
|
|
|
|
public osloop as 'kos_osloop'
|
2020-10-12 05:02:02 +02:00
|
|
|
public set_mouse_data as 'kos_set_mouse_data'
|
2020-10-14 05:30:01 +02:00
|
|
|
public scheduler_current as 'kos_scheduler_current'
|
|
|
|
public eth_input as 'kos_eth_input'
|
2020-10-14 19:56:28 +02:00
|
|
|
public net_buff_alloc as 'kos_net_buff_alloc'
|
2020-05-11 05:38:44 +02:00
|
|
|
|
2020-10-21 16:57:54 +02:00
|
|
|
public mem_block_list
|
2020-12-17 17:42:14 +01:00
|
|
|
public pci_root
|
2020-10-21 16:57:54 +02:00
|
|
|
|
2020-05-09 05:41:32 +02:00
|
|
|
macro cli {
|
|
|
|
pushfd
|
2020-10-10 01:30:52 +02:00
|
|
|
bts dword[esp], 21
|
2020-05-09 05:41:32 +02:00
|
|
|
popfd
|
|
|
|
}
|
|
|
|
|
|
|
|
macro sti {
|
|
|
|
pushfd
|
2020-10-10 01:30:52 +02:00
|
|
|
btr dword[esp], 21
|
2020-05-09 05:41:32 +02:00
|
|
|
popfd
|
|
|
|
}
|
|
|
|
|
2020-02-06 04:19:20 +01:00
|
|
|
iretd equ retd
|
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
|
|
|
|
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-07-17 00:54:33 +02:00
|
|
|
; fasm doesn't align on 65536, but ld script does
|
|
|
|
section '.bss.aligned65k' writeable align 65536
|
|
|
|
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
|
2021-06-23 18:43:26 +02:00
|
|
|
TASK_TABLE equ __pew02
|
2020-10-21 16:57:54 +02:00
|
|
|
TASK_BASE equ __pew03
|
|
|
|
TASK_DATA equ __pew04
|
|
|
|
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
|
2020-09-18 05:00:32 +02:00
|
|
|
;macro OS_BASE [x] {
|
|
|
|
; OS_BASE equ os_base
|
|
|
|
;}
|
2017-10-18 22:19:53 +02:00
|
|
|
include 'const.inc'
|
2020-02-10 06:09:17 +01:00
|
|
|
restore window_data
|
2021-06-23 18:43:26 +02:00
|
|
|
restore TASK_TABLE
|
2021-07-17 02:03:36 +02:00
|
|
|
restore TASK_BASE,TASK_DATA,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
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
macro add r, v {
|
2021-06-23 18:43:26 +02:00
|
|
|
if v eq TASK_TABLE - (SLOT_BASE shr 3)
|
2020-09-17 19:51:03 +02:00
|
|
|
push r
|
|
|
|
mov r, SLOT_BASE
|
|
|
|
shr r, 3
|
|
|
|
neg r
|
2021-06-23 18:43:26 +02:00
|
|
|
add r, TASK_TABLE
|
2020-09-17 19:51:03 +02:00
|
|
|
add esp, 4
|
2020-10-10 01:30:52 +02:00
|
|
|
add r, [esp-4]
|
2020-09-17 19:51:03 +02:00
|
|
|
else
|
|
|
|
add r, v
|
|
|
|
end if
|
|
|
|
}
|
|
|
|
|
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
|
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
|
|
|
|
2020-09-18 03:49:35 +02:00
|
|
|
include 'core/sync.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
;include 'core/sys32.inc'
|
2020-10-10 01:30:52 +02:00
|
|
|
macro call target {
|
|
|
|
if target eq do_change_task
|
|
|
|
call _do_change_task
|
|
|
|
else
|
|
|
|
call target
|
|
|
|
end if
|
|
|
|
}
|
2021-07-17 04:15:14 +02:00
|
|
|
;macro mov r, v {
|
|
|
|
; if r eq byte [current_slot_idx] & v eq bh
|
|
|
|
; push eax
|
|
|
|
; mov eax, ebx
|
|
|
|
; sub eax, SLOT_BASE
|
|
|
|
; shr eax, BSF sizeof.APPDATA
|
|
|
|
; mov [current_slot_idx], eax
|
|
|
|
; pop eax
|
|
|
|
; else
|
|
|
|
; mov r, v
|
|
|
|
; end if
|
|
|
|
;}
|
2020-10-10 01:30:52 +02:00
|
|
|
do_change_task equ hjk
|
|
|
|
irq0 equ jhg
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/sched.inc'
|
2021-07-17 00:54:33 +02:00
|
|
|
purge call, 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'
|
|
|
|
;include 'core/memory.inc'
|
|
|
|
;include 'core/mtrr.inc'
|
2020-02-08 16:10:45 +01:00
|
|
|
include 'core/heap.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/malloc.inc'
|
2020-02-08 16:10:45 +01:00
|
|
|
include 'core/taskman.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
include 'core/dll.inc'
|
|
|
|
;include 'core/peload.inc'
|
|
|
|
;include 'core/exports.inc'
|
|
|
|
include 'core/string.inc'
|
|
|
|
;include 'core/v86.inc'
|
|
|
|
include 'core/irq.inc'
|
|
|
|
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'
|
|
|
|
|
2020-02-07 03:26:27 +01:00
|
|
|
include 'hid/keyboard.inc'
|
2020-02-10 06:09:17 +01:00
|
|
|
include 'hid/mousedrv.inc'
|
2020-09-18 04:31:10 +02:00
|
|
|
;include 'hid/set_dtc.inc' ; setting date,time,clock and alarm-clock
|
|
|
|
|
|
|
|
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'
|
|
|
|
|
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
|
|
|
|
add eax, 978307200 ; epoch to 2001.01.01
|
|
|
|
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
|
|
|
|
|
2020-10-14 19:56:28 +02:00
|
|
|
proc umka_init c uses ebx esi edi ebp
|
2020-10-22 01:44:34 +02:00
|
|
|
call umka._.check_alignment
|
|
|
|
|
2020-02-07 03:26:27 +01:00
|
|
|
mov edi, endofcode
|
|
|
|
mov ecx, uglobals_size
|
|
|
|
xor eax, eax
|
|
|
|
rep stosb
|
|
|
|
|
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
|
|
|
|
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.bpp], 32
|
2020-05-11 05:38:44 +02:00
|
|
|
mov [BOOT.x_res], UMKA_DISPLAY_WIDTH
|
|
|
|
mov [BOOT.y_res], UMKA_DISPLAY_HEIGHT
|
|
|
|
mov [BOOT.pitch], UMKA_DISPLAY_WIDTH*4
|
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
|
|
|
|
mov word[MOUSE_X], 40
|
|
|
|
mov word[MOUSE_Y], 30
|
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
|
|
|
|
mov edx, SLOT_BASE+256*2
|
|
|
|
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
|
|
|
|
xor ecx, ecx
|
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
|
|
|
|
mov dword[TASK_BASE], TASK_TABLE + 2*sizeof.TASKDATA
|
2020-10-12 05:02:02 +02:00
|
|
|
mov [current_slot], SLOT_BASE+2*sizeof.APPDATA
|
2021-06-23 18:43:26 +02:00
|
|
|
mov [TASK_TABLE + 2*sizeof.TASKDATA + TASKDATA.pid], 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
|
|
|
|
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
|
|
|
|
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
public skin_udata
|
|
|
|
proc idle uses ebx esi edi
|
|
|
|
.loop:
|
|
|
|
mov ecx, 10000000
|
|
|
|
@@:
|
|
|
|
loop @b
|
|
|
|
; DEBUGF 1, "1 idle\n"
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2020-05-02 00:09:42 +02:00
|
|
|
extrn pci_read
|
|
|
|
proc pci_read_reg uses ebx esi edi
|
|
|
|
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
|
|
|
|
|
2020-02-10 06:09:17 +01:00
|
|
|
proc sys_msg_board
|
2019-10-13 03:17:29 +02:00
|
|
|
cmp cl, 0x0d
|
|
|
|
jz @f
|
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
|
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
|
|
|
|
|
2020-10-14 19:56:28 +02:00
|
|
|
public umka_cli
|
|
|
|
proc umka_cli
|
|
|
|
cli ; macro
|
|
|
|
ret
|
|
|
|
endp
|
2020-10-14 05:30:01 +02:00
|
|
|
|
2020-10-14 19:56:28 +02:00
|
|
|
public umka_sti
|
|
|
|
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
|
|
|
|
public irq0
|
|
|
|
proc irq0 c, _signo, _info, _context
|
2020-10-14 05:30:01 +02:00
|
|
|
DEBUGF 2, "### 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
|
2020-10-10 01:30:52 +02:00
|
|
|
ccall reset_procmask
|
|
|
|
ccall get_fake_if, [_context]
|
|
|
|
test eax, eax
|
2020-10-14 05:30:01 +02:00
|
|
|
jnz @f
|
|
|
|
DEBUGF 2, "### cli\n"
|
|
|
|
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
|
|
|
|
DEBUGF 2, "### switching task from %d to %d\n",eax,ecx
|
|
|
|
|
|
|
|
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
|
|
|
|
2020-02-10 06:09:17 +01:00
|
|
|
sysfn_saveramdisk:
|
|
|
|
sysfn_meminfo:
|
|
|
|
check_fdd_motor_status:
|
|
|
|
check_ATAPI_device_event:
|
|
|
|
check_fdd_motor_status_has_work?:
|
|
|
|
check_ATAPI_device_event_has_work?:
|
|
|
|
request_terminate:
|
|
|
|
system_shutdown:
|
|
|
|
terminate:
|
|
|
|
LoadMedium:
|
|
|
|
clear_CD_cache:
|
|
|
|
allow_medium_removal:
|
|
|
|
EjectMedium:
|
|
|
|
save_image:
|
|
|
|
init_sys_v86:
|
|
|
|
pci_enum:
|
|
|
|
load_pe_driver:
|
|
|
|
usb_init:
|
|
|
|
fdc_init:
|
|
|
|
mtrr_validate:
|
2018-05-04 20:18:09 +02:00
|
|
|
protect_from_terminate:
|
|
|
|
unprotect_from_terminate:
|
|
|
|
ReadCDWRetr:
|
|
|
|
WaitUnitReady:
|
|
|
|
prevent_medium_removal:
|
|
|
|
Read_TOC:
|
|
|
|
commit_pages:
|
|
|
|
release_pages:
|
2020-02-08 16:10:45 +01:00
|
|
|
lock_application_table:
|
|
|
|
unlock_application_table:
|
|
|
|
get_pg_addr:
|
|
|
|
free_page:
|
2020-02-10 06:09:17 +01:00
|
|
|
build_interrupt_table:
|
|
|
|
init_fpu:
|
|
|
|
init_mtrr:
|
|
|
|
create_trampoline_pgmap:
|
2020-02-27 22:22:44 +01:00
|
|
|
alloc_page:
|
2020-09-17 19:51:03 +02:00
|
|
|
pci_write_reg:
|
2020-02-27 22:22:44 +01:00
|
|
|
|
2020-02-06 04:19:20 +01:00
|
|
|
sys_settime:
|
|
|
|
sys_pcibios:
|
|
|
|
sys_IPC:
|
|
|
|
pci_api:
|
|
|
|
sys_resize_app_memory:
|
|
|
|
f68:
|
2020-09-17 19:51:03 +02:00
|
|
|
v86_irq:
|
2020-10-21 16:57:54 +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:
|
2020-02-06 04:19:20 +01:00
|
|
|
ret
|
2018-05-04 20:18:09 +02:00
|
|
|
|
2020-02-27 22:22:44 +01:00
|
|
|
alloc_pages:
|
|
|
|
ret 4
|
|
|
|
create_ring_buffer:
|
|
|
|
ret 8
|
|
|
|
map_page:
|
|
|
|
ret 12
|
|
|
|
map_memEx:
|
|
|
|
ret 20
|
2020-02-10 06:09:17 +01:00
|
|
|
|
2020-12-09 15:15:54 +01:00
|
|
|
sys_msg_board equ __pex0
|
|
|
|
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
|
|
|
|
|
|
|
macro lea r, v {
|
2021-06-23 18:43:26 +02:00
|
|
|
if v eq [(ecx-(TASK_TABLE and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE]
|
2020-02-17 02:52:44 +01:00
|
|
|
int3
|
2021-06-23 18:43:26 +02:00
|
|
|
else if v eq [(edx-(TASK_TABLE and 1FFFFFFFh))*8+SLOT_BASE]
|
2020-02-17 02:52:44 +01:00
|
|
|
int3
|
|
|
|
else
|
|
|
|
lea r, v
|
|
|
|
end if
|
|
|
|
}
|
2020-02-27 22:22:44 +01:00
|
|
|
|
2020-02-29 02:04:32 +01:00
|
|
|
include 'kernel.asm'
|
2020-02-27 22:22:44 +01:00
|
|
|
|
2020-09-18 05:00:32 +02:00
|
|
|
purge lea,add,org,mov
|
|
|
|
restore lea,add,org,mov
|
2020-12-09 15:15:54 +01:00
|
|
|
purge sys_msg_board,delay_ms
|
|
|
|
restore sys_msg_board,delay_ms
|
2020-02-10 06:09:17 +01:00
|
|
|
|
2019-10-09 01:35:47 +02:00
|
|
|
coverage_end:
|
|
|
|
|
2020-10-22 01:44:34 +02:00
|
|
|
; fasm doesn't align on 65536, but ld script does
|
|
|
|
section '.data.aligned65k' writeable align 65536
|
2020-05-11 05:38:44 +02:00
|
|
|
public umka_tool
|
|
|
|
umka_tool dd ?
|
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
|
|
|
TASK_TABLE: rb 16
|
|
|
|
TASK_BASE: rd 4
|
|
|
|
TASK_DATA: rd sizeof.TASKDATA * 255 / 4
|
|
|
|
CDDataBuf: rb 0x1000
|
|
|
|
idts rb IRQ_RESERVED * 8 ; IDT descriptor is 8 bytes long
|
|
|
|
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 ?
|
|
|
|
KEY_BUFF rb 255 ; 120*2 + 2*2 = 244 bytes, actually 255 bytes
|
|
|
|
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
|
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
|
|
|
|
2020-10-22 01:44:34 +02:00
|
|
|
lfb_base rd MAX_SCREEN_WIDTH*MAX_SCREEN_HEIGHT
|
|
|
|
|
2020-02-09 02:48:16 +01:00
|
|
|
BOOT boot_data
|
2020-10-21 16:57:54 +02:00
|
|
|
virtual at BOOT
|
|
|
|
BOOT_LO boot_data
|
|
|
|
end virtual
|
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] {}
|
2020-02-29 02:04:32 +01:00
|
|
|
include 'data32.inc'
|