Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1375 → Rev 1376

/kernel/branches/net/kernel.asm
17,7 → 17,8
;; Sergey Semyonov (Serge)
;; Johnny_B
;; SPraid (simba)
;; hidnplayr
;; Hidnplayr
;; Alexey Teplov (<Lrz>)
;;
;; 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
79,6 → 80,7
tss0 equ (tss0_l-gdts)
app_code equ (3+app_code_l-gdts)
app_data equ (3+app_data_l-gdts)
app_tls equ (3+tls_data_l-gdts)
pci_code_sel equ (pci_code_32-gdts)
pci_data_sel equ (pci_data_32-gdts)
 
117,7 → 119,7
org 0x0
jmp start_of_code
 
version db 'Kolibri OS version 0.7.5.0 ',13,10,13,10,0
version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0
 
include "boot/bootstr.inc" ; language-independent boot messages
include "boot/preboot.inc"
283,12 → 285,13
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,bx
mov fs, cx
mov gs,bx
 
bt [cpu_caps], CAPS_PGE
346,14 → 349,20
; mov [0xF604],byte 1 ;al
mov al, [BOOT_VAR+0x901F] ; DMA access
mov [allow_dma_access], al
mov al,[BOOT_VAR+0x9000] ; bpp
movzx eax, byte [BOOT_VAR+0x9000] ; bpp
mov [ScreenBPP],al
 
mov [_display.bpp], eax
mov [_display.vrefresh], 60
mov [_display.disable_mouse], __sys_disable_mouse
 
movzx eax,word [BOOT_VAR+0x900A] ; X max
mov [_display.width], eax
dec eax
mov [Screen_Max_X],eax
mov [screen_workarea.right],eax
movzx eax,word [BOOT_VAR+0x900C] ; Y max
mov [_display.height], eax
dec eax
mov [Screen_Max_Y],eax
mov [screen_workarea.bottom],eax
366,9 → 375,14
je @f
cmp [SCR_MODE],word 0x12 ; VGA 640x480
je @f
mov ax,[BOOT_VAR+0x9001] ; for other modes
movzx eax, word[BOOT_VAR+0x9001] ; for other modes
mov [BytesPerScanLine],ax
mov [_display.pitch], eax
@@:
mov eax, [_display.width]
mul [_display.height]
mov [_WinMapSize], eax
 
mov esi, BOOT_VAR+0x9080
movzx ecx, byte [esi-1]
mov [NumBiosDisks], ecx
377,7 → 391,7
 
; GRAPHICS ADDRESSES
 
mov byte [BOOT_VAR+0x901e],0x0
and byte [BOOT_VAR+0x901e],0x0
mov eax,[BOOT_VAR+0x9018]
mov [LFBAddress],eax
 
451,6 → 465,16
wrmsr
.noSYSCALL:
; -----------------------------------------
stdcall alloc_page
stdcall map_page, tss-0xF80, eax, PG_SW
stdcall alloc_page
inc eax
mov [SLOT_BASE+256+APPDATA.io_map], eax
stdcall map_page, tss+0x80, eax, PG_SW
stdcall alloc_page
inc eax
mov dword [SLOT_BASE+256+APPDATA.io_map+4], eax
stdcall map_page, tss+0x1080, eax, PG_SW
 
; LOAD IDT
 
538,14 → 562,18
mov [graph_data_l+4],al
mov [graph_data_l+7],ah
 
mov [CURRENT_TASK],dword 1
mov [TASK_COUNT],dword 1
stdcall kernel_alloc, [_WinMapSize]
mov [_WinMapAddress], eax
 
xor eax,eax
inc eax
mov [CURRENT_TASK],eax ;dword 1
mov [TASK_COUNT],eax ;dword 1
mov [TASK_BASE],dword TASK_DATA
mov [current_slot], SLOT_BASE+256
 
; set background
xor eax,eax
inc eax
 
mov [BgrDrawMode],eax
mov [BgrDataWidth],eax
mov [BgrDataHeight],eax
601,6 → 629,7
include 'vmodeld.inc'
;!!!!!!!!!!!!!!!!!!!!!!!
 
if 0
mov ax,[OS_BASE+0x10000+bx_from_load]
cmp ax,'r1' ; if using not ram disk, then load librares and parameters {SPraid.simba}
je no_lib_load
609,6 → 638,7
call load_file_parse_table ; prepare file parse table
call set_kernel_conf ; configure devices and gui
no_lib_load:
end if
 
; LOAD FONTS I and II
 
628,8 → 658,9
mov edx, 0xFFFFFF
mov ebx, [MEM_AMOUNT]
shr ebx, 20
mov edi, 1
xor edi,edi
mov eax, 0x00040000
inc edi
call display_number_force
 
; BUILD SCHEDULER
646,7 → 677,7
 
mov esi,boot_windefs
call boot_log
call setwindowdefaults
call set_window_defaults
 
; SET BACKGROUND DEFAULTS
 
686,10 → 717,7
add edi, 0x2000-512
mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi
mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case
mov dword [SLOT_BASE+256+APPDATA.io_map],\
(tss._io_map_0-OS_BASE+PG_MAP)
mov dword [SLOT_BASE+256+APPDATA.io_map+4],\
(tss._io_map_1-OS_BASE+PG_MAP)
; [SLOT_BASE+256+APPDATA.io_map] was set earlier
 
mov esi, fpu_data
mov ecx, 512/4
704,17 → 732,19
mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx
 
mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path
mov dword [SLOT_BASE+256+APPDATA.tls_base], eax
 
