Sync net branch with trunk

git-svn-id: svn://kolibrios.org@3405 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-03-23 11:56:23 +00:00
parent 16919a6ad9
commit 372fe91892
9 changed files with 330 additions and 205 deletions

View File

@ -152,18 +152,18 @@ pci_make_config_cmd:
; (0 - byte, 1 - word, 2 - dword) ; (0 - byte, 1 - word, 2 - dword)
;*************************************************************************** ;***************************************************************************
align 4 align 4
pci_read_reg: pci_read_reg:
cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use? push ebx esi
je pci_read_reg_2 cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
je pci_read_reg_2
; mechanism 1
push esi ; save register size into ESI ; mechanism 1
mov esi, eax mov esi, eax ; save register size into ESI
and esi, 3 and esi, 3
call pci_make_config_cmd call pci_make_config_cmd
mov ebx, eax mov ebx, eax
; get current state ; get current state
mov dx, 0xcf8 mov dx, 0xcf8
@ -199,21 +199,20 @@ pci_fin_read1:
; restore configuration control ; restore configuration control
xchg eax, [esp] xchg eax, [esp]
mov dx, 0xcf8 mov dx, 0xcf8
out dx, eax out dx, eax
pop eax pop eax
pop esi pop esi ebx
ret ret
pci_read_reg_2: pci_read_reg_2:
test bh, 128 ;mech#2 only supports 16 devices per bus test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_read_reg_err jnz pci_read_reg_err
push esi; save register size into ESI mov esi, eax ; save register size into ESI
mov esi, eax and esi, 3
and esi, 3
push eax
push eax
;store current state of config space ;store current state of config space
mov dx, 0xcf8 mov dx, 0xcf8
in al, dx in al, dx
@ -259,18 +258,19 @@ pci_fin_read2:
out dx, al out dx, al
mov dl, 0xf8 mov dl, 0xf8
mov al, ah mov al, ah
out dx, al out dx, al
pop eax pop eax
pop esi pop esi ebx
ret ret
pci_read_reg_err: pci_read_reg_err:
xor eax, eax xor eax, eax
dec eax dec eax
ret pop esi ebx
ret
;*************************************************************************** ;***************************************************************************
; Function ; Function
; pci_write_reg: ; pci_write_reg:
@ -283,18 +283,18 @@ pci_read_reg_err:
; (0 - byte, 1 - word, 2 - dword) ; (0 - byte, 1 - word, 2 - dword)
;*************************************************************************** ;***************************************************************************
align 4 align 4
pci_write_reg: pci_write_reg:
cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use? push esi ebx
je pci_write_reg_2 cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
je pci_write_reg_2
; mechanism 1
push esi ; save register size into ESI ; mechanism 1
mov esi, eax mov esi, eax ; save register size into ESI
and esi, 3 and esi, 3
call pci_make_config_cmd call pci_make_config_cmd
mov ebx, eax mov ebx, eax
; get current state into ecx ; get current state into ecx
mov dx, 0xcf8 mov dx, 0xcf8
@ -332,23 +332,22 @@ pci_fin_write1:
; restore configuration control ; restore configuration control
pop eax pop eax
mov dl, 0xf8 mov dl, 0xf8
out dx, eax out dx, eax
xor eax, eax xor eax, eax
pop esi pop ebx esi
ret ret
pci_write_reg_2: pci_write_reg_2:
test bh, 128 ;mech#2 only supports 16 devices per bus test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_write_reg_err jnz pci_write_reg_err
push esi; save register size into ESI mov esi, eax ; save register size into ESI
mov esi, eax and esi, 3
and esi, 3
push eax
push eax
;store current state of config space ;store current state of config space
mov dx, 0xcf8 mov dx, 0xcf8
in al, dx in al, dx
@ -394,18 +393,19 @@ pci_fin_write2:
out dx, al out dx, al
mov dl, 0xf8 mov dl, 0xf8
mov al, ah mov al, ah
out dx, al out dx, al
xor eax, eax xor eax, eax
pop esi pop ebx esi
ret ret
pci_write_reg_err: pci_write_reg_err:
xor eax, eax xor eax, eax
dec eax dec eax
ret pop ebx esi
ret
if defined mmio_pci_addr ; must be set above
if defined mmio_pci_addr ; must be set above
;*************************************************************************** ;***************************************************************************
; Function ; Function
; pci_mmio_init ; pci_mmio_init
@ -655,6 +655,70 @@ sys_pcibios:
mov dword[esp + 28], ecx mov dword[esp + 28], ecx
.return_ab: .return_ab:
mov dword[esp + 20], ebx mov dword[esp + 20], ebx
.return_a: .return_a:
mov dword[esp + 32], eax mov dword[esp + 32], eax
ret ret
proc pci_enum
push ebp
mov ebp, esp
push 0
virtual at ebp-4
.devfn db ?
.bus db ?
end virtual
.loop:
mov ah, [.bus]
mov al, 2
mov bh, [.devfn]
mov bl, 0
call pci_read_reg
cmp eax, 0xFFFFFFFF
jnz .has_device
test byte [.devfn], 7
jnz .next_func
jmp .no_device
.has_device:
push eax
push sizeof.PCIDEV
pop eax
call malloc
pop ecx
test eax, eax
jz .nomemory
mov edi, eax
mov [edi+PCIDEV.vendor_device_id], ecx
mov eax, pcidev_list
mov ecx, [eax+PCIDEV.bk]
mov [edi+PCIDEV.bk], ecx
mov [edi+PCIDEV.fd], eax
mov [ecx+PCIDEV.fd], edi
mov [eax+PCIDEV.bk], edi
mov eax, dword [.devfn]
mov word [edi+PCIDEV.devfn], ax
mov bh, al
mov al, 2
mov bl, 8
call pci_read_reg
shr eax, 8
mov [edi+PCIDEV.class], eax
test byte [.devfn], 7
jnz .next_func
mov ah, [.bus]
mov al, 0
mov bh, [.devfn]
mov bl, 0Eh
call pci_read_reg
test al, al
js .next_func
.no_device:
or byte [.devfn], 7
.next_func:
inc dword [.devfn]
mov ah, [.bus]
cmp ah, [BOOT_VAR+0x9021]
jbe .loop
.nomemory:
leave
ret
endp

