kolibri-acpi: update

git-svn-id: svn://kolibrios.org@5984 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2015-12-18 09:22:50 +00:00
parent 106a9e1d3a
commit 93f98eb37e
41 changed files with 4385 additions and 2205 deletions

View File

@ -11,14 +11,14 @@ $Revision: 4420 $
iglobal iglobal
align 4 align 4
bd_callbacks: bd_callbacks:
dd bd_callbacks.end - bd_callbacks ; strucsize dd bd_callbacks.end - bd_callbacks ; strucsize
dd 0 ; no close function dd 0 ; no close function
dd 0 ; no closemedia function dd 0 ; no closemedia function
dd bd_querymedia dd bd_querymedia
dd bd_read_interface dd bd_read_interface
dd bd_write_interface dd bd_write_interface
dd 0 ; no flush function dd 0 ; no flush function
dd 0 ; use default cache size dd 0 ; use default cache size
.end: .end:
endg endg
@ -238,9 +238,9 @@ int13_call:
; Because this code uses fixed addresses, ; Because this code uses fixed addresses,
; it can not be run simultaniously by many threads. ; it can not be run simultaniously by many threads.
; In current implementation it is protected by common mutex 'ide_status' ; In current implementation it is protected by common mutex 'ide_status'
mov word [OS_BASE + 510h], 10h ; packet length mov word [OS_BASE + 510h], 10h ; packet length
mov word [OS_BASE + 512h], cx ; number of sectors mov word [OS_BASE + 512h], cx ; number of sectors
mov dword [OS_BASE + 514h], 9A000000h ; buffer 9A00:0000 mov dword [OS_BASE + 514h], 9A000000h ; buffer 9A00:0000
mov dword [OS_BASE + 518h], eax mov dword [OS_BASE + 518h], eax
and dword [OS_BASE + 51Ch], 0 and dword [OS_BASE + 51Ch], 0
push ebx ecx esi edi push ebx ecx esi edi

View File

@ -10,44 +10,45 @@ $Revision$
; HDD driver ; HDD driver
struct HD_DATA struct HD_DATA
hdbase dd ? hdbase dw ?
hdid dd ? hdid dw ?
hdpos dd ? hdpos dw ?
hd48 dw ?
ends ends
;----------------------------------------------------------------- ;-----------------------------------------------------------------
iglobal iglobal
align 4 align 4
ide_callbacks: ide_callbacks:
dd ide_callbacks.end - ide_callbacks ; strucsize dd ide_callbacks.end - ide_callbacks
dd 0 ; no close function dd 0 ; no close function
dd 0 ; no closemedia function dd 0 ; no closemedia function
dd ide_querymedia dd ide_querymedia
dd ide_read dd ide_read
dd ide_write dd ide_write
dd 0 ; no flush function dd 0 ; no flush function
dd 0 ; use default cache size dd 0 ; use default cache size
.end: .end:
hd0_data HD_DATA ?, 0, 1 hd0_data HD_DATA ?, 0, 1, 0
hd1_data HD_DATA ?, 0x10, 2 hd1_data HD_DATA ?, 16, 2, 0
hd2_data HD_DATA ?, 0, 3 hd2_data HD_DATA ?, 0, 3, 0
hd3_data HD_DATA ?, 0x10, 4 hd3_data HD_DATA ?, 16, 4, 0
hd4_data HD_DATA ?, 0, 5 hd4_data HD_DATA ?, 0, 5, 0
hd5_data HD_DATA ?, 0x10, 6 hd5_data HD_DATA ?, 16, 6, 0
hd6_data HD_DATA ?, 0, 7 hd6_data HD_DATA ?, 0, 7, 0
hd7_data HD_DATA ?, 0x10, 8 hd7_data HD_DATA ?, 16, 8, 0
hd8_data HD_DATA ?, 0, 9 hd8_data HD_DATA ?, 0, 9, 0
hd9_data HD_DATA ?, 0x10, 10 hd9_data HD_DATA ?, 16, 10, 0
hd10_data HD_DATA ?, 0, 11 hd10_data HD_DATA ?, 0, 11, 0
hd11_data HD_DATA ?, 0x10, 12 hd11_data HD_DATA ?, 16, 12, 0
ide_mutex_table: ide_mutex_table:
dd ide_channel1_mutex dd ide_channel1_mutex
dd ide_channel2_mutex dd ide_channel2_mutex
dd ide_channel3_mutex dd ide_channel3_mutex
dd ide_channel4_mutex dd ide_channel4_mutex
dd ide_channel5_mutex dd ide_channel5_mutex
dd ide_channel6_mutex dd ide_channel6_mutex
endg endg
;----------------------------------------------------------------- ;-----------------------------------------------------------------
uglobal uglobal
@ -74,7 +75,6 @@ ide_read:
ide_write: ide_write:
mov al, 35h ; WRITE DMA EXT mov al, 35h ; WRITE DMA EXT
; fall through to ide_read_write
proc ide_read_write stdcall uses esi edi ebx, \ proc ide_read_write stdcall uses esi edi ebx, \
hd_data, buffer, startsector:qword, numsectors hd_data, buffer, startsector:qword, numsectors
@ -86,9 +86,8 @@ proc ide_read_write stdcall uses esi edi ebx, \
locals locals
sectors_todo dd ? sectors_todo dd ?
channel_lock dd ? channel_lock dd ?
operation db ?
endl endl
mov [operation], al mov bl, al
; get number of requested sectors and say that no sectors were read yet ; get number of requested sectors and say that no sectors were read yet
mov ecx, [numsectors] mov ecx, [numsectors]
mov eax, [ecx] mov eax, [ecx]
@ -98,7 +97,7 @@ endl
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_lock call mutex_lock
mov ecx, [hd_data] mov ecx, [hd_data]
mov ecx, [ecx+HD_DATA.hdpos] movzx ecx, [ecx+HD_DATA.hdpos]
dec ecx dec ecx
shr ecx, 1 shr ecx, 1
shl ecx, 2 shl ecx, 2
@ -106,21 +105,21 @@ endl
mov [channel_lock], ecx mov [channel_lock], ecx
call mutex_lock call mutex_lock
; prepare worker procedures variables ; prepare worker procedures variables
mov ecx, [hd_data]
mov eax, [ecx+HD_DATA.hdbase]
mov [hdbase], eax
mov eax, [ecx+HD_DATA.hdid]
mov [hdid], eax
mov eax, [ecx+HD_DATA.hdpos]
mov [hdpos], eax
mov eax, dword [startsector]
mov [sector], eax
mov ax, word [startsector+4]
mov [sector+4], ax
mov esi, [buffer] mov esi, [buffer]
mov edi, esi mov edi, esi
mov bl, [operation] mov ecx, [hd_data]
mov ecx, [hdpos] movzx eax, [ecx+HD_DATA.hdbase]
mov [hdbase], eax
mov ax, [ecx+HD_DATA.hdid]
mov [hdid], eax
mov eax, dword [startsector]
mov [sector], eax
cmp [ecx+HD_DATA.hd48], 0
jz .LBA28
mov ax, word [startsector+4]
mov [sector+4], ax
movzx ecx, [ecx+HD_DATA.hdpos]
mov [hdpos], ecx
dec ecx dec ecx
shr ecx, 2 shr ecx, 2
imul ecx, sizeof.IDE_DATA imul ecx, sizeof.IDE_DATA
@ -134,7 +133,7 @@ endl
cmp [eax+IDE_DATA.dma_hdd_channel_1], 1 cmp [eax+IDE_DATA.dma_hdd_channel_1], 1
jz .next jz .next
dec ebx ; READ/WRITE SECTOR(S) EXT dec ebx ; READ/WRITE SECTOR(S) EXT
; worker procedures take max 8000h sectors per time ; LBA48 supports max 10000h sectors per time
; loop until all sectors will be processed ; loop until all sectors will be processed
.next: .next:
mov ecx, 8000h mov ecx, 8000h
@ -154,6 +153,30 @@ endl
add [sector], ecx add [sector], ecx
adc word [sector+4], 0 adc word [sector+4], 0
jmp .next jmp .next
.LBA28:
add eax, [sectors_todo]
add eax, 0xF0000000
jc .out
sub bl, 5 ; READ/WRITE SECTOR(S)
; LBA28 supports max 256 sectors per time
; loop until all sectors will be processed
.next28:
mov ecx, 256
cmp ecx, [sectors_todo]
jbe @f
mov ecx, [sectors_todo]
@@:
mov [blockSize], ecx
push ecx
call IDE_transfer.LBA28
pop ecx
jc .out
mov eax, [numsectors]
add [eax], ecx
sub [sectors_todo], ecx
jz .out
add [sector], ecx
jmp .next28
; loop is done, either due to error or because everything is done ; loop is done, either due to error or because everything is done
; release the global lock and return the corresponding status ; release the global lock and return the corresponding status
.out: .out:
@ -360,6 +383,42 @@ IDE_transfer:
cmp [eventPointer], 0 cmp [eventPointer], 0
jz .hd_error jz .hd_error
ret ret
.LBA28:
mov edx, [hdbase]
add edx, 6
mov al, byte [hdid]
add al, 224
out dx, al ; select the desired drive
call save_hd_wait_timeout
inc edx
@@:
call check_hd_wait_timeout
jc .hd_error
in al, dx
test al, 128 ; ready for command?
jnz @b
pushfd ; fill the ports
cli
mov edx, [hdbase]
inc edx
inc edx
mov al, [blockSize]
out dx, al ; Sector count (7:0)
inc edx
mov eax, [sector]
out dx, al ; LBA (7:0)
inc edx
shr eax, 8
out dx, al ; LBA (15:8)
inc edx
shr eax, 8
out dx, al ; LBA (23:16)
inc edx
shr eax, 8
add al, byte [hdid]
add al, 224
out dx, al ; LBA (27:24)
.PIO: .PIO:
inc edx ; ATACommand inc edx ; ATACommand
mov al, bl mov al, bl
@ -387,8 +446,8 @@ IDE_transfer:
cld cld
mov ecx, 256 mov ecx, 256
mov edx, [hdbase] mov edx, [hdbase]
cmp bl, 34h cmp bl, 30h
jz .write jnc .write
rep insw rep insw
jmp @f jmp @f
.write: .write:

View File

@ -59,7 +59,7 @@ getkey: ; Use BIOS INT 16h to read a key from the keyboa
jb getkey ; ASCII code is below lowest accepted value => continue waiting for another key. jb getkey ; ASCII code is below lowest accepted value => continue waiting for another key.
cmp al, bh ; Compare 'al' (ASCII code of key pressed) with 'bh' (highest accepted char from the range). cmp al, bh ; Compare 'al' (ASCII code of key pressed) with 'bh' (highest accepted char from the range).
ja getkey ; ASCII code is above highest accepted value => continue waiting for another key. ja getkey ; ASCII code is above highest accepted value => continue waiting for another key.
push ax ; If the pressed key is in the accepted range, save it on the stack and echo to screen. push ax ; If the pressed key is in the accepted range, save it on the stack and echo to screen.
call putchar call putchar
pop ax pop ax
and ax, 0Fh ; Convert ASCII code to number: '1'->1, '2'->2, etc. 0Fh=1111b. and ax, 0Fh ; Convert ASCII code to number: '1'->1, '2'->2, etc. 0Fh=1111b.
@ -159,7 +159,7 @@ FirstDataSector dw 0 ; begin of data
; ;
;========================================================================= ;=========================================================================
include 'bootvesa.inc' ;Include source for boot vesa include 'bootvesa.inc' ;Include source for boot vesa
if defined extended_primary_loader if defined extended_primary_loader
include 'parsers.inc' include 'parsers.inc'
end if end if
@ -176,9 +176,9 @@ if defined extended_primary_loader
mov [bootfs], bx mov [bootfs], bx
; set up stack ; set up stack
mov ax, 3000h mov ax, (TMP_STACK_TOP and 0xF0000) shr 4
mov ss, ax mov ss, ax
mov sp, 0EC00h mov sp, TMP_STACK_TOP and 0xFFFF
; try to load configuration file ; try to load configuration file
mov ax, 1 mov ax, 1
@ -293,9 +293,9 @@ else
no_hd_load: no_hd_load:
; set up stack ; set up stack
mov ax, 3000h mov ax, (TMP_STACK_TOP and 0xF0000) shr 4
mov ss, ax mov ss, ax
mov sp, 0EC00h mov sp, TMP_STACK_TOP and 0xFFFF
; set up segment registers ; set up segment registers
push cs push cs
pop ds pop ds
@ -534,7 +534,7 @@ end if
cmp byte [di+preboot_dma-preboot_device], 1 cmp byte [di+preboot_dma-preboot_device], 1
adc byte [di+preboot_dma-preboot_device], 0 adc byte [di+preboot_dma-preboot_device], 0
cmp byte [di+preboot_launcher-preboot_device], 1 ; Start LAUNCHER by default cmp byte [di+preboot_launcher-preboot_device], 1 ; Start LAUNCHER by default
adc byte [di+preboot_launcher-preboot_device], 0 adc byte [di+preboot_launcher-preboot_device], 0
; cmp byte [di+preboot_biosdisk-preboot_device], 1 ; cmp byte [di+preboot_biosdisk-preboot_device], 1
; adc byte [di+preboot_biosdisk-preboot_device], 0 ; adc byte [di+preboot_biosdisk-preboot_device], 0
;; default value for VRR is OFF ;; default value for VRR is OFF

View File

@ -51,7 +51,6 @@ goto :eof
echo lang fix %lang% > lang.inc echo lang fix %lang% > lang.inc
fasm -m 65536 kernel.asm bin\kernel.mnt fasm -m 65536 kernel.asm bin\kernel.mnt
if not %errorlevel%==0 goto :Error_FasmFailed if not %errorlevel%==0 goto :Error_FasmFailed
erase lang.inc
goto :eof goto :eof
@ -63,7 +62,6 @@ goto :Exit_OK
:Error_FasmFailed :Error_FasmFailed
echo error: fasm execution failed echo error: fasm execution failed
erase lang.inc >nul 2>&1
echo. echo.
pause pause
exit 1 exit 1

View File

@ -544,13 +544,17 @@ WSTATE_WNDDRAWN = 00000010b
WSTYLE_HASCAPTION = 00010000b WSTYLE_HASCAPTION = 00010000b
WSTYLE_CLIENTRELATIVE = 00100000b WSTYLE_CLIENTRELATIVE = 00100000b
ZPOS_DESKTOP = -2
ZPOS_ALWAYS_BACK = -1
ZPOS_NORMAL = 0
ZPOS_ALWAYS_TOP = 1 ;ZPOS_ALWAYS_TOP is always last and has max number!
; structures definition ; structures definition
struct WDATA struct WDATA
box BOX box BOX
cl_workarea dd ? cl_workarea dd ?
cl_titlebar dd ? cl_titlebar dd ?
cl_frames dd ? cl_frames dd ?
reserved db ? z_modif db ?
fl_wstate db ? fl_wstate db ?
fl_wdrawn db ? fl_wdrawn db ?
fl_redraw db ? fl_redraw db ?

View File

@ -447,6 +447,7 @@ get_clock_ns:
jz .old_tics jz .old_tics
push ebx push ebx
push esi
pushfd pushfd
cli cli
@ -456,15 +457,24 @@ get_clock_ns:
mov eax, [ebx+0xF0] mov eax, [ebx+0xF0]
mov ecx, [ebx+0xF4] mov ecx, [ebx+0xF4]
cmp ecx, edx cmp ecx, edx
jnz @B jne @B
mov ecx, [hpet_period] mul [hpet_period]
mov ebx, edx shrd eax, edx, 10
imul ebx, ecx shr edx, 10
mul ecx
add edx, ebx mov ebx, eax
mov esi, edx
mov eax, ecx
mul [hpet_period]
shld edx, eax, 22
shl eax, 22
add eax, ebx
adc edx, esi
popfd popfd
pop esi
pop ebx pop ebx
ret ret

View File

@ -285,7 +285,7 @@ proc find_next_task
call [ebx+APPDATA.wait_test] call [ebx+APPDATA.wait_test]
mov [esp+28], eax mov [esp+28], eax
popad popad
test eax, eax or eax, eax
jnz @f jnz @f
; testing for timeout ; testing for timeout
mov eax, [timer_ticks] mov eax, [timer_ticks]

View File

@ -263,7 +263,7 @@ show_error_parameters:
call .check_ESP call .check_ESP
test eax, eax test eax, eax
jnz .error_ESP jnz .error_ESP
DEBUGF 1, " [ESP+08]: %x\n",[ebx] DEBUGF 1, " [ESP+08]: %x\n",[ebx]
add ebx, 4 add ebx, 4
call .check_ESP call .check_ESP
test eax, eax test eax, eax
@ -293,7 +293,7 @@ show_error_parameters:
call .check_ESP call .check_ESP
test eax, eax test eax, eax
jnz .error_ESP jnz .error_ESP
DEBUGF 1, " [ESP+32]: %x\n",[ebx] DEBUGF 1, " [ESP+32]: %x\n",[ebx]
pop edx ecx ebx eax pop edx ecx ebx eax
ret ret
.error_ESP: .error_ESP:
@ -315,11 +315,11 @@ show_error_parameters:
mov eax, [page_tabs+ebx*4] mov eax, [page_tabs+ebx*4]
test eax, 2 test eax, 2
jz .fail ;address not reserved for use. error jz .fail ;address not reserved for use. error
pop ebx pop ebx
xor eax, eax xor eax, eax
ret ret
.fail: .fail:
pop ebx pop ebx
xor eax, eax xor eax, eax
@ -581,7 +581,7 @@ destroy_thread:
mov [esi+WDATA.cl_workarea], eax mov [esi+WDATA.cl_workarea], eax
mov [esi+WDATA.cl_titlebar], eax mov [esi+WDATA.cl_titlebar], eax
mov [esi+WDATA.cl_frames], eax mov [esi+WDATA.cl_frames], eax
mov dword [esi+WDATA.reserved], eax; clear all flags: wstate, redraw, wdrawn mov dword [esi+WDATA.z_modif], eax; clear all flags: z_modif, wstate, redraw, wdrawn
lea edi, [esi-window_data+draw_data] lea edi, [esi-window_data+draw_data]
mov ecx, 32/4 mov ecx, 32/4
rep stosd rep stosd

View File

@ -898,7 +898,7 @@ endp
align 4 align 4
proc new_sys_threads proc new_sys_threads
locals locals
slot dd ? slot dd ?
flags dd ? flags dd ?
app_cmdline dd ? ;0x00 app_cmdline dd ? ;0x00
app_path dd ? ;0x04 app_path dd ? ;0x04
@ -1164,7 +1164,7 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov [ebx+REG_ECX], eax mov [ebx+REG_ECX], eax
mov [ebx+REG_EAX], eax mov [ebx+REG_EAX], eax
mov eax, [esi+0x08] ;app_eip mov eax, [esi+0x08] ;app_eip
mov [ebx+REG_EIP], eax ;app_entry mov [ebx+REG_EIP], eax ;app_entry
mov [ebx+REG_CS], dword app_code mov [ebx+REG_CS], dword app_code
mov ecx, USER_PRIORITY mov ecx, USER_PRIORITY

View File

@ -7,61 +7,44 @@
$Revision$ $Revision$
; HDD and CD search
;******************************************************
; поиск приводов HDD и CD
; автор исходного текста Кулаков Владимир Геннадьевич.
; адаптация и доработка Mario79
;******************************************************
;****************************************************
;* ПОИСК HDD и CD *
;****************************************************
cmp [ecx+IDE_DATA.ProgrammingInterface], 0 cmp [ecx+IDE_DATA.ProgrammingInterface], 0
je EndFindHDD je EndFindHDD
FindHDD: FindHDD:
push ecx push ecx
xor ebx, ebx xor ebx, ebx
inc ebx inc ebx
mov [DeviceNumber], 0
cmp ecx, IDE_controller_2 cmp ecx, IDE_controller_1
jne @f jz .find
add bl, 5 add bl, 5
jmp .find add [DeviceNumber], sizeof.HD_DATA*4
@@: cmp ecx, IDE_controller_2
cmp ecx, IDE_controller_3 jz .find
jne .find add bl, 5
add [DeviceNumber], sizeof.HD_DATA*4
add bl, 10
;--------------------------------------
.find: .find:
mov [ChannelNumber], 1 mov [ChannelNumber], 1
mov [DiskNumber], 0 mov [DiskNumber], 0
call FindHDD_2 call FindHDD_1
mov [DiskNumber], 1 inc [DiskNumber]
call FindHDD_2 call FindHDD_2
inc [ChannelNumber] inc [ChannelNumber]
dec [DiskNumber]
mov [DiskNumber], 0
call FindHDD_2 call FindHDD_2
mov [DiskNumber], 1 inc [DiskNumber]
call FindHDD_1 call FindHDD_2
pop ecx pop ecx
jmp EndFindHDD jmp EndFindHDD
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
FindHDD_2: FindHDD_2:
call FindHDD_1 add [DeviceNumber], sizeof.HD_DATA
shl byte [ebx+DRIVE_DATA], 2 shl byte [ebx+DRIVE_DATA], 2
ret
;-----------------------------------------------------------------------------
FindHDD_1: FindHDD_1:
DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2 DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2
DEBUGF 1, "Disk %d\n",[DiskNumber]:1 DEBUGF 1, "Disk %d\n",[DiskNumber]:1
@ -80,6 +63,9 @@ FindHDD_1:
ja .FindCD ja .FindCD
inc byte [ebx+DRIVE_DATA] inc byte [ebx+DRIVE_DATA]
movzx eax, [DeviceNumber]
bt word [Sector512+166], 10
adc [eax+hd0_data.hd48], 0
jmp .Print_Device_Name jmp .Print_Device_Name
;-------------------------------------- ;--------------------------------------
.FindCD: .FindCD:
@ -262,6 +248,7 @@ StandardATABases dw ?, ? ; 1F0h, 170h
ChannelNumber dw ? ChannelNumber dw ?
; Номер диска ; Номер диска
DiskNumber db ? DiskNumber db ?
DeviceNumber db ?
; Базовый адрес группы портов контроллера ATA ; Базовый адрес группы портов контроллера ATA
ATABasePortAddr dw ? ATABasePortAddr dw ?
; Параметры ATA-команды ; Параметры ATA-команды