; task list
mov [CURRENT_TASK],dword 1
mov [TASK_COUNT],dword 1
mov dword [TASK_DATA+TASKDATA.mem_start],eax ; process base address
inc eax
mov dword [CURRENT_TASK],eax
mov dword [TASK_COUNT],eax
mov [current_slot], SLOT_BASE+256
mov [TASK_BASE],dword TASK_DATA
mov [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number
mov [TASK_DATA+TASKDATA.pid], 1 ; process id number
mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address
mov byte[TASK_DATA+TASKDATA.wnd_number],al ; on screen number
mov dword [TASK_DATA+TASKDATA.pid], eax ; process id number
 
call init_cursors
call init_display
mov eax, [def_cursor]
mov [SLOT_BASE+APPDATA.cursor],eax
mov [SLOT_BASE+APPDATA.cursor+256],eax
750,8 → 780,9
movzx ecx, word [boot_y]
add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is '
mov edx, 0xFFFFFF
mov edi, 1
xor edi,edi
mov eax, 0x00040000
inc edi
call display_number_force
 
; SET VARIABLES
797,16 → 828,15
;protect io permission map
 
mov esi, [default_io_map]
stdcall map_page,esi,(tss._io_map_0-OS_BASE), PG_MAP
stdcall map_page,esi,[SLOT_BASE+256+APPDATA.io_map], PG_MAP
add esi, 0x1000
stdcall map_page,esi,(tss._io_map_1-OS_BASE), PG_MAP
stdcall map_page,esi,[SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
 
stdcall map_page,tss._io_map_0,\
(tss._io_map_0-OS_BASE), PG_MAP
[SLOT_BASE+256+APPDATA.io_map], PG_MAP
stdcall map_page,tss._io_map_1,\
(tss._io_map_1-OS_BASE), PG_MAP
[SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
 
 
; LOAD FIRST APPLICATION
cli
 
816,8 → 846,9
mov ebp, vrr_m
call fs_execute_from_sysdir
 
cmp eax,2 ; if vrr_m app found (PID=2)
je first_app_found
; cmp eax,2 ; if vrr_m app found (PID=2)
sub eax,2
jz first_app_found
 
no_load_vrr_m:
 
824,8 → 855,9
mov ebp, firstapp
call fs_execute_from_sysdir
 
cmp eax,2 ; continue if a process has been loaded
je first_app_found
; cmp eax,2 ; continue if a process has been loaded
sub eax,2
jz first_app_found
 
mov esi, boot_failed
call boot_log
838,7 → 870,8
cli
 
;mov [TASK_COUNT],dword 2
mov [CURRENT_TASK],dword 1 ; set OS task fisrt
push 1
pop dword [CURRENT_TASK] ; set OS task fisrt
 
; SET KEYBOARD PARAMETERS
mov al, 0xf6 ; reset keyboard, scan enabled
969,8 → 1002,9
mov bx,word [boot_y]
add [boot_y],dword 10
mov ecx,0x80ffffff ; ASCIIZ string with white color
xor edi,edi
mov edx,esi
mov edi,1
inc edi
call dtext
 
mov [novesachecksum],1000
980,7 → 1014,6
 
ret
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
; MAIN OS LOOP START ;
989,7 → 1022,7
align 32
osloop:
call [draw_pointer]
call checkbuttons
call check_buttons
call checkwindows
; call check_window_move_request
call checkmisc
1055,51 → 1088,52
 
reserve_irqs_ports:
 
pushad
 
mov [irq_owner+4*0], 1 ; timer
push eax
xor eax,eax
inc eax
mov byte [irq_owner+4*0],al ;1 ; timer
;mov [irq_owner+4*1], 1 ; keyboard
mov [irq_owner+4*6], 1 ; floppy diskette
mov [irq_owner+4*13], 1 ; math co-pros
mov [irq_owner+4*14], 1 ; ide I
mov [irq_owner+4*15], 1 ; ide II
mov byte [irq_owner+4*6],al ;1 ; floppy diskette
mov byte [irq_owner+4*13],al ;1 ; math co-pros
mov byte [irq_owner+4*14],al ;1 ; ide I
mov byte [irq_owner+4*15],al ;1 ; ide II
pop eax
 
; RESERVE PORTS
mov edi,1 ; 0x00-0x2d
mov [RESERVED_PORTS],edi
shl edi,4
mov [RESERVED_PORTS+edi+0],dword 1
mov [RESERVED_PORTS+edi+4],dword 0x0
mov [RESERVED_PORTS+edi+8],dword 0x2d
push 4
pop dword [RESERVED_PORTS] ;,edi
 
inc dword [RESERVED_PORTS] ; 0x30-0x4d
mov edi,[RESERVED_PORTS]
shl edi,4
mov [RESERVED_PORTS+edi+0],dword 1
mov [RESERVED_PORTS+edi+4],dword 0x30
mov [RESERVED_PORTS+edi+8],dword 0x4d
push 1
pop dword [RESERVED_PORTS+16+0] ;,dword 1
and dword [RESERVED_PORTS+16+4],0 ;,dword 0x0
mov dword [RESERVED_PORTS+16+8],0x2d ;,dword 0x2d
 
inc dword [RESERVED_PORTS] ; 0x50-0xdf
mov edi,[RESERVED_PORTS]
shl edi,4
mov [RESERVED_PORTS+edi+0],dword 1
mov [RESERVED_PORTS+edi+4],dword 0x50
mov [RESERVED_PORTS+edi+8],dword 0xdf
push 1
pop dword [RESERVED_PORTS+32+0] ;,dword 1
push 0x30
pop dword [RESERVED_PORTS+32+4] ;,dword 0x30
push 0x4d
pop dword [RESERVED_PORTS+32+8] ;,dword 0x4d
 
inc dword [RESERVED_PORTS] ; 0xe5-0xff
mov edi,[RESERVED_PORTS]
shl edi,4
mov [RESERVED_PORTS+edi+0],dword 1
mov [RESERVED_PORTS+edi+4],dword 0xe5
mov [RESERVED_PORTS+edi+8],dword 0xff
push 1
pop dword [RESERVED_PORTS+48+0] ;,dword 1
push 0x50
pop dword [RESERVED_PORTS+48+4] ;,dword 0x50
mov dword [RESERVED_PORTS+48+8],0xdf ;,dword 0xdf
 
popad
push 1
pop dword [RESERVED_PORTS+64+0] ;,dword 1
 
mov dword [RESERVED_PORTS+64+4],0xe5 ;,dword 0xe5
mov dword [RESERVED_PORTS+64+8],0xff ;,dword 0xff
 
ret
 
setirqreadports:
 
mov [irq12read+0],dword 0x60 + 0x01000000 ; read port 0x60 , byte
mov [irq12read+4],dword 0 ; end of port list
and dword [irq12read+4],0 ; end of port list
; mov [irq12read+4],dword 0 ; end of port list
;mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte
;mov [irq04read+4],dword 0 ; end of port list
;mov [irq03read+0],dword 0x2f8 + 0x01000000 ; read port 0x2f8 , byte
1116,12 → 1150,8
mov ecx,0x100 ; flush port 0x60
.fl60: in al,0x60
loop .fl60
mov [MOUSE_BUFF_COUNT],byte 0 ; mouse buffer
mov [KEY_COUNT],byte 0 ; keyboard buffer
mov [BTN_COUNT],byte 0 ; button buffer
; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y
push eax
 
push eax
mov ax,[BOOT_VAR+0x900c]
shr ax,1
shl eax,16
1128,87 → 1158,86
mov ax,[BOOT_VAR+0x900A]
shr ax,1
mov [MOUSE_X],eax
pop eax
 
xor eax,eax
mov [BTN_ADDR],dword BUTTON_INFO ; address of button list
 
mov byte [MOUSE_BUFF_COUNT],al ; mouse buffer
mov byte [KEY_COUNT],al ; keyboard buffer
mov byte [BTN_COUNT],al ; button buffer
; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y
 
;!! IP 04.02.2005:
mov byte [DONT_SWITCH], 0 ; change task if possible
 
ret
 
;* mouse centered - start code- Mario79
mouse_centered:
push eax
mov eax,[Screen_Max_X]
shr eax,1
mov [MOUSE_X],ax
mov eax,[Screen_Max_Y]
shr eax,1
mov [MOUSE_Y],ax
mov byte [DONT_SWITCH],al ; change task if possible
pop eax
ret
;* mouse centered - end code- Mario79
 
align 4
 
;input eax=43,bl-byte of output, ecx - number of port
sys_outport:
 
mov edi,ebx ; separate flag for read / write
and ebx,65535
mov edi,ecx ; separate flag for read / write
and ecx,65535
 
mov ecx,[RESERVED_PORTS]
test ecx,ecx
jne sopl8
mov [esp+36],dword 1
mov eax,[RESERVED_PORTS]
test eax,eax
jnz .sopl8
inc eax
mov [esp+32],eax
ret
 
sopl8:
.sopl8:
mov edx,[TASK_BASE]
mov edx,[edx+0x4]
and ebx,65535
cld
sopl1:
;and ecx,65535
;cld - set on interrupt 0x40
.sopl1:
 
mov esi,ecx
mov esi,eax
shl esi,4
add esi,RESERVED_PORTS
cmp edx,[esi+0]
jne sopl2
cmp ebx,[esi+4]
jb sopl2
cmp ebx,[esi+8]
jg sopl2
jmp sopl3
jne .sopl2
cmp ecx,[esi+4]
jb .sopl2
cmp ecx,[esi+8]
jg .sopl2
.sopl3:
 
sopl2:
test edi,0x80000000 ; read ?
jnz .sopl4
 
dec ecx
jnz sopl1
mov [esp+36],dword 1
mov eax,ebx
mov dx,cx ; write
out dx,al
and [esp+32],dword 0
ret
 
sopl3:
.sopl2:
 
test edi,0x80000000 ; read ?
jnz sopl4
 
mov dx,bx ; write
out dx,al
mov [esp+36],dword 0
dec eax
jnz .sopl1
inc eax
mov [esp+32],eax
ret
 
sopl4:
 
mov dx,bx ; read
.sopl4:
 
mov dx,cx ; read
in al,dx
and eax,0xff
mov [esp+36],dword 0
mov [esp+24],eax
and [esp+32],dword 0
mov [esp+20],eax
ret
 
display_number:
 
;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
1248,8 → 1277,8
displnl1:
sub esp,64
 
cmp ah,0 ; DECIMAL
jne no_display_desnum
test ah,ah ; DECIMAL
jnz no_display_desnum
shr eax,16
and eax,0xC03f
; and eax,0x3f
1406,18 → 1435,20
; 12 = enable pci access
 
 
mov [esp+36],dword 0
cmp eax,1 ; MIDI
and [esp+32],dword 0
dec ebx ; MIDI
jnz nsyse1
cmp ebx,0x100
cmp ecx,0x100
 
jb nsyse1
mov edx,65535
cmp edx,ebx
mov esi,65535
cmp esi,ecx
 
jb nsyse1
mov [midi_base],bx
mov word [mididp],bx
inc bx
mov word [midisp],bx
mov [midi_base],cx ;bx
mov word [mididp],cx ;bx
inc cx ;bx
mov word [midisp],cx ;bx
ret
 
iglobal
1425,70 → 1456,69
endg
 
nsyse1:
dec ebx ; KEYBOARD
jnz nsyse2
mov edi,[TASK_BASE]
mov eax,[edi+TASKDATA.mem_start]
add eax,edx
 
cmp eax,2 ; KEYBOARD
jnz nsyse2
cmp ebx,1
dec ecx
jnz kbnobase
mov edi,[TASK_BASE]
add ecx,[edi+TASKDATA.mem_start]
mov eax,ecx
mov ebx,keymap
mov ecx,128
call memmove
ret
kbnobase:
cmp ebx,2
dec ecx
jnz kbnoshift
mov edi,[TASK_BASE]
add ecx,[edi+TASKDATA.mem_start]
mov eax,ecx
 
mov ebx,keymap_shift
mov ecx,128
call memmove
ret
kbnoshift:
cmp ebx,3
jne kbnoalt
mov edi,[TASK_BASE]
add ecx,[edi+TASKDATA.mem_start]
mov eax,ecx
dec ecx
jnz kbnoalt
mov ebx,keymap_alt
mov ecx,128
call memmove
ret
kbnoalt:
cmp ebx,9
sub ecx,6
jnz kbnocountry
mov word [keyboard],cx
mov word [keyboard],dx
ret
kbnocountry:
mov [esp+36],dword 1
mov [esp+32],dword 1
ret
nsyse2:
cmp eax,3 ; CD
dec ebx ; CD
jnz nsyse4
test ebx,ebx
 
test ecx,ecx
jz nosesl
cmp ebx, 4
 
cmp ecx, 4
ja nosesl
mov [cd_base],bl
cmp ebx,1
mov [cd_base],cl
 
dec ecx
jnz noprma
mov [cdbase],0x1f0
mov [cdid],0xa0
noprma:
cmp ebx,2
 
dec ecx
jnz noprsl
mov [cdbase],0x1f0
mov [cdid],0xb0
noprsl:
cmp ebx,3
dec ecx
jnz nosema
mov [cdbase],0x170
mov [cdid],0xa0
nosema:
cmp ebx,4
dec ecx
jnz nosesl
mov [cdbase],0x170
mov [cdid],0xb0
1495,55 → 1525,63
nosesl:
ret
 
iglobal
cd_base db 0
 
endg
nsyse4:
 
cmp eax,5 ; SYSTEM LANGUAGE
sub ebx,2 ; SYSTEM LANGUAGE
jnz nsyse5
mov [syslang],ebx
mov [syslang],ecx
ret
nsyse5:
 
cmp eax,7 ; HD BASE
jne nsyse7
test ebx,ebx
sub ebx,2 ; HD BASE
jnz nsyse7
 
test ecx,ecx
jz nosethd
cmp ebx,4
 
cmp ecx,4
ja nosethd
mov [hd_base],bl
cmp ebx,1
mov [hd_base],cl
 
cmp ecx,1
jnz noprmahd
mov [hdbase],0x1f0
mov [hdid],0x0
mov [hdpos],1
and dword [hdid],0x0
mov dword [hdpos],ecx
; call set_FAT32_variables
noprmahd:
cmp ebx,2
 
cmp ecx,2
jnz noprslhd
mov [hdbase],0x1f0
mov [hdid],0x10
mov [hdpos],2
mov dword [hdpos],ecx
; call set_FAT32_variables
noprslhd:
cmp ebx,3
 
cmp ecx,3
jnz nosemahd
mov [hdbase],0x170
mov [hdid],0x0
mov [hdpos],3
and dword [hdid],0x0
mov dword [hdpos],ecx
; call set_FAT32_variables
nosemahd:
cmp ebx,4
 
cmp ecx,4
jnz noseslhd
mov [hdbase],0x170
mov [hdid],0x10
mov [hdpos],4
mov dword [hdpos],ecx
; call set_FAT32_variables
noseslhd:
call reserve_hd1
call reserve_hd_channel
call free_hd_channel
mov [hd1_status],0 ; free
and dword [hd1_status],0 ; free
nosethd:
ret
 
1553,31 → 1591,33
 
nsyse7:
 
cmp eax,8 ; HD PARTITION
jne nsyse8
mov [fat32part],ebx
; cmp eax,8 ; HD PARTITION
dec ebx
jnz nsyse8
mov [fat32part],ecx
; call set_FAT32_variables
call reserve_hd1
call reserve_hd_channel
call free_hd_channel
pusha
; pusha
call choice_necessity_partition_1
popa
mov [hd1_status],0 ; free
; popa
and dword [hd1_status],0 ; free
ret
 
nsyse8:
cmp eax,11 ; ENABLE LBA READ
jne no_set_lba_read
and ebx,1
mov [lba_read_enabled],ebx
; cmp eax,11 ; ENABLE LBA READ
and ecx,1
sub ebx,3
jnz no_set_lba_read
mov [lba_read_enabled],ecx
ret
 
no_set_lba_read:
cmp eax,12 ; ENABLE PCI ACCESS
jne no_set_pci_access
and ebx,1
mov [pci_access_enabled],ebx
; cmp eax,12 ; ENABLE PCI ACCESS
dec ebx
jnz no_set_pci_access
mov [pci_access_enabled],ecx
ret
no_set_pci_access:
 
1586,7 → 1626,7
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
sys_setup_err:
mov [esp+36],dword -1
or [esp+32],dword -1
ret
 
align 4
1601,97 → 1641,109
; 8=fat32 partition in hd
; 9=get hs timer tic
 
cmp eax,1
jne ngsyse1
; cmp eax,1
dec ebx
jnz ngsyse1
movzx eax,[midi_base]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse1:
; cmp eax,2
dec ebx
jnz ngsyse2
 
cmp eax,2
jne ngsyse2
cmp ebx,1
mov edi,[TASK_BASE]
mov ebx,[edi+TASKDATA.mem_start]
add ebx,edx
 
; cmp ebx,1
dec ecx
jnz kbnobaseret
mov edi,[TASK_BASE]
add ecx,[edi+TASKDATA.mem_start]
mov ebx,ecx
mov eax,keymap
mov ecx,128
call memmove
ret
kbnobaseret:
cmp ebx,2
; cmp ebx,2
dec ecx
jnz kbnoshiftret
mov edi,[TASK_BASE]
add ecx,[edi+TASKDATA.mem_start]
mov ebx,ecx
 
mov eax,keymap_shift
mov ecx,128
call memmove
ret
kbnoshiftret:
cmp ebx,3
; cmp ebx,3
dec ecx
jne kbnoaltret
mov edi,[TASK_BASE]
add ecx,[edi+TASKDATA.mem_start]
mov ebx,ecx
 
mov eax,keymap_alt
mov ecx,128
call memmove
ret
kbnoaltret:
cmp ebx,9
; cmp ebx,9
sub ecx,6
jnz ngsyse2
movzx eax,word [keyboard]
mov [esp+36],eax
mov [esp+32],eax
ret
 
 
ngsyse2:
 
cmp eax,3
; cmp eax,3
dec ebx
jnz ngsyse3
movzx eax,[cd_base]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse3:
cmp eax,5
; cmp eax,5
sub ebx,2
jnz ngsyse5
mov eax,[syslang]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse5:
cmp eax,7
; cmp eax,7
sub ebx,2
jnz ngsyse7
movzx eax,[hd_base]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse7:
cmp eax,8
; cmp eax,8
dec ebx
jnz ngsyse8
mov eax,[fat32part]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse8:
cmp eax,9
jne ngsyse9
; cmp eax,9
dec ebx
jnz ngsyse9
mov eax,[timer_ticks] ;[0xfdf0]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse9:
cmp eax,11
; cmp eax,11
sub ebx,2
jnz ngsyse11
mov eax,[lba_read_enabled]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse11:
cmp eax,12
; cmp eax,12
dec ebx
jnz ngsyse12
mov eax,[pci_access_enabled]
mov [esp+36],eax
mov [esp+32],eax
ret
ngsyse12:
mov [esp+36],dword 1
mov [esp+32],dword 1
ret
 
get_timer_ticks:
mov eax,[timer_ticks]
ret
1716,14 → 1768,14
; eax=6 delete cursor ; reserved
; eax=7 get mouse_z
 
cmp eax, 7
cmp ebx, 7
ja msset
jmp [mousefn+eax*4]
jmp [mousefn+ebx*4]
msscreen:
mov eax,[MOUSE_X]
shl eax,16
mov ax,[MOUSE_Y]
mov [esp+36],eax
mov [esp+36-4],eax
ret
mswin:
mov eax,[MOUSE_X]
1741,11 → 1793,11
rol eax,16
sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
rol eax,16
mov [esp+36],eax
mov [esp+36-4],eax
ret
msbutton:
movzx eax,byte [BTN_DOWN]
mov [esp+36],eax
mov [esp+36-4],eax
ret
msz:
mov edi, [TASK_COUNT]
1755,32 → 1807,31
mov ax,[MOUSE_SCROLL_H]
shl eax,16
mov ax,[MOUSE_SCROLL_V]
mov [esp+36],eax
mov [MOUSE_SCROLL_H],word 0
mov [MOUSE_SCROLL_V],word 0
mov [esp+36-4],eax
and [MOUSE_SCROLL_H],word 0
and [MOUSE_SCROLL_V],word 0
ret
@@:
mov [esp+36],dword 0
ret
and [esp+36-4],dword 0
; ret
msset:
ret
 
app_load_cursor:
; add ebx, new_app_base
cmp ebx, OS_BASE
cmp ecx, OS_BASE
jae msset
stdcall load_cursor, ebx, ecx
mov [esp+36], eax
stdcall load_cursor, ecx, edx
mov [esp+36-4], eax
ret
 
app_set_cursor:
stdcall set_cursor, ebx
mov [esp+36], eax
stdcall set_cursor, ecx
mov [esp+36-4], eax
ret
 
app_delete_cursor:
stdcall delete_cursor, ebx
mov [esp+36], eax
stdcall delete_cursor, ecx
mov [esp+36-4], eax
ret
 
is_input:
1820,11 → 1871,22
ret
 
 
setuart:
 
align 4
 
sys_midi:
cmp [mididp],0
jnz sm0
mov [esp+36],dword 1
ret
sm0:
and [esp+36],dword 0
dec ebx
jnz smn1
; call setuart
su1:
call is_output
cmp al,0
test al,al
jnz su1
mov dx,word [midisp]
mov al,0xff
1834,7 → 1896,7
mov al,0xff
out dx,al
call is_input
cmp al,0
test al,al
jnz su2
call get_mpu_in
cmp al,0xfe
1841,33 → 1903,14
jnz su2
su3:
call is_output
cmp al,0
test al,al
jnz su3
mov dx,word [midisp]
mov al,0x3f
out dx,al
 
ret
 
 
align 4
 
sys_midi:
 
cmp [mididp],0
jnz sm0
mov [esp+36],dword 1
ret
sm0:
 
cmp eax,1
mov [esp+36],dword 0
jnz smn1
call setuart
ret
smn1:
 
cmp eax,2
dec ebx
jnz smn2
sm10:
call get_mpu_in
1876,12 → 1919,9
jnz sm10
mov al,bl
call put_mpu_out
ret
smn2:
 
ret
 
 
detect_devices:
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;include 'detect/commouse.inc'
1892,9 → 1932,16
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ret
 
 
sys_end:
 
mov ecx, [current_slot]
mov eax, [ecx+APPDATA.tls_base]
test eax, eax
jz @F
 
stdcall user_free, eax
@@:
 
mov eax,[TASK_BASE]
mov [eax+TASKDATA.state], 3 ; terminate this program
 
1977,7 → 2024,7
 
cmp edx,[application_table_status] ; clear app table stat
jne noatsc
mov [application_table_status],0
and [application_table_status],0
noatsc:
noprocessterminate:
ret
2000,7 → 2047,7
mov ecx,eax
cli
call sysfn_terminate
mov [application_table_status],0
and [application_table_status],0
sti
and dword [esp+32],0
ret
2044,7 → 2091,7
;!!!!!!!!!!!!!!!!!!!!!!!!
include 'blkdev/rdsave.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!
 
align 4
sysfn_getactive: ; 18.7 = get active window
mov eax, [TASK_COUNT]
movzx eax, word [WIN_POS + eax*2]
2052,13 → 2099,15
ret
 
sysfn_sound_flag: ; 18.8 = get/set sound_flag
cmp ecx,1
jne nogetsoundflag
; cmp ecx,1
dec ecx
jnz nogetsoundflag
movzx eax,byte [sound_flag] ; get sound_flag
mov [esp+32],eax
ret
nogetsoundflag:
cmp ecx,2
; cmp ecx,2
dec ecx
jnz nosoundflag
xor byte [sound_flag], 1
nosoundflag:
2067,9 → 2116,10
sysfn_minimize: ; 18.10 = minimize window
mov [window_minimize],1
ret
 
align 4
sysfn_getdiskinfo: ; 18.11 = get disk info table
cmp ecx,1
; cmp ecx,1
dec ecx
jnz full_table
small_table:
call for_all_tables
2082,7 → 2132,8
mov esi,DRIVE_DATA
ret
full_table:
cmp ecx,2
; cmp ecx,2
dec ecx
jnz exit_for_anyone
call for_all_tables
mov ecx,16384
2112,13 → 2163,29
and [esp+32],dword 0
ret
 
align 4
sysfn_centermouse: ; 18.15 = mouse centered
call mouse_centered
and [esp+32],dword 0
; removed here by <Lrz>
; call mouse_centered
;* mouse centered - start code- Mario79
;mouse_centered:
; push eax
mov eax,[Screen_Max_X]
shr eax,1
mov [MOUSE_X],ax
mov eax,[Screen_Max_Y]
shr eax,1
mov [MOUSE_Y],ax
; ret
;* mouse centered - end code- Mario79
xor eax,eax
and [esp+32],eax
; pop eax
 
ret
 
align 4
sysfn_mouse_acceleration: ; 18.19 = set/get mouse features
cmp ecx,0 ; get mouse speed factor
test ecx,ecx ; get mouse speed factor
jnz .set_mouse_acceleration
xor eax,eax
mov ax,[mouse_speed_factor]
2125,23 → 2192,27
mov [esp+32],eax
ret
.set_mouse_acceleration:
cmp ecx,1 ; set mouse speed factor
; cmp ecx,1 ; set mouse speed factor
dec ecx
jnz .get_mouse_delay
mov [mouse_speed_factor],dx
ret
.get_mouse_delay:
cmp ecx,2 ; get mouse delay
; cmp ecx,2 ; get mouse delay
dec ecx
jnz .set_mouse_delay
mov eax,[mouse_delay]
mov [esp+32],eax
ret
.set_mouse_delay:
cmp ecx,3 ; set mouse delay
; cmp ecx,3 ; set mouse delay
dec ecx
jnz .set_pointer_position
mov [mouse_delay],edx
ret
.set_pointer_position:
cmp ecx,4 ; set mouse pointer position
; cmp ecx,4 ; set mouse pointer position
dec ecx
jnz .set_mouse_button
mov [MOUSE_Y],dx ;y
ror edx,16
2149,7 → 2220,8
rol edx,16
ret
.set_mouse_button:
cmp ecx,5 ; set mouse button features
; cmp ecx,5 ; set mouse button features
dec ecx
jnz .end
mov [BTN_DOWN],dl
mov [mouse_active],1
2217,7 → 2289,7
 
iglobal
version_inf:
db 0,7,5,0 ; version 0.7.5.0
db 0,7,7,0 ; version 0.7.7.0
db UID_KOLIBRI
dd __REV__
version_end:
2257,10 → 2329,12
 
cmp ebx,1 ; BACKGROUND SIZE
jnz nosb1
cmp ecx,0
je sbgrr
cmp edx,0
je sbgrr
test ecx,ecx
; cmp ecx,0
jz sbgrr
test edx,edx
; cmp edx,0
jz sbgrr
@@:
;;Maxis use atomic bts for mutexes 4.4.2009
bts dword [bgrlock], 0
2446,6 → 2520,7
jnp .err
push eax
shr ecx, 12
dec ecx
@@:
and dword [page_tabs+eax*4], 0
mov edx, eax
2470,8 → 2545,8
ret
 
force_redraw_background:
mov [draw_data+32 + RECT.left],dword 0
mov [draw_data+32 + RECT.top],dword 0
and [draw_data+32 + RECT.left],dword 0
and [draw_data+32 + RECT.top],dword 0
push eax ebx
mov eax,[Screen_Max_X]
mov ebx,[Screen_Max_Y]
2484,49 → 2559,50
align 4
 
sys_getbackground:
 
cmp eax,1 ; SIZE
; cmp eax,1 ; SIZE
dec ebx
jnz nogb1
mov eax,[BgrDataWidth]
shl eax,16
mov ax,[BgrDataHeight]
mov [esp+36],eax
mov [esp+32],eax
ret
 
nogb1:
 
cmp eax,2 ; PIXEL
; cmp eax,2 ; PIXEL
dec ebx
jnz nogb2
 
mov eax, [img_background]
test ebx, ebx
test ecx, ecx
jz @f
cmp eax, static_background_data
jz .ret
@@:
mov ecx, [mem_BACKGROUND]
add ecx, 4095
and ecx, -4096
sub ecx, 4
cmp ebx, ecx
mov ebx, [mem_BACKGROUND]
add ebx, 4095
and ebx, -4096
sub ebx, 4
cmp ecx, ebx
ja .ret
 
mov eax,[ebx+eax]
mov eax,[ecx+eax]
 
and eax, 0xFFFFFF
mov [esp+36],eax
mov [esp+32],eax
.ret:
ret
nogb2:
 
cmp eax,4 ; TILED / STRETCHED
; cmp eax,4 ; TILED / STRETCHED
dec ebx
dec ebx
jnz nogb4
mov eax,[BgrDrawMode]
nogb4:
mov [esp+36],eax
mov [esp+32],eax
ret
 
 
align 4
 
sys_getkey:
2832,9 → 2908,9
; cmp eax,0 ; type I - original style
jne nosyswI
inc [mouse_pause]
call [disable_mouse]
call [_display.disable_mouse]
call sys_set_window
call [disable_mouse]
call [_display.disable_mouse]
call drawwindow_I
;dec [mouse_pause]
;call [draw_pointer]
2845,9 → 2921,9
cmp al,1 ; type II - only reserve area, no draw
jne nosyswII
inc [mouse_pause]
call [disable_mouse]
call [_display.disable_mouse]
call sys_set_window
call [disable_mouse]
call [_display.disable_mouse]
call sys_window_mouse
dec [mouse_pause]
call [draw_pointer]
2857,9 → 2933,9
cmp al,2 ; type III - new style
jne nosyswIII
inc [mouse_pause]
call [disable_mouse]
call [_display.disable_mouse]
call sys_set_window
call [disable_mouse]
call [_display.disable_mouse]
call drawwindow_III
;dec [mouse_pause]
;call [draw_pointer]
2874,9 → 2950,9
draw_skin_window:
 
inc [mouse_pause]
call [disable_mouse]
call [_display.disable_mouse]
call sys_set_window
call [disable_mouse]
call [_display.disable_mouse]
mov eax, [TASK_COUNT]
movzx eax, word [WIN_POS + eax*2]
cmp eax, [CURRENT_TASK]
2895,7 → 2971,7
 
draw_window_caption:
inc [mouse_pause]
call [disable_mouse]
call [_display.disable_mouse]
 
xor eax,eax
mov edx,[TASK_COUNT]
3159,8 → 3235,8
syscall_windowsettings:
 
.set_window_caption:
dec eax ; subfunction #1 - set window caption
jnz .get_window_caption
dec ebx ; subfunction #1 - set window caption
jnz .exit_fail
 
; NOTE: only window owner thread can set its caption,
; so there's no parameter for PID/TID
3178,7 → 3254,7
; cmp ebx,ecx
; ja .exit_fail
 
mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ebx
mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ecx
or [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION
 
call draw_window_caption
3186,9 → 3262,9
xor eax,eax ; eax = 0 (success)
ret
 
.get_window_caption:
dec eax ; subfunction #2 - get window caption
jnz .exit_fail
; .get_window_caption:
; dec eax ; subfunction #2 - get window caption
; jnz .exit_fail
 
; not implemented yet
 
3264,10 → 3340,10
pop eax
add ecx,eax
add edx,ebx
mov [dlx],eax ; save for drawlimits
mov [dly],ebx
mov [dlxe],ecx
mov [dlye],edx
mov [draw_limits.left],eax ; save for drawlimits
mov [draw_limits.top],ebx
mov [draw_limits.right],ecx
mov [draw_limits.bottom],edx
call calculatescreen
 
mov [edi + WDATA.fl_redraw], 1 ; flag the process as redraw
3313,67 → 3389,76
;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.
;---------------------------------------------------------------------------------------------
sys_sheduler: ;noname & halyavin
cmp eax,0
je shed_counter
cmp eax,2
je perf_control
cmp eax,3
je rdmsr_instr
cmp eax,4
je wrmsr_instr
cmp eax,1
jne not_supported
call change_task ;delay,0
ret
shed_counter:
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
jmp dword [sheduler+ebx*4]
;.shed_counter:
.00:
mov eax,[context_counter]
mov [esp+36],eax
not_supported:
mov [esp+32],eax
ret
perf_control:
inc eax ;now eax=3
cmp ebx,eax
je cache_disable
dec eax
cmp ebx,eax
je cache_enable
dec eax
cmp ebx,eax
je is_cache_enabled
dec eax
cmp ebx,eax
je modify_pce
 
.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
 
rdmsr_instr:
.03:
;.rdmsr_instr:
;now counter in ecx
;(edx:eax) esi:edi => edx:esi
mov eax,esi
mov ecx,edx
rdmsr
mov [esp+36],eax
mov [esp+24],edx ;ret in ebx?
mov [esp+32],eax
mov [esp+20],edx ;ret in ebx?
ret
 
wrmsr_instr:
.04:
;.wrmsr_instr:
;now counter in ecx
;(edx:eax) esi:edi => edx:esi
; Fast Call MSR can't be destroy
; Íî MSR_AMD_EFER ìîæíî èçìåíÿòü, ò.ê. â ýòîì ðåãèñòðå ëèø
; âêëþ÷àþòñÿ/âûêëþ÷àþòñÿ ðàñøèðåííûå âîçìîæíîñòè
cmp ecx, MSR_SYSENTER_CS
; ® MSR_AMD_EFER ¬®¦­® ¨§¬¥­ïâì, â.ª. ¢ í⮬ ॣ¨áâॠ«¨è
; ¢ª«îç îâáï/¢ëª«îç îâáï à áè¨à¥­­ë¥ ¢®§¬®¦­®áâ¨
cmp edx,MSR_SYSENTER_CS
je @f
cmp ecx, MSR_SYSENTER_ESP
cmp edx,MSR_SYSENTER_ESP
je @f
cmp ecx, MSR_SYSENTER_EIP
cmp edx,MSR_SYSENTER_EIP
je @f
cmp ecx, MSR_AMD_STAR
cmp edx,MSR_AMD_STAR
je @f
 
mov eax, esi
mov ecx,edx
wrmsr
; mov [esp + 36], eax
; mov [esp + 24], edx ;ret in ebx?
; mov [esp + 32], eax
; mov [esp + 20], edx ;ret in ebx?
@@:
ret
 
3395,9 → 3480,9
mov ebx,eax
and eax,01100000000000000000000000000000b
jz cache_disabled
mov [esp+36],ebx
mov [esp+32],ebx
cache_disabled:
mov dword [esp+36],eax ;0
mov dword [esp+32],eax ;0
ret
 
modify_pce:
3407,7 → 3492,7
; xor eax,ebx ;invert pce
bts eax,8 ;pce=cr4[8]
mov cr4,eax
mov [esp+36],eax
mov [esp+32],eax
ret
;---------------------------------------------------------------------------------------------
 
3420,7 → 3505,8
mov edx,[Screen_Max_X] ; screen x size
inc edx
imul edx, ebx
mov dl, [eax+edx+display_data] ; lea eax, [...]
add eax, [_WinMapAddress]
mov dl, [eax+edx] ; lea eax, [...]
 
xor ecx, ecx
mov eax, [CURRENT_TASK]
3509,7 → 3595,7
 
no_mark_system_shutdown:
 
call [disable_mouse]
call [_display.disable_mouse]
 
dec byte [SYS_SHUTDOWN]
je system_shutdown
3572,11 → 3658,11
add ecx,eax
add edx,ebx
 
mov ecx,[dlye] ; ecx = area y end ebx = window y start
mov ecx,[draw_limits.bottom] ; ecx = area y end ebx = window y start
cmp ecx,ebx
jb ricino
 
mov ecx,[dlxe] ; ecx = area x end eax = window x start
mov ecx,[draw_limits.right] ; ecx = area x end eax = window x start
cmp ecx,eax
jb ricino
 
3587,11 → 3673,11
add ecx, eax
add edx, ebx
 
mov eax,[dly] ; eax = area y start edx = window y end
mov eax,[draw_limits.top] ; eax = area y start edx = window y end
cmp edx,eax
jb ricino
 
mov eax,[dlx] ; eax = area x start ecx = window x end
mov eax,[draw_limits.left] ; eax = area x start ecx = window x end
cmp ecx,eax
jb ricino
 
3605,22 → 3691,22
test al,al
jz .az
lea eax,[edi+draw_data-window_data]
mov ebx,[dlx]
mov ebx,[draw_limits.left]
cmp ebx,[eax+RECT.left]
jae @f
mov [eax+RECT.left],ebx
@@:
mov ebx,[dly]
mov ebx,[draw_limits.top]
cmp ebx,[eax+RECT.top]
jae @f
mov [eax+RECT.top],ebx
@@:
mov ebx,[dlxe]
mov ebx,[draw_limits.right]
cmp ebx,[eax+RECT.right]
jbe @f
mov [eax+RECT.right],ebx
@@:
mov ebx,[dlye]
mov ebx,[draw_limits.bottom]
cmp ebx,[eax+RECT.bottom]
jbe @f
mov [eax+RECT.bottom],ebx
3631,13 → 3717,13
mov eax,edi
add eax,draw_data-window_data
 
mov ebx,[dlx] ; set limits
mov ebx,[draw_limits.left] ; set limits
mov [eax + RECT.left], ebx
mov ebx,[dly]
mov ebx,[draw_limits.top]
mov [eax + RECT.top], ebx
mov ebx,[dlxe]
mov ebx,[draw_limits.right]
mov [eax + RECT.right], ebx
mov ebx,[dlye]
mov ebx,[draw_limits.bottom]
mov [eax + RECT.bottom], ebx
 
sub eax,draw_data-window_data
3667,9 → 3753,10
 
calculatebackground: ; background
 
mov edi,display_data ; set os to use all pixels
mov edi, [_WinMapAddress] ; set os to use all pixels
mov eax,0x01010101
mov ecx,1280*1024 / 4
mov ecx, [_WinMapSize]
shr ecx, 2
rep stosd
 
mov byte [REDRAW_BACKGROUND], 0 ; do not draw background!
3745,7 → 3832,7
 
ret
 
 
align 16 ;very often call this subrutine
memmove: ; memory move in bytes
 
; eax = from
3754,7 → 3841,6
test ecx, ecx
jle .ret
 
 
push esi edi ecx
 
mov edi, ebx
3925,43 → 4011,41
 
 
set_io_access_rights:
 
pushad
 
push edi eax
mov edi, tss._io_map_0
 
; mov ecx,eax
; and ecx,7 ; offset in byte
 
; shr eax,3 ; number of byte
; add edi,eax
 
; mov ebx,1
; shl ebx,cl
 
cmp ebp,0 ; enable access - ebp = 0
jne siar1
 
test ebp,ebp
; cmp ebp,0 ; enable access - ebp = 0
jnz siar1
; not ebx
; and [edi],byte bl
btr [edi], eax
 
popad
 
pop eax edi
ret
 
siar1:
 
bts [edi], eax
; or [edi],byte bl ; disable access - ebp = 1
 
popad
 
pop eax edi
ret
 
;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 eax, eax
test ebx, ebx
jnz free_port_area
; je r_port_area
; jmp free_port_area
3968,78 → 4052,70
 
; r_port_area:
 
pushad
; pushad
 
cmp ebx,ecx ; beginning > end ?
cmp ecx,edx ; beginning > end ?
ja rpal1
cmp ecx,65536
cmp edx,65536
jae rpal1
mov esi,[RESERVED_PORTS]
test esi,esi ; no reserved areas ?
mov eax,[RESERVED_PORTS]
test eax,eax ; no reserved areas ?
je rpal2
cmp esi,255 ; max reserved
cmp eax,255 ; max reserved
jae rpal1
rpal3:
mov edi,esi
shl edi,4
add edi,RESERVED_PORTS
cmp ebx,[edi+8]
mov ebx,eax
shl ebx,4
add ebx,RESERVED_PORTS
cmp ecx,[ebx+8]
ja rpal4
cmp ecx,[edi+4]
cmp edx,[ebx+4]
jae rpal1
; jb rpal4
; jmp rpal1
rpal4:
 
dec esi
dec eax
jnz rpal3
jmp rpal2
rpal1:
popad
mov eax,1
; popad
; mov eax,1
xor eax,eax
inc eax
ret
 
rpal2:
popad
 
 
; popad
; enable port access at port IO map
cli
pushad ; start enable io map
 
cmp ecx,65536 ;16384
cmp edx,65536 ;16384
jae no_unmask_io ; jge
 
mov eax,ebx
 
mov eax,ecx
; push ebp
xor ebp,ebp ; enable - eax = port
new_port_access:
 
pushad
 
xor ebp,ebp ; enable - eax = port
; pushad
call set_io_access_rights
 
popad
 
; popad
inc eax
cmp eax,ecx
cmp eax,edx
jbe new_port_access
 
; pop ebp
no_unmask_io:
 
popad ; end enable io map
sti
 
mov edi,[RESERVED_PORTS]
add edi,1
mov [RESERVED_PORTS],edi
shl edi,4
add edi,RESERVED_PORTS
mov esi,[TASK_BASE]
mov esi,[esi+TASKDATA.pid]
mov [edi],esi
mov [edi+4],ebx
mov [edi+8],ecx
mov eax,[RESERVED_PORTS]
add eax,1
mov [RESERVED_PORTS],eax
shl eax,4
add eax,RESERVED_PORTS
mov ebx,[TASK_BASE]
mov ebx,[ebx+TASKDATA.pid]
mov [eax],ebx
mov [eax+4],ecx
mov [eax+8],edx
 
xor eax, eax
ret
4046,34 → 4122,34
 
free_port_area:
 
pushad
 
mov esi,[RESERVED_PORTS] ; no reserved areas ?
test esi,esi
je frpal2
mov edx,[TASK_BASE]
mov edx,[edx+TASKDATA.pid]
; pushad
mov eax,[RESERVED_PORTS] ; no reserved areas ?
test eax,eax
jz frpal2
mov ebx,[TASK_BASE]
mov ebx,[ebx+TASKDATA.pid]
frpal3:
mov edi,esi
mov edi,eax
shl edi,4
add edi,RESERVED_PORTS
cmp edx,[edi]
cmp ebx,[edi]
jne frpal4
cmp ebx,[edi+4]
cmp ecx,[edi+4]
jne frpal4
cmp ecx,[edi+8]
cmp edx,[edi+8]
jne frpal4
jmp frpal1
frpal4:
dec esi
dec eax
jnz frpal3
frpal2:
popad
mov eax,1
; popad
inc eax
ret
frpal1:
push ecx
mov ecx,256
sub ecx,esi
sub ecx,eax
shl ecx,4
mov esi,edi
add esi,16
4081,36 → 4157,27
rep movsb
 
dec dword [RESERVED_PORTS]
 
popad
 
 
;popad
; disable port access at port IO map
 
pushad ; start disable io map
 
cmp ecx,65536 ;16384
; pushad ; start disable io map
pop eax ;start port
cmp edx,65536 ;16384
jge no_mask_io
 
mov eax,ebx
 
; mov eax,ecx
xor ebp,ebp
inc ebp
new_port_access_disable:
 
pushad
 
mov ebp,1 ; disable - eax = port
; pushad
; mov ebp,1 ; disable - eax = port
call set_io_access_rights
 
popad
 
; popad
inc eax
cmp eax,ecx
cmp eax,edx
jbe new_port_access_disable
 
no_mask_io:
 
popad ; end disable io map
 
; popad ; end disable io map
xor eax, eax
ret
 
4805,13 → 4872,13
 
push dx ax
 
@@: ; wait for empty transmit register
@@: ; Wait for empty transmit register (yes, this slows down system..)
mov dx, debug_com_base+5
in al, dx
test al, 1 shl 5
jz @r
 
mov dx, debug_com_base ; TODO: replace this with variable
mov dx, debug_com_base ; Output the byte
mov al, bl
out dx, al
 
4819,7 → 4886,6
 
end if
 
 
mov [msg_board_data+ecx],bl
inc ecx
and ecx, 4095
4991,7 → 5057,7
ret
no_gs3:
 
mov [esp+36],dword -1
or [esp+36],dword -1
ret
 
 
5019,7 → 5085,7
add ebx, [edi+APPDATA.wnd_clientbox.top]
xor edi, edi ; no force
; mov edi, 1
call [disable_mouse]
call [_display.disable_mouse]
jmp [putpixel]
 
align 4
5093,37 → 5159,39
 
syscall_cdaudio: ; CD
 
cmp eax, 4
cmp ebx, 4
jb .audio
jz .eject
cmp eax, 5
cmp ebx, 5
jnz .ret
.load:
call .reserve
call LoadMedium
call .free
ret
;call .free
jmp .free
; ret
.eject:
call .reserve
call clear_CD_cache
call allow_medium_removal
call EjectMedium
call .free
ret
; call .free
jmp .free
; ret
.audio:
call sys_cd_audio
mov [esp+36],eax
mov [esp+36-4],eax
.ret:
ret
 
.reserve:
call reserve_cd
mov eax, ebx
mov eax, ecx
shr eax, 1
and eax, 1
inc eax
mov [ChannelNumber], ax
mov eax, ebx
mov eax, ecx
and eax, 1
mov [DiskNumber], al
call reserve_cd_channel
5136,7 → 5204,7
mov al, [DRIVE_DATA+1]
shr al, cl
test al, 2
jz .err
jz .free;.err
ret
.free:
call free_cd_channel
5144,7 → 5212,7
ret
.err:
call .free
pop eax
; pop eax
ret
 
align 4
5171,7 → 5239,7
pushad
inc [mouse_pause]
; Check of use of the hardware cursor.
cmp [disable_mouse],__sys_disable_mouse
cmp [_display.disable_mouse],__sys_disable_mouse
jne @f
; Since the test for the coordinates of the mouse should not be used,
; then use the call [disable_mouse] is not possible!
5235,7 → 5303,7
jnz .start_y
dec [mouse_pause]
; Check of use of the hardware cursor.
cmp [disable_mouse],__sys_disable_mouse
cmp [_display.disable_mouse],__sys_disable_mouse
jne @f
call [draw_pointer]
@@:
5289,18 → 5357,24
syscall_reserveportarea: ; ReservePortArea and FreePortArea
 
call r_f_port_area
mov [esp+36],eax
mov [esp+32],eax
ret
 
align 4
 
syscall_threads: ; CreateThreads
; eax=1 create thread
;
; ebx=thread start
; ecx=thread stack value
;
; on return : eax = pid
 
call sys_threads
mov [esp+36],eax
call new_sys_threads
 
mov [esp+32],eax
ret
 
 
align 4
 
read_from_hd: ; Read from hd - fn not in use
5334,18 → 5408,33
 
mov [Screen_Max_X], eax
mov [Screen_Max_Y], edx
mov [BytesPerScanLine], ecx
 
mov [screen_workarea.right],eax
mov [screen_workarea.bottom], edx
inc eax
shl eax, 2 ;32 bpp
mov [BytesPerScanLine], eax
 
push ebx
push esi
push edi
 
pushad
 
stdcall kernel_free, [_WinMapAddress]
 
mov eax, [_display.width]
mul [_display.height]
mov [_WinMapSize], eax
 
stdcall kernel_alloc, eax
mov [_WinMapAddress], eax
test eax, eax
jz .epic_fail
 
popad
 
call repos_windows
mov eax, 0
mov ebx, 0
xor eax, eax
xor ebx, ebx
mov ecx, [Screen_Max_X]
mov edx, [Screen_Max_Y]
call calculatescreen
5356,28 → 5445,37
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:
cmp word [apm_vf], 0 ; Check APM BIOS enable
xor eax,eax
cmp word [apm_vf], ax ; Check APM BIOS enable
jne @f
or [esp + 48], byte 1 ; error
mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported
inc eax
or dword [esp + 44], eax ; error
add eax,7
mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported
ret
 
@@:
xchg eax, ecx
xchg ebx, ecx
; xchg eax, ecx
; xchg ebx, ecx
 
cmp al, 3
cmp dx, 3
ja @f
and [esp + 48], byte 0xfe ; emulate func 0..3 as func 0
and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0
mov eax, [apm_vf]
mov [esp + 36], eax
mov [esp + 32], eax
shr eax, 16
mov [esp + 32], eax
mov [esp + 28], eax
ret
 
@@:
5396,17 → 5494,15
mov cr3, eax
pop eax
 
mov [esp + 8 ], edi
mov [esp + 12], esi
mov [esp + 24], ebx
mov [esp + 28], edx
mov [esp + 32], ecx
mov [esp + 36], eax
mov [esp + 4 ], edi
mov [esp + 8], esi
mov [esp + 20], ebx
mov [esp + 24], edx
mov [esp + 28], ecx
mov [esp + 32], eax
setc al
and [esp + 48], byte 0xfe
or [esp + 48], al
 
 
and [esp + 44], byte 0xfe
or [esp + 44], al
ret
; -----------------------------------------