Subversion Repositories Kolibri OS

Compare Revisions

Ignore whitespace Rev 3404 → Rev 3405

/kernel/branches/net/bus/pci/pci32.inc
152,18 → 152,18
; (0 - byte, 1 - word, 2 - dword)
;***************************************************************************
 
align 4
 
pci_read_reg:
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
mov esi, eax
and esi, 3
 
call pci_make_config_cmd
align 4
 
pci_read_reg:
push ebx esi
cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
je pci_read_reg_2
 
; mechanism 1
mov esi, eax ; save register size into ESI
and esi, 3
 
call pci_make_config_cmd
mov ebx, eax
; get current state
mov dx, 0xcf8
199,21 → 199,20
; restore configuration control
xchg eax, [esp]
mov dx, 0xcf8
out dx, eax
 
pop eax
pop esi
ret
pci_read_reg_2:
 
test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_read_reg_err
 
push esi; save register size into ESI
mov esi, eax
and esi, 3
 
push eax
out dx, eax
 
pop eax
pop esi ebx
ret
pci_read_reg_2:
 
test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_read_reg_err
 
mov esi, eax ; save register size into ESI
and esi, 3
 
push eax
;store current state of config space
mov dx, 0xcf8
in al, dx
259,18 → 258,19
out dx, al
mov dl, 0xf8
mov al, ah
out dx, al
 
pop eax
pop esi
ret
 
pci_read_reg_err:
xor eax, eax
dec eax
ret
 
 
out dx, al
 
pop eax
pop esi ebx
ret
 
pci_read_reg_err:
xor eax, eax
dec eax
pop esi ebx
ret
 
 
;***************************************************************************
; Function
; pci_write_reg:
283,18 → 283,18
; (0 - byte, 1 - word, 2 - dword)
;***************************************************************************
 
align 4
 
pci_write_reg:
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
mov esi, eax
and esi, 3
 
call pci_make_config_cmd
align 4
 
pci_write_reg:
push esi ebx
cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
je pci_write_reg_2
 
; mechanism 1
mov esi, eax ; save register size into ESI
and esi, 3
 
call pci_make_config_cmd
mov ebx, eax
; get current state into ecx
mov dx, 0xcf8
332,23 → 332,22
; restore configuration control
pop eax
mov dl, 0xf8
out dx, eax
out dx, eax
 
xor eax, eax
pop ebx esi
 
ret
pci_write_reg_2:
 
xor eax, eax
pop esi
 
ret
pci_write_reg_2:
 
test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_write_reg_err
 
 
push esi; save register size into ESI
mov esi, eax
and esi, 3
 
push eax
jnz pci_write_reg_err
 
 
mov esi, eax ; save register size into ESI
and esi, 3
 
push eax
;store current state of config space
mov dx, 0xcf8
in al, dx
394,18 → 393,19
out dx, al
mov dl, 0xf8
mov al, ah
out dx, al
 
xor eax, eax
pop esi
ret
 
pci_write_reg_err:
xor eax, eax
dec eax
ret
 
if defined mmio_pci_addr ; must be set above
out dx, al
 
xor eax, eax
pop ebx esi
ret
 
pci_write_reg_err:
xor eax, eax
dec eax
pop ebx esi
ret
 
if defined mmio_pci_addr ; must be set above
;***************************************************************************
; Function
; pci_mmio_init
655,6 → 655,70
mov dword[esp + 28], ecx
.return_ab:
mov dword[esp + 20], ebx
.return_a:
mov dword[esp + 32], eax
ret
.return_a:
mov dword[esp + 32], eax
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
/kernel/branches/net/const.inc
568,12 → 568,41
 
struct MUTEX
lhead LHEAD
count dd ?
ends
 
struct MEM_STATE
mutex MUTEX
smallmap dd ?
count dd ?
ends
 
struct PCIDEV
bk 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 ?
topsize dd ?
top dd ?
/kernel/branches/net/core/heap.inc
151,17 → 151,17
mov [edi+block_base], HEAP_BASE
mov [edi+block_size], 4096*sizeof.MEM_BLOCK
mov [edi+block_flags], USED_BLOCK
 
mov [ecx+block_next], eax
mov [ecx+block_prev], ebx
mov [edi+list_fd], eax
mov [edi+list_bk], eax
mov [edi+block_base], eax
mov [edi+block_size], eax
mov [edi+block_flags], USED_BLOCK
 
mov [ebx+block_next], ecx
mov [ebx+block_prev], edi
 
mov [ecx+block_next], eax
mov [ecx+block_prev], ebx
mov [ecx+list_fd], eax
mov [ecx+list_bk], eax
mov [ecx+block_base], eax
mov [ecx+block_size], eax
mov [ecx+block_flags], USED_BLOCK
 
mov [ebx+block_next], ecx
mov [ebx+block_prev], edi
mov [ebx+block_base], HEAP_BASE+4096*sizeof.MEM_BLOCK
 
