Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2382 → Rev 2381

/kernel/branches/net/network/stack.inc
150,13 → 150,6
 
}
 
 
wait_mutex: ; stub
inc dword [ebx]
 
ret
 
 
include "queue.inc"
 
include "ethernet.inc"
/kernel/branches/net/core/timers.inc
File deleted
/kernel/branches/net/core/apic.inc
File deleted
/kernel/branches/net/core/irq.inc
File deleted
/kernel/branches/net/core/syscall.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17,7 → 17,6
mov edx, esi
mov esi, edi
movzx edi, byte[esp+28 + 4]
sub edi, 53
call dword [servetable+edi*4]
ret
 
102,17 → 101,78
 
align 4
servetable:
 
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd sound_interface ; 55-Sound interface
dd 0
dd 0
dd file_system ; 58-Common file system interface
dd 0
dd sys_IPC ; 60-Inter Process Communication
dd sys_gs ; 61-Direct graphics access
dd sys_pci ; 62-PCI functions
dd sys_msg_board ; 63-System message board
dd 0
dd syscall_putimage_palette; 65-PutImagePalette
dd sys_process_def ; 66-Process definitions - keyboard
dd sys_window_move ; 67-Window move or resize
dd 0
dd 0 ; 62-PCI functions
dd sys_msg_board ; 63-System message board
dd 0
dd file_system_lfn ; 70-Common file system interface, version 2
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW SYSTEM FUNCTIONS TABLE ;;
120,7 → 180,7
align 4
servetable2:
 
dd syscall_draw_window ; 0-DrawWindow
dd sys_drawwindow ; 0-DrawWindow
dd syscall_setpixel ; 1-SetPixel
dd sys_getkey ; 2-GetKey
dd sys_clock ; 3-GetTime
161,11 → 221,11
dd syscall_drawline ; 38-DrawLine
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
dd set_app_param ; 40-WantEvents
dd undefined_syscall ; 41- deprecated GetIrqOwner
dd undefined_syscall ; 42- deprecated ReadIrqData
dd syscall_getirqowner ; 41-GetIrqOwner
dd get_irq_data ; 42-ReadIrqData
dd sys_outport ; 43-SendDeviceData
dd undefined_syscall ; 44- deprecated ProgramIrqs
dd undefined_syscall ; 45- deprecated ReserveIrq and FreeIrq
dd sys_programirq ; 44-ProgramIrqs
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
dd display_number ; 47-WriteNum
dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
172,28 → 232,28
dd sys_apm ; 49-Advanced Power Management (APM)
dd syscall_set_window_shape ; 50-Window shape & scale
dd syscall_threads ; 51-Threads
dd undefined_syscall ; 52 old network stack
dd undefined_syscall ; 53 old network stack
dd undefined_syscall ; 52-Stack driver status
dd undefined_syscall ; 53-Socket interface
dd undefined_syscall ; 54-reserved
dd sound_interface ; 55-Sound interface
dd cross_order ; 55-Sound interface
dd undefined_syscall ; 56-reserved
dd sys_pcibios ; 57-PCI BIOS32
dd cross_order ; 58-Common file system interface
dd undefined_syscall ; 59-reserved
dd sys_IPC ; 60-Inter Process Communication
dd sys_gs ; 61-Direct graphics access
dd pci_api ;cross_order ; 62-PCI functions
dd cross_order ; 60-Inter Process Communication
dd cross_order ; 61-Direct graphics access
dd cross_order ; 62-PCI functions
dd cross_order ; 63-System message board
dd sys_resize_app_memory ; 64-Resize application memory usage
dd sys_putimage_palette ; 65-PutImagePalette
dd sys_process_def ; 66-Process definitions - keyboard
dd syscall_move_window ; 67-Window move or resize
dd cross_order ; 65-PutImagePalette
dd cross_order ; 66-Process definitions - keyboard
dd cross_order ; 67-Window move or resize
dd f68 ; 68-Some internal services
dd sys_debug_services ; 69-Debug
dd file_system_lfn ; 70-Common file system interface, version 2
dd syscall_window_settings ; 71-Window settings
dd cross_order ; 70-Common file system interface, version 2
dd syscall_windowsettings ; 71-Window settings
dd sys_sendwindowmsg ; 72-Send window message
dd blit_32 ; 73-blitter;
dd undefined_syscall ; 73-reserved for blitter
dd sys_network ; 74-Network stack
dd sys_socket ; 75-Sockets
dd sys_protocols ; 76-Protocols
/kernel/branches/net/core/heap.inc
9,17 → 9,17
 
 
struc MEM_BLOCK
{
.list LHEAD
.next_block dd ? ;+8
{ .next_block dd ?
.prev_block dd ? ;+4
.list_fd dd ? ;+8
.list_bk dd ? ;+12
.base dd ? ;+16
.size dd ? ;+20
.flags dd ? ;+24
.handle dd ? ;+28
.sizeof:
}
 
MEM_LIST_OFFSET equ 8
FREE_BLOCK equ 4
USED_BLOCK equ 8
DONT_FREE_BLOCK equ 10h
28,11 → 28,12
MEM_BLOCK MEM_BLOCK
end virtual
 
MEM_BLOCK_SIZE equ 8*4
 
block_next equ MEM_BLOCK.next_block
block_prev equ MEM_BLOCK.prev_block
list_fd equ MEM_BLOCK.list.next
list_bk equ MEM_BLOCK.list.prev
list_fd equ MEM_BLOCK.list_fd
list_bk equ MEM_BLOCK.list_bk
block_base equ MEM_BLOCK.base
block_size equ MEM_BLOCK.size
block_flags equ MEM_BLOCK.flags
46,94 → 47,69
@@:
}
 
align 4
md:
.add_to_used:
mov eax, [esi+block_base]
mov ebx, [esi+block_base]
shr ebx, 6
add eax, ebx
shr ebx, 6
add eax, ebx
shr eax, 12
and eax, 63
inc [mem_hash_cnt+eax*4]
macro remove_from_list op
{ mov edx, [op+list_fd]
mov ecx, [op+list_bk]
test edx, edx
jz @f
mov [edx+list_bk], ecx
@@:
test ecx, ecx
jz @f
mov [ecx+list_fd], edx
@@:
mov [op+list_fd],0
mov [op+list_bk],0
}
 
lea ecx, [mem_used_list+eax*8]
list_add esi, ecx
mov [esi+block_flags], USED_BLOCK
mov eax, [esi+block_size]
sub [heap_free], eax
ret
align 4
.find_used:
mov ecx, eax
mov ebx, eax
shr ebx, 6
add ecx, ebx
shr ebx, 6
add ecx, ebx
shr ecx, 12
and ecx, 63
macro remove_from_free op
{
remove_from_list op
 
lea ebx, [mem_used_list+ecx*8]
mov esi, ebx
.next:
mov esi, [esi+list_fd]
cmp esi, ebx
je .fail
mov eax, [op+block_size]
calc_index eax
cmp [mem_block_list+eax*4], op
jne @f
mov [mem_block_list+eax*4], edx
@@:
cmp [mem_block_list+eax*4], 0
jne @f
btr [mem_block_mask], eax
@@:
}
 
cmp eax, [esi+block_base]
jne .next
macro remove_from_used op
{
mov edx, [op+list_fd]
mov ecx, [op+list_bk]
mov [edx+list_bk], ecx
mov [ecx+list_fd], edx
mov [op+list_fd], 0
mov [op+list_bk], 0
}
 
ret
.fail:
xor esi, esi
ret
 
align 4
.del_from_used:
call .find_used
test esi, esi
jz .done
 
cmp [esi+block_flags], USED_BLOCK
jne .fatal
 
dec [mem_hash_cnt+ecx*4]
list_del esi
.done:
ret
.fatal: ;FIXME panic here
xor esi, esi
ret
 
;Initial heap state
;
;+heap_size terminator USED_BLOCK
;+4096*MEM_BLOCK.sizeof free space FREE_BLOCK
;HEAP_BASE heap_descriptors USED_BLOCK
;
 
align 4
proc init_kernel_heap
 
mov ecx, 64
mov edi, mem_block_list
@@:
mov eax, edi
stosd
stosd
loop @B
xor eax, eax
cld
rep stosd
 
mov ecx, 64
mov edi, mem_used_list
@@:
mov eax, edi
stosd
stosd
loop @B
mov ecx, 512/4
mov edi, mem_block_map
not eax
rep stosd
 
mov [mem_block_start], mem_block_map
mov [mem_block_end], mem_block_map+512
mov [mem_block_arr], HEAP_BASE
 
mov eax, mem_used.fd-MEM_LIST_OFFSET
mov [mem_used.fd], eax
mov [mem_used.bk], eax
 
stdcall alloc_pages, dword 32
mov ecx, 32
mov edx, eax
145,10 → 121,8
dec ecx
jnz .l1
 
mov edi, HEAP_BASE ;descriptors
mov ebx, HEAP_BASE+MEM_BLOCK.sizeof ;free space
mov ecx, HEAP_BASE+MEM_BLOCK.sizeof*2 ;terminator
 
mov edi, HEAP_BASE
mov ebx, HEAP_BASE+MEM_BLOCK_SIZE
xor eax, eax
mov [edi+block_next], ebx
mov [edi+block_prev], eax
155,24 → 129,18
mov [edi+list_fd], eax
mov [edi+list_bk], eax
mov [edi+block_base], HEAP_BASE
mov [edi+block_size], 4096*MEM_BLOCK.sizeof
mov [edi+block_size], 4096*MEM_BLOCK_SIZE
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], eax
mov [ebx+block_prev], eax
mov [ebx+list_fd], eax
mov [ebx+list_bk], eax
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE
 
mov [ebx+block_next], ecx
mov [ebx+block_prev], edi
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK.sizeof
 
mov ecx, [pg_data.kernel_pages]
shl ecx, 12
sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK.sizeof
sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK_SIZE
mov [heap_size], ecx
mov [heap_free], ecx
mov [ebx+block_size], ecx
181,24 → 149,11
mov [mem_block_mask], eax
mov [mem_block_mask+4], 0x80000000
 
mov ecx, mem_block_list+63*8
list_add ebx, ecx
 
mov ecx, 4096-3-1
mov eax, HEAP_BASE+MEM_BLOCK.sizeof*4
 
mov [next_memblock], HEAP_BASE+MEM_BLOCK.sizeof*3
@@:
mov [eax-MEM_BLOCK.sizeof], eax
add eax, MEM_BLOCK.sizeof
loop @B
 
mov [eax-MEM_BLOCK.sizeof], dword 0
 
mov ecx, heap_mutex
call mutex_init
mov [heap_blocks], 4094
mov [free_blocks], 4093
mov [mem_block_list+63*4], ebx
mov byte [mem_block_map], 0xFC
and [heap_mutex], 0
mov [heap_blocks], 4095
mov [free_blocks], 4094
ret
endp
 
235,18 → 190,11
bsf edi, edx
jz .high_mask
add ebx, edi
lea ecx, [mem_block_list+ebx*8]
mov edi, ecx
.next:
mov edi, [edi+list_fd]
cmp edi, ecx
je .err
mov edi, [mem_block_list+ebx*4]
.check_size:
cmp eax, [edi+block_size]
ja .next
ret
.err:
xor edi, edi
ret
 
.high_mask:
add esi, 4
255,24 → 203,66
add ebx, 32
mov edx, [esi]
jmp .find
.next:
mov edi, [edi+list_fd]
test edi, edi
jnz .check_size
.err:
xor edi, edi
ret
 
align 4
alloc_mem_block:
 
mov ebx, [mem_block_start]
mov ecx, [mem_block_end]
.l1:
bsf eax,[ebx];
jnz found
add ebx,4
cmp ebx, ecx
jb .l1
xor eax,eax
ret
 
found:
btr [ebx], eax
mov [mem_block_start],ebx
sub ebx, mem_block_map
lea eax,[eax+ebx*8]
shl eax, 5
add eax, [mem_block_arr]
dec [free_blocks]
ret
align 4
free_mem_block:
mov ebx, [next_memblock]
mov [eax], ebx
mov [next_memblock], eax
xor ebx, ebx
mov dword [eax], 0
mov dword [eax+4], 0
mov dword [eax+8], 0
mov dword [eax+12], 0
mov dword [eax+16], 0
; mov dword [eax+20], 0
mov dword [eax+24], 0
mov dword [eax+28], 0
 
mov dword [eax+4], ebx
mov dword [eax+8], ebx
mov dword [eax+12], ebx
mov dword [eax+16], ebx
; mov dword [eax+20], 0 ;don't clear block size
mov dword [eax+24], ebx
mov dword [eax+28], ebx
sub eax, [mem_block_arr]
shr eax, 5
 
mov ebx, mem_block_map
bts [ebx], eax
inc [free_blocks]
shr eax, 3
and eax, not 3
add eax, ebx
cmp [mem_block_start], eax
ja @f
ret
@@:
mov [mem_block_start], eax
ret
.err:
xor eax, eax
ret
 
align 4
proc alloc_kernel_space stdcall, size:dword
287,20 → 277,18
and eax, not 4095
mov [size], eax
 
mov ebx, heap_mutex
call wait_mutex ;ebx
 
cmp eax, [heap_free]
ja .error
 
mov ecx, heap_mutex
call mutex_lock
 
mov eax, [size]
 
call get_small_block ; eax
test edi, edi
jz .error_unlock
jz .error
 
cmp [edi+block_flags], FREE_BLOCK
jne .error_unlock
jne .error
 
mov [block_ind], ebx ;index of allocated block
 
308,13 → 296,11
cmp eax, [size]
je .m_eq_size
 
mov esi, [next_memblock] ;new memory block
test esi, esi
jz .error_unlock
call alloc_mem_block
and eax, eax
jz .error
 
dec [free_blocks]
mov eax, [esi]
mov [next_memblock], eax
mov esi, eax ;esi - splitted block
 
mov [esi+block_next], edi
mov eax, [edi+block_prev]
322,8 → 308,10
mov [edi+block_prev], esi
mov [esi+list_fd], 0
mov [esi+list_bk], 0
and eax, eax
jz @f
mov [eax+block_next], esi
 
@@:
mov ebx, [edi+block_base]
mov [esi+block_base], ebx
mov edx, [size]
332,48 → 320,75
sub [edi+block_size], edx
 
mov eax, [edi+block_size]
calc_index eax
shr eax, 12
sub eax, 1
cmp eax, 63
jna @f
mov eax, 63
@@:
cmp eax, [block_ind]
je .add_used
je .m_eq_ind
 
list_del edi
remove_from_list edi
 
mov ecx, [block_ind]
lea edx, [mem_block_list+ecx*8]
cmp edx, [edx]
mov [mem_block_list+ecx*4], edx
 
test edx, edx
jnz @f
btr [mem_block_mask], ecx
@@:
mov edx, [mem_block_list+eax*4]
mov [edi+list_fd], edx
test edx, edx
jz @f
mov [edx+list_bk], edi
@@:
mov [mem_block_list+eax*4], edi
bts [mem_block_mask], eax
lea edx, [mem_block_list+eax*8] ;edx= list head
list_add edi, edx
.add_used:
.m_eq_ind:
mov ecx, mem_used.fd-MEM_LIST_OFFSET
mov edx, [ecx+list_fd]
mov [esi+list_fd], edx
mov [esi+list_bk], ecx
mov [ecx+list_fd], esi
mov [edx+list_bk], esi
 
call md.add_to_used
 
mov ecx, heap_mutex
call mutex_unlock
mov [esi+block_flags], USED_BLOCK
mov eax, [esi+block_base]
mov ebx, [size]
sub [heap_free], ebx
and [heap_mutex], 0
pop edi
pop esi
pop ebx
ret
 
.m_eq_size:
list_del edi
lea edx, [mem_block_list+ebx*8]
cmp edx, [edx]
remove_from_list edi
mov [mem_block_list+ebx*4], edx
and edx, edx
jnz @f
btr [mem_block_mask], ebx
@@:
mov esi, edi
jmp .add_used
mov ecx, mem_used.fd-MEM_LIST_OFFSET
mov edx, [ecx+list_fd]
mov [edi+list_fd], edx
mov [edi+list_bk], ecx
mov [ecx+list_fd], edi
mov [edx+list_bk], edi
 
.error_unlock:
mov ecx, heap_mutex
call mutex_unlock
mov [edi+block_flags], USED_BLOCK
mov eax, [edi+block_base]
mov ebx, [size]
sub [heap_free], ebx
and [heap_mutex], 0
pop edi
pop esi
pop ebx
ret
.error:
xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
382,49 → 397,66
 
align 4
proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
push ebx
push esi
push edi
mov ebx, heap_mutex
call wait_mutex ;ebx
 
mov ecx, heap_mutex
call mutex_lock
 
mov eax, [base]
mov esi, [mem_used.fd]
@@:
cmp esi, mem_used.fd-MEM_LIST_OFFSET
je .fail
 
call md.del_from_used
test esi, esi
jz .fail
cmp [esi+block_base], eax
je .found
mov esi, [esi+list_fd]
jmp @b
.found:
cmp [esi+block_flags], USED_BLOCK
jne .fail
 
mov eax, [esi+block_size]
add [heap_free], eax
 
mov edi, [esi+block_next]
test edi, edi
jz .prev
 
cmp [edi+block_flags], FREE_BLOCK
jne .prev
 
list_del edi
remove_from_free edi
 
mov edx, [edi+block_next]
mov [esi+block_next], edx
test edx, edx
jz @f
 
mov [edx+block_prev], esi
@@:
mov ecx, [edi+block_size]
add [esi+block_size], ecx
 
calc_index ecx
 
lea edx, [mem_block_list+ecx*8]
cmp edx, [edx]
jne @F
btr [mem_block_mask], ecx
@@:
mov eax, edi
call free_mem_block
.prev:
mov edi, [esi+block_prev]
test edi, edi
jz .insert
 
cmp [edi+block_flags], FREE_BLOCK
jne .insert
 
remove_from_used esi
 
mov edx, [esi+block_next]
mov [edi+block_next], edx
test edx, edx
jz @f
mov [edx+block_prev], edi
 
@@:
mov eax, esi
call free_mem_block
 
433,40 → 465,67
add eax, ecx
mov [edi+block_size], eax
 
calc_index eax ;new index
calc_index ecx ;old index
calc_index eax
calc_index ecx
cmp eax, ecx
je .m_eq
 
push ecx
list_del edi
remove_from_list edi
pop ecx
 
lea edx, [mem_block_list+ecx*8]
cmp edx, [edx]
jne .add_block
cmp [mem_block_list+ecx*4], edi
jne @f
mov [mem_block_list+ecx*4], edx
@@:
cmp [mem_block_list+ecx*4], 0
jne @f
btr [mem_block_mask], ecx
.add_block:
@@:
mov esi, [mem_block_list+eax*4]
mov [mem_block_list+eax*4], edi
mov [edi+list_fd], esi
test esi, esi
jz @f
mov [esi+list_bk], edi
@@:
bts [mem_block_mask], eax
lea edx, [mem_block_list+eax*8]
list_add edi, edx
.m_eq:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
not eax
mov [heap_mutex], eax
dec eax
pop edi
pop esi
pop ebx
ret
.insert:
mov [esi+block_flags], FREE_BLOCK
remove_from_used esi
 
mov eax, [esi+block_size]
calc_index eax
mov edi, esi
jmp .add_block
 
mov edi, [mem_block_list+eax*4]
mov [mem_block_list+eax*4], esi
mov [esi+list_fd], edi
test edi, edi
jz @f
mov [edi+list_bk], esi
@@:
bts [mem_block_mask], eax
mov [esi+block_flags],FREE_BLOCK
xor eax, eax
mov [heap_mutex], eax
dec eax
pop edi
pop esi
pop ebx
ret
.fail:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
ret
endp
 
546,31 → 605,37
 
align 4
proc kernel_free stdcall, base:dword
 
push ebx esi
 
mov ecx, heap_mutex
call mutex_lock
mov ebx, heap_mutex
call wait_mutex ;ebx
 
mov eax, [base]
call md.find_used
mov esi, [mem_used.fd]
@@:
cmp esi, mem_used.fd-MEM_LIST_OFFSET
je .fail
 
mov ecx, heap_mutex
cmp [esi+block_base], eax
je .found
mov esi, [esi+list_fd]
jmp @b
.found:
cmp [esi+block_flags], USED_BLOCK
jne .fail
 
call mutex_unlock
and [heap_mutex], 0
 
mov eax, [esi+block_base]
mov ecx, [esi+block_size]
push ecx
mov ecx, [esi+block_size];
shr ecx, 12
call release_pages ;eax, ecx
pop ecx
stdcall free_kernel_space, [base]
pop esi ebx
ret
.fail:
call mutex_unlock
xor eax, eax
and [heap_mutex], 0
pop esi ebx
ret
endp
1456,7 → 1521,7
test edi, edi
jz .next
 
lea edi, [edi+SMEM.name]
lea eax, [edi+SMEM.name]
stdcall strncmp, [name], edi, 32
test eax, eax
jne .next
1463,7 → 1528,6
 
stdcall user_free, [esi+SMAP.base]
 
mov eax, esi
call [esi+APPOBJ.destroy]
@@:
popfd
/kernel/branches/net/core/memory.inc
171,14 → 171,9
push ebx
push edi
mov eax, [size]
add eax, [base]
add eax, 4095
and eax, -4096
mov ecx, [base]
and ecx, -4096
sub eax, ecx
mov [size], eax
 
stdcall alloc_kernel_space, eax
test eax, eax
jz .fail
194,7 → 189,9
or edx, [flags]
@@:
mov [page_tabs+eax*4], edx
; push eax
invlpg [ebx]
; pop eax
inc eax
add ebx, edi
add edx, edi
217,32 → 214,30
 
align 4
commit_pages:
push edi
test ecx, ecx
jz .fail
 
push edi
push eax
push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
pop eax
mov edi, ebx
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov edi, ebx
shr edi, 12
lea edi, [page_tabs+edi*4]
mov edx, 0x1000
mov ebx, edi
shr ebx, 12
@@:
stosd
invlpg [ebx]
add eax, 0x1000
add ebx, 0x1000
loop @B
 
mov [page_tabs+ebx*4], eax
; push eax
invlpg [edi]
; pop eax
add edi, edx
add eax, edx
inc ebx
dec ecx
jnz @B
mov [pg_data.pg_mutex],ecx
.fail:
pop edi
 
mov ecx, pg_data.mutex
call mutex_unlock
.fail:
ret
 
 
253,22 → 248,16
align 4
release_pages:
 
push ebp
push esi
push edi
push ebx
pushad
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov esi, eax
mov edi, eax
 
shr esi, 12
lea esi, [page_tabs+esi*4]
shr esi, 10
add esi, page_tabs
 
push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
 
mov ebp, [pg_data.pages_free]
mov ebx, [page_start]
mov edx, sys_pgmap
275,7 → 264,9
@@:
xor eax, eax
xchg eax, [esi]
push eax
invlpg [edi]
pop eax
 
test eax, 1
jz .next
294,16 → 285,11
.next:
add edi, 0x1000
add esi, 4
loop @B
 
dec ecx
jnz @B
mov [pg_data.pages_free], ebp
mov ecx, pg_data.mutex
call mutex_unlock
 
pop ebx
pop edi
pop esi
pop ebp
and [pg_data.pg_mutex],0
popad
ret
 
; param
437,8 → 423,8
align 4
proc new_mem_resize stdcall, new_size:dword
 
mov ecx, pg_data.mutex
call mutex_lock
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov edi, [new_size]
add edi, 4095
470,8 → 456,7
pop eax
call free_page
 
.next:
add edi, 1
.next: add edi, 1
cmp edi, esi
jb @B
 
479,10 → 464,8
mov ebx, [new_size]
call update_mem_size
 
mov ecx, pg_data.mutex
call mutex_unlock
 
xor eax, eax
dec [pg_data.pg_mutex]
ret
.expand:
 
556,11 → 539,9
pop edi
pop esi
.exit:
mov ecx, pg_data.mutex
call mutex_unlock
 
xor eax, eax
inc eax
dec [pg_data.pg_mutex]
ret
endp
 
798,8 → 779,7
; and eax, 0xFFFFF000
; stdcall map_page, edi, eax
 
@@:
mov edi, [lin_addr]
@@: mov edi, [lin_addr]
and edi, 0xFFFFF000
mov ecx, [buf_size]
add ecx, 4095
859,8 → 839,7
jz .exit
stdcall map_page, edi, eax, PG_UW
 
@@:
mov edi, [lin_addr]
@@: mov edi, [lin_addr]
and edi, 0xFFFFF000
mov ecx, [buf_size]
add ecx, 4095
991,8 → 970,7
add edx, 4095
and edx, not 4095
 
.touch:
mov eax, [ecx]
.touch: mov eax, [ecx]
add ecx, 0x1000
cmp ecx, edx
jb .touch
/kernel/branches/net/core/exports.inc
16,16 → 16,12
szGetService db 'GetService',0
szServiceHandler db 'ServiceHandler',0
szAttachIntHandler db 'AttachIntHandler',0
; szGetIntHandler db 'GetIntHandler', 0
szGetIntHandler db 'GetIntHandler', 0
szFpuSave db 'FpuSave',0
szFpuRestore db 'FpuRestore',0
szReservePortArea db 'ReservePortArea',0
szBoot_Log db 'Boot_Log',0
 
szMutexInit db 'MutexInit',0
szMutexLock db 'MutexLock',0
szMutexUnlock db 'MutexUnlock',0
 
szPciApi db 'PciApi', 0
szPciRead32 db 'PciRead32', 0
szPciRead16 db 'PciRead16', 0
75,9 → 71,6
szSleep db 'Sleep',0
szGetTimerTicks db 'GetTimerTicks',0
 
szGetDisplay db 'GetDisplay',0
szSetScreen db 'SetScreen',0
 
szStrncat db 'strncat',0
szStrncpy db 'strncpy',0
szstrncmp db 'strncmp',0
85,13 → 78,6
szStrchr db 'strchr',0
szStrrchr db 'strrchr',0
 
szDiskAdd db 'DiskAdd',0
szDiskDel db 'DiskDel',0
szDiskMediaChanged db 'DiskMediaChanged',0
 
szTimerHS db 'TimerHS',0
szCancelTimerHS db 'CancelTimerHS',0
 
szNetRegDev db 'NetRegDev',0
szNetUnRegDev db 'NetUnRegDev',0
szNetPtrToNum db 'NetPtrToNum',0
105,17 → 91,13
dd szGetService , get_service
dd szServiceHandler , srv_handler
dd szAttachIntHandler, attach_int_handler
; dd szGetIntHandler , get_int_handler
dd szGetIntHandler , get_int_handler
dd szFpuSave , fpu_save
dd szFpuRestore , fpu_restore
dd szReservePortArea , r_f_port_area
dd szBoot_Log , boot_log
 
dd szMutexInit , mutex_init ;gcc fastcall
dd szMutexLock , mutex_lock ;gcc fastcall
dd szMutexUnlock , mutex_unlock ;gcc fastcall
 
dd szPciApi , pci_api_drv
dd szPciApi , pci_api
dd szPciRead32 , pci_read32
dd szPciRead16 , pci_read16
dd szPciRead8 , pci_read8
163,9 → 145,6
dd szSleep , delay_ms
dd szGetTimerTicks , get_timer_ticks
 
dd szGetDisplay , get_display
dd szSetScreen , set_screen
 
dd szStrncat , strncat
dd szStrncpy , strncpy
dd szstrncmp , strncmp
173,13 → 152,6
dd szStrchr , strchr
dd szStrrchr , strrchr
 
dd szDiskAdd , disk_add
dd szDiskDel , disk_del
dd szDiskMediaChanged, disk_media_changed
 
dd szTimerHS , timer_hs
dd szCancelTimerHS , cancel_timer_hs
 
dd szNetRegDev , NET_add_device
dd szNetUnRegDev , NET_remove_device
dd szNetPtrToNum , NET_ptr_to_num
/kernel/branches/net/core/sys32.inc
20,8 → 20,7
mov esi, sys_int
mov ecx, 0x40
mov eax, (10001110b shl 24) + os_code
@@:
movsw ;low word of code-entry
@@: movsw ;low word of code-entry
stosd ;interrupt gate type : os_code selector
movsw ;high word of code-entry
loop @b
40,22 → 39,17
times 12 dd unknown_interrupt ;int_20..int_31
 
;interrupt handlers addresses (for interrupt gate construction)
; 0x20 .. 0x2F - IRQ handlers
dd irq0, irq_serv.irq_1, irq_serv.irq_2
if USE_COM_IRQ
dd irq_serv.irq_3, irq_serv.irq_4
dd irq_serv.irq_5, irq_serv.irq_6, irq_serv.irq_7
else
dd p_irq3, p_irq4 ;??? íåñòûêîâêà
end if
dd irq_serv.irq_5, p_irq6, irq_serv.irq_7
dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10
dd irq_serv.irq_11, irq_serv.irq_12, irqD, irq_serv.irq_14, irq_serv.irq_15
dd irq_serv.irq_16
dd irq_serv.irq_17
dd irq_serv.irq_18
dd irq_serv.irq_19
dd irq_serv.irq_20
dd irq_serv.irq_21
dd irq_serv.irq_22
dd irq_serv.irq_23
dd irq_serv.irq_11, irq_serv.irq_12, irqD,p_irq14,p_irq15
times 16 dd unknown_interrupt ;int_0x30..int_0x3F
 
times 32 - IRQ_RESERVED dd unknown_interrupt
;int_0x40 gate trap (for directly copied)
dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16
 
128,9 → 122,8
reg_esi equ esp+0x04
reg_edi equ esp+0x00
 
mov ax, app_data ;èñêëþ÷åíèå
mov ds, ax ;çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ
mov es, ax ;â ðåãèñòðû
Mov ds,ax,app_data ; çàãðóçèì ïðàâèëüíûå çíà÷åíèÿ
mov es,ax ; â ñåãìåíòíûå ðåãèñòðû
cld ; è ïðèâîäèì DF ê ñòàíäàðòó
movzx ebx, bl
; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
139,15 → 132,13
cmp bl, 14 ; #PF
jne @f
call page_fault_handler ; SEE: core/memory.inc
@@:
mov esi, [current_slot]
@@: mov esi, [current_slot]
btr [esi+APPDATA.except_mask], ebx
jnc @f
mov eax, [esi+APPDATA.exc_handler]
test eax, eax
jnz IRetToUserHook
@@:
cli
@@: cli
mov eax, [esi+APPDATA.debugger_slot]
test eax, eax
jnz .debug
168,12 → 159,10
mov dr6, edx
mov edx, dr7
mov cl, not 8
.l1:
shl dl, 2
.l1: shl dl,2
jc @f
and bl, cl
@@:
sar cl, 1
@@: sar cl,1
jc .l1
mov cl, 3 ; debug_message code=debug_exception
.notify:
197,21 → 186,11
stosd
mov [edi], ebx
restore_ring3_context
; simply return control to interrupted process
unknown_interrupt:
iretd
 
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; bl - error vector
show_error_parameters:
cmp bl, 0x06
jnz .no_ud
push ebx
mov ebx, ud_user_message
mov ebp, notifyapp
call fs_execute_from_sysdir_param
pop ebx
.no_ud:
mov edx, [TASK_BASE];not scratched below
DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid]
cmp bl, 0x08
218,10 → 197,8
jb .l0
cmp bl, 0x0e
jbe .l1
.l0:
mov bl, 0x09
.l1:
mov eax, [msg_fault_sel+ebx*4 - 0x08*4]
.l0: mov bl, 0x09
.l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4]
DEBUGF 1, "K : %s\n", eax
mov eax, [reg_cs3+4]
mov edi, msg_sel_app
230,8 → 207,7
je @f
mov edi, msg_sel_ker
mov ebx, [reg_esp0+4]
@@:
DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4]
@@: DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4]
DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4]
DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx
DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi
252,8 → 228,154
restore reg_esi
restore reg_edi
 
; irq1 -> hid/keyboard.inc
macro irqh [num] {
p_irq#num :
mov edi, num
jmp irqhandler
}
 
align 4
 
 
p_irq6:
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 6
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
call fdc_irq
call ready_for_next_irq
restore_ring3_context
iret
 
 
p_irq14:
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 14
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
; mov byte [BOOT_VAR + 0x48E], 0xFF
call [irq14_func]
call ready_for_next_irq_1
restore_ring3_context
iret
p_irq15:
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 15
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
; mov byte [BOOT_VAR + 0x48E], 0xFF
call [irq15_func]
call ready_for_next_irq_1
restore_ring3_context
iret
 
ready_for_next_irq:
mov eax,5
mov [check_idle_semaphore],eax
; mov al, 0x20
add eax,(0x20-0x5)
 
out 0x20, al
ret
;destroy eax
ready_for_next_irq_1:
mov eax,5
mov [check_idle_semaphore],eax
; mov al, 0x20
add eax,(0x20-0x5)
out 0xa0,al
out 0x20, al
ret
 
irqD:
push eax
xor eax,eax
out 0xf0,al
mov al,0x20
out 0xa0,al
out 0x20,al
pop eax
iret
 
 
irqh 2,3,4,5,7,8,9,10,11
 
irqhandler:
 
mov esi,edi ; 1
shl esi,6 ; 1
add esi,irq00read ; 1
shl edi,12 ; 1
add edi,IRQ_SAVE
mov ecx,16
 
irqnewread:
dec ecx
js irqover
 
movzx edx, word [esi] ; 2+
 
test edx, edx ; 1
jz irqover
 
 
mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size
mov eax, 4000 ; + 0x4 dword - data begin offset
cmp ebx, eax
je irqfull
add ebx, [edi + 0x4] ; add data size to data begin offset
cmp ebx, eax ; if end of buffer, begin cycle again
jb @f
 
xor ebx, ebx
 
@@:
add ebx, edi
movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word
dec eax
jz irqbyte
dec eax
jnz noirqword
 
in ax,dx
cmp ebx, 3999 ; check for address odd in the end of buffer
jne .odd
mov [ebx + 0x10], ax
jmp .add_size
.odd:
mov [ebx + 0x10], al ; I could make mistake here :)
mov [edi + 0x10], ah
.add_size:
add dword [edi], 2
jmp nextport
 
 
irqbyte:
in al,dx
mov [ebx + 0x10],al
inc dword [edi]
nextport:
add esi,4
jmp irqnewread
 
 
noirqword:
irqfull:
irqover:
 
ret
 
 
 
set_application_table_status:
push eax
 
268,7 → 390,7
 
ret
 
align 4
 
clear_application_table_status:
push eax
 
294,7 → 416,6
; * eax = 0 - óñïåøíî
; * eax = 1 - íåäîñòàòî÷íî ïàìÿòè
 
align 4
sys_resize_app_memory:
; ebx = 1 - resize
; ecx = new amount of memory
316,7 → 437,6
; param
; esi= slot
 
align 4
terminate: ; terminate application
 
.slot equ esp ;locals
588,6 → 708,25
and [bgrlock], 0
@@:
 
pusha ; remove all irq reservations
mov eax,esi
shl eax, 5
mov eax,[eax+CURRENT_TASK+TASKDATA.pid]
mov edi,irq_owner
xor ebx, ebx
xor edx, edx
newirqfree:
cmp [edi + 4 * ebx], eax
jne nofreeirq
mov [edi + 4 * ebx], edx ; remove irq reservation
mov [irq_tab + 4 * ebx], edx ; remove irq handler
mov [irq_rights + 4 * ebx], edx ; set access rights to full access
nofreeirq:
inc ebx
cmp ebx, 16
jb newirqfree
popa
 
pusha ; remove all port reservations
mov edx, esi
shl edx, 5
673,18 → 812,17
and [application_table_status], 0
;mov esi,process_terminated
;call sys_msg_board_str
 
mov eax, [.slot]
call SOCKET_process_end
 
add esp, 4
ret
restore .slot
 
iglobal
if lang eq ru
boot_sched_1 db '‘®§¤ ­¨¥ GDT TSS 㪠§ â¥«ï',0
boot_sched_2 db '‘®§¤ ­¨¥ IDT â ¡«¨æë',0
else
boot_sched_1 db 'Building gdt tss pointer',0
boot_sched_2 db 'Building IDT table',0
end if
endg
 
 
/kernel/branches/net/core/conf_lib.inc
13,8 → 13,7
$Revision$
 