View File

@ -13,27 +13,27 @@ search_partitions:
xor eax, eax xor eax, eax
mov edx, IDE_controller_1 mov edx, IDE_controller_1
mov ax, [edx + IDE_DATA.BAR0_val] mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd0_data.hdbase], eax mov [hd0_data.hdbase], ax
mov [hd1_data.hdbase], eax mov [hd1_data.hdbase], ax
mov ax, [edx + IDE_DATA.BAR2_val] mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd2_data.hdbase], eax mov [hd2_data.hdbase], ax
mov [hd3_data.hdbase], eax mov [hd3_data.hdbase], ax
mov edx, IDE_controller_2 mov edx, IDE_controller_2
mov ax, [edx + IDE_DATA.BAR0_val] mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd4_data.hdbase], eax mov [hd4_data.hdbase], ax
mov [hd5_data.hdbase], eax mov [hd5_data.hdbase], ax
mov ax, [edx + IDE_DATA.BAR2_val] mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd6_data.hdbase], eax mov [hd6_data.hdbase], ax
mov [hd7_data.hdbase], eax mov [hd7_data.hdbase], ax
mov edx, IDE_controller_3 mov edx, IDE_controller_3
mov ax, [edx + IDE_DATA.BAR0_val] mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd8_data.hdbase], eax mov [hd8_data.hdbase], ax
mov [hd9_data.hdbase], eax mov [hd9_data.hdbase], ax
mov ax, [edx + IDE_DATA.BAR2_val] mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd10_data.hdbase], eax mov [hd10_data.hdbase], ax
mov [hd11_data.hdbase], eax mov [hd11_data.hdbase], ax
; 2. Notify the system about /hd* disks. ; 2. Notify the system about /hd* disks.
; For every existing disk, call ide_disk_add with correct parameters. ; For every existing disk, call ide_disk_add with correct parameters.
; Generate name "hdN" on the stack; this is 4 bytes including terminating zero. ; Generate name "hdN" on the stack; this is 4 bytes including terminating zero.

View File

@ -194,39 +194,41 @@
* Системное время можно установить функцией 22. * Системное время можно установить функцией 22.
====================================================================== ======================================================================
============== Функция 4 - вывести строку текста в окно. ============= ================ Функция 4 - нарисовать строку текста. ===============
====================================================================== ======================================================================
Параметры: Параметры:
* eax = 4 - номер функции * eax = 4 - номер функции
* ebx = [координата по оси x]*65536 + [координата по оси y] * ebx = X*65536+Y, координаты в окне или буфере
* ecx = 0xXYRRGGBB, где * ecx = 0xXXRRGGBB, где
* RR, GG, BB задают цвет текста * RR, GG, BB задают цвет текста
* X=ABnn (биты): * XX=ABFFCSSS (биты):
* nn задает используемый шрифт: 0=системный моноширинный, * A=1 - рисуемая строка заканчивается нулём
1=системный шрифт переменной ширины * B=1 - закрашивать фон (цвет = edi)
* A=0 - выводить esi символов, A=1 - выводить ASCIIZ-строку * FF задает шрифт и кодировку:
* B=1 - закрашивать фон цветом edi 0 = 6x9 cp866
* Y=Cnnn (биты): 1 = 8x16 cp866
* C=1 перенаправить вывод в область пользователя, задано в edi 2 = 8x16 UTF-16LE
* nnn - не используется в текущем виде, должно быть 0 (zero) 3 = 8x16 UTF-8
* C=0 - рисовать в окно,
С=1 - рисовать в буфер (edi)
* SSS = (множитель размера)-1, то-есть 0 = x1, 7 = x8
* edx = указатель на начало строки * edx = указатель на начало строки
* esi = для A=0 длина строки, должна быть не больше 255; * esi = для A=0 длина строки, для A=1 игнорируется
для A=1 игнорируется * edi = если B=1 - цвет для закраски фона,
* edi = цвет для закраски фона, если B=1 если C=1 - указатель на буфер
* edi = указатель на область пользователя, если C=1
Возвращаемое значение: Возвращаемое значение:
* функция не возвращает значения * функция не возвращает значения
Замечания: Замечания:
* Первый системный шрифт считывается при загрузке из файла char.mt, * Нельзя одновременно использовать B=1 и C=1,
второй - из char2.mt. поскольку в обоих случаях используется регистр edi.
* Оба шрифта имеют высоту 9 пикселей, ширина моноширинного шрифта * Если SSS=0, шрифт может сглаживаться,
равна 6 пикселей. в зависимости от системной настройки.
* C=1, глубина точки = 32 бита, область пользователя выглядит так: * Структура буфера:
dword Xsize Xsize dd
dword Ysize Ysize dd
остаток области = Xsize * Y size * 4 picture rb Xsize*Ysize*4 ; 32 бита
* Нельзя одновременно использовать B=1 и C=1, поскольку в обоих
случаях использован регистр edi для разных целей.
====================================================================== ======================================================================
========================= Функция 5 - пауза. ========================= ========================= Функция 5 - пауза. =========================
====================================================================== ======================================================================
@ -243,38 +245,6 @@
(закончить текущий квант времени), используйте подфункцию 1 (закончить текущий квант времени), используйте подфункцию 1
функции 68. функции 68.
======================================================================
=============== Функция 6 - прочитать файл с рамдиска. ===============
======================================================================
Параметры:
* eax = 6 - номер функции
* ebx = указатель на имя файла
* ecx = номер стартового блока, считая с 1;
ecx=0 - читать с начала файла (то же самое, что и ecx=1)
* edx = число блоков для чтения;
edx=0 - читать один блок (то же самое, что и edx=1)
* esi = указатель на область памяти, куда будут записаны данные
Возвращаемое значение:
* eax = длина файла в байтах, если файл успешно прочитан
* eax = -1, если файл не найден
Замечания:
* Данная функция является устаревшей; функция 70
позволяет выполнять те же действия с расширенными возможностями.
* Блок = 512 байт.
* Для чтения всего файла можно указать заведомо большое значение
в edx, например, edx = -1; но в этом случае будьте готовы к тому,
что программа "упадет", если файл окажется слишком большим
и "не влезет" в память программы.
* Имя файла должно быть либо в формате 8+3 символов
(первые 8 символов - собственно имя, последние 3 - расширение,
короткие имена и расширения дополняются пробелами),
либо в формате 8.3 символов "FILE.EXT"/"FILE.EX "
(имя не более 8 символов, точка, расширение 3 символа,
дополненное при необходимости пробелами).
Имя файла должно быть записано заглавными буквами.
Завершающий символ с кодом 0 не нужен (не ASCIIZ-строка).
* Эта функция не поддерживает папки на рамдиске.
====================================================================== ======================================================================
=============== Функция 7 - вывести изображение в окно. ============== =============== Функция 7 - вывести изображение в окно. ==============
====================================================================== ======================================================================
@ -1004,20 +974,22 @@ dd 1675
Возвращаемое значение: Возвращаемое значение:
* функция не возвращает значения * функция не возвращает значения
------------- Подподфункция 2 - получить задержку мыши. -------------- Замечание: рекомендуемая скорость = 1, 0 = заблокировать курсор.
------------- Подподфункция 2 - получить ускорение мыши. -------------
Параметры: Параметры:
* eax = 18 - номер функции * eax = 18 - номер функции
* ebx = 19 - номер подфункции * ebx = 19 - номер подфункции
* ecx = 2 - номер подподфункции * ecx = 2 - номер подподфункции
Возвращаемое значение: Возвращаемое значение:
* eax = текущая задержка мыши * eax = 0 - выключить, 1 - слабое, 2 - среднее, 3 - сильное
------------ Подподфункция 3 - установить задержку мыши. ------------- ------------ Подподфункция 3 - установить ускорение мыши. ------------
Параметры: Параметры:
* eax = 18 - номер функции * eax = 18 - номер функции
* ebx = 19 - номер подфункции * ebx = 19 - номер подфункции
* ecx = 3 - номер подподфункции * ecx = 3 - номер подподфункции
* edx = новое значение задержки мыши * edx = 0 - выключить, 1 - слабое, 2 - среднее, 3 - сильное
Возвращаемое значение: Возвращаемое значение:
* функция не возвращает значения * функция не возвращает значения
@ -1044,21 +1016,25 @@ dd 1675
* бит 4 установлен = 5-я кнопка нажата * бит 4 установлен = 5-я кнопка нажата
Возвращаемое значение: Возвращаемое значение:
* функция не возвращает значения * функция не возвращает значения
Замечания:
* Рекомендуемая скорость мыши (в подподфункции 1) от 1 до 9. -------- Подподфункция 6 - получить задержку двойного щелчка. --------
Устанавливаемая величина не проверяется кодом ядра, поэтому Параметры:
используйте осторожно, при некорректном значении курсор может * eax = 18 - номер функции
"замёрзнуть". Скорость мыши можно регулировать в приложении SETUP. * ebx = 19 - номер подфункции
* Рекомендуемая величина задержки (в подподфункции 3) = 10. * ecx = 6 - номер подподфункции
Меньшие значения не обрабатываются COM-мышами. При очень больших Возвращаемое значение:
значениях невозможно передвижение мыши на 1 пиксель и курсор будет * eax = текущая задержка двойного щелчка (100 = секунда)
прыгать на величину установленной скорости (подподфункция 1).
Устанавливаемая величина не проверяется кодом ядра. ------- Подподфункция 7 - установить задержку двойного щелчка. -------
Величину задержки можно менять в приложении SETUP. Параметры:
* Подподфункция 4 не проверяет переданное значение. Перед вызовом * eax = 18 - номер функции
необходимо узнать текущее разрешение экрана (подфункцией 14) * ebx = 19 - номер подфункции
и проверить, что устанавливаемое положение не выходит за пределы * ecx = 7 - номер подподфункции
экрана. * dl = новое значение задержки двойного щелчка (100 = секунда)
Возвращаемое значение:
* функция не возвращает значения
Замечание: настройки мыши можно регулировать в приложении mouse_cfg.
====================================================================== ======================================================================
====================== Функция 18, подфункция 20 ===================== ====================== Функция 18, подфункция 20 =====================
@ -1145,6 +1121,37 @@ dd 1675
* Размеры указываемые в функции не должны превышать размеры текущего * Размеры указываемые в функции не должны превышать размеры текущего
видеорежима, иначе функция ничего не изменит. видеорежима, иначе функция ничего не изменит.
======================================================================
===================== Функция 18, подфункция 25 ======================
======== Управление положением окна относительно других окон. ========
======================================================================
------------- Подподфункция 1 - получить положение ------------------
Параметры:
* eax = 18 - номер функции
* ebx = 25 - номер подфункции
* ecx = 1 - номер подподфункции
* edx = -1(для текущего окна) или PID приложения
Возвращаемое значение:
* eax = одна из констант положения окна
------------- Подподфункция 2 - установить положение ----------------
Параметры:
* eax = 18 - номер функции
* ebx = 25 - номер подфункции
* ecx = 2 - номер подподфункции
* edx = -1(для текущего окна) или PID приложения
* esi = новое положение окна (одна из констант ниже)
Возвращаемое значение:
* eax = 0 - неудача
* eax = 1 - успех
Константы положения окна относительно других окон:
ZPOS_DESKTOP = -2 - на самом заднем плане
ZPOS_ALWAYS_BACK = -1 - позади всех окон
ZPOS_NORMAL = 0 - обычное
ZPOS_ALWAYS_TOP = 1 - поверх всех окон
====================================================================== ======================================================================
==================== Функция 20 - интерфейс MIDI. ==================== ==================== Функция 20 - интерфейс MIDI. ====================
====================================================================== ======================================================================
@ -1459,6 +1466,22 @@ dd 1675
497 суток. 497 суток.
* Системное время можно получить функцией 3. * Системное время можно получить функцией 3.
======================================================================
===================== Функция 26, подфункция 10 ======================
========== Получить значение высокоточного счётчика времени. =========
======================================================================
Parameters:
* eax = 26 - номер функции
* ebx = 10 - номер подфункции
Returned value:
* edx:eax = число наносекунд с момента загрузки ядра
* eax = младшее двойное слово
* edx = старшее двойное слово
Remarks:
* функция использует счётчик HPET, если HPET не доступен используется
счётчик PIT. В этом случае точность будет уменьшена до 10 000 000
наносекунд.
====================================================================== ======================================================================
====================== Функция 26, подфункция 11 ===================== ====================== Функция 26, подфункция 11 =====================
=========== Узнать, разрешён ли низкоуровневый доступ к HD. ========== =========== Узнать, разрешён ли низкоуровневый доступ к HD. ==========
@ -1619,18 +1642,41 @@ dir_path1 db 'HD0/1',0
и всё равно содержит относительную y-координату, и всё равно содержит относительную y-координату,
а к старшему слову следует прибавить 1. а к старшему слову следует прибавить 1.
----------------- Подфункция 2 - нажатые кнопки мыши ----------------- ---------------- Подфункция 2 - состояния кнопок мыши ----------------
Параметры: Параметры:
* eax = 37 - номер функции * eax = 37 - номер функции
* ebx = 2 - номер подфункции * ebx = 2 - номер подфункции
Возвращаемое значение: Возвращаемое значение:
* eax содержит информацию о нажатых кнопках мыши: * eax = биты 0-4 соответствуют подфункции 3
* бит 0 установлен = левая кнопка нажата
* бит 1 установлен = правая кнопка нажата ----------- Подфункция 3 - состояния и события кнопок мыши -----------
* бит 2 установлен = средняя кнопка нажата Параметры:
* бит 3 установлен = 4-я кнопка нажата * eax = 37 - номер функции
* бит 4 установлен = 5-я кнопка нажата * ebx = 3 - номер подфункции
* прочие биты сброшены Возвращаемое значение:
* eax содержит следующую информацию:
состояния:
* бит 0 установлен = удерживается левая кнопка
* бит 1 установлен = удерживается правая кнопка
* бит 2 установлен = удерживается средняя кнопка
* бит 3 установлен = удерживается 4-я кнопка
* бит 4 установлен = удерживается 5-я кнопка
события:
* бит 8 установлен = нажата левая кнопка
* бит 9 установлен = нажата правая кнопка
* бит 10 установлен = нажата средняя кнопка
* бит 15 установлен = используется вертикальная прокрутка
* бит 16 установлен = отпущена левая кнопка
* бит 17 установлен = отпущена правая кнопка
* бит 18 установлен = отпущена средняя кнопка
* бит 23 установлен = используется горизонтальная прокрутка
* бит 24 установлен = двойной щелчёк левой кнопкой
------------------ Подфункция 4 - загрузить курсор ------------------- ------------------ Подфункция 4 - загрузить курсор -------------------
Параметры: Параметры:
@ -2085,6 +2131,40 @@ dword-значение цвета 0x00RRGGBB
* Пользователь может изменять скин статически, создав свой * Пользователь может изменять скин статически, создав свой
default.skn, или динамически с помощью приложения desktop. default.skn, или динамически с помощью приложения desktop.
======================================================================
= Функция 48, подфункция 9 - получить настройку сглаживания шрифтов. =
======================================================================
Параметры:
* eax = 48 - номер функции
* ebx = 9 - номер подфункции
Возвращаемое значение:
* eax = 2 - субпиксельное, 1 - обычное, 0 - выключить
======================================================================
===== Функция 48, подфункция 10 - настроить сглаживание шрифтов. =====
======================================================================
Параметры:
* eax = 48 - номер функции
* ebx = 10 - номер подфункции
* cl = 2 - субпиксельное, 1 - обычное, 0 - выключить
======================================================================
======== Функция 48, подфункция 11 - получить размер шрифтов. ========
======================================================================
Параметры:
* eax = 48 - номер функции
* ebx = 9 - номер подфункции
Возвращаемое значение:
* eax = текущая высота шрифта в пикселях
======================================================================
======= Функция 48, подфункция 12 - установить размер шрифтов. =======
======================================================================
Параметры:
* eax = 48 - номер функции
* ebx = 10 - номер подфункции
* cl = новая высота шрифта в пикселях
====================================================================== ======================================================================
============ Функция 49 - Advanced Power Management (APM). =========== ============ Функция 49 - Advanced Power Management (APM). ===========
====================================================================== ======================================================================
@ -3805,9 +3885,13 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
Возвращаемое значение: Возвращаемое значение:
* функция не возвращает значения * функция не возвращает значения
Замечания: Замечания:
* Строка заголовка должна быть в формате ASCIIZ. В заголовке * Строка заголовка должна заканчиваться нулём.
отображается не более 255 символов независимо от полной длины * Можно указать кодировку заголовка,
строки. поместив в начале строки байт со значениями:
1 = cp866
2 = UTF-16LE
3 = UTF-8
иначе будет использоваться cp866.
* Чтобы убрать заголовок, передайте NULL в ecx. * Чтобы убрать заголовок, передайте NULL в ecx.
====================================================================== ======================================================================
@ -3916,6 +4000,76 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
Возвращаемое значение: Возвращаемое значение:
* eax = -1 для ошибки * eax = -1 для ошибки
======================================================================
===== Функция 74, подфункция 4, Получить указатель на устройство =====
======================================================================
Параметры:
* eax = 74 - номер функции
* bl = 4 - номер подфункции
* bh = номер устройства
Возвращаемое значение:
* eax = указатель, -1 для ошибки
======================================================================
=== Функция 74, подфункция 6, Получить количество посланых пакетов ===
======================================================================
Параметры:
* eax = 74 - номер функции
* bl = 6 - номер подфункции
* bh = номер устройства
Возвращаемое значение:
* eax = количество с момента старта устройства, -1 для ошибки
======================================================================
=== Функция 74, подфункция 7, Получить количество принятых пакетов ===
======================================================================
Параметры:
* eax = 74 - номер функции
* bl = 7 - номер подфункции
* bh = номер устройства
Возвращаемое значение:
* eax = количество с момента старта устройства, -1 для ошибки
======================================================================
==== Функция 74, подфункция 8, Получить количество посланых байт. ====
======================================================================
Параметры:
* eax = 74 - номер функции
* bl = 8 - номер подфункции
* bh = номер устройства
Возвращаемое значение:
* eax = количество с момента старта устройства, -1 для ошибки
* ebx = старшая часть
======================================================================
==== Функция 74, подфункция 9, Получить количество принятых байт. ====
======================================================================
Параметры:
* eax = 74 - номер функции
* bl = 9 - номер подфункции
* bh = номер устройства
Возвращаемое значение:
* eax = количество с момента старта устройства, -1 для ошибки
* ebx = старшая часть
======================================================================
======= Функция 74, подфункция 10, Получить статус соединения. =======
======================================================================
Параметры:
* eax = 74 - номер функции
* bl = 10 - номер подфункции
* bh = номер устройства
Возвращаемое значение:
* eax = статус соединения, -1 для ошибки
Статусы:
0 = нет соединения
1 = неизвестное соединение
4 = 10 Мбит
8 = 100 Мбит
12 = 1 Гбит
10b = флаг полного дуплекса
====================================================================== ======================================================================
======= Функция 75, подфункция 0, Open socket (Открыть сокет). ======= ======= Функция 75, подфункция 0, Open socket (Открыть сокет). =======
====================================================================== ======================================================================

View File