View File

@ -568,12 +568,41 @@ ends
struct MUTEX struct MUTEX
lhead LHEAD lhead LHEAD
count dd ? count dd ?
ends ends
struct MEM_STATE struct PCIDEV
mutex MUTEX bk dd ?
smallmap dd ? fd dd ?
vendor_device_id dd ?
class dd ?
devfn db ?
bus db ?
ends
; The following macro assume that we are on uniprocessor machine.
; Serious work is needed for multiprocessor machines.
macro spin_lock_irqsave spinlock
{
pushf
cli
}
macro spin_unlock_irqrestore spinlock
{
popf
}
macro spin_lock_irq spinlock
{
cli
}
macro spin_unlock_irq spinlock
{
sti
}
struct MEM_STATE
mutex MUTEX
smallmap dd ?
treemap dd ? treemap dd ?
topsize dd ? topsize dd ?
top dd ? top dd ?

View File

@ -151,17 +151,17 @@ proc init_kernel_heap
mov [edi+block_base], HEAP_BASE mov [edi+block_base], HEAP_BASE
mov [edi+block_size], 4096*sizeof.MEM_BLOCK mov [edi+block_size], 4096*sizeof.MEM_BLOCK
mov [edi+block_flags], USED_BLOCK mov [edi+block_flags], USED_BLOCK
mov [ecx+block_next], eax mov [ecx+block_next], eax
mov [ecx+block_prev], ebx mov [ecx+block_prev], ebx
mov [edi+list_fd], eax mov [ecx+list_fd], eax
mov [edi+list_bk], eax mov [ecx+list_bk], eax
mov [edi+block_base], eax mov [ecx+block_base], eax
mov [edi+block_size], eax mov [ecx+block_size], eax
mov [edi+block_flags], USED_BLOCK mov [ecx+block_flags], USED_BLOCK
mov [ebx+block_next], ecx mov [ebx+block_next], ecx
mov [ebx+block_prev], edi mov [ebx+block_prev], edi
mov [ebx+block_base], HEAP_BASE+4096*sizeof.MEM_BLOCK mov [ebx+block_base], HEAP_BASE+4096*sizeof.MEM_BLOCK
mov ecx, [pg_data.kernel_pages] mov ecx, [pg_data.kernel_pages]