iglobal
conf_path_sect:
db 'path',0
conf_path_sect: db 'path',0
 
conf_fname db '/sys/sys.conf',0
endg
76,7 → 75,62
udev_midibase db 'midibase',0
udev_midibase_def db '0x320',0
endg
;set up netvork configuration
proc set_network_conf
locals
par db 30 dup(?)
endl
pushad
 
;[net]
;active
lea eax,[par]
invoke ini.get_int,conf_fname, unet, unet_active, 0
or eax,eax
jz .do_not_set_net
mov eax, [stack_config]
and eax, 0xFFFFFF80
add eax, 3
mov [stack_config], eax
call ash_eth_enable
 
;addr
lea eax,[par]
push eax
invoke ini.get_str,conf_fname, unet, unet_addr, eax,30, unet_def
pop eax
stdcall do_inet_adr,eax
mov [stack_ip], eax
 
;mask
lea eax,[par]
push eax
invoke ini.get_str,conf_fname, unet, unet_mask, eax,30, unet_def
pop eax
stdcall do_inet_adr,eax
mov [subnet_mask], eax
 
;gate
lea eax,[par]
push eax
invoke ini.get_str,conf_fname, unet, unet_gate, eax,30, unet_def
pop eax
stdcall do_inet_adr,eax
mov [gateway_ip], eax
.do_not_set_net:
popad
ret
 
 
endp
iglobal
unet db 'net',0
unet_active db 'active',0
unet_addr db 'addr',0
unet_mask db 'mask',0
unet_gate db 'gate',0
unet_def db 0
endg
; convert string to DWord
proc strtoint stdcall,strs
pushad
208,3 → 262,36
popad
ret
endp
 
 
; convert string to DWord for IP addres
proc do_inet_adr stdcall,strs
pushad
 
mov esi,[strs]
mov ebx,0
.next:
push esi
@@:
lodsb
or al,al
jz @f
cmp al,'.'
jz @f
jmp @b
@@:
mov cl, al
mov [esi-1],byte 0
;pop eax
call strtoint_dec
rol eax,24
ror ebx,8
add ebx,eax
or cl,cl
jz @f
jmp .next
@@:
mov [esp+28],ebx
popad
ret
endp
/kernel/branches/net/core/debug.inc
13,8 → 13,7
cmp ebx, 9
ja @f
jmp dword [sys_debug_services_table+ebx*4]
@@:
ret
@@: ret
iglobal
align 4
sys_debug_services_table:
94,8 → 93,7
cmp cl, 5
jnz .ret
mov cl, 2
.2:
mov [CURRENT_TASK+eax+TASKDATA.state], cl
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret:
sti
ret
110,12 → 108,9
cmp cl, 2
jnz .ret
mov cl, 5
.2:
mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret:
ret
.1:
dec ecx
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret: ret
.1: dec ecx
jmp .2
 
debug_resume:
127,8 → 122,7
shl eax, 5
jz .ret
call do_resume
.ret:
sti
.ret: sti
ret
 
debug_getcontext:
329,7 → 323,7
call get_debuggee_slot
jc .err
shr eax, 5
mov ecx, edi
; mov ebx, esi
call read_process_memory
sti
mov dword [esp+32], eax
355,7 → 349,7
call get_debuggee_slot
jc debug_read_process_memory.err
shr eax, 5
mov ecx, edi
; mov ebx, esi
call write_process_memory
sti
mov [esp+32], eax
374,8 → 368,8
.1:
mov eax, ebp
shl eax, 8
mov esi, [SLOT_BASE+eax+APPDATA.dbg_event_mem]
test esi, esi
mov edx, [SLOT_BASE+eax+APPDATA.dbg_event_mem]
test edx, edx
jz .ret
; read buffer header
push ecx
382,15 → 376,15
push eax
push eax
mov eax, ebp
mov ecx, esp
mov edx, 8
mov ebx, esp
mov ecx, 8
call read_process_memory
cmp eax, edx
cmp eax, ecx
jz @f
add esp, 12
jmp .ret
@@:
cmp dword [ecx], 0
cmp dword [ebx], 0
jg @f
.2:
pop ecx
406,26 → 400,26
cli
jmp .1
@@:
mov edx, [ecx+8]
add edx, [ecx+4]
cmp edx, [ecx]
mov ecx, [ebx+8]
add ecx, [ebx+4]
cmp ecx, [ebx]
ja .2
; advance buffer position
push edx
mov edx, 4
sub ecx, edx
push ecx
mov ecx, 4
sub ebx, ecx
mov eax, ebp
add esi, edx
add edx, ecx
call write_process_memory
pop eax
; write message
mov eax, ebp
add esi, edx
add esi, [ecx+8]
add ecx, 20
pop edx
pop edx
pop edx
add edx, ecx
add edx, [ebx+8]
add ebx, 20
pop ecx
pop ecx
pop ecx
call write_process_memory
; new debug event
mov eax, ebp
/kernel/branches/net/core/dll.inc
9,14 → 9,190
 
 
DRV_COMPAT equ 5 ;minimal required drivers version
DRV_CURRENT equ 6 ;current drivers model version
DRV_CURRENT equ 5 ;current drivers model version
 
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
PID_KERNEL equ 1 ;os_idle thread
 
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword
 
push ebx
 
mov ebx, [irq] ;irq num
test ebx, ebx
jz .err
cmp ebx, 15 ; hidnplayr says: we only have 16 IRQ's
ja .err
mov eax, [handler]
test eax, eax
jz .err
cmp [irq_owner + 4 * ebx], 0
je @f
 
mov ecx, [irq_rights + 4 * ebx] ; Rights : 0 - full access, 1 - read only, 2 - forbidden
test ecx, ecx
jnz .err
 
@@:
mov [irq_tab+ebx*4], eax
 
mov eax, [access_rights]
mov [irq_rights + 4 * ebx], eax
 
mov [irq_owner + 4 * ebx], PID_KERNEL ; all handlers belong to a kernel
 
stdcall enable_irq, [irq]
pop ebx
mov eax, 1
ret
.err:
pop ebx
xor eax, eax
ret
endp
 
uglobal
 
irq_rights rd 16
 
endg
 
proc get_int_handler stdcall, irq:dword
 
mov eax, [irq]
 
cmp [irq_rights + 4 * eax], dword 1
ja .err
 
mov eax, [irq_tab + 4 * eax]
ret
 
.err:
xor eax, eax
ret
 
endp
 
align 4
proc detach_int_handler
 
ret
endp
 
align 4
proc enable_irq stdcall, irq_line:dword
mov ebx, [irq_line]
mov edx, 0x21
cmp ebx, 8
jb @F
mov edx, 0xA1
sub ebx,8
@@:
in al,dx
btr eax, ebx
out dx, al
ret
endp
 
align 16
;; proc irq_serv
 
irq_serv:
 
.irq_1:
push 1
jmp .main
align 4
.irq_2:
push 2
jmp .main
align 4
.irq_3:
push 3
jmp .main
align 4
.irq_4:
push 4
jmp .main
align 4
.irq_5:
push 5
jmp .main
; align 4
; .irq_6:
; push 6
; jmp .main
align 4
.irq_7:
push 7
jmp .main
align 4
.irq_8:
push 8
jmp .main
align 4
.irq_9:
push 9
jmp .main
align 4
.irq_10:
push 10
jmp .main
align 4
.irq_11:
push 11
jmp .main
align 4
.irq_12:
push 12
jmp .main
; align 4
; .irq_13:
; push 13
; jmp .main
; align 4
; .irq_14:
; push 14
; jmp .main
; align 4
; .irq_15:
; push 15
; jmp .main
 
align 16
.main:
save_ring3_context
mov eax, [esp + 32]
mov bx, app_data ;os_data
mov ds, bx
mov es, bx
 
cmp [v86_irqhooks+eax*8], 0
jnz v86_irq
 
mov ebx, [irq_tab+eax*4]
test ebx, ebx
jz .exit
 
call ebx
mov [check_idle_semaphore],5
 
.exit:
 
cmp dword [esp + 32], 8
mov al, 0x20
jb @f
out 0xa0, al
@@:
out 0x20, al
 
restore_ring3_context
add esp, 4
 
iret
 
align 4
proc get_notify stdcall, p_ev:dword
 
.wait:
36,7 → 212,7
 
align 4
proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
push ebx
push ebx edx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
44,13 → 220,13
mov bh, byte [devfn]
mov bl, byte [reg]
call pci_read_reg
pop ebx
pop edx ebx
ret
endp
 
align 4
proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
push ebx
push ebx edx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
58,13 → 234,13
mov bh, byte [devfn]
mov bl, byte [reg]
call pci_read_reg
pop ebx
pop edx ebx
ret
endp
 
align 4
proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
push ebx
push ebx edx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
72,13 → 248,13
mov bh, byte [devfn]
mov bl, byte [reg]
call pci_read_reg
pop ebx
pop edx ebx
ret
endp
 
align 4
proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx
push ebx edx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
87,13 → 263,13
mov bl, byte [reg]
mov ecx, [val]
call pci_write_reg
pop ebx
pop edx ebx
ret
endp
 
align 4
proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx
push ebx edx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
102,13 → 278,13
mov bl, byte [reg]
mov ecx, [val]
call pci_write_reg
pop ebx
pop edx ebx
ret
endp
 
align 4
proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx
push ebx edx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
117,7 → 293,7
mov bl, byte [reg]
mov ecx, [val]
call pci_write_reg
pop ebx
pop edx ebx
ret
endp
 
368,8 → 544,10
mov [name], ebx
 
pushad
lea ebx, [cmd]
push eax
lea eax, [cmd]
call file_system_lfn
pop eax
popad
ret
endp
419,8 → 597,6
 
stdcall kernel_alloc, [file_size]
mov [file], eax
test eax, eax
jz .fail
 
stdcall read_file, [file_name], eax, dword 0, [file_size]
cmp ebx, [file_size]
621,7 → 797,6
ret
endp
 
align 4
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
delta:dword
locals
1445,3 → 1620,70
 
call free ;release object memory
ret
 
 
 
if 0
 
irq:
 
.irq0:
pusfd
pushad
push IRQ_0
jmp .master
.irq_1:
pusfd
pushad
push IRQ_1
jmp .master
 
.master:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
cmp [irq_actids+ecx*4], 0
je @F
in al, 0x21
bts eax, ecx
out 0x21, al
mov al, 0x20
out 0x20, al
jmp .restart
 
.slave:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
sub ecx, 8
cmp [irq_actids+ecx*4], 0
je @F
in al, 0xA1
bts eax, ecx
out 0xA1, al
mov al, 0x20
out 0xA0, al
out 0x20, al
.restart:
mov ebx, [next_slot]
test ebx, ebx
jz @F
mov [next_task],0
mov esi, [prev_slot]
call do_change_task
add esp, 4
iretd
 
end if
 
 
 
 
/kernel/branches/net/core/export.inc
28,8 → 28,7
local name
dd (name-OS_BASE)
common
ordinal:
count = 0
ordinal: count = 0
forward
dw count
count = count+1
/kernel/branches/net/core/ext_lib.inc
158,8 → 158,7
 
proc dll.Load, import_table:dword
mov esi, [import_table]
.next_lib:
mov edx, [esi]
.next_lib: mov edx,[esi]
or edx, edx
jz .exit
push esi
169,8 → 168,7
mov al, '/'
stosb
mov esi, sysdir_path
@@:
lodsb
@@: lodsb
stosb
or al, al
jnz @b
181,8 → 179,7
pop esi
push esi
mov esi, [esi+4]
@@:
lodsb
@@: lodsb
stosb
or al, al
jnz @b
198,11 → 195,9
pop esi
add esi, 8
jmp .next_lib
.exit:
xor eax, eax
.exit: xor eax,eax
ret
.fail:
add esp, 4
.fail: add esp,4
xor eax, eax
inc eax
ret
213,8 → 208,7
mov esi, [imp]
test esi, esi
jz .done
.next:
lodsd
.next: lodsd
test eax, eax
jz .done
stdcall dll.GetProcAddress, [exp], eax
222,10 → 216,8
jz @f
mov [esi-4], eax
jmp .next
@@:
mov dword[esp], 0
.done:
pop eax
@@: mov dword[esp],0
.done: pop eax
ret
endp
 
242,8 → 234,7
 
proc dll.GetProcAddress, exp:dword,sz_name:dword
mov edx, [exp]
.next:
test edx, edx
.next: test edx,edx
jz .end
stdcall strncmp, [edx], [sz_name], dword -1
test eax, eax
250,10 → 241,8
jz .ok
add edx, 8
jmp .next
.ok:
mov eax, [edx+4]
.end:
ret
.ok: mov eax,[edx+4]
.end: ret
endp
 
;-----------------------------------------------------------------------------
287,8 → 276,7
add ecx, -4
cmp ecx, [eax-4]
je .exit
@@:
mov eax, ebx
@@: mov eax,ebx
call mem.Alloc
xchg eax, [esp]
or eax, eax
300,8 → 288,7
cmp ecx, [edi-4]
jbe @f
mov ecx, [edi-4]
@@:
add ecx, 3
@@: add ecx,3
shr ecx, 2
cld
rep movsd
/kernel/branches/net/core/malloc.inc
20,7 → 20,7
; esi= nb
; ebx= idx
;
align 4
align 16
malloc:
push esi
 
31,8 → 31,8
and esi, -8
add esi, 8
 
mov ecx, mst.mutex
call mutex_lock
mov ebx, mst.mutex
call wait_mutex ;ebx
 
cmp esi, 256
jae .large
92,13 → 92,9
pop edi
pop ebp
.done:
mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
pop esi
mov [mst.mutex], 0
ret
 
.split:
lea ebx, [edx+8] ;ebx=mem
 
137,10 → 133,10
mov [edx+12], eax ; F->bk = r;
mov [eax+8], edx ; r->fd = F;
mov [eax+12], ecx ; r->bk = B;
 
mov eax, ebx
jmp .done
 
pop esi
mov [mst.mutex], 0
ret
.small:
 
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
154,8 → 150,9
call malloc_small
test eax, eax
jz .from_top
jmp .done
 
pop esi
and [mst.mutex], 0
ret
.large:
 
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
192,19 → 189,19
mov [edx+4], eax
mov [ecx+4], esi
lea eax, [ecx+8]
jmp .done
 
pop esi
and [mst.mutex], 0
ret
.fail:
xor eax, eax
jmp .done
pop esi
and [mst.mutex], 0
ret
 
; param
; eax= mem
align 4
 
free:
test eax, eax
jz .exit
 
push edi
mov edi, eax
add edi, -8
214,8 → 211,8
test byte [edi+4], 2
je .fail
 
mov ecx, mst.mutex
call mutex_lock
mov ebx, mst.mutex
call wait_mutex ;ebx
 
; psize = p->head & (~3);
 
292,16 → 289,11
mov [mst.top], edi
mov [edi+4], eax
.fail2:
mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
and [mst.mutex], 0
pop esi
.fail:
pop edi
.exit:
ret
 
@@:
 
; nsize = next->head & ~INUSE_BITS;
418,15 → 410,13
mov [esi+8], edx ;P->fd = F
mov [esi+12], eax ;P->bk = B
pop esi
mov ecx, mst.mutex
call mutex_unlock
and [mst.mutex], 0
ret
.large:
mov ebx, eax
call insert_large_chunk
pop esi
mov ecx, mst.mutex
call mutex_unlock
and [mst.mutex], 0
ret
 
 
1035,8 → 1025,5
cmp eax, mst.smallbins+512
jb @B
 
mov ecx, mst.mutex
call mutex_init
 
ret
 
/kernel/branches/net/core/peload.inc
283,18 → 283,10
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', \
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall
free_page, 'FreePage', \ ; eax
kernel_alloc, 'KernelAlloc', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall
malloc, 'Kmalloc', \
302,14 → 294,9
map_io_mem, 'MapIoMem', \ ; stdcall
get_pg_addr, 'GetPgAddr', \ ; eax
\
mutex_init, 'MutexInit', \ ; gcc fastcall
mutex_lock, 'MutexLock', \ ; gcc fastcall
mutex_unlock, 'MutexUnlock', \ ; gcc fastcall
\
get_display, 'GetDisplay', \
set_screen, 'SetScreen', \
window._.get_rect, 'GetWindowRect', \ ; gcc fastcall
pci_api_drv, 'PciApi', \
pci_api, 'PciApi', \
pci_read8, 'PciRead8', \ ; stdcall
pci_read16, 'PciRead16', \ ; stdcall
pci_read32, 'PciRead32', \ ; stdcall
317,7 → 304,6
pci_write16, 'PciWrite16', \ ; stdcall
pci_write32, 'PciWrite32', \ ; stdcall
\
get_pid, 'GetPid', \
get_service, 'GetService', \ ;
reg_service, 'RegService', \ ; stdcall
attach_int_handler, 'AttachIntHandler', \ ; stdcall
325,12 → 311,8
user_free, 'UserFree', \ ; stdcall
unmap_pages, 'UnmapPages', \ ; eax, ecx
sys_msg_board_str, 'SysMsgBoardStr', \
get_timer_ticks, 'GetTimerTicks', \
get_stack_base, 'GetStackBase', \
delay_hs, 'Delay', \ ; ebx
set_mouse_data, 'SetMouseData', \ ;
set_keyboard_data, 'SetKeyboardData', \ ; gcc fastcall
timer_hs, 'TimerHs' ; stdcall
set_mouse_data, 'SetMouseData'
 
 
 
/kernel/branches/net/core/sched.inc
27,8 → 27,8
add [next_usage_update], 100
call updatecputimes
.nocounter:
xor ecx, ecx ; send End Of Interrupt signal
call irq_eoi
mov al,0x20 ; send End Of Interrupt signal
out 0x20,al
btr dword[DONT_SWITCH], 0
jc .return
call find_next_task
60,8 → 60,7
end if
call find_next_task
jz .return ; the same task -> skip switch
@@:
mov byte[DONT_SWITCH], 1
@@: mov byte[DONT_SWITCH], 1
call do_change_task
.return:
popad
122,8 → 121,7
jb @f
xor bh, bh
mov edi, CURRENT_TASK
@@:
inc bh ; ebx += APPDATA.size
@@: inc bh ; ebx += APPDATA.size
add edi, 0x20; edi += TASKDATA.size
mov al, [edi+TASKDATA.state]
test al, al
142,8 → 140,7
sub ecx, [ebx+APPDATA.wait_begin]
cmp ecx, [ebx+APPDATA.wait_timeout]
jb .loop
@@:
mov [ebx+APPDATA.wait_param], eax ; retval for wait
@@: mov [ebx+APPDATA.wait_param], eax ; retval for wait
mov [edi+TASKDATA.state], 0
.found:
mov [CURRENT_TASK], bh
217,96 → 214,10
mov reg, eax
} lodsReg dr0, dr1, dr2, dr3, dr7
purge lodsReg
@@:
ret
@@: ret
;end.
 
 
 
struct MUTEX_WAITER
list LHEAD
task dd ?
ends
 
;void __fastcall mutex_init(struct mutex *lock)
 
align 4
mutex_init:
mov [ecx+MUTEX.lhead.next], ecx
mov [ecx+MUTEX.lhead.prev], ecx
mov [ecx+MUTEX.count], 1
ret
 
 
;void __fastcall mutex_lock(struct mutex *lock)
 
align 4
mutex_lock:
 
dec [ecx+MUTEX.count]
jns .done
 
pushfd
cli
 
sub esp, sizeof.MUTEX_WAITER
 
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
 
mov edx, [TASK_BASE]
mov [esp+MUTEX_WAITER.task], edx
 
.forever:
 
mov eax, -1
xchg eax, [ecx+MUTEX.count]
dec eax
jz @F
 
mov [edx+TASKDATA.state], 1
call change_task
jmp .forever
@@:
mov edx, [esp+MUTEX_WAITER.list.next]
mov eax, [esp+MUTEX_WAITER.list.prev]
 
mov [eax+MUTEX_WAITER.list.next], edx
mov [edx+MUTEX_WAITER.list.prev], eax
cmp [ecx+MUTEX.lhead.next], ecx
jne @F
 
mov [ecx+MUTEX.count], 0
@@:
add esp, sizeof.MUTEX_WAITER
 
popfd
.done:
ret
 
;void __fastcall mutex_unlock(struct mutex *lock)
 
align 4
mutex_unlock:
 
pushfd
cli
 
mov eax, [ecx+MUTEX.lhead.next]
cmp eax, ecx
mov [ecx+MUTEX.count], 1
je @F
 
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], 0
@@:
popfd
ret
 
 
purge MUTEX_WAITER
 
if 0
 
struc TIMER
{
.next dd ?
/kernel/branches/net/core/taskman.inc
48,7 → 48,6
 
fs_execute_from_sysdir:
xor ebx, ebx
fs_execute_from_sysdir_param:
xor edx, edx
mov esi, sysdir_path
 
127,7 → 126,7
@@:
lea eax, [filename]
stdcall load_file, eax
mov esi, -ERROR_FILE_NOT_FOUND
mov ecx, -ERROR_FILE_NOT_FOUND
test eax, eax
jz .err_file
 
136,10 → 135,13
 
lea ebx, [hdr_cmdline]
call test_app_header
mov esi, -0x1F
mov ecx, -0x1F
test eax, eax
jz .err_hdr
 
;mov esi, new_process_loading
;call sys_msg_board_str ; write message to message board
 
.wait_lock:
cmp [application_table_status], 0
je .get_lock
156,7 → 158,7
 
call get_new_process_place
test eax, eax
mov esi, -0x20 ; too many processes
mov ecx, -0x20 ; too many processes
jz .err
 
mov [slot], eax
191,7 → 193,7
mov [save_cr3], ebx
 
stdcall create_app_space, [hdr_mem], [file_base], [file_size]
mov esi, -30; no memory
mov ecx, -30 ; no memory
test eax, eax
jz .failed
 
247,7 → 249,7
.err_file:
xor eax, eax
mov [application_table_status], eax
mov eax, esi
mov eax, ecx
ret
endp
 
357,8 → 359,8
app_tabs dd ?
endl
 
mov ecx, pg_data.mutex
call mutex_lock
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
xor eax, eax
mov [dir_addr], eax
477,13 → 479,11
.done:
stdcall map_page, [tmp_task_pdir], dword 0, dword PG_UNMAP
 
mov ecx, pg_data.mutex
call mutex_unlock
dec [pg_data.pg_mutex]
mov eax, [dir_addr]
ret
.fail:
mov ecx, pg_data.mutex
call mutex_unlock
dec [pg_data.pg_mutex]
cmp [dir_addr], 0
je @f
stdcall destroy_app_space, [dir_addr], 0
553,10 → 553,10
jg .ret
;if there isn't threads then clear memory.
mov esi, [dlls_list]
call destroy_all_hdlls;ecx=APPDATA
call destroy_all_hdlls
 
mov ecx, pg_data.mutex
call mutex_lock
mov ebx, pg_data.pg_mutex
call wait_mutex ;ebx
 
mov eax, [pg_dir]
and eax, not 0xFFF
582,8 → 582,7
.exit:
stdcall map_page, [tmp_task_ptab], 0, PG_UNMAP
stdcall map_page, [tmp_task_pdir], 0, PG_UNMAP
mov ecx, pg_data.mutex
call mutex_unlock
dec [pg_data.pg_mutex]
.ret:
ret
endp
956,7 → 955,25
ret
endp
 
; param
; ebx=mutex
 
align 4
wait_mutex:
;;Maxis use atomic bts for mutex 4.4.2009
push eax
push ebx
.do_wait:
bts dword [ebx],0
jnc .locked
call change_task
jmp .do_wait
.locked:
pop ebx
pop eax
ret
 
align 4
tls_app_entry:
 
call init_heap
1149,13 → 1166,4
ret
endp
 
 
align 4
 
get_stack_base:
mov eax, [current_slot]
mov eax, [eax+APPDATA.pl0_stack]
ret
 
 
include "debug.inc"
/kernel/branches/net/core/v86.inc
91,10 → 91,10
; now V86 specific: initialize known addresses in first Mb
pop eax
; first page - BIOS data (shared between all machines!)
; physical address = 0
; linear address = OS_BASE
mov dword [eax], 111b
mov dword [eax+800h], OS_BASE
; physical address = 0x2f0000
; linear address = BOOT_VAR = OS_BASE + 0x2f0000
mov dword [eax], (BOOT_VAR - OS_BASE) or 111b
mov dword [eax+800h], BOOT_VAR
; page before 0xA0000 - Extended BIOS Data Area (shared between all machines!)
; physical address = 0x9C000
; linear address = 0x8009C000
219,12 → 219,12
mov [sys_v86_machine], eax
test eax, eax
jz .ret
mov byte [OS_BASE + 0x500], 0xCD
mov byte [OS_BASE + 0x501], 0x13
mov byte [OS_BASE + 0x502], 0xF4
mov byte [OS_BASE + 0x503], 0xCD
mov byte [OS_BASE + 0x504], 0x10
mov byte [OS_BASE + 0x505], 0xF4
mov byte [BOOT_VAR + 0x500], 0xCD
mov byte [BOOT_VAR + 0x501], 0x13
mov byte [BOOT_VAR + 0x502], 0xF4
mov byte [BOOT_VAR + 0x503], 0xCD
mov byte [BOOT_VAR + 0x504], 0x10
mov byte [BOOT_VAR + 0x505], 0xF4
mov esi, eax
mov ebx, [eax+V86_machine.pagedir]
; one page for stack, two pages for results (0x2000 bytes = 16 sectors)
328,7 → 328,7
cmp edx, -1
jz .noirqhook
uglobal
v86_irqhooks rd IRQ_RESERVED * 2
v86_irqhooks rd 16*2
endg
cmp [v86_irqhooks+edx*8], 0
jz @f
371,8 → 371,7
jne @f
xor eax, eax
mov dr6, eax
@@:
mov eax, [esp+v86_regs.size+10h+18h]
@@: mov eax, [esp+v86_regs.size+10h+18h]
cmp word [esp+v86_regs.eip], ax
jnz @f
shr eax, 16
806,6 → 805,7
mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx
mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx
mov cr3, eax
; mov [irq_tab+5*4], 0
sti
 
popad
839,10 → 839,9
; mov byte [BOOT_VAR + 48Eh], 0FFh
; ret
 
align 4
v86_irq:
; push irq/pushad/jmp v86_irq
; ebp = irq
; eax = irq
lea esi, [esp+1Ch]
lea edi, [esi+4]
mov ecx, 8
849,7 → 848,7
std
rep movsd
cld
mov edi, ebp
mov edi, eax
pop eax
v86_irq2:
mov esi, [v86_irqhooks+edi*8] ; get VM handle
899,8 → 898,12
pop ecx
.cont:
loop .scan
mov ecx, edi
call irq_eoi
mov al, 20h
out 20h, al
cmp edi, 8
jb @f
out 0A0h, al
@@:
popad
iretd
.found:
/kernel/branches/net/gui/mousepointer.inc
File deleted
/kernel/branches/net/gui/skincode.inc
68,10 → 68,10
 
struct SKIN_BUTTONS
type dd ?
; position
; pos:
left dw ?
top dw ?
; size
; size:
width dw ?
height dw ?
ends
127,8 → 127,7
 
mov ebx, [ebp+SKIN_HEADER.bitmaps]
add ebx, skin_data
.lp1:
cmp dword[ebx], 0
.lp1: cmp dword[ebx],0
je .end_bitmaps
movzx eax, [ebx+SKIN_BITMAPS.kind]
movzx ecx, [ebx+SKIN_BITMAPS.type]
139,8 → 138,7
or ecx, ecx
jnz @f
mov edx, skin_inactive.left.data
@@:
jmp .next_bitmap
@@: jmp .next_bitmap
.not_left:
dec eax
jnz .not_oper
152,8 → 150,7
or ecx, ecx
jnz @f
mov edx, skin_inactive.oper.data
@@:
jmp .next_bitmap
@@: jmp .next_bitmap
.not_oper:
dec eax
jnz .not_base
163,8 → 160,7
jnz @f
mov eax, [skin_inactive.left.width]
mov edx, skin_inactive.base.data
@@:
jmp .next_bitmap
@@: jmp .next_bitmap
.not_base:
add ebx, 8
jmp .lp1
182,8 → 178,7
 
mov ebx, [ebp+SKIN_HEADER.buttons]
add ebx, skin_data
.lp2:
cmp dword[ebx], 0
.lp2: cmp dword[ebx],0
je .end_buttons
mov eax, [ebx+SKIN_BUTTONS.type]
dec eax
218,8 → 213,7
or ebx, ebx
jz @f
call sys_putimage.forced
@@:
ret
@@: ret
 
drawwindow_IV_caption:
 
/kernel/branches/net/gui/button.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
8,12 → 8,14
 
$Revision$
 
 
button._.MAX_BUTTONS = 4095
 
 
;==============================================================================
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
 
button.MAX_BUTTONS = 4095
 
struc SYS_BUTTON
{
.pslot dw ?
23,7 → 25,6
.top dw ?
.height dw ?
.id_hi dw ?
dw ?
.sizeof:
}
virtual at 0
30,6 → 31,13
SYS_BUTTON SYS_BUTTON
end virtual
 
iglobal
mx dw 0x0 ; keeps the x mouse's position when it was clicked
my dw 0x0 ; keeps the y mouse's position when it was clicked
bPressedMouseXY_B db 0x0
btn_down_determ db 0x0
endg
 
align 4
;------------------------------------------------------------------------------
syscall_button: ;///// system function 8 //////////////////////////////////////
58,7 → 66,7
; do we have free button slots available?
mov edi, [BTN_ADDR]
mov eax, [edi]
cmp eax, button.MAX_BUTTONS
cmp eax, button._.MAX_BUTTONS
jge .exit
 
; does it have positive size? (otherwise it doesn't have sense)
131,8 → 139,7
call button._.incecx2
 
; set button height counter
@@:
mov edx, edi
@@: mov edx, edi
 
.next_line:
call button._.button_dececx
220,7 → 227,6
add esi, edi
xor ecx, ecx
add ecx, -SYS_BUTTON.sizeof
add esi, SYS_BUTTON.sizeof
 
.next_button:
dec ebx
256,123 → 262,201
 
align 4
;------------------------------------------------------------------------------
sys_button_activate_handler: ;/////////////////////////////////////////////////
check_buttons: ;///////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
;> cl = mouse button mask this system button was pressed with
;------------------------------------------------------------------------------
call button._.find_button
or eax, eax
jz .exit
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed
jnz @f
mov [bPressedMouseXY_B], 0
ret
 
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
call button._.negative_button
@@: pushad
xor esi, esi
mov edi, [BTN_ADDR]
mov edx, [edi]
test edx, edx
jne @f
popad
ret
 
.exit:
;here i catch the coordinates when the mouse's button is clicked
@@: push ax
cmp [bPressedMouseXY_B], 0 ; FALSE
jnz @f
mov [bPressedMouseXY_B], 1 ; TRUE - it was already clicked
mov ax, [MOUSE_X]
mov [mx], ax
mov ax, [MOUSE_Y]
mov [my], ax
@@: pop ax
;and it is only refreshed after the mouse's button release
 
push esi
inc edx
push edx
 
.buttonnewcheck:
pop edx
pop esi
inc esi
cmp edx, esi
jge .bch
 
popad
ret
 
align 4
;------------------------------------------------------------------------------
sys_button_deactivate_handler: ;///////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
;> cl = mouse button mask this system button was pressed with
;------------------------------------------------------------------------------
call button._.find_button
or eax, eax
jz .exit
.bch:
push esi
push edx
mov eax, esi
shl eax, 4
add eax, edi
 
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
; check that button is at top of windowing stack
movzx ebx, [eax + SYS_BUTTON.pslot]
movzx ecx, word[WIN_STACK + ebx * 2]
cmp ecx, [TASK_COUNT]
jne .buttonnewcheck
 
; check that button start is inside window x/y end
shl ebx, 5
 
test [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .buttonnewcheck
 
movzx edx, [eax + SYS_BUTTON.left]
cmp edx, [window_data + ebx + WDATA.box.width] ;ecx
jge .buttonnewcheck
 
movzx edx, [eax + SYS_BUTTON.top]
cmp edx, [window_data + ebx + WDATA.box.height] ;ecx
jge .buttonnewcheck
 
; check coordinates
 
; mouse x >= button x ?
add ebx, window_data
mov ecx, [ebx + WDATA.box.left]
movzx edx, [eax + SYS_BUTTON.left]
add edx, ecx
mov cx, [mx] ;mov cx,[MOUSE_X]
cmp edx, ecx
jg .buttonnewcheck
 
movzx ebx, [eax + SYS_BUTTON.width]
add edx, ebx
cmp ecx, edx
jg .buttonnewcheck
 
; mouse y >= button y ?
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx, 5
add ebx, window_data
mov ecx, [ebx + WDATA.box.top]
movzx edx, [eax + SYS_BUTTON.top]
add edx, ecx
mov cx, [my] ;mov cx,[MOUSE_Y]
cmp edx, ecx
jg .buttonnewcheck
 
movzx ebx, [eax + SYS_BUTTON.height]
add edx, ebx
cmp ecx, edx
jg .buttonnewcheck
 
; mouse on button
 
pop edx
pop esi
 
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] ; button id : bits 16-31
mov bx, [eax + SYS_BUTTON.id_lo] ; button id : bits 00-16
push ebx
 
mov byte[MOUSE_DOWN], 1 ; no mouse down checks
call button._.negative_button
 
.exit:
ret
pushad
push eax
mov al, [BTN_DOWN]
mov byte[btn_down_determ], al
pop eax
 
align 4
;------------------------------------------------------------------------------
sys_button_perform_handler: ;//////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
;> cl = mouse button mask this system button was pressed with
;------------------------------------------------------------------------------
shl eax, 8
mov al, cl
movzx ebx, byte[BTN_COUNT]
mov [BTN_BUFF + ebx * 4], eax
inc bl
mov [BTN_COUNT], bl
ret
.cbwaitmouseup:
call checkidle
call [draw_pointer]
 
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
pushad
call stack_handler
popad
 
;------------------------------------------------------------------------------
button._.find_button: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Find system button by specified process slot, id and coordinates
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)] or 0
;> ebx = pack[16(button x coord), 16(button y coord)]
;------------------------------------------------------------------------------
;< eax = pointer to SYS_BUTTON struct or 0
;------------------------------------------------------------------------------
push ecx edx esi edi
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ?
jnz .cbwaitmouseup
popad
 
mov edx, eax
shr edx, 24
and eax, 0x0ffffff
call button._.negative_button
mov byte[MOUSE_BACKGROUND], 0 ; no mouse background
mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse
 
mov edi, [BTN_ADDR]
mov ecx, [edi]
imul esi, ecx, SYS_BUTTON.sizeof
add esi, edi
inc ecx
add esi, SYS_BUTTON.sizeof
; check coordinates
pusha
 
.next_button:
dec ecx
jz .not_found
; mouse x >= button x ?
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx, 5
add ebx, window_data
mov ecx, [ebx + WDATA.box.left]
movzx edx, [eax + SYS_BUTTON.left]
add edx, ecx
mov cx, [MOUSE_X]
cmp edx, ecx
jg .no_on_button ;if we release the pointer out of the button area
 
add esi, -SYS_BUTTON.sizeof
movzx ebx, [eax + SYS_BUTTON.width]
add edx, ebx
cmp ecx, edx
jg .no_on_button
 
; does it belong to our process?
cmp dx, [esi + SYS_BUTTON.pslot]
jne .next_button
; mouse y >= button y ?
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx, 5
add ebx, window_data
mov ecx, [ebx + WDATA.box.top]
movzx edx, [eax + SYS_BUTTON.top]
add edx, ecx
mov cx, [MOUSE_Y]
cmp edx, ecx
jg .no_on_button
 
; does id match?
mov edi, dword[esi + SYS_BUTTON.id_hi - 2]
mov di, [esi + SYS_BUTTON.id_lo]
and edi, 0x0ffffff
cmp eax, edi
jne .next_button
movzx ebx, [eax + SYS_BUTTON.height]
add edx, ebx
cmp ecx, edx
jg .no_on_button
 