@ -192,40 +192,38 @@ Remarks:
* System time can be set by function 22. * System time can be set by function 22.
====================================================================== ======================================================================
============ Function 4 - draw text string in the window. ============ =================== Function 4 - draw text string. ===================
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 4 - function number * eax = 4 - function number
* ebx = [coordinate on axis x]*65536 + [coordinate on axis y] * ebx = X*65536+Y, coordinates in the window or buffer
* ecx = 0xXYRRGGBB, where * ecx = 0xXXRRGGBB, where
* RR, GG, BB specify text color * RR, GG, BB specify text color
* X=ABnn (bits): * XX = ABFFCSSS (bits):
* nn specifies the used font: 0=system monospaced, * A=1 - output zero terminated string
1=system font of variable width * B=1 - fill background (color = edi)
* A=0 - output esi characters, A=1 - output ASCIIZ-string * FF specifies the font and encoding:
* B=1 - fill background with the color edi 0 = 6x9 cp866
* Y = Cnnn 1 = 8x16 cp866
* C=1 redirect the output to the user area, specified in edi 2 = 8x16 UTF-16LE
* nnn - not used in the current, must be 0 (zero) 3 = 8x16 UTF-8
* C=0 - draw to the window,
C=1 - draw to the user buffer (edi)
* SSS = (size multiplier)-1, so 0 = x1, 7 = x8
* edx = pointer to the beginning of the string * edx = pointer to the beginning of the string
* esi = for A=0 length of the string, must not exceed 255; * esi = for A=0 length of the string, for A=1 is ignored
for A=1 is ignored * edi = for B=1 color to fill background,
* edi = color to fill background, if B=1 for C=1 pointer to user buffer
* edi = pointer to user area, for redirect, if C=1
Returned value: Returned value:
* function does not return value * function does not return value
Remarks: Remarks:
* First system font is read out at loading from the file char.mt, * You can not use B=1 and C=1 at the same time, since both use edi.
second - from char2.mt. * When SSS=0, font may be smoothed, depending on system setting.
* Both fonts have height 9 pixels, width of the monospaced font * User buffer structure:
is equal to 6 pixels. Xsize dd
* C=1, pixel depth = 32 bits, user area is as follows: Ysize dd
dword Xsize picture rb Xsize*Ysize*4 ; 32 bpp
dword Ysize
rest of the area = Xsize * Y size * 4
* You can not use B = 1 and C = 1, at the same time. Since in both
cases, the register edi is used for different purposes.
====================================================================== ======================================================================
========================= Function 5 - delay. ======================== ========================= Function 5 - delay. ========================
@ -242,38 +240,6 @@ Remarks:
to transfer control to the next process (to complete a current to transfer control to the next process (to complete a current
time slice), use subfunction 1 of function 68. time slice), use subfunction 1 of function 68.
======================================================================
============== Function 6 - read the file from ramdisk. ==============
======================================================================
Parameters:
* eax = 6 - function number
* ebx = pointer to the filename
* ecx = number of start block, beginning from 1;
ecx=0 - read from the beginning of the file (same as ecx=1)
* edx = number of blocks to read;
edx=0 - read one block (same as edx=1)
* esi = pointer to memory area for the data
Returned value:
* eax = file size in bytes, if the file was successfully read
* eax = -1, if the file was not found
Remarks:
* This function is out-of-date; function 70 allows
to fulfil the same operations with the extended possibilities.
* Block = 512 bytes.
* For reading all file you can specify the certainly large value
in edx, for example, edx = -1; but in this case be ready that
the program will "fall", if the file will appear too large and can
not be placed in the program memory.
* The filename must be either in the format 8+3 characters
(first 8 characters - name itself, last 3 - extension,
the short names and extensions are supplemented with spaces),
or in the format 8.3 characters "FILE.EXT"/"FILE.EX "
(name no more than 8 characters, dot, extension 3 characters
supplemented if necessary by spaces).
The filename must be written with capital letters. The terminating
character with code 0 is not necessary (not ASCIIZ-string).
* This function does not support folders on the ramdisk.
====================================================================== ======================================================================
=============== Function 7 - draw image in the window. =============== =============== Function 7 - draw image in the window. ===============
====================================================================== ======================================================================
@ -1004,20 +970,22 @@ Parameters:
Returned value: Returned value:
* function does not return value * function does not return value
---------------- Subsubfunction 2 - get mouse delay. ----------------- Remark: recommended speed = 1, 0 = lock the cursor.
------------- Subsubfunction 2 - get mouse acceleration. -------------
Parameters: Parameters:
* eax = 18 - function number * eax = 18 - function number
* ebx = 19 - subfunction number * ebx = 19 - subfunction number
* ecx = 2 - subsubfunction number * ecx = 2 - subsubfunction number
Returned value: Returned value:
* eax = current mouse delay * eax = 0 - off, 1 - slight, 2 - medium, 3 - intense
---------------- Subsubfunction 3 - set mouse delay. ----------------- ------------- Subsubfunction 3 - set mouse acceleration. -------------
Parameters: Parameters:
* eax = 18 - function number * eax = 18 - function number
* ebx = 19 - subfunction number * ebx = 19 - subfunction number
* ecx = 3 - subsubfunction number * ecx = 3 - subsubfunction number
* edx = new value for mouse delay * edx = 0 - off, 1 - slight, 2 - medium, 3 - intense
Returned value: Returned value:
* function does not return value * function does not return value
@ -1044,22 +1012,25 @@ Parameters:
* bit 4 is set = 5th button is pressed * bit 4 is set = 5th button is pressed
Returned value: Returned value:
* function does not return value * function does not return value
Remarks:
* It is recommended to set speed of the mouse (in subsubfunction 1) -------------- Subsubfunction 6 - get doubleclick delay. -------------
from 1 up to 9. The installed value is not inspected by the kernel Parameters:
code, so set it carefully, at incorrect value the cursor * eax = 18 - function number
can "freeze". Speed of the mouse can be regulated through the * ebx = 19 - subfunction number
application SETUP. * ecx = 6 - subsubfunction number
* Recommended delay of the mouse (in subsubfunction 3) = 10. Lower Returned value:
value is not handled by COM mice. At the very large values the * eax = current doubleclick delay (100 = 1 second)
movement of the mouse on 1 pixel is impossible and the cursor will
jump on the value of installed speed (subsubfunction 1). The -------------- Subsubfunction 7 - set doubleclick delay. -------------
installed value is not inspected by the kernel code. Parameters:
Mouse delay can be regulated through the application SETUP. * eax = 18 - function number
* The subsubfunction 4 does not check the passed value. Before * ebx = 19 - subfunction number
its call find out current screen resolution (with function 14) * ecx = 7 - subsubfunction number
and check that the value of position is inside the limits of the * dl = new value for doubleclick delay (100 = 1 second)
screen. Returned value:
* function does not return value
Remark: mouse settings can be modified in the application mouse_cfg.
====================================================================== ======================================================================
======== Function 18, subfunction 20 - get information on RAM. ======= ======== Function 18, subfunction 20 - get information on RAM. =======
@ -1148,6 +1119,37 @@ Remarks:
of the current video mode, otherwise the function will not change of the current video mode, otherwise the function will not change
anything. anything.
======================================================================
===================== Function 18, subfunction 25 ====================
===== Control position of the window relative to other windows. ======
======================================================================
------------- Subsubfunction 1 - get position -----------------------
Parameters:
* eax = 18 - function number
* ebx = 25 - subfunction number
* ecx = 1 - subsubfunction number
* edx = -1(for current window) or PID application
Returned value:
* eax = one of the constants window position
------------- Subsubfunction 2 - set position -----------------------
Parameters:
* eax = 18 - function number
* ebx = 25 - subfunction number
* ecx = 2 - subsubfunction number
* edx = -1(for current window) or PID application
* esi = new window position (one of the constants below)
Returned value:
* eax = 0 - error
* eax = 1 - success
Constant position of the window relative to other windows:
ZPOS_DESKTOP = -2 - on the background
ZPOS_ALWAYS_BACK = -1 - behind all the windows
ZPOS_NORMAL = 0 - normal
ZPOS_ALWAYS_TOP = 1 - on top of all windows
====================================================================== ======================================================================
==================== Function 20 - MIDI interface. =================== ==================== Function 20 - MIDI interface. ===================
====================================================================== ======================================================================
@ -1451,7 +1453,21 @@ Returned value:
Remarks: Remarks:
* Counter takes modulo 2^32, that correspond to a little more * Counter takes modulo 2^32, that correspond to a little more
than 497 days. than 497 days.
* To get system time use function 3. * To get system time use function 3.
======================================================================
===================== Function 26, subfunction 10 ====================
========== Get the value of the high precision time counter. =========
======================================================================
Parameters:
* eax = 26 - function number
* ebx = 10 - subfunction number
Returned value:
* eax = number of nanoseconds since system boot time (lower DWORD)
* edx = number of nanoseconds since system boot time (high DWORD)
Remarks:
* The counter is based on HPET, if HPET is not available, resolution
will be reduced to 10 000 000 nanoseconds.
====================================================================== ======================================================================
===================== Function 26, subfunction 11 ==================== ===================== Function 26, subfunction 11 ====================
@ -1611,18 +1627,41 @@ Remarks:
contains relative y-coordinate, and to the high word contains relative y-coordinate, and to the high word
1 should be added. 1 should be added.
------------ Subfunction 2 - pressed buttons of the mouse ------------ ------------- Subfunction 2 - states of the mouse buttons ------------
Parameters: Parameters:
* eax = 37 - function number * eax = 37 - function number
* ebx = 2 - subfunction number * ebx = 2 - subfunction number
Returned value: Returned value:
* eax contains information on the pressed mouse buttons: * eax = bits 0-4 equal to subfunction 3
* bit 0 is set = left button is pressed
* bit 1 is set = right button is pressed ------- Subfunction 3 - states and events of the mouse buttons -------
* bit 2 is set = middle button is pressed Parameters:
* bit 3 is set = 4th button is pressed * eax = 37 - function number
* bit 4 is set = 5th button is pressed * ebx = 3 - subfunction number
* other bits are cleared Returned value:
* eax contains next information:
states:
* bit 0 is set = left button is held
* bit 1 is set = right button is held
* bit 2 is set = middle button is held
* bit 3 is set = 4th button is held
* bit 4 is set = 5th button is held
events:
* bit 8 is set = left button is pressed
* bit 9 is set = right button is pressed
* bit 10 is set = middle button is pressed
* bit 15 is set = vertical scroll is used
* bit 16 is set = left button is released
* bit 17 is set = right button is released
* bit 18 is set = middle button is released
* bit 23 is set = horisontal scroll is used
* bit 24 is set = doubleclick by left button
-------------------- Subfunction 4 - load cursor --------------------- -------------------- Subfunction 4 - load cursor ---------------------
Parameters: Parameters:
@ -1954,11 +1993,11 @@ Remarks:
* Structure of the color table is described in the standard * Structure of the color table is described in the standard
include file 'macros.inc' as 'system_colors'; for example, include file 'macros.inc' as 'system_colors'; for example,
it is possible to write: it is possible to write:
sc system_colors ; variable declaration sc system_colors ; variable declaration
... ; somewhere one must call ... ; somewhere one must call
; this function with ecx=sc ; this function with ecx=sc
mov ecx, [sc.work_button_text] ; read text color on mov ecx, [sc.work_button_text] ; read text color on
; buttin in working area ; buttin in working area
* A program itself desides to use or not to use color table. * A program itself desides to use or not to use color table.
For usage program must simply at calls to drawing functions select For usage program must simply at calls to drawing functions select
color taken from the table. color taken from the table.
@ -2073,6 +2112,40 @@ Remarks:
* User can change the skin statically by creating hisself * User can change the skin statically by creating hisself
'default.skn' or dynamically with the application 'desktop'. 'default.skn' or dynamically with the application 'desktop'.
======================================================================
====== Function 48, subfunction 9 - get font smoothing setting. ======
======================================================================
Parameters:
* eax = 48 - function number
* ebx = 9 - subfunction number
Returned value:
* eax = 2 - subpixel, 1 - anti-aliasing, 0 - off
======================================================================
========== Function 48, subfunction 10 - set font smoothing. =========
======================================================================
Parameters:
* eax = 48 - function number
* ebx = 10 - subfunction number
* cl = 2 - subpixel, 1 - anti-aliasing, 0 - off
======================================================================
============ Function 48, subfunction 11 - get font size. ============
======================================================================
Parameters:
* eax = 48 - function number
* ebx = 9 - subfunction number
Returned value:
* eax = current font height in pixels
======================================================================
============ Function 48, subfunction 12 - set font size. ============
======================================================================
Parameters:
* eax = 48 - function number
* ebx = 10 - subfunction number
* cl = new font height in pixels
====================================================================== ======================================================================
=========== Function 49 - Advanced Power Management (APM). =========== =========== Function 49 - Advanced Power Management (APM). ===========
====================================================================== ======================================================================
@ -2324,11 +2397,11 @@ Remarks:
The data of the graphics screen (the memory area which displays The data of the graphics screen (the memory area which displays
screen contents) are accessible to a program directly, without screen contents) are accessible to a program directly, without
any system calls, through the selector gs: any system calls, through the selector gs:
mov eax, [gs:0] mov eax, [gs:0]
places in eax the first dword of the buffer, which contains places in eax the first dword of the buffer, which contains
information on color of the left upper point (and, possibly, colors information on color of the left upper point (and, possibly, colors
of several following). of several following).
mov [gs:0], eax mov [gs:0], eax
by work in VESA modes with LFB sets color of the left upper point by work in VESA modes with LFB sets color of the left upper point
(and, possibly, colors of several following). (and, possibly, colors of several following).
To interpret the data of graphics screen program needs to know To interpret the data of graphics screen program needs to know
@ -3056,7 +3129,7 @@ Remarks:
FPU and/or SSE. FPU and/or SSE.
====================================================================== ======================================================================
====== Function 68, subfunction 25 - set FPU exception handler. ====== ======== Function 68, subfunction 25 - set exception activity ========
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 68 - function number * eax = 68 - function number
@ -3161,7 +3234,7 @@ Remarks:
and at arrival of new message the system will wait. and at arrival of new message the system will wait.
For synchronization frame all work with the buffer by operations For synchronization frame all work with the buffer by operations
lock/unlock lock/unlock
neg [bufsize] neg [bufsize]
* Data in the buffer are considered as array of items with variable * Data in the buffer are considered as array of items with variable
length - messages. Format of a message is explained in length - messages. Format of a message is explained in
general description. general description.
@ -3772,12 +3845,16 @@ Remarks:
Parameters: Parameters:
* eax = 71 - function number * eax = 71 - function number
* ebx = 1 - subfunction number * ebx = 1 - subfunction number
* ecx = pointer to caption string * ecx = pointer to zero terminated string
Returned value: Returned value:
* function does not return value * function does not return value
Remarks: Remarks:
* String must be in the ASCIIZ-format. Disregarding real string * You may set the caption string encoding by putting
length, no more than 255 characters are drawn. at the start of the string a byte with next values:
1 = cp866
2 = UTF-16LE
3 = UTF-8
otherwise will be used cp866.
* Pass NULL in ecx to remove caption. * Pass NULL in ecx to remove caption.
====================================================================== ======================================================================
@ -3834,11 +3911,11 @@ Returned value:
* function does not return value * function does not return value
====================================================================== ======================================================================
= Function 74, Subfunction -1, Get number of active network devices. = = Function 74, Subfunction 255, Get number of active network devices. =
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 74 - function number * eax = 74 - function number
* bl = -1 - subfunction number * bl = 255 - subfunction number
Returned value: Returned value:
* eax = number of active network devices * eax = number of active network devices
@ -3850,7 +3927,7 @@ Parameters:
* bl = 0 - subfunction number * bl = 0 - subfunction number
* bh = device number * bh = device number
Returned value: Returned value:
* eax = device type * eax = device type number
====================================================================== ======================================================================
======== Function 74, Subfunction 1, Get network device name. ======== ======== Function 74, Subfunction 1, Get network device name. ========
@ -3884,6 +3961,78 @@ Parameters:
Returned value: Returned value:
* eax = -1 on error * eax = -1 on error
======================================================================
=========== Function 74, Subfunction 4, Get device pointer. ==========
======================================================================
Parameters:
* eax = 74 - function number
* bl = 4 - subfunction number
* bh = device number
Returned value:
* eax = device pointer, -1 on error
======================================================================
========= Function 74, Subfunction 6, Get packet TX counter. =========
======================================================================
Parameters:
* eax = 74 - function number
* bl = 6 - subfunction number
* bh = device number
Returned value:
* eax = Number of packets sent since device start, -1 on error
======================================================================
========= Function 74, Subfunction 7, Get packet RX counter. =========
======================================================================
Parameters:
* eax = 74 - function number
* bl = 7 - subfunction number
* bh = device number
Returned value:
* eax = Number of packets received since device start, -1 on error
======================================================================
========== Function 74, Subfunction 8, Get TX byte counter. ==========
======================================================================
Parameters:
* eax = 74 - function number
* bl = 8 - subfunction number
* bh = device number
Returned value:
* eax = Number of bytes sent since device start (lower dword)
-1 on error
* ebx = Number of bytes sent since device start (higher dword)
======================================================================
========== Function 74, Subfunction 9, Get RX byte counter. ==========
======================================================================
Parameters:
* eax = 74 - function number
* bl = 9 - subfunction number
* bh = device number
Returned value:
* eax = Number of bytes received since device start (lower dword)
-1 on error
* ebx = Number of bytes received since device start (higher dword)
======================================================================
========== Function 74, Subfunction 10, Get link status. =============
======================================================================
Parameters:
* eax = 74 - function number
* bl = 10 - subfunction number
* bh = device number
Returned value:
* eax = link status, -1 on error
Link status:
ETH_LINK_DOWN = 0b ; Link is down
ETH_LINK_UNKNOWN= 1b ; There could be an active link
ETH_LINK_FD = 10b ; full duplex flag
ETH_LINK_10M = 100b ; 10 mbit
ETH_LINK_100M = 1000b ; 100 mbit
ETH_LINK_1G = 1100b ; gigabit
====================================================================== ======================================================================
============== Function 75, Subfunction 0, Open socket. ============== ============== Function 75, Subfunction 0, Open socket. ==============
====================================================================== ======================================================================
@ -4000,10 +4149,11 @@ Returned value:
* ebx = errorcode * ebx = errorcode
Remarks: Remarks:
Optstruct: dd level Optstruct:
dd optionname dd level
dd optlength dd optionname
db options... dd optlength
db options...
====================================================================== ======================================================================
=========== Function 75, Subfunction 9, Get socket options. ========== =========== Function 75, Subfunction 9, Get socket options. ==========
@ -4018,10 +4168,11 @@ Returned value:
* ebx = errorcode * ebx = errorcode
Remarks: Remarks:
Optstruct: dd level Optstruct:
dd optionname dd level
dd optlength dd optionname
db options... dd optlength
db options...
====================================================================== ======================================================================
============ Function 75, Subfunction 10, Get socketpair. =========== ============ Function 75, Subfunction 10, Get socketpair. ===========
@ -4032,6 +4183,53 @@ Parameters:
Returned value: Returned value:
* eax = socketnum1, -1 on error * eax = socketnum1, -1 on error
* ebx = socketnum2, errorcode on error * ebx = socketnum2, errorcode on error
======================================================================
============ Function 76, Network options and statistics. ============
======================================================================
Parameters:
* eax = 76 - function number
* high half of ebx = protocol number
* bh = device number
* bl = subfunction number
Ethernet (0)
0 - Read MAC
IPv4 (1)
0 - Read # IP packets send
1 - Read # IP packets received
2 - Read IP
3 - Write IP
4 - Read DNS
5 - Write DNS
6 - Read subnet
7 - Write subnet
8 - Read gateway
9 - Write gateway
ICMP (2)
0 - Read # ICMP packets send
1 - Read # ICMP packets received
3 - enable/disable ICMP echo reply
UDP (3)
0 - Read # UDP packets send
1 - Read # UDP packets received
TCP (4)
0 - Read # TCP packets send
1 - Read # TCP packets received
ARP (5)
0 - Read # ARP packets send
1 - Read # ARP packets received
2 - Read # ARP entry's
3 - Read ARP entry
4 - Add static ARP entry
5 - Remove ARP entry (-1 = remove all)
6 - Send ARP announce on specified interface
7 - Read # ARP conflicts (IP address conflicts)
====================================================================== ======================================================================
=============== Function -1 - terminate thread/process =============== =============== Function -1 - terminate thread/process ===============

View File