View File

@ -281,16 +281,20 @@ __exports:
export 'KERNEL', \ export 'KERNEL', \
alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall
alloc_page, 'AllocPage', \ ; gcc ABI alloc_page, 'AllocPage', \ ; gcc ABI
alloc_pages, 'AllocPages', \ ; stdcall alloc_pages, 'AllocPages', \ ; stdcall
commit_pages, 'CommitPages', \ ; eax, ebx, ecx commit_pages, 'CommitPages', \ ; eax, ebx, ecx
\ \
create_event, 'CreateEvent', \ ; ecx, esi disk_add, 'DiskAdd', \ ;stdcall
destroy_event, 'DestroyEvent', \ ; disk_media_changed, 'DiskMediaChanged', \ ;stdcall
raise_event, 'RaiseEvent', \ ; eax, ebx, edx, esi \
wait_event, 'WaitEvent', \ ; eax, ebx create_event, 'CreateEvent', \ ; ecx, esi
get_event_ex, 'GetEvent', \ ; edi destroy_event, 'DestroyEvent', \ ;
\ raise_event, 'RaiseEvent', \ ; eax, ebx, edx, esi
create_kernel_object, 'CreateObject', \ wait_event, 'WaitEvent', \ ; eax, ebx
wait_event_timeout, 'WaitEventTimeout', \ ; eax, ebx, ecx
get_event_ex, 'GetEvent', \ ; edi
\
create_kernel_object, 'CreateObject', \
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \ destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall free_kernel_space, 'FreeKernelSpace', \ ; stdcall

View File

@ -885,12 +885,13 @@ v86_irq2:
jmp .found jmp .found
.cont3: .cont3:
pop eax pop eax
.cont2: .cont2:
pop ecx pop ecx
.cont: .cont:
loop .scan add ebx, 0x100
mov ecx, edi loop .scan
call irq_eoi mov ecx, edi
call irq_eoi
popad popad
iretd iretd
.found: .found:

View File

@ -178,12 +178,16 @@ shmem_list:
.fd dd shmem_list .fd dd shmem_list
dll_list: dll_list:
.bk dd dll_list .bk dd dll_list
.fd dd dll_list .fd dd dll_list
MAX_DEFAULT_DLL_ADDR = 0x80000000 pcidev_list:
MIN_DEFAULT_DLL_ADDR = 0x70000000 .bk dd pcidev_list
dll_cur_addr dd MIN_DEFAULT_DLL_ADDR .fd dd pcidev_list
MAX_DEFAULT_DLL_ADDR = 0x80000000
MIN_DEFAULT_DLL_ADDR = 0x70000000
dll_cur_addr dd MIN_DEFAULT_DLL_ADDR
; supported videomodes ; supported videomodes

View File

