small changes and optimization

git-svn-id: svn://kolibrios.org@1369 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Alexey Teplov ( 2010-01-08 12:39:50 +00:00
parent dd75d94380
commit abfe37adc4
6 changed files with 230 additions and 346 deletions

View File

@ -428,16 +428,6 @@ sys_resize_app_memory:
.no_application_mem_resize: .no_application_mem_resize:
ret ret
sys_threads:
; eax=1 create thread
;
; ebx=thread start
; ecx=thread stack value
;
; on return : eax = pid
jmp new_sys_threads
iglobal iglobal
; process_terminating db 'K : Process - terminating',13,10,0 ; process_terminating db 'K : Process - terminating',13,10,0
; process_terminated db 'K : Process - done',13,10,0 ; process_terminated db 'K : Process - done',13,10,0

View File

@ -126,35 +126,35 @@ iglobal
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 ; 24-PlayCdTrack,StopCd and GetCdPlaylist
dd 0 ; 25
dd 0 ; 26
dd 0
dd 0 ;
dd 0
dd 0 ; 30-Get/SetCurrentDirectory
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 ; 37-GetMousePosition_ScreenRelative,.
dd 0 ; 38-DrawLine
dd 0 ; 39-GetBackgroundSize,ReadBgrData,.
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 ; 43-SendDeviceData
dd 0 dd 0
dd 0 dd 0
dd 0 ; 46-ReservePortArea and FreePortArea dd 0
dd display_number ; 47-WriteNum dd 0
dd 0 ; 48-SetRedrawType and SetButtonType dd 0
dd 0 ; 49-Advanced Power Management (APM) dd 0
dd syscall_set_window_shape ; 50-Window shape & scale dd 0
dd syscall_threads ; 51-Threads dd 0
dd stack_driver_stat ; 52-Stack driver status dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd socket ; 53-Socket interface dd socket ; 53-Socket interface
dd 0 dd 0
dd sound_interface ; 55-Sound interface dd sound_interface ; 55-Sound interface
@ -166,14 +166,13 @@ iglobal
dd sys_gs ; 61-Direct graphics access dd sys_gs ; 61-Direct graphics access
dd sys_pci ; 62-PCI functions dd sys_pci ; 62-PCI functions
dd sys_msg_board ; 63-System message board dd sys_msg_board ; 63-System message board
dd 0 ; 64-Resize application memory usage dd 0
dd syscall_putimage_palette; 65-PutImagePalette dd syscall_putimage_palette; 65-PutImagePalette
dd sys_process_def ; 66-Process definitions - keyboard dd sys_process_def ; 66-Process definitions - keyboard
dd sys_window_move ; 67-Window move or resize dd sys_window_move ; 67-Window move or resize
dd 0 ; 68-Some internal services dd 0
dd 0 ; 69-Debug dd 0
dd file_system_lfn ; 70-Common file system interface, version 2 dd file_system_lfn ; 70-Common file system interface, version 2
; dd 0 ; 71-Window settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW SYSTEM FUNCTIONS TABLE ;; ;; NEW SYSTEM FUNCTIONS TABLE ;;
@ -228,12 +227,12 @@ iglobal
dd sys_programirq ; 44-ProgramIrqs dd sys_programirq ; 44-ProgramIrqs
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
dd cross_order ; 47-WriteNum dd display_number ; 47-WriteNum
dd syscall_display_settings ; 48-SetRedrawType and SetButtonType dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
dd sys_apm ; 49-Advanced Power Management (APM) dd sys_apm ; 49-Advanced Power Management (APM)
dd cross_order ; 50-Window shape & scale dd syscall_set_window_shape ; 50-Window shape & scale
dd cross_order ; 51-Threads dd syscall_threads ; 51-Threads
dd cross_order ; 52-Stack driver status dd stack_driver_stat ; 52-Stack driver status
dd cross_order ; 53-Socket interface dd cross_order ; 53-Socket interface
dd undefined_syscall ; 54-reserved dd undefined_syscall ; 54-reserved
dd cross_order ; 55-Sound interface dd cross_order ; 55-Sound interface

View File

@ -864,15 +864,14 @@ proc new_sys_threads
app_mem dd ? ;0x10 app_mem dd ? ;0x10
endl endl
cmp eax,1 cmp ebx,1
jne .failed ;other subfunctions jne .failed ;other subfunctions
xor eax,eax xor eax,eax
mov [app_eip], ecx
mov [app_cmdline], eax mov [app_cmdline], eax
mov [app_esp], edx
mov [app_path], eax mov [app_path], eax
mov [app_eip], ebx
mov [app_esp], ecx
;mov esi,new_process_loading ;mov esi,new_process_loading
;call sys_msg_board_str ;call sys_msg_board_str
.wait_lock: .wait_lock:

View File

@ -246,23 +246,23 @@ align 4
syscall_set_window_shape: ;///// system function 50 /////////////////////////// syscall_set_window_shape: ;///// system function 50 ///////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;; Set window shape address: ;; Set window shape address:
;> eax = 0 ;> ebx = 0
;> ebx = shape data address ;> ecx = shape data address
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Set window shape scale: ;; Set window shape scale:
;> eax = 1 ;> ebx = 1
;> ebx = scale power (resulting scale is 2^ebx) ;> ecx = scale power (resulting scale is 2^ebx)
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
mov edi, [current_slot] mov edi, [current_slot]
test eax, eax test ebx, ebx
jne .shape_scale jne .shape_scale
mov [edi + APPDATA.wnd_shape], ebx mov [edi + APPDATA.wnd_shape], ecx
.shape_scale: .shape_scale:
dec eax dec ebx
jnz .exit jnz .exit
mov [edi + APPDATA.wnd_shape_scale], ebx mov [edi + APPDATA.wnd_shape_scale], ecx
.exit: .exit:
ret ret

View File

@ -1245,7 +1245,12 @@ sys_outport:
ret ret
display_number: display_number:
;It is not optimization
mov eax, ebx
mov ebx, ecx
mov ecx, edx
mov edx, esi
mov esi, edi
; eax = print type, al=0 -> ebx is number ; eax = print type, al=0 -> ebx is number
; al=1 -> ebx is pointer ; al=1 -> ebx is pointer
; ah=0 -> display decimal ; ah=0 -> display decimal
@ -5371,9 +5376,16 @@ syscall_reserveportarea: ; ReservePortArea and FreePortArea
align 4 align 4
syscall_threads: ; CreateThreads syscall_threads: ; CreateThreads
; eax=1 create thread
;
; ebx=thread start
; ecx=thread stack value
;
; on return : eax = pid
call sys_threads call new_sys_threads
mov [esp+36],eax
mov [esp+32],eax
ret ret
align 4 align 4
@ -5385,7 +5397,7 @@ stack_driver_stat:
; mov [check_idle_semaphore],5 ; enable these for zero delay ; mov [check_idle_semaphore],5 ; enable these for zero delay
; call change_task ; between sent packet ; call change_task ; between sent packet
mov [esp+36],eax mov [esp+32],eax
ret ret
align 4 align 4

View File

@ -361,27 +361,48 @@ cs_exit:
; It provides application access to the network interface layer ; It provides application access to the network interface layer
; ;
;*************************************************************************** ;***************************************************************************
iglobal
align 4
f52call:
dd app_stack_handler.00
dd app_stack_handler.01
dd app_stack_handler.02
dd app_stack_handler.03
dd app_stack_handler.fail ;04
dd app_stack_handler.fail ;05
dd stack_insert_packet ;app_stack_handler.06
dd app_stack_handler.fail ;07
dd stack_get_packet ;app_stack_handler.08
dd app_stack_handler.09
dd app_stack_handler.10
dd app_stack_handler.11
dd app_stack_handler.12
dd app_stack_handler.13
dd app_stack_handler.14
dd app_stack_handler.15
endg
app_stack_handler: app_stack_handler:
cmp eax, 0 ;in ebx,ecx
jnz not0 ;out eax
cmp ebx,15
ja .fail ;if more than 15 then exit
jmp dword [f52call+ebx*4]
.00:
; Read the configuration word ; Read the configuration word
mov eax, [stack_config] mov eax, [stack_config]
ret ret
not0: .01:
cmp eax, 1
jnz not1
; read the IP address ; read the IP address
mov eax, [stack_ip] mov eax, [stack_ip]
ret ret
not1: .02:
cmp eax, 2
jnz not2
; write the configuration word ; write the configuration word
mov [stack_config], ebx mov [stack_config], ecx
; <Slip shouldn't be active anyway - thats an operational issue.> ; <Slip shouldn't be active anyway - thats an operational issue.>
; If ethernet now enabled, probe for the card, reset it and empty ; If ethernet now enabled, probe for the card, reset it and empty
@ -391,155 +412,90 @@ not1:
; empty the tcpip data area too. ; empty the tcpip data area too.
; ethernet interface is '3' in ls 7 bits ; ethernet interface is '3' in ls 7 bits
and bl, 0x7f and cl, 0x7f
cmp bl, 3 cmp cl, 3
je ash_eth_enable je ash_eth_enable
; Ethernet isn't enabled, so make sure that the card is disabled ; Ethernet isn't enabled, so make sure that the card is disabled
mov [ethernet_active], byte 0 mov [ethernet_active], byte 0
ret ret
ash_eth_enable: .03:
; Probe for the card. This will reset it and enable the interface
; if found
call eth_probe
cmp eax, 0
je ash_eth_done ; Abort if no hardware found
mov [ethernet_active], byte 1
ash_eth_done:
ret
not2:
cmp eax, 3
jnz not3
; write the IP Address ; write the IP Address
mov [stack_ip], ebx mov [stack_ip], ecx
ret ret
;old functions was deleted ;old functions was deleted
;.06:
not3:
cmp eax, 6
jnz not6
; Insert an IP packet into the stacks received packet queue ; Insert an IP packet into the stacks received packet queue
call stack_insert_packet ; call stack_insert_packet
ret ; ret
not6:
cmp eax, 7
jnz not7
; Test for any packets queued for transmission over the network ; Test for any packets queued for transmission over the network
not7: ;.08:
cmp eax, 8 ; call stack_get_packet
jnz not8
call stack_get_packet
; Extract a packet queued for transmission by the network ; Extract a packet queued for transmission by the network
ret ; ret
not8:
cmp eax, 9
jnz not9
.09:
; read the gateway IP address ; read the gateway IP address
mov eax, [gateway_ip] mov eax, [gateway_ip]
ret ret
not9: .10:
cmp eax, 10
jnz not10
; read the subnet mask ; read the subnet mask
mov eax, [subnet_mask] mov eax, [subnet_mask]
ret ret
.11:
not10:
cmp eax, 11
jnz not11
; write the gateway IP Address ; write the gateway IP Address
mov [gateway_ip], ebx mov [gateway_ip], ecx
ret ret
not11: .12:
cmp eax, 12
jnz not12
; write the subnet mask ; write the subnet mask
mov [subnet_mask], ebx mov [subnet_mask], ecx
ret
not12:
cmp eax, 13
jnz not13
.13:
; read the dns ; read the dns
mov eax, [dns_ip] mov eax, [dns_ip]
ret ret
not13: .14:
cmp eax, 14
jnz not14
; write the dns IP Address ; write the dns IP Address
mov [dns_ip], ebx mov [dns_ip], ecx
ret ret
.15:
;<added by Frank Sommer> ;<added by Frank Sommer>
not14: ; in ecx we need 4 to read the last 2 bytes
cmp eax, 15
jnz not15
; in ebx we need 4 to read the last 2 bytes
cmp ebx, dword 4
je read
; or we need 0 to read the first 4 bytes ; or we need 0 to read the first 4 bytes
cmp ebx, dword 0 cmp ecx,4
jnz param_error ja .param_error
; read MAC, returned (in mirrored byte order) in eax ; read MAC, returned (in mirrored byte order) in eax
read: mov eax, [node_addr + ecx]
mov eax, [node_addr + ebx]
jmp @f
param_error:
mov eax, -1 ; params not accepted
@@:
ret ret
.param_error:
or eax, -1 ; params not accepted
ret
.16:
; 0 -> arp_probe ; 0 -> arp_probe
; 1 -> arp_announce ; 1 -> arp_announce
; 2 -> arp_responce (not supported yet) ; 2 -> arp_responce (not supported yet)
test ecx,ecx
not15: ; ARP stuff
cmp eax, 16
jnz not16
cmp ebx, 0
je a_probe je a_probe
cmp ebx, 1 dec ebx
je a_ann ; arp announce jz a_ann ; arp announce
.fail:
or eax, -1
ret
; cmp ebx,2 ; cmp ebx,2
; jne a_resp ; arp response ; jne a_resp ; arp response
jmp param15_error
; arp probe, sender IP must be set to 0.0.0.0, target IP is set to address being probed ; arp probe, sender IP must be set to 0.0.0.0, target IP is set to address being probed
; ecx: pointer to target MAC, MAC should set to 0 by application ; ecx: pointer to target MAC, MAC should set to 0 by application
; edx: target IP ; edx: target IP
@ -547,12 +503,12 @@ a_probe:
push dword [stack_ip] push dword [stack_ip]
mov edx, [stack_ip] mov edx, [stack_ip]
mov [stack_ip], dword 0 and [stack_ip], dword 0
mov esi, ecx ; pointer to target MAC address mov esi, ecx ; pointer to target MAC address
call arp_request call arp_request
pop dword [stack_ip] pop dword [stack_ip]
jmp @f ret
; arp announce, sender IP must be set to target IP ; arp announce, sender IP must be set to target IP
; ecx: pointer to target MAC ; ecx: pointer to target MAC
@ -560,33 +516,30 @@ a_ann:
mov edx, [stack_ip] mov edx, [stack_ip]
mov esi, ecx ; pointer to target MAC address mov esi, ecx ; pointer to target MAC address
call arp_request call arp_request
jmp @f
param15_error:
mov eax, -1
@@:
ret ret
.17:
;</added by Frank Sommer> ;</added by Frank Sommer>
; modified by [smb] ; modified by [smb]
;<added by Johnny_B> ;<added by Johnny_B>
; ARPTable manager interface ; ARPTable manager interface
not16:
cmp eax, 17
jnz stack_driver_end
;see "proc arp_table_manager" for more details ;see "proc arp_table_manager" for more details
stdcall arp_table_manager,ebx,ecx,edx ;Opcode,Index,Extra stdcall arp_table_manager,ecx,edx,esi ;Opcode,Index,Extra
ret ret
;</added by Johnny_B> ;</added by Johnny_B>
stack_driver_end: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ash_eth_enable:
; Probe for the card. This will reset it and enable the interface
; if found
call eth_probe
test eax,eax
jz ash_eth_done ; Abort if no hardware found
mov [ethernet_active], byte 1
ash_eth_done:
ret ret
;*************************************************************************** ;***************************************************************************
; Function ; Function
; app_socket_handler ; app_socket_handler
@ -597,110 +550,65 @@ stack_driver_end:
; such as opening sockets ; such as opening sockets
; ;
;*************************************************************************** ;***************************************************************************
iglobal
align 4
f53call:
dd socket_open ;00
dd socket_close ;01
dd socket_poll ;02
dd socket_read ;03
dd socket_write ;04
dd socket_open_tcp ;05
dd socket_status ;06
dd socket_write_tcp ;07
dd socket_close_tcp ;08
dd is_localport_unused ;09
dd app_socket_handler.10
dd socket_read_packet ;11
endg
app_socket_handler: app_socket_handler:
cmp eax, 0 ;in ebx,ecx,edx,wsi
jnz nots0 ;out eax
cmp eax,255
je stack_internal_status
call socket_open cmp eax,11
ret ja .fail ;if more than 15 then exit
nots0: jmp dword [f53call+eax*4]
cmp eax, 1
jnz nots1
call socket_close
ret
nots1:
cmp eax, 2
jnz nots2
call socket_poll
ret
nots2:
cmp eax, 3
jnz nots3
call socket_read
ret
nots3:
cmp eax, 4
jnz nots4
call socket_write
ret
nots4:
cmp eax, 5
jnz nots5
call socket_open_tcp
ret
nots5:
cmp eax, 6
jnz nots6
call socket_status
ret
nots6:
cmp eax, 7
jnz nots7
call socket_write_tcp
ret
nots7:
cmp eax, 8
jnz nots8
call socket_close_tcp
ret
nots8:
cmp eax, 9
jnz nots9
call is_localport_unused
ret
nots9:
cmp eax, 10
jnz nots10
.10:
mov eax,dword[drvr_cable] mov eax,dword[drvr_cable]
test eax,eax test eax,eax
jnz @f ; if function is not implented, return -1 jnz @f ; if function is not implented, return -1
mov al,-1 or al,-1
ret ret
@@: @@:
call dword[drvr_cable] jmp dword[drvr_cable]
.fail:
or eax,-1
ret ret
uglobal
ARPTmp:
times 14 db 0
endg
;***************************************************************************
nots10: ; Function
cmp eax, 11 ; stack_internal_status
jnz nots11 ;
; Description
call socket_read_packet ; Returns information about the internal status of the stack
ret ; This is only useful for debugging
; It works with the ethernet driver
nots11: ; sub function in ebx
cmp eax, 254 ; return requested data in eax
jnz notdump ;
;***************************************************************************
ret
notdump:
cmp eax, 255
jnz notsdebug
; This sub function allows access to debugging information on the stack ; This sub function allows access to debugging information on the stack
; ebx holds the request: ; ecx holds the request:
; 100 : return length of empty queue ; 100 : return length of empty queue
; 101 : return length of IPOUT QUEUE ; 101 : return length of IPOUT QUEUE
; 102 : return length of IPIN QUEUE ; 102 : return length of IPIN QUEUE
@ -722,31 +630,7 @@ notdump:
; 6 : return status of packet driver ; 6 : return status of packet driver
; ( 0 == not active, FFFFFFFF = successful ) ; ( 0 == not active, FFFFFFFF = successful )
call stack_internal_status
ret
notsdebug:
; Invalid Option
ret
uglobal
ARPTmp:
times 14 db 0
endg
;***************************************************************************
; Function
; stack_internal_status
;
; Description
; Returns information about the internal status of the stack
; This is only useful for debugging
; It works with the ethernet driver
; sub function in ebx
; return requested data in eax
;
;***************************************************************************
stack_internal_status: stack_internal_status:
cmp ebx, 100 cmp ebx, 100
jnz notsis100 jnz notsis100