@ -10,37 +10,37 @@ $Revision: 5082 $
; fetch the UTF-8 character in addrspace:offs to char ; fetch the UTF-8 character in addrspace:offs to char
macro fetch_utf8_char addrspace, offs, char macro fetch_utf8_char addrspace, offs, char
{ local first_byte, b { local first_byte, b
; fetch first byte ; fetch first byte
load first_byte byte from addrspace:offs load first_byte byte from addrspace:offs
if first_byte < 0x80 if first_byte < 0x80
char = first_byte char = first_byte
offs = offs + 1 offs = offs + 1
else if first_byte < 0xC0 else if first_byte < 0xC0
err Invalid UTF-8 string err Invalid UTF-8 string
else if first_byte < 0xE0 else if first_byte < 0xE0
char = first_byte and 0x1F char = first_byte and 0x1F
load b byte from addrspace:offs + 1 load b byte from addrspace:offs + 1
char = (char shl 6) + (b and 0x3F) char = (char shl 6) + (b and 0x3F)
offs = offs + 2 offs = offs + 2
else if first_byte < 0xF0 else if first_byte < 0xF0
char = first_byte and 0xF char = first_byte and 0xF
load b byte from addrspace:offs + 1 load b byte from addrspace:offs + 1
char = (char shl 6) + (b and 0x3F) char = (char shl 6) + (b and 0x3F)
load b byte from addrspace:offs + 2 load b byte from addrspace:offs + 2
char = (char shl 6) + (b and 0x3F) char = (char shl 6) + (b and 0x3F)
offs = offs + 3 offs = offs + 3
else if first_byte < 0xF8 else if first_byte < 0xF8
char = first_byte and 0x7 char = first_byte and 0x7
load b byte from addrspace:offs + 1 load b byte from addrspace:offs + 1
char = (char shl 6) + (b and 0x3F) char = (char shl 6) + (b and 0x3F)
load b byte from addrspace:offs + 2 load b byte from addrspace:offs + 2
char = (char shl 6) + (b and 0x3F) char = (char shl 6) + (b and 0x3F)
load b byte from addrspace:offs + 3 load b byte from addrspace:offs + 3
char = (char shl 6) + (b and 0x3F) char = (char shl 6) + (b and 0x3F)
offs = offs + 4 offs = offs + 4
else else
err Invalid UTF-8 string err Invalid UTF-8 string
end if end if
} }
; Worker macro for all encodings. ; Worker macro for all encodings.
@ -59,29 +59,29 @@ macro convert_utf8 encoding, [arg]
end virtual end virtual
while offs < ..addrspace#.size while offs < ..addrspace#.size
fetch_utf8_char ..addrspace, offs, char fetch_utf8_char ..addrspace, offs, char
if char = 0x2500 if char = 0x2500
db 0xC4 db 0xC4
else if char = 0x2502 else if char = 0x2502
db 0xB3 db 0xB3
else if char = 0x250C else if char = 0x250C
db 0xDA db 0xDA
else if char = 0x2510 else if char = 0x2510
db 0xBF db 0xBF
else if char = 0x2514 else if char = 0x2514
db 0xC0 db 0xC0
else if char = 0x2518 else if char = 0x2518
db 0xD9 db 0xD9
else if char = 0x252C else if char = 0x252C
db 0xC2 db 0xC2
else if char = 0x2534 else if char = 0x2534
db 0xC1 db 0xC1
else if char = 0x2551 else if char = 0x2551
db 0xBA db 0xBA
else if char < 0x80 else if char < 0x80
db char db char
else else
encoding char encoding char
end if end if
end while end while
} }
@ -101,16 +101,16 @@ macro declare_encoding encoding
declare_encoding cp866 declare_encoding cp866
{ {
if char = 0x401 if char = 0x401
db 0xF0 db 0xF0
else if char = 0x451 else if char = 0x451
db 0xF1 db 0xF1
else if (char < 0x410) | (char > 0x44F) else if (char < 0x410) | (char > 0x44F)
err Failed to convert to CP866 err Failed to convert to CP866
else if char < 0x440 else if char < 0x440
db char - 0x410 + 0x80 db char - 0x410 + 0x80
else else
db char - 0x440 + 0xE0 db char - 0x440 + 0xE0
end if end if
} }
; Latin-1 encoding ; Latin-1 encoding
@ -118,28 +118,28 @@ declare_encoding cp866
declare_encoding latin1 declare_encoding latin1
{ {
if char < 0x100 if char < 0x100
db char db char
else else
err Failed to convert to Latin-1 err Failed to convert to Latin-1
end if end if
} }
; CP850 encoding ; CP850 encoding
declare_encoding cp850 declare_encoding cp850
{ {
if char = 0xBF if char = 0xBF
db 0xA8 db 0xA8
else if char = 0xE1 else if char = 0xE1
db 0xA0 db 0xA0
else if char = 0xE9 else if char = 0xE9
db 0x82 db 0x82
else if char = 0xED else if char = 0xED
db 0xA1 db 0xA1
else if char = 0xF3 else if char = 0xF3
db 0xA2 db 0xA2
else if char = 0xFA else if char = 0xFA
db 0xA3 db 0xA3
else else
err Failed to convert to CP850 err Failed to convert to CP850
end if end if
} }

View File

@ -1843,6 +1843,9 @@ fat_Read:
shr edi, 9 shr edi, 9
add eax, edi add eax, edi
and edx, 511 and edx, 511
cmp ecx, 512
jc .sectorPiece
test edx, edx
jz .alignedSector jz .alignedSector
.sectorPiece: .sectorPiece:
push eax ebx push eax ebx
@ -1870,8 +1873,6 @@ fat_Read:
test ecx, ecx test ecx, ecx
jz .done jz .done
.alignedSector: .alignedSector:
cmp ecx, 512
jc .sectorPiece
shl edi, 9 shl edi, 9
add ecx, edi add ecx, edi
mov edi, [ebp+FAT.SECTORS_PER_CLUSTER] mov edi, [ebp+FAT.SECTORS_PER_CLUSTER]
@ -1899,15 +1900,19 @@ fat_Read:
dec eax dec eax
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
add eax, [ebp+FAT.DATA_START] add eax, [ebp+FAT.DATA_START]
sub eax, edx
.readFragment:
push ecx push ecx
mov ecx, eax mov ecx, eax
mov eax, esi
dec eax
dec eax
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
add eax, [ebp+FAT.DATA_START]
push eax
.readFragment:
sub ecx, edx
mov eax, edx mov eax, edx
xor edx, edx xor edx, edx
push eax
call fs_read64_app call fs_read64_app
add [esp], ecx
shl ecx, 9 shl ecx, 9
add ebx, ecx add ebx, ecx
test eax, eax test eax, eax
@ -1916,13 +1921,6 @@ fat_Read:
pop ecx pop ecx
xor edx, edx xor edx, edx
jcxz .done jcxz .done
cmp ecx, 512
jc .sectorPiece
mov eax, esi
dec eax
dec eax
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
add eax, [ebp+FAT.DATA_START]
jmp .alignedCluster jmp .alignedCluster
.readEnd: .readEnd:
add ecx, edi add ecx, edi
@ -1933,8 +1931,10 @@ fat_Read:
dec eax dec eax
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
add eax, [ebp+FAT.DATA_START] add eax, [ebp+FAT.DATA_START]
sub eax, edx
add eax, edi add eax, edi
push ecx
push eax
mov ecx, eax
jmp .readFragment jmp .readFragment
.noaccess3: .noaccess3:
pop eax pop eax

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -9,9 +9,9 @@ $Revision$
include 'mousepointer.inc' include 'mousepointer.inc'
;============================================================================== ;================================
;///// public functions /////////////////////////////////////////////////////// ;/////// public functions ///////
;============================================================================== ;================================
mouse.LEFT_BUTTON_FLAG = 0001b mouse.LEFT_BUTTON_FLAG = 0001b
mouse.RIGHT_BUTTON_FLAG = 0010b mouse.RIGHT_BUTTON_FLAG = 0010b
@ -36,14 +36,10 @@ mouse.WINDOW_RESIZE_SE_FLAG = \
mouse.WINDOW_RESIZE_E_FLAG mouse.WINDOW_RESIZE_E_FLAG
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse_check_events: ;////////////////////////////////////////////////////////// mouse_check_events:
;------------------------------------------------------------------------------ ; Check if mouse buttons state or cursor position has changed
;? Check if mouse buttons state or cursor position has changed and call
;? appropriate handlers
;------------------------------------------------------------------------------
push eax ebx push eax ebx
mov al, [BTN_DOWN] mov al, [BTN_DOWN]
mov bl, [mouse.state.buttons] mov bl, [mouse.state.buttons]
and al, mouse.BUTTONS_MASK and al, mouse.BUTTONS_MASK
@ -63,8 +59,8 @@ mouse_check_events: ;//////////////////////////////////////////////////////////
; yes it is, activate window user is pointing at, if needed ; yes it is, activate window user is pointing at, if needed
call mouse._.activate_sys_window_under_cursor call mouse._.activate_sys_window_under_cursor
; NOTE: this code wouldn't be necessary if we knew window did ; NOTE: this code wouldn't be necessary if we knew
; already redraw itself after call above ; that window did already redraw itself after call above
or eax, eax or eax, eax
jnz .exit jnz .exit
@ -162,19 +158,19 @@ mouse_check_events: ;//////////////////////////////////////////////////////////
jnz mouse._.middle_button_press_handler jnz mouse._.middle_button_press_handler
jmp mouse._.middle_button_release_handler jmp mouse._.middle_button_release_handler
;============================================================================== ;===============================
;///// private functions ////////////////////////////////////////////////////// ;////// private functions //////
;============================================================================== ;===============================
uglobal uglobal
mouse.state: mouse.state:
.pos POINT .pos POINT
.buttons db ? .buttons db ?
; NOTE: since there's no unique and lifetime-constant button identifiers, ; NOTE: since there's no unique and lifetime-constant button identifiers,
; we're using two dwords to identify each of them: ; we are using two dwords to identify each of them:
; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack ; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack
; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack ; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack
align 4 align 4
mouse.active_sys_button: mouse.active_sys_button:
.pbid dd ? .pbid dd ?
@ -191,12 +187,25 @@ uglobal
.action db ? .action db ?
endg endg
iglobal
fl_moving db 0
rb 3
endg
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse._.left_button_press_handler: ;/////////////////////////////////////////// mouse._.left_button_press_handler:
;------------------------------------------------------------------------------ ; Called when left mouse button has been pressed down
;? Called when left mouse button has been pressed down bts word [BTN_DOWN], 8
;------------------------------------------------------------------------------ mov eax, [timer_ticks]
mov ebx, eax
xchg ebx, [mouse.active_sys_window.last_ticks]
sub eax, ebx
movzx ebx, [mouse_doubleclick_delay]
cmp eax, ebx
jg @f
bts dword [BTN_DOWN], 24
@@:
test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG
jnz .exit jnz .exit
@ -210,12 +219,8 @@ mouse._.left_button_press_handler: ;///////////////////////////////////////////
test dl, mouse.WINDOW_MOVE_FLAG test dl, mouse.WINDOW_MOVE_FLAG
jz @f jz @f
mov eax, [timer_ticks] bt dword [BTN_DOWN], 24
mov ebx, eax jnc @f
xchg ebx, [mouse.active_sys_window.last_ticks]
sub eax, ebx
cmp eax, 50
jg @f
mov [mouse.active_sys_window.last_ticks], 0 mov [mouse.active_sys_window.last_ticks], 0
call sys_window_maximize_handler call sys_window_maximize_handler
@ -254,9 +259,6 @@ mouse._.left_button_press_handler: ;///////////////////////////////////////////
call .calculate_e_delta call .calculate_e_delta
.call_window_handler: .call_window_handler:
; mov eax, mouse.active_sys_window.old_box
; call sys_window_start_moving_handler
.exit: .exit:
ret ret
@ -287,11 +289,10 @@ mouse._.left_button_press_handler: ;///////////////////////////////////////////
ret ret
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse._.left_button_release_handler: ;///////////////////////////////////////// mouse._.left_button_release_handler:
;------------------------------------------------------------------------------ ; Called when left mouse button has been released
;? Called when left mouse button has been released bts dword [BTN_DOWN], 16
;------------------------------------------------------------------------------
xor esi, esi xor esi, esi
xchg esi, [mouse.active_sys_window.pslot] xchg esi, [mouse.active_sys_window.pslot]
or esi, esi or esi, esi
@ -310,60 +311,38 @@ mouse._.left_button_release_handler: ;/////////////////////////////////////////
.exit: .exit:
and [mouse.active_sys_window.action], 0 and [mouse.active_sys_window.action], 0
mov [fl_moving], 0
ret ret
align 4 mouse._.right_button_press_handler:
;------------------------------------------------------------------------------ bts word [BTN_DOWN], 9
mouse._.right_button_press_handler: ;//////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when right mouse button has been pressed down
;------------------------------------------------------------------------------
test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG
jnz .exit jnz @f
call mouse._.find_sys_window_under_cursor call mouse._.find_sys_window_under_cursor
call mouse._.check_sys_window_actions call mouse._.check_sys_window_actions
test al, mouse.WINDOW_MOVE_FLAG test al, mouse.WINDOW_MOVE_FLAG
jz .exit jz @f
jmp sys_window_rollup_handler
call sys_window_rollup_handler mouse._.right_button_release_handler:
bts dword [BTN_DOWN], 17
@@:
ret
.exit: mouse._.middle_button_press_handler:
bts word [BTN_DOWN], 10
ret
mouse._.middle_button_release_handler:
bts dword [BTN_DOWN], 18
ret ret
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse._.right_button_release_handler: ;//////////////////////////////////////// mouse._.move_handler:
;------------------------------------------------------------------------------ ; Called when cursor has been moved
;? Called when right mouse button has been released
;------------------------------------------------------------------------------
ret
align 4
;------------------------------------------------------------------------------
mouse._.middle_button_press_handler: ;/////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when middle mouse button has been pressed down
;------------------------------------------------------------------------------
ret
align 4
;------------------------------------------------------------------------------
mouse._.middle_button_release_handler: ;///////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when middle mouse button has been released
;------------------------------------------------------------------------------
ret
align 4
;------------------------------------------------------------------------------
mouse._.move_handler: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when cursor has been moved
;------------------------------------------------------------------------------
;> eax = old x coord ;> eax = old x coord
;> ebx = old y coord ;> ebx = old y coord
;------------------------------------------------------------------------------
cmp [mouse.active_sys_button.pbid], 0 cmp [mouse.active_sys_button.pbid], 0
jnz .exit jnz .exit
@ -507,6 +486,19 @@ mouse._.move_handler: ;////////////////////////////////////////////////////////
pop esi pop esi
je .exit je .exit
test [fl_moving], 1
jnz @f
mov [fl_moving], 1
push edi
mov edi, esi
shl edi, 5
add edi, WDATA.box + window_data
call window._.draw_negative_box
pop edi
@@:
mov [mouse.active_sys_window.last_ticks], 0 mov [mouse.active_sys_window.last_ticks], 0
call sys_window_moving_handler call sys_window_moving_handler
@ -514,15 +506,12 @@ mouse._.move_handler: ;////////////////////////////////////////////////////////
ret ret
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// mouse._.find_sys_window_under_cursor:
;------------------------------------------------------------------------------ ; Find system window object which is currently visible on screen
;? Find system window object which is currently visible on screen and has ; and has mouse cursor within its bounds
;? mouse cursor within its bounds
;------------------------------------------------------------------------------
;< esi = process slot ;< esi = process slot
;< edi = pointer to WDATA struct ;< edi = pointer to WDATA struct
;------------------------------------------------------------------------------
mov esi, [mouse.state.pos.y] mov esi, [mouse.state.pos.y]
mov esi, [d_width_calc_area + esi*4] mov esi, [d_width_calc_area + esi*4]
@ -535,27 +524,21 @@ mouse._.find_sys_window_under_cursor: ;////////////////////////////////////////
ret ret
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// mouse._.activate_sys_window_under_cursor:
;------------------------------------------------------------------------------ ; activate and redraw window under cursor (if necessary)
;? <description>
;------------------------------------------------------------------------------
; activate and redraw window under cursor (if necessary)
call mouse._.find_sys_window_under_cursor call mouse._.find_sys_window_under_cursor
movzx esi, word[WIN_STACK + esi * 2] movzx esi, word[WIN_STACK + esi * 2]
lea esi, [WIN_POS + esi * 2] lea esi, [WIN_POS + esi * 2]
jmp waredraw jmp waredraw
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// mouse._.find_sys_button_under_cursor:
;------------------------------------------------------------------------------ ; Find system button object which is currently visible on screen
;? Find system button object which is currently visible on screen and has ; and has mouse cursor within its bounds
;? mouse cursor within its bounds
;------------------------------------------------------------------------------
;< eax = pack[8(process slot), 24(button id)] or 0 ;< eax = pack[8(process slot), 24(button id)] or 0
;< ebx = pack[16(button x coord), 16(button y coord)] ;< ebx = pack[16(button x coord), 16(button y coord)]
;------------------------------------------------------------------------------
push ecx edx esi edi push ecx edx esi edi
call mouse._.find_sys_window_under_cursor call mouse._.find_sys_window_under_cursor
@ -612,13 +595,9 @@ mouse._.find_sys_button_under_cursor: ;////////////////////////////////////////
ret ret
align 4 align 4
;------------------------------------------------------------------------------ ;-----------------------------------------------------------------
mouse._.check_sys_window_actions: ;//////////////////////////////////////////// mouse._.check_sys_window_actions:
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;< eax = action flags or 0 ;< eax = action flags or 0
;------------------------------------------------------------------------------
; is window movable? ; is window movable?
test byte[edi + WDATA.cl_titlebar + 3], 0x01 test byte[edi + WDATA.cl_titlebar + 3], 0x01
jnz .no_action jnz .no_action
@ -638,8 +617,8 @@ mouse._.check_sys_window_actions: ;////////////////////////////////////////////
; no there isn't, can it be resized then? ; no there isn't, can it be resized then?
mov dl, [edi + WDATA.fl_wstyle] mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f and dl, 0x0f
; NOTE: dangerous optimization, revise if window types changed; ; NOTE: dangerous optimization, revise if window types changed
; this currently implies only types 2 and 3 could be resized ; this currently implies only types 2 and 3 could be resized
test dl, 2 test dl, 2
jz .no_action jz .no_action

View File

