forked from KolibriOS/kolibrios
kolibri-acpi: update
git-svn-id: svn://kolibrios.org@5594 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
80ceac6a9f
commit
e5efe832f3
@ -1132,21 +1132,22 @@ check_ATAPI_device_event:
|
|||||||
mov [ignore_CD_eject_wait], 0
|
mov [ignore_CD_eject_wait], 0
|
||||||
ret
|
ret
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
iglobal
|
uglobal
|
||||||
timer_ATAPI_check dd 0
|
align 4
|
||||||
ATAPI_IDE0_lock db 0
|
timer_ATAPI_check dd ?
|
||||||
ATAPI_IDE1_lock db 0
|
ATAPI_IDE0_lock db ?
|
||||||
ATAPI_IDE2_lock db 0
|
ATAPI_IDE1_lock db ?
|
||||||
ATAPI_IDE3_lock db 0
|
ATAPI_IDE2_lock db ?
|
||||||
ATAPI_IDE4_lock db 0
|
ATAPI_IDE3_lock db ?
|
||||||
ATAPI_IDE5_lock db 0
|
ATAPI_IDE4_lock db ?
|
||||||
ATAPI_IDE6_lock db 0
|
ATAPI_IDE5_lock db ?
|
||||||
ATAPI_IDE7_lock db 0
|
ATAPI_IDE6_lock db ?
|
||||||
ATAPI_IDE8_lock db 0
|
ATAPI_IDE7_lock db ?
|
||||||
ATAPI_IDE9_lock db 0
|
ATAPI_IDE8_lock db ?
|
||||||
ATAPI_IDE10_lock db 0
|
ATAPI_IDE9_lock db ?
|
||||||
ATAPI_IDE11_lock db 0
|
ATAPI_IDE10_lock db ?
|
||||||
ignore_CD_eject_wait db 0
|
ATAPI_IDE11_lock db ?
|
||||||
|
ignore_CD_eject_wait db ?
|
||||||
endg
|
endg
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
;*************************************************
|
;*************************************************
|
||||||
|
@ -1445,7 +1445,3 @@ proc print_mem
|
|||||||
.done:
|
.done:
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -469,7 +469,6 @@ proc create_process stdcall, app_size:dword,img_base:dword,img_size:dword
|
|||||||
stdcall kernel_alloc, 0x2000
|
stdcall kernel_alloc, 0x2000
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .fail
|
jz .fail
|
||||||
|
|
||||||
mov [process], eax
|
mov [process], eax
|
||||||
|
|
||||||
lea edi, [eax+PROC.heap_lock]
|
lea edi, [eax+PROC.heap_lock]
|
||||||
|
@ -3,13 +3,12 @@
|
|||||||
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; FAT32.INC ;;
|
|
||||||
;; ;;
|
|
||||||
;; FAT functions for KolibriOS ;;
|
;; FAT functions for KolibriOS ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
|
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; See file COPYING for details ;;
|
;; See file COPYING for details ;;
|
||||||
|
;; 06.2015 fs_read64 - pathoswithin ;;
|
||||||
;; 04.02.2007 LFN create folder - diamond ;;
|
;; 04.02.2007 LFN create folder - diamond ;;
|
||||||
;; 08.10.2006 LFN delete file/folder - diamond ;;
|
;; 08.10.2006 LFN delete file/folder - diamond ;;
|
||||||
;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;;
|
;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;;
|
||||||
@ -34,17 +33,15 @@
|
|||||||
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
|
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
|
||||||
;; 20.10.2004 Makedir/Removedir - ATV ;;
|
;; 20.10.2004 Makedir/Removedir - ATV ;;
|
||||||
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
|
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
|
||||||
;; 06.9.2004 Fix free space by Mario79 added - MH ;;
|
;; 06.09.2004 Fix free space - Mario79 ;;
|
||||||
;; 24.5.2004 Write back buffer for File_write -VT ;;
|
;; 24.05.2004 Write back buffer for File_write - VT ;;
|
||||||
;; 20.5.2004 File_read function to work with syscall 58 - VT ;;
|
;; 20.05.2004 File_read function to work with syscall 58 - VT ;;
|
||||||
;; 30.3.2004 Error parameters at function return - VT ;;
|
;; 30.03.2004 Error parameters at function return - VT ;;
|
||||||
;; 01.5.2002 Bugfix in device write - VT ;;
|
;; 29.06.2002 Improved fat32 verification - VT ;;
|
||||||
;; 20.5.2002 Hd status check - VT ;;
|
;; 20.05.2002 Hd status check - VT ;;
|
||||||
;; 29.6.2002 Improved fat32 verification - VT ;;
|
;; 01.05.2002 Bugfix in device write - VT ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 4273 $
|
|
||||||
|
|
||||||
|
|
||||||
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00
|
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00
|
||||||
@ -62,11 +59,9 @@ struct FAT PARTITION
|
|||||||
fs_type db ?
|
fs_type db ?
|
||||||
fat16_root db 0 ; flag for fat16 rootdir
|
fat16_root db 0 ; flag for fat16 rootdir
|
||||||
fat_change db 0 ; 1=fat has changed
|
fat_change db 0 ; 1=fat has changed
|
||||||
db ? ; alignment
|
rb 1
|
||||||
Lock MUTEX ? ; currently operations with one partition
|
Lock MUTEX ? ; currently operations with one partition
|
||||||
; can not be executed in parallel since the
|
; can not be executed in parallel since the legacy code is not ready
|
||||||
; legacy code is not ready; this mutex guards
|
|
||||||
; all operations
|
|
||||||
SECTORS_PER_FAT dd 0x1f3a
|
SECTORS_PER_FAT dd 0x1f3a
|
||||||
NUMBER_OF_FATS dd 0x2
|
NUMBER_OF_FATS dd 0x2
|
||||||
SECTORS_PER_CLUSTER dd 0x8
|
SECTORS_PER_CLUSTER dd 0x8
|
||||||
@ -85,19 +80,16 @@ fatEND dd 0x0FFFFFF8
|
|||||||
fatMASK dd 0x0FFFFFFF
|
fatMASK dd 0x0FFFFFFF
|
||||||
|
|
||||||
fatStartScan dd 2
|
fatStartScan dd 2
|
||||||
|
|
||||||
cluster_tmp dd 0 ; used by analyze_directory
|
cluster_tmp dd 0 ; used by analyze_directory
|
||||||
; and analyze_directory_to_write
|
; and analyze_directory_to_write
|
||||||
|
|
||||||
longname_sec1 dd 0 ; used by analyze_directory to save 2 previous
|
longname_sec1 dd 0 ; used by analyze_directory to save 2 previous
|
||||||
longname_sec2 dd 0 ; directory sectors for delete long filename
|
longname_sec2 dd 0 ; directory sectors for delete long filename
|
||||||
|
|
||||||
fat_in_cache dd -1
|
fat_in_cache dd -1
|
||||||
|
|
||||||
; For FAT16/FAT32, this points to 512-byte buffer for the current sector of FAT.
|
; For FAT16/FAT32, this points to 512-byte buffer for the current sector of FAT.
|
||||||
; For FAT12, the entire FAT structure is read
|
; For FAT12, the entire FAT structure is read
|
||||||
; and unpacked from 12bit per cluster to word per cluster.
|
; and unpacked from 12bit per cluster to word per cluster.
|
||||||
;
|
|
||||||
; Note: work with unpacked copy of FAT12 means
|
; Note: work with unpacked copy of FAT12 means
|
||||||
; additional memory and additional code for packing/unpacking.
|
; additional memory and additional code for packing/unpacking.
|
||||||
; I'm not sure that the economy justifies the cost, but anyway,
|
; I'm not sure that the economy justifies the cost, but anyway,
|
||||||
@ -111,11 +103,9 @@ ends
|
|||||||
uglobal
|
uglobal
|
||||||
align 4
|
align 4
|
||||||
partition_count dd 0 ; partitions found by set_FAT32_variables
|
partition_count dd 0 ; partitions found by set_FAT32_variables
|
||||||
|
hd_error dd 0
|
||||||
hd_error dd 0 ; set by wait_for_sector_buffer
|
|
||||||
hd_setup dd 0
|
hd_setup dd 0
|
||||||
hd_wait_timeout dd 0
|
hd_wait_timeout dd 0
|
||||||
|
|
||||||
cache_search_start dd 0 ; used by find_empty_slot
|
cache_search_start dd 0 ; used by find_empty_slot
|
||||||
endg
|
endg
|
||||||
|
|
||||||
@ -123,7 +113,7 @@ uglobal
|
|||||||
align 4
|
align 4
|
||||||
Sector512: ; label for dev_hdcd.inc
|
Sector512: ; label for dev_hdcd.inc
|
||||||
buffer:
|
buffer:
|
||||||
times 512 db 0
|
rb 512
|
||||||
endg
|
endg
|
||||||
|
|
||||||
iglobal
|
iglobal
|
||||||
@ -1788,14 +1778,12 @@ fat_Read:
|
|||||||
jnz @f
|
jnz @f
|
||||||
.noaccess:
|
.noaccess:
|
||||||
pop edi
|
pop edi
|
||||||
.noaccess_2:
|
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
or ebx, -1
|
or ebx, -1
|
||||||
mov eax, ERROR_ACCESS_DENIED
|
mov eax, ERROR_ACCESS_DENIED
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
stdcall hd_find_lfn, [esp+4+4]
|
stdcall hd_find_lfn, [esp+8]
|
||||||
jnc .found
|
jnc .found
|
||||||
pop edi
|
pop edi
|
||||||
push eax
|
push eax
|
||||||
@ -1803,27 +1791,25 @@ fat_Read:
|
|||||||
pop eax
|
pop eax
|
||||||
or ebx, -1
|
or ebx, -1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.found:
|
.found:
|
||||||
test byte [edi+11], 0x10 ; do not allow read directories
|
test byte [edi+11], 0x10 ; do not allow read directories
|
||||||
jnz .noaccess
|
jnz .noaccess
|
||||||
cmp dword [ebx+8], 0
|
cmp dword [ebx+8], 0
|
||||||
jz @f
|
jz @f
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
.reteof:
|
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
mov eax, ERROR_END_OF_FILE
|
mov eax, ERROR_END_OF_FILE
|
||||||
pop edi
|
pop edi
|
||||||
ret
|
ret
|
||||||
@@:
|
@@:
|
||||||
|
mov edx, [ebx+4] ; file offset
|
||||||
mov ecx, [ebx+12] ; size
|
mov ecx, [ebx+12] ; size
|
||||||
mov edx, [ebx+16] ; pointer
|
mov ebx, [ebx+16] ; buffer
|
||||||
mov ebx, [ebx+4] ; file offset
|
push ebx
|
||||||
push edx
|
|
||||||
push 0
|
push 0
|
||||||
mov eax, [edi+28]
|
mov eax, [edi+28]
|
||||||
sub eax, ebx
|
sub eax, edx
|
||||||
jb .eof
|
jb .fileEnd
|
||||||
cmp eax, ecx
|
cmp eax, ecx
|
||||||
jae @f
|
jae @f
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
@ -1831,87 +1817,145 @@ fat_Read:
|
|||||||
@@:
|
@@:
|
||||||
mov eax, [edi+20-2]
|
mov eax, [edi+20-2]
|
||||||
mov ax, [edi+26]
|
mov ax, [edi+26]
|
||||||
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
|
; now eax=cluster, ebx=buffer for data, ecx=count, edx=position
|
||||||
.new_cluster:
|
|
||||||
jecxz .new_sector
|
|
||||||
cmp eax, 2
|
|
||||||
jb .eof
|
|
||||||
cmp eax, [ebp+FAT.fatRESERVED]
|
|
||||||
jae .eof
|
|
||||||
mov [ebp+FAT.cluster_tmp], eax
|
|
||||||
dec eax
|
|
||||||
dec eax
|
|
||||||
mov edi, [ebp+FAT.SECTORS_PER_CLUSTER]
|
mov edi, [ebp+FAT.SECTORS_PER_CLUSTER]
|
||||||
imul eax, edi
|
shl edi, 9
|
||||||
|
@@:
|
||||||
|
cmp eax, 2
|
||||||
|
jb .fileEnd
|
||||||
|
cmp eax, [ebp+FAT.fatRESERVED]
|
||||||
|
jae .fileEnd
|
||||||
|
sub edx, edi
|
||||||
|
jc @f
|
||||||
|
call get_FAT
|
||||||
|
jc .noaccess2
|
||||||
|
jmp @b
|
||||||
|
@@:
|
||||||
|
mov esi, eax
|
||||||
|
dec eax
|
||||||
|
dec eax
|
||||||
|
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
|
||||||
add eax, [ebp+FAT.DATA_START]
|
add eax, [ebp+FAT.DATA_START]
|
||||||
.new_sector:
|
add edx, edi
|
||||||
test ecx, ecx
|
jz .alignedCluster
|
||||||
jz .done
|
mov edi, edx
|
||||||
sub ebx, 512
|
shr edi, 9
|
||||||
jae .skip
|
add eax, edi
|
||||||
add ebx, 512
|
and edx, 511
|
||||||
jnz .force_buf
|
jz .alignedSector
|
||||||
cmp ecx, 512
|
.sectorPiece:
|
||||||
jb .force_buf
|
|
||||||
; we may read directly to given buffer
|
|
||||||
push eax ebx
|
|
||||||
mov ebx, edx
|
|
||||||
call fs_read32_app
|
|
||||||
test eax, eax
|
|
||||||
pop ebx eax
|
|
||||||
jne .noaccess_1
|
|
||||||
add edx, 512
|
|
||||||
sub ecx, 512
|
|
||||||
jmp .skip
|
|
||||||
.force_buf:
|
|
||||||
; we must read sector to temporary buffer and then copy it to destination
|
|
||||||
push eax ebx
|
push eax ebx
|
||||||
lea ebx, [ebp+FAT.buffer]
|
lea ebx, [ebp+FAT.buffer]
|
||||||
call fs_read32_app
|
call fs_read32_app
|
||||||
test eax, eax
|
test eax, eax
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
pop ebx
|
pop ebx
|
||||||
jne .noaccess_3
|
jne .noaccess3
|
||||||
add eax, ebx
|
add eax, edx
|
||||||
push ecx
|
push ecx
|
||||||
add ecx, ebx
|
add ecx, edx
|
||||||
cmp ecx, 512
|
cmp ecx, 512
|
||||||
jbe @f
|
jbe @f
|
||||||
mov ecx, 512
|
mov ecx, 512
|
||||||
@@:
|
@@:
|
||||||
sub ecx, ebx
|
sub ecx, edx
|
||||||
mov ebx, edx
|
|
||||||
call memmove
|
call memmove
|
||||||
add edx, ecx
|
|
||||||
sub [esp], ecx
|
sub [esp], ecx
|
||||||
pop ecx
|
add ebx, ecx
|
||||||
pop eax
|
pop ecx eax
|
||||||
xor ebx, ebx
|
xor edx, edx
|
||||||
.skip:
|
inc edi
|
||||||
inc eax
|
inc eax
|
||||||
dec edi
|
test ecx, ecx
|
||||||
jnz .new_sector
|
jz .done
|
||||||
mov eax, [ebp+FAT.cluster_tmp]
|
.alignedSector:
|
||||||
|
cmp ecx, 512
|
||||||
|
jc .sectorPiece
|
||||||
|
shl edi, 9
|
||||||
|
add ecx, edi
|
||||||
|
mov edi, [ebp+FAT.SECTORS_PER_CLUSTER]
|
||||||
|
shl edi, 9
|
||||||
|
.alignedCluster:
|
||||||
|
cmp ecx, 512
|
||||||
|
jc .sectorPiece
|
||||||
|
mov edx, eax
|
||||||
|
mov eax, esi
|
||||||
|
@@:
|
||||||
|
sub ecx, edi
|
||||||
|
jbe .readEnd
|
||||||
call get_FAT
|
call get_FAT
|
||||||
jc .noaccess_1
|
jc .noaccess4
|
||||||
|
cmp eax, 2
|
||||||
jmp .new_cluster
|
jb .fileEnd2
|
||||||
.noaccess_3:
|
cmp eax, [ebp+FAT.fatRESERVED]
|
||||||
|
jae .fileEnd2
|
||||||
|
inc esi
|
||||||
|
cmp eax, esi
|
||||||
|
jz @b
|
||||||
|
.fragmentEnd:
|
||||||
|
xchg eax, esi
|
||||||
|
dec eax
|
||||||
|
dec eax
|
||||||
|
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
|
||||||
|
add eax, [ebp+FAT.DATA_START]
|
||||||
|
sub eax, edx
|
||||||
|
.readFragment:
|
||||||
|
push ecx
|
||||||
|
mov ecx, eax
|
||||||
|
mov eax, edx
|
||||||
|
xor edx, edx
|
||||||
|
push eax
|
||||||
|
call fs_read64_app
|
||||||
|
add [esp], ecx
|
||||||
|
shl ecx, 9
|
||||||
|
add ebx, ecx
|
||||||
|
test eax, eax
|
||||||
pop eax
|
pop eax
|
||||||
.noaccess_1:
|
jnz .noaccess3
|
||||||
|
pop ecx
|
||||||
|
xor edx, edx
|
||||||
|
jcxz .done
|
||||||
|
cmp ecx, 512
|
||||||
|
jc .sectorPiece
|
||||||
|
mov eax, esi
|
||||||
|
dec eax
|
||||||
|
dec eax
|
||||||
|
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
|
||||||
|
add eax, [ebp+FAT.DATA_START]
|
||||||
|
jmp .alignedCluster
|
||||||
|
.readEnd:
|
||||||
|
add ecx, edi
|
||||||
|
mov edi, ecx
|
||||||
|
and ecx, 511
|
||||||
|
shr edi, 9
|
||||||
|
dec eax
|
||||||
|
dec eax
|
||||||
|
imul eax, [ebp+FAT.SECTORS_PER_CLUSTER]
|
||||||
|
add eax, [ebp+FAT.DATA_START]
|
||||||
|
sub eax, edx
|
||||||
|
add eax, edi
|
||||||
|
jmp .readFragment
|
||||||
|
.noaccess3:
|
||||||
pop eax
|
pop eax
|
||||||
push ERROR_DEVICE
|
.noaccess2:
|
||||||
|
mov byte [esp], ERROR_DEVICE
|
||||||
.done:
|
.done:
|
||||||
mov ebx, edx
|
|
||||||
call fat_unlock
|
call fat_unlock
|
||||||
pop eax edx edi
|
pop eax edx edi
|
||||||
sub ebx, edx
|
sub ebx, edx
|
||||||
ret
|
ret
|
||||||
.eof:
|
.fileEnd:
|
||||||
mov ebx, edx
|
mov byte [esp], ERROR_END_OF_FILE
|
||||||
pop eax edx
|
jmp .done
|
||||||
sub ebx, edx
|
.noaccess4:
|
||||||
jmp .reteof
|
mov byte [esp], ERROR_DEVICE
|
||||||
|
jmp @f
|
||||||
|
.fileEnd2:
|
||||||
|
mov byte [esp], ERROR_END_OF_FILE
|
||||||
|
@@:
|
||||||
|
inc esi
|
||||||
|
xor ecx, ecx
|
||||||
|
jmp .fragmentEnd
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;----------------------------------------------------------------
|
||||||
; fat_ReadFolder - FAT implementation of reading a folder
|
; fat_ReadFolder - FAT implementation of reading a folder
|
||||||
|
@ -112,9 +112,11 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
|||||||
add ebx, [eax - twdw + WDATA.box.left]
|
add ebx, [eax - twdw + WDATA.box.left]
|
||||||
add ecx, [eax - twdw + WDATA.box.top]
|
add ecx, [eax - twdw + WDATA.box.top]
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
|
inc eax
|
||||||
shl eax, 16
|
shl eax, 16
|
||||||
mov ax, bx
|
mov ax, bx
|
||||||
add ax, word[esp + 16]
|
add ax, word[esp + 16]
|
||||||
|
dec ax
|
||||||
mov ebx, ecx
|
mov ebx, ecx
|
||||||
shl ebx, 16
|
shl ebx, 16
|
||||||
mov bx, cx
|
mov bx, cx
|
||||||
@ -128,6 +130,8 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
|||||||
; set button height counter
|
; set button height counter
|
||||||
@@:
|
@@:
|
||||||
mov edx, edi
|
mov edx, edi
|
||||||
|
add ebx, 0x00010001
|
||||||
|
dec edx
|
||||||
|
|
||||||
.next_line:
|
.next_line:
|
||||||
call button._.button_dececx
|
call button._.button_dececx
|
||||||
@ -192,6 +196,7 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
|||||||
mov ecx, esi
|
mov ecx, esi
|
||||||
call button._.incecx
|
call button._.incecx
|
||||||
; call [draw_line]
|
; call [draw_line]
|
||||||
|
dec ebx
|
||||||
call __sys_draw_line
|
call __sys_draw_line
|
||||||
|
|
||||||
; right border
|
; right border
|
||||||
|
@ -1688,8 +1688,8 @@ draw_num_text:
|
|||||||
mov edi, [esp+64+4]
|
mov edi, [esp+64+4]
|
||||||
jmp dtext
|
jmp dtext
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
iglobal
|
uglobal
|
||||||
midi_base dw 0
|
midi_base dw ?
|
||||||
endg
|
endg
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
|
@ -569,6 +569,7 @@ IPv4_find_fragment_slot:
|
|||||||
; IPv4_output
|
; IPv4_output
|
||||||
;
|
;
|
||||||
; IN: eax = Destination IP
|
; IN: eax = Destination IP
|
||||||
|
; ebx = device ptr (or 0 to let IP layer decide)
|
||||||
; ecx = data length
|
; ecx = data length
|
||||||
; edx = Source IP
|
; edx = Source IP
|
||||||
; di = TTL shl 8 + protocol
|
; di = TTL shl 8 + protocol
|
||||||
@ -863,6 +864,7 @@ IPv4_fragment:
|
|||||||
; IPv4_route
|
; IPv4_route
|
||||||
;
|
;
|
||||||
; IN: eax = Destination IP
|
; IN: eax = Destination IP
|
||||||
|
; ebx = outgoing device / 0
|
||||||
; edx = Source IP
|
; edx = Source IP
|
||||||
; OUT: eax = Destination IP (or gateway IP)
|
; OUT: eax = Destination IP (or gateway IP)
|
||||||
; edx = Source IP
|
; edx = Source IP
|
||||||
@ -874,6 +876,9 @@ IPv4_fragment:
|
|||||||
align 4
|
align 4
|
||||||
IPv4_route: ; TODO: return error if no valid route found
|
IPv4_route: ; TODO: return error if no valid route found
|
||||||
|
|
||||||
|
test ebx, ebx
|
||||||
|
jnz .got_device
|
||||||
|
|
||||||
cmp eax, 0xffffffff
|
cmp eax, 0xffffffff
|
||||||
je .broadcast
|
je .broadcast
|
||||||
|
|
||||||
@ -903,6 +908,27 @@ IPv4_route: ; TODO: return error if no valid route found
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
.got_device:
|
||||||
|
; Validate device ptr and convert to device number
|
||||||
|
call NET_ptr_to_num4
|
||||||
|
cmp edi, -1
|
||||||
|
je .fail
|
||||||
|
|
||||||
|
mov edx, [IP_LIST + edi] ; Source IP
|
||||||
|
|
||||||
|
; Check if we should route to gateway or not
|
||||||
|
mov ebx, [IP_LIST + edi]
|
||||||
|
and ebx, [SUBNET_LIST + edi]
|
||||||
|
mov ecx, eax
|
||||||
|
and ecx, [SUBNET_LIST + edi]
|
||||||
|
je @f
|
||||||
|
mov eax, [GATEWAY_LIST + edi]
|
||||||
|
@@:
|
||||||
|
ret
|
||||||
|
|
||||||
|
.fail:
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;---------------------------------------------------------------------------
|
||||||
|
@ -388,6 +388,7 @@ ICMP_output_raw:
|
|||||||
|
|
||||||
mov di, IP_PROTO_ICMP SHL 8 + 128 ; TTL
|
mov di, IP_PROTO_ICMP SHL 8 + 128 ; TTL
|
||||||
mov edx, [eax + IP_SOCKET.LocalIP]
|
mov edx, [eax + IP_SOCKET.LocalIP]
|
||||||
|
mov ebx, [eax + IP_SOCKET.device]
|
||||||
mov eax, [eax + IP_SOCKET.RemoteIP]
|
mov eax, [eax + IP_SOCKET.RemoteIP]
|
||||||
call IPv4_output
|
call IPv4_output
|
||||||
jz .exit
|
jz .exit
|
||||||
|
@ -1160,7 +1160,7 @@ SOCKET_set_opt:
|
|||||||
cmp dword[edx+8], 0
|
cmp dword[edx+8], 0
|
||||||
je .unbind
|
je .unbind
|
||||||
|
|
||||||
movzx edx, byte[edx + 9]
|
movzx edx, byte[edx + 12]
|
||||||
cmp edx, NET_DEVICES_MAX
|
cmp edx, NET_DEVICES_MAX
|
||||||
ja .invalid
|
ja .invalid
|
||||||
|
|
||||||
|
@ -504,6 +504,7 @@ endl
|
|||||||
|
|
||||||
mov ecx, esi
|
mov ecx, esi
|
||||||
mov edx, [eax + IP_SOCKET.LocalIP] ; source ip
|
mov edx, [eax + IP_SOCKET.LocalIP] ; source ip
|
||||||
|
mov ebx, [eax + IP_SOCKET.device]
|
||||||
mov eax, [eax + IP_SOCKET.RemoteIP] ; dest ip
|
mov eax, [eax + IP_SOCKET.RemoteIP] ; dest ip
|
||||||
mov di, IP_PROTO_TCP shl 8 + 128
|
mov di, IP_PROTO_TCP shl 8 + 128
|
||||||
call IPv4_output
|
call IPv4_output
|
||||||
|
@ -287,6 +287,7 @@ TCP_respond:
|
|||||||
push cx ebx
|
push cx ebx
|
||||||
mov eax, [ebx + IP_SOCKET.RemoteIP]
|
mov eax, [ebx + IP_SOCKET.RemoteIP]
|
||||||
mov edx, [ebx + IP_SOCKET.LocalIP]
|
mov edx, [ebx + IP_SOCKET.LocalIP]
|
||||||
|
mov ebx, [ebx + IP_SOCKET.device]
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
mov di, IP_PROTO_TCP shl 8 + 128
|
mov di, IP_PROTO_TCP shl 8 + 128
|
||||||
call IPv4_output
|
call IPv4_output
|
||||||
@ -372,6 +373,7 @@ TCP_respond_segment:
|
|||||||
mov eax, [edi]
|
mov eax, [edi]
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
mov di, IP_PROTO_TCP shl 8 + 128
|
mov di, IP_PROTO_TCP shl 8 + 128
|
||||||
|
xor ebx, ebx ;;; fixme
|
||||||
call IPv4_output
|
call IPv4_output
|
||||||
jz .error
|
jz .error
|
||||||
pop esi cx
|
pop esi cx
|
||||||
|
@ -258,6 +258,7 @@ UDP_output:
|
|||||||
sub esp, 4 ; Data ptr will be placed here
|
sub esp, 4 ; Data ptr will be placed here
|
||||||
push edx esi
|
push edx esi
|
||||||
mov edx, [eax + IP_SOCKET.LocalIP]
|
mov edx, [eax + IP_SOCKET.LocalIP]
|
||||||
|
mov ebx, [eax + IP_SOCKET.device]
|
||||||
mov eax, [eax + IP_SOCKET.RemoteIP]
|
mov eax, [eax + IP_SOCKET.RemoteIP]
|
||||||
mov di, IP_PROTO_UDP shl 8 + 128
|
mov di, IP_PROTO_UDP shl 8 + 128
|
||||||
add ecx, sizeof.UDP_header
|
add ecx, sizeof.UDP_header
|
||||||
|
Loading…
Reference in New Issue
Block a user