@ -562,13 +562,13 @@ ext2_HdReadFolder:
mov ecx, [ext2_data.inode_size] mov ecx, [ext2_data.inode_size]
shr ecx, 2 shr ecx, 2
mov ebp, edi mov ebp, edi
rep movsd rep movsd
pop ecx pop ecx
@@: @@:
cmp [ebp + EXT2_INODE_STRUC.i_blocks], 0 ;папка пуста cmp [ebp + EXT2_INODE_STRUC.i_size], 0 ;папка пуста
je .error_empty_dir je .error_empty_dir
push edx ;адрес результата [edi + 28] push edx ;адрес результата [edi + 28]
push 0 ;конец очередного блока папки [edi + 24] push 0 ;конец очередного блока папки [edi + 24]
push ecx ;сколько файлов нужно прочитать [edi + 20] push ecx ;сколько файлов нужно прочитать [edi + 20]
push dword [ebx] ;первый "нужный" файл [edi + 16] push dword [ebx] ;первый "нужный" файл [edi + 16]
@ -613,20 +613,20 @@ ext2_HdReadFolder:
cmp ebx, 12 ; минимальная длина записи cmp ebx, 12 ; минимальная длина записи
jb .error_bad_len jb .error_bad_len
test ebx, 0x3 ; длина записи должна делиться на 4 test ebx, 0x3 ; длина записи должна делиться на 4
jnz .error_bad_len jnz .error_bad_len
add esi, ebx ; к следующей записи sub [ebp + EXT2_INODE_STRUC.i_size], ebx ;вычитаем напрямую из структуры inode
cmp esi, [edi + 24] ; сравниваем с концом блока add esi, ebx ; к следующей записи
jb .find_wanted_start cmp esi, [edi + 24] ; сравниваем с концом блока
jb .find_wanted_start
push .find_wanted_start
.end_block: ;вылетели из цикла push .find_wanted_start
mov ebx, [ext2_data.count_block_in_block] .end_block: ;вылетели из цикла
sub [ebp + EXT2_INODE_STRUC.i_blocks], ebx ;вычитаем напрямую из структуры inode cmp [ebp + EXT2_INODE_STRUC.i_size], 0
jle .end_dir jle .end_dir
inc dword [edi] ;получаем новый блок inc dword [edi] ;получаем новый блок
push ecx push ecx
mov ecx, [edi] mov ecx, [edi]
call ext2_get_inode_block call ext2_get_inode_block
@ -724,12 +724,13 @@ ext2_HdReadFolder:
movzx ebx, [esi + EXT2_DIR_STRUC.rec_len] movzx ebx, [esi + EXT2_DIR_STRUC.rec_len]
cmp ebx, 12 ; минимальная длина записи cmp ebx, 12 ; минимальная длина записи
jb .error_bad_len jb .error_bad_len
test ebx, 0x3 ; длина записи должна делиться на 4 test ebx, 0x3 ; длина записи должна делиться на 4
jnz .error_bad_len jnz .error_bad_len
add esi, ebx sub [ebp + EXT2_INODE_STRUC.i_size], ebx ;вычитаем напрямую из структуры inode
cmp esi, [edi + 24] ;дошли ли до конца блока? add esi, ebx
jb .wanted_start cmp esi, [edi + 24] ;дошли ли до конца блока?
jb .wanted_start
push .wanted_start ; дошли push .wanted_start ; дошли
jmp .end_block jmp .end_block
@ -1092,25 +1093,26 @@ ext2_find_lfn:
je .error_empty_root je .error_empty_root
.next_path_part: .next_path_part:
push [ebp + EXT2_INODE_STRUC.i_blocks] push [ebp + EXT2_INODE_STRUC.i_blocks]
xor ecx, ecx xor ecx, ecx
.folder_block_cycle: .folder_block_cycle:
call ext2_get_inode_block push ecx
test eax, eax call ext2_get_inode_block
jnz .error_get_inode_block test eax, eax
jnz .error_get_inode_block
mov eax, ecx mov eax, ecx
mov ebx, [ext2_data.ext2_save_block] ;ebx = cur dir record mov ebx, [ext2_data.ext2_save_block] ;ebx = cur dir record
call ext2_get_block call ext2_get_block
test eax, eax test eax, eax
jnz .error_get_block jnz .error_get_block
push esi push esi
call ext2_test_block_by_name call ext2_test_block_by_name
pop edi pop edi ecx
cmp edi, esi ;нашли имя? cmp edi, esi ;нашли имя?
je .next_folder_block ;не нашли -> к след. блоку je .next_folder_block ;не нашли -> к след. блоку
cmp byte [esi], 0 ;дошли до "конца" пути -> возваращаемся cmp byte [esi], 0 ;дошли до "конца" пути -> возваращаемся
jz .get_inode_ret jz .get_inode_ret
@ -1150,12 +1152,13 @@ ext2_find_lfn:
mov ebp, ebx mov ebp, ebx
xor eax, eax xor eax, eax
ret ret
.error_get_inode_block: .error_get_inode_block:
.error_get_block: .error_get_block:
.error_get_inode: pop ecx
pop ebx .error_get_inode:
.error_empty_root: pop ebx
.error_empty_root:
mov eax, ERROR_FS_FAIL mov eax, ERROR_FS_FAIL
ret ret

View File

@ -304,12 +304,29 @@ wait_event: ;; EXPORT use
mov ecx, eax ; wait_param mov ecx, eax ; wait_param
mov edx, get_event_alone ; wait_test mov edx, get_event_alone ; wait_test
call Wait_events ; timeout ignored call Wait_events ; timeout ignored
jmp wait_finish jmp wait_finish
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
get_event_ex: ;; f68:14 wait_event_timeout:
;info: ;param:
; Ожидание любого события в очереди EventList текущего слота ; eax - event
; ebx - uid (for Dummy testing)
; ecx - timeout in timer ticks
;retval:
; eax - EVENT handle or 0 if timeout
call DummyTest
mov ebx, ecx
mov ecx, eax ; wait_param
mov edx, get_event_alone ; wait_test
call Wait_events_ex
test eax, eax
jnz wait_finish
ret
;-----------------------------------------------------------------------------
align 4
get_event_ex: ;; f68:14
;info:
; Îæèäàíèå ëþáîãî ñîáûòèÿ â î÷åðåäè EventList òåêóùåãî ñëîòà
; Данные события code - копируются в память приложения (косвенно по edi) ; Данные события code - копируются в память приложения (косвенно по edi)
; При активном флаге MANUAL_RESET - больше ничего ; При активном флаге MANUAL_RESET - больше ничего
; Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются, ; Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются,
@ -592,7 +609,7 @@ align 4
je .result je .result
add edx, 8 add edx, 8
cmp edx, hotkey_buffer+120*8 cmp edx, hotkey_buffer+120*8
jb @b jb @b
jmp .loop jmp .loop
;end. ;end.
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------

View File

@ -789,12 +789,13 @@ end if
; call build_scheduler; sys32.inc ; call build_scheduler; sys32.inc
; mov esi, boot_devices ; mov esi, boot_devices
; call boot_log ; call boot_log
mov [pci_access_enabled], 1 mov [pci_access_enabled], 1
call pci_enum
; SET PRELIMINARY WINDOW STACK AND POSITIONS
; SET PRELIMINARY WINDOW STACK AND POSITIONS
mov esi, boot_windefs mov esi, boot_windefs
call boot_log call boot_log
call set_window_defaults call set_window_defaults
@ -4614,15 +4615,16 @@ sys_msg_board_dword:
pop eax pop eax
pop ecx pop ecx
loop @b loop @b
popad popad
ret ret
uglobal msg_board_data_size = 65536 ; Must be power of two
msg_board_data:
times 4096 db 0 uglobal
msg_board_count dd 0x0 msg_board_data rb msg_board_data_size
endg msg_board_count dd 0x0
endg
sys_msg_board: sys_msg_board:
; eax=1 : write : bl byte to write ; eax=1 : write : bl byte to write
@ -4649,13 +4651,13 @@ if defined debug_com_base
pop ax dx pop ax dx
end if end if
mov [msg_board_data+ecx], bl mov [msg_board_data+ecx], bl
inc ecx inc ecx
and ecx, 4095 and ecx, msg_board_data_size - 1
mov [msg_board_count], ecx mov [msg_board_count], ecx
mov [check_idle_semaphore], 5 mov [check_idle_semaphore], 5
ret ret
.smbl1: .smbl1:
cmp eax, 2 cmp eax, 2
jne .smbl2 jne .smbl2
@ -4742,13 +4744,14 @@ align 4
movzx ecx, cl movzx ecx, cl
lea ecx, [hotkey_scancodes+ecx*4] lea ecx, [hotkey_scancodes+ecx*4]
mov edx, [ecx] mov edx, [ecx]
mov [eax], edx mov [eax], edx
mov [ecx], eax mov [ecx], eax
mov [eax+12], ecx mov [eax+12], ecx
jecxz @f test edx, edx
mov [edx+12], eax jz @f
@@: mov [edx+12], eax
and dword [esp+32], 0 @@:
and dword [esp+32], 0
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4