; does coordinates match?
mov edi, dword[esi + SYS_BUTTON.left - 2]
mov di, [esi + SYS_BUTTON.top]
cmp ebx, edi
jne .next_button
popa
 
; okay, return it
mov eax, esi
jmp .exit
mov byte[BTN_COUNT], 1 ; no of buttons in buffer
pop ebx
mov [BTN_BUFF], ebx ; lets put the button id in buffer
push ebx
pusha
jmp .yes_on_button
 
.not_found:
xor eax, eax
.no_on_button:
mov byte[BTN_COUNT], 0 ; no of buttons in buffer
 
.exit:
pop edi esi edx ecx
.yes_on_button:
mov byte[MOUSE_DOWN], 0 ; mouse down -> do not draw
popa
pop ebx
popa
ret
 
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
 
;------------------------------------------------------------------------------
button._.dececx: ;/////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
381,17 → 465,14
sub cl, 0x20
jnc @f
xor cl, cl
@@:
sub ch, 0x20
@@: sub ch, 0x20
jnc @f
xor ch, ch
@@:
rol ecx, 16
@@: rol ecx, 16
sub cl, 0x20
jnc @f
xor cl, cl
@@:
rol ecx, 16
@@: rol ecx, 16
ret
 
;------------------------------------------------------------------------------
402,17 → 483,14
add cl, 0x20
jnc @f
or cl, -1
@@:
add ch, 0x20
@@: add ch, 0x20
jnc @f
or ch, -1
@@:
rol ecx, 16
@@: rol ecx, 16
add cl, 0x20
jnc @f
or cl, -1
@@:
rol ecx, 16
@@: rol ecx, 16
ret
 
;------------------------------------------------------------------------------
423,17 → 501,14
add cl, 0x14
jnc @f
or cl, -1
@@:
add ch, 0x14
@@: add ch, 0x14
jnc @f
or ch, -1
@@:
rol ecx, 16
@@: rol ecx, 16
add cl, 0x14
jnc @f
or cl, -1
@@:
rol ecx, 16
@@: rol ecx, 16
ret
 
;------------------------------------------------------------------------------
450,21 → 525,17
jg @f
mov al, 2
 
@@:
sub cl, al
@@: sub cl, al
jnc @f
xor cl, cl
@@:
sub ch, al
@@: sub ch, al
jnc @f
xor ch, ch
@@:
rol ecx, 16
@@: rol ecx, 16
sub cl, al
jnc @f
xor cl, cl
@@:
rol ecx, 16
@@: rol ecx, 16
 
pop eax
 
474,7 → 545,7
;------------------------------------------------------------------------------
button._.negative_button: ;////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Invert system button border
;? <description>
;------------------------------------------------------------------------------
; if requested, do not display button border on press.
test ebx, 0x20000000
/kernel/branches/net/gui/event.inc
7,13 → 7,6
 
$Revision$
 
WINDOW_MOVE_AND_RESIZE_FLAGS = \
mouse.WINDOW_RESIZE_N_FLAG + \
mouse.WINDOW_RESIZE_W_FLAG + \
mouse.WINDOW_RESIZE_S_FLAG + \
mouse.WINDOW_RESIZE_E_FLAG + \
mouse.WINDOW_MOVE_FLAG
 
uglobal
align 4
event_start dd ?
32,8 → 25,7
mov ecx, EV_SPACE ; current - in allocated space
mov ebx, FreeEvents ; previos - íà÷àëî ñïèñêà
push ebx ; îíî æå è êîíåö ïîòîì áóäåò
@@:
mov [ebx+EVENT.fd], eax
@@: mov [ebx+EVENT.fd],eax
mov [eax+EVENT.bk], ebx
mov ebx, eax ; previos <- current
add eax, EVENT.size ; new current
41,8 → 33,7
pop eax ; âîò îíî êîíöîì è ñòàëî
mov [ebx+EVENT.fd], eax
mov [eax+EVENT.bk], ebx
.fail:
ret
.fail: ret
 
EVENT_WATCHED equ 0x10000000 ;áèò 28
EVENT_SIGNALED equ 0x20000000 ;áèò 29
89,8 → 80,7
call init_events
popad
jz RemoveEventTo.break ; POPF+RET
@@:
mov eax, [eax+EVENT.fd]
@@: mov eax,[eax+EVENT.fd]
mov [eax+EVENT.magic], 'EVNT'
mov [eax+EVENT.destroy], destroy_event.internal
mov [eax+EVENT.state], ecx
118,8 → 108,7
xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight
mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight
mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft
.break:
popfd
.break: popfd
ret
 
align 4
217,11 → 206,9
jne @f
cmp [eax+EVENT.id], ebx
je .ret
@@:
pop eax
@@: pop eax
xor eax, eax
.ret:
ret
.ret: ret
 
 
align 4
260,8 → 247,7
mov [eax+TASKDATA.state], 5
call change_task
mov eax, [esi+APPDATA.wait_param]
@@:
ret
@@: ret
 
align 4
wait_event: ;; EXPORT use
353,8 → 339,7
mov eax, [ebx+APPOBJ.bk] ; âûáèðàåì ñ êîíöà, ïî ïðèíöèïó FIFO
cmp eax, ebx ; empty ???
je get_event_alone.ret0
.ret:
ret
.ret: ret
 
align 4
get_event_alone:
372,10 → 357,8
test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24
jnz .ret
or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24
.ret0:
xor eax, eax; NO event!!!
.ret:
ret
.ret0: xor eax,eax ; NO event!!!
.ret: ret
 
align 4
sys_sendwindowmsg: ;; f72
385,13 → 368,11
cli
sub ecx, 2
je .sendkey
dec ecx
jnz .retf
loop .retf
.sendbtn:
cmp byte[BTN_COUNT], 1
jae .result ;overflow
inc byte[BTN_COUNT]
shl edx, 8
mov [BTN_BUFF], edx
jmp .result
.sendkey:
403,8 → 384,7
.result:
setae byte[esp+32] ;ñ÷èòàåì, ÷òî èñõîäíî: dword[esp+32]==72
.retf: ;popfd
.ret:
ret
.ret: ret
 
align 4
sys_getevent: ;; f11
446,8 → 426,10
jz .no_events ; èñ÷åðïàëè âñå áèòû ìàñêè, íî íè÷åãî íå íàøëè ???
btr ecx, eax ; ñáðàñûâàåì ïðîâåðÿåìûé áèò ìàñêè
; ïåðåõîäèì íà îáðàáîò÷èê ýòîãî (eax) áèòà
cmp eax,16
jae .IRQ ; eax=[16..31]=retvals, events irq0..irq15
cmp eax, 9
jae .loop ; eax=[9..31], ignored
jae .loop ; eax=[9..15], ignored
cmp eax, 3
je .loop ; eax=3, ignored
ja .FlagAutoReset ; eax=[4..8], retvals=eax+1
460,18 → 442,17
.no_events:
xor eax, eax
ret
 
.IRQ:
;TODO: ñäåëàòü òàê æå, êàê è äëÿ FlagAutoReset (BgrRedraw,Mouse,IPC,Stack,Debug)
mov edx,[irq_owner+eax*4-64] ; eax==16+irq
cmp edx,[edi+TASKDATA.pid]
jne .loop
mov edx,eax
shl edx,12
cmp dword[IRQ_SAVE+edx-0x10000],0 ; edx==(16+irq)*0x1000
je .loop ; empty ???
ret ; retval = eax
.FlagAutoReset: ; retvals: BgrRedraw=5, Mouse=6, IPC=7, Stack=8, Debug=9
cmp eax, 5; Mouse 5+1=6
jne @f
push eax
; If the window is captured and moved by the user, then no mouse events!!!
mov al, [mouse.active_sys_window.action]
and al, WINDOW_MOVE_AND_RESIZE_FLAGS
test al, al
pop eax
jnz .loop
@@:
btr [ebx+APPDATA.event_mask], eax
jnc .loop
.result: ; retval = eax+1
486,9 → 467,7
je .loop ; empty ???
cmp edx, [TASK_COUNT]
jne .loop ; not Top ???
mov edx, [BTN_BUFF]
shr edx, 8
cmp edx, 0xFFFF ;-ID for Minimize-Button of Form
cmp dword[BTN_BUFF],0xFFFF ;-ID for Minimize-Button of Form
jne .result
mov [window_minimize], 1
dec byte[BTN_COUNT]
498,10 → 477,8
jne @f ; not Top ???
cmp [KEY_COUNT], al; al==1
jae .result ; not empty ???
@@:
mov edx, hotkey_buffer
@@:
cmp [edx], bh ; bh - slot for testing
@@: mov edx, hotkey_buffer
@@: cmp [edx],bh ; bh - slot for testing
je .result
add edx, 8
cmp edx, hotkey_buffer+120*8
/kernel/branches/net/gui/mouse.inc
1,715 → 1,250
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2010. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
$Revision$
 
include 'mousepointer.inc'
 
;==============================================================================
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
iglobal
 
mouse.LEFT_BUTTON_FLAG = 0001b
mouse.RIGHT_BUTTON_FLAG = 0010b
mouse.MIDDLE_BUTTON_FLAG = 0100b
 
mouse.BUTTONS_MASK = \
mouse.LEFT_BUTTON_FLAG or \
mouse.RIGHT_BUTTON_FLAG or \
mouse.MIDDLE_BUTTON_FLAG
 
mouse.WINDOW_RESIZE_N_FLAG = 000001b
mouse.WINDOW_RESIZE_W_FLAG = 000010b
mouse.WINDOW_RESIZE_S_FLAG = 000100b
mouse.WINDOW_RESIZE_E_FLAG = 001000b
mouse.WINDOW_MOVE_FLAG = 010000b
 
mouse.WINDOW_RESIZE_SW_FLAG = \
mouse.WINDOW_RESIZE_S_FLAG or \
mouse.WINDOW_RESIZE_W_FLAG
mouse.WINDOW_RESIZE_SE_FLAG = \
mouse.WINDOW_RESIZE_S_FLAG or \
mouse.WINDOW_RESIZE_E_FLAG
 
align 4
;------------------------------------------------------------------------------
mouse_check_events: ;//////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Check if mouse buttons state or cursor position has changed and call
;? appropriate handlers
;------------------------------------------------------------------------------
push eax ebx
mousepointer:
db 0x00,0x00,0x00,0x74,0x74,0x74,0x6e,0x6e,0x6e,0x6f
db 0x6f,0x6f,0x71,0x71,0x71,0x75,0x75,0x75,0x79,0x79
db 0x79,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x54,0x54,0x54,0x57,0x57
db 0x57,0x5f,0x5f,0x5f,0x68,0x68,0x68,0x71,0x71,0x71
db 0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x47,0x47,0x47,0x50
db 0x50,0x50,0x5b,0x5b,0x5b,0x67,0x67,0x67,0x70,0x70
db 0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3f,0x3f,0x3f
db 0x4b,0x4b,0x4b,0x59,0x59,0x59,0x66,0x66,0x66,0x70
db 0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e
db 0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3a,0x3a
db 0x3a,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66,0x66
db 0x70,0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e
db 0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x39
db 0x39,0x39,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66
db 0x66,0x71,0x71,0x71,0x78,0x78,0x78,0x7c,0x7c,0x7c
db 0x7e,0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0xff
db 0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0x39,0x39,0x39,0x4a,0x4a,0x4a,0x5a,0x5a,0x5a,0x68
db 0x68,0x68,0x72,0x72,0x72,0x79,0x79,0x79,0x7d,0x7d
db 0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00
db 0x00,0x3c,0x3c,0x3c,0x4e,0x4e,0x4e,0x5e,0x5e,0x5e
db 0x6b,0x6b,0x6b,0x75,0x75,0x75,0x7a,0x7a,0x7a,0x7e
db 0x7e,0x7e,0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00
db 0x00,0x00,0x43,0x43,0x43,0x55,0x55,0x55,0x64,0x64
db 0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d
db 0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x4e,0x4e,0x4e,0x5f,0x5f,0x5f,0x6d
db 0x6d,0x6d,0x76,0x76,0x76,0x7c,0x7c,0x7c,0x80,0x80
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x14
db 0x14,0x14,0x1b,0x1b,0x1b,0x29,0x29,0x29,0x3a,0x3a
db 0x3a,0x4c,0x4c,0x4c,0x5d,0x5d,0x5d,0x6c,0x6c,0x6c
db 0x75,0x75,0x75,0x7b,0x7b,0x7b,0x80,0x80,0x80,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x2f,0x2f,0x2f,0x80,0x80
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0x21,0x21,0x21,0x2e,0x2e,0x2e,0x40,0x40,0x40,0x52
db 0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f,0x77,0x77
db 0x77,0x7c,0x7c,0x7c,0x80,0x80,0x80,0x00,0x00,0x00
db 0x47,0x47,0x47,0x3b,0x3b,0x3b,0x80,0x80,0x80,0xff
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x25,0x25
db 0x25,0x30,0x30,0x30,0x42,0x42,0x42,0x54,0x54,0x54
db 0x64,0x64,0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
db 0x7d,0x7d,0x00,0x00,0x00,0x62,0x62,0x62,0x52,0x52
db 0x52,0x4a,0x4a,0x4a,0x43,0x43,0x43,0x80,0x80,0x80
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x33
db 0x33,0x33,0x42,0x42,0x42,0x54,0x54,0x54,0x64,0x64
db 0x64,0x71,0x71,0x71,0x79,0x79,0x79,0x7d,0x7d,0x7d
db 0x72,0x72,0x72,0x6b,0x6b,0x6b,0x5f,0x5f,0x5f,0x5a
db 0x5a,0x5a,0x54,0x54,0x54,0x80,0x80,0x80,0xff,0xff
db 0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x35,0x35,0x35
db 0x41,0x41,0x41,0x53,0x53,0x53,0x63,0x63,0x63,0x70
db 0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d,0x77,0x77
db 0x77,0x73,0x73,0x73,0x6c,0x6c,0x6c,0x68,0x68,0x68
db 0x62,0x62,0x62,0x5a,0x5a,0x5a,0x80,0x80,0x80,0xff
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x41,0x41
db 0x41,0x52,0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f
db 0x78,0x78,0x78,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x79
db 0x79,0x79,0x74,0x74,0x74,0x72,0x72,0x72,0x6e,0x6e
db 0x6e,0x66,0x66,0x66,0x80,0x80,0x80,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x44,0x44,0x44,0x52
db 0x52,0x52,0x62,0x62,0x62,0x6e,0x6e,0x6e,0x77,0x77
db 0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7c,0x7c,0x7c
db 0x7a,0x7a,0x7a,0x79,0x79,0x79,0x75,0x75,0x75,0x6f
db 0x6f,0x6f,0x65,0x65,0x65,0x00,0x00,0x00,0x00,0x00
db 0x00,0x48,0x48,0x48,0x4b,0x4b,0x4b,0x56,0x56,0x56
db 0x65,0x65,0x65,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
db 0x7d,0x7d,0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e
db 0x7e,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76,0x76
db 0x6f,0x6f,0x6f,0x65,0x65,0x65,0x5c,0x5c,0x5c,0x56
db 0x56,0x56,0x58,0x58,0x58,0x60,0x60,0x60,0x6b,0x6b
db 0x6b,0x73,0x73,0x73,0x7a,0x7a,0x7a,0x7d,0x7d,0x7d
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7f
db 0x7f,0x7f,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76
db 0x76,0x70,0x70,0x70,0x6a,0x6a,0x6a,0x66,0x66,0x66
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x77
db 0x77,0x77,0x73,0x73,0x73,0x71,0x71,0x71,0x71,0x71
db 0x71,0x74,0x74,0x74,0x78,0x78,0x78,0x7b,0x7b,0x7b
db 0x7d,0x7d,0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7c,0x7c,0x7c
db 0x7a,0x7a,0x7a,0x78,0x78,0x78,0x78,0x78,0x78,0x7a
db 0x7a,0x7a,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7f,0x7f
db 0x7f,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e,0x7e,0x7e,0x7e
db 0x7e,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e
db 0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
db 0x80,0x80
 
mov al, [BTN_DOWN]
mov bl, [mouse.state.buttons]
and al, mouse.BUTTONS_MASK
mov cl, al
xchg cl, [mouse.state.buttons]
xor bl, al
push eax ebx
mousepointer1:
db 0xff,0xff,0xff,0x06,0x06,0x06,0x0a,0x0a
db 0x0a,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0x19,0x19,0x19,0x16
db 0x16,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2e,0x2e,0x2e
db 0x23,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f
db 0x3f,0x29,0x29,0x29,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x47
db 0x47,0x47,0x2c,0x2c,0x2c,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0x47,0x47,0x47,0x29,0x29,0x29
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0x40,0x40,0x40,0x23,0x23
db 0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xaa,0xaa,0xaa,0x9f,0x9f,0x9f,0x8c,0x8c,0x8c
db 0x70,0x70,0x70,0x4f,0x4f,0x4f,0x30,0x30,0x30,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x8f,0x8f,0x8f
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0x9c,0x9c,0x9c,0x87,0x87,0x87,0x6c,0x6c
db 0x6c,0x4f,0x4f,0x4f,0x32,0x32,0x32,0x19,0x19,0x19
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0x69,0x69,0x69,0x84,0x84,0x84,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x92,0x92,0x92,0x79,0x79,0x79,0x59,0x59,0x59,0x3c
db 0x3c,0x3c,0x24,0x24,0x24,0x11,0x11,0x11,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x37,0x37,0x37
db 0x5d,0x5d,0x5d,0x70,0x70,0x70,0x76,0x76,0x76,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0x75,0x75,0x75,0x51,0x51,0x51,0x31,0x31,0x31
db 0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x16,0x16,0x16,0x2d,0x2d,0x2d,0x49,0x49
db 0x49,0x53,0x53,0x53,0x54,0x54,0x54,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x78
db 0x78,0x78,0x54,0x54,0x54,0x30,0x30,0x30,0x16,0x16
db 0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x0f,0x0f,0x0f,0x1f,0x1f,0x1f,0x30,0x30,0x30,0x33
db 0x33,0x33,0x33,0x33,0x33,0x3b,0x3b,0x3b,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x62,0x62,0x62,0x3b,0x3b,0x3b,0x1c,0x1c,0x1c,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08
db 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x24,0x24,0x24,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6e,0x6e
db 0x6e,0x48,0x48,0x48,0x25,0x25,0x25,0x0e,0x0e,0x0e
db 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00
db 0x00,0x00,0x0a,0x0a,0x0a,0x09,0x09,0x09,0x00,0x00
db 0x00,0x00,0x00,0x00,0x29,0x29,0x29,0xff,0xff,0xff
db 0xff,0xff,0xff,0x7c,0x7c,0x7c,0x71,0x71,0x71,0x50
db 0x50,0x50,0x2b,0x2b,0x2b,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x02,0x02,0x02,0x04,0x04,0x04,0x00
db 0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x56,0x56
db 0x56,0x69,0x69,0x69,0x64,0x64,0x64,0x4a,0x4a,0x4a
db 0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x05,0x05,0x05
db 0x00,0x00,0x00,0x21,0x21,0x21,0x39,0x39,0x39,0x49
db 0x49,0x49,0x48,0x48,0x48,0x35,0x35,0x35,0x1d,0x1d
db 0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00
db 0x00,0x00,0x00,0x00,0x1d,0x1d,0x1d,0x27,0x27,0x27
db 0x27,0x27,0x27,0x1d,0x1d,0x1d,0x0f,0x0f,0x0f,0x06
db 0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00
 
; did any mouse button changed its state?
or bl, bl
jz .check_position
 
; yes it did, is that the first button of all pressed down?
or cl, cl
jnz .check_buttons_released
 
; yes it is, activate window user is pointing at, if needed
call mouse._.activate_sys_window_under_cursor
 
; NOTE: this code wouldn't be necessary if we knew window did
; already redraw itself after call above
or eax, eax
jz @f
 
and [mouse.state.buttons], 0
jmp .exit
 
; is there any system button under cursor?
@@:
call mouse._.find_sys_button_under_cursor
or eax, eax
jz .check_buttons_released
 
; yes there is, activate it and exit
mov [mouse.active_sys_button.pbid], eax
mov [mouse.active_sys_button.coord], ebx
mov cl, [mouse.state.buttons]
mov [mouse.active_sys_button.buttons], cl
call sys_button_activate_handler
jmp .exit
 
.check_buttons_released:
cmp [mouse.state.buttons], 0
jnz .buttons_changed
 
; did we press some button earlier?
cmp [mouse.active_sys_button.pbid], 0
je .buttons_changed
 
; yes we did, deactivate it
xor eax, eax
xchg eax, [mouse.active_sys_button.pbid]
mov ebx, [mouse.active_sys_button.coord]
mov cl, [mouse.active_sys_button.buttons]
push eax ebx
call sys_button_deactivate_handler
pop edx ecx
 
; is the button under cursor the one we deactivated?
call mouse._.find_sys_button_under_cursor
cmp eax, ecx
jne .exit
cmp ebx, edx
jne .exit
 
; yes it is, perform associated action
mov cl, [mouse.active_sys_button.buttons]
call sys_button_perform_handler
jmp .exit
 
.buttons_changed:
test byte[esp], mouse.LEFT_BUTTON_FLAG
jz @f
mov eax, [esp + 4]
call .call_left_button_handler
 
@@:
test byte[esp], mouse.RIGHT_BUTTON_FLAG
jz @f
mov eax, [esp + 4]
call .call_right_button_handler
 
@@:
test byte[esp], mouse.MIDDLE_BUTTON_FLAG
jz .check_position
mov eax, [esp + 4]
call .call_middle_button_handler
 
.check_position:
movzx eax, word[MOUSE_X]
movzx ebx, word[MOUSE_Y]
cmp eax, [mouse.state.pos.x]
jne .position_changed
cmp ebx, [mouse.state.pos.y]
je .exit
 
.position_changed:
xchg eax, [mouse.state.pos.x]
xchg ebx, [mouse.state.pos.y]
 
call mouse._.move_handler
 
.exit:
add esp, 8
pop ebx eax
ret
 
.call_left_button_handler:
test eax, mouse.LEFT_BUTTON_FLAG
jnz mouse._.left_button_press_handler
jmp mouse._.left_button_release_handler
 
.call_right_button_handler:
test eax, mouse.RIGHT_BUTTON_FLAG
jnz mouse._.right_button_press_handler
jmp mouse._.right_button_release_handler
 
.call_middle_button_handler:
test eax, mouse.MIDDLE_BUTTON_FLAG
jnz mouse._.middle_button_press_handler
jmp mouse._.middle_button_release_handler
 
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
 
uglobal
mouse.state:
.pos POINT
.buttons db ?
 
; NOTE: since there's no unique and lifetime-constant button identifiers,
; we're using two dwords to identify each of them:
; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack
; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack
align 4
mouse.active_sys_button:
.pbid dd ?
.coord dd ?
.buttons db ?
 
align 4
mouse.active_sys_window:
.pslot dd ?
.old_box BOX
.new_box BOX
.delta POINT
.last_ticks dd ?
.action db ?
endg
 
align 4
;------------------------------------------------------------------------------
mouse._.left_button_press_handler: ;///////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when left mouse button has been pressed down
;------------------------------------------------------------------------------
test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG
jnz .exit
 
call mouse._.find_sys_window_under_cursor
call mouse._.check_sys_window_actions
mov [mouse.active_sys_window.action], al
or eax, eax
jz .exit
 
xchg eax, edx
test dl, mouse.WINDOW_MOVE_FLAG
jz @f
 
mov eax, [timer_ticks]
mov ebx, eax
xchg ebx, [mouse.active_sys_window.last_ticks]
sub eax, ebx
cmp eax, 50
jg @f
 
mov [mouse.active_sys_window.last_ticks], 0
call sys_window_maximize_handler
jmp .exit
 
@@:
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jnz .exit
mov [mouse.active_sys_window.pslot], esi
lea eax, [edi + WDATA.box]
mov ebx, mouse.active_sys_window.old_box
mov ecx, sizeof.BOX
call memmove
mov ebx, mouse.active_sys_window.new_box
call memmove
test edx, mouse.WINDOW_MOVE_FLAG
jz @f
 
call .calculate_n_delta
call .calculate_w_delta
jmp .call_window_handler
 
@@:
test dl, mouse.WINDOW_RESIZE_W_FLAG
jz @f
call .calculate_w_delta
 
@@:
test dl, mouse.WINDOW_RESIZE_S_FLAG
jz @f
call .calculate_s_delta
 
@@:
test dl, mouse.WINDOW_RESIZE_E_FLAG
jz .call_window_handler
call .calculate_e_delta
 
.call_window_handler:
mov eax, mouse.active_sys_window.old_box
call sys_window_start_moving_handler
 
.exit:
ret
 
.calculate_n_delta:
mov eax, [mouse.state.pos.y]
sub eax, [mouse.active_sys_window.old_box.top]
mov [mouse.active_sys_window.delta.y], eax
ret
 
.calculate_w_delta:
mov eax, [mouse.state.pos.x]
sub eax, [mouse.active_sys_window.old_box.left]
mov [mouse.active_sys_window.delta.x], eax
ret
 
.calculate_s_delta:
mov eax, [mouse.active_sys_window.old_box.top]
add eax, [mouse.active_sys_window.old_box.height]
sub eax, [mouse.state.pos.y]
mov [mouse.active_sys_window.delta.y], eax
ret
 
.calculate_e_delta:
mov eax, [mouse.active_sys_window.old_box.left]
add eax, [mouse.active_sys_window.old_box.width]
sub eax, [mouse.state.pos.x]
mov [mouse.active_sys_window.delta.x], eax
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.left_button_release_handler: ;/////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when left mouse button has been released
;------------------------------------------------------------------------------
xor esi, esi
xchg esi, [mouse.active_sys_window.pslot]
or esi, esi
jz .exit
 
mov eax, esi
shl eax, 5
add eax, window_data + WDATA.box
mov ebx, mouse.active_sys_window.old_box
mov ecx, sizeof.BOX
call memmove
 
mov eax, mouse.active_sys_window.old_box
mov ebx, mouse.active_sys_window.new_box
call sys_window_end_moving_handler
 
.exit:
and [mouse.active_sys_window.action], 0
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.right_button_press_handler: ;//////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when right mouse button has been pressed down
;------------------------------------------------------------------------------
test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG
jnz .exit
 
call mouse._.find_sys_window_under_cursor
call mouse._.check_sys_window_actions
test al, mouse.WINDOW_MOVE_FLAG
jz .exit
 
call sys_window_rollup_handler
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.right_button_release_handler: ;////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when right mouse button has been released
;------------------------------------------------------------------------------
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.middle_button_press_handler: ;/////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when middle mouse button has been pressed down
;------------------------------------------------------------------------------
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.middle_button_release_handler: ;///////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when middle mouse button has been released
;------------------------------------------------------------------------------
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.move_handler: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when cursor has been moved
;------------------------------------------------------------------------------
;> eax = old x coord
;> ebx = old y coord
;------------------------------------------------------------------------------
cmp [mouse.active_sys_button.pbid], 0
jnz .exit
 
mov esi, [mouse.active_sys_window.pslot]
or esi, esi
jz .exit
 
mov eax, mouse.active_sys_window.new_box
mov ebx, mouse.active_sys_window.old_box
mov ecx, sizeof.BOX
call memmove
 
mov dl, [mouse.active_sys_window.action]
test dl, mouse.WINDOW_MOVE_FLAG
jz .check_resize_w
 
mov eax, [mouse.state.pos.x]
sub eax, [mouse.active_sys_window.delta.x]
mov [mouse.active_sys_window.new_box.left], eax
mov eax, [mouse.state.pos.y]
sub eax, [mouse.active_sys_window.delta.y]
mov [mouse.active_sys_window.new_box.top], eax
 
mov eax, [mouse.active_sys_window.new_box.left]
or eax, eax
jge @f
xor eax, eax
mov [mouse.active_sys_window.new_box.left], eax
@@:
add eax, [mouse.active_sys_window.new_box.width]
cmp eax, [Screen_Max_X]
jl @f
sub eax, [Screen_Max_X]
sub [mouse.active_sys_window.new_box.left], eax
@@:
mov eax, [mouse.active_sys_window.new_box.top]
or eax, eax
jge @f
xor eax, eax
mov [mouse.active_sys_window.new_box.top], eax
@@:
add eax, [mouse.active_sys_window.new_box.height]
cmp eax, [Screen_Max_Y]
jle .call_window_handler
sub eax, [Screen_Max_Y]
sub [mouse.active_sys_window.new_box.top], eax
jmp .call_window_handler
 
.check_resize_w:
test dl, mouse.WINDOW_RESIZE_W_FLAG
jz .check_resize_s
 
mov eax, [mouse.state.pos.x]
sub eax, [mouse.active_sys_window.delta.x]
mov [mouse.active_sys_window.new_box.left], eax
sub eax, [mouse.active_sys_window.old_box.left]
sub [mouse.active_sys_window.new_box.width], eax
 
mov eax, [mouse.active_sys_window.new_box.width]
sub eax, 127
jge @f
add [mouse.active_sys_window.new_box.left], eax
mov [mouse.active_sys_window.new_box.width], 127
@@:
mov eax, [mouse.active_sys_window.new_box.left]
or eax, eax
jge .check_resize_s
add [mouse.active_sys_window.new_box.width], eax
xor eax, eax
mov [mouse.active_sys_window.new_box.left], eax
 
.check_resize_s:
test dl, mouse.WINDOW_RESIZE_S_FLAG
jz .check_resize_e
 
mov eax, [mouse.state.pos.y]
add eax, [mouse.active_sys_window.delta.y]
sub eax, [mouse.active_sys_window.old_box.top]
mov [mouse.active_sys_window.new_box.height], eax
 
push eax
mov edi, esi
shl edi, 5
add edi, window_data
call window._.get_rolledup_height
mov ecx, eax
pop eax
mov eax, [mouse.active_sys_window.new_box.height]
cmp eax, ecx
jge @f
mov eax, ecx
mov [mouse.active_sys_window.new_box.height], eax
@@:
add eax, [mouse.active_sys_window.new_box.top]
cmp eax, [Screen_Max_Y]
jle .check_resize_e
sub eax, [Screen_Max_Y]
neg eax
add [mouse.active_sys_window.new_box.height], eax
mov ecx, [Screen_Max_Y]
cmp ecx, eax
jge .check_resize_e
mov [mouse.active_sys_window.new_box.height], ecx
 
.check_resize_e:
test dl, mouse.WINDOW_RESIZE_E_FLAG
jz .call_window_handler
 
mov eax, [mouse.state.pos.x]
add eax, [mouse.active_sys_window.delta.x]
sub eax, [mouse.active_sys_window.old_box.left]
mov [mouse.active_sys_window.new_box.width], eax
 
mov eax, [mouse.active_sys_window.new_box.width]
cmp eax, 127
jge @f
mov eax, 127
mov [mouse.active_sys_window.new_box.width], eax
@@:
add eax, [mouse.active_sys_window.new_box.left]
cmp eax, [Screen_Max_X]
jle .call_window_handler
sub eax, [Screen_Max_X]
neg eax
add [mouse.active_sys_window.new_box.width], eax
mov ecx, [Screen_Max_X]
cmp ecx, eax
jge .call_window_handler
mov [mouse.active_sys_window.new_box.width], ecx
 
.call_window_handler:
mov eax, mouse.active_sys_window.old_box
mov ebx, mouse.active_sys_window.new_box
 
push esi
mov esi, mouse.active_sys_window.old_box
mov edi, mouse.active_sys_window.new_box
mov ecx, sizeof.BOX / 4
repe
cmpsd
pop esi
je .exit
 
mov [mouse.active_sys_window.last_ticks], 0
call sys_window_moving_handler
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.find_sys_window_under_cursor: ;////////////////////////////////////////
;------------------------------------------------------------------------------
;? Find system window object which is currently visible on screen and has
;? mouse cursor within its bounds
;------------------------------------------------------------------------------
;< esi = process slot
;< edi = pointer to WDATA struct
;------------------------------------------------------------------------------
mov esi, [Screen_Max_X]
inc esi
imul esi, [mouse.state.pos.y]
add esi, [_WinMapAddress]
add esi, [mouse.state.pos.x]
movzx esi, byte[esi]
mov edi, esi
shl edi, 5
add edi, window_data
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.activate_sys_window_under_cursor: ;////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
; activate and redraw window under cursor (if necessary)
call mouse._.find_sys_window_under_cursor
movzx esi, word[WIN_STACK + esi * 2]
lea esi, [WIN_POS + esi * 2]
jmp waredraw
 
align 4
;------------------------------------------------------------------------------
mouse._.find_sys_button_under_cursor: ;////////////////////////////////////////
;------------------------------------------------------------------------------
;? Find system button object which is currently visible on screen and has
;? mouse cursor within its bounds
;------------------------------------------------------------------------------
;< eax = pack[8(process slot), 24(button id)] or 0
;< ebx = pack[16(button x coord), 16(button y coord)]
;------------------------------------------------------------------------------
push ecx edx esi edi
 
call mouse._.find_sys_window_under_cursor
mov edx, esi
 
; check if any process button contains cursor
mov eax, [BTN_ADDR]
mov ecx, [eax]
imul esi, ecx, SYS_BUTTON.sizeof
add esi, eax
inc ecx
add esi, SYS_BUTTON.sizeof
 
.next_button:
dec ecx
jz .not_found
 
add esi, -SYS_BUTTON.sizeof
 
; does it belong to our process?
cmp dx, [esi + SYS_BUTTON.pslot]
jne .next_button
 
; does it contain cursor coordinates?
mov eax, [mouse.state.pos.x]
sub eax, [edi + WDATA.box.left]
sub ax, [esi + SYS_BUTTON.left]
jl .next_button
sub ax, [esi + SYS_BUTTON.width]
jge .next_button
mov eax, [mouse.state.pos.y]
sub eax, [edi + WDATA.box.top]
sub ax, [esi + SYS_BUTTON.top]
jl .next_button
sub ax, [esi + SYS_BUTTON.height]
jge .next_button
 
; okay, return it
shl edx, 24
mov eax, dword[esi + SYS_BUTTON.id_hi - 2]
mov ax, [esi + SYS_BUTTON.id_lo]
and eax, 0x0ffffff
or eax, edx
mov ebx, dword[esi + SYS_BUTTON.left - 2]
mov bx, [esi + SYS_BUTTON.top]
jmp .exit
 
.not_found:
xor eax, eax
xor ebx, ebx
 
.exit:
pop edi esi edx ecx
ret
 
align 4
;------------------------------------------------------------------------------
mouse._.check_sys_window_actions: ;////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;< eax = action flags or 0
;------------------------------------------------------------------------------
; is window movable?
test byte[edi + WDATA.cl_titlebar + 3], 0x01
jnz .no_action
 
mov eax, [mouse.state.pos.x]
mov ebx, [mouse.state.pos.y]
sub eax, [edi + WDATA.box.left]
sub ebx, [edi + WDATA.box.top]
 
; is there a window titlebar under cursor?
push eax
call window._.get_titlebar_height
cmp ebx, eax
pop eax
jl .move_action
 
; no there isn't, can it be resized then?
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
; NOTE: dangerous optimization, revise if window types changed;
; this currently implies only types 2 and 3 could be resized
test dl, 2
jz .no_action
 
mov ecx, [edi + WDATA.box.width]
add ecx, -window.BORDER_SIZE
mov edx, [edi + WDATA.box.height]
add edx, -window.BORDER_SIZE
 
; is it rolled up?
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
jnz .resize_w_or_e_action
 
cmp eax, window.BORDER_SIZE
jl .resize_w_action
cmp eax, ecx
jg .resize_e_action
cmp ebx, edx
jle .no_action
 
.resize_s_action:
cmp eax, window.BORDER_SIZE + 10
jl .resize_sw_action
add ecx, -10
cmp eax, ecx
jge .resize_se_action
mov eax, mouse.WINDOW_RESIZE_S_FLAG
jmp .exit
 
.resize_w_or_e_action:
cmp eax, window.BORDER_SIZE + 10
jl .resize_w_action.direct
add ecx, -10
cmp eax, ecx
jg .resize_e_action.direct
jmp .no_action
 
.resize_w_action:
add edx, -10
cmp ebx, edx
jge .resize_sw_action
.resize_w_action.direct:
mov eax, mouse.WINDOW_RESIZE_W_FLAG
jmp .exit
 
.resize_e_action:
add edx, -10
cmp ebx, edx
jge .resize_se_action
.resize_e_action.direct:
mov eax, mouse.WINDOW_RESIZE_E_FLAG
jmp .exit
 
.resize_sw_action:
mov eax, mouse.WINDOW_RESIZE_SW_FLAG
jmp .exit
 
.resize_se_action:
mov eax, mouse.WINDOW_RESIZE_SE_FLAG
jmp .exit
 
.move_action:
mov eax, mouse.WINDOW_MOVE_FLAG
jmp .exit
 
.no_action:
xor eax, eax
 
.exit:
ret
/kernel/branches/net/gui/window.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
8,88 → 8,43
 
$Revision$
 
 
;==============================================================================
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
 
window.BORDER_SIZE = 5
 
macro FuncTable name, table_name, [label]
macro FuncTable name, [label]
{
common
align 4
\label name#.#table_name dword
\label name#.ftable dword
forward
dd name#.#label
common
name#.sizeof.#table_name = $ - name#.#table_name
name#.sizeof.ftable = $ - name#.ftable
}
 
iglobal
FuncTable syscall_display_settings, \
00, 01, 02, 03, 04, 05, 06, 07, 08
endg
 
uglobal
common_colours rd 32
new_window_starting dd ?
latest_window_touch dd ?
latest_window_touch_delta dd ?
old_window_pos BOX
new_window_pos BOX
draw_limits RECT
bPressedMouseXY_W db ?
do_resize db ?
do_resize_from_corner db ?
reposition db ?
endg
 
align 4
;------------------------------------------------------------------------------
syscall_draw_window: ;///// system function 0 /////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
mov eax, edx
shr eax, 24
and al, 0x0f
cmp al, 5
jae .exit
 
push eax
inc [mouse_pause]
call [_display.disable_mouse]
call window._.sys_set_window
call [_display.disable_mouse]
pop eax
 
or al, al
jnz @f
 
; type I - original style
call drawwindow_I
jmp window._.draw_window_caption.2
 
@@:
dec al
jnz @f
 
; type II - only reserve area, no draw
call sys_window_mouse
dec [mouse_pause]
call [draw_pointer]
jmp .exit
 
@@:
dec al
jnz @f
 
; type III - new style
call drawwindow_III
jmp window._.draw_window_caption.2
 
; type IV & V - skinned window (resizable & not)
@@:
mov eax, [TASK_COUNT]
movzx eax, word[WIN_POS + eax * 2]
cmp eax, [CURRENT_TASK]
setz al
movzx eax, al
push eax
call drawwindow_IV
jmp window._.draw_window_caption.2
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
syscall_display_settings: ;///// system function 48 ///////////////////////////
;------------------------------------------------------------------------------
;; Redraw screen:
136,8 → 91,7
cmp ebx, .sizeof.ftable / 4
ja @f
jmp [.ftable + ebx * 4]
@@:
ret
@@: ret
 
 
align 4
214,13 → 168,11
or eax, eax
jge @f
xor eax, eax
@@:
mov [screen_workarea.left], eax
@@: mov [screen_workarea.left], eax
cmp ebx, edi
jle @f
mov ebx, edi
@@:
mov [screen_workarea.right], ebx
@@: mov [screen_workarea.right], ebx
 
.check_horizontal:
mov edi, [Screen_Max_Y]
233,13 → 185,11
or eax, eax
jge @f
xor eax, eax
@@:
mov [screen_workarea.top], eax
@@: mov [screen_workarea.top], eax
cmp ebx, edi
jle @f
mov ebx, edi
@@:
mov [screen_workarea.bottom], ebx
@@: mov [screen_workarea.bottom], ebx
 
.check_if_redraw_needed:
or esi, esi
319,100 → 269,14
 
align 4
;------------------------------------------------------------------------------
syscall_move_window: ;///// system function 67 ////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
mov edi, [CURRENT_TASK]
shl edi, 5
add edi, window_data
 
test [edi + WDATA.fl_wdrawn], 1
jz .exit
 
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jnz .exit
 
cmp ebx, -1
jne @f
mov ebx, [edi + WDATA.box.left]
@@:
cmp ecx, -1
jne @f
mov ecx, [edi + WDATA.box.top]
@@:
cmp edx, -1
jne @f
mov edx, [edi + WDATA.box.width]
@@:
cmp esi, -1
jne @f
mov esi, [edi + WDATA.box.height]
 
@@:
push esi edx ecx ebx
mov eax, esp
mov bl, [edi + WDATA.fl_wstate]
call window._.set_window_box
add esp, sizeof.BOX
 
; NOTE: do we really need this? to be reworked
; mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
; mov byte[MOUSE_BACKGROUND], 0 ; no mouse under
; mov byte[MOUSE_DOWN], 0 ; react to mouse up/down
 
; NOTE: do we really need this? to be reworked
; call [draw_pointer]
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
syscall_window_settings: ;///// system function 71 /////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
dec ebx ; subfunction #1 - set window caption
jnz .exit_fail
 
; NOTE: only window owner thread can set its caption,
; so there's no parameter for PID/TID
 
mov edi, [CURRENT_TASK]
shl edi, 5
 
mov [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx
or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
 
call window._.draw_window_caption
 
xor eax, eax ; eax = 0 (success)
ret
 
; .get_window_caption:
; dec eax ; subfunction #2 - get window caption
; jnz .exit_fail
 
; not implemented yet
 
.exit_fail:
xor eax, eax
inc eax ; eax = 1 (fail)
ret
 
align 4
;------------------------------------------------------------------------------
set_window_defaults: ;/////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable
push eax ecx
xor eax, eax
mov ecx, WIN_STACK
@@:
inc eax
@@: inc eax
add ecx, 2
; process no
mov [ecx + 0x000], ax
479,21 → 343,17
cmp eax, [esp + RECT.left]
jae @f
mov eax, [esp + RECT.left]
@@:
cmp ebx, [esp + RECT.top]
@@: cmp ebx, [esp + RECT.top]
jae @f
mov ebx, [esp + RECT.top]
@@:
cmp ecx, [esp + RECT.right]
@@: cmp ecx, [esp + RECT.right]
jbe @f
mov ecx, [esp + RECT.right]
@@:
cmp edx, [esp + RECT.bottom]
@@: cmp edx, [esp + RECT.bottom]
jbe @f
mov edx, [esp + RECT.bottom]
 
@@:
push esi
@@: push esi
movzx esi, word[WIN_POS + esi * 2]
call window._.set_screen
pop esi
518,7 → 378,7
;? <description>
;------------------------------------------------------------------------------
mov ecx, [TASK_COUNT]
mov edi, window_data + sizeof.WDATA * 2
mov edi, window_data + WDATA.sizeof * 2
call force_redraw_background
dec ecx
jle .exit
537,8 → 397,7
sub eax, ebx
jle @f
mov [edi + WDATA.box.width], ebx
@@:
sub ebx, [edi + WDATA.box.width]
@@: sub ebx, [edi + WDATA.box.width]
mov [edi + WDATA.box.left], ebx
 
.fix_vertical:
551,8 → 410,7
sub eax, ebx
jle @f
mov [edi + WDATA.box.height], ebx
@@:
sub ebx, [edi + WDATA.box.height]
@@: sub ebx, [edi + WDATA.box.height]
mov [edi + WDATA.box.top], ebx
jmp .fix_client_box
 
571,9 → 429,9
mov [edi + WDATA.box.height], eax
 
.fix_client_box:
call window._.set_window_clientbox
call set_window_clientbox
 
add edi, sizeof.WDATA
add edi, WDATA.sizeof
loop .next_window
 
.exit:
581,25 → 439,97
 
align 4
;------------------------------------------------------------------------------
check_window_position: ;///////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Check if window is inside screen area
;------------------------------------------------------------------------------
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
push eax ebx ecx edx esi
 
mov eax, [edi + WDATA.box.left]
mov ebx, [edi + WDATA.box.top]
mov ecx, [edi + WDATA.box.width]
mov edx, [edi + WDATA.box.height]
 
mov esi, [Screen_Max_X]
cmp ecx, esi
ja .fix_width
 
.check_left:
or eax, eax
jl .fix_left_low
add eax, ecx
cmp eax, esi
jg .fix_left_high
 
.check_height:
mov esi, [Screen_Max_Y]
cmp edx, esi
ja .fix_height
 
.check_top:
or ebx, ebx
jl .fix_top_low
add ebx, edx
cmp ebx, esi
jg .fix_top_high
 
.exit:
pop esi edx ecx ebx eax
ret
 
.fix_width:
mov ecx, esi
mov [edi + WDATA.box.width], esi
jmp .check_left
 
.fix_left_low:
xor eax, eax
mov [edi + WDATA.box.left], eax
jmp .check_height
 
.fix_left_high:
mov eax, esi
sub eax, ecx
mov [edi + WDATA.box.left], eax
jmp .check_height
 
.fix_height:
mov edx, esi
mov [edi + WDATA.box.height], esi
jmp .check_top
 
.fix_top_low:
xor ebx, ebx
mov [edi + WDATA.box.top], ebx
jmp .exit
 
.fix_top_high:
mov ebx, esi
sub ebx, edx
mov [edi + WDATA.box.top], ebx
jmp .exit
 
align 4
;------------------------------------------------------------------------------
sys_window_mouse: ;////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
; NOTE: commented out since doesn't provide necessary functionality
; anyway, to be reworked
; push eax
;
; mov eax, [timer_ticks]
; cmp [new_window_starting], eax
; jb .exit
;
; mov byte[MOUSE_BACKGROUND], 0
; mov byte[DONT_DRAW_MOUSE], 0
;
; mov [new_window_starting], eax
;
; .exit:
; pop eax
push eax
 
mov eax, [timer_ticks]
cmp [new_window_starting], eax
jb .exit
 
mov byte[MOUSE_BACKGROUND], 0
mov byte[DONT_DRAW_MOUSE], 0
 
mov [new_window_starting], eax
 
.exit:
pop eax
ret
 
align 4
674,8 → 604,7
cmp ebx, eax
jbe @f
mov ebx, eax
@@:
push ebx
@@: push ebx
 
xor edi, edi
 
694,8 → 623,7
jz @f
sub ecx, 0x00040404
mov [esi + WDATA.cl_titlebar], ecx
@@:
and ecx, 0x00ffffff
@@: and ecx, 0x00ffffff
call [draw_line]
inc edx
cmp edx, [esp]
774,8 → 702,7
cmp ebx, eax
jb @f
mov ebx, eax
@@:
push ebx
@@: push ebx
 
xor edi, edi
 
792,12 → 719,10
test ecx, 0x40000000
jz @f
add ecx, 0x00040404
@@:
test ecx, 0x80000000
@@: test ecx, 0x80000000
jz @f
sub ecx, 0x00040404
@@:
mov [esi + WDATA.cl_titlebar], ecx
@@: mov [esi + WDATA.cl_titlebar], ecx
and ecx, 0x00ffffff
call [draw_line]
inc edx
884,13 → 809,6
;------------------------------------------------------------------------------
;? Activate window, redrawing if necessary
;------------------------------------------------------------------------------
push -1
mov eax, [TASK_COUNT]
lea eax, [WIN_POS + eax * 2]
cmp eax, esi
pop eax
je .exit
 
; is it overlapped by another window now?
push ecx
call window._.check_window_draw
923,20 → 841,15
 
; tell application to redraw itself
mov [edi + WDATA.fl_redraw], 1
xor eax, eax
jmp .exit
mov byte[MOUSE_DOWN], 0
ret
 
.do_not_draw:
; no it's not, just activate the window
call window._.window_activate
xor eax, eax
mov byte[MOUSE_BACKGROUND], al
mov byte[DONT_DRAW_MOUSE], al
 
 
.exit:
mov byte[MOUSE_DOWN], 0
inc eax
mov byte[MOUSE_BACKGROUND], 0
mov byte[DONT_DRAW_MOUSE], 0
ret
 
align 4
1011,8 → 924,7
cmp eax, [TASK_COUNT]
jz @f
mov ebp, calculatescreen
@@:
mov eax, [edi + WDATA.box.left]
@@: mov eax, [edi + WDATA.box.left]
mov ebx, [edi + WDATA.box.top]
mov ecx, [edi + WDATA.box.width]
mov edx, [edi + WDATA.box.height]
1028,15 → 940,16
ret
 
align 4
; TODO: remove this proc
;------------------------------------------------------------------------------
window_check_events: ;/////////////////////////////////////////////////////////
checkwindows: ;////////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;? Check for user-initiated window operations
;------------------------------------------------------------------------------
pushad
 
; do we have window minimize/restore request?
cmp [window_minimize], 0
je .exit
je .check_for_mouse_buttons_state
 
; okay, minimize or restore top-most window and exit
mov eax, [TASK_COUNT]
1045,487 → 958,443
dec bl
jnz @f
call minimize_window
jmp .exit
jmp .check_for_mouse_buttons_state
@@: call restore_minimized_window
 
@@:
call restore_minimized_window
.check_for_mouse_buttons_state:
; do we have any mouse buttons pressed?
cmp byte[BTN_DOWN], 0
jne .mouse_buttons_pressed
 
.exit:
ret
mov [bPressedMouseXY_W], 0
jmp .exit
 
align 4
;------------------------------------------------------------------------------
sys_window_maximize_handler: ;/////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> esi = process slot
;------------------------------------------------------------------------------
mov edi, esi
shl edi, 5
add edi, window_data
.mouse_buttons_pressed:
; yes we do, iterate and ...
mov esi, [TASK_COUNT]
inc esi
 
; can window change its height?
; only types 2 and 3 can be resized
mov dl, [edi + WDATA.fl_wstyle]
test dl, 2
jz .exit
cmp [bPressedMouseXY_W], 1
ja .next_window
inc [bPressedMouseXY_W]
jnc .next_window
push dword[MOUSE_X]
pop dword[mx]
 
; toggle normal/maximized window state
mov bl, [edi + WDATA.fl_wstate]
xor bl, WSTATE_MAXIMIZED
.next_window:
cmp esi, 2
jb .exit
 
; calculate and set appropriate window bounds
test bl, WSTATE_MAXIMIZED
jz .restore_size
dec esi
 
mov eax, [screen_workarea.left]
mov ecx, [screen_workarea.top]
push [screen_workarea.bottom] \
[screen_workarea.right] \
ecx \
eax
sub [esp + BOX.width], eax
sub [esp + BOX.height], ecx
mov eax, esp
jmp .set_box
; is that window not minimized?
movzx edi, word[WIN_POS + esi * 2]
shl edi, 5
add edi, window_data
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .next_window
 
.restore_size:
mov eax, esi
shl eax, 8
add eax, SLOT_BASE + APPDATA.saved_box
push [eax + BOX.height] \
[eax + BOX.width] \
[eax + BOX.top] \
[eax + BOX.left]
mov eax, esp
movzx eax, [mx]
movzx ebx, [my]
 
.set_box:
test bl, WSTATE_ROLLEDUP
jz @f
; is the cursor inside screen bounds of that window?
mov ecx, [edi + WDATA.box.left]
mov edx, [edi + WDATA.box.top]
cmp eax, ecx
jl .next_window
cmp ebx, edx
jl .next_window
add ecx, [edi + WDATA.box.width]
add edx, [edi + WDATA.box.height]
cmp eax, ecx
jge .next_window
cmp ebx, edx
jge .next_window
 
xchg eax, ecx
call window._.get_rolledup_height
mov [ecx + BOX.height], eax
xchg eax, ecx
; is that a top-most (which means active) window?
cmp esi, [TASK_COUNT]
je .check_for_moving_or_resizing
 
@@:
call window._.set_window_box
add esp, sizeof.BOX
; no it's not, did we just press mouse button down above it or was it
; already pressed before?
cmp [bPressedMouseXY_W], 1
ja .exit
 
.exit:
ret
; okay, we just pressed the button, activate this window and exit
lea esi, [WIN_POS + esi * 2]
call waredraw
jmp .exit
 
align 4
;------------------------------------------------------------------------------
sys_window_rollup_handler: ;///////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> esi = process slot
;------------------------------------------------------------------------------
mov edx, esi
shl edx, 8
add edx, SLOT_BASE
.check_for_moving_or_resizing:
; is that window movable?
test byte[edi + WDATA.cl_titlebar + 3], 0x01
jnz .exit
 
; toggle normal/rolled up window state
mov bl, [edi + WDATA.fl_wstate]
xor bl, WSTATE_ROLLEDUP
; yes it is, is it rolled up?
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
jnz .check_for_cursor_on_caption
 
; calculate and set appropriate window bounds
test bl, WSTATE_ROLLEDUP
jz .restore_size
; no it's not, can it be resized then?
mov [do_resize_from_corner], 0
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
cmp dl, 0x00
je .check_for_cursor_on_caption
cmp dl, 0x01
je .check_for_cursor_on_caption
cmp dl, 0x04
je .check_for_cursor_on_caption
 
call window._.get_rolledup_height
push eax \
[edi + WDATA.box.width] \
[edi + WDATA.box.top] \
[edi + WDATA.box.left]
mov eax, esp
jmp .set_box
; are we going to resize it?
mov edx, [edi + WDATA.box.top]
add edx, [edi + WDATA.box.height]
sub edx, 6
cmp ebx, edx
jl .check_for_cursor_on_caption
 
.restore_size:
test bl, WSTATE_MAXIMIZED
jnz @f
add esp, -sizeof.BOX
lea eax, [edx + APPDATA.saved_box]
jmp .set_box
; yes we do, remember that
mov [do_resize_from_corner], 1
jmp .set_move_resize_flag
 
@@:
mov eax, [screen_workarea.top]
push [screen_workarea.bottom] \
[edi + WDATA.box.width] \
eax \
[edi + WDATA.box.left]
sub [esp + BOX.height], eax
mov eax, esp
.check_for_cursor_on_caption:
; is the cursor inside window titlebar?
push eax
call window._.get_titlebar_height
add eax, [edi + WDATA.box.top]
cmp ebx, eax
pop eax
jge .exit
 
.set_box:
call window._.set_window_box
add esp, sizeof.BOX
; calculate duration between two clicks
mov ecx, [timer_ticks]
mov edx, ecx
sub edx, [latest_window_touch]
mov [latest_window_touch], ecx
mov [latest_window_touch_delta], edx
 
ret
.set_move_resize_flag:
mov cl, [BTN_DOWN]
mov [do_resize], cl
 
align 4
;------------------------------------------------------------------------------
sys_window_start_moving_handler: ;/////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = old (original) window box
;> esi = process slot
;------------------------------------------------------------------------------
mov edi, eax
call window._.draw_negative_box
mov ecx, [edi + WDATA.box.left]
mov edx, [edi + WDATA.box.top]
 
ret
push ecx edx
mov [draw_limits.left], ecx
mov [draw_limits.top], edx
add ecx, [edi + WDATA.box.width]
add edx, [edi + WDATA.box.height]
mov [draw_limits.right], ecx
mov [draw_limits.bottom], edx
pop edx ecx
 
align 4
;------------------------------------------------------------------------------
sys_window_end_moving_handler: ;///////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = old (original) window box
;> ebx = new (final) window box
;> esi = process slot
;------------------------------------------------------------------------------
mov edi, ebx
call window._.end_moving__box
; calculate window-relative cursor coordinates
sub eax, ecx
sub ebx, edx
 
mov edi, esi
shl edi, 5
add edi, window_data
push dword[MOUSE_X]
pop dword[WIN_TEMP_XY]
 
mov eax, ebx
mov bl, [edi + WDATA.fl_wstate]
call window._.set_window_box
ret
; save old window coordinates
push eax
mov eax, [edi + WDATA.box.left]
mov [old_window_pos.left], eax
mov [new_window_pos.left], eax
mov eax, [edi + WDATA.box.top]
mov [old_window_pos.top], eax
mov [new_window_pos.top], eax
mov eax, [edi + WDATA.box.width]
mov [old_window_pos.width], eax
mov [new_window_pos.width], eax
mov eax, [edi + WDATA.box.height]
mov [old_window_pos.height], eax
mov [new_window_pos.height], eax
pop eax
 
align 4
;------------------------------------------------------------------------------
sys_window_moving_handler: ;///////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = old (from previous call) window box
;> ebx = new (current) window box
;> esi = process_slot
;------------------------------------------------------------------------------
mov edi, eax
call window._.draw_negative_box
mov edi, ebx
call window._.draw_negative_box
ret
; draw negative moving/sizing frame
call window._.draw_window_frames
 
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
mov [reposition], 0
mov byte[MOUSE_DOWN], 1
 
iglobal
FuncTable syscall_display_settings, ftable, \
00, 01, 02, 03, 04, 05, 06, 07, 08
.next_mouse_state_check:
; process OS events
mov byte[DONT_DRAW_MOUSE], 1
call checkidle
call checkVga_N13
mov byte[MOUSE_BACKGROUND], 0
call [draw_pointer]
pushad
call stack_handler
popad
 
align 4
window_topleft dd \
1, 21, \ ;type 0
0, 0, \ ;type 1
5, 20, \ ;type 2
5, ?, \ ;type 3 {set by skin}
5, ? ;type 4 {set by skin}
endg
; did cursor position change?
mov esi, [WIN_TEMP_XY]
cmp esi, [MOUSE_X]
je .check_for_new_mouse_buttons_state
 
;uglobal
; NOTE: commented out since doesn't provide necessary functionality anyway,
; to be reworked
; new_window_starting dd ?
;endg
; yes it did, calculate window-relative cursor coordinates
movzx ecx, word[MOUSE_X]
movzx edx, word[MOUSE_Y]
sub ecx, eax
sub edx, ebx
 
align 4
;------------------------------------------------------------------------------
window._.invalidate_screen: ;//////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = old (original) window box
;> ebx = new (final) window box
;> edi = pointer to WDATA struct
;------------------------------------------------------------------------------
push eax ebx
 
; TODO: do we really need `draw_limits`?
; Yes, they are used by background drawing code.
mov ecx, [eax + BOX.left]
mov edx, [ebx + BOX.left]
cmp ecx, edx
jle @f
mov ecx, edx
@@:
mov [draw_limits.left], ecx
mov ecx, [eax + BOX.left]
add ecx, [eax + BOX.width]
add edx, [ebx + BOX.width]
cmp ecx, edx
jae @f
mov ecx, edx
@@:
mov [draw_limits.right], ecx
mov ecx, [eax + BOX.top]
mov edx, [ebx + BOX.top]
cmp ecx, edx
jle @f
mov ecx, edx
@@:
mov [draw_limits.top], ecx
mov ecx, [eax + BOX.top]
add ecx, [eax + BOX.height]
add edx, [ebx + BOX.height]
cmp ecx, edx
jae @f
mov ecx, edx
@@:
mov [draw_limits.bottom], ecx
; we're going to draw new frame, erasing the old one
call window._.draw_window_frames
 
; recalculate screen buffer at old position
push ebx
mov edx, [eax + BOX.height]
mov ecx, [eax + BOX.width]
mov ebx, [eax + BOX.top]
mov eax, [eax + BOX.left]
add ecx, eax
add edx, ebx
call calculatescreen
pop eax
; are we moving it right now?
cmp [do_resize_from_corner], 0
jne .resize_window
 
; recalculate screen buffer at new position
mov edx, [eax + BOX.height]
mov ecx, [eax + BOX.width]
mov ebx, [eax + BOX.top]
mov eax, [eax + BOX.left]
add ecx, eax
add edx, ebx
call calculatescreen
; yes we do, check if it's inside the screen area
mov eax, [Screen_Max_X]
mov ebx, [Screen_Max_Y]
 
mov eax, edi
call redrawscreen
mov [new_window_pos.left], 0
or ecx, ecx
jle .check_for_new_vert_cursor_pos
mov [reposition], 1
sub eax, [new_window_pos.width]
mov [new_window_pos.left], eax
cmp ecx, eax
jge .check_for_new_vert_cursor_pos
mov [new_window_pos.left], ecx
 
; tell window to redraw itself
mov [edi + WDATA.fl_redraw], 1
.check_for_new_vert_cursor_pos:
mov [new_window_pos.top], 0
or edx, edx
jle .draw_new_window_frame
mov [reposition], 1
sub ebx, [new_window_pos.height]
mov [new_window_pos.top], ebx
cmp edx, ebx
jge .draw_new_window_frame
mov [new_window_pos.top], edx
jmp .draw_new_window_frame
 
pop ebx eax
ret
.resize_window:
push eax ebx edx
 
align 4
;------------------------------------------------------------------------------
window._.set_window_box: ;/////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = pointer to BOX struct
;> bl = new window state flags
;> edi = pointer to WDATA struct
;------------------------------------------------------------------------------
push eax ebx esi
mov edx, edi
sub edx, window_data
lea edx, [SLOT_BASE + edx * 8]
 
; don't do anything if the new box is identical to the old
cmp bl, [edi + WDATA.fl_wstate]
jnz @f
mov esi, eax
push edi
if WDATA.box
add edi, WDATA.box
end if
mov ecx, 4
repz cmpsd
pop edi
jz .exit
@@:
movzx eax, word[MOUSE_X]
cmp eax, [edi + WDATA.box.left]
jb .fix_new_vert_size
sub eax, [edi + WDATA.box.left]
cmp eax, 32
jge @f
mov eax, 32
@@: mov [new_window_pos.width], eax
 
add esp, -sizeof.BOX
 
mov ebx, esp
if WDATA.box
lea esi, [edi + WDATA.box]
else
mov esi, edi ; optimization for WDATA.box = 0
end if
xchg eax, esi
mov ecx, sizeof.BOX
call memmove
xchg eax, esi
xchg ebx, esi
call memmove
.fix_new_vert_size:
call window._.get_rolledup_height
mov ebx, eax
movzx eax, word[MOUSE_Y]
cmp eax, [edi + WDATA.box.top]
jb .set_reposition_flag
sub eax, [edi + WDATA.box.top]
cmp eax, ebx
jge @f
mov eax, ebx
mov ebx, esi
@@: mov [new_window_pos.height], eax
 
call window._.check_window_position
call window._.set_window_clientbox
call window._.invalidate_screen
.set_reposition_flag:
mov [reposition], 1
 
add esp, sizeof.BOX
pop edx ebx eax
 
mov cl, [esp + 4]
mov ch, cl
xchg cl, [edi + WDATA.fl_wstate]
.draw_new_window_frame:
pop ebx eax
 
or cl, ch
test cl, WSTATE_MAXIMIZED
jnz .exit
; draw new window moving/sizing frame
call window._.draw_window_frames
 
mov eax, edi
sub eax, window_data
shl eax, 3
add eax, SLOT_BASE
mov esi, [MOUSE_X]
mov [WIN_TEMP_XY], esi
 
lea ebx, [edi + WDATA.box]
xchg esp, ebx
.check_for_new_mouse_buttons_state:
; did user release mouse button(s)?
cmp byte[BTN_DOWN], 0
jne .next_mouse_state_check
 
pop [eax + APPDATA.saved_box.left] \
[eax + APPDATA.saved_box.top] \
[eax + APPDATA.saved_box.width] \
edx
; yes he did, moving/sizing is over
mov byte[DONT_DRAW_MOUSE], 1
mov cl, 0
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jnz .check_other_actions
 
xchg esp, ebx
mov cl, [reposition]
 
test ch, WSTATE_ROLLEDUP
jnz .exit
; draw negative frame once again to hide it
call window._.draw_window_frames
 
mov [eax + APPDATA.saved_box.height], edx
; save new window bounds
mov eax, [new_window_pos.left]
mov [edi + WDATA.box.left], eax
mov eax, [new_window_pos.top]
mov [edi + WDATA.box.top], eax
mov eax, [new_window_pos.width]
mov [edi + WDATA.box.width], eax
mov eax, [new_window_pos.height]
mov [edi + WDATA.box.height], eax
call set_window_clientbox
 
.exit:
pop esi ebx eax
ret
cmp cl, 1
jne .check_other_actions
push esi edi ecx
mov esi, edi
mov ecx, 2
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP or WSTATE_MAXIMIZED
jnz @f
add ecx, 2
@@: sub edi, window_data
shr edi, 5
shl edi, 8
add edi, SLOT_BASE + APPDATA.saved_box
cld
rep movsd
pop ecx edi esi
 
align 4
;------------------------------------------------------------------------------
window._.set_window_clientbox: ;///////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> edi = pointer to WDATA struct
;------------------------------------------------------------------------------
push eax ecx edi
.check_other_actions:
mov [reposition], cl
 
mov eax, [_skinh]
mov [window_topleft + 8 * 3 + 4], eax
mov [window_topleft + 8 * 4 + 4], eax
pushad
 
mov ecx, edi
sub edi, window_data
shl edi, 3
test [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE
jz .whole_window
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
cmp dl, 0x00
je .check_if_window_fits_screen
cmp dl, 0x01
je .check_if_window_fits_screen
 
movzx eax, [ecx + WDATA.fl_wstyle]
and eax, 0x0F
mov eax, [eax * 8 + window_topleft + 0]
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
shl eax, 1
neg eax
add eax, [ecx + WDATA.box.width]
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
cmp cl, 1
je .no_window_sizing
mov edx, edi
sub edx, window_data
shr edx, 5
shl edx, 8
add edx, SLOT_BASE
 
movzx eax, [ecx + WDATA.fl_wstyle]
and eax, 0x0F
push [eax * 8 + window_topleft + 0]
mov eax, [eax * 8 + window_topleft + 4]
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
neg eax
sub eax, [esp]
add eax, [ecx + WDATA.box.height]
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
add esp, 4
jmp .exit
; did we right-click on titlebar?
cmp [do_resize], 2
jne .check_maximization_request
 
.whole_window:
xor eax, eax
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax
mov eax, [ecx + WDATA.box.width]
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax
mov eax, [ecx + WDATA.box.height]
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax
; yes we did, toggle normal/rolled up window state
xor [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
mov [reposition], 1
 
.exit:
pop edi ecx eax
ret
; calculate and set appropriate window height
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
jz @f
call window._.get_rolledup_height
jmp .set_new_window_height
@@: mov eax, [edx + APPDATA.saved_box.height]
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jz .set_new_window_height
mov eax, [screen_workarea.bottom]
sub eax, [screen_workarea.top]
 
align 4
;------------------------------------------------------------------------------
window._.sys_set_window: ;/////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;< edx = pointer to WDATA struct
;------------------------------------------------------------------------------
mov eax, [CURRENT_TASK]
shl eax, 5
add eax, window_data
.set_new_window_height:
mov [edi + WDATA.box.height], eax
add eax, [edi + WDATA.box.top]
cmp eax, [Screen_Max_Y]
jbe @f
mov eax, [Screen_Max_Y]
sub eax, [edi + WDATA.box.height]
mov [edi + WDATA.box.top], eax
@@: call check_window_position
call set_window_clientbox
 
; save window colors
mov [eax + WDATA.cl_workarea], edx
mov [eax + WDATA.cl_titlebar], esi
mov [eax + WDATA.cl_frames], edi
.check_maximization_request:
; can window change its height?
push edx
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
cmp dl, 0x04
pop edx
je .check_if_window_fits_screen
 
mov edi, eax
; was it really a maximize/restore request?
cmp [do_resize], 1
jne .check_if_window_fits_screen
cmp [do_resize_from_corner], 0
jne .check_if_window_fits_screen
cmp [latest_window_touch_delta], 50
jg .check_if_window_fits_screen
 
; was it already defined before?
test [edi + WDATA.fl_wdrawn], 1
jnz .set_client_box
or [edi + WDATA.fl_wdrawn], 1
; yes is was, toggle normal/maximized window state
xor [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
mov [reposition], 1
 
; NOTE: commented out since doesn't provide necessary functionality
; anyway, to be reworked
; mov eax, [timer_ticks] ; [0xfdf0]
; add eax, 100
; mov [new_window_starting], eax
 
; no it wasn't, performing initial window definition
movzx eax, bx
; calculate and set appropriate window bounds
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jz .restore_normal_window_size
mov eax, [screen_workarea.left]
mov [edi + WDATA.box.left], eax
sub eax, [screen_workarea.right]
neg eax
mov [edi + WDATA.box.width], eax
movzx eax, cx
mov eax, [screen_workarea.top]
mov [edi + WDATA.box.top], eax
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
jnz .calculate_window_client_area
sub eax, [screen_workarea.bottom]
neg eax
mov [edi + WDATA.box.height], eax
sar ebx, 16
sar ecx, 16
mov [edi + WDATA.box.left], ebx
mov [edi + WDATA.box.top], ecx
jmp .calculate_window_client_area
 
call window._.check_window_position
.restore_normal_window_size:
push [edi + WDATA.box.height]
push edi
lea esi, [edx + APPDATA.saved_box]
mov ecx, 4
cld
rep movsd
pop edi
pop eax
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
jz .calculate_window_client_area
mov [edi + WDATA.box.height], eax
 
push ecx edi
.calculate_window_client_area:
call set_window_clientbox
 
mov cl, [edi + WDATA.fl_wstyle]
mov eax, [edi + WDATA.cl_frames]
.check_if_window_fits_screen:
; does window fit into screen area?
mov eax, [edi + WDATA.box.top]
add eax, [edi + WDATA.box.height]
cmp eax, [Screen_Max_Y]
jbe .no_window_sizing
mov eax, [edi + WDATA.box.left]
add eax, [edi + WDATA.box.width]
cmp eax, [Screen_Max_X]
jbe .no_window_sizing
 
sub edi, window_data
shl edi, 3
add edi, SLOT_BASE
; no it doesn't, fix that
mov eax, [Screen_Max_X]
sub eax, [edi + WDATA.box.width]
mov [edi + WDATA.box.left], eax
mov eax, [Screen_Max_Y]
sub eax, [edi + WDATA.box.height]
mov [edi + WDATA.box.top], eax
call set_window_clientbox
 
and cl, 0x0F
cmp cl, 3
je @f
cmp cl, 4
je @f
.no_window_sizing:
popad
 
xor eax, eax
; did somethins actually change its place?
cmp [reposition], 0
je .reset_vars
 
@@:
mov [edi + APPDATA.wnd_caption], eax
mov byte[DONT_DRAW_MOUSE], 1
 
mov esi, [esp]
add edi, APPDATA.saved_box
movsd
movsd
movsd
movsd
push eax ebx ecx edx
 
pop edi ecx
 
mov esi, [CURRENT_TASK]
movzx esi, word[WIN_STACK + esi * 2]
lea esi, [WIN_POS + esi * 2]
call waredraw
 
; recalculate screen buffer at new position
mov eax, [edi + WDATA.box.left]
mov ebx, [edi + WDATA.box.top]
mov ecx, [edi + WDATA.box.width]
1534,98 → 1403,50
add edx, ebx
call calculatescreen
 
mov byte[KEY_COUNT], 0 ; empty keyboard buffer
mov byte[BTN_COUNT], 0 ; empty button buffer
; recalculate screen buffer at old position
mov eax, [old_window_pos.left]
mov ebx, [old_window_pos.top]
mov ecx, [old_window_pos.width]
mov edx, [old_window_pos.height]
add ecx, eax
add edx, ebx
call calculatescreen
 
.set_client_box:
; update window client box coordinates
call window._.set_window_clientbox
pop edx ecx ebx eax
 
; reset window redraw flag and exit
mov [edi + WDATA.fl_redraw], 0
mov edx, edi
ret
mov eax, edi
call redrawscreen
 
align 4
;------------------------------------------------------------------------------
window._.check_window_position: ;//////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Check if window is inside screen area
;------------------------------------------------------------------------------
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
push eax ebx ecx edx esi
; tell window to redraw itself
mov [edi + WDATA.fl_redraw], 1
 
mov eax, [edi + WDATA.box.left]
mov ebx, [edi + WDATA.box.top]
mov ecx, [edi + WDATA.box.width]
mov edx, [edi + WDATA.box.height]
; wait a bit for window to redraw itself
mov ecx, 100
 
mov esi, [Screen_Max_X]
cmp ecx, esi
ja .fix_width_high
.next_idle_cycle:
mov byte[DONT_DRAW_MOUSE], 1
call checkidle
cmp [edi + WDATA.fl_redraw], 0
jz .reset_vars
loop .next_idle_cycle
 
.check_left:
or eax, eax
jl .fix_left_low
add eax, ecx
cmp eax, esi
jg .fix_left_high
.reset_vars:
mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer
mov byte[MOUSE_BACKGROUND], 0 ; no mouse under
mov byte[MOUSE_DOWN], 0 ; react to mouse up/down
 
.check_height:
mov esi, [Screen_Max_Y]
cmp edx, esi
ja .fix_height_high
 
.check_top:
or ebx, ebx
jl .fix_top_low
add ebx, edx
cmp ebx, esi
jg .fix_top_high
 
.exit:
pop esi edx ecx ebx eax
popad
ret
 
.fix_width_high:
mov ecx, esi
mov [edi + WDATA.box.width], esi
jmp .check_left
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
 
.fix_left_low:
xor eax, eax
mov [edi + WDATA.box.left], eax
jmp .check_height
 
.fix_left_high:
mov eax, esi
sub eax, ecx
mov [edi + WDATA.box.left], eax
jmp .check_height
 
.fix_height_high:
mov edx, esi
mov [edi + WDATA.box.height], esi
jmp .check_top
 
.fix_top_low:
xor ebx, ebx
mov [edi + WDATA.box.top], ebx
jmp .exit
 
.fix_top_high:
mov ebx, esi
sub ebx, edx
mov [edi + WDATA.box.top], ebx
jmp .exit
 
align 4
;------------------------------------------------------------------------------
window._.get_titlebar_height: ;////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
mov al, [edi + WDATA.fl_wstyle]
1634,8 → 1455,7
jne @f
mov eax, [_skinh]
ret
@@:
mov eax, 21
@@: mov eax, 21
ret
 
align 4
1642,8 → 1462,6
;------------------------------------------------------------------------------
window._.get_rolledup_height: ;////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
mov al, [edi + WDATA.fl_wstyle]
1653,13 → 1471,11
mov eax, [_skinh]
add eax, 3
ret
@@:
or al, al
@@: or al, al
jnz @f
mov eax, 21
ret
@@:
mov eax, 21 + 2
@@: mov eax, 21 + 2
ret
 
align 4
1806,8 → 1622,7
mov eax, esi
mov [ebp], al
; -- end body --
@@:
inc ebp
@@: inc ebp
inc edx
cmp edx, [ff_xsz]
jb .ff_new_x
1849,9 → 1664,6
 
; if type of current active window is 3 or 4, it must be redrawn
mov ebx, [TASK_COUNT]
; DEBUGF 1, "K : TASK_COUNT (0x%x)\n", ebx
movzx ebx, word[WIN_POS + ebx * 2]
shl ebx, 5
add eax, window_data
1878,13 → 1690,6
cmp eax, [TASK_COUNT]
jae .move_self_up
inc eax
; push ebx
; xor ebx,ebx
; mov bx,[WIN_STACK + eax * 2]
; DEBUGF 1, "K : DEC WIN_STACK (0x%x)\n",ebx
; pop ebx
cmp [WIN_STACK + eax * 2], bx
jbe .next_stack_window
dec word[WIN_STACK + eax * 2]
1917,53 → 1722,6
pop ebx eax
ret
 
;------------------------------------------------------------------------------
window._.window_deactivate: ;////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Deactivate window
;------------------------------------------------------------------------------
;> esi = pointer to WIN_POS+ window data
;------------------------------------------------------------------------------
push eax ebx
;------------------------------------------------------------------------------
.move_others_up:
; ax <- process no
movzx ebx, word[esi]
; ax <- position in window stack
movzx ebx, word[WIN_STACK + ebx * 2]
; up others
xor eax, eax
.next_stack_window:
cmp eax, [TASK_COUNT]
jae .move_self_down
inc eax
cmp [WIN_STACK + eax * 2], bx
jae .next_stack_window
inc word[WIN_STACK + eax * 2]
jmp .next_stack_window
;----------------------------------------------
.move_self_down:
movzx ebx, word[esi]
; this is the last (and the low)
mov [WIN_STACK + ebx * 2], word 1
; update on screen - window stack
xor eax, eax
.next_window_pos:
cmp eax, [TASK_COUNT]
jae .reset_vars
inc eax
movzx ebx, word[WIN_STACK + eax * 2]
mov [WIN_POS + ebx * 2], ax
jmp .next_window_pos
;-----------------------------------------------
.reset_vars:
mov byte[KEY_COUNT], 0
mov byte[BTN_COUNT], 0
mov word[MOUSE_SCROLL_H], 0
mov word[MOUSE_SCROLL_V], 0
pop ebx eax
ret
;------------------------------------------------------------------------------
align 4
;------------------------------------------------------------------------------
window._.check_window_draw: ;//////////////////////////////////////////////////
1974,9 → 1732,9
;------------------------------------------------------------------------------
mov cl, [edi + WDATA.fl_wstyle]
and cl, 0x0f
cmp cl, 3
cmp cl, 0x03
je .exit.redraw ; window type 3
cmp cl, 4
cmp cl, 0x04
je .exit.redraw ; window type 4
 
push eax ebx edx esi
1985,6 → 1743,8
sub eax, window_data
shr eax, 5
 
; esi = process number
 
movzx eax, word[WIN_STACK + eax * 2] ; get value of the curr process
lea esi, [WIN_POS + eax * 2] ; get address of this process at 0xC400
 
2038,180 → 1798,49
 
align 4
;------------------------------------------------------------------------------
window._.draw_window_caption: ;////////////////////////////////////////////////
window._.draw_window_frames: ;/////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;? Draw negative window frames
;------------------------------------------------------------------------------
inc [mouse_pause]
call [_display.disable_mouse]
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
push eax
cli
 
xor eax, eax
mov edx, [TASK_COUNT]
movzx edx, word[WIN_POS + edx * 2]
cmp edx, [CURRENT_TASK]
jne @f
inc eax
@@:
mov edx, [CURRENT_TASK]
shl edx, 5
add edx, window_data
movzx ebx, [edx + WDATA.fl_wstyle]
and bl, 0x0F
cmp bl, 3
je .draw_caption_style_3
cmp bl, 4
je .draw_caption_style_3
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jnz .exit
mov eax, [new_window_pos.left]
cmp eax, [edi + WDATA.box.left]
jnz .draw
mov eax, [new_window_pos.width]
cmp eax, [edi + WDATA.box.width]
jnz .draw
mov eax, [new_window_pos.top]
cmp eax, [edi + WDATA.box.top]
jnz .draw
mov eax, [new_window_pos.height]
cmp eax, [edi + WDATA.box.height]
jnz .draw
xor [edi + WDATA.fl_wdrawn], 2
 
jmp .not_style_3
 
.draw_caption_style_3:
push edx
call drawwindow_IV_caption
add esp, 4
jmp .2
 
.not_style_3:
cmp bl, 2
jne .not_style_2
 
call drawwindow_III_caption
jmp .2
 
.not_style_2:
cmp bl, 0
jne .2
 
call drawwindow_I_caption
 
.2:
mov edi, [CURRENT_TASK]
shl edi, 5
test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION
jz .exit
mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption]
or edx, edx
jz .exit
 
movzx eax, [edi + window_data + WDATA.fl_wstyle]
and al, 0x0F
cmp al, 3
je .skinned
cmp al, 4
je .skinned
 
jmp .not_skinned
 
.skinned:
mov ebp, [edi + window_data + WDATA.box.left - 2]
mov bp, word[edi + window_data + WDATA.box.top]
movzx eax, word[edi + window_data + WDATA.box.width]
sub ax, [_skinmargins.left]
sub ax, [_skinmargins.right]
push edx
cwde
cdq
mov ebx, 6
idiv ebx
pop edx
or eax, eax
js .exit
 
mov esi, eax
mov ebx, dword[_skinmargins.left - 2]
mov bx, word[_skinh]
sub bx, [_skinmargins.bottom]
sub bx, [_skinmargins.top]
sar bx, 1
adc bx, 0
add bx, [_skinmargins.top]
add bx, -3
add ebx, ebp
jmp .dodraw
 
.not_skinned:
cmp al, 1
je .exit
 
mov ebp, [edi + window_data + WDATA.box.left - 2]
mov bp, word[edi + window_data + WDATA.box.top]
movzx eax, word[edi + window_data + WDATA.box.width]
sub eax, 16
push edx
cwde
cdq
mov ebx, 6
idiv ebx
pop edx
or eax, eax
js .exit
 
mov esi, eax
mov ebx, 0x00080007
add ebx, ebp
 
.dodraw:
mov ecx, [common_colours + 16]
or ecx, 0x80000000
xor edi, edi
call dtext_asciiz_esi
 
.exit:
dec [mouse_pause]
call [draw_pointer]
ret
 
align 4
;------------------------------------------------------------------------------
window._.draw_negative_box: ;//////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Draw negative box
;------------------------------------------------------------------------------
;> edi = pointer to BOX struct
;------------------------------------------------------------------------------
push eax ebx esi
.draw:
push ebx esi
mov eax, [new_window_pos.left - 2]
mov ax, word[new_window_pos.left]
add ax, word[new_window_pos.width]
mov ebx, [new_window_pos.top - 2]
mov bx, word[new_window_pos.top]
add bx, word[new_window_pos.height]
mov esi, 0x01000000
.1:
mov eax, [edi + BOX.left - 2]
mov ax, word[edi + BOX.left]
add ax, word[edi + BOX.width]
mov ebx, [edi + BOX.top - 2]
mov bx, word[edi + BOX.top]
add bx, word[edi + BOX.height]
call draw_rectangle.forced
pop esi ebx eax
ret
;------------------------------------------------------------------------------
window._.end_moving__box: ;//////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Draw positive box
;------------------------------------------------------------------------------
;> edi = pointer to BOX struct
;------------------------------------------------------------------------------
push eax ebx esi
xor esi, esi
jmp window._.draw_negative_box.1
pop esi ebx
 
 
;------------------------------------------------------------------------------
window._.get_rect: ;/////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description> void __fastcall get_window_rect(struct RECT* rc);
;------------------------------------------------------------------------------
;> ecx = pointer to RECT
;------------------------------------------------------------------------------
mov eax, [TASK_BASE]
 
mov edx, [eax-twdw + WDATA.box.left]
mov [ecx+RECT.left], edx
 
add edx, [eax-twdw + WDATA.box.width]
mov [ecx+RECT.right], edx
 
mov edx, [eax-twdw + WDATA.box.top]
mov [ecx+RECT.top], edx
 
add edx, [eax-twdw + WDATA.box.height]
mov [ecx+RECT.bottom], edx
 
.exit:
sti
pop eax
ret
 
.forced:
push eax
cli
jmp .draw
/kernel/branches/net/kernel.asm
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved.
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved.
;; PROGRAMMING:
;; Ivan Poddubny
;; Marat Zakiyanov (Mario79)
19,17 → 19,6
;; SPraid (simba)
;; Hidnplayr
;; Alexey Teplov (<Lrz>)
;; Rus
;; Nable
;; shurf
;; Alver
;; Maxis
;; Galkov
;; CleverMouse
;; tsdima
;; turbanoff
;; Asper
;; art_zh
;;
;; Data in this file was originally part of MenuetOS project which is
;; distributed under the terms of GNU GPL. It is modified and redistributed as
75,11 → 64,11
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
 
; 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
 
include "proc32.inc"
include "kglobals.inc"
include "lang.inc"
lang fix en
 
include "const.inc"
max_processes equ 255
172,20 → 161,17
mov al, 255 ; mask all irqs
out 0xa1, al
out 0x21, al
l.5:
in al, 0x64 ; Enable A20
l.5: in al, 0x64 ; Enable A20
test al, 2
jnz l.5
mov al, 0xD1
out 0x64, al
l.6:
in al, 0x64
l.6: in al, 0x64
test al, 2
jnz l.6
mov al, 0xDF
out 0x60, al
l.7:
in al, 0x64
l.7: in al, 0x64
test al, 2
jnz l.7
mov al, 0xFF
230,27 → 216,29
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 0x006CC00 ; Set stack
mov esp,0x3ec00 ; Set stack
 
; CLEAR 0x280000 - HEAP_BASE
 
xor eax, eax
mov edi, CLEAN_ZONE
mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4
mov edi,0x280000
mov ecx,(HEAP_BASE-OS_BASE-0x280000) / 4
cld
rep stosd
 
mov edi,0x40000
mov ecx,(0x90000-0x40000)/4
rep stosd
 
; CLEAR KERNEL UNDEFINED GLOBALS
mov edi, endofcode-OS_BASE
mov ecx, 0x90000
sub ecx, edi
shr ecx, 2
mov ecx, (uglobals_size/4)+4
rep stosd
 
; SAVE & CLEAR 0-0xffff
 
xor esi, esi
mov edi, (BOOT_VAR-OS_BASE)
mov edi,0x2F0000
mov ecx, 0x10000 / 4
rep movsd
mov edi, 0x1000
260,7 → 248,6
call test_cpu
bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc
 
call check_acpi
call init_BIOS32
; MEMORY MODEL
call mem_test
324,12 → 311,6
mov eax, cr3
mov cr3, eax ; flush TLB
 
mov ecx, pg_data.mutex
call mutex_init
 
mov ecx, disk_list_mutex
call mutex_init
 
; SAVE REAL MODE VARIABLES
mov ax, [BOOT_VAR + 0x9031]
mov [IDEContrRegsBaseAddr], ax
570,6 → 551,11
mov [srv.fd], eax
mov [srv.bk], eax
 
mov edi, irq_tab
xor eax, eax
mov ecx, 16
rep stosd
 
;Set base of graphic segment to linear address of LFB
mov eax, [LFBAddress] ; set for gs
mov [graph_data_l+2], ax
599,34 → 585,29
 
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
 
call init_irqs
call PIC_init
call rerouteirqs
 
; Initialize system V86 machine
call init_sys_v86
 
; Initialize system timer (IRQ0)
call PIT_init
; TIMER SET TO 1/100 S
 
; Try to Initialize APIC
call APIC_init
mov al,0x34 ; set to 100Hz
out 0x43,al
mov al,0x9b ; lsb 1193180 / 1193
out 0x40,al
mov al,0x2e ; msb
out 0x40,al
 
; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15)
; they are used: when partitions are scanned, hd_read relies on timer
call unmask_timer
stdcall enable_irq, 2 ; @#$%! PIC
stdcall enable_irq, 6 ; FDD
stdcall enable_irq, 13 ; co-processor
stdcall enable_irq, 14
stdcall enable_irq, 15
; Also enable IRQ2, because in some configurations
; IRQs from slave controller are not delivered until IRQ2 on master is enabled
mov al, 0xFA
out 0x21, al
mov al, 0x3F
out 0xA1, al
 
; Enable interrupts in IDE controller
mov al, 0
mov dx, 0x3F6
out dx, al
mov dl, 0x76
out dx, al
 
;!!!!!!!!!!!!!!!!!!!!!!!!!!
include 'detect/disks.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!!!
633,19 → 614,22
 
call Parser_params
 
if ~ defined extended_primary_loader
; ramdisk image should be loaded by extended primary loader if it exists
; READ RAMDISK IMAGE FROM HD
 
;!!!!!!!!!!!!!!!!!!!!!!!
include 'boot/rdload.inc'
;!!!!!!!!!!!!!!!!!!!!!!!
end if
; mov [dma_hdd],1
; CALCULATE FAT CHAIN FOR RAMDISK
 
call calculatefatchain
 
; LOAD VMODE DRIVER
 
;!!!!!!!!!!!!!!!!!!!!!!!
include 'vmodeld.inc'
;!!!!!!!!!!!!!!!!!!!!!!!
 
if 0
mov ax, [OS_BASE+0x10000+bx_from_load]
cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba}
665,23 → 649,12
mov esi, boot_fonts
call boot_log
 
; Display APIC status
mov esi, boot_APIC_found
cmp [irq_mode], IRQ_APIC
je @f
mov esi, boot_APIC_nfound
@@:
 
; PRINT AMOUNT OF MEMORY
mov esi, boot_memdetect
call boot_log
 
movzx ecx, word [boot_y]
if lang eq ru
or ecx, (10+30*6) shl 16
else
or ecx, (10+29*6) shl 16
end if
or ecx, (10+29*6) shl 16 ; "Determining amount of memory"
sub ecx, 10
mov edx, 0xFFFFFF
mov ebx, [MEM_AMOUNT]
720,6 → 693,12
call boot_log
call reserve_irqs_ports
 
; SET PORTS FOR IRQ HANDLERS
 
mov esi,boot_setrports
call boot_log
;call setirqreadports
 
; SET UP OS TASK
 
mov esi, boot_setostask
800,11 → 779,7
 
mov ebx, edx
movzx ecx, word [boot_y]
if lang eq ru
add ecx, (10+19*6) shl 16 - 10 ; 'Determining amount of memory'
else
add ecx, (10+17*6) shl 16 - 10 ; 'Determining amount of memory'
end if
add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is '
mov edx, 0xFFFFFF
xor edi, edi
mov eax, 0x00040000
815,6 → 790,17
 
call set_variables
 
; SET MOUSE
 
;call detect_devices
stdcall load_driver, szPS2MDriver
; stdcall load_driver, szCOM_MDriver
 
mov esi,boot_setmouse
call boot_log
call setmouse
 
 
; STACK AND FDC
 
call stack_init
852,23 → 838,21
stdcall map_page, tss._io_map_1, \
[SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
 
mov ax, [OS_BASE+0x10000+bx_from_load]
 
; LOAD FIRST APPLICATION
cli
 
; cmp byte [BOOT_VAR+0x9030],1
; jne no_load_vrr_m
cmp byte [BOOT_VAR+0x9030],1
jne no_load_vrr_m
 
; mov ebp, vrr_m
; call fs_execute_from_sysdir
;
;; cmp eax,2 ; if vrr_m app found (PID=2)
; sub eax,2
; jz first_app_found
;
;no_load_vrr_m:
mov ebp, vrr_m
call fs_execute_from_sysdir
 
; cmp eax,2 ; if vrr_m app found (PID=2)
sub eax,2
jz first_app_found
 
no_load_vrr_m:
 
mov ebp, firstapp
call fs_execute_from_sysdir
 
901,7 → 885,7
and al, 00000010b
loopnz @b
 
; mov al, 0xED ; Keyboard LEDs - only for testing!
; mov al, 0xED ; svetodiody - only for testing!
; call kb_write
; call kb_read
; mov al, 111b
917,17 → 901,8
;// mike.dld [
call set_lights
;// mike.dld ]
stdcall attach_int_handler, 1, irq1, 0
 
; SET MOUSE
 
stdcall load_driver, szPS2MDriver
; stdcall load_driver, szCOM_MDriver
 
mov esi, boot_setmouse
call boot_log
call setmouse
 
; Setup serial output console (if enabled)
 
if defined debug_com_base
971,16 → 946,39
 
; START MULTITASKING
 
; A 'All set - press ESC to start' messages if need
if preboot_blogesc
mov esi, boot_tasking
call boot_log
.bll1:
in al, 0x60 ; wait for ESC key press
.bll1: in al, 0x60 ; wait for ESC key press
cmp al, 129
jne .bll1
end if
 
; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled
 
; UNMASK ALL IRQ'S
 
mov esi,boot_allirqs
call boot_log
 
cli ;guarantee forbidance of interrupts.
mov al,0 ; unmask all irq's
out 0xA1,al
out 0x21,al
 
mov ecx,32
 
ready_for_irqs:
 
mov al,0x20 ; ready for irqs
out 0x20,al
out 0xa0,al
 
loop ready_for_irqs ; flush the queue
 
stdcall attach_int_handler, dword 1, irq1, dword 0
 
; mov [dma_hdd],1
cmp [IDEContrRegsBaseAddr], 0
setnz [dma_hdd]
mov [timer_ticks_enable], 1 ; for cd driver
990,6 → 988,7
 
jmp osloop
 
; jmp $ ; wait here for timer to take control
 
; Fly :)
 
1024,8 → 1023,9
align 32
osloop:
call [draw_pointer]
call window_check_events
call mouse_check_events
call check_buttons
call checkwindows
; call check_window_move_request
call checkmisc
call checkVga_N13
call stack_handler
1032,7 → 1032,6
call checkidle
call check_fdd_motor_status
call check_ATAPI_device_event
call check_timers
jmp osloop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;
1090,32 → 1089,59
 
reserve_irqs_ports:
 
push eax
xor eax,eax
inc eax
mov byte [irq_owner+4*0],al ;1 ; timer
;mov [irq_owner+4*1], 1 ; keyboard
mov byte [irq_owner+4*6],al ;1 ; floppy diskette
mov byte [irq_owner+4*13],al ;1 ; math co-pros
mov byte [irq_owner+4*14],al ;1 ; ide I
mov byte [irq_owner+4*15],al ;1 ; ide II
pop eax
 
; RESERVE PORTS
mov eax, RESERVED_PORTS
mov ecx, 1
push 4
pop dword [RESERVED_PORTS] ;,edi
 
mov [eax], dword 4
push 1
pop dword [RESERVED_PORTS+16+0] ;,dword 1
and dword [RESERVED_PORTS+16+4],0 ;,dword 0x0
mov dword [RESERVED_PORTS+16+8],0x2d ;,dword 0x2d
 
mov [eax+16], ecx
mov [eax+16+4], dword 0
mov [eax+16+4], dword 0x2D
push 1
pop dword [RESERVED_PORTS+32+0] ;,dword 1
push 0x30
pop dword [RESERVED_PORTS+32+4] ;,dword 0x30
push 0x4d
pop dword [RESERVED_PORTS+32+8] ;,dword 0x4d
 
mov [eax+32], ecx
mov [eax+32+4], dword 0x30
mov [eax+32+8], dword 0x4D
push 1
pop dword [RESERVED_PORTS+48+0] ;,dword 1
push 0x50
pop dword [RESERVED_PORTS+48+4] ;,dword 0x50
mov dword [RESERVED_PORTS+48+8],0xdf ;,dword 0xdf
 
mov [eax+48], ecx
mov [eax+48+4], dword 0x50
mov [eax+28+8], dword 0xDF
push 1
pop dword [RESERVED_PORTS+64+0] ;,dword 1
 
mov [eax+64], ecx
mov [eax+64+4], dword 0xE5
mov [eax+64+8], dword 0xFF
mov dword [RESERVED_PORTS+64+4],0xe5 ;,dword 0xe5
mov dword [RESERVED_PORTS+64+8],0xff ;,dword 0xff
 
ret
 
setirqreadports:
 
mov [irq12read+0],dword 0x60 + 0x01000000 ; read port 0x60 , byte
and dword [irq12read+4],0 ; end of port list
; mov [irq12read+4],dword 0 ; end of port list
;mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte
;mov [irq04read+4],dword 0 ; end of port list
;mov [irq03read+0],dword 0x2f8 + 0x01000000 ; read port 0x2f8 , byte
;mov [irq03read+4],dword 0 ; end of port list
 
ret
 
iglobal
process_number dd 0x1
endg
1122,9 → 1148,8
 
set_variables:
 
mov ecx, 0x16 ; flush port 0x60
.fl60:
in al, 0x60
mov ecx,0x100 ; flush port 0x60
.fl60: in al,0x60
loop .fl60
push eax
 
1592,10 → 1617,15
no_set_lba_read:
; cmp eax,12 ; ENABLE PCI ACCESS
dec ebx
jnz sys_setup_err
jnz no_set_pci_access
mov [pci_access_enabled], ecx
ret
no_set_pci_access:
 
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
include 'vmodeint.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
sys_setup_err:
or [esp+32], dword -1
ret
1924,7 → 1954,7
iglobal
align 4
sys_system_table:
dd sysfn_deactivate ; 1 = deactivate window
dd exit_for_anyone ; 1 = obsolete
dd sysfn_terminate ; 2 = terminate thread
dd sysfn_activate ; 3 = activate window
dd sysfn_getidletime ; 4 = get idle time
1949,7 → 1979,7
dd sysfn_min_rest_window ; 22 = minimize and restore any window
sysfn_num = ($ - sys_system_table)/4
endg
;------------------------------------------------------------------------------
 
sys_system:
dec ebx
cmp ebx, sysfn_num
1957,7 → 1987,8
jmp dword [sys_system_table + ebx*4]
@@:
ret
;------------------------------------------------------------------------------
 
 
sysfn_shutdown: ; 18.9 = system shutdown
cmp ecx, 1
jl exit_for_anyone
1972,10 → 2003,9
exit_for_anyone:
ret
uglobal
shutdown_processes:
dd 0x0
shutdown_processes: dd 0x0
endg
;------------------------------------------------------------------------------
 
sysfn_terminate: ; 18.2 = TERMINATE
cmp ecx, 2
jb noprocessterminate
1999,7 → 2029,7
noatsc:
noprocessterminate:
ret
;------------------------------------------------------------------------------
 
sysfn_terminate2:
;lock application_table_status mutex
.table_status:
2026,34 → 2056,7
mov [application_table_status], 0
or dword [esp+32], -1
ret
;------------------------------------------------------------------------------
sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW
cmp ecx, 2
jb .nowindowdeactivate
cmp ecx, [TASK_COUNT]
ja .nowindowdeactivate
movzx esi, word [WIN_STACK + ecx*2]
cmp esi, 1
je .nowindowdeactivate ; already deactive
 
mov edi, ecx
shl edi, 5
add edi, window_data
movzx esi, word [WIN_STACK + ecx * 2]
lea esi, [WIN_POS + esi * 2]
call window._.window_deactivate
xor eax, eax
mov byte[MOUSE_BACKGROUND], al
mov byte[DONT_DRAW_MOUSE], al
mov byte[MOUSE_DOWN], 0
 
call syscall_display_settings._.calculate_whole_screen
call syscall_display_settings._.redraw_whole_screen
.nowindowdeactivate:
ret
;------------------------------------------------------------------------------
sysfn_activate: ; 18.3 = ACTIVATE WINDOW
cmp ecx, 2
jb .nowindowactivate
2074,22 → 2077,21
call waredraw
.nowindowactivate:
ret
;------------------------------------------------------------------------------
 
sysfn_getidletime: ; 18.4 = GET IDLETIME
mov eax, [idleusesec]
mov [esp+32], eax
ret
;------------------------------------------------------------------------------
 
sysfn_getcpuclock: ; 18.5 = GET TSC/SEC
mov eax, [CPU_FREQ]
mov [esp+32], eax
ret
;------------------------------------------------------------------------------
 
; SAVE ramdisk to /hd/1/menuet.img
;!!!!!!!!!!!!!!!!!!!!!!!!
include 'blkdev/rdsave.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!
;------------------------------------------------------------------------------
align 4
sysfn_getactive: ; 18.7 = get active window
mov eax, [TASK_COUNT]
2096,7 → 2098,7
movzx eax, word [WIN_POS + eax*2]
mov [esp+32], eax
ret
;------------------------------------------------------------------------------
 
sysfn_sound_flag: ; 18.8 = get/set sound_flag
; cmp ecx,1
dec ecx
2111,11 → 2113,10
xor byte [sound_flag], 1
nosoundflag:
ret
;------------------------------------------------------------------------------
 
sysfn_minimize: ; 18.10 = minimize window
mov [window_minimize], 1
ret
;------------------------------------------------------------------------------
align 4
sysfn_getdiskinfo: ; 18.11 = get disk info table
; cmp ecx,1
2140,18 → 2141,18
cld
rep movsd
ret
;------------------------------------------------------------------------------
 
sysfn_lastkey: ; 18.12 = return 0 (backward compatibility)
and dword [esp+32], 0
ret
;------------------------------------------------------------------------------
 
sysfn_getversion: ; 18.13 = get kernel ID and version
mov edi, ecx
mov edi,ebx
mov esi, version_inf
mov ecx, version_end-version_inf
rep movsb
ret
;------------------------------------------------------------------------------
 
sysfn_waitretrace: ; 18.14 = sys wait retrace
;wait retrace functions
sys_wait_retrace:
2162,7 → 2163,7
jz WaitRetrace_loop
and [esp+32], dword 0
ret
;------------------------------------------------------------------------------
 
align 4
sysfn_centermouse: ; 18.15 = mouse centered
; removed here by <Lrz>
2181,8 → 2182,8
xor eax, eax
and [esp+32], eax
; pop eax
 
ret
;------------------------------------------------------------------------------
align 4
sysfn_mouse_acceleration: ; 18.19 = set/get mouse features
test ecx, ecx; get mouse speed factor
2214,12 → 2215,10
; cmp ecx,4 ; set mouse pointer position
dec ecx
jnz .set_mouse_button
cmp dx, word[Screen_Max_Y]
ja .end
mov [MOUSE_Y],dx ;y
ror edx,16
mov [MOUSE_X],dx ;x
rol edx, 16
cmp dx, word[Screen_Max_X]
ja .end
mov [MOUSE_X], edx
ret
.set_mouse_button:
; cmp ecx,5 ; set mouse button features
2229,7 → 2228,7
mov [mouse_active], 1
.end:
ret
;------------------------------------------------------------------------------
 
sysfn_getfreemem:
mov eax, [pg_data.pages_free]
shl eax, 2
2289,18 → 2288,18
sound_flag db 0
endg
 
UID_NONE=0
UID_MENUETOS=1 ;official
UID_KOLIBRI=2 ;russian
 
iglobal
version_inf:
db 0,7,7,0 ; version 0.7.7.0
db 0
db UID_KOLIBRI
dd __REV__
version_end:
endg
 
UID_NONE=0
UID_MENUETOS=1 ;official
UID_KOLIBRI=2 ;russian
 
sys_cachetodiskette:
cmp ebx, 1
jne .no_floppy_a_save
2426,8 → 2425,8
;draw_background_temp:
; mov [bgrchanged],1 ;0
mov [background_defined], 1
mov byte[BACKGROUND_CHANGED], 1
call force_redraw_background
mov [REDRAW_BACKGROUND], byte 2
nosb31:
ret
nosb3:
2547,8 → 2546,8
ret
 
force_redraw_background:
and [draw_data+32 + RECT.left], 0
and [draw_data+32 + RECT.top], 0
and [draw_data+32 + RECT.left],dword 0
and [draw_data+32 + RECT.top],dword 0
push eax ebx
mov eax, [Screen_Max_X]
mov ebx, [Screen_Max_Y]
2555,7 → 2554,7
mov [draw_data+32 + RECT.right], eax
mov [draw_data+32 + RECT.bottom], ebx
pop ebx eax
inc byte[REDRAW_BACKGROUND]
mov byte [REDRAW_BACKGROUND], 1
ret
 
align 4
2664,7 → 2663,11
test eax, eax
jz .exit
mov eax, [BTN_BUFF]
shl eax, 8
; // Alver 22.06.2008 // {
mov al, byte [btn_down_determ]
and al, 0xFE ; delete left button bit
; } \\ Alver \\
mov [BTN_COUNT], byte 0
mov [esp + 32], eax
.exit:
2756,10 → 2759,6
mov al, [ecx+window_data+WDATA.fl_wstate]
stosb
 
; Event mask (+71)
mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask]
stosd
 
pop esi
pop edi
 
2774,8 → 2773,7
sys_clock:
cli
; Mikhail Lisovin xx Jan 2005
@@:
mov al, 10
@@: mov al, 10
out 0x70, al
in al, 0x71
test al, al
2812,8 → 2810,7
sys_date:
 
cli
@@:
mov al, 10
@@: mov al, 10
out 0x70, al
in al, 0x71
test al, al
2894,9 → 2891,488
mov eax, [Screen_Max_Y]
mov [edx + RECT.bottom], eax
 
mov edi, [TASK_BASE]
or [edi - twdw + WDATA.fl_wdrawn], 1 ; no new position & buttons from app
call sys_window_mouse
ret
 
srl1:
ret
 
 
sys_drawwindow:
 
mov eax,edx
shr eax,16+8
and eax,15
 
; cmp eax,0 ; type I - original style
jne nosyswI
inc [mouse_pause]
call [_display.disable_mouse]
call sys_set_window
call [_display.disable_mouse]
call drawwindow_I
;dec [mouse_pause]
;call [draw_pointer]
;ret
jmp draw_window_caption.2
nosyswI:
 
cmp al,1 ; type II - only reserve area, no draw
jne nosyswII
inc [mouse_pause]
call [_display.disable_mouse]
call sys_set_window
call [_display.disable_mouse]
call sys_window_mouse
dec [mouse_pause]
call [draw_pointer]
ret
nosyswII:
 
cmp al,2 ; type III - new style
jne nosyswIII
inc [mouse_pause]
call [_display.disable_mouse]
call sys_set_window
call [_display.disable_mouse]
call drawwindow_III
;dec [mouse_pause]
;call [draw_pointer]
;ret
jmp draw_window_caption.2
nosyswIII:
 
cmp al,3 ; type IV - skinned window
je draw_skin_window
cmp al,4 ; type V - skinned window not sized! {not_sized_skin_window}
jne nosyswV
draw_skin_window:
 
inc [mouse_pause]
call [_display.disable_mouse]
call sys_set_window
call [_display.disable_mouse]
mov eax, [TASK_COUNT]
movzx eax, word [WIN_POS + eax*2]
cmp eax, [CURRENT_TASK]
setz al
movzx eax, al
push eax
call drawwindow_IV
;dec [mouse_pause]
;call [draw_pointer]
;ret
jmp draw_window_caption.2
nosyswV:
 
ret
 
 
draw_window_caption:
inc [mouse_pause]
call [_display.disable_mouse]
 
xor eax,eax
mov edx,[TASK_COUNT]
movzx edx,word[WIN_POS+edx*2]
cmp edx,[CURRENT_TASK]
jne @f
inc eax
@@: mov edx,[CURRENT_TASK]
shl edx,5
add edx,window_data
movzx ebx,[edx+WDATA.fl_wstyle]
and bl,0x0F
cmp bl,3
je .draw_caption_style_3 ;{for 3 and 4 style write caption}
cmp bl,4
je .draw_caption_style_3
 
jmp .not_style_3
.draw_caption_style_3:
 
push edx
call drawwindow_IV_caption
add esp,4
jmp .2
 
.not_style_3:
cmp bl,2
jne .not_style_2
 
call drawwindow_III_caption
jmp .2
 
.not_style_2:
cmp bl,0
jne .2
 
call drawwindow_I_caption
 
;--------------------------------------------------------------
.2: ;jmp @f
mov edi,[CURRENT_TASK]
shl edi,5
test [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION
jz @f
mov edx,[edi*8+SLOT_BASE+APPDATA.wnd_caption]
or edx,edx
jz @f
 
movzx eax,[edi+window_data+WDATA.fl_wstyle]
and al,0x0F
cmp al,3
je .skinned
cmp al,4
je .skinned
 
jmp .not_skinned
.skinned:
mov ebp,[edi+window_data+WDATA.box.left-2]
mov bp,word[edi+window_data+WDATA.box.top]
movzx eax,word[edi+window_data+WDATA.box.width]
sub ax,[_skinmargins.left]
sub ax,[_skinmargins.right]
push edx
cwde
cdq
mov ebx,6
idiv ebx
pop edx
or eax,eax
js @f
mov esi,eax
mov ebx,dword[_skinmargins.left-2]
mov bx,word[_skinh]
sub bx,[_skinmargins.bottom]
sub bx,[_skinmargins.top]
sar bx,1
adc bx,0
add bx,[_skinmargins.top]
add bx,-3
add ebx,ebp
jmp .dodraw
 
.not_skinned:
cmp al,1
je @f
 
mov ebp,[edi+window_data+WDATA.box.left-2]
mov bp,word[edi+window_data+WDATA.box.top]
movzx eax,word[edi+window_data+WDATA.box.width]
sub eax,16
push edx
cwde
cdq
mov ebx,6
idiv ebx
pop edx
or eax,eax
js @f
mov esi,eax
mov ebx,0x00080007
add ebx,ebp
.dodraw:
mov ecx,[common_colours+16];0x00FFFFFF
or ecx, 0x80000000
xor edi,edi
; // Alver 22.06.2008 // {
; call dtext
call dtext_asciiz_esi
; } \\ Alver \\
 
@@:
;--------------------------------------------------------------
dec [mouse_pause]
call [draw_pointer]
ret
 
iglobal
align 4
window_topleft dd \
1, 21,\ ;type 0
0, 0,\ ;type 1
5, 20,\ ;type 2
5, ?,\ ;type 3 {set by skin}
5, ? ;type 4 {set by skin}
endg
 
set_window_clientbox:
push eax ecx edi
 
mov eax,[_skinh]
mov [window_topleft+4*7],eax
mov [window_topleft+4*9],eax
 
mov ecx,edi
sub edi,window_data
shl edi,3
test [ecx+WDATA.fl_wstyle],WSTYLE_CLIENTRELATIVE
jz @f
 
movzx eax,[ecx+WDATA.fl_wstyle]
and eax,0x0F
mov eax,[eax*8+window_topleft+0]
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax
shl eax,1
neg eax
add eax,[ecx+WDATA.box.width]
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax
 
movzx eax,[ecx+WDATA.fl_wstyle]
and eax,0x0F
push [eax*8+window_topleft+0]
mov eax,[eax*8+window_topleft+4]
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax
neg eax
sub eax,[esp]
add eax,[ecx+WDATA.box.height]
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax
add esp,4
 
pop edi ecx eax
ret
@@:
xor eax,eax
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax
mov eax,[ecx+WDATA.box.width]
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax
mov eax,[ecx+WDATA.box.height]
mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax
 
pop edi ecx eax
ret
 
sys_set_window:
 
mov eax,[CURRENT_TASK]
shl eax,5
add eax,window_data
 
; colors
mov [eax+WDATA.cl_workarea],edx
mov [eax+WDATA.cl_titlebar],esi
mov [eax+WDATA.cl_frames],edi
 
mov edi, eax
 
; check flag (?)
test [edi+WDATA.fl_wdrawn],1
jnz newd
 
mov eax,[timer_ticks] ;[0xfdf0]
add eax,100
mov [new_window_starting],eax
 
movsx eax,bx
mov [edi+WDATA.box.width],eax
movsx eax,cx
mov [edi+WDATA.box.height],eax
sar ebx,16
sar ecx,16
mov [edi+WDATA.box.left],ebx
mov [edi+WDATA.box.top],ecx
 
call check_window_position
 
push ecx esi edi ; save for window fullscreen/resize
;mov esi,edi
 
mov cl, [edi+WDATA.fl_wstyle]
mov eax, [edi+WDATA.cl_frames]
 
sub edi,window_data
shl edi,3
add edi,SLOT_BASE
 
and cl,0x0F
mov [edi+APPDATA.wnd_caption],0
cmp cl,3
je set_APPDATA_wnd_caption
cmp cl,4 ; {SPraid.simba}
je set_APPDATA_wnd_caption
 
jmp @f
set_APPDATA_wnd_caption:
mov [edi+APPDATA.wnd_caption],eax
@@: mov esi,[esp+0]
 
add edi, APPDATA.saved_box
movsd
movsd
movsd
movsd
pop edi esi ecx
 
mov esi, [CURRENT_TASK]
movzx esi, word [WIN_STACK+esi*2]
lea esi, [WIN_POS+esi*2]
call waredraw
 
;;; mov ebx, 1
;;; call delay_hs
mov eax, [edi+WDATA.box.left]
mov ebx, [edi+WDATA.box.top]
mov ecx, [edi+WDATA.box.width]
mov edx, [edi+WDATA.box.height]
add ecx, eax
add edx, ebx
call calculatescreen
 
mov [KEY_COUNT],byte 0 ; empty keyboard buffer
mov [BTN_COUNT],byte 0 ; empty button buffer
 
newd:
call set_window_clientbox
 
mov [edi+WDATA.fl_redraw],byte 0 ; no redraw
mov edx,edi
 
ret
 
syscall_windowsettings:
 
.set_window_caption:
dec ebx ; subfunction #1 - set window caption
jnz .exit_fail
 
; NOTE: only window owner thread can set its caption,
; so there's no parameter for PID/TID
 
mov edi,[CURRENT_TASK]
shl edi,5
 
; have to check if caption is within application memory limit
; check is trivial, and if application resizes its memory,
; caption still can become over bounds
; diamond, 31.10.2006: check removed because with new memory manager
; there can be valid data after APPDATA.mem_size bound
; mov ecx,[edi*8+SLOT_BASE+APPDATA.mem_size]
; add ecx,255 ; max caption length
; cmp ebx,ecx
; ja .exit_fail
 
mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ecx
or [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION
 
call draw_window_caption
 
xor eax,eax ; eax = 0 (success)
ret
 
; .get_window_caption:
; dec eax ; subfunction #2 - get window caption
; jnz .exit_fail
 
; not implemented yet
 
.exit_fail:
xor eax,eax
inc eax ; eax = 1 (fail)
ret
 
 
sys_window_move:
 
mov edi,[CURRENT_TASK]
shl edi,5
add edi,window_data
 
test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jnz .window_move_return
 
push dword [edi + WDATA.box.left] ; save old coordinates
push dword [edi + WDATA.box.top]
push dword [edi + WDATA.box.width]
push dword [edi + WDATA.box.height]
 
cmp eax,-1 ; set new position and size
je .no_x_reposition
mov [edi + WDATA.box.left], eax
.no_x_reposition:
cmp ebx,-1
je .no_y_reposition
mov [edi + WDATA.box.top], ebx
.no_y_reposition:
 
test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
jnz .no_y_resizing
 
cmp ecx,-1
je .no_x_resizing
mov [edi + WDATA.box.width], ecx
.no_x_resizing:
cmp edx,-1
je .no_y_resizing
mov [edi + WDATA.box.height], edx
.no_y_resizing:
 
call check_window_position
call set_window_clientbox
 
pushad ; save for window fullscreen/resize
mov esi,edi
sub edi,window_data
shr edi,5
shl edi,8
add edi, SLOT_BASE + APPDATA.saved_box
mov ecx,4
cld
rep movsd
popad
 
pushad ; calculcate screen at new position
mov eax, [edi + WDATA.box.left]
mov ebx, [edi + WDATA.box.top]
mov ecx, [edi + WDATA.box.width]
mov edx, [edi + WDATA.box.height]
add ecx,eax
add edx,ebx
 
call calculatescreen
popad
 
pop edx ; calculcate screen at old position
pop ecx
pop ebx
pop eax
add ecx,eax
add edx,ebx
mov [draw_limits.left],eax ; save for drawlimits
mov [draw_limits.top],ebx
mov [draw_limits.right],ecx
mov [draw_limits.bottom],edx
call calculatescreen
 
mov [edi + WDATA.fl_redraw], 1 ; flag the process as redraw
 
mov eax,edi ; redraw screen at old position
xor esi,esi
call redrawscreen
 
mov [DONT_DRAW_MOUSE],byte 0 ; mouse pointer
mov [MOUSE_BACKGROUND],byte 0 ; no mouse under
mov [MOUSE_DOWN],byte 0 ; react to mouse up/down
 
call [draw_pointer]
 
mov [window_move_pr],0
 
.window_move_return:
 
ret
 
uglobal
window_move_pr dd 0x0
window_move_eax dd 0x0
window_move_ebx dd 0x0
window_move_ecx dd 0x0
window_move_edx dd 0x0
endg
 
;ok - 100% work
;nt - not tested
;---------------------------------------------------------------------------------------------
3074,8 → 3550,12
loop set_mouse_event
 
mouse_not_active:
cmp byte[BACKGROUND_CHANGED], 0
jz no_set_bgr_event
cmp [REDRAW_BACKGROUND],byte 0 ; background update ?
jz nobackgr
cmp [background_defined], 0
jz nobackgr
cmp [REDRAW_BACKGROUND], byte 2
jnz no_set_bgr_event
xor edi, edi
mov ecx, [TASK_COUNT]
set_bgr_event:
3082,12 → 3562,7
add edi, 256
or [edi+SLOT_BASE+APPDATA.event_mask], 16
loop set_bgr_event
mov byte[BACKGROUND_CHANGED], 0
no_set_bgr_event:
cmp byte[REDRAW_BACKGROUND], 0 ; background update ?
jz nobackgr
cmp [background_defined], 0
jz nobackgr
; mov [draw_data+32 + RECT.left],dword 0
; mov [draw_data+32 + RECT.top],dword 0
; mov eax,[Screen_Max_X]
3094,16 → 3569,8
; mov ebx,[Screen_Max_Y]
; mov [draw_data+32 + RECT.right],eax
; mov [draw_data+32 + RECT.bottom],ebx
@@:
call drawbackground
xor eax, eax
xchg al, [REDRAW_BACKGROUND]
test al, al ; got new update request?
jnz @b
mov [draw_data+32 + RECT.left], eax
mov [draw_data+32 + RECT.top], eax
mov [draw_data+32 + RECT.right], eax
mov [draw_data+32 + RECT.bottom], eax
mov [REDRAW_BACKGROUND],byte 0
mov [MOUSE_BACKGROUND], byte 0
 
nobackgr:
3217,39 → 3684,34
 
bgli:
 
cmp dword[esp], 1
cmp ecx,1
jnz .az
; cmp byte[BACKGROUND_CHANGED], 0
; jnz newdw8
cmp byte[REDRAW_BACKGROUND], 0
mov al,[REDRAW_BACKGROUND]
cmp al,2
jz newdw8
test al,al
jz .az
mov dl, 0
lea eax, [edi+draw_data-window_data]
mov ebx, [draw_limits.left]
cmp ebx, [eax+RECT.left]
jae @f
mov [eax+RECT.left], ebx
mov dl, 1
@@:
mov ebx, [draw_limits.top]
cmp ebx, [eax+RECT.top]
jae @f
mov [eax+RECT.top], ebx
mov dl, 1
@@:
mov ebx, [draw_limits.right]
cmp ebx, [eax+RECT.right]
jbe @f
mov [eax+RECT.right], ebx
mov dl, 1
@@:
mov ebx, [draw_limits.bottom]
cmp ebx, [eax+RECT.bottom]
jbe @f
mov [eax+RECT.bottom], ebx
mov dl, 1
@@:
add byte[REDRAW_BACKGROUND], dl
jmp newdw8
.az:
 
3269,7 → 3731,7
 
cmp dword [esp], 1
jne nobgrd
inc byte[REDRAW_BACKGROUND]
mov byte [REDRAW_BACKGROUND], 1
 
newdw8:
nobgrd:
3299,7 → 3761,6
rep stosd
 
mov byte[REDRAW_BACKGROUND], 0 ; do not draw background!
mov byte[BACKGROUND_CHANGED], 0
 
ret
 
3326,8 → 3787,7
mov ah, al
cld
 
cnt1:
in al, 0x61
cnt1: in al,0x61
and al, 0x10
cmp al, ah
jz cnt1
3454,6 → 3914,103
 
 
align 4
 
sys_programirq:
 
mov eax, [TASK_BASE]
add ebx, [eax + TASKDATA.mem_start]
 
cmp ecx, 16
jae .not_owner
mov edi, [eax + TASKDATA.pid]
cmp edi, [irq_owner + 4 * ecx]
je .spril1
.not_owner:
xor ecx, ecx
inc ecx
jmp .end
.spril1:
 
shl ecx, 6
mov esi, ebx
lea edi, [irq00read + ecx]
push 16
pop ecx
 
cld
rep movsd
.end:
mov [esp+32], ecx
ret
 
 
align 4
 
get_irq_data:
movzx esi, bh ; save number of subfunction, if bh = 1, return data size, otherwise, read data
xor bh, bh
cmp ebx, 16
jae .not_owner
mov edx, [4 * ebx + irq_owner] ; check for irq owner
 
mov eax,[TASK_BASE]
 
cmp edx,[eax+TASKDATA.pid]
je gidril1
.not_owner:
xor edx, edx
dec edx
jmp gid1
 
gidril1:
 
shl ebx, 12
lea eax, [ebx + IRQ_SAVE] ; calculate address of the beginning of buffer + 0x0 - data size
mov edx, [eax] ; + 0x4 - data offset
dec esi
jz gid1
test edx, edx ; check if buffer is empty
jz gid1
 
mov ebx, [eax + 0x4]
mov edi, ecx
 
mov ecx, 4000 ; buffer size, used frequently
 
cmp ebx, ecx ; check for the end of buffer, if end of buffer, begin cycle again
jb @f
 
xor ebx, ebx
 
@@:
 
lea esi, [ebx + edx] ; calculate data size and offset
cld
cmp esi, ecx ; if greater than the buffer size, begin cycle again
jbe @f
 
sub ecx, ebx
sub edx, ecx
 
lea esi, [eax + ebx + 0x10]
rep movsb
 
xor ebx, ebx
@@:
lea esi, [eax + ebx + 0x10]
mov ecx, edx
add ebx, edx
 
rep movsb
mov edx, [eax]
mov [eax], ecx ; set data size to zero
mov [eax + 0x4], ebx ; set data offset
 
gid1:
mov [esp+32], edx ; eax
ret
 
 
set_io_access_rights:
push edi eax
mov edi, tss._io_map_0
3465,13 → 4022,13
; shl ebx,cl
test ebp, ebp
; cmp ebp,0 ; enable access - ebp = 0
jnz .siar1
jnz siar1
; not ebx
; and [edi],byte bl
btr [edi], eax
pop eax edi
ret
.siar1:
siar1:
bts [edi], eax
; or [edi],byte bl ; disable access - ebp = 1
pop eax edi
3626,7 → 4183,66
ret
 
 
align 4
reserve_free_irq:
 
xor esi, esi
inc esi
cmp ecx, 16
jae ril1
 
push ecx
lea ecx, [irq_owner + 4 * ecx]
mov edx, [ecx]
mov eax, [TASK_BASE]
mov edi, [eax + TASKDATA.pid]
pop eax
dec ebx
jnz reserve_irq
 
cmp edx, edi
jne ril1
dec esi
mov [ecx], esi
 
jmp ril1
 
reserve_irq:
 
cmp dword [ecx], 0
jne ril1
 
mov ebx, [f_irqs + 4 * eax]
 
stdcall attach_int_handler, eax, ebx, dword 0
 
mov [ecx], edi
 
dec esi
ril1:
mov [esp+32], esi ; return in eax
ret
 
iglobal
f_irqs:
dd 0x0
dd 0x0
dd p_irq2
dd p_irq3
dd p_irq4
dd p_irq5
dd p_irq6
dd p_irq7
dd p_irq8
dd p_irq9
dd p_irq10
dd p_irq11
dd 0x0
dd 0x0
dd p_irq14
dd p_irq15
 
endg
 
drawbackground:
inc [mouse_pause]
cmp [SCR_MODE], word 0x12
3693,7 → 4309,13
dec [mouse_pause]
pop ebp esi ebp
jmp [draw_pointer]
align 4
 
syscall_putimage_palette:
mov edi, esi
mov esi, edx
mov edx, ecx
mov ecx, ebx
mov ebx, eax
sys_putimage_palette:
; ebx = pointer to image
; ecx = [xsize]*65536 + [ysize]
4118,6 → 4740,64
ret
end if
 
rerouteirqs:
 
cli
 
mov al,0x11 ; icw4, edge triggered
out 0x20,al
call pic_delay
out 0xA0,al
call pic_delay
 
mov al,0x20 ; generate 0x20 +
out 0x21,al
call pic_delay
mov al,0x28 ; generate 0x28 +
out 0xA1,al
call pic_delay
 
mov al,0x04 ; slave at irq2
out 0x21,al
call pic_delay
mov al,0x02 ; at irq9
out 0xA1,al
call pic_delay
 
mov al,0x01 ; 8086 mode
out 0x21,al
call pic_delay
out 0xA1,al
call pic_delay
 
mov al,255 ; mask all irq's
out 0xA1,al
call pic_delay
out 0x21,al
call pic_delay
 
mov ecx,0x1000
cld
picl1: call pic_delay
loop picl1
 
mov al,255 ; mask all irq's
out 0xA1,al
call pic_delay
out 0x21,al
call pic_delay
 
cli
 
ret
 
 
pic_delay:
 
jmp pdl1
pdl1: ret
 
 
sys_msg_board_str:
 
pushad
4176,8 → 4856,7
ret
 
uglobal
msg_board_data:
times 4096 db 0
msg_board_data: times 4096 db 0
msg_board_count dd 0x0
endg
 
4233,47 → 4912,36
.smbl2:
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 66 sys function. ;;
;; in eax=66,ebx in [0..5],ecx,edx ;;
;; out eax ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iglobal
align 4
f66call:
dd sys_process_def.1 ; 1 = set keyboard mode
dd sys_process_def.2 ; 2 = get keyboard mode
dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift
dd sys_process_def.4
dd sys_process_def.5
endg
 
 
 
 
sys_process_def:
dec ebx
cmp ebx, 5
jae .not_support ;if >=6 then or eax,-1
 
mov edi, [CURRENT_TASK]
jmp dword [f66call+ebx*4]
 
.not_support:
or eax, -1
ret
dec eax ; 1 = set keyboard mode
jne no_set_keyboard_setup
 
.1:
shl edi, 8
mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl
mov [edi+SLOT_BASE + APPDATA.keyboard_mode],bl
 
ret
 
.2: ; 2 = get keyboard mode
no_set_keyboard_setup:
 
dec eax ; 2 = get keyboard mode
jne no_get_keyboard_setup
 
shl edi, 8
movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode]
mov [esp+32], eax
 
mov [esp+36],eax
 
ret
 
no_get_keyboard_setup:
 
dec eax ; 3 = get keyboard ctrl, alt, shift
jne no_get_keyboard_cas
 
; xor eax,eax
; movzx eax,byte [shift]
; movzx ebx,byte [ctrl]
4282,14 → 4950,20
; movzx ebx,byte [alt]
; shl ebx,3
; add eax,ebx
.3: ;3 = get keyboard ctrl, alt, shift
 
;// mike.dld [
mov eax, [kb_state]
;// mike.dld ]
mov [esp+32], eax
 
mov [esp+36],eax
 
ret
 
.4:
no_get_keyboard_cas:
 
dec eax
jnz no_add_keyboard_hotkey
 
mov eax, hotkey_list
@@:
cmp dword [eax+8], 0
4297,25 → 4971,29
add eax, 16
cmp eax, hotkey_list+16*256
jb @b
mov dword [esp+32], 1
mov dword [esp+36], 1
ret
.found_free:
mov [eax+8], edi
mov [eax+4], edx
movzx ecx, cl
lea ecx, [hotkey_scancodes+ecx*4]
mov edx, [ecx]
mov [eax], edx
mov [ecx], eax
mov [eax+12], ecx
mov [eax+4], ecx
movzx ebx, bl
lea ebx, [hotkey_scancodes+ebx*4]
mov ecx, [ebx]
mov [eax], ecx
mov [ebx], eax
mov [eax+12], ebx
jecxz @f
mov [edx+12], eax
mov [ecx+12], eax
@@:
and dword [esp+32], 0
and dword [esp+36], 0
ret
 
.5:
movzx ebx, cl
no_add_keyboard_hotkey:
 
dec eax
jnz no_del_keyboard_hotkey
 
movzx ebx, bl
lea ebx, [hotkey_scancodes+ebx*4]
mov eax, [ebx]
.scan:
4323,13 → 5001,13
jz .notfound
cmp [eax+8], edi
jnz .next
cmp [eax+4], edx
cmp [eax+4], ecx
jz .found
.next:
mov eax, [eax]
jmp .scan
.notfound:
mov dword [esp+32], 1
mov dword [esp+36], 1
ret
.found:
mov ecx, [eax]
4345,52 → 5023,54
mov [eax+8], edx
mov [eax+12], edx
mov [eax], edx
mov [esp+32], edx
mov [esp+36], edx
ret
 
no_del_keyboard_hotkey:
ret
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 61 sys function. ;;
;; in eax=61,ebx in [1..3] ;;
;; out eax ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iglobal
align 4
f61call:
dd sys_gs.1 ; resolution
dd sys_gs.2 ; bits per pixel
dd sys_gs.3 ; bytes per scanline
endg
 
 
align 4
 
sys_gs: ; direct screen access
dec ebx
cmp ebx, 2
ja .not_support
jmp dword [f61call+ebx*4]
.not_support:
or [esp+32], dword -1
ret
 
 
.1: ; resolution
cmp eax,1 ; resolution
jne no_gs1
mov eax, [Screen_Max_X]
shl eax, 16
mov ax, [Screen_Max_Y]
add eax, 0x00010001
mov [esp+32], eax
mov [esp+36],eax
ret
.2: ; bits per pixel
no_gs1:
 
cmp eax,2 ; bits per pixel
jne no_gs2
movzx eax, byte [ScreenBPP]
mov [esp+32], eax
mov [esp+36],eax
ret
.3: ; bytes per scanline
no_gs2:
 
cmp eax,3 ; bytes per scanline
jne no_gs3
mov eax, [BytesPerScanLine]
mov [esp+32], eax
mov [esp+36],eax
ret
no_gs3:
 
or [esp+36],dword -1
ret
 
 
align 4 ; PCI functions
 
sys_pci:
 
call pci_api
mov [esp+36],eax
ret
 
 
align 4 ; system functions
 
syscall_setpixel: ; SetPixel
4655,9 → 5335,26
mov ecx, edx
jmp [draw_line]
 
align 4
 
syscall_getirqowner: ; GetIrqOwner
 
cmp ebx,16
jae .err
 
cmp [irq_rights + 4 * ebx], dword 2
je .err
 
mov eax,[4 * ebx + irq_owner]
mov [esp+32],eax
 
ret
.err:
or dword [esp+32], -1
ret
 
align 4
 
syscall_reserveportarea: ; ReservePortArea and FreePortArea
 
call r_f_port_area
4665,6 → 5362,7
ret
 
align 4
 
syscall_threads: ; CreateThreads
; eax=1 create thread
;
4830,7 → 5528,6
yes_shutdown_param:
cli
 
if ~ defined extended_primary_loader
mov eax, kernel_file ; load kernel.mnt to 0x7000:0
push 12
pop esi
4843,9 → 5540,8
mov edi, OS_BASE+0x40000
mov ecx, 1000
rep movsb
end if
 
mov esi, BOOT_VAR ; restore 0x0 - 0xffff
mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff
mov edi, OS_BASE
mov ecx, 0x10000/4
cld
4853,7 → 5549,9
 
call restorefatchain
 
call IRQ_mask_all
mov al, 0xFF
out 0x21, al
out 0xA1, al
 
if 0
mov word [OS_BASE+0x467+0], pr_mode_exit
/kernel/branches/net/macros.inc
11,9 → 11,6
 
$Revision$
 
 
;// mike.dld, 2006-29-01 [
 
; macros definition
macro diff16 title,l1,l2
{
83,31 → 80,45
mov op1, op2
}
 
macro __list_add new, prev, next
{
mov [next+LHEAD.prev], new
mov [new+LHEAD.next], next
mov [new+LHEAD.prev], prev
mov [prev+LHEAD.next], new
 
if __CPU_type eq p5 ; CMOVcc isnt supported on the P5
 
cmove fix cmovz
macro cmovz reg1, reg2 {
 
local .jumpaddr
 
jnz .jumpaddr
mov reg1, reg2
.jumpaddr:
}
 
macro list_add new, head
{
mov eax, [head+LHEAD.next]
__list_add new, head, eax
cmovne fix cmovnz
macro cmovnz reg1, reg2 {
 
local .jumpaddr
 
jz .jumpaddr
mov reg1, reg2
.jumpaddr:
}
 
macro list_add_tail new, head
{
mov eax, [head+LHEAD.prev]
__list_add new, eax, head
macro cmovg reg1, reg2 {
 
local .jumpaddr
 
jle .jumpaddr
mov reg1, reg2
.jumpaddr:
}
 
macro list_del entry
{
mov edx, [entry+list_fd]
mov ecx, [entry+list_bk]
mov [edx+list_bk], ecx
mov [ecx+list_fd], edx
macro cmovl reg1, reg2 {
 
local .jumpaddr
 
jge .jumpaddr
mov reg1, reg2
.jumpaddr:
}
 
end if
/kernel/branches/net/blkdev/disk.inc
File deleted
/kernel/branches/net/blkdev/disk_cache.inc
File deleted
/kernel/branches/net/blkdev/cd_drv.inc
170,15 → 170,13
MaxCDWaitTime equ 1000 ;200 ;10 ñåêóíä
uglobal
; Îáëàñòü ïàìÿòè äëÿ ôîðìèðîâàíèÿ ïàêåòíîé êîìàíäû
PacketCommand:
rb 12 ;DB 12 DUP (?)
PacketCommand: rb 12 ;DB 12 DUP (?)
; Îáëàñòü ïàìÿòè äëÿ ïðèåìà äàííûõ îò äèñêîâîäà
;CDDataBuf DB 4096 DUP (0)
; Ðàçìåð ïðèíèìàåìîãî áëîêà äàííûõ â áàéòàõ
;CDBlockSize DW ?
; Àäðåñ ñ÷èòûâàåìîãî ñåêòîðà äàííûõ
CDSectorAddress:
DD ?
CDSectorAddress: DD ?
; Âðåìÿ íà÷àëà î÷åðåäíîé îïåðàöèè ñ äèñêîì
TickCounter_1 DD 0
; Âðåìÿ íà÷àëà îæèäàíèÿ ãîòîâíîñòè óñòðîéñòâà
/kernel/branches/net/blkdev/rd.inc
1169,8 → 1169,7
add edi, 6
cmp word [edi], ' '
jnz .insert_tilde
@@:
dec edi
@@: dec edi
cmp byte [edi], ' '
jz @b
inc edi
/kernel/branches/net/blkdev/flp_drv.inc
176,8 → 176,7
@@GetByteFromFDC:
inc DX
in AL, DX
@@End_6:
pop DX
@@End_6: pop DX
pop ECX
ret
 
223,8 → 222,7
; Îøèáêà òàéì-àóòà
mov [FDC_Status], FDC_TimeOut
; mov [flp_status],0
@@End_7:
popa
@@End_7: popa
ret
 
;*********************************
458,8 → 456,7
jnz @@Err_1
mov [FDC_Status], FDC_Normal
jmp @@Exit_1
@@Err_1:
mov [FDC_Status], FDC_SectorNotFound
@@Err_1: mov [FDC_Status],FDC_SectorNotFound
; mov [flp_status],0
@@Exit_1:
call save_timer_fdd_motor
558,8 → 555,7
jnz @@Err_2
mov [FDC_Status], FDC_Normal
jmp @@Exit_3
@@Err_2:
mov [FDC_Status], FDC_SectorNotFound
@@Err_2: mov [FDC_Status],FDC_SectorNotFound
@@Exit_3:
call save_timer_fdd_motor
popad
/kernel/branches/net/video/blitter.inc
File deleted
/kernel/branches/net/video/vesa20.inc
445,14 → 445,6
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1)
;--------------------------------------
; correction for the remainder of the division
shl edx, 1
cmp ebp, edx
jb @f
inc eax
@@:
;--------------------------------------
mov edx, ebp ; edx = counter (number of pixels to draw)
mov ebp, 1 *65536; <<16 ; ebp = dy = 1.0
mov esi, eax ; esi = dx
474,14 → 466,6
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv esi ; eax = ((y2-y1)*65536)/(x2-x1)
;--------------------------------------
; correction for the remainder of the division
shl edx, 1
cmp esi, edx
jb @f
inc eax
@@:
;--------------------------------------
mov edx, esi ; edx = counter (number of pixels to draw)
mov esi, 1 *65536;<< 16 ; esi = dx = 1.0
mov ebp, eax ; ebp = dy
490,25 → 474,10
mov ebx, [dl_y1]
shl eax, 16
shl ebx, 16
;-----------------------------------------------------------------------------
align 4
.draw:
push eax ebx
;--------------------------------------
; correction for the remainder of the division
test ah, 0x80
jz @f
add eax, 1 shl 16
@@:
;--------------------------------------
shr eax, 16
;--------------------------------------
; correction for the remainder of the division
test bh, 0x80
jz @f
add ebx, 1 shl 16
@@:
;--------------------------------------
shr ebx, 16
call [putpixel]
pop ebx eax
/kernel/branches/net/video/cursors.inc
332,13 → 332,19
 
stdcall init_cursor, eax, esi
 
mov ecx, [.hcursor]
lea ecx, [ecx+CURSOR.list_next]
mov eax, [.hcursor]
lea eax, [eax+CURSOR.list_next]
lea edx, [_display.cr_list.next]
 
pushfd
cli
list_add ecx, edx ;list_add_tail(new, head)
mov ecx, [edx]
 
mov [eax], ecx
mov [eax+4], edx
 
mov [ecx+4], eax
mov [edx], eax
popfd
 
mov eax, [.hcursor]
452,16 → 458,8
 
push eax
stdcall kernel_free, [eax+CURSOR.base]
pop eax
 
mov eax, [esp]
lea eax, [eax+CURSOR.list_next]
 
pushfd
cli
list_del eax
popfd
 
pop eax
call destroy_kernel_object
ret
 
794,6 → 792,14
ret
 
 
 
 
 
 
 
 
 
 
align 4
def_arrow:
file 'arrow.cur'
/kernel/branches/net/bus/pci/PCIe.inc
File deleted
/kernel/branches/net/bus/pci/pci32.inc
32,91 → 32,63
;***************************************************************************
;mmio_pci_addr equ 0x400 ; set actual PCI address here to activate user-MMIO
 
iglobal
align 4
f62call:
dd pci_fn_0
dd pci_fn_1
dd pci_fn_2
dd pci_service_not_supported ;3
dd pci_read_reg ;4 byte
dd pci_read_reg ;5 word
dd pci_read_reg ;6 dword
dd pci_service_not_supported ;7
dd pci_write_reg ;8 byte
dd pci_write_reg ;9 word
dd pci_write_reg ;10 dword
if defined mmio_pci_addr
dd pci_mmio_init ;11
dd pci_mmio_map ;12
dd pci_mmio_unmap ;13
end if
 
endg
 
align 4
 
pci_api:
 
;cross
mov eax, ebx
mov ebx, ecx
mov ecx, edx
 
cmp [pci_access_enabled], 1
jne pci_service_not_supported
jne no_pci_access_for_applications
 
movzx edx, al
 
if defined mmio_pci_addr
cmp al, 13
ja pci_service_not_supported
else
cmp al, 10
ja pci_service_not_supported
end if
 
call dword [f62call+edx*4]
mov dword [esp+32], eax
ret
 
 
align 4
pci_api_drv:
 
cmp [pci_access_enabled], 1
jne .fail
 
cmp eax, 2
ja .fail
 
jmp dword [f62call+eax*4]
 
.fail:
or eax, -1
ret
 
 
;; ============================================
 
pci_fn_0:
or al,al
jnz pci_fn_1
; PCI function 0: get pci version (AH.AL)
movzx eax, word [BOOT_VAR+0x9022]
ret
 
pci_fn_1:
cmp al,1
jnz pci_fn_2
 
; PCI function 1: get last bus in AL
mov al, [BOOT_VAR+0x9021]
ret
 
pci_fn_2:
cmp al,2
jne pci_fn_3
; PCI function 2: get pci access mechanism
mov al, [BOOT_VAR+0x9020]
ret
pci_fn_3:
 
pci_service_not_supported:
cmp al,4
jz pci_read_reg ;byte
cmp al,5
jz pci_read_reg ;word
cmp al,6
jz pci_read_reg ;dword
 
cmp al,8
jz pci_write_reg ;byte
cmp al,9
jz pci_write_reg ;word
cmp al,10
jz pci_write_reg ;dword
 
if defined mmio_pci_addr
cmp al,11 ; user-level MMIO functions
jz pci_mmio_init
cmp al,12
jz pci_mmio_map
cmp al,13
jz pci_mmio_unmap
end if
 
no_pci_access_for_applications:
 
or eax, -1
mov dword [esp+32], eax
 
ret
 
;***************************************************************************
492,7 → 464,6
@@:
pop ecx ; ecx = block size, bytes (expanded to whole page)
mov ebx, ecx; user_alloc destroys eax, ecx, edx, but saves ebx
and eax, 0xFFFFFFF0
push eax ; store MMIO physical address + keep 2DWords in the stack
stdcall user_alloc, ecx
or eax, eax
545,8 → 516,7
uglobal
align 4
; VendID (2), DevID (2), Revision = 0 (1), Class Code (3), FNum (1), Bus (1)
pci_emu_dat:
times 30*10 db 0
pci_emu_dat: times 30*10 db 0
endg
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
align 4
570,9 → 540,9
cmp ebp, 1 ; PCI_FUNCTION_ID
jnz .not_PCI_BIOS_PRESENT
mov edx, 'PCI '
mov al, [BOOT_VAR + 0x9020]
mov bx, [BOOT_VAR + 0x9022]
mov cl, [BOOT_VAR + 0x9021]
mov al, [OS_BASE+0x2F0000 + 0x9020]
mov bx, [OS_BASE+0x2F0000 + 0x9022]
mov cl, [OS_BASE+0x2F0000 + 0x9021]
xor ah, ah
jmp .return_abcd
 
580,8 → 550,7
cmp ebp, 2 ; FIND_PCI_DEVICE
jne .not_FIND_PCI_DEVICE
mov ebx, pci_emu_dat
..nxt:
cmp [ebx], dx
..nxt: cmp [ebx], dx
jne ..no
cmp [ebx + 2], cx
jne ..no
590,8 → 559,7
mov bx, [ebx + 4]
xor ah, ah
jmp .return_ab
..no:
cmp word[ebx], 0
..no: cmp word[ebx], 0
je ..dev_not_found
add ebx, 10
jmp ..nxt
604,14 → 572,12
jne .not_FIND_PCI_CLASS_CODE
mov esi, pci_emu_dat
shl ecx, 8
..nxt2:
cmp [esi], ecx
..nxt2: cmp [esi], ecx
jne ..no2
mov bx, [esi]
xor ah, ah
jmp .return_ab
..no2:
cmp dword[esi], 0
..no2: cmp dword[esi], 0
je ..dev_not_found
add esi, 10
jmp ..nxt2
646,8 → 612,7
.not_WRITE_CONFIG:
.unsupported_func:
mov ah, 0x81 ; FUNC_NOT_SUPPORTED
.return:
mov dword[esp + 4 ], edi
.return:mov dword[esp + 4 ], edi
mov dword[esp + 8], esi
.return_abcd:
mov dword[esp + 24], edx
/kernel/branches/net/const.inc
143,42 → 143,45
 
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
 
IRQ_PIC equ 0
IRQ_APIC equ 1
 
struct TSS
_back rw 2
_esp0 rd 1
_ss0 rw 2
_esp1 rd 1
_ss1 rw 2
_esp2 rd 1
_ss2 rw 2
_cr3 rd 1
_eip rd 1
_eflags rd 1
_eax rd 1
_ecx rd 1
_edx rd 1
_ebx rd 1
_esp rd 1
_ebp rd 1
_esi rd 1
_edi rd 1
_es rw 2
_cs rw 2
_ss rw 2
_ds rw 2
_fs rw 2
_gs rw 2
_ldt rw 2
_trap rw 1
_io rw 1
struc TSS
{
._back rw 2
._esp0 rd 1
._ss0 rw 2
._esp1 rd 1
._ss1 rw 2
._esp2 rd 1
._ss2 rw 2
._cr3 rd 1
._eip rd 1
._eflags rd 1
._eax rd 1
._ecx rd 1
._edx rd 1
._ebx rd 1
._esp rd 1
._ebp rd 1
._esi rd 1
._edi rd 1
._es rw 2
._cs rw 2
._ss rw 2
._ds rw 2
._fs rw 2
._gs rw 2
._ldt rw 2
._trap rw 1
._io rw 1
rb 24
_io_map_0 rb 4096
_io_map_1 rb 4096
ends
._io_map_0 rb 4096
._io_map_1 rb 4096
}
 
virtual at 0
TSS TSS
end virtual
 
TSS_SIZE equ (128+8192)
 
OS_BASE equ 0x80000000
244,20 → 247,19
;unused ? only one reference
MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
 
LFBAddress equ (OS_BASE+0x000FE80)
MEM_AMOUNT equ (OS_BASE+0x000FE8C)
 
Screen_Max_X equ (OS_BASE+0x000FE00)
Screen_Max_Y equ (OS_BASE+0x000FE04)
BytesPerScanLine equ (OS_BASE+0x000FE08)
SCR_MODE equ (OS_BASE+0x000FE0C)
 
LFBAddress equ (OS_BASE+0x000FE80)
BTN_ADDR equ (OS_BASE+0x000FE88)
MEM_AMOUNT equ (OS_BASE+0x000FE8C)
 
SYS_SHUTDOWN equ (OS_BASE+0x000FF00)
TASK_ACTIVATE equ (OS_BASE+0x000FF01)
 
REDRAW_BACKGROUND equ (OS_BASE+0x000FFF0)
BACKGROUND_CHANGED equ (OS_BASE+0x000FFF1)
BANK_RW equ (OS_BASE+0x000FFF2)
MOUSE_BACKGROUND equ (OS_BASE+0x000FFF4)
DONT_DRAW_MOUSE equ (OS_BASE+0x000FFF5)
283,35 → 285,33
RAMDISK_FAT equ (OS_BASE+0x0280000)
FLOPPY_FAT equ (OS_BASE+0x0282000)
 
CLEAN_ZONE equ 0x284000
IDE_DMA equ 0x284000
 
BgrAuxTable equ (OS_BASE+0x0298000)
; unused?
SB16Buffer equ (OS_BASE+0x02A0000)
SB16Buffer equ (OS_BASE+0x2A0000)
SB16_Status equ (OS_BASE+0x02B0000)
 
BUTTON_INFO equ (OS_BASE+0x02C0000)
RESERVED_PORTS equ (OS_BASE+0x02D0000)
BOOT_VAR equ (OS_BASE+0x02E0000)
IRQ_SAVE equ (OS_BASE+0x02E0000)
BOOT_VAR equ (OS_BASE+0x02f0000)
 
stack_data_start equ (OS_BASE+0x02F0000)
eth_data_start equ (OS_BASE+0x02F0000)
stack_data equ (OS_BASE+0x02F4000)
stack_data_end equ (OS_BASE+0x030ffff)
resendQ equ (OS_BASE+0x0310000)
stack_data_start equ (OS_BASE+0x0300000)
eth_data_start equ (OS_BASE+0x0300000)
stack_data equ (OS_BASE+0x0304000)
stack_data_end equ (OS_BASE+0x031ffff)
resendQ equ (OS_BASE+0x0320000)
VMODE_BASE equ (OS_BASE+0x0328000)
skin_data equ (OS_BASE+0x0330000)
draw_data equ (OS_BASE+0x0338000);
 
skin_data equ (OS_BASE+0x0318000)
draw_data equ (OS_BASE+0x0320000)
BgrDrawMode equ (OS_BASE+0x033BFF4)
BgrDataWidth equ (OS_BASE+0x033BFF8)
BgrDataHeight equ (OS_BASE+0x033BFFC)
 
BgrDrawMode equ (OS_BASE+0x0323FF4)
BgrDataWidth equ (OS_BASE+0x0323FF8)
BgrDataHeight equ (OS_BASE+0x0323FFC)
sys_pgmap equ (OS_BASE+0x033C000)
 
sys_pgmap equ (OS_BASE+0x0324000)
 
UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000)
 
virtual at (OS_BASE+0x05FFF80)
tss TSS
end virtual
587,6 → 587,20
display_t display_t
end virtual
 
struc HEAP_DATA
{
.mutex rd 1
.refcount rd 1
.heap_base rd 1
.heap_top rd 1
.app_mem rd 1
}
 
HEAP_DATA_SIZE equ 20
virtual at 0
HEAP_DATA HEAP_DATA
end virtual
 
struc BOOT_DATA
{ .bpp dd ?
.scanline dd ?
625,7 → 639,7
end virtual
 
struc MEM_STATE
{ .mutex MUTEX
{ .mutex rd 1
.smallmap rd 1
.treemap rd 1
.topsize rd 1
644,7 → 658,7
.kernel_pages dd ?
.kernel_tables dd ?
.sys_page_dir dd ?
.mutex MUTEX
.pg_mutex dd ?
}
 
;struc LIB
751,27 → 765,3
virtual at 0
CSYM COFF_SYM
end virtual
 
struc LHEAD
{
.next dd ? ;next object in list
.prev dd ? ;prev object in list
.sizeof:
}
 
virtual at 0
LHEAD LHEAD
end virtual
 
struc IRQH
{
.list LHEAD
.handler dd ? ;handler roututine
.data dd ? ;user-specific data
.sizeof:
}
 
virtual at 0
IRQH IRQH
end virtual
 
/kernel/branches/net/data16.inc
12,8 → 12,7
preboot_lfb db 0
preboot_bootlog db 0
boot_drive db 0
bx_from_load:
dw 'r1' ; ñòðóêòóðà äëÿ õðàíåíèÿ ïàðàìåòðîâ- îòêóäà ãàøðóçèëèñü, áåðåòñÿ íèæå èç bx ; {SPraid}[13.03.2007]
bx_from_load: dw 'r1' ; ñòðóêòóðà äëÿ õðàíåíèÿ ïàðàìåòðîâ- îòêóäà ãàøðóçèëèñü, áåðåòñÿ íèæå èç bx ; {SPraid}[13.03.2007]
; a,b,c,d - âèí÷åñòåðû, r - ðàì äèñê
; # äèñêà... ñèìâîë, à íå áàéò. '1', à íå 1
 
23,12 → 22,10
dd 0
dw 0
 
if ~ defined extended_primary_loader ; restart from memory is not supported in extended primary loader cfg
kernel_restart_bootblock:
db 1 ; version
dw 1 ; floppy image is in memory
dd 0 ; cannot save parameters
end if
 
; table for move to extended memory (int 15h, ah=87h)
align 8
56,36 → 53,3
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
 
if defined extended_primary_loader
; look in PrimaryLoader.txt for the description
bootdevice dw 0 ; ax from primary loader
bootfs dw 0 ; bx from primary loader
bootcallback dd 0 ; ds:si from primary loader
; data for configuration file loading, look in PrimaryLoader.txt
config_file_struct:
dw 0, 4000h ; load to 4000:0000
dw 16 ; read no more than 16*4K = 64K
db 'config.ini',0
; data for configuration file parsing
macro config_variable string,parser
{
local len
len dw 0
db string
store word $ - len - 2 at len
dw parser
}
config_file_variables:
config_variable 'timeout', parse_timeout
config_variable 'resolution', parse_resolution
config_variable 'vbemode', parse_vbemode
; config_variable 'vrr', parse_vrr
config_variable 'biosdisks', parse_biosdisks
config_variable 'imgfrom', parse_imgfrom
dw 0
; data for image file loading, look in PrimaryLoader.txt
image_file_struct:
dw 0, 4000h ; load to 4000:0000
dw 16 ; read no more than 16*4K = 64K
db 'kolibri.img',0
end if
/kernel/branches/net/data32.inc
47,43 → 47,20
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
 
 
if lang eq ru
boot_fonts db '˜à¨äâë § £à㦥­ë',0
boot_memdetect db 'Š®«¨ç¥á⢮ ®¯¥à â¨¢­®© ¯ ¬ïâ¨',' ',' Œ¡',0
boot_tss db '“áâ ­®¢ª  TSSs',0
boot_cpuid db '—⥭¨¥ CPUIDs',0
boot_devices db '®¨áª ãáâனáâ¢',0
boot_timer db '“áâ ­®¢ª  â ©¬¥à ',0
boot_irqs db '¥à¥®¯à¥¤¥«¥­¨¥ IRQ',0
boot_setmouse db '“áâ ­®¢ª  ¬ëè¨',0
boot_windefs db '“áâ ­®¢ª  ­ áâ஥ª ®ª®­ ¯® 㬮«ç ­¨î',0
boot_bgr db '“áâ ­®¢ª  ä®­ ',0
boot_resirqports db '¥§¥à¢¨à®¢ ­¨¥ IRQ ¨ ¯®à⮢',0
boot_setrports db '“áâ ­®¢ª   ¤à¥á®¢ IRQ',0
boot_setostask db '‘®§¤ ­¨¥ ¯à®æ¥áá  ï¤à ',0
boot_allirqs db 'Žâªàë⨥ ¢á¥å IRQ',0
boot_tsc db '—⥭¨¥ TSC',0
boot_cpufreq db '— áâ®â  ¯à®æ¥áá®à  ',' ',' Œƒæ',0
boot_pal_ega db '“áâ ­®¢ª  EGA/CGA 320x200 ¯ «¨âàë',0
boot_pal_vga db '“áâ ­®¢ª  VGA 640x480 ¯ «¨âàë',0
boot_failed db '‡ £à㧪  ¯¥à¢®£® ¯à¨«®¦¥­¨ï ­¥ 㤠« áì',0
boot_mtrr db '“áâ ­®¢ª  MTRR',0
if preboot_blogesc
boot_tasking db '‚ᥠ£®â®¢® ¤«ï § ¯ã᪠, ­ ¦¬¨âॠESC ¤«ï áâ àâ ',0
end if
else
boot_memdetect db 'Determining amount of memory',0
boot_fonts db 'Fonts loaded',0
boot_memdetect db 'Determining amount of memory',0
boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0
boot_timer db 'Setting timer',0
boot_irqs db 'Reprogramming IRQs',0
boot_setmouse db 'Setting mouse',0
boot_windefs db 'Setting window defaults',0
boot_bgr db 'Calculating background',0
boot_resirqports db 'Reserving IRQs & ports',0
boot_setrports db 'Setting addresses for IRQs',0
boot_setostask db 'Setting OS task',0
boot_allirqs db 'Unmasking IRQs',0
boot_allirqs db 'Unmasking all IRQs',0
boot_tsc db 'Reading TSC',0
boot_cpufreq db 'CPU frequency is ',' ',' MHz',0
boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
93,11 → 70,7
if preboot_blogesc
boot_tasking db 'All set - press ESC to start',0
end if
end if
 
boot_APIC_found db 'APIC enabled', 0
boot_APIC_nfound db 'APIC not found', 0
 
;new_process_loading db 'K : New Process - loading',13,10,0
;new_process_running db 'K : New Process - done',13,10,0
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
128,12 → 101,6
 
read_firstapp db '/sys/'
firstapp db 'LAUNCHER',0
notifyapp db '@notify',0
if lang eq ru
ud_user_message db 'Žè¨¡ª : ­¥¯®¤¤¥à¦¨¢ ¥¬ ï ¨­áâàãªæ¨ï ¯à®æ¥áá®à ',0
else
ud_user_message db 'Error: unsupported processor instruction',0
end if
 
char db '/sys/FONTS/CHAR.MT',0
char2 db '/sys/FONTS/CHAR2.MT',0
141,10 → 108,9
bootpath db '/KOLIBRI '
bootpath2 db 0
vmode db '/sys/drivers/VMODE.MDR',0
;vrr_m db 'VRR_M',0
vrr_m db 'VRR_M',0
kernel_file db 'KERNEL MNT'
 
dev_data_path db '/RD/1/DRIVERS/DEVICES.DAT',0
 
align 4
 
293,23 → 259,51
 
align 16
cur_saved_data rb 4096
fpu_data:
rb 512
fpu_data: rb 512
 
mem_block_list rd 64*2
mem_used_list rd 64*2
mem_hash_cnt rd 64
; device irq owners
irq_owner rd 16 ; process id
 
heap_mutex MUTEX
; on irq read ports
 
irq00read rd 16
irq01read rd 16
irq02read rd 16
irq03read rd 16
irq04read rd 16
irq05read rd 16
irq06read rd 16
irq07read rd 16
irq08read rd 16
irq09read rd 16
irq10read rd 16
irq11read rd 16
irq12read rd 16
irq13read rd 16
irq14read rd 16
irq15read rd 16
 
irq_tab rd 16
 
mem_block_map rb 512
mem_block_list rd 64
large_block_list rd 31
mem_block_mask rd 2
large_block_mask rd 1
 
mem_used.fd rd 1
mem_used.bk rd 1
 
mem_block_arr rd 1
mem_block_start rd 1
mem_block_end rd 1
 
heap_mutex rd 1
heap_size rd 1
heap_free rd 1
heap_blocks rd 1
free_blocks rd 1
 
mem_block_mask rd 2
next_memblock rd 1
 
 
mst MEM_STATE
 
page_start rd 1
374,7 → 368,6
hdbase rd 1 ; for boot 0x1f0
hdid rd 1
hdpos rd 1 ; for boot 0x1
label known_part dword
fat32part rd 1 ; for boot 0x1
cdpos rd 1
 
/kernel/branches/net/detect/dev_fd.inc
28,10 → 28,3
jnz wait_cmos
in al, 0x71
mov [DRIVE_DATA], al
test al, al
jz @f
in al, 0x21
and al, 10111111b ; Enable IRQ6
out 0x21, al
@@:
 
/kernel/branches/net/detect/dev_hdcd.inc
124,8 → 124,7
ret
@@Error6:
mov [DevErrorCode], 6
@@End:
ret
@@End: ret
 
 
iglobal
259,20 → 258,15
mov [DevErrorCode], 0
ret
; Çàïèñàòü êîä îøèáêè
@@Err1:
mov [DevErrorCode], 1
@@Err1: mov [DevErrorCode],1
ret
@@Err2:
mov [DevErrorCode], 2
@@Err2: mov [DevErrorCode],2
ret
@@Err3:
mov [DevErrorCode], 3
@@Err3: mov [DevErrorCode],3
ret
@@Err4:
mov [DevErrorCode], 4
@@Err4: mov [DevErrorCode],4
ret
@@Err5:
mov [DevErrorCode], 5
@@Err5: mov [DevErrorCode],5
; Çàâåðøåíèå ðàáîòû ïðîãðàììû
ret
 
379,14 → 373,11
mov [DevErrorCode], 0
ret
; Îáðàáîòêà îøèáîê
@@Err1_2:
mov [DevErrorCode], 1
@@Err1_2: mov [DevErrorCode],1
ret
@@Err3_2:
mov [DevErrorCode], 3
@@Err3_2: mov [DevErrorCode],3
ret
@@Err4_2:
mov [DevErrorCode], 4
@@Err4_2: mov [DevErrorCode],4
; Çàïèñàòü êîä îøèáêè
ret
 
/kernel/branches/net/detect/getcache.inc
209,4 → 209,4
; mov [cache_ide0_pointer],HD_CACHE
; mov [cache_ide0_system_data],HD_CACHE+65536
; mov [cache_ide0_system_sad_size],1919
popa
popa
/kernel/branches/net/detect/sear_par.inc
20,20 → 20,15
mov [hdbase], 0x1f0
mov [hdid], 0x0
mov [hdpos], 1
mov [known_part], 1
mov [fat32part],1
search_partitions_ide0_1:
call set_PARTITION_variables
test [problem_partition], 2
jnz search_partitions_ide1 ; not found part
test [problem_partition], 1
jnz @F ; not found known_part
;cmp [problem_partition],0
;jne search_partitions_ide1
call set_FAT32_variables
cmp [problem_partition],0
jne search_partitions_ide1
inc byte [DRIVE_DATA+2]
call partition_data_transfer
add [transfer_adress], 100
@@:
inc [known_part]
inc [fat32part]
jmp search_partitions_ide0_1
 
search_partitions_ide1:
42,20 → 37,15
mov [hdbase], 0x1f0
mov [hdid], 0x10
mov [hdpos], 2
mov [known_part], 1
mov [fat32part],1
search_partitions_ide1_1:
call set_PARTITION_variables
test [problem_partition], 2
jnz search_partitions_ide2
test [problem_partition], 1
jnz @F
;cmp [problem_partition],0
;jne search_partitions_ide2
call set_FAT32_variables
cmp [problem_partition],0
jne search_partitions_ide2
inc byte [DRIVE_DATA+3]
call partition_data_transfer
add [transfer_adress], 100
@@:
inc [known_part]
inc [fat32part]
jmp search_partitions_ide1_1
 
search_partitions_ide2:
64,20 → 54,15
mov [hdbase], 0x170
mov [hdid], 0x0
mov [hdpos], 3
mov [known_part], 1
mov [fat32part],1
search_partitions_ide2_1:
call set_PARTITION_variables
test [problem_partition], 2
jnz search_partitions_ide3
test [problem_partition], 1
jnz @F
;cmp [problem_partition],0
;jne search_partitions_ide3
call set_FAT32_variables
cmp [problem_partition],0
jne search_partitions_ide3
inc byte [DRIVE_DATA+4]
call partition_data_transfer
add [transfer_adress], 100
@@:
inc [known_part]
inc [fat32part]
jmp search_partitions_ide2_1
 
search_partitions_ide3:
86,20 → 71,15
mov [hdbase], 0x170
mov [hdid], 0x10
mov [hdpos], 4
mov [known_part], 1
mov [fat32part],1
search_partitions_ide3_1:
call set_PARTITION_variables
test [problem_partition], 2
jnz end_search_partitions_ide
test [problem_partition], 1
jnz @F
;cmp [problem_partition],0
;jne end_search_partitions_ide
call set_FAT32_variables
cmp [problem_partition],0
jne end_search_partitions_ide
inc byte [DRIVE_DATA+5]
call partition_data_transfer
add [transfer_adress], 100
@@:
inc [known_part]
inc [fat32part]
jmp search_partitions_ide3_1
 
end_search_partitions_ide:
111,21 → 91,16
push ecx
mov eax, [hdpos]
and [BiosDiskPartitions+(eax-80h)*4], 0
mov [known_part], 1
mov [fat32part], 1
search_partitions_bd:
call set_PARTITION_variables
test [problem_partition], 2
jnz end_search_partitions_bd
test [problem_partition], 1
jnz @F
;cmp [problem_partition], 0
;jne end_search_partitions_bd
call set_FAT32_variables
cmp [problem_partition], 0
jne end_search_partitions_bd
mov eax, [hdpos]
inc [BiosDiskPartitions+(eax-80h)*4]
call partition_data_transfer
add [transfer_adress], 100
@@:
inc [known_part]
inc [fat32part]
jmp search_partitions_bd
end_search_partitions_bd:
pop ecx
135,7 → 110,7
 
partition_data_transfer:
mov edi, [transfer_adress]
mov esi, PARTITION_START ;start of file_system_data
mov esi,PARTITION_START
mov ecx, (file_system_data_size+3)/4
rep movsd
ret
155,3 → 130,24
 
end_search_partitions:
 
;PARTITION_START dd 0x3f
;PARTITION_END dd 0
;SECTORS_PER_FAT dd 0x1f3a
;NUMBER_OF_FATS dd 0x2
;SECTORS_PER_CLUSTER dd 0x8
;BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes
;ROOT_CLUSTER dd 2 ; first rootdir cluster
;FAT_START dd 0 ; start of fat table
;ROOT_START dd 0 ; start of rootdir (only fat16)
;ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16)
;DATA_START dd 0 ; start of data area (=first cluster 2)
;LAST_CLUSTER dd 0 ; last availabe cluster
;ADR_FSINFO dd 0 ; used only by fat32
;
;fatRESERVED dd 0x0FFFFFF6
;fatBAD dd 0x0FFFFFF7
;fatEND dd 0x0FFFFFF8
;fatMASK dd 0x0FFFFFFF
;
;fat_type db 0 ; 0=none, 16=fat16, 32=fat32
 
/kernel/branches/net/fdo.inc
62,11 → 62,13
jmp ..label
..str db _str,0
..label:
; add esp,4*8+4
esp equ esp+4*8+4
mov edx, ..str
esp equ _esp
; sub esp,4*8+4
else
esp equ esp+4*8+4
mov edx, _str
esp equ _esp
end if
if ~_num eq
if _num eqtype eax
252,8 → 254,7
debug_func fdo_debug_outstr
debug_beginf
mov eax, 1
.l1:
dec esi
.l1: dec esi
js .l2
movzx ebx, byte[edx]
or bl, bl
262,8 → 263,7
call ecx ; sys_msg_board
inc edx
jmp .l1
.l2:
ret
.l2: ret
debug_endf
 
debug_func fdo_debug_outdec
277,24 → 277,20
mov al, '-'
call fdo_debug_outchar
pop eax
@@:
push 10
@@: push 10
pop ecx
push -'0'
.l1:
xor edx, edx
.l1: xor edx,edx
div ecx
push edx
test eax, eax
jnz .l1
.l2:
pop eax
.l2: pop eax
add al, '0'
jz .l3
call fdo_debug_outchar
jmp .l2
.l3:
ret
.l3: ret
debug_endf
 
debug_func fdo_debug_outhex
305,8 → 301,7
add cl, 8
shl cl, 2
rol eax, cl
.l1:
rol eax, 4
.l1: rol eax,4
push eax
and eax, 0x0000000F
mov al, [__fdo_hexdigits+eax]
/kernel/branches/net/fs/ext2.inc
File deleted
/kernel/branches/net/fs/fat32.inc
60,7 → 60,6
ERROR_DISK_FULL = 8
ERROR_FAT_TABLE = 9
ERROR_ACCESS_DENIED = 10
ERROR_DEVICE = 11
 
PUSHAD_EAX equ [esp+28]
PUSHAD_ECX equ [esp+24]
94,13 → 93,10
 
uglobal
align 4
fat_cache:
times 512 db 0
fat_cache: times 512 db 0
Sector512: ; label for dev_hdcd.inc
buffer:
times 512 db 0
fsinfo_buffer:
times 512 db 0
buffer: times 512 db 0
fsinfo_buffer: times 512 db 0
endg
 
uglobal
1053,8 → 1049,6
jz @f
cmp [fs_type], 1
jz ntfs_HdRead
cmp [fs_type], 2
jz ext2_HdRead
or ebx, -1
mov eax, ERROR_UNKNOWN_FS
ret
1206,8 → 1200,6
fs_HdReadFolder:
cmp [fs_type], 1
jz ntfs_HdReadFolder
cmp [fs_type], 2
jz ext2_HdReadFolder
cmp [fs_type], 16
jz @f
cmp [fs_type], 32
1594,8 → 1586,6
.common:
cmp [fs_type], 1
jz ntfs_HdRewrite
cmp [fs_type], 2
jz ext2_HdRewrite
cmp [fs_type], 16
jz @f
cmp [fs_type], 32
2130,8 → 2120,6
fs_HdWrite:
cmp [fs_type], 1
jz ntfs_HdWrite
cmp [fs_type], 2
jz ext2_HdWrite
cmp [fs_type], 16
jz @f
cmp [fs_type], 32
2348,8 → 2336,7
sub dword [esp], 0x200
jae @f
and dword [esp], 0
@@:
jmp .write_loop
@@: jmp .write_loop
 
hd_extend_file.zero_size:
xor eax, eax
2458,8 → 2445,7
cmp [hd_error], 0
jz @f
mov al, 11
@@:
stc
@@: stc
ret
 
;----------------------------------------------------------------
2477,8 → 2463,6
fs_HdSetFileEnd:
cmp [fs_type], 1
jz ntfs_HdSetFileEnd
cmp [fs_type], 2
jz ext2_HdSetFileEnd
cmp [fs_type], 16
jz @f
cmp [fs_type], 32
2711,8 → 2695,6
fs_HdGetFileInfo:
cmp [fs_type], 1
jz ntfs_HdGetFileInfo
cmp [fs_type], 2
jz ext2_HdGetFileInfo
cmp [fs_type], 16
jz @f
cmp [fs_type], 32
2741,8 → 2723,6
fs_HdSetFileInfo:
cmp [fs_type], 1
jz ntfs_HdSetFileInfo
cmp [fs_type], 2
jz ext2_HdSetFileInfo
cmp [fs_type], 16
jz @f
cmp [fs_type], 32
2793,8 → 2773,6
fs_HdDelete:
cmp [fs_type], 1
jz ntfs_HdDelete
cmp [fs_type], 2
jz ext2_HdDelete
cmp [fs_type], 16
jz @f
cmp [fs_type], 32
/kernel/branches/net/fs/fs.inc
21,14 → 21,12
 
 
iglobal
dir0:
db 'HARDDISK '
dir0: db 'HARDDISK '
db 'RAMDISK '
db 'FLOPPYDISK '
db 0
 
dir1:
db 'FIRST '
dir1: db 'FIRST '
db 'SECOND '
db 'THIRD '
db 'FOURTH '
36,8 → 34,7
 
not_select_IDE db 0
 
hd_address_table:
dd 0x1f0,0x00,0x1f0,0x10
hd_address_table: dd 0x1f0,0x00,0x1f0,0x10
dd 0x170,0x00,0x170,0x10
endg
 
391,7 → 388,7
.s:
sub eax, ebx
.f:
add eax, [known_part]; add eax,[fat32part]
add eax,[fat32part]
dec eax
xor edx, edx
imul eax, 100
796,6 → 793,5
stc
jmp i4
 
partition_string:
dd 0
partition_string: dd 0
db 32
/kernel/branches/net/fs/fs_lfn.inc
8,8 → 8,8
$Revision$
 
 
image_of_eax EQU esp+32
image_of_ebx EQU esp+20
image_of_eax EQU esp+36
image_of_ebx EQU esp+24
 
; System function 70 - files with long names (LFN)
; diamond, 2006
85,13 → 85,13
 
fs_additional_handlers:
dd biosdisk_handler, biosdisk_enum_root
dd dyndisk_handler, dyndisk_enum_root
; add new handlers here
dd 0
 
endg
 
file_system_lfn:
; in: ebx->fileinfo block
; in: eax->fileinfo block
; operation codes:
; 0 : read file
; 1 : read folder
105,6 → 105,7
; 9 : create directory
 
; parse file name
xchg ebx, eax
lea esi, [ebx+20]
lodsb
test al, al
168,8 → 169,8
cmp dword [ebx], 1
jnz .access_denied
xor eax, eax
mov ebp, [ebx+12] ;количество блоков для считывания
mov edx, [ebx+16] ;куда записывать рузельтат
mov ebp, [ebx+12]
mov edx, [ebx+16]
; add edx, std_application_base_address
push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags
384,8 → 385,7
.notfounda:
cmp edi, esp
jnz .notfound
call dword [edi+4]
add esp, 16
add esp, 8
jmp .notfound
 
.found1:
537,7 → 537,7
mov dword [image_of_eax], 5 ; not found
ret
@@:
mov [known_part], ecx ; mov [fat32part], ecx
mov [fat32part], ecx
push ebx esi
call choice_necessity_partition_1
pop esi ebx
852,8 → 852,6
jmp file_system_lfn.maindir_noesi
@@:
push ecx
push ecx
push biosdisk_cleanup
push fs_OnBd
mov edi, esp
jmp file_system_lfn.found2
862,11 → 860,10
cmp eax, [BiosDiskPartitions+ecx*4]
inc eax
cmc
biosdisk_cleanup:
ret
 
fs_OnBd:
pop edx edx edx edx
pop edx edx
; edx = disk number, ecx = partition number
; esi+ebp = name
call reserve_hd1
907,7 → 904,7
xor eax, eax
ret
.big:
push ecx edx
push ecx
push -'0'
mov ecx, 10
@@:
922,7 → 919,7
add al, '0'
stosb
jnz @b
pop edx ecx
pop ecx
pop eax
inc eax
ret
1018,11 → 1015,9
stosb
mov ecx, edx
rep movsb ;copy string
.ret:
ret
.ret: ret
 
.error:
add esp, 8
.error: add esp,8
or dword [esp+32], -1 ;error not found zerro at string ->[eax+APPDATA.cur_dir]
ret
.set:
/kernel/branches/net/fs/iso9660.inc
5,7 → 5,7
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
$Revision$
$Revision:1322 $
 
 
uglobal
54,14 → 54,12
je .reserve_ok_2
sti
call change_task
jmp .IDE_Channel_2
jmp .IDE_Channel_1
.reserve_ok_1:
mov [IDE_Channel_1], 1
sti
ret
.reserve_ok_2:
mov [IDE_Channel_2], 1
sti
ret
 
free_cd_channel:
69,11 → 67,9
jne .IDE_Channel_2
.IDE_Channel_1:
mov [IDE_Channel_1], 0
sti
ret
.IDE_Channel_2:
mov [IDE_Channel_2], 0
sti
ret
 
uglobal
/kernel/branches/net/fs/ntfs.inc
95,8 → 95,8
 
ntfs_setup: ; CODE XREF: part_set.inc
; By given bootsector, initialize some NTFS variables
; call ntfs_test_bootsec ; checking boot sector was already
; jc problem_fat_dec_count
call ntfs_test_bootsec
jc problem_fat_dec_count
movzx eax, byte [ebx+13]
mov [ntfs_data.sectors_per_cluster], eax
mov eax, [ebx+0x28]
942,18 → 942,6
pop edi ecx eax
ret
 
unichar_toupper:
push eax
call uni2ansi_char
cmp al, '_'
jz .unk
add esp, 4
call char_toupper
jmp ansi2uni_char
.unk:
pop eax
ret
 
ntfs_find_lfn:
; in: esi+ebp -> name
; out: CF=1 - file not found
1042,7 → 1030,8
push edi
@@:
lodsw
call unichar_toupper
call uni2ansi_char
call char_toupper
push eax
mov al, [edi]
inc edi
1049,8 → 1038,7
cmp al, '/'
jz .slash
call char_toupper
call ansi2uni_char
cmp ax, [esp]
cmp al, [esp]
pop eax
loopz @b
jz .found
1653,7 → 1641,6
xchg eax, [esp]
div [_10000000]
pop edx
.sec:
; edx:eax = number of seconds since January 1, 1601
push eax
mov eax, edx
1826,4 → 1813,3
pop edi esi
xor eax, eax
ret
 
/kernel/branches/net/fs/part_set.inc
9,7 → 9,6
 
 
;*************************************************************
;* 13.02.2010 Find all partition and check supported FS
;* 12.07.2007 Check all 4 entry of MBR and EMBR
;* 29.04.2006 Elimination of hangup after the
;* expiration hd_wait_timeout - Mario79
27,7 → 26,7
;******************************************************
PARTITION_START dd 0x3f
PARTITION_END dd 0
fs_type db 0 ; 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32
fs_type db 0 ; 0=none, 1=NTFS, 16=FAT16, 32=FAT32
align 4
 
fs_dependent_data_start:
55,8 → 54,7
fs_dependent_data_end:
file_system_data_size = $ - PARTITION_START
if file_system_data_size > 96
ERROR:
sizeof(file system data) too big!
ERROR: sizeof(file system data) too big!
end if
 
virtual at fs_dependent_data_start
76,36 → 74,10
.cur_index_size dd ?
.cur_index_buf dd ?
if $ > fs_dependent_data_end
ERROR:
increase sizeof(fs_dependent_data)!
ERROR: increase sizeof(fs_dependent_data)!
end if
end virtual
 
virtual at fs_dependent_data_start
; EXT2 data
ext2_data:
.log_block_size dd ?
.block_size dd ?
.count_block_in_block dd ?
.blocks_per_group dd ?
.inodes_per_group dd ?
.global_desc_table dd ?
.root_inode dd ? ; pointer to root inode in memory
.inode_size dd ?
.count_pointer_in_block dd ? ; block_size / 4
.count_pointer_in_block_square dd ? ; (block_size / 4)**2
.ext2_save_block dd ? ; ¡«®ª ­  £«®¡ «ì­ãî 1 ¯à®æ¥¤ãàã
.ext2_temp_block dd ? ; ¡«®ª ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà
.ext2_save_inode dd ? ; inode ­  £«®¡ «ì­ãî ¯à®æ¥¤ãàã
.ext2_temp_inode dd ? ; inode ¤«ï ¬¥«ª¨å ¯à®æ¥¤ãà
.sb dd ? ; superblock
.groups_count dd ?
if $ > fs_dependent_data_end
ERROR:
increase sizeof(fs_dependent_data)!
end if
end virtual
 
;***************************************************************************
; End place
; Mario79
133,7 → 105,6
db 0xd6 ; Old Multiuser DOS secured: fat16 >32M
db 0x07 ; NTFS
db 0x27 ; NTFS, hidden
db 0x83 ; Linux native file system (ext2fs)
partition_types_end:
 
 
147,16 → 118,18
endg
 
; Partition chain used:
; MBR <---------------------
; | |
; |-> PARTITION1 |
; |-> EXTENDED PARTITION - ;not need be second partition
; |-> PARTITION3
; |-> PARTITION4
; MBR ; PARTITION2 ; PARTITION3 ; PARTITION4
;==========================================================
; fat16/32 +-- fat16/32 +-- fat16/32 +-- fat16/32 +--
; extended --+ extended --+ extended --+ extended --+
; 0 0 0 0
; 0 0 0 0
; Notes:
; - extended partition need to be in second entry on table
; - it will skip over removed partitions
 
set_PARTITION_variables:
set_FAT32_variables: ;deprecated
and [problem_partition], 0
set_FAT32_variables:
mov [problem_partition],0
call reserve_hd1
call reserve_hd_channel
 
166,12 → 139,12
je problem_hd
 
xor ecx, ecx ; partition count
;or edx,-1 ; flag for partition
xor eax, eax ; address MBR
mov edx,-1 ; flag for partition
xor eax,eax ; read MBR
xor ebp, ebp ; extended partition start
 
new_mbr:
test ebp, ebp ; is there extended partition? (MBR or EMBR)
new_partition:
test ebp,ebp ; is there extended partition?
jnz extended_already_set; yes
xchg ebp, eax ; no. set it now
 
184,164 → 157,153
 
cmp word [ebx+0x1fe], 0xaa55; is it valid boot sector?
jnz end_partition_chain
push eax ; push only one time
cmp dword [ebx+0x1be+0xc], 0; skip over empty partition
jnz test_primary_partition_0
; jz next_partition
jnz .next_primary_partition
cmp dword [ebx+0x1be+0xc+16], 0
jnz test_primary_partition_1
jnz next_primary_partition
cmp dword [ebx+0x1be+0xc+16+16], 0
jnz test_primary_partition_2
jnz next_primary_partition_1
cmp dword [ebx+0x1be+0xc+16+16+16], 0
jnz test_primary_partition_3
pop eax
jmp end_partition_chain
jnz next_primary_partition_2
jmp next_partition
 
test_primary_partition_0:
.next_primary_partition:
push eax
mov al, [ebx+0x1be+4]; get primary partition type
call scan_partition_types
jnz test_primary_partition_1; no. skip over
pop eax
jnz next_primary_partition ; no. skip over
 
inc ecx
cmp ecx, [known_part]; is it wanted partition?
jnz test_primary_partition_1; no
cmp ecx,[fat32part] ; is it wanted partition?
jnz next_primary_partition ; no
 
pop eax
;mov edx, eax ; start sector
add eax, [ebx+0x1be+8] ; add relative start
;mov [PARTITON_START],edx
;push edx
mov edx, [ebx+0x1be+12] ; length
;add edx, eax ; add length
;dec edx ; PARTITION_END is inclusive
;mov [PARTITION_END], edx ; note that this can be changed
mov edx, eax ; start sector
add edx, [ebx+0x1be+8] ; add relative start
push edx
add edx, [ebx+0x1be+12] ; add length
dec edx ; PARTITION_END is inclusive
mov [PARTITION_END], edx ; note that this can be changed
; when file system data will be available
mov cl, [ebx+0x1be+4] ; fs_type
;mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS)
;pop edx
jmp hd_and_partition_ok
mov dl, [ebx+0x1be+4]
mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS)
pop edx
 
test_primary_partition_1:
next_primary_partition:
push eax
mov al, [ebx+0x1be+4+16]; get primary partition type
call scan_partition_types
jnz test_primary_partition_2 ; no. skip over
pop eax
jnz next_primary_partition_1 ; no. skip over
 
inc ecx
cmp ecx, [known_part]; is it wanted partition?
jnz test_primary_partition_2 ; no
cmp ecx,[fat32part] ; is it wanted partition?
jnz next_primary_partition_1 ; no
 
pop eax
add eax, [ebx+0x1be+8+16]
mov edx, [ebx+0x1be+12+16]
mov cl, [ebx+0x1be+4+16]
jmp hd_and_partition_ok
mov edx, eax
add edx, [ebx+0x1be+8+16]
push edx
add edx, [ebx+0x1be+12+16]
dec edx
mov [PARTITION_END], edx
mov dl, [ebx+0x1be+4+16]
mov [fs_type], dl
pop edx
 
;mov edx, eax
;add edx, [ebx+0x1be+8+16]
;push edx
;add edx, [ebx+0x1be+12+16]
;dec edx
;mov [PARTITION_END], edx
;mov al, [ebx+0x1be+4+16]
;mov [fs_type], dl
;pop edx
 
test_primary_partition_2:
next_primary_partition_1:
push eax
mov al, [ebx+0x1be+4+16+16]; get primary partition type
call scan_partition_types
jnz test_primary_partition_3 ; no. skip over
pop eax
jnz next_primary_partition_2 ; no. skip over
 
inc ecx
cmp ecx, [known_part]; is it wanted partition?
jnz test_primary_partition_3 ; no
cmp ecx,[fat32part] ; is it wanted partition?
jnz next_primary_partition_2 ; no
 
pop eax
add eax, [ebx+0x1be+8+16+16]
mov edx, [ebx+0x1be+12+16+16]
mov cl, [ebx+0x1be+4+16+16]
jmp hd_and_partition_ok
;mov edx, eax
;add edx, [ebx+0x1be+8+16+16]
;push edx
;add edx, [ebx+0x1be+12+16+16]
;dec edx
;mov [PARTITION_END], edx
;mov al, [ebx+0x1be+4+16+16]
;mov [fs_type], dl
;pop edx
mov edx, eax
add edx, [ebx+0x1be+8+16+16]
push edx
add edx, [ebx+0x1be+12+16+16]
dec edx
mov [PARTITION_END], edx
mov dl, [ebx+0x1be+4+16+16]
mov [fs_type], dl
pop edx
 
test_primary_partition_3:
next_primary_partition_2:
push eax
mov al, [ebx+0x1be+4+16+16+16]; get primary partition type
call scan_partition_types
jnz test_ext_partition_0 ; no. skip over
pop eax
jnz next_partition ; no. skip over
 
inc ecx
cmp ecx, [known_part]; is it wanted partition?
jnz test_ext_partition_0; no
cmp ecx,[fat32part] ; is it wanted partition?
jnz next_partition ; no
 
pop eax
add eax, [ebx+0x1be+8+16+16+16]
mov edx, [ebx+0x1be+12+16+16+16]
mov cl, [ebx+0x1be+4+16+16+16]
jmp hd_and_partition_ok
mov edx, eax
add edx, [ebx+0x1be+8+16+16+16]
push edx
add edx, [ebx+0x1be+12+16+16+16]
dec edx
mov [PARTITION_END], edx
mov dl, [ebx+0x1be+4+16+16+16]
mov [fs_type], dl
pop edx
 
;mov edx, eax
;add edx, [ebx+0x1be+8+16+16+16]
;push edx
;add edx, [ebx+0x1be+12+16+16+16]
;dec edx
;mov [PARTITION_END], edx
;mov al, [ebx+0x1be+4+16+16+16]
;mov [fs_type], dl
;pop edx
 
test_ext_partition_0:
pop eax ; ¯à®áâ® ¢ëª¨¤ë¢ ¥¬ ¨§ á⥪ 
next_partition:
push eax
mov al, [ebx+0x1be+4]; get extended partition type
call scan_extended_types
jnz test_ext_partition_1
pop eax
jnz next_partition_1
 
mov eax, [ebx+0x1be+8]; add relative start
test eax, eax ; is there extended partition?
jnz new_mbr ; yes. read it
jnz new_partition ; yes. read it
 
test_ext_partition_1:
next_partition_1:
push eax
mov al, [ebx+0x1be+4+16]; get extended partition type
call scan_extended_types
jnz test_ext_partition_2
pop eax
jnz next_partition_2
 
mov eax, [ebx+0x1be+8+16]; add relative start
test eax, eax ; is there extended partition?
jnz new_mbr ; yes. read it
jnz new_partition ; yes. read it
 
test_ext_partition_2:
next_partition_2:
push eax
mov al, [ebx+0x1be+4+16+16]; get extended partition type
call scan_extended_types
jnz test_ext_partition_3
pop eax
jnz next_partition_3
 
mov eax, [ebx+0x1be+8+16+16]; add relative start
test eax, eax ; is there extended partition?
jnz new_mbr ; yes. read it
jnz new_partition ; yes. read it
 
test_ext_partition_3:
next_partition_3:
push eax
mov al, [ebx+0x1be+4+16+16+16]; get extended partition type
call scan_extended_types
pop eax
jnz end_partition_chain; no. end chain
 
mov eax, [ebx+0x1be+8+16+16+16]; get start of extended partition
test eax, eax ; is there extended partition?
jnz new_mbr ; yes. read it
jnz new_partition ; yes. read it
 
end_partition_chain:
;mov [partition_count],ecx
mov [partition_count],ecx
 
;cmp edx,-1 ; found wanted partition?
;jnz hd_and_partition_ok ; yes. install it
;jmp problem_partition_or_fat
problem_hd:
or [problem_partition], 2
jmp return_from_part_set
cmp edx,-1 ; found wanted partition?
jnz hd_and_partition_ok ; yes. install it
jmp problem_partition_or_fat
 
 
scan_partition_types:
push ecx
mov edi, partition_types
361,32 → 323,25
ret
 
problem_fat_dec_count: ; bootsector is missing or another problem
; dec [partition_count] ; remove it from partition_count
dec [partition_count] ; remove it from partition_count
 
problem_partition_or_fat:
or [problem_partition], 1
problem_hd:
popad
 
return_from_part_set:
popad
;mov [fs_type],0
mov [fs_type],0
call free_hd_channel
mov [hd1_status], 0 ; free
mov [problem_partition],1
ret
 
hd_and_partition_ok:
 
;eax = PARTITION_START edx=PARTITION_LENGTH cl=fs_type
mov [fs_type], cl
;mov eax,edx
mov eax,edx
mov [PARTITION_START], eax
add edx, eax
dec edx
mov [PARTITION_END], edx
mov edx, [PARTITION_END]
sub edx, eax
inc edx ; edx = length of partition
 
; mov edx, [PARTITION_END]
; sub edx, eax
; inc edx ; edx = length of partition § ç¥¬ ®­® ­ ¬??
 
; mov [hd_setup],1
mov ebx, buffer
call hd_read ; read boot sector of partition
411,22 → 366,15
add eax, [PARTITION_START]
call hd_read
cmp [hd_error], 0
jnz problem_fat_dec_count ; no chance...
jnz problem_fat_dec_count ; ­¥ áã¤ì¡ ...
boot_read_ok:
 
; mov [hd_setup], 0
; if we are running on NTFS, check bootsector
 
call ntfs_test_bootsec ; test ntfs
; cmp [fs_type], 7
; jz ntfs_setup
call ntfs_test_bootsec
jnc ntfs_setup
 
call ext2_test_superblock ; test ext2fs
jnc ext2_setup
 
mov eax, [PARTITION_START] ;ext2 test changes [buffer]
call hd_read
cmp [hd_error], 0
jnz problem_fat_dec_count
 
cmp word [ebx+0x1fe], 0xaa55; is it valid boot sector?
jnz problem_fat_dec_count
 
531,4 → 479,3
call free_hd_channel
mov [hd1_status], 0 ; free
ret
 
/kernel/branches/net/hid/keyboard.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8,6 → 8,8
$Revision$
 
 
;// mike.dld [
 
VKEY_LSHIFT = 0000000000000001b
VKEY_RSHIFT = 0000000000000010b
VKEY_LCONTROL = 0000000000000100b
49,32 → 51,28
dd hotkey_test4
hotkey_tests_num = 5
endg
;---------------------------------------------------------------------
 
hotkey_test0:
test al, al
setz al
ret
;---------------------------------------------------------------------
hotkey_test1:
test al, al
setnp al
ret
;---------------------------------------------------------------------
hotkey_test2:
cmp al, 3
setz al
ret
;---------------------------------------------------------------------
hotkey_test3:
cmp al, 1
setz al
ret
;---------------------------------------------------------------------
hotkey_test4:
cmp al, 2
setz al
ret
;---------------------------------------------------------------------
 
hotkey_do_test:
push eax
mov edx, [kb_state]
85,7 → 83,6
and eax, 15
cmp al, hotkey_tests_num
jae .fail
xchg eax, edx
and al, 3
call [hotkey_tests + edx*4]
92,29 → 89,18
cmp al, 1
pop eax
ret
;--------------------------------------
.fail:
stc
pop eax
ret
;---------------------------------------------------------------------
align 4
set_keyboard_data:
movzx eax, word[TASK_COUNT]; top window process
movzx eax, word[WIN_POS+eax*2]
shl eax, 8
mov al, [SLOT_BASE+eax+APPDATA.keyboard_mode]
mov [keyboard_mode], al
mov eax, ecx
push ebx esi edi ebp
call send_scancode
pop ebp edi esi ebx
ret
;---------------------------------------------------------------------
align 4
irq1:
; save_ring3_context
; mov ax, os_data
; mov ds, ax
; mov es, ax
 
movzx eax, word[TASK_COUNT]; top window process
movzx eax, word[WIN_POS+eax*2]
shl eax, 8
122,18 → 108,17
mov [keyboard_mode], al
in al, 0x60
;--------------------------------------
send_scancode:
mov [keyboard_data], al
 
; ch = scancode
; cl = ext_code
; bh = 0 - normal key
; bh = 1 - modifier (Shift/Ctrl/Alt)
; bh = 2 - extended code
 
mov ch, al
cmp al, 0xE0
je @f
cmp al, 0xE1
jne .normal_code
@@:
140,148 → 125,100
mov bh, 2
mov [ext_code], al
jmp .writekey
;--------------------------------------
.normal_code:
mov cl, 0
xchg cl, [ext_code]
and al, 0x7F
mov bh, 1
@@:
cmp al, 0x2A
@@: cmp al,0x2A
jne @f
cmp cl, 0xE0
je .writekey
mov eax, VKEY_LSHIFT
jmp .modifier
;--------------------------------------
@@:
cmp al, 0x36
@@: cmp al,0x36
jne @f
cmp cl, 0xE0
je .writekey
mov eax, VKEY_RSHIFT
jmp .modifier
;--------------------------------------
@@:
cmp al, 0x38
@@: cmp al,0x38
jne @f
mov eax, VKEY_LALT
test cl, cl
jz .modifier
mov al, VKEY_RALT
jmp .modifier
;--------------------------------------
@@:
cmp al, 0x1D
@@: cmp al,0x1D
jne @f
mov eax, VKEY_LCONTROL
test cl, cl
jz .modifier
mov al, VKEY_RCONTROL
cmp cl, 0xE0
jz .modifier
mov [ext_code], cl
jmp .writekey
;--------------------------------------
@@:
cmp al, 0x3A
@@: cmp al,0x3A
jne @f
mov bl, 4
mov eax, VKEY_CAPSLOCK
jmp .no_key.xor
;--------------------------------------
@@:
cmp al, 0x45
@@: cmp al,0x45
jne @f
test cl, cl
jnz .writekey
mov bl, 2
mov eax, VKEY_NUMLOCK
jmp .no_key.xor
;--------------------------------------
@@:
cmp al, 0x46
@@: cmp al,0x46
jne @f
mov bl, 1
mov eax, VKEY_SCRLOCK
jmp .no_key.xor
;--------------------------------------
@@:
xor ebx, ebx
test ch, ch
js .writekey
movzx eax, ch ; plain key
mov bl, [keymap+eax]
mov edx, [kb_state]
test dl, VKEY_CONTROL ; ctrl alt del
jz .noctrlaltdel
test dl, VKEY_ALT
jz .noctrlaltdel
cmp ch, 53h
jne .noctrlaltdel
mov [ctrl_alt_del], 1
.noctrlaltdel:
test dl, VKEY_CONTROL ; ctrl on ?
jz @f
sub bl, 0x60
@@:
test dl, VKEY_CAPSLOCK ; caps lock on ?
jz .no_caps_lock
test dl, VKEY_SHIFT ; shift on ?
jz .keymap_shif
jmp @f
;--------------------------------------
.no_caps_lock:
test dl, VKEY_SHIFT ; shift on ?
@@: test dl,VKEY_SHIFT ; shift on ?
jz @f
.keymap_shif:
mov bl, [keymap_shift+eax]
@@:
test dl, VKEY_ALT ; alt on ?
@@: test dl,VKEY_ALT ; alt on ?
jz @f
mov bl, [keymap_alt+eax]
@@:
mov bh, 0
jmp .writekey
;--------------------------------------
.modifier:
test ch, ch
js .modifier.up
or [kb_state], eax
jmp .writekey
;--------------------------------------
.modifier.up:
not eax
and [kb_state], eax
jmp .writekey
;--------------------------------------
.no_key.xor:
mov bh, 0
test ch, ch
js .writekey
xor [kb_state], eax
xor [kb_lights], bl
call set_lights
 
.writekey:
; test for system hotkeys
movzx eax, ch
288,7 → 225,6
cmp bh, 1
ja .nohotkey
jb @f
xor eax, eax
@@:
mov eax, [hotkey_scancodes + eax*4]
295,15 → 231,12
.hotkey_loop:
test eax, eax
jz .nohotkey
mov cl, 0
call hotkey_do_test
jc .hotkey_cont
mov cl, 2
call hotkey_do_test
jc .hotkey_cont
mov cl, 4
call hotkey_do_test
jnc .hotkey_found
310,7 → 243,6
.hotkey_cont:
mov eax, [eax]
jmp .hotkey_loop
;--------------------------------------
.hotkey_found:
mov eax, [eax+8]
; put key in buffer for process in slot eax
318,7 → 250,6
@@:
cmp dword [edi], 0
jz .found_free
add edi, 8
cmp edi, hotkey_buffer+120*8
jb @b
329,7 → 260,6
movzx eax, ch
cmp bh, 1
jnz @f
xor eax, eax
@@:
mov [edi+4], ax
336,40 → 266,37
mov eax, [kb_state]
mov [edi+6], ax
jmp .exit.irq1
;--------------------------------------
.nohotkey:
cmp [keyboard_mode], 0; return from keymap
jne .scancode
test bh, bh
jnz .exit.irq1
test bl, bl
jz .exit.irq1
 
;.........................Part1 Start.......Code by Rus, optimize by Ghost...................................
test [kb_state], VKEY_NUMLOCK
jz .dowrite
cmp cl, 0xE0
jz .dowrite
cmp ch, 55
jnz @f
mov bl, 0x2A ;*
jmp .dowrite
;--------------------------------------
@@:
cmp ch, 71
jb .dowrite
cmp ch, 83
ja .dowrite
;push eax
movzx eax, ch
mov bl, [numlock_map + eax - 71]
;pop eax
 
;.........................Part1 End.................................................
 
jmp .dowrite
;--------------------------------------
.scancode:
mov bl, ch
.dowrite:
379,10 → 306,17
inc eax
mov [KEY_COUNT], al
mov [KEY_COUNT+eax], bl
 
.exit.irq1:
mov [check_idle_semaphore], 5
 
; mov al,0x20 ; ready for next irq
; out 0x20,al
 
; restore_ring3_context
; iret
ret
;---------------------------------------------------------------------
 
set_lights:
mov al, 0xED
call kb_write
389,7 → 323,9
mov al, [kb_lights]
call kb_write
ret
;---------------------------------------------------------------------
 
;// mike.dld ]
;..........................Part2 Start.......Code by Rus.......................................
numlock_map:
db 0x37 ;Num 7
db 0x38 ;Num 8
404,4 → 340,4
db 0x33 ;Num 3
db 0x30 ;Num 0
db 0x2E ;Num .
;---------------------------------------------------------------------
;..........................Part2 End................................................
/kernel/branches/net/hid/mousedrv.inc
28,8 → 28,7
 
iglobal
mouse_delay dd 10
mouse_speed_factor:
dd 3
mouse_speed_factor: dd 3
mouse_timer_ticks dd 0
endg
 
293,20 → 292,21
add ecx, eax
add ecx, [_WinMapAddress]
mov eax, [CURRENT_TASK]
cmp al, [ecx]
movzx ebx, byte [ecx]
cmp eax,ebx
je yes_mouse_disable
cmp al, [ecx+16]
movzx ebx, byte [ecx+16]
cmp eax,ebx
je yes_mouse_disable
add ebx, 10
cmp ebx, [Screen_Max_Y]
jae no_mouse_disable
mov ebx, [Screen_Max_X]
inc ebx
imul ebx, 10
add ecx, ebx
cmp al, [ecx]
movzx ebx, byte [ecx]
cmp eax,ebx
je yes_mouse_disable
cmp al, [ecx+16]
movzx ebx, byte [ecx+16]
cmp eax,ebx
je yes_mouse_disable
jmp no_mouse_disable
yes_mouse_disable:
/kernel/branches/net/init.inc
139,10 → 139,14
dec [pg_data.kernel_tables-OS_BASE]
 
mov [edx], eax
add eax, 0x00400000
add edx, 4
 
mov edi, [tmp_page_tabs]
jmp .map_kernel_heap ; new kernel fits to the first 4Mb - nothing to do with ".map_low"
mov eax, 0x400000+PG_SW
mov ecx, [tmp_page_tabs]
sub ecx, 0x400000
shr ecx, 12 ;ecx/=4096
jmp .map_low
.no_PSE:
mov eax, PG_SW
mov ecx, [tmp_page_tabs]
155,7 → 159,6
dec ecx
jnz @B
 
.map_kernel_heap:
mov ecx, [pg_data.kernel_tables-OS_BASE]
shl ecx, 10
xor eax, eax
167,6 → 170,7
mov edi, edx
 
.map_kernel_tabs:
 
stosd
add eax, 0x1000
dec ecx
266,6 → 270,7
add ebx, [pg_data.pagemap_size-OS_BASE]
mov [page_end-OS_BASE], ebx
 
mov [pg_data.pg_mutex-OS_BASE], 0
ret
endp
 
288,8 → 293,7
mov esi, edi
xor eax, eax
cld ; paranoia
@@:
lodsb
@@: lodsb
add ah, al
loop @b
jnz .pcibios_nxt2; control summ must be zero
432,123 → 436,3
ret
endp
 
uglobal
align 4
acpi_rsdp rd 1
acpi_rsdt rd 1
acpi_madt rd 1
 
acpi_dev_data rd 1
acpi_dev_size rd 1
 
acpi_rsdt_base rd 1
acpi_madt_base rd 1
acpi_lapic_base rd 1
acpi_ioapic_base rd 1
endg
 
ACPI_HI_RSDP_WINDOW_START equ 0x000E0000
ACPI_HI_RSDP_WINDOW_END equ 0x00100000
ACPI_RSDP_CHECKSUM_LENGTH equ 20
ACPI_MADT_SIGN equ 0x43495041
 
 
acpi_locate:
push ebx
mov ebx, ACPI_HI_RSDP_WINDOW_START
.check:
cmp [ebx], dword 0x20445352
jne .next
cmp [ebx+4], dword 0x20525450
jne .next
 
mov edx, ebx
mov ecx, ACPI_RSDP_CHECKSUM_LENGTH
xor eax, eax
.sum:
add al, [edx]
inc edx
loop .sum
 
test al, al
jnz .next
 
mov eax, ebx
pop ebx
ret
.next:
add ebx, 16
cmp ebx, ACPI_HI_RSDP_WINDOW_END
jb .check
 
pop ebx
xor eax, eax
ret
 
align 4
rsdt_find: ;ecx= rsdt edx= SIG
push ebx
push esi
 
lea ebx, [ecx+36]
mov esi, [ecx+4]
add esi, ecx
.next:
mov eax, [ebx]
cmp [eax], edx
je .done
 
add ebx, 4
cmp ebx, esi
jb .next
 
xor eax, eax
pop esi
pop ebx
ret
 
.done:
mov eax, [ebx]
pop esi
pop ebx
ret
 
 
align 4
 
check_acpi:
 
call acpi_locate
test eax, eax
jz .done
 
mov ecx, [eax+16]
mov edx, ACPI_MADT_SIGN
mov [acpi_rsdt_base-OS_BASE], ecx
call rsdt_find
test eax, eax
jz .done
 
mov [acpi_madt_base-OS_BASE], eax
mov ecx, [eax+36]
mov [acpi_lapic_base-OS_BASE], ecx
 
lea edx, [eax+44]
mov ecx, [eax+4]
add ecx, eax
.check:
mov eax, [edx]
cmp al, 1
je .ioapic
 
.next:
movzx eax, ah
add edx, eax
cmp edx, ecx
jb .check
.done:
ret
.ioapic:
mov eax, [edx+4]
mov [acpi_ioapic_base-OS_BASE], eax
ret
/kernel/branches/net/kernel32.inc
15,32 → 15,59
 
$Revision$
 
struct POINT
x dd ?
y dd ?
ends
 
struct RECT
left dd ?
top dd ?
right dd ?
bottom dd ?
ends
;struc db [a] { common . db a
; if ~used .
; display 'not used db: ',`.,13,10
; end if }
;struc dw [a] { common . dw a
; if ~used .
; display 'not used dw: ',`.,13,10
; end if }
;struc dd [a] { common . dd a
; if ~used .
; display 'not used dd: ',`.,13,10
; end if }
;struc dp [a] { common . dp a
; if ~used .
; display 'not used dp: ',`.,13,10
; end if }
;struc dq [a] { common . dq a
; if ~used .
; display 'not used dq: ',`.,13,10
; end if }
;struc dt [a] { common . dt a
; if ~used .
; display 'not used dt: ',`.,13,10
; end if }
 
struct BOX
left dd ?
top dd ?
width dd ?
height dd ?
ends
struc RECT {
.left dd ?
.top dd ?
.right dd ?
.bottom dd ?
}
virtual at 0
RECT RECT
end virtual
 
struct DISPMODE
width dw ?
height dw ?
bpp dw ?
freq dw ?
ends
struc BOX {
.left dd ?
.top dd ?
.width dd ?
.height dd ?
}
virtual at 0
BOX BOX
end virtual
 
struc DISPMODE {
.width rw 1
.height rw 1
.bpp rw 1
.freq rw 1
}
 
; constants definition
WSTATE_NORMAL = 00000000b
WSTATE_MAXIMIZED = 00000001b
53,20 → 80,24
WSTYLE_HASCAPTION = 00010000b
WSTYLE_CLIENTRELATIVE = 00100000b
 
struct TASKDATA
event_mask dd ?
pid dd ?
struc TASKDATA
{
.event_mask dd ?
.pid dd ?
dw ?
state db ?
.state db ?
db ?
dw ?
wnd_number db ?
.wnd_number db ?
db ?
mem_start dd ?
counter_sum dd ?
counter_add dd ?
cpu_usage dd ?
ends
.mem_start dd ?
.counter_sum dd ?
.counter_add dd ?
.cpu_usage dd ?
}
virtual at 0
TASKDATA TASKDATA
end virtual
 
TSTATE_RUNNING = 0
TSTATE_RUN_SUSPENDED = 1
77,87 → 108,82
TSTATE_FREE = 9
 
; structures definition
struct WDATA
box BOX
cl_workarea dd ?
cl_titlebar dd ?
cl_frames dd ?
reserved db ?
fl_wstate db ?
fl_wdrawn db ?
fl_redraw db ?
ends
 
struc WDATA {
.box BOX
.cl_workarea dd ?
.cl_titlebar dd ?
.cl_frames dd ?
.reserved db ?
.fl_wstate db ?
.fl_wdrawn db ?
.fl_redraw db ?
.sizeof:
}
virtual at 0
WDATA WDATA
end virtual
label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3
 
struct DBG_REGS
dr0 dd ?
dr1 dd ?
dr2 dd ?
dr3 dd ?
dr7 dd ?
ends
struc APPDATA
{
.app_name db 11 dup(?)
db 5 dup(?)
 
struct APPDATA
app_name rb 11
rb 5
.fpu_state dd ? ;+16
.ev_count_ dd ? ;unused ;+20
.exc_handler dd ? ;+24
.except_mask dd ? ;+28
.pl0_stack dd ? ;unused ;+32
.heap_base dd ? ;+36
.heap_top dd ? ;+40
.cursor dd ? ;+44
.fd_ev dd ? ;+48
.bk_ev dd ? ;+52
.fd_obj dd ? ;+56
.bk_obj dd ? ;+60
.saved_esp dd ? ;+64
.io_map rd 2 ;+68
.dbg_state dd ? ;+76
.cur_dir dd ? ;+80
.wait_timeout dd ? ;+84
.saved_esp0 dd ? ;+88
.wait_begin dd ? ;+92 +++
.wait_test dd ? ;+96 +++
.wait_param dd ? ;+100 +++
.tls_base dd ? ;+104
.dlls_list_ptr dd ? ;+108
db 16 dup(?) ;+112
 
fpu_state dd ? ;+16
ev_count_ dd ? ;unused ;+20
exc_handler dd ? ;+24
except_mask dd ? ;+28
pl0_stack dd ? ;+32
heap_base dd ? ;+36
heap_top dd ? ;+40
cursor dd ? ;+44
fd_ev dd ? ;+48
bk_ev dd ? ;+52
fd_obj dd ? ;+56
bk_obj dd ? ;+60
saved_esp dd ? ;+64
io_map rd 2 ;+68
dbg_state dd ? ;+76
cur_dir dd ? ;+80
wait_timeout dd ? ;+84
saved_esp0 dd ? ;+88
wait_begin dd ? ;+92 +++
wait_test dd ? ;+96 +++
wait_param dd ? ;+100 +++
tls_base dd ? ;+104
dlls_list_ptr dd ? ;+108
rb 16 ;+112
 
wnd_shape dd ? ;+128
wnd_shape_scale dd ? ;+132
.wnd_shape dd ? ;+128
.wnd_shape_scale dd ? ;+132
dd ? ;+136
mem_size dd ? ;+140
saved_box BOX
ipc_start dd ?
ipc_size dd ?
event_mask dd ?
debugger_slot dd ?
.mem_size dd ? ;+140
.saved_box BOX
.ipc_start dd ?
.ipc_size dd ?
.event_mask dd ?
.debugger_slot dd ?
dd ?
keyboard_mode db ?
rb 3
dir_table dd ?
dbg_event_mem dd ?
dbg_regs DBG_REGS
wnd_caption dd ?
wnd_clientbox BOX
.keyboard_mode db ?
db 3 dup(?)
.dir_table dd ?
.dbg_event_mem dd ?
.dbg_regs:
.dbg_regs.dr0 dd ?
.dbg_regs.dr1 dd ?
.dbg_regs.dr2 dd ?
.dbg_regs.dr3 dd ?
.dbg_regs.dr7 dd ?
.wnd_caption dd ?
.wnd_clientbox BOX
}
virtual at 0
APPDATA APPDATA
end virtual
 
ends
 
 
 
 
;// mike.dld, 2006-29-01 ]
 
struct MUTEX
lhead LHEAD
count dd ?
ends
 
 
; Core functions
include "core/sync.inc" ; macros for synhronization objects
include "core/sys32.inc" ; process management
173,9 → 199,6
include "core/exports.inc"
include "core/string.inc"
include "core/v86.inc" ; virtual-8086 manager
include "core/irq.inc" ; irq handling functions
include "core/apic.inc" ; Interrupt Controller functions
include "core/timers.inc"
 
; GUI stuff
include "gui/window.inc"
187,8 → 210,6
 
; file system
 
include "blkdev/disk.inc" ; support for plug-n-play disks
include "blkdev/disk_cache.inc" ; caching for plug-n-play disks
include "fs/fs.inc" ; syscall
include "fs/fat32.inc" ; read / write for fat32 filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem
196,7 → 217,6
include "blkdev/rd.inc" ; ramdisk read /write
include "fs/fs_lfn.inc" ; syscall, version 2
include "fs/iso9660.inc" ; read for iso9660 filesystem CD
include "fs/ext2.inc" ; read / write for ext2 filesystem
 
; sound
 
206,7 → 226,6
 
include "video/vesa12.inc" ; Vesa 1.2 functions
include "video/vesa20.inc" ; Vesa 2.0 functions
include "video/blitter.inc" ;
include "video/vga.inc" ; VGA 16 color functions
include "video/cursors.inc" ; cursors functions
 
/kernel/branches/net/sound/playnote.inc
21,7 → 21,7
align 4
sound_interface:
 
cmp eax, ebx ; this is subfunction #55 ?
cmp eax, edi ; this is subfunction #55 ?
jne retFunc55 ; if no then return.
 
cmp byte [sound_flag], 0
31,12 → 31,12
or al, al ; player is busy ?
jnz retFunc55 ; return counter delay Note
 
mov [memAdrNote], esi;edx
mov [memAdrNote],edx
call get_pid
mov [pidProcessNote], eax
xor eax, eax ; Ok! EAX = 0
retFunc55:
mov [esp+32], eax ; return value EAX for application
mov [esp+36], eax ; return value EAX for application
ret
 
iglobal
/kernel/branches/net/memmap.inc
62,36 → 62,33
; 3c dword cpu usage in cpu timer tics
;
;
; 5000 -> 68FF free (6k6)
; 6900 -> 6EFF saved picture under mouse pointer (1k5)
; 5000 -> 68FF free
; 6900 -> 6EFF saved picture under mouse pointer
;
; 6F00 -> 6FFF free (256)
; 6F00 -> 6FFF free
;
; 7000 -> 7FFF used CD driver
;
; 8000 -> A3FF used FLOPPY driver
;
; A400 -> B0FF free (3k3), unused ACTIVE_PROC_STACK
; A400 -> B0FF free
 
; B100 -> B307 IDT for int_0x00..int_0x40
 
; B308 -> BFFF free (3k3)
; B308 -> BFFF free
 
; C000 -> C3FF window stack C000 no of windows - all in words
; C402 -> C7FF window position in stack
; D000 -> D1FF FDC controller
; D200 -> D3FF FDC controller for Fat12
; D400 -> DFFF free (3k)
; D400 -> DFFF free
; E000 byte multitasking started
; E020 dword putpixel address
; E024 dword getpixel address
; E030 dword Vesa 1.2 pm bank switch address
; E034 -> F1FF free (4k5)
; F200 dword mousepicture -pointer
; F204 dword mouse appearance counter
; F208 -> F2FF free (248)
; F300 dword x & y temp for windowmove
; F304 -> F3FF free (252)
; F400 byte no of keys in buffer
; F401 byte 'buffer'
; F402 -> F4FF reserved for keys
99,13 → 96,8
; F501 dword 'buffer'
; F502 -> F5FF reserved for buttons
; F600 dword tsc / second
; F604 byte (unused?) mouse port: 1 ps2, 2 com1, 3 com2
; F605 -> FAFF free (1k2)
; FB00 -> FB0F mouse memory 00 chunk count, that includes:
; FB08 word -- mouse H-scroll
; FB0A word -- mouse x
; FB0C word -- mouse y
; FB0E word -- mouse V-scroll
; F604 byte mouse port: 1 ps2, 2 com1, 3 com2
; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y
; FB10 -> FB17 mouse color mem
; FB21 x move
; FB22 y move
117,21 → 109,18
; FBF1 byte bits per pixel
; FC00 -> FCFE com1/ps2 buffer
; FCFF com1/ps2 buffer count starting from FC00
; FD00 -> FDFF free (256)
; FE00 dword screen x size
; FE04 dword screen y size
; FE08 dword screen y multiplier
; FE0C dword screen mode
; FE10 -> FE7F free (112)
; FE80 dword address of LFB in physical
; FE84 dword address of applications memory start in physical ?
; FE84 dword address of applications memory start in physical
; FE88 dword address of button list
; FE8C dword memory to use
; FE90 -> FEFF free (112)
; FF00 byte 1 = system shutdown request
; FF01 byte task activation request?
; FFF0 byte >0 if redraw background request from app
; FFF1 byte >0 if background changed
; FF01 dword free
; FFF0 byte 1 = redraw background request from app
; FFF1 byte 1 = diskette int occur
; FFF2 write and read bank in screen
; FFF4 byte 0 if first mouse draw & do not return picture under
; FFF5 byte 1 do not draw pointer
188,22 → 177,20
; BC dword address of debug event memory
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
;
; 0x80090000 -> 9FFFF tmp (64k) - unused?
; 0x80090000 -> 9FFFF tmp
; 0x800A0000 -> AFFFF screen access area
; 0x800B0000 -> FFFFF bios rest in peace -area (320k) ?
; 0x80100000 -> 27FFFF diskette image (1m5)
; 0x80280000 -> 281FFF ramdisk fat (8k)
; 0x80282000 -> 283FFF floppy fat (8k)
; 0x800B0000 -> FFFFF bios rest in peace -area
; 0x80100000 -> 27FFFF diskette image
; 0x80280000 -> 281FFF ramdisk fat
; 0x80282000 -> 283FFF floppy fat
;
; 0x80284000 -> 28BFFF HDD DMA AREA (32k)
; 0x8028C000 -> 297FFF free (48k)
; 0x80284000 -> 28BFFF HDD DMA AREA
; 0x8028C000 -> 297FFF free (48 Kb)
;
; 0x80298000 -> 29ffff auxiliary table for background smoothing code (32k)
; 0x80298000 -> 29ffff auxiliary table for background smoothing code
;
; 0x802A0000 -> 2B00ff wav device buffer (64k)
; 0x802A0000 -> 2B00ff wav device status (256)
; 0x802B0100 -> 2Bffff free (63k8)
; 0x802C0000 -> 2C3fff button info (8k)
; 0x802A0000 -> 2B00ff wav device data
; 0x802C0000 -> 2C3fff button info
;
; 0000 word number of buttons
; first button entry at 0x10
215,9 → 202,9
; +000A word y size
; +000C word button id number : bits 16-31
;
; 0x802C4000 -> 2CFFFF free (48k)
; 0x802C4000 -> 2CFFFF free (48Kb)
;
; 0x802D0000 -> 2DFFFF reserved port area (64k)
; 0x802D0000 -> 2DFFFF reserved port area
;
; 0000 dword no of port areas reserved
; 0010 dword process id
225,37 → 212,34
; dword end port
; dword 0
;
; 0x802E0000 -> 2EFFFF irq data area (64k)
; 0x802F0000 -> 2FFFFF low memory save (64k)
; 0x802E0000 -> 2EFFFF irq data area
; 0x802F0000 -> 2FFFFF low memory save
;
; 0x80300000 -> 31FFFF tcp memory (128k)
; 0x80320000 -> 327FFF tcp memory (32k)
; 0x80300000 -> 31FFFF tcp memory 128 Kb
; 0x80320000 -> 327FFF tcp memory 32 Kb
;
; 0x80328000 -> 32FFFF !vrr driver (32k)
; 0x80328000 -> 32FFFF !vrr driver 32 Kb
 
; 0x80330000 -> 377FFF skin data (32k)
; 0x80330000 -> 377FFF skin data
 
; 0x80338000 -> 338FFF draw data - 256 entries (4k)
; 0x80338000 -> 33AFFF draw data - 256 entries
; 00 dword draw limit - x start
; 04 dword draw limit - y start
; 08 dword draw limit - x end
; 0C dword draw limit - y end
; 0x80339000 -> 3BFFF3 free (12k)
; 0x8033BFF4 -> 33BFFF background info
; 0x8033C000 page map (length b = memsize shr 15)
; 0x8033C000 + b start of static pagetables
 
; 0x803FFFFF <- no direct address translation beyond this point
; =============================================================
; 0x8033C000 -> 47BFFF display info
 
; 0x805FF000 -> 5FFF80 TSS
; 0x80600000 -> 601FFF i/o maps
; 0x8047CF80 -> 47CFFF TSS 128 bytes
; 0x8047D000 -> 47EFFF IO map for (8192*8)=65536 ports
 
; 0x8047F000 -> 48FFFF page map max 128 Kb
;
 
; 0x80800000 -> kernel heap
; 0x80FFFFFF heap min limit
; 0x81FFFFFF heap min limit
; 0xFDBFFFFF heap max limit
 
; 0xF0000000 -> 0xF1FFFFFF PCI-express extended config space
; 0xFDC00000 -> 0xFDFFFFFF page tables 4Mb
; 0xFE000000 -> 0xFFFFFFFF LFB 32Mb
; 0xFE000000 -> 0xFE7FFFFF application available LFB 8Mb
/kernel/branches/net/unpacker.inc
21,7 → 21,7
push eax
add esi, 12
and al, not 0xC0
dec al
dec eax
jz .lzma
.failed:
pop eax
219,8 → 219,7
cmp bl, 10
jb @f
mov al, 6
@@:
sub bl, al
@@: sub bl, al
jmp .main_loop
.1:
lea eax, [.IsRep*4 + ebx*4]