mov ecx, [pg_data.kernel_pages]
/kernel/branches/net/core/peload.inc
281,16 → 281,20
export 'KERNEL', \
alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall
alloc_page, 'AllocPage', \ ; gcc ABI
alloc_pages, 'AllocPages', \ ; stdcall
commit_pages, 'CommitPages', \ ; eax, ebx, ecx
\
create_event, 'CreateEvent', \ ; ecx, esi
destroy_event, 'DestroyEvent', \ ;
raise_event, 'RaiseEvent', \ ; eax, ebx, edx, esi
wait_event, 'WaitEvent', \ ; eax, ebx
get_event_ex, 'GetEvent', \ ; edi
\
create_kernel_object, 'CreateObject', \
alloc_pages, 'AllocPages', \ ; stdcall
commit_pages, 'CommitPages', \ ; eax, ebx, ecx
\
disk_add, 'DiskAdd', \ ;stdcall
disk_media_changed, 'DiskMediaChanged', \ ;stdcall
\
create_event, 'CreateEvent', \ ; ecx, esi
destroy_event, 'DestroyEvent', \ ;
raise_event, 'RaiseEvent', \ ; eax, ebx, edx, esi
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
destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall
/kernel/branches/net/core/v86.inc
885,12 → 885,13
jmp .found
.cont3:
pop eax
.cont2:
pop ecx
.cont:
loop .scan
mov ecx, edi
call irq_eoi
.cont2:
pop ecx
.cont:
add ebx, 0x100
loop .scan
mov ecx, edi
call irq_eoi
popad
iretd
.found:
/kernel/branches/net/data32.inc
178,13 → 178,17
.fd dd shmem_list
 
dll_list:
.bk dd dll_list
.fd dd dll_list
.bk dd dll_list
.fd dd dll_list
 
pcidev_list:
.bk dd pcidev_list
.fd dd pcidev_list
 
MAX_DEFAULT_DLL_ADDR = 0x80000000
MIN_DEFAULT_DLL_ADDR = 0x70000000
dll_cur_addr dd MIN_DEFAULT_DLL_ADDR
 
MAX_DEFAULT_DLL_ADDR = 0x80000000
MIN_DEFAULT_DLL_ADDR = 0x70000000
dll_cur_addr dd MIN_DEFAULT_DLL_ADDR
 
; supported videomodes
 
 
/kernel/branches/net/fs/ext2.inc
562,13 → 562,13
mov ecx, [ext2_data.inode_size]
shr ecx, 2
mov ebp, edi
rep movsd
pop ecx
@@:
cmp [ebp + EXT2_INODE_STRUC.i_blocks], 0 ;папка пуста
je .error_empty_dir
push edx ;адрес результата [edi + 28]
rep movsd
pop ecx
@@:
cmp [ebp + EXT2_INODE_STRUC.i_size], 0 ;папка пуста
je .error_empty_dir
push edx ;адрес результата [edi + 28]
push 0 ;конец очередного блока папки [edi + 24]
push ecx ;сколько файлов нужно прочитать [edi + 20]
push dword [ebx] ;первый "нужный" файл [edi + 16]
613,20 → 613,20
 
cmp ebx, 12 ; минимальная длина записи
jb .error_bad_len
test ebx, 0x3 ; длина записи должна делиться на 4
jnz .error_bad_len
 
add esi, ebx ; к следующей записи
cmp esi, [edi + 24] ; сравниваем с концом блока
jb .find_wanted_start
 
push .find_wanted_start
.end_block: ;вылетели из цикла
mov ebx, [ext2_data.count_block_in_block]
sub [ebp + EXT2_INODE_STRUC.i_blocks], ebx ;вычитаем напрямую из структуры inode
jle .end_dir
 
inc dword [edi] ;получаем новый блок
test ebx, 0x3 ; длина записи должна делиться на 4
jnz .error_bad_len
 
sub [ebp + EXT2_INODE_STRUC.i_size], ebx ;вычитаем напрямую из структуры inode
add esi, ebx ; к следующей записи
cmp esi, [edi + 24] ; сравниваем с концом блока
jb .find_wanted_start
 
push .find_wanted_start
.end_block: ;вылетели из цикла
cmp [ebp + EXT2_INODE_STRUC.i_size], 0
jle .end_dir
 
inc dword [edi] ;получаем новый блок
push ecx
mov ecx, [edi]
call ext2_get_inode_block
724,13 → 724,14
movzx ebx, [esi + EXT2_DIR_STRUC.rec_len]
cmp ebx, 12 ; минимальная длина записи
jb .error_bad_len
test ebx, 0x3 ; длина записи должна делиться на 4
jnz .error_bad_len
test ebx, 0x3 ; длина записи должна делиться на 4
jnz .error_bad_len
 
sub [ebp + EXT2_INODE_STRUC.i_size], ebx ;вычитаем напрямую из структуры inode
add esi, ebx
cmp esi, [edi + 24] ;дошли ли до конца блока?
jb .wanted_start
 
add esi, ebx
cmp esi, [edi + 24] ;дошли ли до конца блока?
jb .wanted_start
 
push .wanted_start ; дошли
jmp .end_block
 
1092,12 → 1093,13
je .error_empty_root
.next_path_part:
push [ebp + EXT2_INODE_STRUC.i_blocks]
xor ecx, ecx
.folder_block_cycle:
call ext2_get_inode_block
test eax, eax
jnz .error_get_inode_block
push [ebp + EXT2_INODE_STRUC.i_blocks]
xor ecx, ecx
.folder_block_cycle:
push ecx
call ext2_get_inode_block
test eax, eax
jnz .error_get_inode_block
mov eax, ecx
mov ebx, [ext2_data.ext2_save_block] ;ebx = cur dir record
1104,14 → 1106,14
call ext2_get_block
test eax, eax
jnz .error_get_block
push esi
call ext2_test_block_by_name
pop edi ecx
 
cmp edi, esi ;нашли имя?
je .next_folder_block ;не нашли -> к след. блоку
push esi
call ext2_test_block_by_name
pop edi
 
cmp edi, esi ;нашли имя?
je .next_folder_block ;не нашли -> к след. блоку
cmp byte [esi], 0 ;дошли до "конца" пути -> возваращаемся
jz .get_inode_ret
 
1150,12 → 1152,13
mov ebp, ebx
xor eax, eax
ret
 
.error_get_inode_block:
.error_get_block:
.error_get_inode:
pop ebx
.error_empty_root:
 
.error_get_inode_block:
.error_get_block:
pop ecx
.error_get_inode:
pop ebx
.error_empty_root:
mov eax, ERROR_FS_FAIL
ret
 
/kernel/branches/net/gui/event.inc
304,12 → 304,29
mov ecx, eax ; wait_param
mov edx, get_event_alone ; wait_test
call Wait_events ; timeout ignored
jmp wait_finish
;-----------------------------------------------------------------------------
align 4
get_event_ex: ;; f68:14
;info:
; Îæèäàíèå ëþáîãî ñîáûòèÿ â î÷åðåäè EventList òåêóùåãî ñëîòà
jmp wait_finish
;-----------------------------------------------------------------------------
align 4
wait_event_timeout:
;param:
; 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)
; Ïðè àêòèâíîì ôëàãå MANUAL_RESET - áîëüøå íè÷åãî
; Èíà÷å: ôëàãè EVENT_SIGNALED è EVENT_WATCHED ó ïîëó÷åííîãî ñîáûòèÿ ñáðàñûâàþòñÿ,
592,7 → 609,7
je .result
add edx, 8
cmp edx, hotkey_buffer+120*8
jb @b
jmp .loop
;end.
;-----------------------------------------------------------------------------
jb @b
jmp .loop
;end.
;-----------------------------------------------------------------------------
/kernel/branches/net/kernel.asm
789,12 → 789,13
; call build_scheduler; sys32.inc
 
; mov esi, boot_devices
; call boot_log
 
mov [pci_access_enabled], 1
 
; SET PRELIMINARY WINDOW STACK AND POSITIONS
 
; call boot_log
 
mov [pci_access_enabled], 1
call pci_enum
 
; SET PRELIMINARY WINDOW STACK AND POSITIONS
 
mov esi, boot_windefs
call boot_log
call set_window_defaults
4614,15 → 4615,16
pop eax
pop ecx
loop @b
popad
ret
 
uglobal
msg_board_data:
times 4096 db 0
msg_board_count dd 0x0
endg
 
popad
ret
 
msg_board_data_size = 65536 ; Must be power of two
 
uglobal
msg_board_data rb msg_board_data_size
msg_board_count dd 0x0
endg
 
sys_msg_board:
 
; eax=1 : write : bl byte to write
4649,13 → 4651,13
pop ax dx
 
end if
 
mov [msg_board_data+ecx], bl
inc ecx
and ecx, 4095
mov [msg_board_count], ecx
mov [check_idle_semaphore], 5
ret
 
mov [msg_board_data+ecx], bl
inc ecx
and ecx, msg_board_data_size - 1
mov [msg_board_count], ecx
mov [check_idle_semaphore], 5
ret
.smbl1:
cmp eax, 2
jne .smbl2
4742,13 → 4744,14
movzx ecx, cl
lea ecx, [hotkey_scancodes+ecx*4]
mov edx, [ecx]
mov [eax], edx
mov [ecx], eax
mov [eax+12], ecx
jecxz @f
mov [edx+12], eax
@@:
and dword [esp+32], 0
mov [eax], edx
mov [ecx], eax
mov [eax+12], ecx
test edx, edx
jz @f
mov [edx+12], eax
@@:
and dword [esp+32], 0
ret
;-----------------------------------------------------------------------------
align 4