@ -30,11 +30,8 @@ uglobal
draw_limits RECT draw_limits RECT
endg endg
align 4
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
syscall_draw_window: ;///// system function 0 ///////////////////////////////// syscall_draw_window: ;///// system function 0 /////////////////////////////////
;------------------------------------------------------------------------------
;? <description>.
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
mov eax, edx mov eax, edx
shr eax, 24 shr eax, 24
@ -49,34 +46,28 @@ syscall_draw_window: ;///// system function 0 /////////////////////////////////
or al, al or al, al
jnz @f jnz @f
; type I - original style ; type I - original style
call drawwindow_I call drawwindow_I
jmp window._.draw_window_caption.2 jmp window._.draw_window_caption.2
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
dec al dec al
jnz @f jnz @f
; type II - only reserve area, no draw ; type II - only reserve area, no draw
; call sys_window_mouse
; call [draw_pointer]
call __sys_draw_pointer call __sys_draw_pointer
jmp .exit jmp .exit
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
dec al dec al
jnz @f jnz @f
; type III - new style ; type III - new style
call drawwindow_III call drawwindow_III
jmp window._.draw_window_caption.2 jmp window._.draw_window_caption.2
; type IV & V - skinned window (resizable & not)
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
; type IV & V - skinned window (resizable & not)
mov eax, [TASK_COUNT] mov eax, [TASK_COUNT]
movzx eax, word[WIN_POS + eax * 2] movzx eax, word[WIN_POS + eax * 2]
cmp eax, [CURRENT_TASK] cmp eax, [CURRENT_TASK]
@ -86,12 +77,9 @@ align 4
call drawwindow_IV call drawwindow_IV
jmp window._.draw_window_caption.2 jmp window._.draw_window_caption.2
;-------------------------------------- ;--------------------------------------
align 4
.exit: .exit:
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
;------------------------------------------------------------------------------
syscall_display_settings: ;///// system function 48 /////////////////////////// syscall_display_settings: ;///// system function 48 ///////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;; Redraw screen: ;; Redraw screen:
@ -134,74 +122,73 @@ syscall_display_settings: ;///// system function 48 ///////////////////////////
;< ebx = 8 ;< ebx = 8
;< ecx = pointer to FileInfoBlock struct ;< ecx = pointer to FileInfoBlock struct
;> eax = FS error code ;> eax = FS error code
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Get font smoothing:
;< ebx = 9
;> eax = 0 off, 1 on, 2 subpixel
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Set font smoothing:
;< ebx = 10
;< ecx = 0 off, 1 on, 2 subpixel
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Get font size:
;< ebx = 11
;> eax = height in pixels
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Set font size:
;< ebx = 12
;< ecx = height in pixels
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
cmp ebx, .sizeof.ftable / 4 cmp ebx, .sizeof.ftable / 4
ja @f ja @f
jmp [.ftable + ebx * 4] jmp [.ftable + ebx * 4]
;--------------------------------------
align 4
@@:
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.00: syscall_display_settings.00:
xor eax, eax xor eax, eax
inc ebx inc ebx
cmp [windowtypechanged], ebx cmp [windowtypechanged], ebx
jne .exit jne @f
mov [windowtypechanged], eax mov [windowtypechanged], eax
jmp syscall_display_settings._.redraw_whole_screen jmp syscall_display_settings._.redraw_whole_screen
;--------------------------------------
align 4
.exit:
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.01: syscall_display_settings.01:
and ecx, 1 and ecx, 1
cmp ecx, [buttontype] cmp ecx, [buttontype]
je .exit je @f
mov [buttontype], ecx mov [buttontype], ecx
mov [windowtypechanged], ebx mov [windowtypechanged], ebx
;-------------------------------------- @@:
align 4
.exit:
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.02: syscall_display_settings.02:
dec ebx dec ebx
mov esi, ecx mov esi, ecx
cmp edx, 192 cmp edx, 192
jnae @f jnae @f
mov edx, 192 ; max size mov edx, 192 ; max size
@@: @@:
mov edi, common_colours mov edi, common_colours
mov ecx, edx mov ecx, edx
rep movsb rep movsb
mov [windowtypechanged], ebx mov [windowtypechanged], ebx
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.03: syscall_display_settings.03:
mov edi, ecx mov edi, ecx
cmp edx, 192 cmp edx, 192
jnae @f jnae @f
mov edx, 192 ; max size mov edx, 192 ; max size
@@: @@:
mov esi, common_colours mov esi, common_colours
mov ecx, edx mov ecx, edx
rep movsb rep movsb
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.04: syscall_display_settings.04:
mov eax, [_skinh] mov eax, [_skinh]
mov [esp + 32], eax mov [esp + 32], eax
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.05: syscall_display_settings.05:
mov eax, [screen_workarea.left - 2] mov eax, [screen_workarea.left - 2]
mov ax, word[screen_workarea.right] mov ax, word[screen_workarea.right]
@ -211,10 +198,8 @@ syscall_display_settings.05:
mov [esp + 20], eax mov [esp + 20], eax
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.06: syscall_display_settings.06:
xor esi, esi xor esi, esi
mov edi, [_display.width] mov edi, [_display.width]
dec edi dec edi
mov eax, ecx mov eax, ecx
@ -226,19 +211,13 @@ syscall_display_settings.06:
or eax, eax or eax, eax
jge @f jge @f
xor eax, eax xor eax, eax
;--------------------------------------
align 4
@@: @@:
mov [screen_workarea.left], eax mov [screen_workarea.left], eax
cmp ebx, edi cmp ebx, edi
jle @f jle @f
mov ebx, edi mov ebx, edi
;--------------------------------------
align 4
@@: @@:
mov [screen_workarea.right], ebx mov [screen_workarea.right], ebx
;--------------------------------------
align 4
.check_horizontal: .check_horizontal:
mov edi, [_display.height] mov edi, [_display.height]
dec edi dec edi
@ -251,54 +230,58 @@ align 4
or eax, eax or eax, eax
jge @f jge @f
xor eax, eax xor eax, eax
;--------------------------------------
align 4
@@: @@:
mov [screen_workarea.top], eax mov [screen_workarea.top], eax
cmp ebx, edi cmp ebx, edi
jle @f jle @f
mov ebx, edi mov ebx, edi
;--------------------------------------
align 4
@@: @@:
mov [screen_workarea.bottom], ebx mov [screen_workarea.bottom], ebx
;--------------------------------------
align 4
.check_if_redraw_needed: .check_if_redraw_needed:
or esi, esi or esi, esi
jz .exit jz @f
call repos_windows call repos_windows
jmp syscall_display_settings._.calculate_whole_screen jmp syscall_display_settings._.calculate_whole_screen
;--------------------------------------
align 4
.exit:
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.07: syscall_display_settings.07:
mov eax, [_skinmargins + 0] mov eax, [_skinmargins + 0]
mov [esp + 32], eax mov [esp + 32], eax
mov eax, [_skinmargins + 4] mov eax, [_skinmargins + 4]
mov [esp + 20], eax mov [esp + 20], eax
@@:
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings.08: syscall_display_settings.08:
mov ebx, ecx mov ebx, ecx
call read_skin_file call read_skin_file
mov [esp + 32], eax mov [esp + 32], eax
test eax, eax test eax, eax
jnz .exit jnz @b
call syscall_display_settings._.calculate_whole_screen call syscall_display_settings._.calculate_whole_screen
jmp syscall_display_settings._.redraw_whole_screen jmp syscall_display_settings._.redraw_whole_screen
;-------------------------------------- ;------------------------------------------------------------------------------
align 4 syscall_display_settings.09:
.exit: xor eax, eax
mov al, [fontSmoothing]
mov [esp + 32], eax
ret
;------------------------------------------------------------------------------
syscall_display_settings.10:
mov [fontSmoothing], cl
ret
;------------------------------------------------------------------------------
syscall_display_settings.11:
xor eax, eax
mov al, [fontSize]
mov [esp + 32], eax
ret
;------------------------------------------------------------------------------
syscall_display_settings.12:
mov [fontSize], cl
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings._.calculate_whole_screen: syscall_display_settings._.calculate_whole_screen:
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
@ -308,7 +291,6 @@ syscall_display_settings._.calculate_whole_screen:
dec edx dec edx
jmp calculatescreen jmp calculatescreen
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
syscall_display_settings._.redraw_whole_screen: syscall_display_settings._.redraw_whole_screen:
xor eax, eax xor eax, eax
mov [draw_limits.left], eax mov [draw_limits.left], eax
@ -322,8 +304,6 @@ syscall_display_settings._.redraw_whole_screen:
mov eax, window_data mov eax, window_data
jmp redrawscreen jmp redrawscreen
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
;------------------------------------------------------------------------------
syscall_set_window_shape: ;///// system function 50 /////////////////////////// syscall_set_window_shape: ;///// system function 50 ///////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;; Set window shape address: ;; Set window shape address:
@ -406,58 +386,19 @@ align 4
call window._.set_window_box call window._.set_window_box
add esp, sizeof.BOX add esp, sizeof.BOX
; NOTE: do we really need this? to be reworked
; mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
; mov byte[MOUSE_BACKGROUND], 0 ; no mouse under
; mov byte[MOUSE_DOWN], 0 ; react to mouse up/down
; NOTE: do we really need this? to be reworked
; call [draw_pointer]
;--------------------------------------
align 4
.exit: .exit:
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4 syscall_window_settings: ;///// system function 71 ////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
syscall_window_settings: ;///// system function 71 /////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
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
mov edi, [CURRENT_TASK] mov edi, [CURRENT_TASK]
shl edi, 5 shl edi, 5
mov [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx mov [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx
or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
jmp window._.draw_window_caption
call window._.draw_window_caption
xor eax, eax ; eax = 0 (success)
ret
; .get_window_caption:
; dec eax ; subfunction #2 - get window caption
; jnz .exit_fail
; not implemented yet
;--------------------------------------
align 4
.exit_fail:
xor eax, eax
inc eax ; eax = 1 (fail)
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4 align 4
;------------------------------------------------------------------------------
set_window_defaults: ;///////////////////////////////////////////////////////// set_window_defaults: ;/////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
push eax ecx push eax ecx
@ -477,6 +418,7 @@ align 4
pop ecx eax pop ecx eax
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4 align 4
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
calculatescreen: ;///////////////////////////////////////////////////////////// calculatescreen: ;/////////////////////////////////////////////////////////////
@ -502,12 +444,21 @@ calculatescreen: ;/////////////////////////////////////////////////////////////
cmp ebp, 1 cmp ebp, 1
jbe .exit jbe .exit
push eax ;for num layout
push edx ecx ebx eax push edx ecx ebx eax
mov dword[esp+10h], ZPOS_DESKTOP
;--------------------------------------
align 4
.layout:
mov esi, 1 ; = num in window stack
mov ebp, [TASK_COUNT]
;-------------------------------------- ;--------------------------------------
align 4 align 4
.next_window: .next_window:
movzx edi, word[WIN_POS + esi * 2] movzx edi, word[WIN_POS + esi * 2]
shl edi, 5 shl edi, 5 ;size of TASKDATA and WDATA = 32 bytes
cmp [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE cmp [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
je .skip_window je .skip_window
@ -516,6 +467,10 @@ align 4
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .skip_window jnz .skip_window
mov eax, [esp+10h]
cmp [edi + WDATA.z_modif], al
jne .skip_window
mov eax, [edi + WDATA.box.left] mov eax, [edi + WDATA.box.left]
cmp eax, [esp + RECT.right] cmp eax, [esp + RECT.right]
jg .skip_window jg .skip_window
@ -565,8 +520,18 @@ align 4
inc esi inc esi
dec ebp dec ebp
jnz .next_window jnz .next_window
;---------------------------------------------
inc dword[esp+10h]
cmp dword[esp+10h], ZPOS_ALWAYS_TOP
jle .layout
;---------------------------------------------
mov esi, [TASK_COUNT]
movzx edi, word[WIN_POS + esi * 2]
shl edi, 5
add edi, window_data
pop eax ebx ecx edx pop eax ebx ecx edx
pop ebp ;del num layout
;-------------------------------------- ;--------------------------------------
align 4 align 4
.exit: .exit:
@ -1019,6 +984,9 @@ waredraw: ;////////////////////////////////////////////////////////////////////
mov edi, [TASK_COUNT] mov edi, [TASK_COUNT]
movzx esi, word[WIN_POS + edi * 2] movzx esi, word[WIN_POS + edi * 2]
call window._.set_screen call window._.set_screen
call window._.set_top_wnd
inc [_display.mask_seqno] inc [_display.mask_seqno]
popad popad
@ -1188,6 +1156,11 @@ align 4
add ecx, eax add ecx, eax
add edx, ebx add edx, ebx
call ebp call ebp
cmp ebp, window._.set_screen
jne @f
call window._.set_top_wnd
@@:
inc [_display.mask_seqno] inc [_display.mask_seqno]
;-------------------------------------- ;--------------------------------------
align 4 align 4
@ -1374,6 +1347,15 @@ sys_window_end_moving_handler: ;///////////////////////////////////////////////
shl edi, 5 shl edi, 5
add edi, window_data add edi, window_data
test [fl_moving], 1
jz @f
push edi
mov edi, ebx
call window._.draw_negative_box
pop edi
@@:
mov eax, ebx mov eax, ebx
mov bl, [edi + WDATA.fl_wstate] mov bl, [edi + WDATA.fl_wstate]
call window._.set_window_box call window._.set_window_box
@ -1400,7 +1382,7 @@ sys_window_moving_handler: ;///////////////////////////////////////////////////
iglobal iglobal
FuncTable syscall_display_settings, ftable, \ FuncTable syscall_display_settings, ftable, \
00, 01, 02, 03, 04, 05, 06, 07, 08 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12
align 4 align 4
window_topleft dd \ window_topleft dd \
@ -1511,7 +1493,6 @@ end if
call memmove call memmove
mov eax, ebx mov eax, ebx
mov ebx, esi mov ebx, esi
call window._.check_window_position call window._.check_window_position
call window._.set_window_clientbox call window._.set_window_clientbox
call window._.invalidate_screen call window._.invalidate_screen
@ -1618,30 +1599,21 @@ window._.sys_set_window: ;/////////////////////////////////////////////////////
mov eax, [CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 5 shl eax, 5
add eax, window_data add eax, window_data
; save window colors
; save window colors
mov [eax + WDATA.cl_workarea], edx mov [eax + WDATA.cl_workarea], edx
mov [eax + WDATA.cl_titlebar], esi mov [eax + WDATA.cl_titlebar], esi
mov [eax + WDATA.cl_frames], edi mov [eax + WDATA.cl_frames], edi
mov edi, eax mov edi, eax
; Was it already defined before?
; was it already defined before?
test [edi + WDATA.fl_wdrawn], 1 test [edi + WDATA.fl_wdrawn], 1
jnz .set_client_box jnz .set_client_box
or [edi + WDATA.fl_wdrawn], 1 ; No, it wasn't. After first draw_window we need redraw mouse necessarily!
; After first draw_window we need redraw mouse necessarily!
; Otherwise the user can see cursor specified by f.37.5 from another window. ; Otherwise the user can see cursor specified by f.37.5 from another window.
; He will be really unhappy! He is terrible in rage - usually he throws stones! ; He will be really unhappy! Usually, he will be enraged!
or [edi + WDATA.fl_wdrawn], 1
mov [redrawmouse_unconditional], 1 mov [redrawmouse_unconditional], 1
call wakeup_osloop call wakeup_osloop
; NOTE: commented out since doesn't provide necessary functionality ; performing initial window definition
; anyway, to be reworked
; mov eax, [timer_ticks] ; [0xfdf0]
; add eax, 100
; mov [new_window_starting], eax
; no it wasn't, performing initial window definition
movzx eax, bx movzx eax, bx
mov [edi + WDATA.box.width], eax mov [edi + WDATA.box.width], eax
movzx eax, cx movzx eax, cx
@ -2296,6 +2268,8 @@ align 4
or edx, edx or edx, edx
jz .exit jz .exit
mov ebp, [edi + window_data + WDATA.box.left - 2]
mov bp, word[edi + window_data + WDATA.box.top]
movzx eax, [edi + window_data + WDATA.fl_wstyle] movzx eax, [edi + window_data + WDATA.fl_wstyle]
and al, 0x0F and al, 0x0F
cmp al, 3 cmp al, 3
@ -2307,66 +2281,46 @@ align 4
;-------------------------------------- ;--------------------------------------
align 4 align 4
.skinned: .skinned:
mov ebp, [edi + window_data + WDATA.box.left - 2]
mov bp, word[edi + window_data + WDATA.box.top]
movzx eax, word[edi + window_data + WDATA.box.width] movzx eax, word[edi + window_data + WDATA.box.width]
sub ax, [_skinmargins.left] sub ax, [_skinmargins.left]
sub ax, [_skinmargins.right] sub ax, [_skinmargins.right]
push edx
cwde
cdq
mov ebx, 6
idiv ebx
pop edx
or eax, eax
js .exit js .exit
mov esi, eax
mov ebx, dword[_skinmargins.left - 2] mov ebx, dword[_skinmargins.left - 2]
mov bx, word[_skinh] mov bx, word[_skinh]
sub bx, [_skinmargins.bottom] sub bx, [_skinmargins.bottom]
sub bx, [_skinmargins.top] sub bx, [_skinmargins.top]
sar bx, 1 sar bx, 1
adc bx, 0
add bx, [_skinmargins.top] add bx, [_skinmargins.top]
add bx, -3 sub bx, 8
add ebx, ebp
jmp .dodraw jmp .dodraw
;-------------------------------------- ;--------------------------------------
align 4 align 4
.not_skinned: .not_skinned:
cmp al, 1 cmp al, 1
je .exit je .exit
mov ebp, [edi + window_data + WDATA.box.left - 2]
mov bp, word[edi + window_data + WDATA.box.top]
movzx eax, word[edi + window_data + WDATA.box.width] movzx eax, word[edi + window_data + WDATA.box.width]
sub eax, 16 sub eax, 16
push edx
cwde
cdq
mov ebx, 6
idiv ebx
pop edx
or eax, eax
js .exit js .exit
mov ebx, 80002h
mov esi, eax
mov ebx, 0x00080007
add ebx, ebp
;--------------------------------------
align 4
.dodraw: .dodraw:
shr eax, 3
mov esi, eax
add ebx, ebp
mov ecx, [common_colours + 16] mov ecx, [common_colours + 16]
or ecx, 0x80000000 mov al, 1
cmp byte [edx], 4
jnc @f
mov al, [edx]
test al, al
jz .exit
inc edx
@@:
shl eax, 28
or ecx, eax
xor edi, edi xor edi, edi
call dtext_asciiz_esi call dtext
;--------------------------------------
align 4
.exit: .exit:
; call [draw_pointer] jmp __sys_draw_pointer
call __sys_draw_pointer
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4 align 4
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -2426,3 +2380,153 @@ window._.get_rect: ;/////////////////////////////////////////////////////
mov [ecx+RECT.bottom], edx mov [ecx+RECT.bottom], edx
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
;------------------------------------------------------------------------------
window._.redraw_top_wnd: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? redraw all windows one above the window
;------------------------------------------------------------------------------
;> eax = left
;> ebx = top
;> ecx = right
;> edx = bottom
;> esi = process number
;! corrupted edi
;------------------------------------------------------------------------------
push 0
jmp window._.set_top_wnd.go
align 4
;------------------------------------------------------------------------------
window._.set_top_wnd: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? call set_screen for all windows one above the window
;------------------------------------------------------------------------------
;> eax = left
;> ebx = top
;> ecx = right
;> edx = bottom
;> esi = process number
;! corrupted edi
;------------------------------------------------------------------------------
push 1
.go:
push esi
pushfd
cli
push ebp
mov ebp, [TASK_COUNT]
cmp ebp, 1
jbe .exit
shl esi, 5
cmp [esi + window_data + WDATA.z_modif], ZPOS_ALWAYS_TOP
je .exit
push eax ;for num layout
push edx ecx ebx eax
movsx eax, byte [esi + window_data + WDATA.z_modif]
inc eax
mov dword[esp+10h], eax
;--------------------------------------
align 4
.layout:
mov esi, 1 ; = num in window stack
mov ebp, [TASK_COUNT]
;--------------------------------------
align 4
.next_window:
movzx edi, word[WIN_POS + esi * 2]
shl edi, 5 ;size of TASKDATA and WDATA = 32 bytes
cmp [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
je .skip_window
add edi, window_data
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .skip_window
mov eax, [esp+10h]
cmp [edi + WDATA.z_modif], al
jne .skip_window
mov eax, [edi + WDATA.box.left]
cmp eax, [esp + RECT.right]
jg .skip_window
mov ebx, [edi + WDATA.box.top]
cmp ebx, [esp + RECT.bottom]
jg .skip_window
mov ecx, [edi + WDATA.box.width]
add ecx, eax
cmp ecx, [esp + RECT.left]
jl .skip_window
mov edx, [edi + WDATA.box.height]
add edx, ebx
cmp edx, [esp + RECT.top]
jl .skip_window
cmp eax, [esp + RECT.left]
jae @f
mov eax, [esp + RECT.left]
;--------------------------------------
align 4
@@:
cmp ebx, [esp + RECT.top]
jae @f
mov ebx, [esp + RECT.top]
;--------------------------------------
align 4
@@:
cmp ecx, [esp + RECT.right]
jbe @f
mov ecx, [esp + RECT.right]
;--------------------------------------
align 4
@@:
cmp edx, [esp + RECT.bottom]
jbe @f
mov edx, [esp + RECT.bottom]
;--------------------------------------
align 4
@@:
cmp dword[esp+32], 0
je .set_fl_redraw
push esi
movzx esi, word[WIN_POS + esi * 2]
call window._.set_screen
pop esi
jmp @f
.set_fl_redraw:
mov [edi + WDATA.fl_redraw], 1 ;set redraw flag
@@:
;--------------------------------------
align 4
.skip_window:
inc esi
dec ebp
jnz .next_window
;--------------------------------------
inc dword[esp+10h]
cmp byte[esp+10h], ZPOS_ALWAYS_TOP
jle .layout
;-------------------------------------
pop eax ebx ecx edx
pop ebp ;del num layout
;-------------------------------------
align 4
.exit:
pop ebp
popfd
pop esi
add esp, 4 ;dword for 0/1 - set_screen/fl_redraw
ret

View File

@ -25,6 +25,8 @@ VKEY_CONTROL = 0000000000001100b
VKEY_ALT = 0000000000110000b VKEY_ALT = 0000000000110000b
uglobal uglobal
align 4
kb_state dd 0
ext_code db 0 ext_code db 0
keyboard_mode db 0 keyboard_mode db 0
@ -33,6 +35,7 @@ uglobal
altmouseb db 0 altmouseb db 0
ctrl_alt_del db 0 ctrl_alt_del db 0
kb_lights db 0
old_kb_lights db 0 old_kb_lights db 0
align 4 align 4
@ -42,13 +45,6 @@ align 4
endg endg
iglobal iglobal
kb_lights db 2
align 4
kb_state dd VKEY_NUMLOCK
endg
iglobal
align 4
hotkey_tests dd hotkey_test0 hotkey_tests dd hotkey_test0
dd hotkey_test1 dd hotkey_test1
dd hotkey_test2 dd hotkey_test2

View File

@ -35,10 +35,9 @@ endg
iglobal iglobal
;-------------------------------------- ;--------------------------------------
align 4 align 4
mouse_delay dd 10 mouse_speed_factor dw 1
mouse_speed_factor: mouse_delay db 1
dd 3 mouse_doubleclick_delay db 64
mouse_timer_ticks dd 0
endg endg
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -490,11 +489,12 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
mov eax, [XMoving] mov eax, [XMoving]
test [BtnState], 0x80000000 test [BtnState], 0x80000000
jnz .absolute_x jnz .absolute_x
test eax, eax
jz @f
call mouse_acceleration call mouse_acceleration
add ax, [MOUSE_X] add ax, [MOUSE_X]
cmp ax, 0 jns .check_x
jge .check_x xor eax, eax
mov eax, 0
jmp .set_x jmp .set_x
.absolute_x: .absolute_x:
mov edx, [_display.width] mov edx, [_display.width]
@ -508,15 +508,17 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
.set_x: .set_x:
mov [MOUSE_X], ax mov [MOUSE_X], ax
;-------------------------------------- ;--------------------------------------
@@:
mov eax, [YMoving] mov eax, [YMoving]
test [BtnState], 0x40000000 test [BtnState], 0x40000000
jnz .absolute_y jnz .absolute_y
test eax, eax
jz @f
neg eax neg eax
call mouse_acceleration call mouse_acceleration
add ax, [MOUSE_Y] add ax, [MOUSE_Y]
cmp ax, 0 jns .check_y
jge .check_y xor eax, eax
mov ax, 0
jmp .set_y jmp .set_y
.absolute_y: .absolute_y:
mov edx, [_display.height] mov edx, [_display.height]
@ -530,31 +532,54 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
.set_y: .set_y:
mov [MOUSE_Y], ax mov [MOUSE_Y], ax
;-------------------------------------- ;--------------------------------------
@@:
mov eax, [VScroll] mov eax, [VScroll]
test eax, eax
jz @f
add [MOUSE_SCROLL_V], ax add [MOUSE_SCROLL_V], ax
bts word [BTN_DOWN], 15
@@:
mov eax, [HScroll] mov eax, [HScroll]
test eax, eax
jz @f
add [MOUSE_SCROLL_H], ax add [MOUSE_SCROLL_H], ax
bts dword [BTN_DOWN], 23
@@:
mov [mouse_active], 1 mov [mouse_active], 1
mov eax, [timer_ticks]
mov [mouse_timer_ticks], eax
call wakeup_osloop call wakeup_osloop
ret ret
endp endp
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; 3 = x^2 /2
; 2 = (x+1)^2 /4
; 1 = (x+2)^2 /8
align 4 align 4
mouse_acceleration: mouse_acceleration:
cmp [mouse_delay], 0
jz .end
push eax push eax
mov eax, [timer_ticks] @@:
sub eax, [mouse_timer_ticks] neg eax
cmp eax, [mouse_delay] jl @b
pop eax cmp [mouse_delay], 3
ja @f adc eax, 0
;push edx cmp [mouse_delay], 2
imul eax, [mouse_speed_factor] adc eax, 0
;pop edx mul al
@@: shr eax, 1
adc eax, 0
cmp [mouse_delay], 2
jz .2
jnc .3
shr eax, 1
.2:
shr eax, 1
.3:
pop edx
test edx, edx
jns .end
neg eax
.end:
imul [mouse_speed_factor]
ret ret

View File

@ -439,7 +439,7 @@ acpi_hpet_base rd 1
hpet_base rd 1 hpet_base rd 1
hpet_period rd 1 hpet_period rd 1
hpet_timers rd 1 hpet_timers rd 1
hpet_tsc_start rd 2
cpu_count rd 1 cpu_count rd 1
smpt rd 16 smpt rd 16
endg endg
@ -599,39 +599,62 @@ check_acpi:
mov [acpi_ioapic_base-OS_BASE], eax mov [acpi_ioapic_base-OS_BASE], eax
jmp .next jmp .next
HPET_PERIOD equ 0x004 HPET_PERIOD equ 0x0004
HPET_CFG_ENABLE equ 1 HPET_CFG_ENABLE equ 0x0001
HPET_CFG equ 0x010 HPET_CFG equ 0x0010
HPET_COUNTER equ 0x00f0
HPET_T0_CFG equ 0x0100
HPET_TN_LEVEL equ 0x0002
HPET_TN_ENABLE equ 0x0004
HPET_TN_FSB equ 0x4000
align 4 align 4
init_hpet: init_hpet:
mov ebx, [hpet_base-OS_BASE] mov ebx, [hpet_base-OS_BASE]
test ebx, ebx test ebx, ebx
jz @F jz .done
mov eax, [ebx] mov eax, [ebx]
and ah, 0x1F and ah, 0x1F
inc ah inc ah
movzx eax, ah movzx eax, ah
mov [hpet_timers-OS_BASE], eax mov [hpet_timers-OS_BASE], eax
mov ecx, eax
mov eax, [ebx+HPET_PERIOD] mov eax, [ebx+HPET_PERIOD]
mov edx, 0x431BDE83 xor edx, edx
mul edx shld edx, eax, 10
shr edx, 18 shl eax, 10
mov [hpet_period-OS_BASE], edx mov esi, 1000000
div esi
mov [hpet_period-OS_BASE], eax
mov eax, [ebx+HPET_CFG] mov esi, [ebx+HPET_CFG]
and eax, not HPET_CFG_ENABLE and esi, not HPET_CFG_ENABLE
mov [ebx+HPET_CFG], eax ;stop main counter mov [ebx+HPET_CFG], esi ;stop main counter
xor ecx, ecx lea edx, [ebx+HPET_T0_CFG]
mov [ebx+0xF0], ecx ;reset counter
mov [ebx+0xF4], ecx
or eax, HPET_CFG_ENABLE
mov [ebx+HPET_CFG], eax ;and start again
@@: @@:
jcxz @F
mov eax, [edx]
and eax, not (HPET_TN_ENABLE+HPET_TN_LEVEL+HPET_TN_FSB)
mov [edx], eax
add edx, 0x20
dec ecx
jmp @B
@@:
mov [ebx+HPET_COUNTER], ecx ;reset main counter
mov [ebx+HPET_COUNTER+4], ecx
or esi, HPET_CFG_ENABLE
mov [ebx+HPET_CFG], esi ;and start again
.done:
rdtsc
mov [hpet_tsc_start-OS_BASE], eax
mov [hpet_tsc_start+4-OS_BASE], edx
ret ret

View File

@ -701,19 +701,11 @@ setvideomode:
mov eax, [hpet_base] mov eax, [hpet_base]
test eax, eax test eax, eax
jz @F jz @F
DEBUGF 1, "K : HPET base %x\n", eax
mov eax, [hpet_period]
DEBUGF 1, "K : HPET period %d\n", eax
mov eax, [hpet_timers]
DEBUGF 1, "K : HPET timers %d\n", eax
mov eax, [hpet_base] mov eax, [hpet_base]
stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR
mov [hpet_base], eax mov [hpet_base], eax
mov eax, [eax] mov eax, [eax]
DEBUGF 1, "K : HPET caps %x\n", eax DEBUGF 1, "K : HPET caps %x\n", eax
@@: @@:
; SET UP OS TASK ; SET UP OS TASK
@ -1041,7 +1033,31 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
mov esi, boot_cpufreq mov esi, boot_cpufreq
call boot_log call boot_log
cli ;FIXME check IF cli
mov ebx, [hpet_base]
test ebx, ebx
jz @F
mov ebx, [ebx+0xF0]
rdtsc
mov ecx, 1000
sub eax, [hpet_tsc_start]
sbb edx, [hpet_tsc_start+4]
shld edx, eax, 10
shl eax, 10
mov esi, eax
mov eax, edx
mul ecx
xchg eax, esi
mul ecx
adc edx, esi
div ebx
mul ecx
div [hpet_period]
mul ecx
DEBUGF 1, "K : cpu frequency %u Hz\n", eax
jmp .next
@@:
rdtsc rdtsc
mov ecx, eax mov ecx, eax
mov esi, 250 ; wait 1/4 a second mov esi, 250 ; wait 1/4 a second
@ -1053,6 +1069,7 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
xor edx, edx xor edx, edx
shld edx, eax, 2 shld edx, eax, 2
shl eax, 2 shl eax, 2
.next:
mov dword [cpu_freq], eax mov dword [cpu_freq], eax
mov dword [cpu_freq+4], edx mov dword [cpu_freq+4], edx
mov ebx, 1000000 mov ebx, 1000000
@ -1103,7 +1120,7 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
call load_default_skin call load_default_skin
;protect io permission map ; Protect I/O permission map
mov esi, [default_io_map] mov esi, [default_io_map]
stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ
@ -1905,8 +1922,18 @@ sys_getsetup:
ret ret
;-------------------------------------- ;--------------------------------------
@@: @@:
; F.26.10 - get the time from kernel launch in nanoseconds
sub ebx, 1
jnz @f
call get_clock_ns
mov [esp+24], edx
mov [esp+32], eax
ret
;--------------------------------------
@@:
; F.26.11 - Find out whether low-level HD access is enabled ; F.26.11 - Find out whether low-level HD access is enabled
sub ebx, 2 sub ebx, 1
jnz @f jnz @f
mov eax, [lba_read_enabled] mov eax, [lba_read_enabled]
@ -1932,7 +1959,10 @@ get_timer_ticks:
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
iglobal iglobal
align 4 align 4
mousefn dd msscreen, mswin, msbutton, msset mousefn dd msscreen
dd mswin
dd msbutton
dd msbuttonExt
dd app_load_cursor dd app_load_cursor
dd app_set_cursor dd app_set_cursor
dd app_delete_cursor dd app_delete_cursor
@ -1944,21 +1974,24 @@ readmousepos:
; eax=0 screen relative ; eax=0 screen relative
; eax=1 window relative ; eax=1 window relative
; eax=2 buttons pressed ; eax=2 buttons pressed
; eax=3 set mouse pos ; reserved ; eax=3 buttons pressed ext
; eax=4 load cursor ; eax=4 load cursor
; eax=5 set cursor ; eax=5 set cursor
; eax=6 delete cursor ; reserved ; eax=6 delete cursor
; eax=7 get mouse_z ; eax=7 get mouse_z
cmp ebx, 7 cmp ebx, 7
ja msset ja @f
jmp [mousefn+ebx*4] jmp [mousefn+ebx*4]
msscreen: msscreen:
mov eax, [MOUSE_X] mov eax, [MOUSE_X]
shl eax, 16 shl eax, 16
mov ax, [MOUSE_Y] mov ax, [MOUSE_Y]
mov [esp+36-4], eax mov [esp+36-4], eax
@@:
ret ret
mswin: mswin:
mov eax, [MOUSE_X] mov eax, [MOUSE_X]
shl eax, 16 shl eax, 16
@ -1968,7 +2001,6 @@ mswin:
shl ebx, 16 shl ebx, 16
mov bx, word [esi-twdw+WDATA.box.top] mov bx, word [esi-twdw+WDATA.box.top]
sub eax, ebx sub eax, ebx
mov edi, [CURRENT_TASK] mov edi, [CURRENT_TASK]
shl edi, 8 shl edi, 8
sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
@ -1977,10 +2009,35 @@ mswin:
rol eax, 16 rol eax, 16
mov [esp+36-4], eax mov [esp+36-4], eax
ret ret
msbutton: msbutton:
movzx eax, byte [BTN_DOWN] movzx eax, byte [BTN_DOWN]
mov [esp+36-4], eax mov [esp+36-4], eax
ret ret
msbuttonExt:
mov eax, [BTN_DOWN]
mov [esp+36-4], eax
ret
app_load_cursor:
cmp ecx, OS_BASE
jae @f
stdcall load_cursor, ecx, edx
mov [esp+36-4], eax
@@:
ret
app_set_cursor:
stdcall set_cursor, ecx
mov [esp+36-4], eax
ret
app_delete_cursor:
stdcall delete_cursor, ecx
mov [esp+36-4], eax
ret
msz: msz:
mov edi, [TASK_COUNT] mov edi, [TASK_COUNT]
movzx edi, word [WIN_POS + edi*2] movzx edi, word [WIN_POS + edi*2]
@ -1993,27 +2050,8 @@ msz:
and [MOUSE_SCROLL_H], word 0 and [MOUSE_SCROLL_H], word 0
and [MOUSE_SCROLL_V], word 0 and [MOUSE_SCROLL_V], word 0
ret ret
@@: @@:
and [esp+36-4], dword 0 and [esp+36-4], dword 0
; ret
msset:
ret
app_load_cursor:
cmp ecx, OS_BASE
jae msset
stdcall load_cursor, ecx, edx
mov [esp+36-4], eax
ret
app_set_cursor:
stdcall set_cursor, ecx
mov [esp+36-4], eax
ret
app_delete_cursor:
stdcall delete_cursor, ecx
mov [esp+36-4], eax
ret ret
is_input: is_input:
@ -2204,6 +2242,8 @@ sys_system_table:
dd sysfn_min_rest_window ; 22 = minimize and restore any window dd sysfn_min_rest_window ; 22 = minimize and restore any window
dd sysfn_min_windows ; 23 = minimize all windows dd sysfn_min_windows ; 23 = minimize all windows
dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa
dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer
sysfn_num = ($ - sys_system_table)/4 sysfn_num = ($ - sys_system_table)/4
endg endg
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -2363,6 +2403,72 @@ sysfn_activate: ; 18.3 = ACTIVATE WINDOW
.nowindowactivate: .nowindowactivate:
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4
sysfn_zmodif:
;18,25,1 - get z_modif
;18,25,2 - set z_modif
;edx = -1(for current task) or TID
;esi(for 2) = new value z_modif
;return:
;1: eax = z_modif
;2: eax=0(fail),1(success) for set z_modif
cmp edx, -1
jne @f
mov edx, [CURRENT_TASK]
@@:
cmp edx, [TASK_COUNT]
ja .fail
cmp edx, 1
je .fail
mov eax, edx
shl edx, 5
cmp [edx + CURRENT_TASK + TASKDATA.state], 9
je .fail
cmp ecx, 1
jnz .set_zmod
mov al, [edx + window_data + WDATA.z_modif]
jmp .exit
.set_zmod:
cmp ecx, 2
jnz .fail
mov ebx, esi
mov esi, eax
cmp bl, ZPOS_ALWAYS_TOP
jg .fail
mov [edx + window_data + WDATA.z_modif], bl
mov eax, [edx + window_data + WDATA.box.left]
mov ebx, [edx + window_data + WDATA.box.top]
mov ecx, [edx + window_data + WDATA.box.width]
mov edx, [edx + window_data + WDATA.box.height]
add ecx, eax
add edx, ebx
call window._.set_screen
call window._.set_top_wnd
call window._.redraw_top_wnd
shl esi, 5
mov [esi + window_data + WDATA.fl_redraw], 1
mov eax, 1
jmp .exit
.fail:
xor eax, eax
.exit:
mov [esp+32], eax
ret
;------------------------------------------------------------------------------
sysfn_getidletime: ; 18.4 = GET IDLETIME sysfn_getidletime: ; 18.4 = GET IDLETIME
mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage]
mov [esp+32], eax mov [esp+32], eax
@ -2446,11 +2552,6 @@ sysfn_waitretrace: ; 18.14 = sys wait retrace
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4 align 4
sysfn_centermouse: ; 18.15 = mouse centered sysfn_centermouse: ; 18.15 = mouse centered
; removed here by <Lrz>
; call mouse_centered
;* mouse centered - start code- Mario79
;mouse_centered:
; push eax
mov eax, [_display.width] mov eax, [_display.width]
shr eax, 1 shr eax, 1
mov [MOUSE_X], ax mov [MOUSE_X], ax
@ -2458,62 +2559,62 @@ sysfn_centermouse: ; 18.15 = mouse centered
shr eax, 1 shr eax, 1
mov [MOUSE_Y], ax mov [MOUSE_Y], ax
call wakeup_osloop call wakeup_osloop
; ret
;* mouse centered - end code- Mario79
xor eax, eax xor eax, eax
and [esp+32], eax and [esp+32], eax
; pop eax
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
align 4 sysfn_mouse_acceleration: ; 18.19 = set/get mouse features
sysfn_mouse_acceleration: ; 18.19 = set/get mouse features cmp ecx, 8
test ecx, ecx; get mouse speed factor jnc @f
jnz .set_mouse_acceleration jmp dword [.table+ecx*4]
.get_mouse_acceleration:
xor eax, eax xor eax, eax
mov ax, [mouse_speed_factor] mov ax, [mouse_speed_factor]
mov [esp+32], eax mov [esp+32], eax
ret ret
.set_mouse_acceleration: .set_mouse_acceleration:
; cmp ecx,1 ; set mouse speed factor
dec ecx
jnz .get_mouse_delay
mov [mouse_speed_factor], dx mov [mouse_speed_factor], dx
ret ret
.get_mouse_delay: .get_mouse_delay:
; cmp ecx,2 ; get mouse delay xor eax, eax
dec ecx mov al, [mouse_delay]
jnz .set_mouse_delay
mov eax, [mouse_delay]
mov [esp+32], eax mov [esp+32], eax
ret ret
.set_mouse_delay: .set_mouse_delay:
; cmp ecx,3 ; set mouse delay mov [mouse_delay], dl
dec ecx @@:
jnz .set_pointer_position
mov [mouse_delay], edx
ret ret
.set_pointer_position: .set_pointer_position:
; cmp ecx,4 ; set mouse pointer position
dec ecx
jnz .set_mouse_button
cmp dx, word[_display.height] cmp dx, word[_display.height]
jae .end jae @b
rol edx, 16 rol edx, 16
cmp dx, word[_display.width] cmp dx, word[_display.width]
jae .end jae @b
mov [MOUSE_X], edx mov [MOUSE_X], edx
mov [mouse_active], 1 mov [mouse_active], 1
call wakeup_osloop jmp wakeup_osloop
ret .set_mouse_button:
.set_mouse_button: mov [BTN_DOWN], edx
; cmp ecx,5 ; set mouse button features
dec ecx
jnz .end
mov [BTN_DOWN], dl
mov [mouse_active], 1 mov [mouse_active], 1
call wakeup_osloop jmp wakeup_osloop
.end: .get_doubleclick_delay:
xor eax, eax
mov al, [mouse_doubleclick_delay]
mov [esp+32], eax
ret ret
.set_doubleclick_delay:
mov [mouse_doubleclick_delay], dl
ret
align 4
.table:
dd .get_mouse_acceleration
dd .set_mouse_acceleration
dd .get_mouse_delay
dd .set_mouse_delay
dd .set_pointer_position
dd .set_mouse_button
dd .get_doubleclick_delay
dd .set_doubleclick_delay
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
sysfn_getfreemem: sysfn_getfreemem:
mov eax, [pg_data.pages_free] mov eax, [pg_data.pages_free]
@ -3740,6 +3841,14 @@ newdw2:
cmp ecx, 1 ; limit for background cmp ecx, 1 ; limit for background
jz bgli jz bgli
mov eax, [esp+4] ;if upper in z-position - no redraw
test eax, eax
jz @f
mov al, [eax + WDATA.z_modif]
cmp [edi + WDATA.z_modif], al
jg ricino
@@:
mov eax, [edi + WDATA.box.left] mov eax, [edi + WDATA.box.left]
mov ebx, [edi + WDATA.box.top] mov ebx, [edi + WDATA.box.top]

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;; KERNEL32.INC ;; ;; KERNEL32.INC ;;
;; ;; ;; ;;
;; Included 32 bit kernel files for KolibriOS ;; ;; Included 32 bit kernel files for MenuetOS ;;
;; ;; ;; ;;
;; This file is kept separate as it will be easier to ;; ;; This file is kept separate as it will be easier to ;;
;; maintain and compile with an automated SETUP program ;; ;; maintain and compile with an automated SETUP program ;;

View File

@ -16,7 +16,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5584 $ $Revision: 5842 $
IPv4_MAX_FRAGMENTS = 64 IPv4_MAX_FRAGMENTS = 64
IPv4_MAX_ROUTES = 64 IPv4_MAX_ROUTES = 64
@ -215,7 +215,6 @@ macro IPv4_checksum ptr {
; It will also re-construct fragmented packets ; It will also re-construct fragmented packets
; ;
; IN: Pointer to buffer in [esp] ; IN: Pointer to buffer in [esp]
; size of buffer in [esp+4]
; pointer to device struct in ebx ; pointer to device struct in ebx
; pointer to IPv4 header in edx ; pointer to IPv4 header in edx
; size of IPv4 packet in ecx ; size of IPv4 packet in ecx
@ -223,7 +222,7 @@ macro IPv4_checksum ptr {
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
IPv4_input: ; TODO: add IPv4 raw sockets support IPv4_input:
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\ DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\
[edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\ [edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
@ -232,6 +231,10 @@ IPv4_input: ; TODO: add IPv4
[edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\ [edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
[edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1 [edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
call NET_ptr_to_num4
cmp edi, -1
je .invalid_device
;------------------------------- ;-------------------------------
; re-calculate the checksum ; re-calculate the checksum
@ -240,40 +243,32 @@ IPv4_input: ; TODO: add IPv4
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Checksum ok\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Checksum ok\n"
;----------------------------------- ;--------------------------------
; Check if destination IP is correct ; Check if destination IP matches
call NET_ptr_to_num4
; check if it matches local ip (Using RFC1122 strong end system model)
; local ip (Using RFC1122 strong end system model)
mov eax, [edx + IPv4_header.DestinationAddress] mov eax, [edx + IPv4_header.DestinationAddress]
cmp eax, [IP_LIST + edi] cmp eax, [IP_LIST + edi]
je .ip_ok je .ip_ok
; check for broadcast (IP or (not SUBNET)) ; network layer broadcast
cmp eax, [BROADCAST_LIST + edi] cmp eax, [BROADCAST_LIST + edi]
je .ip_ok je .ip_ok
; or a special broadcast (255.255.255.255) ; physical layer broadcast (255.255.255.255)
cmp eax, 0xffffffff cmp eax, 0xffffffff
je .ip_ok je .ip_ok
; maybe it's a multicast (224.0.0.0/4) ; multicast (224.0.0.0/4 = 224.0.0.0 to 239.255.255.255)
and eax, 0x0fffffff and eax, 0x0fffffff
cmp eax, 224 cmp eax, 224
je .ip_ok je .ip_ok
; maybe we just dont have an IP yet and should accept everything on the IP level ; maybe we just dont have an IP yet and should accept everything on the IP level
cmp [IP_LIST + edi], 0 cmp [IP_LIST + edi], 0
je .ip_ok je .ip_ok
; or it's just not meant for us.. :( ; or it's just not meant for us.. :(
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Destination address does not match!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Destination address does not match!\n"
jmp .dump jmp .dump
@ -305,7 +300,6 @@ IPv4_input: ; TODO: add IPv4
xchg cl, ch ; xchg cl, ch ;
sub ecx, esi ; sub ecx, esi ;
lea edi, [edx + IPv4_header.SourceAddress] ; make edi ptr to source and dest IPv4 address
mov al, [edx + IPv4_header.Protocol] mov al, [edx + IPv4_header.Protocol]
add esi, edx ; make esi ptr to data add esi, edx ; make esi ptr to data
@ -318,11 +312,60 @@ IPv4_input: ; TODO: add IPv4
cmp al, IP_PROTO_ICMP cmp al, IP_PROTO_ICMP
je ICMP_input je ICMP_input
;-------------------------------
; Look for a matching RAW socket
pusha
mov ecx, socket_mutex
call mutex_lock
popa
add ecx, esi
sub ecx, edx
mov esi, edx
movzx edx, al
mov eax, net_sockets
.next_socket:
mov eax, [eax + SOCKET.NextPtr]
or eax, eax
jz .dump_unlock
cmp [eax + SOCKET.Domain], AF_INET4
jne .next_socket
cmp [eax + SOCKET.Protocol], edx
jne .next_socket
pusha
mov ecx, socket_mutex
call mutex_unlock
popa
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: found matching RAW socket: 0x%x\n", eax
pusha
lea ecx, [eax + SOCKET.mutex]
call mutex_lock
popa
jmp SOCKET_input
.dump_unlock:
pusha
mov ecx, socket_mutex
call mutex_unlock
popa
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: unknown protocol %u\n", al DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: unknown protocol %u\n", al
.dump: .dump:
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
inc [IPv4_packets_dumped] ; FIXME: use correct interface inc [IPv4_packets_dumped + edi]
call NET_BUFF_free
ret
.invalid_device:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_input: packet originated from invalid device\n"
call NET_BUFF_free call NET_BUFF_free
ret ret
@ -568,11 +611,12 @@ IPv4_find_fragment_slot:
; ;
; IPv4_output ; IPv4_output
; ;
; IN: eax = Destination IP ; IN: al = protocol
; ah = TTL
; ebx = device ptr (or 0 to let IP layer decide) ; ebx = device ptr (or 0 to let IP layer decide)
; ecx = data length ; ecx = data length
; edx = Source IP ; edx = Source IP
; di = TTL shl 8 + protocol ; edi = Destination IP
; ;
; OUT: eax = pointer to buffer start / 0 on error ; OUT: eax = pointer to buffer start / 0 on error
; ebx = device ptr (send packet through this device) ; ebx = device ptr (send packet through this device)
@ -589,7 +633,8 @@ IPv4_output:
cmp ecx, 65500 ; Max IPv4 packet size cmp ecx, 65500 ; Max IPv4 packet size
ja .too_large ja .too_large
push ecx di eax push ecx ax edi
mov eax, edi
call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
push edx push edx
test edi, edi test edi, edi
@ -601,7 +646,7 @@ IPv4_output:
push ebx ; push the mac onto the stack push ebx ; push the mac onto the stack
push ax push ax
inc [IPv4_packets_tx + edi] ; update stats inc [IPv4_packets_tx + edi] ; update stats
mov ax, ETHER_PROTO_IPv4 mov ax, ETHER_PROTO_IPv4
mov ebx, [NET_DRV_LIST + edi] mov ebx, [NET_DRV_LIST + edi]
@ -642,7 +687,10 @@ IPv4_output:
.arp_error: .arp_error:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax
add esp, 3*4+2 add esp, 4
pop eax
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ip=0x%x\n", eax
add esp, 4+2
xor eax, eax xor eax, eax
ret ret
@ -678,9 +726,6 @@ IPv4_output_raw:
DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
cmp ecx, 1480 ;;;;; FIXME
ja .too_large
sub esp, 8 sub esp, 8
push esi eax push esi eax
@ -707,7 +752,7 @@ IPv4_output_raw:
mov dword[esp+4+4+4], eax mov dword[esp+4+4+4], eax
pop eax esi pop eax esi
;; todo: check socket options if we should add header, or just compute checksum ;; TODO: check socket options if we should add header, or just compute checksum
push edi ecx push edi ecx
rep movsb rep movsb
@ -734,11 +779,14 @@ IPv4_output_raw:
ret ret
.error: .error:
add esp, 6 add esp, 6+8+4+4
mov ebx, ENOBUFS ; FIXME: NOBUFS or MSGSIZE error
or eax, -1
ret
.arp_error: .arp_error:
add esp, 8+4+4 add esp, 8+4+4
.too_large: mov ebx, ENOTCONN
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output_raw: Failed\n"
or eax, -1 or eax, -1
ret ret
@ -746,117 +794,120 @@ IPv4_output_raw:
;-------------------------------------------------------- ;--------------------------------------------------------
; ;
; ;
; IN: dword [esp] = pointer to buffer containing ipv4 packet to be fragmented ; IN: [esp] = pointer to buffer containing ipv4 packet to be fragmented
; esi = pointer to ip header in that buffer ; edi = pointer to ip header in that buffer
; ecx = max size of fragments ; ebx = device ptr
; ;
; OUT: / ; OUT: /
; ;
;-------------------------------------------------------- ;--------------------------------------------------------
proc IPv4_fragment stdcall buffer
align 4 locals
IPv4_fragment: offset dd ?
headerlength dd ?
headerptr dd ?
dataptr dd ?
remaining dd ?
segmentsize dd ?
endl
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_fragment\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_fragment\n"
and ecx, not 111b ; align 4 ; We must be able to put at least 8 bytes per segment
movzx eax, byte[edi] ; IHL
cmp ecx, sizeof.IPv4_header + 8 ; must be able to put at least 8 bytes and eax, 0xf
jb .err2 shl eax, 2
mov [headerlength], eax
push esi ecx add eax, 8
mov eax, [esi + IPv4_header.DestinationAddress] mov ecx, [ebx + NET_DEVICE.mtu]
call ARP_IP_to_MAC and ecx, not 11b
pop ecx esi cmp ecx, eax
cmp eax, -1 jb .fail
jz .err2
push ebx
push ax
mov ebx, [NET_DRV_LIST]
lea eax, [ebx + ETH_DEVICE.mac]
push eax
push esi ; ptr to ip header
sub ecx, sizeof.IPv4_header ; substract header size
push ecx ; max data size
push dword 0 ; offset
.new_fragment:
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment"
mov ax, ETHER_PROTO_IPv4
lea ebx, [esp + 4*4]
call ETH_output
jz .err
; copy header
mov esi, [esp + 2*4]
mov ecx, 5 ; 5 dwords: TODO: use IHL field of the header!
rep movsd
; copy data
mov esi, [esp + 2*4]
add esi, sizeof.IPv4_header
add esi, [esp] ; offset
mov ecx, [esp + 1*4]
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_fragment: copying %u bytes\n", ecx
rep movsb
; now, correct header
mov ecx, [esp + 1*4]
add ecx, sizeof.IPv4_header
xchg cl, ch
mov [edi + IPv4_header.TotalLength], cx
mov ecx, [esp] ; offset
xchg cl, ch
; cmp dword[esp + 4*4], 0 ; last fragment?;<<<<<<
; je .last_fragment
or cx, 1 shl 2 ; more fragments
; .last_fragment:
mov [edi + IPv4_header.FlagsAndFragmentOffset], cx
mov [edi + IPv4_header.HeaderChecksum], 0 mov [edi + IPv4_header.HeaderChecksum], 0
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<< send the packet mov [segmentsize], ecx
mov ecx, [esp + 1*4] mov [headerptr], edi
movzx ecx, [edi + IPv4_header.TotalLength]
xchg cl, ch
sub ecx, [headerlength]
mov [remaining], ecx
mov [offset], 0
push edx eax add edi, [headerlength]
mov [dataptr], edi
.loop:
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment"
mov ecx, [segmentsize]
cmp ecx, [remaining]
jbe @f
mov ecx, [remaining]
@@:
mov ax, ETHER_PROTO_IPv4
mov edx, [esp]
add edx, [edx + NET_BUFF.offset]
; add edx, ETH_header.DstMAC ; = 0
call ETH_output
jz .fail
push edi
mov edx, ecx
; copy header
mov esi, [headerptr]
mov ecx, [headerlength]
shr ecx, 2
rep movsd
; copy data
mov esi, [dataptr]
add esi, [offset]
mov ecx, edx
sub ecx, [headerlength]
shr ecx, 2
rep movsd
pop edi
; now, correct header
; packet length
mov ax, dx
xchg al, ah
mov [edi + IPv4_header.TotalLength], ax
; offset
mov eax, [offset]
xchg al, ah
sub edx, [headerlength]
sub [remaining], edx
je @f
jb .fail
or ah, 1 shl 2 ; more fragments
add [offset], edx
@@:
mov [edi + IPv4_header.FlagsAndFragmentOffset], ax
; Send the fragment
IPv4_checksum edi IPv4_checksum edi
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
mov ecx, [esp+4] cmp [remaining], 0
add [esp], ecx jne .loop
mov ecx, [esp+3*4+6+4] ; ptr to begin of buff
add ecx, [esp+3*4+6+4+4] ; buff size
sub ecx, [esp+2*4] ; ptr to ip header
add ecx, [esp] ; offset
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: %u bytes remaining\n", ecx
cmp ecx, [esp+1*4]
jae .new_fragment
mov [esp+4], ecx ; set fragment size to remaining packet size
jmp .new_fragment
.err:
DEBUGF DEBUG_NETWORK_ERROR, "Ipv4_fragment: failed\n"
.done:
add esp, 12 + 4 + 6
.err2:
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: dumping\n"
call NET_BUFF_free call NET_BUFF_free
ret ret
.fail:
DEBUGF DEBUG_NETWORK_ERROR, "Ipv4_fragment: failed\n"
call NET_BUFF_free
ret
endp
;--------------------------------------------------------------------------- ;---------------------------------------------------------------------------
@ -973,11 +1024,6 @@ IPv4_connect:
pushd [edx + 4] pushd [edx + 4]
pop [eax + IP_SOCKET.RemoteIP] pop [eax + IP_SOCKET.RemoteIP]
; Set up data receiving queue
push eax
init_queue (eax + SOCKET_QUEUE_LOCATION)
pop eax
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_unlock call mutex_unlock

View File

@ -133,8 +133,9 @@ macro ICMP_init {
; IN: Pointer to buffer in [esp] ; IN: Pointer to buffer in [esp]
; ebx = pointer to device struct ; ebx = pointer to device struct
; ecx = ICMP Packet size ; ecx = ICMP Packet size
; edx = ptr to IPv4 header
; esi = ptr to ICMP Packet data ; esi = ptr to ICMP Packet data
; edi = ptr to ipv4 source and dest address ; edi = interface number*4
; ;
; OUT: / ; OUT: /
; ;
@ -144,8 +145,13 @@ ICMP_input:
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
; Dump all multicasts and broadcasts
mov eax, [IP_LIST + edi]
cmp eax, [edx + IPv4_header.DestinationAddress]
jne .dump
; Check the checksum ; Check the checksum
push esi ecx push esi ecx edx
push [esi + ICMP_header.Checksum] push [esi + ICMP_header.Checksum]
mov [esi + ICMP_header.Checksum], 0 mov [esi + ICMP_header.Checksum], 0
xor edx, edx xor edx, edx
@ -153,17 +159,11 @@ ICMP_input:
call checksum_2 call checksum_2
pop si pop si
cmp dx, si cmp dx, si
pop ecx esi pop edx ecx esi
jne .checksum_mismatch jne .checksum_mismatch
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: Checksum OK\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: Checksum OK\n"
; Ualidate device ptr
mov eax, edi
call NET_ptr_to_num4
cmp edi, -1
je .dump
; Update stats ; Update stats
inc [ICMP_PACKETS_RX + edi] inc [ICMP_PACKETS_RX + edi]
@ -177,10 +177,10 @@ ICMP_input:
call mutex_lock call mutex_lock
popa popa
mov edx, [eax] ; ipv4 source address add ecx, esi
sub ecx, edx
mov esi, edx
mov eax, net_sockets mov eax, net_sockets
.try_more:
; mov , [esi + ICMP_header.Identifier]
.next_socket: .next_socket:
mov eax, [eax + SOCKET.NextPtr] mov eax, [eax + SOCKET.NextPtr]
or eax, eax or eax, eax
@ -192,12 +192,6 @@ ICMP_input:
cmp [eax + SOCKET.Protocol], IP_PROTO_ICMP cmp [eax + SOCKET.Protocol], IP_PROTO_ICMP
jne .next_socket jne .next_socket
cmp [eax + IP_SOCKET.RemoteIP], edx
jne .next_socket
; cmp [eax + ICMP_SOCKET.Identifier],
; jne .next_socket
pusha pusha
mov ecx, socket_mutex mov ecx, socket_mutex
call mutex_unlock call mutex_unlock
@ -376,7 +370,7 @@ end if
; ;
; IN: eax = socket ptr ; IN: eax = socket ptr
; ecx = data length ; ecx = data length
; esi = data offset ; edx = data pointer
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
@ -385,13 +379,13 @@ ICMP_output_raw:
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx
push edx push edx
mov di, IP_PROTO_ICMP SHL 8 + 128 ; TTL
mov edx, [eax + IP_SOCKET.LocalIP]
mov ebx, [eax + IP_SOCKET.device] mov ebx, [eax + IP_SOCKET.device]
mov eax, [eax + IP_SOCKET.RemoteIP] mov edx, [eax + IP_SOCKET.LocalIP]
mov edi, [eax + IP_SOCKET.RemoteIP]
mov al, [eax + IP_SOCKET.ttl]
mov ah, IP_PROTO_ICMP
call IPv4_output call IPv4_output
jz .exit jz .fail
pop esi pop esi
push eax push eax
@ -415,10 +409,14 @@ ICMP_output_raw:
jnz @f jnz @f
call NET_ptr_to_num4 call NET_ptr_to_num4
inc [ICMP_PACKETS_TX + edi] inc [ICMP_PACKETS_TX + edi]
@@: @@:
ret ret
.exit:
.fail:
pop edx
DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n" DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
or eax, -1
mov ebx, EMSGSIZE ;;; FIXME
ret ret

View File

@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5523 $ $Revision: 5976 $
iglobal iglobal
align 4 align 4
@ -61,15 +61,15 @@ local .fail
.fail: .fail:
} }
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; LOOP_input ; LOOP_input ;
; ; ;
; IN: [esp+4] = Pointer to buffer ; IN: [esp+4] = Pointer to buffer ;
; ; ;
; OUT: / ; OUT: / ;
; ; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
align 4 align 4
LOOP_input: LOOP_input:
@ -105,19 +105,19 @@ LOOP_input:
ret ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; LOOP_output ; LOOP_output ;
; ; ;
; IN: ecx = packet size ; IN: ecx = packet size ;
; edi = address family ; edi = address family ;
; ; ;
; OUT: eax = start of net frame / 0 on error ; OUT: eax = start of net frame / 0 on error ;
; ebx = to device structure ; ebx = to device structure ;
; ecx = unchanged (packet size of embedded data) ; ecx = unchanged (packet size of embedded data) ;
; edi = start of payload ; edi = start of payload ;
; ; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
align 4 align 4
LOOP_output: LOOP_output:

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,12 @@ IP_PROTO_IP = 0
IP_PROTO_ICMP = 1 IP_PROTO_ICMP = 1
IP_PROTO_TCP = 6 IP_PROTO_TCP = 6
IP_PROTO_UDP = 17 IP_PROTO_UDP = 17
IP_PROTO_RAW = 255
; IP options
IP_TOS = 1
IP_TTL = 2
IP_HDRINCL = 3
; PPP protocol numbers ; PPP protocol numbers
PPP_PROTO_IPv4 = 0x2100 PPP_PROTO_IPv4 = 0x2100
@ -71,6 +77,9 @@ SOCK_STREAM = 1
SOCK_DGRAM = 2 SOCK_DGRAM = 2
SOCK_RAW = 3 SOCK_RAW = 3
; Socket level
SOL_SOCKET = 0xffff
; Socket options ; Socket options
SO_ACCEPTCON = 1 shl 0 SO_ACCEPTCON = 1 shl 0
SO_BROADCAST = 1 shl 1 SO_BROADCAST = 1 shl 1
@ -89,10 +98,6 @@ SO_NONBLOCK = 1 shl 31
MSG_PEEK = 0x02 MSG_PEEK = 0x02
MSG_DONTWAIT = 0x40 MSG_DONTWAIT = 0x40
; Socket level
SOL_SOCKET = 0
; Socket States ; Socket States
SS_NOFDREF = 0x0001 ; no file table ref any more SS_NOFDREF = 0x0001 ; no file table ref any more
SS_ISCONNECTED = 0x0002 ; socket connected to a peer SS_ISCONNECTED = 0x0002 ; socket connected to a peer

View File

@ -201,13 +201,11 @@ align 4
endg endg
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; TCP_init ; TCP_init: Resets all TCP variables. ;
; ; ;
; This function resets all TCP variables ;-----------------------------------------------------------------;
;
;-----------------------------------------------------------------
macro TCP_init { macro TCP_init {
xor eax, eax xor eax, eax
@ -246,19 +244,17 @@ include 'tcp_input.inc'
include 'tcp_output.inc' include 'tcp_output.inc'
;--------------------------------------------------------------------------- ;------------------------------------------------------------------;
; ; ;
; TCP_API ; TCP_api: This function is called by system function 76 ;
; ; ;
; This function is called by system function 76 ; IN: bl = subfunction number ;
; ; bh = device number ;
; IN: subfunction number in bl ; ecx, edx, .. depends on subfunction ;
; device number in bh ; ;
; ecx, edx, .. depends on subfunction ; OUT: depends on subfunction ;
; ; ;
; OUT: ;------------------------------------------------------------------;
;
;---------------------------------------------------------------------------
align 4 align 4
TCP_api: TCP_api:

View File

@ -14,36 +14,35 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5522 $ $Revision: 5976 $
;-----------------------------------------------------------------
;
; TCP_input:
;
; Add a segment to the incoming TCP queue
;
; IN: [esp] = ptr to buffer
; ebx = ptr to device struct
; ecx = segment size
; esi = ptr to TCP segment
; edi = ptr to ipv4 source address, followed by ipv4 dest address
;
; OUT: /
;
;-----------------------------------------------------------------
;-----------------------------------------------------------------;
; ;
; TCP_input: Add a segment to the incoming TCP queue. ;
; ;
; IN: [esp] = ptr to buffer ;
; ebx = ptr to device struct ;
; ecx = TCP segment size ;
; edx = ptr to IPv4 header ;
; esi = ptr to TCP segment ;
; edi = interface number*4 ;
; ;
; OUT: / ;
; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_input: TCP_input:
; record the current time ; record the current time
push [timer_ticks] ; in 1/100 seconds push [timer_ticks] ; in 1/100 seconds
push ebx ecx esi edi ; mind the order (see TCP_queue_entry struct) push ebx ecx esi edx ; mind the order (see TCP_queue_entry struct)
mov esi, esp mov esi, esp
push edi
add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
pop edi
add esp, sizeof.TCP_queue_entry add esp, sizeof.TCP_queue_entry
call NET_ptr_to_num4
inc [TCP_segments_rx + edi] inc [TCP_segments_rx + edi]
xor edx, edx xor edx, edx
@ -55,12 +54,13 @@ TCP_input:
ret ret
.fail: .fail:
pop edi
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
call NET_ptr_to_num4 call NET_ptr_to_num4
inc [TCP_segments_missed + edi] inc [TCP_segments_missed + edi]
add esp, sizeof.TCP_queue_entry - 8 add esp, sizeof.TCP_queue_entry - 4
call NET_BUFF_free call NET_BUFF_free
ret ret
@ -94,7 +94,7 @@ endl
mov ebx, [esi + TCP_queue_entry.device_ptr] mov ebx, [esi + TCP_queue_entry.device_ptr]
mov ecx, [esi + TCP_queue_entry.segment_size] mov ecx, [esi + TCP_queue_entry.segment_size]
mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 source address, followed by ipv4 destination address mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 header
mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks] DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
@ -111,8 +111,8 @@ endl
push ecx esi push ecx esi
pushw [esi + TCP_header.Checksum] pushw [esi + TCP_header.Checksum]
mov [esi + TCP_header.Checksum], 0 mov [esi + TCP_header.Checksum], 0
TCP_checksum (edi), (edi+4) TCP_checksum (edi+IPv4_header.SourceAddress), (edi+IPv4_header.DestinationAddress)
pop cx ; previous checksum pop cx ; previous checksum
cmp cx, dx cmp cx, dx
pop edx ecx pop edx ecx
jne .drop_no_socket jne .drop_no_socket
@ -170,7 +170,7 @@ endl
jne .socket_loop jne .socket_loop
mov eax, [ebx + IP_SOCKET.RemoteIP] mov eax, [ebx + IP_SOCKET.RemoteIP]
cmp eax, [edi] ; Ipv4 source address cmp eax, [edi + IPv4_header.SourceAddress]
je @f je @f
test eax, eax test eax, eax
jnz .socket_loop jnz .socket_loop
@ -233,7 +233,7 @@ endl
call mutex_unlock call mutex_unlock
popa popa
push ecx edx esi edi ;;; push ecx edx esi edi
call SOCKET_fork call SOCKET_fork
pop edi esi edx ecx pop edi esi edx ecx
@ -244,7 +244,7 @@ endl
mov [temp_bits], TCP_BIT_DROPSOCKET mov [temp_bits], TCP_BIT_DROPSOCKET
push dword [edi + 4] ; Ipv4 destination addres push [edi + IPv4_header.DestinationAddress]
pop [ebx + IP_SOCKET.LocalIP] pop [ebx + IP_SOCKET.LocalIP]
push [edx + TCP_header.DestinationPort] push [edx + TCP_header.DestinationPort]
@ -485,8 +485,8 @@ endl
inc eax inc eax
call TCP_xmit_timer call TCP_xmit_timer
jmp .rtt_done jmp .rtt_done
.no_timestamp_rtt: .no_timestamp_rtt:
cmp [ebx + TCP_SOCKET.t_rtt], 0 cmp [ebx + TCP_SOCKET.t_rtt], 0
je .rtt_done je .rtt_done
mov eax, [edx + TCP_header.AckNumber] mov eax, [edx + TCP_header.AckNumber]
@ -494,7 +494,6 @@ endl
jbe .rtt_done jbe .rtt_done
mov eax, [ebx + TCP_SOCKET.t_rtt] mov eax, [ebx + TCP_SOCKET.t_rtt]
call TCP_xmit_timer call TCP_xmit_timer
.rtt_done: .rtt_done:
; update window pointers ; update window pointers
@ -1211,7 +1210,7 @@ align 4
;;; TODO: check if it's a broadcast or multicast, and drop if so ;;; TODO: check if it's a broadcast or multicast, and drop if so
push dword [edi] ; Ipv4 source addres push [edi + IPv4_header.SourceAddress]
pop [ebx + IP_SOCKET.RemoteIP] pop [ebx + IP_SOCKET.RemoteIP]
push [edx + TCP_header.SourcePort] push [edx + TCP_header.SourcePort]
@ -1673,11 +1672,13 @@ align 4
.respond_seg_ack: .respond_seg_ack:
mov cl, TH_RST mov cl, TH_RST
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
call TCP_respond_segment call TCP_respond_segment
jmp .drop_no_socket jmp .drop_no_socket
.respond_seg_syn: .respond_seg_syn:
mov cl, TH_RST + TH_ACK mov cl, TH_RST + TH_ACK
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
call TCP_respond_segment call TCP_respond_segment
jmp .drop_no_socket jmp .drop_no_socket

View File

@ -16,14 +16,15 @@
$Revision: 5584 $ $Revision: 5584 $
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; TCP_output ; TCP_output ;
; ; ;
; IN: eax = socket pointer ; IN: eax = socket pointer ;
; OUT: eax = 0 on success/errorcode ; ;
; ; OUT: eax = 0 on success/errorcode ;
;----------------------------------------------------------------- ; ;
;-----------------------------------------------------------------;
align 4 align 4
proc TCP_output proc TCP_output
@ -503,10 +504,11 @@ endl
; Create the IP packet ; Create the IP packet
mov ecx, esi mov ecx, esi
mov edx, [eax + IP_SOCKET.LocalIP] ; source ip
mov ebx, [eax + IP_SOCKET.device] mov ebx, [eax + IP_SOCKET.device]
mov eax, [eax + IP_SOCKET.RemoteIP] ; dest ip mov edx, [eax + IP_SOCKET.LocalIP] ; source ip
mov di, IP_PROTO_TCP shl 8 + 128 mov edi, [eax + IP_SOCKET.RemoteIP] ; dest ip
mov al, [eax + IP_SOCKET.ttl]
mov ah, IP_PROTO_TCP
call IPv4_output call IPv4_output
jz .ip_error jz .ip_error

View File

@ -104,18 +104,17 @@ macro TCP_init_socket socket {
} }
;--------------------------- ;-----------------------------------------------------------------;
; ; ;
; TCP_pull_out_of_band ; TCP_pull_out_of_band ;
; ; ;
; IN: eax = ; IN: eax = ? ;
; ebx = socket ptr ; ebx = socket ptr ;
; edx = tcp packet ptr ; edx = tcp packet ptr ;
; ; ;
; OUT: / ; OUT: / ;
; ; ;
;--------------------------- ;-----------------------------------------------------------------;
align 4 align 4
TCP_pull_out_of_band: TCP_pull_out_of_band:
@ -127,21 +126,16 @@ TCP_pull_out_of_band:
;-----------------------------------------------------------------;
; ;
; TCP_drop ;
; ;
; IN: eax = socket ptr ;
;------------------------- ; ebx = error number ;
; ; ;
; TCP_drop ; OUT: eax = socket ptr ;
; ; ;
; IN: eax = socket ptr ;-----------------------------------------------------------------;
; ebx = error number
;
; OUT: eax = socket ptr
;
;-------------------------
align 4 align 4
TCP_drop: ; FIXME CHECKME TODO TCP_drop: ; FIXME CHECKME TODO
@ -171,14 +165,15 @@ TCP_drop: ; FIXME CHECKME TODO
;------------------------- ;-----------------------------------------------------------------;
; ; ;
; TCP_disconnect ; TCP_disconnect ;
; ; ;
; IN: eax = socket ptr ; IN: eax = socket ptr ;
; OUT: eax = socket ptr / 0 ; ;
; ; OUT: eax = socket ptr / 0 ;
;------------------------- ; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_disconnect: TCP_disconnect:
@ -198,18 +193,18 @@ TCP_disconnect:
call TCP_output call TCP_output
pop eax pop eax
@@: @@:
ret ret
;------------------------- ;-----------------------------------------------------------------;
; ; ;
; TCP_close ; TCP_close ;
; ; ;
; IN: eax = socket ptr ; IN: eax = socket ptr ;
; OUT: / ; ;
; ; OUT: / ;
;------------------------- ; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_close: TCP_close:
@ -222,21 +217,19 @@ TCP_close:
call SOCKET_free call SOCKET_free
xor eax, eax xor eax, eax
ret ret
;-----------------------------------------------------------------;
;------------------------- ; ;
; ; TCP_outflags ;
; TCP_outflags ; ;
; ; IN: eax = socket ptr ;
; IN: eax = socket ptr ; ;
; ; OUT: edx = flags ;
; OUT: edx = flags ; ;
; ;-----------------------------------------------------------------;
;-------------------------
align 4 align 4
TCP_outflags: TCP_outflags:
@ -266,16 +259,16 @@ TCP_outflags:
;--------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; The fast way to send an ACK/RST/keepalive segment ; TCP_respond: Fast way to send an ACK/RST/keepalive segment. ;
; ; ;
; TCP_respond ; IN: ebx = socket ptr ;
; ; cl = flags ;
; IN: ebx = socket ptr ; ;
; cl = flags ; OUT: / ;
; ; ;
;-------------------------------------- ;-----------------------------------------------------------------;
align 4 align 4
TCP_respond: TCP_respond:
@ -285,11 +278,12 @@ TCP_respond:
; Create the IP packet ; Create the IP packet
push cx ebx push cx ebx
mov eax, [ebx + IP_SOCKET.RemoteIP]
mov edx, [ebx + IP_SOCKET.LocalIP] mov edx, [ebx + IP_SOCKET.LocalIP]
mov ebx, [ebx + IP_SOCKET.device] mov edi, [ebx + IP_SOCKET.RemoteIP]
mov al, [ebx + IP_SOCKET.ttl]
mov ah, IP_PROTO_TCP
mov ecx, sizeof.TCP_header mov ecx, sizeof.TCP_header
mov di, IP_PROTO_TCP shl 8 + 128 mov ebx, [ebx + IP_SOCKET.device]
call IPv4_output call IPv4_output
jz .error jz .error
pop esi cx pop esi cx
@ -347,33 +341,31 @@ TCP_respond:
ret ret
;-----------------------------------------------------------------;
; ;
; TCP_respond_segment ;
; ;
; IN: ebx = device ptr ;
; edx = segment ptr (a previously received segment) ;
;------------------------- ; edi = ptr to IPv4 header ;
; TCP_respond_segment: ; cl = flags ;
; ; ;
; IN: edx = segment ptr (a previously received segment) ; OUT: / ;
; edi = ptr to dest and src IPv4 addresses ; ;
; cl = flags ;-----------------------------------------------------------------;
align 4 align 4
TCP_respond_segment: TCP_respond_segment:
DEBUGF DEBUG_NETWORK_VERBOSE,"TCP_respond_segment: frame=%x flags=%x\n", edx, cl DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_segment: frame=%x flags=%x\n", edx, cl
;--------------------- ;---------------------
; Create the IP packet ; Create the IP packet
push cx edx push cx edx
mov edx, [edi + 4] mov edx, [edi + IPv4_header.DestinationAddress]
mov eax, [edi] mov edi, [edi + IPv4_header.SourceAddress]
mov ecx, sizeof.TCP_header mov ecx, sizeof.TCP_header
mov di, IP_PROTO_TCP shl 8 + 128 mov ax, IP_PROTO_TCP shl 8 + 128
xor ebx, ebx ;;; fixme
call IPv4_output call IPv4_output
jz .error jz .error
pop esi cx pop esi cx
@ -454,7 +446,11 @@ local .done
.done: .done:
} }
;-----------------------------------------------------------------;
; ;
; TCP_set_persist ;
; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_set_persist: TCP_set_persist:
@ -491,13 +487,20 @@ TCP_set_persist:
; eax = rtt ;-----------------------------------------------------------------;
; ebx = socket ptr ; ;
; TCP_xmit_timer: Calculate new smoothed RTT. ;
; ;
; IN: eax = rtt ;
; ebx = socket ptr ;
; ;
; OUT: / ;
; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_xmit_timer: TCP_xmit_timer:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_xmit_timer: socket=%x rtt=%d0ms\n", ebx, eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_xmit_timer: socket=0x%x rtt=%d0ms\n", ebx, eax
;TODO: update stats ;TODO: update stats
@ -546,7 +549,6 @@ TCP_xmit_timer:
.no_rtt_yet: .no_rtt_yet:
push ecx push ecx
mov ecx, eax mov ecx, eax
shl ecx, TCP_RTT_SHIFT shl ecx, TCP_RTT_SHIFT
@ -559,14 +561,20 @@ TCP_xmit_timer:
ret ret
;-----------------------------------------------------------------;
; ;
; eax = max segment size ; TCP_mss: Update maximum segment size ;
; ebx = socket ptr ; ;
; IN: eax = max segment size ;
; ebx = socket ptr ;
; ;
; OUT: / ;
; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_mss: TCP_mss:
cmp eax, 1420 ; FIXME cmp eax, 1420 ; FIXME
jbe @f jbe @f
mov eax, 1420 mov eax, 1420
@@: @@:
@ -577,13 +585,20 @@ TCP_mss:
;-----------------------------------------------------------------;
; ebx = socket ptr ; ;
; edx = segment ptr ; TCP_reassemble ;
; ;
; IN: ebx = socket ptr ;
; edx = segment ptr ;
; ;
; OUT: / ;
; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_reassemble: TCP_reassemble:
;;;;; TODO
ret ret

View File

@ -23,9 +23,6 @@ timer_flag_persist = 1 shl 3
timer_flag_wait = 1 shl 4 timer_flag_wait = 1 shl 4
;----------------------
; 160 ms timer
;----------------------
macro TCP_timer_160ms { macro TCP_timer_160ms {
local .loop local .loop
@ -150,9 +147,9 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
.check_more5: .check_more5:
dec [eax + TCP_SOCKET.timer_persist] dec [eax + TCP_SOCKET.timer_persist]
jnz .loop jnz .check_more6
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist test [eax + TCP_SOCKET.timer_flags], timer_flag_persist
jz .loop jz .check_more6
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
@ -163,14 +160,33 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
pop eax pop eax
mov [eax + TCP_SOCKET.t_force], 0 mov [eax + TCP_SOCKET.t_force], 0
jmp .loop .check_more6:
dec [eax + TCP_SOCKET.timer_timed_wait]
jnz .loop
test [eax + TCP_SOCKET.timer_flags], timer_flag_wait
jz .loop
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: timed wait timer expired\n", eax
push [eax + SOCKET.NextPtr]
call TCP_close
pop eax
jmp .check_only
endp endp
;-----------------------------------------------------------------;
; eax = socket ; ;
; TCP_cancel_timers ;
; ;
; IN: eax = socket ;
; ;
; OUT: / ;
; ;
;-----------------------------------------------------------------;
align 4
TCP_cancel_timers: TCP_cancel_timers:
mov [eax + TCP_SOCKET.timer_flags], 0 mov [eax + TCP_SOCKET.timer_flags], 0

View File

@ -17,15 +17,15 @@
$Revision: 5442 $ $Revision: 5442 $
;------------------------- ;-----------------------------------------------------------------;
; ; ;
; TCP_usrclose ; TCP_usrclosed ;
; ; ;
; Move connection to next state, based on process close. ; IN: eax = socket ptr ;
; ; ;
; IN: eax = socket ptr ; OUT: / ;
; ; ;
;------------------------- ;-----------------------------------------------------------------;
align 4 align 4
TCP_usrclosed: TCP_usrclosed:
@ -37,7 +37,6 @@ TCP_usrclosed:
jmp ebx jmp ebx
.switch: .switch:
dd .close ; TCPS_CLOSED dd .close ; TCPS_CLOSED
dd .close ; TCPS_LISTEN dd .close ; TCPS_LISTEN
dd .close ; TCPS_SYN_SENT dd .close ; TCPS_SYN_SENT
@ -50,7 +49,6 @@ TCP_usrclosed:
dd .disc ; TCPS_FIN_WAIT_2 dd .disc ; TCPS_FIN_WAIT_2
dd .disc ; TCPS_TIMED_WAIT dd .disc ; TCPS_TIMED_WAIT
.close: .close:
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
call TCP_close call TCP_close
@ -74,15 +72,17 @@ TCP_usrclosed:
ret ret
;------------------------- ;-----------------------------------------------------------------;
; ; ;
; TCP_connect ; TCP_connect ;
; ; ;
; IN: eax = socket ptr ; IN: eax = socket ptr ;
; OUT: eax = 0 ok / -1 error ; ;
; ebx = error code ; OUT: eax = 0 on success ;
; ; eax = -1 on error ;
;------------------------- ; ebx = error code on error ;
; ;
;-----------------------------------------------------------------;
align 4 align 4
TCP_connect: TCP_connect:

View File

@ -36,13 +36,11 @@ align 4
endg endg
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; UDP_init ; UDP_init: This function resets all UDP variables ;
; ; ;
; This function resets all UDP variables ;-----------------------------------------------------------------;
;
;-----------------------------------------------------------------
macro UDP_init { macro UDP_init {
xor eax, eax xor eax, eax
@ -57,15 +55,15 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
; Pseudoheader ; Pseudoheader
mov edx, IP_PROTO_UDP mov edx, IP_PROTO_UDP
add dl, [IP1+1] add dl, byte[IP1+1]
adc dh, [IP1+0] adc dh, byte[IP1+0]
adc dl, [IP1+3] adc dl, byte[IP1+3]
adc dh, [IP1+2] adc dh, byte[IP1+2]
adc dl, [IP2+1] adc dl, byte[IP2+1]
adc dh, [IP2+0] adc dh, byte[IP2+0]
adc dl, [IP2+3] adc dl, byte[IP2+3]
adc dh, [IP2+2] adc dh, byte[IP2+2]
adc dl, cl ; byte[esi+UDP_header.Length+1] adc dl, cl ; byte[esi+UDP_header.Length+1]
adc dh, ch ; byte[esi+UDP_header.Length+0] adc dh, ch ; byte[esi+UDP_header.Length+0]
@ -98,23 +96,20 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
} }
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; UDP_input: ; UDP_input: Inject the UDP data in the application sockets. ;
; ; ;
; Called by IPv4_input, ; IN: [esp] = ptr to buffer ;
; this procedure will inject the udp data diagrams in the application sockets. ; ebx = ptr to device struct ;
; ; ecx = UDP packet size ;
; IN: [esp] = Pointer to buffer ; edx = ptr to IPv4 header ;
; [esp+4] = size of buffer ; esi = ptr to UDP packet data ;
; ebx = ptr to device struct ; edi = interface number*4 ;
; ecx = UDP Packet size ; ;
; esi = ptr to UDP header ; OUT: / ;
; edi = ptr to ipv4 source and dest address ; ;
; ;-----------------------------------------------------------------;
; OUT: /
;
;-----------------------------------------------------------------
align 4 align 4
UDP_input: UDP_input:
@ -127,7 +122,8 @@ UDP_input:
; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct ; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct
UDP_checksum (edi), (edi+4) mov eax, edx
UDP_checksum (eax+IPv4_header.SourceAddress), (eax+IPv4_header.DestinationAddress)
jnz .checksum_mismatch jnz .checksum_mismatch
.no_checksum: .no_checksum:
@ -148,9 +144,7 @@ UDP_input:
mov cx, [esi + UDP_header.SourcePort] mov cx, [esi + UDP_header.SourcePort]
mov dx, [esi + UDP_header.DestinationPort] mov dx, [esi + UDP_header.DestinationPort]
mov edi, [edi + 4] ; ipv4 source address
mov eax, net_sockets mov eax, net_sockets
.next_socket: .next_socket:
mov eax, [eax + SOCKET.NextPtr] mov eax, [eax + SOCKET.NextPtr]
or eax, eax or eax, eax
@ -172,15 +166,15 @@ UDP_input:
call mutex_unlock call mutex_unlock
popa popa
;;; TODO: when packet is processed, check more sockets! ;;; TODO: when packet is processed, check more sockets?!
; FIXME: check remote IP if possible
;
; cmp [eax + IP_SOCKET.RemoteIP], 0xffffffff ; cmp [eax + IP_SOCKET.RemoteIP], 0xffffffff
; je @f ; je @f
; cmp [eax + IP_SOCKET.RemoteIP], edi ; cmp [eax + IP_SOCKET.RemoteIP],
; jne .next_socket ; jne .next_socket
; @@: ; @@:
;
; FIXME: UDP should check remote IP, but not under all circumstances!
cmp [eax + UDP_SOCKET.RemotePort], 0 cmp [eax + UDP_SOCKET.RemotePort], 0
je .updateport je .updateport
@ -194,7 +188,6 @@ UDP_input:
popa popa
.updatesock: .updatesock:
call NET_ptr_to_num4
inc [UDP_PACKETS_RX + edi] inc [UDP_PACKETS_RX + edi]
movzx ecx, [esi + UDP_header.Length] movzx ecx, [esi + UDP_header.Length]
@ -232,17 +225,17 @@ UDP_input:
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; UDP_output ; UDP_output: Create an UDP packet. ;
; ; ;
; IN: eax = socket pointer ; IN: eax = socket pointer ;
; ecx = number of bytes to send ; ecx = number of bytes to send ;
; esi = pointer to data ; esi = pointer to data ;
; ; ;
; OUT: eax = -1 on error ; OUT: eax = -1 on error ;
; ; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
align 4 align 4
UDP_output: UDP_output:
@ -257,10 +250,11 @@ UDP_output:
sub esp, 4 ; Data ptr will be placed here sub esp, 4 ; Data ptr will be placed here
push edx esi push edx esi
mov edx, [eax + IP_SOCKET.LocalIP]
mov ebx, [eax + IP_SOCKET.device] mov ebx, [eax + IP_SOCKET.device]
mov eax, [eax + IP_SOCKET.RemoteIP] mov edx, [eax + IP_SOCKET.LocalIP]
mov di, IP_PROTO_UDP shl 8 + 128 mov edi, [eax + IP_SOCKET.RemoteIP]
mov al, [eax + IP_SOCKET.ttl]
mov ah, IP_PROTO_UDP
add ecx, sizeof.UDP_header add ecx, sizeof.UDP_header
call IPv4_output call IPv4_output
jz .fail jz .fail
@ -306,15 +300,17 @@ UDP_output:
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; UDP_connect ; UDP_connect ;
; ; ;
; IN: eax = socket pointer ; IN: eax = socket pointer ;
; OUT: eax = 0 ok / -1 error ; ;
; ebx = error code ; OUT: eax = 0 on success ;
; ; eax = -1 on error ;
;------------------------- ; ebx = error code on error ;
; ;
;-----------------------------------------------------------------;
align 4 align 4
UDP_connect: UDP_connect:
@ -347,10 +343,6 @@ UDP_connect:
call SOCKET_find_port call SOCKET_find_port
@@: @@:
push eax
init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue
pop eax
push eax push eax
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_unlock call mutex_unlock
@ -362,14 +354,15 @@ UDP_connect:
ret ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; UDP_disconnect ; UDP_disconnect ;
; ; ;
; IN: eax = socket pointer ; IN: eax = socket pointer ;
; OUT: eax = socket pointer ; ;
; ; OUT: eax = socket pointer ;
;------------------------- ; ;
;-----------------------------------------------------------------;
align 4 align 4
UDP_disconnect: UDP_disconnect:
@ -383,20 +376,17 @@ UDP_disconnect:
;--------------------------------------------------------------------------- ;-----------------------------------------------------------------;
; ; ;
; UDP_API ; UDP_api: This function is called by system function 76 ;
; ; ;
; This function is called by system function 75 ; IN: bl = subfunction number in bl ;
; ; bh = device number in bh ;
; IN: subfunction number in bl ; ecx, edx, .. depends on subfunction ;
; device number in bh ; ;
; ecx, edx, .. depends on subfunction ; OUT: depends on subfunction ;
; ; ;
; OUT: ;-----------------------------------------------------------------;
;
;---------------------------------------------------------------------------
align 4 align 4
UDP_api: UDP_api: