forked from KolibriOS/kolibrios
acpi:update
git-svn-id: svn://kolibrios.org@3626 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
f2ab5a6e90
commit
61f55267ef
@ -335,8 +335,7 @@ disk_add:
|
|||||||
push ebx esi ; save used registers to be stdcall
|
push ebx esi ; save used registers to be stdcall
|
||||||
; 1. Allocate the DISK structure.
|
; 1. Allocate the DISK structure.
|
||||||
; 1a. Call the heap manager.
|
; 1a. Call the heap manager.
|
||||||
push sizeof.DISK
|
movi eax, sizeof.DISK
|
||||||
pop eax
|
|
||||||
call malloc
|
call malloc
|
||||||
; 1b. Check the result. If allocation failed, return (go to 9) with eax = 0.
|
; 1b. Check the result. If allocation failed, return (go to 9) with eax = 0.
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -608,15 +607,13 @@ disk_call_driver:
|
|||||||
|
|
||||||
; The default implementation of DISKFUNC.querymedia.
|
; The default implementation of DISKFUNC.querymedia.
|
||||||
disk_default_querymedia:
|
disk_default_querymedia:
|
||||||
push DISK_STATUS_INVALID_CALL
|
movi eax, DISK_STATUS_INVALID_CALL
|
||||||
pop eax
|
|
||||||
ret 8
|
ret 8
|
||||||
|
|
||||||
; The default implementation of DISKFUNC.read and DISKFUNC.write.
|
; The default implementation of DISKFUNC.read and DISKFUNC.write.
|
||||||
disk_default_read:
|
disk_default_read:
|
||||||
disk_default_write:
|
disk_default_write:
|
||||||
push DISK_STATUS_INVALID_CALL
|
movi eax, DISK_STATUS_INVALID_CALL
|
||||||
pop eax
|
|
||||||
ret 20
|
ret 20
|
||||||
|
|
||||||
; The default implementation of DISKFUNC.close, DISKFUNC.closemedia and
|
; The default implementation of DISKFUNC.close, DISKFUNC.closemedia and
|
||||||
@ -1002,8 +999,7 @@ end virtual
|
|||||||
jnz .success
|
jnz .success
|
||||||
; 3. No file system has recognized the volume, so just allocate the PARTITION
|
; 3. No file system has recognized the volume, so just allocate the PARTITION
|
||||||
; structure without extra fields.
|
; structure without extra fields.
|
||||||
push sizeof.PARTITION
|
movi eax, sizeof.PARTITION
|
||||||
pop eax
|
|
||||||
call malloc
|
call malloc
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nothing
|
jz .nothing
|
||||||
|
@ -1252,8 +1252,7 @@ fat_gen_short_name:
|
|||||||
stosd
|
stosd
|
||||||
pop edi
|
pop edi
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
push 8
|
movi ebx, 8
|
||||||
pop ebx
|
|
||||||
lea ecx, [edi+8]
|
lea ecx, [edi+8]
|
||||||
.loop:
|
.loop:
|
||||||
lodsb
|
lodsb
|
||||||
@ -1538,8 +1537,7 @@ fs_RamdiskRewrite:
|
|||||||
push ecx edi
|
push ecx edi
|
||||||
mov ecx, 8
|
mov ecx, 8
|
||||||
repnz scasb
|
repnz scasb
|
||||||
push 1
|
movi eax, 1 ; 1 entry
|
||||||
pop eax ; 1 entry
|
|
||||||
jnz .notilde
|
jnz .notilde
|
||||||
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total
|
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -1764,8 +1762,7 @@ fs_RamdiskRewrite:
|
|||||||
add esp, 20
|
add esp, 20
|
||||||
mov [esp+16], ebx
|
mov [esp+16], ebx
|
||||||
popad
|
popad
|
||||||
push ERROR_DISK_FULL
|
movi eax, ERROR_DISK_FULL
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
.writedir:
|
.writedir:
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
@ -1957,8 +1954,7 @@ ramdisk_extend_file:
|
|||||||
jb @b
|
jb @b
|
||||||
.fat_err:
|
.fat_err:
|
||||||
pop ecx
|
pop ecx
|
||||||
push ERROR_FAT_TABLE
|
movi eax, ERROR_FAT_TABLE
|
||||||
pop eax
|
|
||||||
stc
|
stc
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
@ -2033,8 +2029,7 @@ ramdisk_extend_file:
|
|||||||
pop edi ecx
|
pop edi ecx
|
||||||
pop esi edx
|
pop esi edx
|
||||||
stc
|
stc
|
||||||
push ERROR_DISK_FULL
|
movi eax, ERROR_DISK_FULL
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
fat_update_datetime:
|
fat_update_datetime:
|
||||||
|
@ -50,8 +50,7 @@ real_start:
|
|||||||
; get file system information
|
; get file system information
|
||||||
; scan for Primary Volume Descriptor
|
; scan for Primary Volume Descriptor
|
||||||
db 66h
|
db 66h
|
||||||
push 10h-1
|
movi eax, 10h-1
|
||||||
pop eax
|
|
||||||
pvd_scan_loop:
|
pvd_scan_loop:
|
||||||
mov cx, 1
|
mov cx, 1
|
||||||
inc eax
|
inc eax
|
||||||
|
@ -680,8 +680,7 @@ end virtual
|
|||||||
jmp .no_device
|
jmp .no_device
|
||||||
.has_device:
|
.has_device:
|
||||||
push eax
|
push eax
|
||||||
push sizeof.PCIDEV
|
movi eax, sizeof.PCIDEV
|
||||||
pop eax
|
|
||||||
call malloc
|
call malloc
|
||||||
pop ecx
|
pop ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
|
@ -330,8 +330,7 @@ end if
|
|||||||
; 2b. Fill first 32 entries.
|
; 2b. Fill first 32 entries.
|
||||||
inc eax
|
inc eax
|
||||||
inc eax ; set Type to EHCI_TYPE_QH
|
inc eax ; set Type to EHCI_TYPE_QH
|
||||||
push 32
|
movi ecx, 32
|
||||||
pop ecx
|
|
||||||
mov edx, ecx
|
mov edx, ecx
|
||||||
@@:
|
@@:
|
||||||
stosd
|
stosd
|
||||||
@ -434,14 +433,12 @@ end if
|
|||||||
; now edi = MMIOBase2
|
; now edi = MMIOBase2
|
||||||
; 6. Transfer the controller to a known state.
|
; 6. Transfer the controller to a known state.
|
||||||
; 6b. Stop the controller if it is running.
|
; 6b. Stop the controller if it is running.
|
||||||
push 10
|
movi ecx, 10
|
||||||
pop ecx
|
|
||||||
test dword [edi+EhciStatusReg], 1 shl 12
|
test dword [edi+EhciStatusReg], 1 shl 12
|
||||||
jnz .stopped
|
jnz .stopped
|
||||||
and dword [edi+EhciCommandReg], not 1
|
and dword [edi+EhciCommandReg], not 1
|
||||||
@@:
|
@@:
|
||||||
push 1
|
movi esi, 1
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
test dword [edi+EhciStatusReg], 1 shl 12
|
test dword [edi+EhciStatusReg], 1 shl 12
|
||||||
jnz .stopped
|
jnz .stopped
|
||||||
@ -451,11 +448,9 @@ end if
|
|||||||
.stopped:
|
.stopped:
|
||||||
; 6c. Reset the controller. Wait up to 50 ms checking status every 1 ms.
|
; 6c. Reset the controller. Wait up to 50 ms checking status every 1 ms.
|
||||||
or dword [edi+EhciCommandReg], 2
|
or dword [edi+EhciCommandReg], 2
|
||||||
push 50
|
movi ecx, 50
|
||||||
pop ecx
|
|
||||||
@@:
|
@@:
|
||||||
push 1
|
movi esi, 1
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
test dword [edi+EhciCommandReg], 2
|
test dword [edi+EhciCommandReg], 2
|
||||||
jz .reset_ok
|
jz .reset_ok
|
||||||
@ -515,8 +510,7 @@ end if
|
|||||||
test byte [esi+ehci_controller.StructuralParams-sizeof.ehci_controller], 10h
|
test byte [esi+ehci_controller.StructuralParams-sizeof.ehci_controller], 10h
|
||||||
jz @f
|
jz @f
|
||||||
push esi
|
push esi
|
||||||
push 20
|
movi esi, 20
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
pop esi
|
pop esi
|
||||||
@@:
|
@@:
|
||||||
@ -676,8 +670,7 @@ proc ehci_kickoff_bios
|
|||||||
test al, 1
|
test al, 1
|
||||||
jz .has_ownership
|
jz .has_ownership
|
||||||
push esi
|
push esi
|
||||||
push 1
|
movi esi, 1
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
pop esi
|
pop esi
|
||||||
dec dword [esp]
|
dec dword [esp]
|
||||||
@ -862,8 +855,7 @@ end virtual
|
|||||||
push eax ecx
|
push eax ecx
|
||||||
sub edi, ehci_pipe.SoftwarePart
|
sub edi, ehci_pipe.SoftwarePart
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
push ehci_pipe.SoftwarePart/4
|
movi ecx, ehci_pipe.SoftwarePart/4
|
||||||
pop ecx
|
|
||||||
rep stosd
|
rep stosd
|
||||||
pop ecx eax
|
pop ecx eax
|
||||||
; 2. Setup PID in the first TD and make sure that the it is not active.
|
; 2. Setup PID in the first TD and make sure that the it is not active.
|
||||||
@ -883,8 +875,7 @@ end virtual
|
|||||||
and eax, 3FFF0000h
|
and eax, 3FFF0000h
|
||||||
; Use 1 requests per microframe for control/bulk endpoints,
|
; Use 1 requests per microframe for control/bulk endpoints,
|
||||||
; use value from the endpoint descriptor for periodic endpoints
|
; use value from the endpoint descriptor for periodic endpoints
|
||||||
push 1
|
movi edx, 1
|
||||||
pop edx
|
|
||||||
test [.type], 1
|
test [.type], 1
|
||||||
jz @f
|
jz @f
|
||||||
mov edx, [.maxpacket]
|
mov edx, [.maxpacket]
|
||||||
@ -1292,8 +1283,7 @@ proc ehci_port_init
|
|||||||
@@:
|
@@:
|
||||||
; 3. Call the worker procedure to notify the protocol layer
|
; 3. Call the worker procedure to notify the protocol layer
|
||||||
; about new EHCI device. It is high-speed.
|
; about new EHCI device. It is high-speed.
|
||||||
push USB_SPEED_HS
|
movi eax, USB_SPEED_HS
|
||||||
pop eax
|
|
||||||
call ehci_new_device
|
call ehci_new_device
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz .nothing
|
jnz .nothing
|
||||||
@ -1794,8 +1784,7 @@ proc ehci_process_updated_td
|
|||||||
; all corresponding bits are set. In this case, return some error code,
|
; all corresponding bits are set. In this case, return some error code,
|
||||||
; the order is quite arbitrary.
|
; the order is quite arbitrary.
|
||||||
pop eax ; status
|
pop eax ; status
|
||||||
push USB_STATUS_UNDERRUN
|
movi ecx, USB_STATUS_UNDERRUN
|
||||||
pop ecx
|
|
||||||
test al, 40h ; not Halted?
|
test al, 40h ; not Halted?
|
||||||
jz .know_error
|
jz .know_error
|
||||||
mov cl, USB_STATUS_OVERRUN
|
mov cl, USB_STATUS_OVERRUN
|
||||||
|
@ -398,8 +398,7 @@ proc usb_process_wait_lists
|
|||||||
jnc @f
|
jnc @f
|
||||||
or byte [esp], 1 shl CONTROL_PIPE
|
or byte [esp], 1 shl CONTROL_PIPE
|
||||||
@@:
|
@@:
|
||||||
push 4
|
movi edx, 4
|
||||||
pop edx
|
|
||||||
call usb_process_one_wait_list
|
call usb_process_one_wait_list
|
||||||
jnc @f
|
jnc @f
|
||||||
or byte [esp], 1 shl INTERRUPT_PIPE
|
or byte [esp], 1 shl INTERRUPT_PIPE
|
||||||
|
@ -253,8 +253,7 @@ end virtual
|
|||||||
; 2a. Save registers.
|
; 2a. Save registers.
|
||||||
push edx
|
push edx
|
||||||
; 2b. Call the allocator.
|
; 2b. Call the allocator.
|
||||||
push 40
|
movi eax, 40
|
||||||
pop eax
|
|
||||||
call malloc
|
call malloc
|
||||||
; 2c. Restore registers.
|
; 2c. Restore registers.
|
||||||
pop ecx
|
pop ecx
|
||||||
|
@ -131,8 +131,7 @@ endg
|
|||||||
proc create_usb_thread
|
proc create_usb_thread
|
||||||
; 1. Create the thread.
|
; 1. Create the thread.
|
||||||
push edi
|
push edi
|
||||||
push 1
|
movi ebx, 1
|
||||||
pop ebx
|
|
||||||
mov ecx, usb_thread_proc
|
mov ecx, usb_thread_proc
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
|
@ -351,8 +351,7 @@ end if
|
|||||||
lea esi, [eax+ohci_controller.IntEDs+32*sizeof.ohci_static_ep]
|
lea esi, [eax+ohci_controller.IntEDs+32*sizeof.ohci_static_ep]
|
||||||
call get_pg_addr
|
call get_pg_addr
|
||||||
add eax, ohci_controller.IntEDs
|
add eax, ohci_controller.IntEDs
|
||||||
push 32
|
movi ecx, 32
|
||||||
pop ecx
|
|
||||||
mov edx, ecx
|
mov edx, ecx
|
||||||
@@:
|
@@:
|
||||||
stosd
|
stosd
|
||||||
@ -429,10 +428,8 @@ end if
|
|||||||
; 5c. Save FmInterval register.
|
; 5c. Save FmInterval register.
|
||||||
pushd [edi+OhciFmIntervalReg]
|
pushd [edi+OhciFmIntervalReg]
|
||||||
; 5d. Issue software reset and wait up to 10ms, checking status every 1 ms.
|
; 5d. Issue software reset and wait up to 10ms, checking status every 1 ms.
|
||||||
push 1
|
movi ecx, 1
|
||||||
pop ecx
|
movi edx, 10
|
||||||
push 10
|
|
||||||
pop edx
|
|
||||||
mov [edi+OhciCommandStatusReg], ecx
|
mov [edi+OhciCommandStatusReg], ecx
|
||||||
@@:
|
@@:
|
||||||
mov esi, ecx
|
mov esi, ecx
|
||||||
@ -633,14 +630,12 @@ proc ohci_kickoff_bios
|
|||||||
; (This should generate SMI, BIOS should release its ownership in SMI handler.)
|
; (This should generate SMI, BIOS should release its ownership in SMI handler.)
|
||||||
mov dword [eax+OhciCommandStatusReg], 8
|
mov dword [eax+OhciCommandStatusReg], 8
|
||||||
; 4c. Wait for result no more than 50 ms, checking for status every 1 ms.
|
; 4c. Wait for result no more than 50 ms, checking for status every 1 ms.
|
||||||
push 50
|
movi ecx, 50
|
||||||
pop ecx
|
|
||||||
@@:
|
@@:
|
||||||
test dword [eax+OhciControlReg], edx
|
test dword [eax+OhciControlReg], edx
|
||||||
jz .has_ownership
|
jz .has_ownership
|
||||||
push esi
|
push esi
|
||||||
push 1
|
movi esi, 1
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
pop esi
|
pop esi
|
||||||
loop @b
|
loop @b
|
||||||
@ -984,8 +979,7 @@ end virtual
|
|||||||
; if so, return an error.
|
; if so, return an error.
|
||||||
lea edx, [esi + ohci_controller.IntEDs - sizeof.ohci_controller]
|
lea edx, [esi + ohci_controller.IntEDs - sizeof.ohci_controller]
|
||||||
lea eax, [esi + ohci_controller.IntEDs + 32*sizeof.ohci_static_ep - sizeof.ohci_controller]
|
lea eax, [esi + ohci_controller.IntEDs + 32*sizeof.ohci_static_ep - sizeof.ohci_controller]
|
||||||
push 64
|
movi ecx, 64
|
||||||
pop ecx
|
|
||||||
call usb1_select_interrupt_list
|
call usb1_select_interrupt_list
|
||||||
test edx, edx
|
test edx, edx
|
||||||
jz .return0
|
jz .return0
|
||||||
|
@ -206,8 +206,7 @@ end virtual
|
|||||||
sub ecx, 3
|
sub ecx, 3
|
||||||
cmp ecx, 5 ; maximum 32ms
|
cmp ecx, 5 ; maximum 32ms
|
||||||
jbe @f
|
jbe @f
|
||||||
push 5
|
movi ecx, 5
|
||||||
pop ecx
|
|
||||||
@@:
|
@@:
|
||||||
; There are four nested loops,
|
; There are four nested loops,
|
||||||
; * Loop #4 (the innermost one) calculates the total periodic bandwidth
|
; * Loop #4 (the innermost one) calculates the total periodic bandwidth
|
||||||
@ -221,10 +220,8 @@ end virtual
|
|||||||
; ebx = number of iterations of loop #1
|
; ebx = number of iterations of loop #1
|
||||||
; [esp] = delta of counter for loop #3, in bytes
|
; [esp] = delta of counter for loop #3, in bytes
|
||||||
; [esp+4] = delta between the first group and the target group, in bytes
|
; [esp+4] = delta between the first group and the target group, in bytes
|
||||||
push 1
|
movi ebx, 1
|
||||||
pop ebx
|
movi edx, sizeof.ehci_static_ep
|
||||||
push sizeof.ehci_static_ep
|
|
||||||
pop edx
|
|
||||||
shl ebx, cl
|
shl ebx, cl
|
||||||
shl edx, cl
|
shl edx, cl
|
||||||
mov eax, 64*sizeof.ehci_static_ep
|
mov eax, 64*sizeof.ehci_static_ep
|
||||||
@ -282,8 +279,7 @@ end virtual
|
|||||||
ja @f
|
ja @f
|
||||||
mov [.bandwidth], edi
|
mov [.bandwidth], edi
|
||||||
mov [.target], edx
|
mov [.target], edx
|
||||||
push 1
|
movi eax, 1
|
||||||
pop eax
|
|
||||||
shl eax, cl
|
shl eax, cl
|
||||||
mov [.targetsmask], eax
|
mov [.targetsmask], eax
|
||||||
@@:
|
@@:
|
||||||
@ -317,8 +313,7 @@ end virtual
|
|||||||
mov ecx, [.targetsmask]
|
mov ecx, [.targetsmask]
|
||||||
add [edx+ehci_static_ep.Bandwidths+ecx*2], ax
|
add [edx+ehci_static_ep.Bandwidths+ecx*2], ax
|
||||||
add edx, ehci_static_ep.SoftwarePart
|
add edx, ehci_static_ep.SoftwarePart
|
||||||
push 1
|
movi eax, 1
|
||||||
pop eax
|
|
||||||
shl eax, cl
|
shl eax, cl
|
||||||
pop edi ebx ; restore used registers to be stdcall
|
pop edi ebx ; restore used registers to be stdcall
|
||||||
ret
|
ret
|
||||||
@ -371,8 +366,7 @@ virtual at esp
|
|||||||
end virtual
|
end virtual
|
||||||
; 10. Select the best variant.
|
; 10. Select the best variant.
|
||||||
; edx = S-Mask = bitmask of scheduled microframes
|
; edx = S-Mask = bitmask of scheduled microframes
|
||||||
push 0x11
|
movi edx, 0x11
|
||||||
pop edx
|
|
||||||
cmp ecx, 1
|
cmp ecx, 1
|
||||||
ja @f
|
ja @f
|
||||||
mov dl, 0x55
|
mov dl, 0x55
|
||||||
|
@ -315,8 +315,7 @@ end if
|
|||||||
; 2b. Fill first 32 entries.
|
; 2b. Fill first 32 entries.
|
||||||
inc eax
|
inc eax
|
||||||
inc eax ; set QH bit for uhci_pipe.NextQH
|
inc eax ; set QH bit for uhci_pipe.NextQH
|
||||||
push 32
|
movi ecx, 32
|
||||||
pop ecx
|
|
||||||
mov edx, ecx
|
mov edx, ecx
|
||||||
@@:
|
@@:
|
||||||
stosd
|
stosd
|
||||||
@ -416,12 +415,10 @@ end if
|
|||||||
mov ax, 2
|
mov ax, 2
|
||||||
out dx, ax
|
out dx, ax
|
||||||
; 5f. Wait up to 10ms.
|
; 5f. Wait up to 10ms.
|
||||||
push 10
|
movi ecx, 10
|
||||||
pop ecx
|
|
||||||
@@:
|
@@:
|
||||||
push esi
|
push esi
|
||||||
push 1
|
movi esi, 1
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
pop esi
|
pop esi
|
||||||
in ax, dx
|
in ax, dx
|
||||||
@ -435,8 +432,7 @@ if 0
|
|||||||
; emergency variant for tests - always wait 10 ms
|
; emergency variant for tests - always wait 10 ms
|
||||||
; wait 10 ms
|
; wait 10 ms
|
||||||
push esi
|
push esi
|
||||||
push 10
|
movi esi, 10
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
pop esi
|
pop esi
|
||||||
; clear reset signal
|
; clear reset signal
|
||||||
@ -998,8 +994,7 @@ end if
|
|||||||
; * if several non-fatal errors have occured during transaction retries,
|
; * if several non-fatal errors have occured during transaction retries,
|
||||||
; all corresponding bits are set. In this case, return some error code,
|
; all corresponding bits are set. In this case, return some error code,
|
||||||
; the order is quite arbitrary.
|
; the order is quite arbitrary.
|
||||||
push USB_STATUS_UNDERRUN
|
movi ecx, USB_STATUS_UNDERRUN
|
||||||
pop ecx
|
|
||||||
test al, 1 shl (22-16) ; not Stalled?
|
test al, 1 shl (22-16) ; not Stalled?
|
||||||
jz .know_error
|
jz .know_error
|
||||||
mov cl, USB_STATUS_OVERRUN
|
mov cl, USB_STATUS_OVERRUN
|
||||||
@ -1260,8 +1255,7 @@ proc uhci_port_reset_done
|
|||||||
; 2. Status bits in UHCI are invalid during reset signalling.
|
; 2. Status bits in UHCI are invalid during reset signalling.
|
||||||
; Wait a millisecond while status bits become valid again.
|
; Wait a millisecond while status bits become valid again.
|
||||||
push esi
|
push esi
|
||||||
push 1
|
movi esi, 1
|
||||||
pop esi
|
|
||||||
call delay_ms
|
call delay_ms
|
||||||
pop esi
|
pop esi
|
||||||
; 3. ConnectStatus bit is zero during reset and becomes 1 during step 2;
|
; 3. ConnectStatus bit is zero during reset and becomes 1 during step 2;
|
||||||
@ -1458,8 +1452,7 @@ end virtual
|
|||||||
; if so, return an error.
|
; if so, return an error.
|
||||||
lea edx, [esi + uhci_controller.IntEDs - sizeof.uhci_controller]
|
lea edx, [esi + uhci_controller.IntEDs - sizeof.uhci_controller]
|
||||||
lea eax, [esi + uhci_controller.IntEDs + 32*sizeof.uhci_static_ep - sizeof.uhci_controller]
|
lea eax, [esi + uhci_controller.IntEDs + 32*sizeof.uhci_static_ep - sizeof.uhci_controller]
|
||||||
push 64
|
movi ecx, 64
|
||||||
pop ecx
|
|
||||||
call usb1_select_interrupt_list
|
call usb1_select_interrupt_list
|
||||||
test edx, edx
|
test edx, edx
|
||||||
jz .return0
|
jz .return0
|
||||||
|
@ -66,7 +66,7 @@ iglobal
|
|||||||
szLoadCursor db 'LoadCursor',0
|
szLoadCursor db 'LoadCursor',0
|
||||||
|
|
||||||
szSysMsgBoardStr db 'SysMsgBoardStr', 0
|
szSysMsgBoardStr db 'SysMsgBoardStr', 0
|
||||||
szSysMsgBoardChar db 'SysMsgBoardChar', 0
|
szSysMsgBoard db 'SysMsgBoard', 0
|
||||||
szGetCurrentTask db 'GetCurrentTask',0
|
szGetCurrentTask db 'GetCurrentTask',0
|
||||||
szLFBAddress db 'LFBAddress',0
|
szLFBAddress db 'LFBAddress',0
|
||||||
szLoadFile db 'LoadFile',0
|
szLoadFile db 'LoadFile',0
|
||||||
@ -163,7 +163,7 @@ kernel_export:
|
|||||||
dd szLoadCursor , load_cursor ;stdcall
|
dd szLoadCursor , load_cursor ;stdcall
|
||||||
|
|
||||||
dd szSysMsgBoardStr , sys_msg_board_str
|
dd szSysMsgBoardStr , sys_msg_board_str
|
||||||
dd szSysMsgBoardChar , sys_msg_board
|
dd szSysMsgBoard , sys_msg_board
|
||||||
dd szGetCurrentTask , get_curr_task
|
dd szGetCurrentTask , get_curr_task
|
||||||
dd szLoadFile , load_file ;retval eax, ebx
|
dd szLoadFile , load_file ;retval eax, ebx
|
||||||
dd szSendEvent , send_event ;see EVENT.inc for specification
|
dd szSendEvent , send_event ;see EVENT.inc for specification
|
||||||
|
@ -273,6 +273,12 @@ align 16
|
|||||||
mov ecx, ebp
|
mov ecx, ebp
|
||||||
call irq_eoi
|
call irq_eoi
|
||||||
|
|
||||||
|
; IRQ handler could make some kernel thread ready; reschedule
|
||||||
|
mov bl, SCHEDULE_HIGHER_PRIORITY
|
||||||
|
call find_next_task
|
||||||
|
jz .return ; if there is only one running process
|
||||||
|
call do_change_task
|
||||||
|
.return:
|
||||||
restore_ring3_context
|
restore_ring3_context
|
||||||
add esp, 4
|
add esp, 4
|
||||||
iret
|
iret
|
||||||
|
@ -31,6 +31,7 @@ irq0:
|
|||||||
call irq_eoi
|
call irq_eoi
|
||||||
; btr dword[DONT_SWITCH], 0
|
; btr dword[DONT_SWITCH], 0
|
||||||
; jc .return
|
; jc .return
|
||||||
|
mov bl, SCHEDULE_ANY_PRIORITY
|
||||||
call find_next_task
|
call find_next_task
|
||||||
jz .return ; if there is only one running process
|
jz .return ; if there is only one running process
|
||||||
call do_change_task
|
call do_change_task
|
||||||
@ -58,6 +59,7 @@ if 0
|
|||||||
.find_next_task:
|
.find_next_task:
|
||||||
; \end{Mario79}
|
; \end{Mario79}
|
||||||
end if
|
end if
|
||||||
|
mov bl, SCHEDULE_ANY_PRIORITY
|
||||||
call find_next_task
|
call find_next_task
|
||||||
jz .return ; the same task -> skip switch
|
jz .return ; the same task -> skip switch
|
||||||
@@:
|
@@:
|
||||||
@ -324,8 +326,16 @@ proc scheduler_remove_thread
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
SCHEDULE_ANY_PRIORITY = 0
|
||||||
|
SCHEDULE_HIGHER_PRIORITY = 1
|
||||||
;info:
|
;info:
|
||||||
; Find next task to execute
|
; Find next task to execute
|
||||||
|
;in:
|
||||||
|
; bl = SCHEDULE_ANY_PRIORITY:
|
||||||
|
; consider threads with any priority
|
||||||
|
; bl = SCHEDULE_HIGHER_PRIORITY:
|
||||||
|
; consider only threads with strictly higher priority than the current one,
|
||||||
|
; keep running the current thread if other ready threads have the same or lower priority
|
||||||
;retval:
|
;retval:
|
||||||
; ebx = address of the APPDATA for the selected task (slot-base)
|
; ebx = address of the APPDATA for the selected task (slot-base)
|
||||||
; edi = address of the TASKDATA for the selected task
|
; edi = address of the TASKDATA for the selected task
|
||||||
@ -337,6 +347,18 @@ endp
|
|||||||
proc find_next_task
|
proc find_next_task
|
||||||
call update_counters
|
call update_counters
|
||||||
spin_lock_irqsave SchedulerLock
|
spin_lock_irqsave SchedulerLock
|
||||||
|
push NR_SCHED_QUEUES
|
||||||
|
; If bl == SCHEDULE_ANY_PRIORITY = 0, loop over all NR_SCHED lists.
|
||||||
|
; Otherwise, loop over first [APPDATA.priority] lists.
|
||||||
|
test bl, bl
|
||||||
|
jz .start
|
||||||
|
mov ebx, [current_slot]
|
||||||
|
mov edi, [TASK_BASE]
|
||||||
|
mov eax, [ebx+APPDATA.priority]
|
||||||
|
test eax, eax
|
||||||
|
jz .unlock_found
|
||||||
|
mov [esp], eax
|
||||||
|
.start:
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
.priority_loop:
|
.priority_loop:
|
||||||
mov ebx, [scheduler_current+ecx*4]
|
mov ebx, [scheduler_current+ecx*4]
|
||||||
@ -370,6 +392,18 @@ proc find_next_task
|
|||||||
mov [edi+TASKDATA.state], 0
|
mov [edi+TASKDATA.state], 0
|
||||||
.task_found:
|
.task_found:
|
||||||
mov [scheduler_current+ecx*4], ebx
|
mov [scheduler_current+ecx*4], ebx
|
||||||
|
; If we have selected a thread with higher priority
|
||||||
|
; AND rescheduling is due to IRQ,
|
||||||
|
; turn the current scheduler list one entry back,
|
||||||
|
; so the current thread will be next after high-priority thread is done.
|
||||||
|
mov ecx, [esp]
|
||||||
|
cmp ecx, NR_SCHED_QUEUES
|
||||||
|
jz .unlock_found
|
||||||
|
mov eax, [current_slot]
|
||||||
|
mov eax, [eax+APPDATA.in_schedule.prev]
|
||||||
|
mov [scheduler_current+ecx*4], eax
|
||||||
|
.unlock_found:
|
||||||
|
pop ecx
|
||||||
spin_unlock_irqrestore SchedulerLock
|
spin_unlock_irqrestore SchedulerLock
|
||||||
.found:
|
.found:
|
||||||
mov [CURRENT_TASK], bh
|
mov [CURRENT_TASK], bh
|
||||||
@ -383,10 +417,11 @@ proc find_next_task
|
|||||||
jnz .task_loop
|
jnz .task_loop
|
||||||
.priority_next:
|
.priority_next:
|
||||||
inc ecx
|
inc ecx
|
||||||
cmp ecx, NR_SCHED_QUEUES
|
cmp ecx, [esp]
|
||||||
jb .priority_loop
|
jb .priority_loop
|
||||||
hlt
|
mov ebx, [current_slot]
|
||||||
jmp $-1
|
mov edi, [TASK_BASE]
|
||||||
|
jmp .unlock_found
|
||||||
endp
|
endp
|
||||||
|
|
||||||
if 0
|
if 0
|
||||||
|
@ -160,7 +160,11 @@ exc_c: ; исключения (все, кроме 7-г
|
|||||||
;mov edx, [TASK_BASE]
|
;mov edx, [TASK_BASE]
|
||||||
mov [edx + TASKDATA.state], byte 4 ; terminate
|
mov [edx + TASKDATA.state], byte 4 ; terminate
|
||||||
call wakeup_osloop
|
call wakeup_osloop
|
||||||
jmp change_task ; stack - here it does not matter at all, SEE: core/shed.inc
|
call change_task
|
||||||
|
; If we're here, then the main OS thread has crashed before initializing IDLE thread.
|
||||||
|
; Or they both have crashed. Anyway, things are hopelessly broken.
|
||||||
|
hlt
|
||||||
|
jmp $-1
|
||||||
.debug:
|
.debug:
|
||||||
; we are debugged process, notify debugger and suspend ourself
|
; we are debugged process, notify debugger and suspend ourself
|
||||||
; eax=debugger PID
|
; eax=debugger PID
|
||||||
@ -504,8 +508,7 @@ terminate: ; terminate application
|
|||||||
mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot]
|
mov eax, [SLOT_BASE+edi*8+APPDATA.debugger_slot]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nodebug
|
jz .nodebug
|
||||||
push 8
|
movi ecx, 8
|
||||||
pop ecx
|
|
||||||
push dword [CURRENT_TASK+edi+TASKDATA.pid]; PID
|
push dword [CURRENT_TASK+edi+TASKDATA.pid]; PID
|
||||||
push 2
|
push 2
|
||||||
call debugger_notify
|
call debugger_notify
|
||||||
|
@ -121,8 +121,8 @@ iglobal
|
|||||||
dd 0
|
dd 0
|
||||||
dd 0
|
dd 0
|
||||||
dd 0
|
dd 0
|
||||||
dd 0 ; 62-PCI functions
|
dd 0
|
||||||
dd sys_msg_board ; 63-System message board
|
dd 0
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; NEW SYSTEM FUNCTIONS TABLE ;;
|
;; NEW SYSTEM FUNCTIONS TABLE ;;
|
||||||
@ -192,8 +192,8 @@ iglobal
|
|||||||
dd undefined_syscall ; 59-reserved
|
dd undefined_syscall ; 59-reserved
|
||||||
dd sys_IPC ; 60-Inter Process Communication
|
dd sys_IPC ; 60-Inter Process Communication
|
||||||
dd sys_gs ; 61-Direct graphics access
|
dd sys_gs ; 61-Direct graphics access
|
||||||
dd pci_api ;cross_order ; 62-PCI functions
|
dd pci_api ; 62-PCI functions
|
||||||
dd cross_order ; 63-System message board
|
dd sys_msg_board ; 63-System message board
|
||||||
dd sys_resize_app_memory ; 64-Resize application memory usage
|
dd sys_resize_app_memory ; 64-Resize application memory usage
|
||||||
dd sys_putimage_palette ; 65-PutImagePalette
|
dd sys_putimage_palette ; 65-PutImagePalette
|
||||||
dd sys_process_def ; 66-Process definitions - keyboard
|
dd sys_process_def ; 66-Process definitions - keyboard
|
||||||
|
@ -82,8 +82,7 @@ proc timer_hs stdcall uses ebx, deltaStart:dword, interval:dword, \
|
|||||||
timerFunc:dword, userData:dword
|
timerFunc:dword, userData:dword
|
||||||
; 1. Allocate memory for the TIMER structure.
|
; 1. Allocate memory for the TIMER structure.
|
||||||
; 1a. Call the allocator.
|
; 1a. Call the allocator.
|
||||||
push sizeof.TIMER
|
movi eax, sizeof.TIMER
|
||||||
pop eax
|
|
||||||
call malloc
|
call malloc
|
||||||
; 1b. If allocation failed, return (go to 5) with eax = 0.
|
; 1b. If allocation failed, return (go to 5) with eax = 0.
|
||||||
test eax, eax
|
test eax, eax
|
||||||
|
@ -323,6 +323,8 @@ tls_data_l:
|
|||||||
endofcode:
|
endofcode:
|
||||||
gdte:
|
gdte:
|
||||||
|
|
||||||
|
diff16 "end of .data segment",0,$
|
||||||
|
|
||||||
align 16
|
align 16
|
||||||
cur_saved_data:
|
cur_saved_data:
|
||||||
rb 4096
|
rb 4096
|
||||||
@ -336,6 +338,7 @@ mem_hash_cnt rd 64
|
|||||||
MEM_AMOUNT rd 1
|
MEM_AMOUNT rd 1
|
||||||
|
|
||||||
cpu_freq rq 1
|
cpu_freq rq 1
|
||||||
|
|
||||||
heap_mutex MUTEX
|
heap_mutex MUTEX
|
||||||
heap_size rd 1
|
heap_size rd 1
|
||||||
heap_free rd 1
|
heap_free rd 1
|
||||||
@ -365,18 +368,24 @@ _display display_t
|
|||||||
_WinMapAddress rd 1
|
_WinMapAddress rd 1
|
||||||
_WinMapSize rd 1
|
_WinMapSize rd 1
|
||||||
|
|
||||||
|
LFBAddress rd 1
|
||||||
Screen_Max_X rd 1
|
Screen_Max_X rd 1
|
||||||
Screen_Max_Y rd 1
|
Screen_Max_Y rd 1
|
||||||
|
|
||||||
LFBAddress rd 1
|
|
||||||
BytesPerScanLine rd 1
|
|
||||||
SCR_MODE rw 2
|
SCR_MODE rw 2
|
||||||
|
|
||||||
PUTPIXEL rd 1
|
PUTPIXEL rd 1
|
||||||
GETPIXEL rd 1
|
GETPIXEL rd 1
|
||||||
|
|
||||||
|
if VESA_1_2_VIDEO
|
||||||
|
BANK_SWITCH rd 1 reserved for vesa 1.2
|
||||||
|
BANK_RW rd 1
|
||||||
|
end if
|
||||||
|
|
||||||
REDRAW_BACKGROUND rb 4
|
REDRAW_BACKGROUND rb 4
|
||||||
|
|
||||||
|
mouseunder rd 16*24
|
||||||
|
|
||||||
MOUSE_PICTURE rd 1
|
MOUSE_PICTURE rd 1
|
||||||
|
|
||||||
MOUSE_SCROLL_H rw 1
|
MOUSE_SCROLL_H rw 1
|
||||||
@ -429,7 +438,6 @@ BTN_BUFF rd 255
|
|||||||
KEY_COUNT rb 4
|
KEY_COUNT rb 4
|
||||||
KEY_BUFF rb 128
|
KEY_BUFF rb 128
|
||||||
|
|
||||||
mouseunder rd 16*24
|
|
||||||
|
|
||||||
SYS_SHUTDOWN rb 4
|
SYS_SHUTDOWN rb 4
|
||||||
|
|
||||||
@ -548,10 +556,12 @@ BiosDisksData rb 200h
|
|||||||
BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
|
BiosDiskCaches rb 80h*(cache_ide1-cache_ide0)
|
||||||
BiosDiskPartitions rd 80h
|
BiosDiskPartitions rd 80h
|
||||||
|
|
||||||
|
align 16
|
||||||
|
DRIVE_DATA: rb DRIVE_DATA_SIZE
|
||||||
|
|
||||||
align 4096
|
align 4096
|
||||||
|
|
||||||
SLOT_BASE: rb 64*1024
|
SLOT_BASE: rb 64*1024
|
||||||
DRIVE_DATA: rb 64*1024
|
|
||||||
RESERVED_PORTS: rb 64*1024
|
RESERVED_PORTS: rb 64*1024
|
||||||
FLOPPY_BUFF: rb 16*1024
|
FLOPPY_BUFF: rb 16*1024
|
||||||
BUTTON_INFO: rb 16*1024
|
BUTTON_INFO: rb 16*1024
|
||||||
|
@ -15,7 +15,7 @@ $Revision$
|
|||||||
;***************************************************
|
;***************************************************
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, DRIVE_DATA
|
mov edi, DRIVE_DATA
|
||||||
mov ecx, 16384
|
mov ecx, DRIVE_DATA_SIZE/4
|
||||||
cld
|
cld
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ kernel_export \
|
|||||||
HwCursorCreate,\
|
HwCursorCreate,\
|
||||||
\
|
\
|
||||||
SysMsgBoardStr,\
|
SysMsgBoardStr,\
|
||||||
SysMsgBoardChar,\
|
SysMsgBoard,\
|
||||||
GetCurrentTask,\
|
GetCurrentTask,\
|
||||||
LoadFile,\
|
LoadFile,\
|
||||||
SendEvent,\
|
SendEvent,\
|
||||||
|
@ -234,8 +234,7 @@ AddDevice:
|
|||||||
; 8 bytes for a packet and 8 bytes for previous packet, used by a keyboard.
|
; 8 bytes for a packet and 8 bytes for previous packet, used by a keyboard.
|
||||||
; 9. Initialize device data.
|
; 9. Initialize device data.
|
||||||
mov [ebx+device_data.intpipe], eax
|
mov [ebx+device_data.intpipe], eax
|
||||||
push 8
|
movi ecx, 8
|
||||||
pop ecx
|
|
||||||
cmp edx, ecx
|
cmp edx, ecx
|
||||||
jb @f
|
jb @f
|
||||||
mov edx, ecx
|
mov edx, ecx
|
||||||
@ -364,8 +363,7 @@ keyboard_data_ready:
|
|||||||
jb .controlloop
|
jb .controlloop
|
||||||
.nocontrol:
|
.nocontrol:
|
||||||
; 3. Initialize before loop for normal keys. esi = index.
|
; 3. Initialize before loop for normal keys. esi = index.
|
||||||
push 2
|
movi esi, 2
|
||||||
pop esi
|
|
||||||
.normalloop:
|
.normalloop:
|
||||||
; 4. Process one key which was pressed in the previous packet.
|
; 4. Process one key which was pressed in the previous packet.
|
||||||
; 4a. Get the next pressed key from the previous packet.
|
; 4a. Get the next pressed key from the previous packet.
|
||||||
@ -486,8 +484,7 @@ keyboard_data_ready:
|
|||||||
|
|
||||||
; Auxiliary procedure for keyboard_data_ready.
|
; Auxiliary procedure for keyboard_data_ready.
|
||||||
haskey:
|
haskey:
|
||||||
push 2
|
movi edx, 2
|
||||||
pop edx
|
|
||||||
@@:
|
@@:
|
||||||
cmp byte [ecx+edx], al
|
cmp byte [ecx+edx], al
|
||||||
jz @f
|
jz @f
|
||||||
|
@ -298,8 +298,7 @@ virtual at esp
|
|||||||
.UserData dd ? ; request_queue_item.UserData
|
.UserData dd ? ; request_queue_item.UserData
|
||||||
end virtual
|
end virtual
|
||||||
; 1. Allocate the memory for the request description.
|
; 1. Allocate the memory for the request description.
|
||||||
push request_queue_item.sizeof
|
movi eax, request_queue_item.sizeof
|
||||||
pop eax
|
|
||||||
call Kmalloc
|
call Kmalloc
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
@ -1004,10 +1003,8 @@ proc inquiry_callback
|
|||||||
; 4. Thus, create a temporary kernel thread which would do it.
|
; 4. Thus, create a temporary kernel thread which would do it.
|
||||||
mov edx, [esp+8]
|
mov edx, [esp+8]
|
||||||
push ebx ecx
|
push ebx ecx
|
||||||
push 51
|
movi eax, 51
|
||||||
pop eax
|
movi ebx, 1
|
||||||
push 1
|
|
||||||
pop ebx
|
|
||||||
mov ecx, new_disk_thread
|
mov ecx, new_disk_thread
|
||||||
; edx = parameter
|
; edx = parameter
|
||||||
int 0x40
|
int 0x40
|
||||||
@ -1069,8 +1066,7 @@ end virtual
|
|||||||
cmp [edx+usb_unit_data.UnitReadyAttempts], 3
|
cmp [edx+usb_unit_data.UnitReadyAttempts], 3
|
||||||
jz @f
|
jz @f
|
||||||
push ecx edx esi
|
push ecx edx esi
|
||||||
push 10
|
movi esi, 10
|
||||||
pop esi
|
|
||||||
call Sleep
|
call Sleep
|
||||||
pop esi edx ecx
|
pop esi edx ecx
|
||||||
stdcall queue_request, ecx, test_unit_ready_req, 0, test_unit_ready_callback, edx
|
stdcall queue_request, ecx, test_unit_ready_req, 0, test_unit_ready_callback, edx
|
||||||
@ -1124,8 +1120,7 @@ end virtual
|
|||||||
mov byte [edi-1], 'd'
|
mov byte [edi-1], 'd'
|
||||||
push eax
|
push eax
|
||||||
push -'0'
|
push -'0'
|
||||||
push 10
|
movi ecx, 10
|
||||||
pop ecx
|
|
||||||
@@:
|
@@:
|
||||||
cdq
|
cdq
|
||||||
div ecx
|
div ecx
|
||||||
|
@ -241,25 +241,23 @@ esp equ _esp
|
|||||||
debug_func fdo_debug_outchar
|
debug_func fdo_debug_outchar
|
||||||
debug_beginf
|
debug_beginf
|
||||||
pushad
|
pushad
|
||||||
movzx ebx, al
|
movzx ecx, al
|
||||||
mov eax, 1
|
mov ebx, 1
|
||||||
mov ecx, sys_msg_board
|
call sys_msg_board
|
||||||
call ecx ; sys_msg_board
|
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
debug_endf
|
debug_endf
|
||||||
|
|
||||||
debug_func fdo_debug_outstr
|
debug_func fdo_debug_outstr
|
||||||
debug_beginf
|
debug_beginf
|
||||||
mov eax, 1
|
mov ebx, 1
|
||||||
.l1:
|
.l1:
|
||||||
dec esi
|
dec esi
|
||||||
js .l2
|
js .l2
|
||||||
movzx ebx, byte[edx]
|
movzx ecx, byte[edx]
|
||||||
or bl, bl
|
or cl, cl
|
||||||
jz .l2
|
jz .l2
|
||||||
mov ecx, sys_msg_board
|
call sys_msg_board
|
||||||
call ecx ; sys_msg_board
|
|
||||||
inc edx
|
inc edx
|
||||||
jmp .l1
|
jmp .l1
|
||||||
.l2:
|
.l2:
|
||||||
@ -278,8 +276,7 @@ debug_beginf
|
|||||||
call fdo_debug_outchar
|
call fdo_debug_outchar
|
||||||
pop eax
|
pop eax
|
||||||
@@:
|
@@:
|
||||||
push 10
|
movi ecx, 10
|
||||||
pop ecx
|
|
||||||
push -'0'
|
push -'0'
|
||||||
.l1:
|
.l1:
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
|
@ -1311,8 +1311,7 @@ fs_FloppyRewrite:
|
|||||||
push ecx edi
|
push ecx edi
|
||||||
mov ecx, 8
|
mov ecx, 8
|
||||||
repnz scasb
|
repnz scasb
|
||||||
push 1
|
movi eax, 1 ; 1 entry
|
||||||
pop eax ; 1 entry
|
|
||||||
jnz .notilde
|
jnz .notilde
|
||||||
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total
|
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -1822,8 +1821,7 @@ floppy_extend_file:
|
|||||||
jb @b
|
jb @b
|
||||||
.fat_err:
|
.fat_err:
|
||||||
pop ecx
|
pop ecx
|
||||||
push ERROR_FAT_TABLE
|
movi eax, ERROR_FAT_TABLE
|
||||||
pop eax
|
|
||||||
stc
|
stc
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
@ -1885,8 +1883,7 @@ floppy_extend_file:
|
|||||||
pop edi ecx
|
pop edi ecx
|
||||||
pop esi edx
|
pop esi edx
|
||||||
stc
|
stc
|
||||||
push ERROR_DISK_FULL
|
movi eax, ERROR_DISK_FULL
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
|
@ -167,8 +167,7 @@ fat_create_partition:
|
|||||||
; in the normal operation, let's hope for the best and allocate data now; if
|
; in the normal operation, let's hope for the best and allocate data now; if
|
||||||
; it will prove wrong, just deallocate it.
|
; it will prove wrong, just deallocate it.
|
||||||
push ebx
|
push ebx
|
||||||
push sizeof.FAT
|
movi eax, sizeof.FAT
|
||||||
pop eax
|
|
||||||
call malloc
|
call malloc
|
||||||
pop ebx
|
pop ebx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -972,8 +971,7 @@ fs_HdReadFolder:
|
|||||||
jz ntfs_HdReadFolder
|
jz ntfs_HdReadFolder
|
||||||
cmp [fs_type], 2
|
cmp [fs_type], 2
|
||||||
jz ext2_HdReadFolder
|
jz ext2_HdReadFolder
|
||||||
push ERROR_UNSUPPORTED_FS
|
movi eax, ERROR_UNSUPPORTED_FS
|
||||||
pop eax
|
|
||||||
or ebx, -1
|
or ebx, -1
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
@ -1659,8 +1657,7 @@ fat_Rewrite:
|
|||||||
push ecx edi
|
push ecx edi
|
||||||
mov ecx, 8
|
mov ecx, 8
|
||||||
repnz scasb
|
repnz scasb
|
||||||
push 1
|
movi eax, 1 ; 1 entry
|
||||||
pop eax ; 1 entry
|
|
||||||
jnz .notilde
|
jnz .notilde
|
||||||
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total
|
; we need ceil(strlen(esi)/13) additional entries = floor((strlen(esi)+12+13)/13) total
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
@ -2362,8 +2359,7 @@ hd_extend_file:
|
|||||||
jmp .device_err2
|
jmp .device_err2
|
||||||
.disk_full:
|
.disk_full:
|
||||||
pop eax edx esi
|
pop eax edx esi
|
||||||
push ERROR_DISK_FULL
|
movi eax, ERROR_DISK_FULL
|
||||||
pop eax
|
|
||||||
stc
|
stc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -2390,8 +2386,7 @@ fs_HdSetFileEnd:
|
|||||||
jz ntfs_HdSetFileEnd
|
jz ntfs_HdSetFileEnd
|
||||||
cmp [fs_type], 2
|
cmp [fs_type], 2
|
||||||
jz ext2_HdSetFileEnd
|
jz ext2_HdSetFileEnd
|
||||||
push ERROR_UNKNOWN_FS
|
movi eax, ERROR_UNKNOWN_FS
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
sub ebx, 4
|
sub ebx, 4
|
||||||
@ -2566,8 +2561,7 @@ fat_SetFileEnd:
|
|||||||
pop eax ecx eax edi
|
pop eax ecx eax edi
|
||||||
call update_disk
|
call update_disk
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
push ERROR_DEVICE
|
movi eax, ERROR_DEVICE
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
; we will zero data at the end of last sector - remember it
|
; we will zero data at the end of last sector - remember it
|
||||||
@ -2640,8 +2634,7 @@ fat_SetFileEnd:
|
|||||||
pop eax ecx eax edi
|
pop eax ecx eax edi
|
||||||
call update_disk
|
call update_disk
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
push ERROR_FAT_TABLE
|
movi eax, ERROR_FAT_TABLE
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
fs_HdGetFileInfo:
|
fs_HdGetFileInfo:
|
||||||
@ -2771,8 +2764,7 @@ fs_HdDelete:
|
|||||||
jz ntfs_HdDelete
|
jz ntfs_HdDelete
|
||||||
cmp [fs_type], 2
|
cmp [fs_type], 2
|
||||||
jz ext2_HdDelete
|
jz ext2_HdDelete
|
||||||
push ERROR_UNKNOWN_FS
|
movi eax, ERROR_UNKNOWN_FS
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
sub ebx, 4
|
sub ebx, 4
|
||||||
@ -2866,23 +2858,20 @@ fat_Delete:
|
|||||||
.err2:
|
.err2:
|
||||||
pop edi
|
pop edi
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
push ERROR_DEVICE
|
movi eax, ERROR_DEVICE
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
.error_fat:
|
.error_fat:
|
||||||
popad
|
popad
|
||||||
pop edi
|
pop edi
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
push ERROR_FAT_TABLE
|
movi eax, ERROR_FAT_TABLE
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
.notempty:
|
.notempty:
|
||||||
popad
|
popad
|
||||||
.access_denied2:
|
.access_denied2:
|
||||||
pop edi
|
pop edi
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
push ERROR_ACCESS_DENIED
|
movi eax, ERROR_ACCESS_DENIED
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
.empty:
|
.empty:
|
||||||
popad
|
popad
|
||||||
|
@ -683,61 +683,43 @@ fs_NumCdServices = ($ - fs_CdServices)/4
|
|||||||
fs_HasRamdisk:
|
fs_HasRamdisk:
|
||||||
mov al, 1 ; we always have ramdisk
|
mov al, 1 ; we always have ramdisk
|
||||||
ret
|
ret
|
||||||
|
|
||||||
fs_HasFloppy:
|
fs_HasFloppy:
|
||||||
cmp byte [DRIVE_DATA], 0
|
cmp byte [DRIVE_DATA], 0
|
||||||
setnz al
|
setnz al
|
||||||
ret
|
ret
|
||||||
|
|
||||||
fs_HasHd0:
|
fs_HasHd0:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 01000000b
|
||||||
and al, 11000000b
|
setnz al
|
||||||
cmp al, 01000000b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
fs_HasHd1:
|
fs_HasHd1:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 00010000b
|
||||||
and al, 00110000b
|
setnz al
|
||||||
cmp al, 00010000b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
fs_HasHd2:
|
fs_HasHd2:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 00000100b
|
||||||
and al, 00001100b
|
setnz al
|
||||||
cmp al, 00000100b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
fs_HasHd3:
|
fs_HasHd3:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 00000001b
|
||||||
and al, 00000011b
|
setnz al
|
||||||
cmp al, 00000001b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;*******************************************************
|
;*******************************************************
|
||||||
fs_HasCd0:
|
fs_HasCd0:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 10000000b
|
||||||
and al, 11000000b
|
setnz al
|
||||||
cmp al, 10000000b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
fs_HasCd1:
|
fs_HasCd1:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 00100000b
|
||||||
and al, 00110000b
|
setnz al
|
||||||
cmp al, 00100000b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
fs_HasCd2:
|
fs_HasCd2:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 00001000b
|
||||||
and al, 00001100b
|
setnz al
|
||||||
cmp al, 00001000b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
fs_HasCd3:
|
fs_HasCd3:
|
||||||
mov al, [DRIVE_DATA+1]
|
test byte [DRIVE_DATA+1], 00000010b
|
||||||
and al, 00000011b
|
setnz al
|
||||||
cmp al, 00000010b
|
|
||||||
setz al
|
|
||||||
ret
|
ret
|
||||||
;*******************************************************
|
;*******************************************************
|
||||||
|
|
||||||
|
@ -1139,15 +1139,13 @@ ntfs_HdRead:
|
|||||||
cmp byte [esi], 0
|
cmp byte [esi], 0
|
||||||
jnz @f
|
jnz @f
|
||||||
or ebx, -1
|
or ebx, -1
|
||||||
push ERROR_ACCESS_DENIED
|
movi eax, ERROR_ACCESS_DENIED
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
call ntfs_find_lfn
|
call ntfs_find_lfn
|
||||||
jnc .found
|
jnc .found
|
||||||
or ebx, -1
|
or ebx, -1
|
||||||
push ERROR_FILE_NOT_FOUND
|
movi eax, ERROR_FILE_NOT_FOUND
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
.found:
|
.found:
|
||||||
mov [ntfs_cur_attr], 0x80 ; $DATA
|
mov [ntfs_cur_attr], 0x80 ; $DATA
|
||||||
@ -1156,8 +1154,7 @@ ntfs_HdRead:
|
|||||||
call ntfs_read_attr
|
call ntfs_read_attr
|
||||||
jnc @f
|
jnc @f
|
||||||
or ebx, -1
|
or ebx, -1
|
||||||
push ERROR_ACCESS_DENIED
|
movi eax, ERROR_ACCESS_DENIED
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
pushad
|
pushad
|
||||||
@ -1171,8 +1168,7 @@ ntfs_HdRead:
|
|||||||
popad
|
popad
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
.eof:
|
.eof:
|
||||||
push ERROR_END_OF_FILE
|
movi eax, ERROR_END_OF_FILE
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
mov eax, [ebx]
|
mov eax, [ebx]
|
||||||
@ -1349,8 +1345,7 @@ ntfs_HdReadFolder:
|
|||||||
.nomem:
|
.nomem:
|
||||||
popad
|
popad
|
||||||
or ebx, -1
|
or ebx, -1
|
||||||
push 12
|
movi eax, 12
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
mov [ntfs_data.cur_index_buf], eax
|
mov [ntfs_data.cur_index_buf], eax
|
||||||
@ -1804,14 +1799,12 @@ ntfs_HdDelete:
|
|||||||
ntfs_HdGetFileInfo:
|
ntfs_HdGetFileInfo:
|
||||||
cmp byte [esi], 0
|
cmp byte [esi], 0
|
||||||
jnz @f
|
jnz @f
|
||||||
push 2
|
movi eax, 2
|
||||||
pop eax
|
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
call ntfs_find_lfn
|
call ntfs_find_lfn
|
||||||
jnc .doit
|
jnc .doit
|
||||||
push ERROR_FILE_NOT_FOUND
|
movi eax, ERROR_FILE_NOT_FOUND
|
||||||
pop eax
|
|
||||||
cmp [hd_error], 0
|
cmp [hd_error], 0
|
||||||
jz @f
|
jz @f
|
||||||
mov al, 11
|
mov al, 11
|
||||||
|
@ -139,8 +139,7 @@ endg
|
|||||||
|
|
||||||
register_keyboard:
|
register_keyboard:
|
||||||
push ebx
|
push ebx
|
||||||
push sizeof.KEYBOARD
|
movi eax, sizeof.KEYBOARD
|
||||||
pop eax
|
|
||||||
call malloc
|
call malloc
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nothing
|
jz .nothing
|
||||||
|
@ -75,6 +75,7 @@ $Revision$
|
|||||||
|
|
||||||
|
|
||||||
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
|
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
|
||||||
|
VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions
|
||||||
|
|
||||||
; Enabling the next line will enable serial output console
|
; Enabling the next line will enable serial output console
|
||||||
;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
|
;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
|
||||||
@ -230,6 +231,10 @@ tmp_gdt:
|
|||||||
|
|
||||||
include "data16.inc"
|
include "data16.inc"
|
||||||
|
|
||||||
|
if ~ lang eq sp
|
||||||
|
diff16 "end of bootcode",0,$+0x10000
|
||||||
|
end if
|
||||||
|
|
||||||
use32
|
use32
|
||||||
org $+0x10000
|
org $+0x10000
|
||||||
|
|
||||||
@ -405,19 +410,18 @@ high_code:
|
|||||||
dec eax
|
dec eax
|
||||||
mov [Screen_Max_Y], eax
|
mov [Screen_Max_Y], eax
|
||||||
mov [screen_workarea.bottom], eax
|
mov [screen_workarea.bottom], eax
|
||||||
movzx eax, word [BOOT_VAR+BOOT_VESA_MODE]; screen mode
|
movzx eax, word [BOOT_VAR+BOOT_VESA_MODE] ; screen mode
|
||||||
mov [SCR_MODE], eax
|
mov dword [SCR_MODE], eax
|
||||||
; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add
|
; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add
|
||||||
; mov [BANK_SWITCH], eax
|
; mov [BANK_SWITCH], eax
|
||||||
mov [BytesPerScanLine], word 640*4 ; Bytes PerScanLine
|
mov eax, 640 *4 ; Bytes PerScanLine
|
||||||
cmp [SCR_MODE], word 0x13 ; 320x200
|
cmp [SCR_MODE], word 0x13 ; 320x200
|
||||||
je @f
|
je @f
|
||||||
cmp [SCR_MODE], word 0x12 ; VGA 640x480
|
cmp [SCR_MODE], word 0x12 ; VGA 640x480
|
||||||
je @f
|
je @f
|
||||||
movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes
|
movzx eax, word[BOOT_VAR+BOOT_PITCH] ; for other modes
|
||||||
mov [BytesPerScanLine], ax
|
|
||||||
mov [_display.pitch], eax
|
|
||||||
@@:
|
@@:
|
||||||
|
mov [_display.pitch], eax
|
||||||
mov eax, [_display.width]
|
mov eax, [_display.width]
|
||||||
mul [_display.height]
|
mul [_display.height]
|
||||||
mov [_WinMapSize], eax
|
mov [_WinMapSize], eax
|
||||||
@ -658,6 +662,10 @@ no_mode_0x12:
|
|||||||
; Initialize system timer (IRQ0)
|
; Initialize system timer (IRQ0)
|
||||||
call PIT_init
|
call PIT_init
|
||||||
|
|
||||||
|
; CALCULATE FAT CHAIN FOR RAMDISK
|
||||||
|
|
||||||
|
call calculatefatchain
|
||||||
|
|
||||||
mov esi, boot_initapic
|
mov esi, boot_initapic
|
||||||
call boot_log
|
call boot_log
|
||||||
; Try to Initialize APIC
|
; Try to Initialize APIC
|
||||||
@ -714,9 +722,6 @@ include 'boot/rdload.inc'
|
|||||||
;!!!!!!!!!!!!!!!!!!!!!!!
|
;!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
end if
|
end if
|
||||||
; mov [dma_hdd],1
|
; mov [dma_hdd],1
|
||||||
; CALCULATE FAT CHAIN FOR RAMDISK
|
|
||||||
|
|
||||||
call calculatefatchain
|
|
||||||
|
|
||||||
if 0
|
if 0
|
||||||
mov ax, [OS_BASE+0x10000+bx_from_load]
|
mov ax, [OS_BASE+0x10000+bx_from_load]
|
||||||
@ -1241,13 +1246,10 @@ set_variables:
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov [BTN_ADDR], dword BUTTON_INFO ; address of button list
|
mov [BTN_ADDR], dword BUTTON_INFO ; address of button list
|
||||||
|
|
||||||
mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer
|
|
||||||
mov byte [KEY_COUNT], al ; keyboard buffer
|
mov byte [KEY_COUNT], al ; keyboard buffer
|
||||||
mov byte [BTN_COUNT], al ; button buffer
|
mov byte [BTN_COUNT], al ; button buffer
|
||||||
; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y
|
; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y
|
||||||
|
|
||||||
;!! IP 04.02.2005:
|
|
||||||
; mov byte [DONT_SWITCH], al; change task if possible
|
|
||||||
pop eax
|
pop eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -2036,10 +2038,9 @@ sys_end:
|
|||||||
mov [eax+TASKDATA.state], 3; terminate this program
|
mov [eax+TASKDATA.state], 3; terminate this program
|
||||||
call wakeup_osloop
|
call wakeup_osloop
|
||||||
|
|
||||||
waitterm: ; wait here for termination
|
.waitterm: ; wait here for termination
|
||||||
mov ebx, 100
|
call change_task
|
||||||
call delay_hs
|
jmp .waitterm
|
||||||
jmp waitterm
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
restore_default_cursor_before_killing:
|
restore_default_cursor_before_killing:
|
||||||
@ -2325,7 +2326,7 @@ sysfn_getdiskinfo: ; 18.11 = get disk info table
|
|||||||
dec ecx
|
dec ecx
|
||||||
jnz exit_for_anyone
|
jnz exit_for_anyone
|
||||||
call for_all_tables
|
call for_all_tables
|
||||||
mov ecx, 16384
|
mov ecx, DRIVE_DATA_SIZE/4
|
||||||
cld
|
cld
|
||||||
rep movsd
|
rep movsd
|
||||||
ret
|
ret
|
||||||
@ -2493,7 +2494,7 @@ sysfn_set_screen_sizes:
|
|||||||
pushfd
|
pushfd
|
||||||
cli
|
cli
|
||||||
mov eax, ecx
|
mov eax, ecx
|
||||||
mov ecx, [BytesPerScanLine]
|
mov ecx, [_display.pitch]
|
||||||
mov [_display.width], eax
|
mov [_display.width], eax
|
||||||
dec eax
|
dec eax
|
||||||
mov [_display.height], edx
|
mov [_display.height], edx
|
||||||
@ -3519,23 +3520,23 @@ set_bgr_event:
|
|||||||
cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0
|
cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0
|
||||||
jz .set
|
jz .set
|
||||||
.join:
|
.join:
|
||||||
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax
|
|
||||||
jbe @f
|
|
||||||
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax
|
|
||||||
@@:
|
|
||||||
shr eax, 16
|
|
||||||
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax
|
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax
|
||||||
jae @f
|
jae @f
|
||||||
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax
|
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax
|
||||||
@@:
|
@@:
|
||||||
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx
|
shr eax, 16
|
||||||
|
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax
|
||||||
jbe @f
|
jbe @f
|
||||||
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx
|
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax
|
||||||
@@:
|
@@:
|
||||||
shr edx, 16
|
|
||||||
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx
|
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx
|
||||||
jae @f
|
jae @f
|
||||||
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx
|
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx
|
||||||
|
@@:
|
||||||
|
shr edx, 16
|
||||||
|
cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx
|
||||||
|
jbe @f
|
||||||
|
mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx
|
||||||
@@:
|
@@:
|
||||||
jmp .common
|
jmp .common
|
||||||
.set:
|
.set:
|
||||||
@ -3850,6 +3851,34 @@ proc delay_hs_unprotected
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
if 1
|
||||||
|
align 4
|
||||||
|
delay_hs: ; delay in 1/100 secs
|
||||||
|
; ebx = delay time
|
||||||
|
|
||||||
|
pushad
|
||||||
|
push ebx
|
||||||
|
xor esi, esi
|
||||||
|
mov ecx, MANUAL_DESTROY
|
||||||
|
call create_event
|
||||||
|
test eax, eax
|
||||||
|
jz .done
|
||||||
|
|
||||||
|
mov ebx, edx
|
||||||
|
mov ecx, [esp]
|
||||||
|
push edx
|
||||||
|
push eax
|
||||||
|
call wait_event_timeout
|
||||||
|
pop eax
|
||||||
|
pop ebx
|
||||||
|
call destroy_event
|
||||||
|
.done:
|
||||||
|
add esp, 4
|
||||||
|
popad
|
||||||
|
ret
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
delay_hs: ; delay in 1/100 secs
|
delay_hs: ; delay in 1/100 secs
|
||||||
; ebx = delay time
|
; ebx = delay time
|
||||||
@ -3874,6 +3903,8 @@ zerodelay:
|
|||||||
pop edx
|
pop edx
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
end if
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
align 16 ;very often call this subrutine
|
align 16 ;very often call this subrutine
|
||||||
memmove: ; memory move in bytes
|
memmove: ; memory move in bytes
|
||||||
@ -4651,8 +4682,8 @@ sys_msg_board_str:
|
|||||||
@@:
|
@@:
|
||||||
cmp [esi], byte 0
|
cmp [esi], byte 0
|
||||||
je @f
|
je @f
|
||||||
mov eax, 1
|
mov ebx, 1
|
||||||
movzx ebx, byte [esi]
|
movzx ecx, byte [esi]
|
||||||
call sys_msg_board
|
call sys_msg_board
|
||||||
inc esi
|
inc esi
|
||||||
jmp @b
|
jmp @b
|
||||||
@ -4692,9 +4723,9 @@ sys_msg_board_dword:
|
|||||||
cmp al, 10
|
cmp al, 10
|
||||||
sbb al, 69h
|
sbb al, 69h
|
||||||
das
|
das
|
||||||
mov bl, al
|
mov cl, al
|
||||||
xor eax, eax
|
xor ebx, ebx
|
||||||
inc eax
|
inc ebx
|
||||||
call sys_msg_board
|
call sys_msg_board
|
||||||
pop eax
|
pop eax
|
||||||
pop ecx
|
pop ecx
|
||||||
@ -4711,8 +4742,12 @@ endg
|
|||||||
|
|
||||||
sys_msg_board:
|
sys_msg_board:
|
||||||
|
|
||||||
; eax=1 : write : bl byte to write
|
; ebx=1 : write : bl byte to write
|
||||||
; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al
|
; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al
|
||||||
|
|
||||||
|
push eax ebx ; Save eax and ebx, since we're restoring their order required.
|
||||||
|
mov eax, ebx
|
||||||
|
mov ebx, ecx
|
||||||
|
|
||||||
mov ecx, [msg_board_count]
|
mov ecx, [msg_board_count]
|
||||||
cmp eax, 1
|
cmp eax, 1
|
||||||
@ -4754,7 +4789,7 @@ endg
|
|||||||
jnz @f
|
jnz @f
|
||||||
mov word [msg_board_pos+2], 234
|
mov word [msg_board_pos+2], 234
|
||||||
add word [msg_board_pos], 10
|
add word [msg_board_pos], 10
|
||||||
mov ax, [Screen_Max_Y]
|
mov ax, word [Screen_Max_Y]
|
||||||
cmp word [msg_board_pos], ax
|
cmp word [msg_board_pos], ax
|
||||||
jbe @f
|
jbe @f
|
||||||
mov word [msg_board_pos], 10
|
mov word [msg_board_pos], 10
|
||||||
@ -4770,24 +4805,29 @@ end if
|
|||||||
inc ecx
|
inc ecx
|
||||||
and ecx, msg_board_data_size - 1
|
and ecx, msg_board_data_size - 1
|
||||||
mov [msg_board_count], ecx
|
mov [msg_board_count], ecx
|
||||||
|
|
||||||
|
pop ebx eax
|
||||||
ret
|
ret
|
||||||
.smbl1:
|
.smbl1:
|
||||||
cmp eax, 2
|
cmp eax, 2
|
||||||
jne .smbl2
|
jne .smbl2
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .smbl21
|
jz .smbl21
|
||||||
|
|
||||||
|
add esp, 8 ; Returning data in ebx and eax, so no need to restore them.
|
||||||
mov eax, msg_board_data+1
|
mov eax, msg_board_data+1
|
||||||
mov ebx, msg_board_data
|
mov ebx, msg_board_data
|
||||||
movzx edx, byte [ebx]
|
movzx edx, byte [ebx]
|
||||||
call memmove
|
call memmove
|
||||||
dec [msg_board_count]
|
dec [msg_board_count]
|
||||||
mov [esp + 36], edx ;eax
|
mov [esp + 32], edx ;eax
|
||||||
mov [esp + 24], dword 1
|
mov [esp + 20], dword 1
|
||||||
ret
|
ret
|
||||||
.smbl21:
|
.smbl21:
|
||||||
mov [esp+36], ecx
|
mov [esp+32], ecx
|
||||||
mov [esp+24], ecx
|
mov [esp+20], ecx
|
||||||
.smbl2:
|
.smbl2:
|
||||||
|
pop ebx eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@ -4969,7 +5009,7 @@ sys_gs: ; direct screen access
|
|||||||
.1: ; resolution
|
.1: ; resolution
|
||||||
mov eax, [Screen_Max_X]
|
mov eax, [Screen_Max_X]
|
||||||
shl eax, 16
|
shl eax, 16
|
||||||
mov ax, [Screen_Max_Y]
|
mov ax, word [Screen_Max_Y]
|
||||||
add eax, 0x00010001
|
add eax, 0x00010001
|
||||||
mov [esp+32], eax
|
mov [esp+32], eax
|
||||||
ret
|
ret
|
||||||
@ -4978,7 +5018,7 @@ sys_gs: ; direct screen access
|
|||||||
mov [esp+32], eax
|
mov [esp+32], eax
|
||||||
ret
|
ret
|
||||||
.3: ; bytes per scanline
|
.3: ; bytes per scanline
|
||||||
mov eax, [BytesPerScanLine]
|
mov eax, [_display.pitch]
|
||||||
mov [esp+32], eax
|
mov [esp+32], eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -5068,9 +5108,9 @@ syscall_drawrect: ; DrawRect
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
syscall_getscreensize: ; GetScreenSize
|
syscall_getscreensize: ; GetScreenSize
|
||||||
mov ax, [Screen_Max_X]
|
mov ax, word [Screen_Max_X]
|
||||||
shl eax, 16
|
shl eax, 16
|
||||||
mov ax, [Screen_Max_Y]
|
mov ax, word [Screen_Max_Y]
|
||||||
mov [esp + 32], eax
|
mov [esp + 32], eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -5389,7 +5429,7 @@ calculate_fast_getting_offset_for_LFB:
|
|||||||
cld
|
cld
|
||||||
@@:
|
@@:
|
||||||
stosd
|
stosd
|
||||||
add eax, [BytesPerScanLine]
|
add eax, [_display.pitch]
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz @r
|
jnz @r
|
||||||
ret
|
ret
|
||||||
@ -5412,7 +5452,7 @@ set_screen:
|
|||||||
|
|
||||||
mov [Screen_Max_X], eax
|
mov [Screen_Max_X], eax
|
||||||
mov [Screen_Max_Y], edx
|
mov [Screen_Max_Y], edx
|
||||||
mov [BytesPerScanLine], ecx
|
mov [_display.pitch], ecx
|
||||||
|
|
||||||
mov [screen_workarea.right], eax
|
mov [screen_workarea.right], eax
|
||||||
mov [screen_workarea.bottom], edx
|
mov [screen_workarea.bottom], edx
|
||||||
@ -5538,8 +5578,7 @@ system_shutdown: ; shut down the system
|
|||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
call stop_all_services
|
call stop_all_services
|
||||||
push 3 ; stop playing cd
|
movi eax, 3
|
||||||
pop eax
|
|
||||||
call sys_cd_audio
|
call sys_cd_audio
|
||||||
|
|
||||||
yes_shutdown_param:
|
yes_shutdown_param:
|
||||||
@ -5547,8 +5586,7 @@ yes_shutdown_param:
|
|||||||
|
|
||||||
if ~ defined extended_primary_loader
|
if ~ defined extended_primary_loader
|
||||||
mov eax, kernel_file ; load kernel.mnt to 0x7000:0
|
mov eax, kernel_file ; load kernel.mnt to 0x7000:0
|
||||||
push 12
|
movi esi, 12
|
||||||
pop esi
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
or ecx, -1
|
or ecx, -1
|
||||||
mov edx, OS_BASE+0x70000
|
mov edx, OS_BASE+0x70000
|
||||||
@ -5770,6 +5808,10 @@ scan_rsdp:
|
|||||||
ret
|
ret
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
if ~ lang eq sp
|
||||||
|
diff16 "end of .text segment",0,$
|
||||||
|
end if
|
||||||
|
|
||||||
include "data32.inc"
|
include "data32.inc"
|
||||||
|
|
||||||
__REV__ = __REV
|
__REV__ = __REV
|
||||||
|
@ -117,3 +117,16 @@ macro list_del entry
|
|||||||
mov [ecx+list_fd], edx
|
mov [ecx+list_fd], edx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; MOV Immediate.
|
||||||
|
; Useful for things like movi eax,10:
|
||||||
|
; shorter than regular mov, but slightly slower,
|
||||||
|
; do not use it in performance-critical places.
|
||||||
|
macro movi dst, imm
|
||||||
|
{
|
||||||
|
if imm >= -0x80 & imm <= 0x7F
|
||||||
|
push imm
|
||||||
|
pop dst
|
||||||
|
else
|
||||||
|
mov dst, imm
|
||||||
|
end if
|
||||||
|
}
|
||||||
|
@ -32,39 +32,39 @@ ARP_REP_OPCODE = 0x0200 ; reply
|
|||||||
|
|
||||||
ARP_TABLE_SIZE = 20 ; Size of table
|
ARP_TABLE_SIZE = 20 ; Size of table
|
||||||
|
|
||||||
struct ARP_entry
|
struct ARP_entry
|
||||||
|
|
||||||
IP dd ?
|
IP dd ?
|
||||||
MAC dp ?
|
MAC dp ?
|
||||||
Status dw ?
|
Status dw ?
|
||||||
TTL dw ?
|
TTL dw ?
|
||||||
|
|
||||||
ends
|
ends
|
||||||
|
|
||||||
struct ARP_header
|
struct ARP_header
|
||||||
|
|
||||||
HardwareType dw ?
|
HardwareType dw ?
|
||||||
ProtocolType dw ?
|
ProtocolType dw ?
|
||||||
HardwareSize db ?
|
HardwareSize db ?
|
||||||
ProtocolSize db ?
|
ProtocolSize db ?
|
||||||
Opcode dw ?
|
Opcode dw ?
|
||||||
SenderMAC dp ?
|
SenderMAC dp ?
|
||||||
SenderIP dd ?
|
SenderIP dd ?
|
||||||
TargetMAC dp ?
|
TargetMAC dp ?
|
||||||
TargetIP dd ?
|
TargetIP dd ?
|
||||||
|
|
||||||
ends
|
ends
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
uglobal
|
uglobal
|
||||||
|
|
||||||
NumARP dd ?
|
|
||||||
|
|
||||||
ARP_table rb ARP_TABLE_SIZE * sizeof.ARP_entry ; TODO: separate ARP table and stats per interface
|
ARP_table rb NET_DEVICES_MAX*(ARP_TABLE_SIZE * sizeof.ARP_entry)
|
||||||
|
|
||||||
ARP_PACKETS_TX rd MAX_NET_DEVICES
|
ARP_entries_num rd NET_DEVICES_MAX
|
||||||
ARP_PACKETS_RX rd MAX_NET_DEVICES
|
ARP_PACKETS_TX rd NET_DEVICES_MAX
|
||||||
ARP_CONFLICTS rd MAX_NET_DEVICES
|
ARP_PACKETS_RX rd NET_DEVICES_MAX
|
||||||
|
ARP_CONFLICTS rd NET_DEVICES_MAX
|
||||||
|
|
||||||
|
|
||||||
endg
|
endg
|
||||||
@ -81,10 +81,8 @@ endg
|
|||||||
macro ARP_init {
|
macro ARP_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov [NumARP], eax
|
mov edi, ARP_entries_num
|
||||||
|
mov ecx, 4*NET_DEVICES_MAX
|
||||||
mov edi, ARP_PACKETS_TX
|
|
||||||
mov ecx, 3*MAX_NET_DEVICES
|
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -111,11 +109,15 @@ local .exit
|
|||||||
; The last status value is provided to allow the network layer to delete
|
; The last status value is provided to allow the network layer to delete
|
||||||
; a packet that is queued awaiting an ARP response
|
; a packet that is queued awaiting an ARP response
|
||||||
|
|
||||||
mov ecx, [NumARP]
|
xor edi, edi
|
||||||
|
.loop_outer:
|
||||||
|
mov ecx, [ARP_entries_num + 4*edi]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov esi, ARP_table
|
mov esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)
|
||||||
|
imul esi, edi
|
||||||
|
add esi, ARP_table
|
||||||
.loop:
|
.loop:
|
||||||
cmp [esi + ARP_entry.TTL], ARP_STATIC_ENTRY
|
cmp [esi + ARP_entry.TTL], ARP_STATIC_ENTRY
|
||||||
je .next
|
je .next
|
||||||
@ -133,9 +135,9 @@ local .exit
|
|||||||
cmp [esi + ARP_entry.Status], ARP_AWAITING_RESPONSE
|
cmp [esi + ARP_entry.Status], ARP_AWAITING_RESPONSE
|
||||||
je .response_timeout
|
je .response_timeout
|
||||||
|
|
||||||
push esi ecx
|
push esi edi ecx
|
||||||
call ARP_del_entry
|
call ARP_del_entry
|
||||||
pop ecx esi
|
pop ecx edi esi
|
||||||
|
|
||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
@ -146,6 +148,9 @@ local .exit
|
|||||||
jmp .next
|
jmp .next
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
|
inc edi
|
||||||
|
cmp edi, NET_DEVICES_MAX
|
||||||
|
jb .loop_outer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,11 +201,13 @@ ARP_input:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
|
||||||
|
|
||||||
mov ecx, [NumARP]
|
mov ecx, [ARP_entries_num + 4*edi]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov esi, ARP_table
|
mov esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)
|
||||||
|
imul esi, edi
|
||||||
|
add esi, ARP_table
|
||||||
.loop:
|
.loop:
|
||||||
cmp [esi + ARP_entry.IP], eax
|
cmp [esi + ARP_entry.IP], eax
|
||||||
je .gotit
|
je .gotit
|
||||||
@ -298,32 +305,27 @@ ARP_input:
|
|||||||
;
|
;
|
||||||
; ARP_output_request
|
; ARP_output_request
|
||||||
;
|
;
|
||||||
; IN: ip in eax
|
; IN: ebx = device ptr
|
||||||
; device in edi
|
; eax = IP
|
||||||
; OUT: /
|
; OUT: /
|
||||||
|
; scratched: probably everything
|
||||||
;
|
;
|
||||||
;---------------------------------------------------------------------------
|
;---------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
ARP_output_request:
|
ARP_output_request:
|
||||||
|
|
||||||
push eax ; DestIP
|
push eax
|
||||||
pushd [IP_LIST + edi] ; SenderIP
|
|
||||||
inc [ARP_PACKETS_TX + edi] ; assume we will succeed
|
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u\n",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u device=0x%x\n",\
|
||||||
[esp + 4]:1, [esp + 5]:1, [esp + 6]:1, [esp + 7]:1
|
[esp]:1, [esp + 1]:1, [esp + 2]:1, [esp + 3]:1, ebx
|
||||||
|
|
||||||
mov ebx, [NET_DRV_LIST + edi] ; device ptr
|
|
||||||
|
|
||||||
lea eax, [ebx + ETH_DEVICE.mac] ; local device mac
|
lea eax, [ebx + ETH_DEVICE.mac] ; local device mac
|
||||||
mov edx, ETH_BROADCAST ; broadcast mac
|
mov edx, ETH_BROADCAST ; broadcast mac
|
||||||
mov ecx, sizeof.ARP_header
|
mov ecx, sizeof.ARP_header
|
||||||
mov di, ETHER_ARP
|
mov di, ETHER_PROTO_ARP
|
||||||
call ETH_output
|
call ETH_output
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov ecx, eax
|
|
||||||
|
|
||||||
mov [edi + ARP_header.HardwareType], 0x0100 ; Ethernet
|
mov [edi + ARP_header.HardwareType], 0x0100 ; Ethernet
|
||||||
mov [edi + ARP_header.ProtocolType], 0x0008 ; IP
|
mov [edi + ARP_header.ProtocolType], 0x0008 ; IP
|
||||||
mov [edi + ARP_header.HardwareSize], 6 ; MAC-addr length
|
mov [edi + ARP_header.HardwareSize], 6 ; MAC-addr length
|
||||||
@ -331,29 +333,29 @@ ARP_output_request:
|
|||||||
mov [edi + ARP_header.Opcode], ARP_REQ_OPCODE ; Request
|
mov [edi + ARP_header.Opcode], ARP_REQ_OPCODE ; Request
|
||||||
|
|
||||||
add edi, ARP_header.SenderMAC
|
add edi, ARP_header.SenderMAC
|
||||||
|
|
||||||
lea esi, [ebx + ETH_DEVICE.mac] ; SenderMac
|
lea esi, [ebx + ETH_DEVICE.mac] ; SenderMac
|
||||||
movsw ;
|
movsw ;
|
||||||
movsd ;
|
movsd ;
|
||||||
pop eax ; SenderIP
|
|
||||||
stosd ;
|
|
||||||
|
|
||||||
mov eax, -1 ; DestMac
|
; mov esi, [ebx + NET_DEVICE.number]
|
||||||
stosd ;
|
xor esi, esi ;;;; FIXME
|
||||||
stosw ;
|
inc esi ;;;;;;;;;
|
||||||
pop eax ; DestIP
|
inc [ARP_PACKETS_TX + 4*esi] ; assume we will succeed
|
||||||
stosd ;
|
lea esi, [IP_LIST + 4*esi] ; SenderIP
|
||||||
|
movsd
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: device=%x\n", ebx
|
mov esi, ETH_BROADCAST ; DestMac
|
||||||
|
movsw ;
|
||||||
|
movsd ;
|
||||||
|
popd [edi] ; DestIP
|
||||||
|
|
||||||
push edx ecx
|
push edx eax
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
add esp, 4 + 4
|
add esp, 4
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: failed\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "ARP_output_request: send failed\n"
|
||||||
sub eax, eax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -362,50 +364,64 @@ ARP_output_request:
|
|||||||
; ARP_add_entry (or update)
|
; ARP_add_entry (or update)
|
||||||
;
|
;
|
||||||
; IN: esi = ptr to entry (can easily be made on the stack)
|
; IN: esi = ptr to entry (can easily be made on the stack)
|
||||||
|
; edi = device num
|
||||||
; OUT: eax = entry #, -1 on error
|
; OUT: eax = entry #, -1 on error
|
||||||
; edi = ptr to newly created entry
|
; esi = ptr to newly created entry
|
||||||
;
|
;
|
||||||
;----------------------------------------------------------------- ; TODO: use a mutex
|
;----------------------------------------------------------------- ; TODO: use a mutex
|
||||||
align 4
|
align 4
|
||||||
ARP_add_entry:
|
ARP_add_entry:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: "
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
|
||||||
|
|
||||||
mov ecx, [NumARP]
|
mov ecx, [ARP_entries_num + 4*edi]
|
||||||
cmp ecx, ARP_TABLE_SIZE ; list full ?
|
cmp ecx, ARP_TABLE_SIZE ; list full ?
|
||||||
jae .error
|
jae .full
|
||||||
|
|
||||||
xor eax, eax
|
; From this point on, we can only fail if IP has a static entry, or if table is corrupt.
|
||||||
mov edi, ARP_table
|
|
||||||
mov ecx, [esi + ARP_entry.IP]
|
inc [ARP_entries_num + 4*edi] ; assume we will succeed
|
||||||
|
|
||||||
|
push edi
|
||||||
|
xor ecx, ecx
|
||||||
|
imul edi, ARP_TABLE_SIZE*sizeof.ARP_entry
|
||||||
|
add edi, ARP_table
|
||||||
|
mov eax, [esi + ARP_entry.IP]
|
||||||
.loop:
|
.loop:
|
||||||
cmp [edi + ARP_entry.Status], ARP_NO_ENTRY ; is this slot empty?
|
cmp [edi + ARP_entry.Status], ARP_NO_ENTRY ; is this slot empty?
|
||||||
je .add
|
je .add
|
||||||
|
|
||||||
cmp [edi + ARP_entry.IP], ecx ; if not, check if it doesnt collide
|
cmp [edi + ARP_entry.IP], eax ; if not, check if it doesnt collide
|
||||||
jne .maybe_next
|
jne .maybe_next
|
||||||
|
|
||||||
cmp [edi + ARP_entry.TTL], ARP_STATIC_ENTRY ; ok, its the same IP, update it if not static
|
cmp [edi + ARP_entry.TTL], ARP_STATIC_ENTRY ; ok, its the same IP, update it if not static
|
||||||
jne .add
|
jne .add
|
||||||
|
|
||||||
|
DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry: failed, IP already has a static entry\n"
|
||||||
|
jmp .error
|
||||||
|
|
||||||
.maybe_next: ; try the next slot
|
.maybe_next: ; try the next slot
|
||||||
add edi, sizeof.ARP_entry
|
add edi, sizeof.ARP_entry
|
||||||
inc eax
|
inc ecx
|
||||||
cmp eax, ARP_TABLE_SIZE
|
cmp ecx, ARP_TABLE_SIZE
|
||||||
jae .error
|
jb .loop
|
||||||
jmp .loop
|
|
||||||
|
|
||||||
.add:
|
.add:
|
||||||
|
push ecx
|
||||||
mov ecx, sizeof.ARP_entry/2
|
mov ecx, sizeof.ARP_entry/2
|
||||||
rep movsw
|
rep movsw
|
||||||
inc [NumARP]
|
pop ecx
|
||||||
sub edi, sizeof.ARP_entry
|
lea esi, [edi - sizeof.ARP_entry]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "entry=%u\n", eax
|
pop edi
|
||||||
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: entry=%u\n", ecx
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "failed\n"
|
pop edi
|
||||||
|
dec [ARP_entries_num + 4*edi]
|
||||||
|
DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry_failed\n"
|
||||||
|
.full:
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -414,30 +430,36 @@ ARP_add_entry:
|
|||||||
;
|
;
|
||||||
; ARP_del_entry
|
; ARP_del_entry
|
||||||
;
|
;
|
||||||
; IN: esi = ptr to arp entry
|
; IN: esi = ptr to arp entry
|
||||||
; OUT: /
|
; edi = device number
|
||||||
|
; OUT: /
|
||||||
;
|
;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
ARP_del_entry:
|
ARP_del_entry:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [NumARP]
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [ARP_entries_num + 4*edi]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
|
||||||
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
|
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
|
||||||
|
|
||||||
mov ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry
|
push edi
|
||||||
|
imul edi, (ARP_TABLE_SIZE) * sizeof.ARP_entry
|
||||||
|
lea ecx, [ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry + edi]
|
||||||
sub ecx, esi
|
sub ecx, esi
|
||||||
shr ecx, 1
|
shr ecx, 1
|
||||||
|
|
||||||
|
; move all trailing entries, sizeof.ARP_entry bytes to left.
|
||||||
mov edi, esi
|
mov edi, esi
|
||||||
add esi, sizeof.ARP_entry
|
add esi, sizeof.ARP_entry
|
||||||
rep movsw
|
rep movsw
|
||||||
|
|
||||||
|
; now add an empty entry to the end (erasing previous one)
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov ecx, sizeof.ARP_entry/2
|
mov ecx, sizeof.ARP_entry/2
|
||||||
rep stosw
|
rep stosw
|
||||||
|
|
||||||
dec [NumARP]
|
pop edi
|
||||||
|
dec [ARP_entries_num + 4*edi]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n"
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -465,7 +487,7 @@ ARP_IP_to_MAC:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
|
||||||
rol eax, 16
|
rol eax, 16
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, ".%u.%u\n", al, ah
|
DEBUGF DEBUG_NETWORK_VERBOSE, ".%u.%u device: %u\n", al, ah, edi
|
||||||
rol eax, 16
|
rol eax, 16
|
||||||
|
|
||||||
cmp eax, 0xffffffff
|
cmp eax, 0xffffffff
|
||||||
@ -474,46 +496,51 @@ ARP_IP_to_MAC:
|
|||||||
;--------------------------------
|
;--------------------------------
|
||||||
; Try to find the IP in ARP_table
|
; Try to find the IP in ARP_table
|
||||||
|
|
||||||
mov ecx, [NumARP]
|
mov ecx, [ARP_entries_num + 4*edi]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .not_in_list
|
jz .not_in_list
|
||||||
mov esi, ARP_table + ARP_entry.IP
|
mov esi, edi
|
||||||
|
imul esi, sizeof.ARP_entry * ARP_TABLE_SIZE
|
||||||
|
add esi, ARP_table + ARP_entry.IP
|
||||||
.scan_loop:
|
.scan_loop:
|
||||||
cmp [esi], eax
|
cmp [esi], eax
|
||||||
je .found_it
|
je .found_it
|
||||||
add esi, sizeof.ARP_entry
|
add esi, sizeof.ARP_entry
|
||||||
loop .scan_loop
|
dec ecx
|
||||||
|
jnz .scan_loop
|
||||||
|
|
||||||
.not_in_list:
|
.not_in_list:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: preparing for ARP request\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: preparing for ARP request\n"
|
||||||
|
|
||||||
;--------------------
|
|
||||||
; Send an ARP request
|
|
||||||
|
|
||||||
push eax edi ; save IP for ARP_output_request
|
push eax edi ; save IP for ARP_output_request
|
||||||
|
; Now craft the ARP entry on the stack
|
||||||
; Now create the ARP entry
|
|
||||||
pushw ARP_REQUEST_TTL ; TTL
|
pushw ARP_REQUEST_TTL ; TTL
|
||||||
pushw ARP_AWAITING_RESPONSE ; status
|
pushw ARP_AWAITING_RESPONSE ; status
|
||||||
pushd 0 ; mac
|
pushd 0 ; mac
|
||||||
pushw 0
|
pushw 0
|
||||||
pushd eax ; ip
|
pushd eax ; ip
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
|
; Add it to the list
|
||||||
call ARP_add_entry
|
call ARP_add_entry
|
||||||
|
|
||||||
|
; Delete the temporary entry
|
||||||
add esp, sizeof.ARP_entry ; clear the entry from stack
|
add esp, sizeof.ARP_entry ; clear the entry from stack
|
||||||
|
|
||||||
|
; If we could not add it to the list, give up
|
||||||
cmp eax, -1 ; did ARP_add_entry fail?
|
cmp eax, -1 ; did ARP_add_entry fail?
|
||||||
je .full
|
je .full
|
||||||
|
|
||||||
mov esi, edi
|
|
||||||
pop edi eax ; IP in eax, device number in edi, for ARP_output_request
|
|
||||||
|
|
||||||
push esi edi
|
|
||||||
call ARP_output_request ; And send a request
|
|
||||||
pop edi esi
|
|
||||||
|
|
||||||
;-----------------------------------------------
|
;-----------------------------------------------
|
||||||
; At this point, we got an ARP entry in the list
|
; At this point, we got an ARP entry in the list
|
||||||
|
|
||||||
|
; Now send a request packet on the network
|
||||||
|
pop edi eax ; IP in eax, device number in ebx, for ARP_output_request
|
||||||
|
|
||||||
|
push esi edi
|
||||||
|
mov ebx, [NET_DRV_LIST + 4*edi]
|
||||||
|
call ARP_output_request
|
||||||
|
pop edi esi
|
||||||
.found_it:
|
.found_it:
|
||||||
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
||||||
je .valid
|
je .valid
|
||||||
@ -558,7 +585,7 @@ end if
|
|||||||
;
|
;
|
||||||
; ARP_API
|
; ARP_API
|
||||||
;
|
;
|
||||||
; This function is called by system function 75
|
; This function is called by system function 76
|
||||||
;
|
;
|
||||||
; IN: subfunction number in bl
|
; IN: subfunction number in bl
|
||||||
; device number in bh
|
; device number in bh
|
||||||
@ -606,17 +633,19 @@ ARP_api:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.entries:
|
.entries:
|
||||||
mov eax, [NumARP]
|
mov eax, [ARP_entries_num + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.read:
|
.read:
|
||||||
cmp ecx, [NumARP]
|
cmp ecx, [ARP_entries_num + eax]
|
||||||
jae .error
|
jae .error
|
||||||
|
shr eax, 2
|
||||||
|
imul eax, sizeof.ARP_entry*ARP_TABLE_SIZE
|
||||||
|
add eax, ARP_table
|
||||||
; edi = pointer to buffer
|
; edi = pointer to buffer
|
||||||
; ecx = # entry
|
; ecx = # entry
|
||||||
imul ecx, sizeof.ARP_entry
|
imul ecx, sizeof.ARP_entry
|
||||||
add ecx, ARP_table
|
lea esi, [eax + ecx]
|
||||||
mov esi, ecx
|
|
||||||
mov ecx, sizeof.ARP_entry/2
|
mov ecx, sizeof.ARP_entry/2
|
||||||
rep movsw
|
rep movsw
|
||||||
|
|
||||||
@ -625,20 +654,24 @@ ARP_api:
|
|||||||
|
|
||||||
.write:
|
.write:
|
||||||
; esi = pointer to buffer
|
; esi = pointer to buffer
|
||||||
|
mov edi, eax
|
||||||
|
shr edi, 2
|
||||||
call ARP_add_entry ; out: eax = entry number, -1 on error
|
call ARP_add_entry ; out: eax = entry number, -1 on error
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.remove:
|
.remove:
|
||||||
; ecx = # entry
|
; ecx = # entry
|
||||||
cmp ecx, [NumARP]
|
cmp ecx, [ARP_entries_num + eax]
|
||||||
jae .error
|
jae .error
|
||||||
imul ecx, sizeof.ARP_entry
|
imul ecx, sizeof.ARP_entry
|
||||||
lea esi, [ARP_table + ecx]
|
lea esi, [ARP_table + ecx]
|
||||||
|
mov edi, eax
|
||||||
|
shr edi, 2
|
||||||
call ARP_del_entry
|
call ARP_del_entry
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.send_announce:
|
.send_announce:
|
||||||
mov edi, eax
|
mov ebx, [NET_DRV_LIST + eax]
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IP_LIST + eax]
|
||||||
call ARP_output_request ; now send a gratuitous ARP
|
call ARP_output_request ; now send a gratuitous ARP
|
||||||
ret
|
ret
|
||||||
|
@ -58,17 +58,17 @@ ends
|
|||||||
align 4
|
align 4
|
||||||
uglobal
|
uglobal
|
||||||
|
|
||||||
IP_LIST rd MAX_NET_DEVICES
|
IP_LIST rd NET_DEVICES_MAX
|
||||||
SUBNET_LIST rd MAX_NET_DEVICES
|
SUBNET_LIST rd NET_DEVICES_MAX
|
||||||
DNS_LIST rd MAX_NET_DEVICES
|
DNS_LIST rd NET_DEVICES_MAX
|
||||||
GATEWAY_LIST rd MAX_NET_DEVICES
|
GATEWAY_LIST rd NET_DEVICES_MAX
|
||||||
BROADCAST_LIST rd MAX_NET_DEVICES
|
BROADCAST_LIST rd NET_DEVICES_MAX
|
||||||
|
|
||||||
IP_packets_tx rd MAX_NET_DEVICES
|
IP_packets_tx rd NET_DEVICES_MAX
|
||||||
IP_packets_rx rd MAX_NET_DEVICES
|
IP_packets_rx rd NET_DEVICES_MAX
|
||||||
IP_packets_dumped rd MAX_NET_DEVICES
|
IP_packets_dumped rd NET_DEVICES_MAX
|
||||||
|
|
||||||
FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot
|
FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ macro IPv4_init {
|
|||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, IP_LIST
|
mov edi, IP_LIST
|
||||||
mov ecx, 7*MAX_NET_DEVICES + (sizeof.FRAGMENT_slot*MAX_FRAGMENTS)/4
|
mov ecx, 7*NET_DEVICES_MAX + (sizeof.FRAGMENT_slot*MAX_FRAGMENTS)/4
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -568,31 +568,32 @@ IPv4_find_fragment_slot:
|
|||||||
align 4
|
align 4
|
||||||
IPv4_output:
|
IPv4_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u\n", ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
|
||||||
|
|
||||||
cmp ecx, 65500 ; Max IPv4 packet size
|
cmp ecx, 65500 ; Max IPv4 packet size
|
||||||
ja .too_large
|
ja .too_large
|
||||||
|
|
||||||
push ecx eax edx di
|
push ecx eax edx di
|
||||||
|
|
||||||
cmp eax, 1 shl 24 + 127
|
|
||||||
je .loopback
|
|
||||||
|
|
||||||
call IPv4_route ; outputs device number in edi, dest ip in eax
|
call IPv4_route ; outputs device number in edi, dest ip in eax
|
||||||
|
|
||||||
|
test edi, edi
|
||||||
|
jz .loopback
|
||||||
|
|
||||||
call ARP_IP_to_MAC
|
call ARP_IP_to_MAC
|
||||||
test eax, 0xffff0000 ; error bits
|
test eax, 0xffff0000 ; error bits
|
||||||
jnz .arp_error
|
jnz .arp_error
|
||||||
push ebx ; push the mac onto the stack
|
push ebx ; push the mac onto the stack
|
||||||
push ax
|
push ax
|
||||||
|
|
||||||
inc [IP_packets_tx + edi] ; update stats
|
inc [IP_packets_tx + 4*edi] ; update stats
|
||||||
|
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [NET_DRV_LIST + 4*edi]
|
||||||
lea eax, [ebx + ETH_DEVICE.mac]
|
lea eax, [ebx + ETH_DEVICE.mac]
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
mov ecx, [esp + 10 + 6]
|
mov ecx, [esp + 10 + 6]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov di, ETHER_IPv4
|
mov di, ETHER_PROTO_IPv4
|
||||||
call ETH_output
|
call ETH_output
|
||||||
jz .eth_error
|
jz .eth_error
|
||||||
add esp, 6 ; pop the mac out of the stack
|
add esp, 6 ; pop the mac out of the stack
|
||||||
@ -618,13 +619,13 @@ IPv4_output:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.eth_error:
|
.eth_error:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: ethernet error\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n"
|
||||||
add esp, 3*4+2+6
|
add esp, 3*4+2+6
|
||||||
xor edi, edi
|
xor edi, edi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.arp_error:
|
.arp_error:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "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, 3*4+2
|
||||||
xor edi, edi
|
xor edi, edi
|
||||||
ret
|
ret
|
||||||
@ -635,9 +636,10 @@ IPv4_output:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.loopback:
|
.loopback:
|
||||||
mov dword [esp + 2], eax
|
mov dword [esp + 2], eax ; change source IP to dest IP
|
||||||
|
mov ecx, [esp + 10]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov di, ETHER_IPv4
|
mov edi, AF_INET4
|
||||||
call LOOP_output
|
call LOOP_output
|
||||||
jmp .continue
|
jmp .continue
|
||||||
|
|
||||||
@ -675,13 +677,13 @@ IPv4_output_raw:
|
|||||||
push ebx ; push the mac
|
push ebx ; push the mac
|
||||||
push ax
|
push ax
|
||||||
|
|
||||||
inc [IP_packets_tx + edi]
|
inc [IP_packets_tx + 4*edi]
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [NET_DRV_LIST + 4*edi]
|
||||||
lea eax, [ebx + ETH_DEVICE.mac]
|
lea eax, [ebx + ETH_DEVICE.mac]
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
mov ecx, [esp + 6 + 4]
|
mov ecx, [esp + 6 + 4]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov di, ETHER_IPv4
|
mov di, ETHER_PROTO_IPv4
|
||||||
call ETH_output
|
call ETH_output
|
||||||
jz .error
|
jz .error
|
||||||
|
|
||||||
@ -775,7 +777,7 @@ IPv4_fragment:
|
|||||||
|
|
||||||
mov eax, [esp + 3*4]
|
mov eax, [esp + 3*4]
|
||||||
lea ebx, [esp + 4*4]
|
lea ebx, [esp + 4*4]
|
||||||
mov di , ETHER_IPv4
|
mov di , ETHER_PROTO_IPv4
|
||||||
call ETH_output
|
call ETH_output
|
||||||
|
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
@ -855,7 +857,7 @@ IPv4_fragment:
|
|||||||
; IPv4_route
|
; IPv4_route
|
||||||
;
|
;
|
||||||
; IN: eax = Destination IP
|
; IN: eax = Destination IP
|
||||||
; OUT: edi = device id * 4
|
; OUT: edi = device number
|
||||||
; eax = ip of gateway if nescessary, unchanged otherwise
|
; eax = ip of gateway if nescessary, unchanged otherwise
|
||||||
;
|
;
|
||||||
;---------------------------------------------------------------------------
|
;---------------------------------------------------------------------------
|
||||||
@ -866,7 +868,7 @@ IPv4_route:
|
|||||||
je .broadcast
|
je .broadcast
|
||||||
|
|
||||||
xor edi, edi
|
xor edi, edi
|
||||||
mov ecx, MAX_NET_DEVICES
|
mov ecx, NET_DEVICES_MAX
|
||||||
.loop:
|
.loop:
|
||||||
mov ebx, [IP_LIST+edi]
|
mov ebx, [IP_LIST+edi]
|
||||||
and ebx, [SUBNET_LIST+edi]
|
and ebx, [SUBNET_LIST+edi]
|
||||||
@ -875,22 +877,21 @@ IPv4_route:
|
|||||||
and edx, [SUBNET_LIST+edi]
|
and edx, [SUBNET_LIST+edi]
|
||||||
|
|
||||||
cmp ebx, edx
|
cmp ebx, edx
|
||||||
je .found_it
|
jne .next
|
||||||
|
|
||||||
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
||||||
|
ret
|
||||||
|
|
||||||
.next:
|
.next:
|
||||||
add edi, 4
|
add edi, 4
|
||||||
dec ecx
|
dec ecx
|
||||||
jnz .loop
|
jnz .loop
|
||||||
|
|
||||||
.invalid:
|
.invalid:
|
||||||
xor edi, edi ; if none found, use device 0 as default
|
mov eax, [GATEWAY_LIST+4] ;;; FIXME
|
||||||
mov eax, [GATEWAY_LIST]
|
|
||||||
|
|
||||||
.found_it:
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
|
||||||
ret
|
|
||||||
|
|
||||||
.broadcast:
|
.broadcast:
|
||||||
xor edi, edi
|
xor edi, edi ; if none found, use device 1 as default ;;;; FIXME
|
||||||
|
inc di
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -973,7 +974,8 @@ IPv4_api:
|
|||||||
or ebx, ecx
|
or ebx, ecx
|
||||||
mov [BROADCAST_LIST + eax], ebx
|
mov [BROADCAST_LIST + eax], ebx
|
||||||
|
|
||||||
mov eax, ecx
|
mov ebx, [NET_DRV_LIST + eax]
|
||||||
|
mov eax, [IP_LIST + eax]
|
||||||
call ARP_output_request ; now send a gratuitous ARP
|
call ARP_output_request ; now send a gratuitous ARP
|
||||||
|
|
||||||
call NET_send_event
|
call NET_send_event
|
||||||
|
@ -34,13 +34,13 @@ align 4
|
|||||||
uglobal
|
uglobal
|
||||||
|
|
||||||
IPv6:
|
IPv6:
|
||||||
.addresses rd 4*MAX_NET_DEVICES
|
.addresses rd 4*NET_DEVICES_MAX
|
||||||
.subnet rd 4*MAX_NET_DEVICES
|
.subnet rd 4*NET_DEVICES_MAX
|
||||||
.dns rd 4*MAX_NET_DEVICES
|
.dns rd 4*NET_DEVICES_MAX
|
||||||
.gateway rd 4*MAX_NET_DEVICES
|
.gateway rd 4*NET_DEVICES_MAX
|
||||||
|
|
||||||
.packets_tx rd MAX_NET_DEVICES
|
.packets_tx rd NET_DEVICES_MAX
|
||||||
.packets_rx rd MAX_NET_DEVICES
|
.packets_rx rd NET_DEVICES_MAX
|
||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
@ -113,14 +113,14 @@ PPPoE_discovery_output:
|
|||||||
; Check that device exists and is ethernet device
|
; Check that device exists and is ethernet device
|
||||||
mov ebx, [eax + SOCKET.device]
|
mov ebx, [eax + SOCKET.device]
|
||||||
|
|
||||||
cmp ebx, MAX_NET_DEVICES
|
cmp ebx, NET_DEVICES_MAX
|
||||||
ja .bad
|
ja .bad
|
||||||
|
|
||||||
mov ebx, [NET_DRV_LIST + 4*ebx]
|
mov ebx, [NET_DRV_LIST + 4*ebx]
|
||||||
test ebx, ebx
|
test ebx, ebx
|
||||||
jz .bad
|
jz .bad
|
||||||
|
|
||||||
cmp [ebx + NET_DEVICE.type], NET_TYPE_ETH
|
cmp [ebx + NET_DEVICE.device_type], NET_DEVICE_ETH
|
||||||
jne .bad
|
jne .bad
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx
|
||||||
@ -148,9 +148,9 @@ PPPoE_discovery_output:
|
|||||||
lea esi, [ebx + ETH_DEVICE.mac]
|
lea esi, [ebx + ETH_DEVICE.mac]
|
||||||
movsd
|
movsd
|
||||||
movsw
|
movsw
|
||||||
cmp word[edi], ETHER_PPP_SESSION ; Allow only PPP_discovery, or LCP
|
cmp word[edi], ETHER_PROTO_PPP_SESSION ; Allow only PPP_discovery, or LCP
|
||||||
je @f
|
je @f
|
||||||
mov ax, ETHER_PPP_DISCOVERY
|
mov ax, ETHER_PROTO_PPP_DISCOVERY
|
||||||
stosw
|
stosw
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -200,10 +200,10 @@ PPPoE_session_input:
|
|||||||
mov ax, word [edx + PPPoE_frame.Payload]
|
mov ax, word [edx + PPPoE_frame.Payload]
|
||||||
add edx, PPPoE_frame.Payload + 2
|
add edx, PPPoE_frame.Payload + 2
|
||||||
|
|
||||||
cmp ax, PPP_IPv4
|
cmp ax, PPP_PROTO_IPv4
|
||||||
je IPv4_input
|
je IPv4_input
|
||||||
|
|
||||||
; cmp ax, PPP_IPv6
|
; cmp ax, PPP_PROTO_IPv6
|
||||||
; je IPv6_input
|
; je IPv6_input
|
||||||
|
|
||||||
jmp PPPoE_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
|
jmp PPPoE_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
|
||||||
@ -246,7 +246,7 @@ PPPoE_output:
|
|||||||
lea eax, [ebx + ETH_DEVICE.mac]
|
lea eax, [ebx + ETH_DEVICE.mac]
|
||||||
lea edx, [PPPoE_MAC]
|
lea edx, [PPPoE_MAC]
|
||||||
add ecx, PPPoE_frame.Payload + 2
|
add ecx, PPPoE_frame.Payload + 2
|
||||||
mov di, ETHER_PPP_SESSION
|
mov di, ETHER_PROTO_PPP_SESSION
|
||||||
call ETH_output
|
call ETH_output
|
||||||
jz .eth_error
|
jz .eth_error
|
||||||
|
|
||||||
|
@ -64,19 +64,19 @@ ETH_input:
|
|||||||
lea edx, [eax + sizeof.ETH_header]
|
lea edx, [eax + sizeof.ETH_header]
|
||||||
mov ax, [eax + ETH_header.Type]
|
mov ax, [eax + ETH_header.Type]
|
||||||
|
|
||||||
cmp ax, ETHER_IPv4
|
cmp ax, ETHER_PROTO_IPv4
|
||||||
je IPv4_input
|
je IPv4_input
|
||||||
|
|
||||||
cmp ax, ETHER_ARP
|
cmp ax, ETHER_PROTO_ARP
|
||||||
je ARP_input
|
je ARP_input
|
||||||
|
|
||||||
cmp ax, ETHER_IPv6
|
cmp ax, ETHER_PROTO_IPv6
|
||||||
je IPv6_input
|
je IPv6_input
|
||||||
|
|
||||||
cmp ax, ETHER_PPP_DISCOVERY
|
cmp ax, ETHER_PROTO_PPP_DISCOVERY
|
||||||
je PPPoE_discovery_input
|
je PPPoE_discovery_input
|
||||||
|
|
||||||
cmp ax, ETHER_PPP_SESSION
|
cmp ax, ETHER_PROTO_PPP_SESSION
|
||||||
je PPPoE_session_input
|
je PPPoE_session_input
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "ETH_input: Unknown packet type=%x\n", ax
|
DEBUGF DEBUG_NETWORK_ERROR, "ETH_input: Unknown packet type=%x\n", ax
|
||||||
@ -162,7 +162,7 @@ ETH_output:
|
|||||||
;
|
;
|
||||||
; ETH_API
|
; ETH_API
|
||||||
;
|
;
|
||||||
; This function is called by system function 75
|
; This function is called by system function 76
|
||||||
;
|
;
|
||||||
; IN: subfunction number in bl
|
; IN: subfunction number in bl
|
||||||
; device number in bh
|
; device number in bh
|
||||||
@ -174,11 +174,11 @@ ETH_output:
|
|||||||
align 4
|
align 4
|
||||||
ETH_api:
|
ETH_api:
|
||||||
|
|
||||||
cmp bh, MAX_NET_DEVICES
|
cmp bh, NET_DEVICES_MAX
|
||||||
ja .error
|
ja .error
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
mov eax, dword [NET_DRV_LIST + 4*eax]
|
mov eax, dword [NET_DRV_LIST + 4*eax]
|
||||||
cmp [eax + NET_DEVICE.type], NET_TYPE_ETH
|
cmp [eax + NET_DEVICE.device_type], NET_DEVICE_ETH
|
||||||
jne .error
|
jne .error
|
||||||
|
|
||||||
and ebx, 0xff
|
and ebx, 0xff
|
||||||
@ -187,39 +187,13 @@ ETH_api:
|
|||||||
jmp dword [.table + 4*ebx]
|
jmp dword [.table + 4*ebx]
|
||||||
|
|
||||||
.table:
|
.table:
|
||||||
dd .packets_tx ; 0
|
dd .read_mac ; 0
|
||||||
dd .packets_rx ; 1
|
|
||||||
dd .bytes_tx ; 2
|
|
||||||
dd .bytes_rx ; 3
|
|
||||||
dd .read_mac ; 4
|
|
||||||
dd .state ; 5
|
|
||||||
.number = ($ - .table) / 4 - 1
|
.number = ($ - .table) / 4 - 1
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
or eax, -1
|
or eax, -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.packets_tx:
|
|
||||||
mov eax, [eax + NET_DEVICE.packets_tx]
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
.packets_rx:
|
|
||||||
mov eax, [eax + NET_DEVICE.packets_rx]
|
|
||||||
ret
|
|
||||||
|
|
||||||
.bytes_tx:
|
|
||||||
mov ebx, dword [eax + NET_DEVICE.bytes_tx + 4]
|
|
||||||
mov eax, dword [eax + NET_DEVICE.bytes_tx]
|
|
||||||
mov [esp+20+4], ebx ; TODO: fix this ugly code
|
|
||||||
ret
|
|
||||||
|
|
||||||
.bytes_rx:
|
|
||||||
mov ebx, dword [eax + NET_DEVICE.bytes_rx + 4]
|
|
||||||
mov eax, dword [eax + NET_DEVICE.bytes_rx]
|
|
||||||
mov [esp+20+4], ebx ; TODO: fix this ugly code
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
.read_mac:
|
.read_mac:
|
||||||
movzx ebx, word [eax + ETH_DEVICE.mac]
|
movzx ebx, word [eax + ETH_DEVICE.mac]
|
||||||
@ -227,7 +201,4 @@ ETH_api:
|
|||||||
mov [esp+20+4], ebx ; TODO: fix this ugly code
|
mov [esp+20+4], ebx ; TODO: fix this ugly code
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.state:
|
|
||||||
mov eax, [eax + NET_DEVICE.state]
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
$Revision$
|
$Revision$
|
||||||
|
|
||||||
; ICMP types & codes
|
; ICMP types & codes
|
||||||
@ -100,8 +99,8 @@ ends
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
uglobal
|
uglobal
|
||||||
ICMP_PACKETS_TX rd MAX_NET_DEVICES
|
ICMP_PACKETS_TX rd NET_DEVICES_MAX
|
||||||
ICMP_PACKETS_RX rd MAX_NET_DEVICES
|
ICMP_PACKETS_RX rd NET_DEVICES_MAX
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ macro ICMP_init {
|
|||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, ICMP_PACKETS_TX
|
mov edi, ICMP_PACKETS_TX
|
||||||
mov ecx, 2*MAX_NET_DEVICES
|
mov ecx, 2*NET_DEVICES_MAX
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -168,16 +167,18 @@ ICMP_input:
|
|||||||
|
|
||||||
mov esi, [esp] ; Start of buffer
|
mov esi, [esp] ; Start of buffer
|
||||||
|
|
||||||
cmp dword[edi + 4], 1 shl 24 + 127
|
|
||||||
je .loopback
|
|
||||||
|
|
||||||
; Update stats (and validate device ptr)
|
; Update stats (and validate device ptr)
|
||||||
call NET_ptr_to_num
|
call NET_ptr_to_num
|
||||||
cmp edi,-1
|
cmp edi, -1
|
||||||
je .dump
|
je .dump
|
||||||
inc [ICMP_PACKETS_RX + 4*edi]
|
inc [ICMP_PACKETS_RX + 4*edi]
|
||||||
inc [ICMP_PACKETS_TX + 4*edi]
|
inc [ICMP_PACKETS_TX + 4*edi]
|
||||||
|
|
||||||
|
cmp ebx, LOOPBACK_DEVICE
|
||||||
|
je .loopback
|
||||||
|
|
||||||
|
; FIXME: dont assume device is an ethernet device!
|
||||||
|
|
||||||
; exchange dest and source address in IP header
|
; exchange dest and source address in IP header
|
||||||
; exchange dest and source MAC in ETH header
|
; exchange dest and source MAC in ETH header
|
||||||
push dword [esi + ETH_header.DstMAC]
|
push dword [esi + ETH_header.DstMAC]
|
||||||
@ -188,10 +189,10 @@ ICMP_input:
|
|||||||
push word [esi + ETH_header.SrcMAC + 4]
|
push word [esi + ETH_header.SrcMAC + 4]
|
||||||
pop word [esi + ETH_header.DstMAC + 4]
|
pop word [esi + ETH_header.DstMAC + 4]
|
||||||
pop word [esi + ETH_header.SrcMAC + 4]
|
pop word [esi + ETH_header.SrcMAC + 4]
|
||||||
add esi, sizeof.ETH_header-2
|
add esi, sizeof.ETH_header-4
|
||||||
|
|
||||||
.loopback:
|
.loopback:
|
||||||
add esi, 2
|
add esi, 4
|
||||||
push [esi + IPv4_header.SourceAddress]
|
push [esi + IPv4_header.SourceAddress]
|
||||||
push [esi + IPv4_header.DestinationAddress]
|
push [esi + IPv4_header.DestinationAddress]
|
||||||
pop [esi + IPv4_header.SourceAddress]
|
pop [esi + IPv4_header.SourceAddress]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; loopback.inc ;;
|
;; loopback.inc ;;
|
||||||
@ -19,31 +19,52 @@ $Revision: 2891 $
|
|||||||
iglobal
|
iglobal
|
||||||
|
|
||||||
LOOPBACK_DEVICE:
|
LOOPBACK_DEVICE:
|
||||||
.type dd NET_TYPE_LOOPBACK
|
|
||||||
.mtu dd 4096
|
|
||||||
.name dd .namestr
|
|
||||||
|
|
||||||
.unload dd .dummy_fn
|
.device_type dd NET_DEVICE_LOOPBACK
|
||||||
.reset dd .dummy_fn
|
.mtu dd 4096
|
||||||
.transmit dd LOOP_input
|
.name dd .namestr
|
||||||
|
|
||||||
.bytes_tx dq 0
|
.unload dd .dummy_fn
|
||||||
.bytes_rx dq 0
|
.reset dd .dummy_fn
|
||||||
.packets_tx dd 0
|
.transmit dd LOOP_input
|
||||||
.packets_rx dd 0
|
|
||||||
|
|
||||||
.namestr db 'loopback', 0
|
.bytes_tx dq 0
|
||||||
|
.bytes_rx dq 0
|
||||||
|
.packets_tx dd 0
|
||||||
|
.packets_rx dd 0
|
||||||
|
|
||||||
|
.link_state dd -1
|
||||||
|
.hwacc dd 0
|
||||||
|
|
||||||
|
.namestr db 'loopback', 0
|
||||||
|
|
||||||
.dummy_fn:
|
.dummy_fn:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
|
macro LOOP_init {
|
||||||
|
local .fail
|
||||||
|
|
||||||
|
mov ebx, LOOPBACK_DEVICE
|
||||||
|
call NET_add_device
|
||||||
|
|
||||||
|
cmp eax, -1
|
||||||
|
je .fail
|
||||||
|
|
||||||
|
mov [IP_LIST], 127 + 1 shl 24
|
||||||
|
mov [SUBNET_LIST], 255
|
||||||
|
mov [BROADCAST_LIST], 0xffffff00 + 127
|
||||||
|
|
||||||
|
.fail:
|
||||||
|
}
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
;
|
;
|
||||||
; LOOP_input
|
; LOOP_input
|
||||||
;
|
;
|
||||||
; IN: [esp+4] = Pointer to buffer
|
; IN: [esp+4] = Pointer to buffer
|
||||||
; [esp+8] = size of buffer
|
; [esp+8] = size of buffer
|
||||||
;
|
;
|
||||||
; OUT: /
|
; OUT: /
|
||||||
@ -59,12 +80,16 @@ LOOP_input:
|
|||||||
push ecx
|
push ecx
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
|
inc [LOOPBACK_DEVICE.packets_rx]
|
||||||
|
add dword[LOOPBACK_DEVICE.bytes_rx], ecx
|
||||||
|
adc dword[LOOPBACK_DEVICE.bytes_rx + 4], 0
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: size=%u\n", ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: size=%u\n", ecx
|
||||||
lea edx, [eax + 2]
|
lea edx, [eax + 4]
|
||||||
mov ax, word[eax]
|
mov eax, dword[eax]
|
||||||
mov ebx, LOOPBACK_DEVICE
|
mov ebx, LOOPBACK_DEVICE
|
||||||
|
|
||||||
cmp ax, ETHER_IPv4
|
cmp eax, AF_INET4
|
||||||
je IPv4_input
|
je IPv4_input
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", ax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", ax
|
||||||
@ -80,14 +105,14 @@ LOOP_input:
|
|||||||
; LOOP_output
|
; LOOP_output
|
||||||
;
|
;
|
||||||
; IN:
|
; IN:
|
||||||
; ecx = packet size
|
; ecx = packet size
|
||||||
; di = protocol
|
; edi = address family
|
||||||
;
|
;
|
||||||
; OUT: edi = 0 on error, pointer to buffer otherwise
|
; OUT: edi = 0 on error, pointer to buffer otherwise
|
||||||
; eax = buffer start
|
; eax = buffer start
|
||||||
; ebx = to device structure
|
; ebx = to device structure
|
||||||
; ecx = unchanged (packet size of embedded data)
|
; ecx = unchanged (packet size of embedded data)
|
||||||
; edx = size of complete buffer
|
; edx = size of complete buffer
|
||||||
;
|
;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@ -96,31 +121,34 @@ LOOP_output:
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
|
||||||
|
|
||||||
push ecx
|
push ecx
|
||||||
push di
|
push edi
|
||||||
|
|
||||||
add ecx, 2
|
add ecx, 4
|
||||||
cmp ecx, [LOOPBACK_DEVICE.mtu]
|
cmp ecx, [LOOPBACK_DEVICE.mtu]
|
||||||
ja .out_of_ram
|
ja .out_of_ram
|
||||||
stdcall kernel_alloc, ecx
|
stdcall kernel_alloc, ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .out_of_ram
|
jz .out_of_ram
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
pop ax
|
pop eax
|
||||||
stosw
|
stosd
|
||||||
|
|
||||||
lea eax, [edi - 2] ; Set eax to buffer start
|
lea eax, [edi - 4] ; Set eax to buffer start
|
||||||
pop ecx
|
pop ecx
|
||||||
lea edx, [ecx + 2] ; Set edx to complete buffer size
|
lea edx, [ecx + 4] ; Set edx to complete buffer size
|
||||||
mov ebx, LOOPBACK_DEVICE
|
mov ebx, LOOPBACK_DEVICE
|
||||||
|
|
||||||
.done:
|
inc [LOOPBACK_DEVICE.packets_tx]
|
||||||
|
add dword[LOOPBACK_DEVICE.bytes_tx], ecx
|
||||||
|
adc dword[LOOPBACK_DEVICE.bytes_tx + 4], 0
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: ptr=%x size=%u\n", eax, edx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: ptr=%x size=%u\n", eax, edx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.out_of_ram:
|
.out_of_ram:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: failed\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "LOOP_output: out of memory\n"
|
||||||
add esp, 2+4
|
add esp, 4+4
|
||||||
sub edi, edi
|
xor edi, edi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ struct TCP_SOCKET IP_SOCKET
|
|||||||
|
|
||||||
;-------
|
;-------
|
||||||
; Timers
|
; Timers
|
||||||
|
timer_flags dd ?
|
||||||
timer_retransmission dd ? ; rexmt
|
timer_retransmission dd ? ; rexmt
|
||||||
timer_persist dd ?
|
timer_persist dd ?
|
||||||
timer_keepalive dd ? ; keepalive/syn timeout
|
timer_keepalive dd ? ; keepalive/syn timeout
|
||||||
@ -215,18 +216,18 @@ macro SOCKET_init {
|
|||||||
|
|
||||||
@@:
|
@@:
|
||||||
pseudo_random eax
|
pseudo_random eax
|
||||||
cmp ax, MIN_EPHEMERAL_PORT
|
cmp ax, EPHEMERAL_PORT_MIN
|
||||||
jb @r
|
jb @r
|
||||||
cmp ax, MAX_EPHEMERAL_PORT
|
cmp ax, EPHEMERAL_PORT_MAX
|
||||||
ja @r
|
ja @r
|
||||||
xchg al, ah
|
xchg al, ah
|
||||||
mov [last_UDP_port], ax
|
mov [last_UDP_port], ax
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
pseudo_random eax
|
pseudo_random eax
|
||||||
cmp ax, MIN_EPHEMERAL_PORT
|
cmp ax, EPHEMERAL_PORT_MIN
|
||||||
jb @r
|
jb @r
|
||||||
cmp ax, MAX_EPHEMERAL_PORT
|
cmp ax, EPHEMERAL_PORT_MAX
|
||||||
ja @r
|
ja @r
|
||||||
xchg al, ah
|
xchg al, ah
|
||||||
mov [last_TCP_port], ax
|
mov [last_TCP_port], ax
|
||||||
@ -432,11 +433,10 @@ SOCKET_bind:
|
|||||||
.tcp:
|
.tcp:
|
||||||
.udp:
|
.udp:
|
||||||
|
|
||||||
mov ebx, [edx + 4] ; First, fill in the IP
|
cmp ebx, [edx + 4] ; First, fill in the IP
|
||||||
test ebx, ebx ; If IP is 0, use default
|
test ebx, ebx ; If IP is 0, use default
|
||||||
jnz @f
|
jnz @f
|
||||||
mov ebx, [NET_DEFAULT]
|
mov ebx, [IP_LIST + 4] ;;;;; FIXME !i!i!i
|
||||||
mov ebx, [IP_LIST + 4*ebx]
|
|
||||||
@@:
|
@@:
|
||||||
mov [eax + IP_SOCKET.LocalIP], ebx
|
mov [eax + IP_SOCKET.LocalIP], ebx
|
||||||
|
|
||||||
@ -483,7 +483,7 @@ SOCKET_connect:
|
|||||||
.af_inet4:
|
.af_inet4:
|
||||||
cmp [eax + IP_SOCKET.LocalIP], 0
|
cmp [eax + IP_SOCKET.LocalIP], 0
|
||||||
jne @f
|
jne @f
|
||||||
push [IP_LIST] ; FIXME
|
push [IP_LIST + 4] ; FIXME !i!i!i!
|
||||||
pop [eax + IP_SOCKET.LocalIP]
|
pop [eax + IP_SOCKET.LocalIP]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ SOCKET_listen:
|
|||||||
|
|
||||||
cmp [eax + IP_SOCKET.LocalIP], 0
|
cmp [eax + IP_SOCKET.LocalIP], 0
|
||||||
jne @f
|
jne @f
|
||||||
push [IP_LIST]
|
push [IP_LIST + 4] ;;; fixme!!!!
|
||||||
pop [eax + IP_SOCKET.LocalIP]
|
pop [eax + IP_SOCKET.LocalIP]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -1121,7 +1121,7 @@ SOCKET_set_opt:
|
|||||||
je .unbind
|
je .unbind
|
||||||
|
|
||||||
movzx edx, byte [edx + 9]
|
movzx edx, byte [edx + 9]
|
||||||
cmp edx, MAX_NET_DEVICES
|
cmp edx, NET_DEVICES_MAX
|
||||||
ja s_error
|
ja s_error
|
||||||
|
|
||||||
mov edx, [NET_DRV_LIST + 4*edx]
|
mov edx, [NET_DRV_LIST + 4*edx]
|
||||||
|
@ -31,31 +31,20 @@ endg
|
|||||||
DEBUG_NETWORK_ERROR = 1
|
DEBUG_NETWORK_ERROR = 1
|
||||||
DEBUG_NETWORK_VERBOSE = 0
|
DEBUG_NETWORK_VERBOSE = 0
|
||||||
|
|
||||||
MAX_NET_DEVICES = 16
|
NET_DEVICES_MAX = 16
|
||||||
ARP_BLOCK = 1 ; true or false
|
ARP_BLOCK = 1 ; true or false
|
||||||
|
|
||||||
MIN_EPHEMERAL_PORT = 49152
|
EPHEMERAL_PORT_MIN = 49152
|
||||||
|
EPHEMERAL_PORT_MAX = 61000
|
||||||
MIN_EPHEMERAL_PORT_N = 0x00C0 ; same in Network byte order (FIXME)
|
MIN_EPHEMERAL_PORT_N = 0x00C0 ; same in Network byte order (FIXME)
|
||||||
MAX_EPHEMERAL_PORT = 61000
|
|
||||||
MAX_EPHEMERAL_PORT_N = 0x48EE ; same in Network byte order (FIXME)
|
MAX_EPHEMERAL_PORT_N = 0x48EE ; same in Network byte order (FIXME)
|
||||||
|
|
||||||
; Ethernet protocol numbers
|
; Ethernet protocol numbers
|
||||||
ETHER_ARP = 0x0608
|
ETHER_PROTO_ARP = 0x0608
|
||||||
ETHER_IPv4 = 0x0008
|
ETHER_PROTO_IPv4 = 0x0008
|
||||||
ETHER_IPv6 = 0xDD86
|
ETHER_PROTO_IPv6 = 0xDD86
|
||||||
ETHER_PPP_DISCOVERY = 0x6388
|
ETHER_PROTO_PPP_DISCOVERY = 0x6388
|
||||||
ETHER_PPP_SESSION = 0x6488
|
ETHER_PROTO_PPP_SESSION = 0x6488
|
||||||
|
|
||||||
; PPP protocol numbers
|
|
||||||
PPP_IPv4 = 0x2100
|
|
||||||
PPP_IPV6 = 0x5780
|
|
||||||
|
|
||||||
;Protocol family
|
|
||||||
AF_UNSPEC = 0
|
|
||||||
AF_LOCAL = 1
|
|
||||||
AF_INET4 = 2
|
|
||||||
AF_INET6 = 10
|
|
||||||
AF_PPP = 777
|
|
||||||
|
|
||||||
; Internet protocol numbers
|
; Internet protocol numbers
|
||||||
IP_PROTO_IP = 0
|
IP_PROTO_IP = 0
|
||||||
@ -63,8 +52,17 @@ IP_PROTO_ICMP = 1
|
|||||||
IP_PROTO_TCP = 6
|
IP_PROTO_TCP = 6
|
||||||
IP_PROTO_UDP = 17
|
IP_PROTO_UDP = 17
|
||||||
|
|
||||||
; PPP protocol number
|
; PPP protocol numbers
|
||||||
PPP_PROTO_ETHERNET = 666
|
PPP_PROTO_IPv4 = 0x2100
|
||||||
|
PPP_PROTO_IPV6 = 0x5780
|
||||||
|
PPP_PROTO_ETHERNET = 666 ; FIXME
|
||||||
|
|
||||||
|
;Protocol family
|
||||||
|
AF_UNSPEC = 0
|
||||||
|
AF_LOCAL = 1
|
||||||
|
AF_INET4 = 2
|
||||||
|
AF_INET6 = 10
|
||||||
|
AF_PPP = 777 ; FIXME
|
||||||
|
|
||||||
; Socket types
|
; Socket types
|
||||||
SOCK_STREAM = 1
|
SOCK_STREAM = 1
|
||||||
@ -83,7 +81,7 @@ SO_REUSEPORT = 1 shl 7
|
|||||||
SO_USELOOPBACK = 1 shl 8
|
SO_USELOOPBACK = 1 shl 8
|
||||||
SO_BINDTODEVICE = 1 shl 9
|
SO_BINDTODEVICE = 1 shl 9
|
||||||
|
|
||||||
SO_BLOCK = 1 shl 10 ; TO BE REMOVED
|
SO_BLOCK = 1 shl 10 ; TO BE REMOVED
|
||||||
SO_NONBLOCK = 1 shl 31
|
SO_NONBLOCK = 1 shl 31
|
||||||
|
|
||||||
; Socket flags for user calls
|
; Socket flags for user calls
|
||||||
@ -95,32 +93,26 @@ 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
|
||||||
SS_ISCONNECTING = 0x0004 ; in process of connecting to peer
|
SS_ISCONNECTING = 0x0004 ; in process of connecting to peer
|
||||||
SS_ISDISCONNECTING = 0x0008 ; in process of disconnecting
|
SS_ISDISCONNECTING = 0x0008 ; in process of disconnecting
|
||||||
SS_CANTSENDMORE = 0x0010 ; can't send more data to peer
|
SS_CANTSENDMORE = 0x0010 ; can't send more data to peer
|
||||||
SS_CANTRCVMORE = 0x0020 ; can't receive more data from peer
|
SS_CANTRCVMORE = 0x0020 ; can't receive more data from peer
|
||||||
SS_RCVATMARK = 0x0040 ; at mark on input
|
SS_RCVATMARK = 0x0040 ; at mark on input
|
||||||
SS_ISABORTING = 0x0080 ; aborting fd references - close()
|
SS_ISABORTING = 0x0080 ; aborting fd references - close()
|
||||||
SS_RESTARTSYS = 0x0100 ; restart blocked system calls
|
SS_RESTARTSYS = 0x0100 ; restart blocked system calls
|
||||||
SS_ISDISCONNECTED = 0x0800 ; socket disconnected from peer
|
SS_ISDISCONNECTED = 0x0800 ; socket disconnected from peer
|
||||||
|
|
||||||
SS_ASYNC = 0x0100 ; async i/o notify
|
SS_ASYNC = 0x0100 ; async i/o notify
|
||||||
SS_ISCONFIRMING = 0x0200 ; deciding to accept connection req
|
SS_ISCONFIRMING = 0x0200 ; deciding to accept connection req
|
||||||
SS_MORETOCOME = 0x0400
|
SS_MORETOCOME = 0x0400
|
||||||
|
|
||||||
SS_BLOCKED = 0x8000
|
SS_BLOCKED = 0x8000
|
||||||
|
|
||||||
|
|
||||||
SOCKET_MAXDATA = 4096*32 ; must be 4096*(power of 2) where 'power of 2' is at least 8
|
SOCKET_MAXDATA = 4096*32 ; must be 4096*(power of 2) where 'power of 2' is at least 8
|
||||||
|
MAX_backlog = 20 ; maximum backlog for stream sockets
|
||||||
; Network driver types
|
|
||||||
NET_TYPE_LOOPBACK = 0
|
|
||||||
NET_TYPE_ETH = 1
|
|
||||||
NET_TYPE_SLIP = 2
|
|
||||||
|
|
||||||
MAX_backlog = 20 ; maximum backlog for stream sockets
|
|
||||||
|
|
||||||
; Error Codes
|
; Error Codes
|
||||||
ENOBUFS = 55
|
ENOBUFS = 55
|
||||||
@ -139,11 +131,23 @@ API_ARP = 5
|
|||||||
API_PPPOE = 6
|
API_PPPOE = 6
|
||||||
API_IPv6 = 7
|
API_IPv6 = 7
|
||||||
|
|
||||||
|
; Network device types
|
||||||
|
NET_DEVICE_LOOPBACK = 0
|
||||||
|
NET_DEVICE_ETH = 1
|
||||||
|
NET_DEVICE_SLIP = 2
|
||||||
|
|
||||||
|
; Network link types (link protocols)
|
||||||
|
NET_LINK_LOOPBACK = 0 ;;; Really a link type?
|
||||||
|
NET_LINK_MAC = 1 ; Media access control (ethernet, isdn, ...)
|
||||||
|
NET_LINK_PPP = 2 ; Point to Point Protocol (PPPoE, ...)
|
||||||
|
NET_LINK_IEEE802.11 = 3 ; IEEE 802.11 (WiFi)
|
||||||
|
|
||||||
|
; Hardware acceleration bits
|
||||||
HWACC_TCP_IPv4 = 1 shl 0
|
HWACC_TCP_IPv4 = 1 shl 0
|
||||||
|
|
||||||
struct NET_DEVICE
|
struct NET_DEVICE
|
||||||
|
|
||||||
type dd ? ; Type field
|
device_type dd ? ; Type field
|
||||||
mtu dd ? ; Maximal Transmission Unit
|
mtu dd ? ; Maximal Transmission Unit
|
||||||
name dd ? ; Ptr to 0 terminated string
|
name dd ? ; Ptr to 0 terminated string
|
||||||
|
|
||||||
@ -156,7 +160,7 @@ struct NET_DEVICE
|
|||||||
packets_tx dd ? ;
|
packets_tx dd ? ;
|
||||||
packets_rx dd ? ;
|
packets_rx dd ? ;
|
||||||
|
|
||||||
state dd ? ; link state (0 = no link)
|
link_state dd ? ; link state (0 = no link)
|
||||||
hwacc dd ? ; bitmask stating enabled HW accelerations (offload engines)
|
hwacc dd ? ; bitmask stating enabled HW accelerations (offload engines)
|
||||||
|
|
||||||
ends
|
ends
|
||||||
@ -213,8 +217,7 @@ align 4
|
|||||||
uglobal
|
uglobal
|
||||||
|
|
||||||
NET_RUNNING dd ?
|
NET_RUNNING dd ?
|
||||||
NET_DEFAULT dd ?
|
NET_DRV_LIST rd NET_DEVICES_MAX
|
||||||
NET_DRV_LIST rd MAX_NET_DEVICES
|
|
||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
@ -235,7 +238,7 @@ stack_init:
|
|||||||
; Init the network drivers list
|
; Init the network drivers list
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, NET_RUNNING
|
mov edi, NET_RUNNING
|
||||||
mov ecx, (MAX_NET_DEVICES + 2)
|
mov ecx, (NET_DEVICES_MAX + 2)
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
PPPoE_init
|
PPPoE_init
|
||||||
@ -250,6 +253,8 @@ stack_init:
|
|||||||
|
|
||||||
SOCKET_init
|
SOCKET_init
|
||||||
|
|
||||||
|
LOOP_init
|
||||||
|
|
||||||
mov [net_tmr_count], 0
|
mov [net_tmr_count], 0
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -308,7 +313,7 @@ stack_handler:
|
|||||||
align 4
|
align 4
|
||||||
NET_link_changed:
|
NET_link_changed:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.state]
|
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.link_state]
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_send_event:
|
NET_send_event:
|
||||||
@ -345,13 +350,13 @@ NET_add_device:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list
|
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list
|
||||||
|
|
||||||
cmp [NET_RUNNING], MAX_NET_DEVICES
|
cmp [NET_RUNNING], NET_DEVICES_MAX
|
||||||
jae .error
|
jae .error
|
||||||
|
|
||||||
;----------------------------------
|
;----------------------------------
|
||||||
; Check if device is already listed
|
; Check if device is already listed
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ecx, MAX_NET_DEVICES ; We need to check whole list because a device may be removed without re-organizing list
|
mov ecx, NET_DEVICES_MAX ; We need to check whole list because a device may be removed without re-organizing list
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, NET_DRV_LIST
|
||||||
|
|
||||||
repne scasd ; See if device is already in the list
|
repne scasd ; See if device is already in the list
|
||||||
@ -360,7 +365,7 @@ NET_add_device:
|
|||||||
;----------------------------
|
;----------------------------
|
||||||
; Find empty slot in the list
|
; Find empty slot in the list
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov ecx, MAX_NET_DEVICES
|
mov ecx, NET_DEVICES_MAX
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, NET_DRV_LIST
|
||||||
|
|
||||||
repne scasd
|
repne scasd
|
||||||
@ -378,13 +383,6 @@ NET_add_device:
|
|||||||
|
|
||||||
inc [NET_RUNNING] ; Indicate that one more network device is up and running
|
inc [NET_RUNNING] ; Indicate that one more network device is up and running
|
||||||
|
|
||||||
cmp eax, 1 ; If it's the first network device, try to set it as default
|
|
||||||
jne @f
|
|
||||||
push eax
|
|
||||||
call NET_set_default
|
|
||||||
pop eax
|
|
||||||
@@:
|
|
||||||
|
|
||||||
call NET_send_event
|
call NET_send_event
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Device number: %u\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Device number: %u\n", eax
|
||||||
@ -397,43 +395,11 @@ NET_add_device:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; NET_set_default
|
|
||||||
;
|
|
||||||
; API to set the default interface
|
|
||||||
;
|
|
||||||
; IN: Device num in eax
|
|
||||||
; OUT: Device num in eax, -1 on error
|
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
|
||||||
NET_set_default:
|
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_set_default: device=%x\n", eax
|
|
||||||
|
|
||||||
cmp eax, MAX_NET_DEVICES
|
|
||||||
jae .error
|
|
||||||
|
|
||||||
cmp [NET_DRV_LIST+eax*4], 0
|
|
||||||
je .error
|
|
||||||
|
|
||||||
mov [NET_DEFAULT], eax
|
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_set_default: succes\n"
|
|
||||||
ret
|
|
||||||
|
|
||||||
.error:
|
|
||||||
or eax, -1
|
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "NET_set_default: failed\n"
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
;
|
;
|
||||||
; NET_Remove_Device:
|
; NET_Remove_Device:
|
||||||
;
|
;
|
||||||
; This function is called by etwork drivers,
|
; This function is called by network drivers,
|
||||||
; to unregister network devices from the kernel
|
; to unregister network devices from the kernel
|
||||||
;
|
;
|
||||||
; IN: Pointer to device structure in ebx
|
; IN: Pointer to device structure in ebx
|
||||||
@ -446,28 +412,12 @@ NET_remove_device:
|
|||||||
cmp [NET_RUNNING], 0
|
cmp [NET_RUNNING], 0
|
||||||
je .error
|
je .error
|
||||||
|
|
||||||
cmp [NET_DRV_LIST], ebx
|
|
||||||
jne @f
|
|
||||||
mov [NET_DRV_LIST], 0
|
|
||||||
cmp [NET_RUNNING], 1
|
|
||||||
je @f
|
|
||||||
; there are still active devices, find one and make it default
|
|
||||||
xor eax, eax
|
|
||||||
mov ecx, MAX_NET_DEVICES
|
|
||||||
mov edi, NET_DRV_LIST
|
|
||||||
repe scasd
|
|
||||||
je @f
|
|
||||||
shr edi, 2
|
|
||||||
dec edi
|
|
||||||
mov [NET_DEFAULT], edi
|
|
||||||
@@:
|
|
||||||
|
|
||||||
;----------------------------
|
;----------------------------
|
||||||
; Find the driver in the list
|
; Find the driver in the list
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ecx, MAX_NET_DEVICES
|
mov ecx, NET_DEVICES_MAX
|
||||||
mov edi, NET_DRV_LIST+4
|
mov edi, NET_DRV_LIST
|
||||||
|
|
||||||
repne scasd
|
repne scasd
|
||||||
jnz .error
|
jnz .error
|
||||||
@ -477,10 +427,11 @@ NET_remove_device:
|
|||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov dword [edi-4], eax
|
mov dword [edi-4], eax
|
||||||
|
dec [NET_RUNNING]
|
||||||
|
|
||||||
call NET_send_event
|
call NET_send_event
|
||||||
|
|
||||||
dec [NET_RUNNING]
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
@ -501,7 +452,7 @@ align 4
|
|||||||
NET_ptr_to_num:
|
NET_ptr_to_num:
|
||||||
push ecx
|
push ecx
|
||||||
|
|
||||||
mov ecx, MAX_NET_DEVICES
|
mov ecx, NET_DEVICES_MAX
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, NET_DRV_LIST
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
@ -645,20 +596,21 @@ checksum_2:
|
|||||||
|
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
;
|
;
|
||||||
; System function to work with network devices (75)
|
; System function to work with network devices (74)
|
||||||
;
|
;
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
sys_network: ; FIXME: make default device easily accessible
|
sys_network:
|
||||||
|
|
||||||
cmp ebx, -1
|
cmp ebx, -1
|
||||||
jne @f
|
jne @f
|
||||||
|
|
||||||
mov eax, [NET_RUNNING]
|
mov eax, [NET_RUNNING]
|
||||||
jmp .return
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
cmp bh, MAX_NET_DEVICES ; Check if device number exists
|
cmp bh, NET_DEVICES_MAX ; Check if device number exists
|
||||||
jae .doesnt_exist
|
jae .doesnt_exist
|
||||||
|
|
||||||
mov esi, ebx
|
mov esi, ebx
|
||||||
@ -682,17 +634,20 @@ sys_network: ; FIXME: make default device easily accessible
|
|||||||
dd .stop ; 3
|
dd .stop ; 3
|
||||||
dd .get_ptr ; 4
|
dd .get_ptr ; 4
|
||||||
dd .get_drv_name ; 5
|
dd .get_drv_name ; 5
|
||||||
dd .set_default ; 6
|
|
||||||
|
dd .packets_tx ; 6
|
||||||
|
dd .packets_rx ; 7
|
||||||
|
dd .bytes_tx ; 8
|
||||||
|
dd .bytes_rx ; 9
|
||||||
|
dd .state ; 10
|
||||||
.number = ($ - .table) / 4 - 1
|
.number = ($ - .table) / 4 - 1
|
||||||
|
|
||||||
.get_type: ; 0 = Get device type (ethernet/token ring/...)
|
.get_type:
|
||||||
|
mov eax, [eax + NET_DEVICE.device_type]
|
||||||
mov eax, [eax + NET_DEVICE.type]
|
mov [esp+32], eax
|
||||||
jmp .return
|
ret
|
||||||
|
|
||||||
|
|
||||||
.get_dev_name: ; 1 = Get device name
|
|
||||||
|
|
||||||
|
.get_dev_name:
|
||||||
mov esi, [eax + NET_DEVICE.name]
|
mov esi, [eax + NET_DEVICE.name]
|
||||||
mov edi, ecx
|
mov edi, ecx
|
||||||
|
|
||||||
@ -700,42 +655,65 @@ sys_network: ; FIXME: make default device easily accessible
|
|||||||
rep movsd
|
rep movsd
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
jmp .return
|
|
||||||
|
|
||||||
.reset: ; 2 = Reset the device
|
|
||||||
|
|
||||||
call [eax + NET_DEVICE.reset]
|
|
||||||
jmp .return
|
|
||||||
|
|
||||||
.stop: ; 3 = Stop driver for this device
|
|
||||||
|
|
||||||
call [eax + NET_DEVICE.unload]
|
|
||||||
jmp .return
|
|
||||||
|
|
||||||
|
|
||||||
.get_ptr: ; 4 = Get driver pointer
|
|
||||||
|
|
||||||
jmp .return
|
|
||||||
|
|
||||||
|
|
||||||
.get_drv_name: ; 5 = Get driver name
|
|
||||||
|
|
||||||
xor eax, eax
|
|
||||||
jmp .return
|
|
||||||
|
|
||||||
|
|
||||||
.set_default: ; 6 = Set default device
|
|
||||||
|
|
||||||
call NET_set_default
|
|
||||||
jmp .return
|
|
||||||
|
|
||||||
.doesnt_exist:
|
|
||||||
mov eax, -1
|
|
||||||
|
|
||||||
.return:
|
|
||||||
mov [esp+32], eax
|
mov [esp+32], eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.reset:
|
||||||
|
call [eax + NET_DEVICE.reset]
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.stop:
|
||||||
|
call [eax + NET_DEVICE.unload]
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
.get_ptr:
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
.get_drv_name:
|
||||||
|
xor eax, eax
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.packets_tx:
|
||||||
|
mov eax, [eax + NET_DEVICE.packets_tx]
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.packets_rx:
|
||||||
|
mov eax, [eax + NET_DEVICE.packets_rx]
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.bytes_tx:
|
||||||
|
mov ebx, dword [eax + NET_DEVICE.bytes_tx + 4]
|
||||||
|
mov [esp+20], ebx
|
||||||
|
mov eax, dword [eax + NET_DEVICE.bytes_tx]
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.bytes_rx:
|
||||||
|
mov ebx, dword [eax + NET_DEVICE.bytes_rx + 4]
|
||||||
|
mov [esp+20], ebx
|
||||||
|
mov eax, dword [eax + NET_DEVICE.bytes_rx]
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.state:
|
||||||
|
mov eax, [eax + NET_DEVICE.link_state]
|
||||||
|
mov [esp+32], eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
.doesnt_exist:
|
||||||
|
mov dword[esp+32], -1
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
;
|
;
|
||||||
@ -744,7 +722,7 @@ sys_network: ; FIXME: make default device easily accessible
|
|||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
sys_protocols:
|
sys_protocols:
|
||||||
cmp bh, MAX_NET_DEVICES ; Check if device number exists
|
cmp bh, NET_DEVICES_MAX ; Check if device number exists
|
||||||
jae .doesnt_exist
|
jae .doesnt_exist
|
||||||
|
|
||||||
mov esi, ebx
|
mov esi, ebx
|
||||||
|
@ -129,12 +129,12 @@ ends
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
uglobal
|
uglobal
|
||||||
TCP_segments_tx rd MAX_NET_DEVICES
|
TCP_segments_tx rd NET_DEVICES_MAX
|
||||||
TCP_segments_rx rd MAX_NET_DEVICES
|
TCP_segments_rx rd NET_DEVICES_MAX
|
||||||
TCP_segments_missed rd MAX_NET_DEVICES
|
TCP_segments_missed rd NET_DEVICES_MAX
|
||||||
TCP_segments_dumped rd MAX_NET_DEVICES
|
TCP_segments_dumped rd NET_DEVICES_MAX
|
||||||
; TCP_bytes_rx rq MAX_NET_DEVICES
|
; TCP_bytes_rx rq NET_DEVICES_MAX
|
||||||
; TCP_bytes_tx rq MAX_NET_DEVICES
|
; TCP_bytes_tx rq NET_DEVICES_MAX
|
||||||
TCP_sequence_num dd ?
|
TCP_sequence_num dd ?
|
||||||
TCP_queue rd TCP_QUEUE_SIZE*sizeof.TCP_queue_entry/4
|
TCP_queue rd TCP_QUEUE_SIZE*sizeof.TCP_queue_entry/4
|
||||||
TCP_input_event dd ?
|
TCP_input_event dd ?
|
||||||
@ -152,7 +152,7 @@ macro TCP_init {
|
|||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, TCP_segments_tx
|
mov edi, TCP_segments_tx
|
||||||
mov ecx, (6*MAX_NET_DEVICES)
|
mov ecx, (6*NET_DEVICES_MAX)
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
pseudo_random eax
|
pseudo_random eax
|
||||||
@ -160,8 +160,7 @@ macro TCP_init {
|
|||||||
|
|
||||||
init_queue TCP_queue
|
init_queue TCP_queue
|
||||||
|
|
||||||
push 1
|
movi ebx, 1
|
||||||
pop ebx
|
|
||||||
mov ecx, TCP_process_input
|
mov ecx, TCP_process_input
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
|
|
||||||
|
@ -253,6 +253,7 @@ TCP_process_input:
|
|||||||
|
|
||||||
mov [ebx + TCP_SOCKET.t_idle], 0
|
mov [ebx + TCP_SOCKET.t_idle], 0
|
||||||
mov [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
|
mov [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
||||||
|
|
||||||
;--------------------
|
;--------------------
|
||||||
; Process TCP options
|
; Process TCP options
|
||||||
@ -488,7 +489,7 @@ TCP_process_input:
|
|||||||
mov [ebx + TCP_SOCKET.SND_UNA], eax
|
mov [ebx + TCP_SOCKET.SND_UNA], eax
|
||||||
|
|
||||||
; Stop retransmit timer
|
; Stop retransmit timer
|
||||||
mov [ebx + TCP_SOCKET.timer_retransmission], 0
|
and [ebx + TCP_SOCKET.timer_flags], not timer_flag_retransmission
|
||||||
|
|
||||||
; Unlock the socket
|
; Unlock the socket
|
||||||
pusha
|
pusha
|
||||||
@ -852,8 +853,8 @@ TCP_process_input:
|
|||||||
; (window info didnt change) The ACK is the biggest we've seen and we've seen exactly our rexmt threshold of them,
|
; (window info didnt change) The ACK is the biggest we've seen and we've seen exactly our rexmt threshold of them,
|
||||||
; assume a packet has been dropped and retransmit it. Kludge snd_nxt & the congestion window so we send only this one packet.
|
; assume a packet has been dropped and retransmit it. Kludge snd_nxt & the congestion window so we send only this one packet.
|
||||||
|
|
||||||
cmp [ebx + TCP_SOCKET.timer_retransmission], 0 ;;;; FIXME
|
test [ebx + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
jg @f
|
jz @f
|
||||||
|
|
||||||
mov eax, [edx + TCP_header.AckNumber]
|
mov eax, [edx + TCP_header.AckNumber]
|
||||||
cmp eax, [ebx + TCP_SOCKET.SND_UNA]
|
cmp eax, [ebx + TCP_SOCKET.SND_UNA]
|
||||||
@ -886,7 +887,7 @@ TCP_process_input:
|
|||||||
pop edx
|
pop edx
|
||||||
mov [ebx + TCP_SOCKET.SND_SSTHRESH], eax
|
mov [ebx + TCP_SOCKET.SND_SSTHRESH], eax
|
||||||
|
|
||||||
mov [ebx + TCP_SOCKET.timer_retransmission], 0 ; turn off retransmission timer
|
and [ebx + TCP_SOCKET.timer_flags], not timer_flag_retransmission ; turn off retransmission timer
|
||||||
mov [ebx + TCP_SOCKET.t_rtt], 0
|
mov [ebx + TCP_SOCKET.t_rtt], 0
|
||||||
mov eax, [edx + TCP_header.AckNumber]
|
mov eax, [edx + TCP_header.AckNumber]
|
||||||
mov [ebx + TCP_SOCKET.SND_NXT], eax
|
mov [ebx + TCP_SOCKET.SND_NXT], eax
|
||||||
@ -1017,16 +1018,16 @@ TCP_process_input:
|
|||||||
mov eax, [ebx + TCP_SOCKET.SND_MAX]
|
mov eax, [ebx + TCP_SOCKET.SND_MAX]
|
||||||
cmp eax, [edx + TCP_header.AckNumber]
|
cmp eax, [edx + TCP_header.AckNumber]
|
||||||
jne .more_data
|
jne .more_data
|
||||||
mov [ebx + TCP_SOCKET.timer_retransmission], 0
|
and [ebx + TCP_SOCKET.timer_flags], not timer_flag_retransmission
|
||||||
or [ebx + TCP_SOCKET.temp_bits], TCP_BIT_NEEDOUTPUT
|
or [ebx + TCP_SOCKET.temp_bits], TCP_BIT_NEEDOUTPUT
|
||||||
jmp .no_restart
|
jmp .no_restart
|
||||||
.more_data:
|
.more_data:
|
||||||
cmp [ebx + TCP_SOCKET.timer_persist], 0
|
test [ebx + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
jne .no_restart
|
jnz .no_restart
|
||||||
|
|
||||||
mov eax, [ebx + TCP_SOCKET.t_rxtcur]
|
mov eax, [ebx + TCP_SOCKET.t_rxtcur]
|
||||||
mov [ebx + TCP_SOCKET.timer_retransmission], eax
|
mov [ebx + TCP_SOCKET.timer_retransmission], eax
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
.no_restart:
|
.no_restart:
|
||||||
|
|
||||||
|
|
||||||
@ -1140,6 +1141,7 @@ TCP_process_input:
|
|||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_disconnected
|
call SOCKET_is_disconnected
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle
|
mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
@@:
|
@@:
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_FIN_WAIT_2
|
mov [ebx + TCP_SOCKET.t_state], TCPS_FIN_WAIT_2
|
||||||
jmp .ack_processed
|
jmp .ack_processed
|
||||||
@ -1151,6 +1153,7 @@ TCP_process_input:
|
|||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_cancel_timers
|
call TCP_cancel_timers
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_disconnected
|
call SOCKET_is_disconnected
|
||||||
jmp .ack_processed
|
jmp .ack_processed
|
||||||
@ -1164,6 +1167,7 @@ TCP_process_input:
|
|||||||
|
|
||||||
.ack_tw:
|
.ack_tw:
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
jmp .drop_after_ack
|
jmp .drop_after_ack
|
||||||
|
|
||||||
.reset_dupacks: ; We got a new ACK, reset duplicate ACK counter
|
.reset_dupacks: ; We got a new ACK, reset duplicate ACK counter
|
||||||
@ -1209,6 +1213,7 @@ align 4
|
|||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
||||||
mov [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
mov [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
mov [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval ;;;; macro
|
mov [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval ;;;; macro
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
||||||
|
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_create
|
call SOCKET_ring_create
|
||||||
@ -1272,7 +1277,7 @@ align 4
|
|||||||
@@:
|
@@:
|
||||||
|
|
||||||
.no_syn_ack:
|
.no_syn_ack:
|
||||||
mov [ebx + TCP_SOCKET.timer_retransmission], 0 ; disable retransmission
|
and [ebx + TCP_SOCKET.timer_flags], not timer_flag_retransmission ; disable retransmission timer
|
||||||
|
|
||||||
push [edx + TCP_header.SequenceNumber]
|
push [edx + TCP_header.SequenceNumber]
|
||||||
pop [ebx + TCP_SOCKET.IRS]
|
pop [ebx + TCP_SOCKET.IRS]
|
||||||
@ -1525,11 +1530,13 @@ align 4
|
|||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_cancel_timers
|
call TCP_cancel_timers
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
call SOCKET_is_disconnected
|
call SOCKET_is_disconnected
|
||||||
jmp .final_processing
|
jmp .final_processing
|
||||||
|
|
||||||
.fin_timed:
|
.fin_timed:
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
jmp .final_processing
|
jmp .final_processing
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ TCP_output:
|
|||||||
jmp .no_force
|
jmp .no_force
|
||||||
|
|
||||||
.no_zero_window:
|
.no_zero_window:
|
||||||
mov [eax + TCP_SOCKET.timer_persist], 0
|
and [eax + TCP_SOCKET.timer_flags], not timer_flag_persist
|
||||||
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
||||||
|
|
||||||
.no_force:
|
.no_force:
|
||||||
@ -125,7 +125,7 @@ TCP_output:
|
|||||||
jnz @f
|
jnz @f
|
||||||
|
|
||||||
; cancel pending retransmit
|
; cancel pending retransmit
|
||||||
mov [eax + TCP_SOCKET.timer_retransmission], 0
|
and [eax + TCP_SOCKET.timer_flags], not timer_flag_retransmission
|
||||||
|
|
||||||
; pull SND_NXT back to (closed) window, We will enter persist state below.
|
; pull SND_NXT back to (closed) window, We will enter persist state below.
|
||||||
push [eax + TCP_SOCKET.SND_UNA]
|
push [eax + TCP_SOCKET.SND_UNA]
|
||||||
@ -266,13 +266,14 @@ TCP_output:
|
|||||||
|
|
||||||
.enter_persist:
|
.enter_persist:
|
||||||
|
|
||||||
cmp [eax + STREAM_SOCKET.snd.size], 0 ; Data ready to send?
|
cmp [eax + STREAM_SOCKET.snd.size], 0 ; Data ready to send?
|
||||||
jne @f
|
jne @f
|
||||||
cmp [eax + TCP_SOCKET.timer_retransmission], 0
|
and [eax + TCP_SOCKET.timer_flags], not timer_flag_retransmission
|
||||||
jne @f
|
|
||||||
cmp [eax + TCP_SOCKET.timer_persist], 0 ; Persist timer already expired?
|
|
||||||
jne @f
|
jne @f
|
||||||
|
|
||||||
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist ; Persist timer already expired?
|
||||||
|
jnz @f
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
||||||
@ -512,19 +513,19 @@ TCP_send:
|
|||||||
@@:
|
@@:
|
||||||
|
|
||||||
; set retransmission timer if not already set, and not doing an ACK or keepalive probe
|
; set retransmission timer if not already set, and not doing an ACK or keepalive probe
|
||||||
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
cmp [eax + TCP_SOCKET.timer_retransmission], 0 ;;;; FIXME
|
jnz .retransmit_set
|
||||||
ja .retransmit_set
|
|
||||||
|
|
||||||
cmp edx, [eax + TCP_SOCKET.SND_UNA] ; edx is still [eax + TCP_SOCKET.SND_NXT]
|
cmp edx, [eax + TCP_SOCKET.SND_UNA] ; edx is still [eax + TCP_SOCKET.SND_NXT]
|
||||||
je .retransmit_set
|
je .retransmit_set
|
||||||
|
|
||||||
mov edx, [eax + TCP_SOCKET.t_rxtcur]
|
mov edx, [eax + TCP_SOCKET.t_rxtcur]
|
||||||
mov [eax + TCP_SOCKET.timer_retransmission], edx
|
mov [eax + TCP_SOCKET.timer_retransmission], edx
|
||||||
|
or [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.timer_persist], 0
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
jne .retransmit_set
|
jz .retransmit_set
|
||||||
mov [eax + TCP_SOCKET.timer_persist], 0
|
and [eax + TCP_SOCKET.timer_flags], not timer_flag_persist
|
||||||
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
||||||
|
|
||||||
.retransmit_set:
|
.retransmit_set:
|
||||||
@ -593,11 +594,12 @@ TCP_send:
|
|||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.timer_retransmission], TCP_time_re_min
|
mov [eax + TCP_SOCKET.timer_retransmission], TCP_time_re_min
|
||||||
|
or [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
|
|
||||||
lea ecx, [eax + SOCKET.mutex]
|
lea ecx, [eax + SOCKET.mutex]
|
||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: IP error\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "TCP_send: IP error\n"
|
||||||
|
|
||||||
or eax, -1
|
or eax, -1
|
||||||
ret
|
ret
|
||||||
@ -609,7 +611,7 @@ TCP_send:
|
|||||||
lea ecx, [eax + SOCKET.mutex]
|
lea ecx, [eax + SOCKET.mutex]
|
||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: sending failed\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "TCP_send: sending failed\n"
|
||||||
|
|
||||||
or eax, -2
|
or eax, -2
|
||||||
ret
|
ret
|
||||||
|
@ -420,8 +420,8 @@ TCP_set_persist:
|
|||||||
|
|
||||||
; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive
|
; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.timer_retransmission], 0
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
ja @f
|
jnz .exit
|
||||||
|
|
||||||
; calculate RTO
|
; calculate RTO
|
||||||
push ebx
|
push ebx
|
||||||
@ -436,13 +436,14 @@ TCP_set_persist:
|
|||||||
; Start/restart persistance timer.
|
; Start/restart persistance timer.
|
||||||
|
|
||||||
TCPT_RANGESET [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
|
TCPT_RANGESET [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
|
||||||
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.t_rxtshift], TCP_max_rxtshift
|
cmp [eax + TCP_SOCKET.t_rxtshift], TCP_max_rxtshift
|
||||||
jae @f
|
jae @f
|
||||||
inc [eax + TCP_SOCKET.t_rxtshift]
|
inc [eax + TCP_SOCKET.t_rxtshift]
|
||||||
@@:
|
@@:
|
||||||
|
.exit:
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Part of the TCP/IP network stack for KolibriOS ;;
|
;; Part of the TCP/IP network stack for KolibriOS ;;
|
||||||
@ -16,6 +16,13 @@
|
|||||||
|
|
||||||
$Revision: 3143 $
|
$Revision: 3143 $
|
||||||
|
|
||||||
|
timer_flag_retransmission = 1 shl 0
|
||||||
|
timer_flag_keepalive = 1 shl 1
|
||||||
|
timer_flag_2msl = 1 shl 2
|
||||||
|
timer_flag_persist = 1 shl 3
|
||||||
|
timer_flag_wait = 1 shl 4
|
||||||
|
|
||||||
|
|
||||||
;----------------------
|
;----------------------
|
||||||
; 160 ms timer
|
; 160 ms timer
|
||||||
;----------------------
|
;----------------------
|
||||||
@ -27,17 +34,16 @@ local .exit
|
|||||||
mov ebx, net_sockets
|
mov ebx, net_sockets
|
||||||
.loop:
|
.loop:
|
||||||
mov ebx, [ebx + SOCKET.NextPtr]
|
mov ebx, [ebx + SOCKET.NextPtr]
|
||||||
or ebx, ebx
|
test ebx, ebx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
cmp [ebx + SOCKET.Domain], AF_INET4
|
cmp [ebx + SOCKET.Domain], AF_INET4
|
||||||
jne .loop
|
jne .loop
|
||||||
|
|
||||||
cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP
|
cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP
|
||||||
jne .loop
|
jne .loop
|
||||||
|
|
||||||
test [ebx + TCP_SOCKET.t_flags], TF_DELACK
|
test [ebx + TCP_SOCKET.t_flags], TF_DELACK
|
||||||
jz .loop
|
jz .loop
|
||||||
|
|
||||||
and [ebx + TCP_SOCKET.t_flags], not (TF_DELACK)
|
and [ebx + TCP_SOCKET.t_flags], not (TF_DELACK)
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
@ -58,7 +64,7 @@ local .exit
|
|||||||
;----------------------
|
;----------------------
|
||||||
; 640 ms timer
|
; 640 ms timer
|
||||||
;----------------------
|
;----------------------
|
||||||
macro TCP_timer_640ms {
|
macro TCP_timer_640ms { ; TODO: implement timed wait timer!
|
||||||
|
|
||||||
local .loop
|
local .loop
|
||||||
local .exit
|
local .exit
|
||||||
@ -68,7 +74,7 @@ local .exit
|
|||||||
add [TCP_sequence_num], 64000
|
add [TCP_sequence_num], 64000
|
||||||
|
|
||||||
; scan through all the active TCP sockets, decrementing ALL timers
|
; scan through all the active TCP sockets, decrementing ALL timers
|
||||||
; timers do not have the chance to wrap because the keepalive timer will kill the socket when it expires
|
; When a timer reaches zero, we'll check wheter it was active or not
|
||||||
|
|
||||||
mov eax, net_sockets
|
mov eax, net_sockets
|
||||||
.loop:
|
.loop:
|
||||||
@ -84,8 +90,11 @@ local .exit
|
|||||||
jne .loop
|
jne .loop
|
||||||
|
|
||||||
inc [eax + TCP_SOCKET.t_idle]
|
inc [eax + TCP_SOCKET.t_idle]
|
||||||
|
|
||||||
dec [eax + TCP_SOCKET.timer_retransmission]
|
dec [eax + TCP_SOCKET.timer_retransmission]
|
||||||
jnz .check_more2
|
jnz .check_more2
|
||||||
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
|
jz .check_more2
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Retransmission timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Retransmission timer expired\n", eax
|
||||||
|
|
||||||
@ -96,6 +105,8 @@ local .exit
|
|||||||
.check_more2:
|
.check_more2:
|
||||||
dec [eax + TCP_SOCKET.timer_keepalive]
|
dec [eax + TCP_SOCKET.timer_keepalive]
|
||||||
jnz .check_more3
|
jnz .check_more3
|
||||||
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
||||||
|
jz .check_more3
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Keepalive expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Keepalive expired\n", eax
|
||||||
|
|
||||||
@ -125,12 +136,16 @@ local .exit
|
|||||||
.check_more3:
|
.check_more3:
|
||||||
dec [eax + TCP_SOCKET.timer_timed_wait]
|
dec [eax + TCP_SOCKET.timer_timed_wait]
|
||||||
jnz .check_more5
|
jnz .check_more5
|
||||||
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_2msl
|
||||||
|
jz .check_more5
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: 2MSL timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: 2MSL timer expired\n", eax
|
||||||
|
|
||||||
.check_more5:
|
.check_more5:
|
||||||
dec [eax + TCP_SOCKET.timer_persist]
|
dec [eax + TCP_SOCKET.timer_persist]
|
||||||
jnz .loop
|
jnz .loop
|
||||||
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
|
jz .loop
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
|
||||||
|
|
||||||
@ -152,17 +167,6 @@ local .exit
|
|||||||
|
|
||||||
TCP_cancel_timers:
|
TCP_cancel_timers:
|
||||||
|
|
||||||
push eax edi
|
mov [eax + TCP_SOCKET.timer_flags], 0
|
||||||
|
|
||||||
lea edi, [eax + TCP_SOCKET.timer_retransmission]
|
|
||||||
xor eax, eax
|
|
||||||
stosd
|
|
||||||
stosd
|
|
||||||
stosd
|
|
||||||
stosd
|
|
||||||
stosd
|
|
||||||
|
|
||||||
pop edi eax
|
|
||||||
|
|
||||||
|
|
||||||
ret
|
ret
|
@ -29,8 +29,8 @@ ends
|
|||||||
|
|
||||||
align 4
|
align 4
|
||||||
uglobal
|
uglobal
|
||||||
UDP_PACKETS_TX rd MAX_NET_DEVICES
|
UDP_PACKETS_TX rd NET_DEVICES_MAX
|
||||||
UDP_PACKETS_RX rd MAX_NET_DEVICES
|
UDP_PACKETS_RX rd NET_DEVICES_MAX
|
||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ macro UDP_init {
|
|||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, UDP_PACKETS_TX
|
mov edi, UDP_PACKETS_TX
|
||||||
mov ecx, 2*MAX_NET_DEVICES
|
mov ecx, 2*NET_DEVICES_MAX
|
||||||
rep stosd
|
rep stosd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ proc restore_24 stdcall, x:dword, y:dword
|
|||||||
align 4
|
align 4
|
||||||
@@:
|
@@:
|
||||||
mov edi, ebx
|
mov edi, ebx
|
||||||
add ebx, [BytesPerScanLine]
|
add ebx, [_display.pitch]
|
||||||
|
|
||||||
mov ecx, [esp]
|
mov ecx, [esp]
|
||||||
rep movsb
|
rep movsb
|
||||||
@ -559,7 +559,7 @@ proc restore_32 stdcall, x:dword, y:dword
|
|||||||
align 4
|
align 4
|
||||||
@@:
|
@@:
|
||||||
mov edi, ebx
|
mov edi, ebx
|
||||||
add ebx, [BytesPerScanLine]
|
add ebx, [_display.pitch]
|
||||||
|
|
||||||
mov ecx, [cur.w]
|
mov ecx, [cur.w]
|
||||||
rep movsd
|
rep movsd
|
||||||
@ -650,7 +650,7 @@ align 4
|
|||||||
align 4
|
align 4
|
||||||
@@:
|
@@:
|
||||||
mov esi, edx
|
mov esi, edx
|
||||||
add edx, [BytesPerScanLine]
|
add edx, [_display.pitch]
|
||||||
mov ecx, [cur.w]
|
mov ecx, [cur.w]
|
||||||
lea ecx, [ecx+ecx*2]
|
lea ecx, [ecx+ecx*2]
|
||||||
rep movsb
|
rep movsb
|
||||||
@ -673,7 +673,7 @@ align 4
|
|||||||
mov esi, edx
|
mov esi, edx
|
||||||
mov edi, ebx
|
mov edi, ebx
|
||||||
add edx, 32*4
|
add edx, 32*4
|
||||||
add ebx, [BytesPerScanLine]
|
add ebx, [_display.pitch]
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
align 4
|
align 4
|
||||||
.pix:
|
.pix:
|
||||||
@ -768,7 +768,7 @@ align 4
|
|||||||
align 4
|
align 4
|
||||||
@@:
|
@@:
|
||||||
mov esi, edx
|
mov esi, edx
|
||||||
add edx, [BytesPerScanLine]
|
add edx, [_display.pitch]
|
||||||
mov ecx, [cur.w]
|
mov ecx, [cur.w]
|
||||||
rep movsd
|
rep movsd
|
||||||
dec eax
|
dec eax
|
||||||
@ -790,7 +790,7 @@ align 4
|
|||||||
mov esi, edx
|
mov esi, edx
|
||||||
mov edi, ebx
|
mov edi, ebx
|
||||||
add edx, 32*4
|
add edx, 32*4
|
||||||
add ebx, [BytesPerScanLine]
|
add ebx, [_display.pitch]
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
align 4
|
align 4
|
||||||
.pix:
|
.pix:
|
||||||
|
@ -230,7 +230,7 @@ align 4
|
|||||||
sub eax, [putimg.real_sx]
|
sub eax, [putimg.real_sx]
|
||||||
mov [putimg.winmap_newline], eax
|
mov [putimg.winmap_newline], eax
|
||||||
; screen new line increment
|
; screen new line increment
|
||||||
mov eax, [BytesPerScanLine]
|
mov eax, [_display.pitch]
|
||||||
mov ebx, [_display.bpp]
|
mov ebx, [_display.bpp]
|
||||||
shr ebx, 3
|
shr ebx, 3
|
||||||
imul ecx, ebx
|
imul ecx, ebx
|
||||||
@ -1233,7 +1233,7 @@ align 4
|
|||||||
shr ebx, 3
|
shr ebx, 3
|
||||||
imul eax, ebx
|
imul eax, ebx
|
||||||
neg eax
|
neg eax
|
||||||
add eax, [BytesPerScanLine]
|
add eax, [_display.pitch]
|
||||||
mov [drbar.line_inc_scr], eax
|
mov [drbar.line_inc_scr], eax
|
||||||
; pointer to screen
|
; pointer to screen
|
||||||
mov edx, [drbar.abs_cy]
|
mov edx, [drbar.abs_cy]
|
||||||
@ -1950,7 +1950,7 @@ sdp4:
|
|||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@@:
|
@@:
|
||||||
add edi, [BytesPerScanLine]
|
add edi, [_display.pitch]
|
||||||
; restore ecx,edx; advance esi to next background line
|
; restore ecx,edx; advance esi to next background line
|
||||||
mov eax, [esp+28]
|
mov eax, [esp+28]
|
||||||
mov ebx, [esp+32]
|
mov ebx, [esp+32]
|
||||||
|
Loading…
Reference in New Issue
Block a user