forked from KolibriOS/kolibrios
Synced net branch with trunk
git-svn-id: svn://kolibrios.org@2382 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -170,13 +170,15 @@ ReadCDWRetr_1:
|
||||
MaxCDWaitTime equ 1000 ;200 ;10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uglobal
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
PacketCommand: rb 12 ;DB 12 DUP (?)
|
||||
PacketCommand:
|
||||
rb 12 ;DB 12 DUP (?)
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
;CDDataBuf DB 4096 DUP (0)
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
;CDBlockSize DW ?
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
CDSectorAddress: DD ?
|
||||
CDSectorAddress:
|
||||
DD ?
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
TickCounter_1 DD 0
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
1258
kernel/branches/net/blkdev/disk.inc
Normal file
1258
kernel/branches/net/blkdev/disk.inc
Normal file
File diff suppressed because it is too large
Load Diff
592
kernel/branches/net/blkdev/disk_cache.inc
Normal file
592
kernel/branches/net/blkdev/disk_cache.inc
Normal file
@@ -0,0 +1,592 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2011. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 2381 $
|
||||
|
||||
; This function is intended to replace the old 'hd_read' function when
|
||||
; [hdd_appl_data] = 0, so its input/output parameters are the same, except
|
||||
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
|
||||
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
|
||||
; eax is relative to partition start
|
||||
; out: eax = error code; 0 = ok
|
||||
fs_read32_sys:
|
||||
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
|
||||
; this request should be processed by hd_read.
|
||||
cmp [ebp+PARTITION.Disk], 'old'
|
||||
jnz @f
|
||||
mov [hdd_appl_data], 0
|
||||
call hd_read
|
||||
mov [hdd_appl_data], 1 ; restore to default state
|
||||
ret
|
||||
@@:
|
||||
; In the normal case, save ecx, set ecx to SysCache and let the common part
|
||||
; do its work.
|
||||
push ecx
|
||||
mov ecx, [ebp+PARTITION.Disk]
|
||||
add ecx, DISK.SysCache
|
||||
jmp fs_read32_common
|
||||
|
||||
; This function is intended to replace the old 'hd_read' function when
|
||||
; [hdd_appl_data] = 1, so its input/output parameters are the same, except
|
||||
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
|
||||
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
|
||||
; eax is relative to partition start
|
||||
; out: eax = error code; 0 = ok
|
||||
fs_read32_app:
|
||||
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
|
||||
; this request should be processed by hd_read.
|
||||
cmp [ebp+PARTITION.Disk], 'old'
|
||||
jnz @f
|
||||
mov [hdd_appl_data], 1
|
||||
jmp hd_read
|
||||
@@:
|
||||
; In the normal case, save ecx, set ecx to AppCache and let the common part
|
||||
; do its work.
|
||||
push ecx
|
||||
mov ecx, [ebp+PARTITION.Disk]
|
||||
add ecx, DISK.AppCache
|
||||
|
||||
; This label is the common part of fs_read32_sys and fs_read32_app.
|
||||
fs_read32_common:
|
||||
; 1. Check that the required sector is inside the partition. If no, return
|
||||
; DISK_STATUS_END_OF_MEDIA.
|
||||
cmp dword [ebp+PARTITION.Length+4], 0
|
||||
jnz @f
|
||||
cmp dword [ebp+PARTITION.Length], eax
|
||||
ja @f
|
||||
mov eax, DISK_STATUS_END_OF_MEDIA
|
||||
pop ecx
|
||||
ret
|
||||
@@:
|
||||
; 2. Get the absolute sector on the disk.
|
||||
push edx
|
||||
xor edx, edx
|
||||
add eax, dword [ebp+PARTITION.FirstSector]
|
||||
adc edx, dword [ebp+PARTITION.FirstSector+4]
|
||||
; 3. If there is no cache for this disk, just pass the request to the driver.
|
||||
cmp [ecx+DISKCACHE.pointer], 0
|
||||
jnz .scancache
|
||||
push 1
|
||||
push esp ; numsectors
|
||||
push edx ; startsector
|
||||
push eax ; startsector
|
||||
push ebx ; buffer
|
||||
mov al, DISKFUNC.read
|
||||
call disk_call_driver
|
||||
pop ecx
|
||||
pop edx
|
||||
pop ecx
|
||||
ret
|
||||
.scancache:
|
||||
; 4. Scan the cache.
|
||||
push esi edi ecx ; scan cache
|
||||
push edx eax
|
||||
virtual at esp
|
||||
.sector_lo dd ?
|
||||
.sector_hi dd ?
|
||||
.cache dd ?
|
||||
end virtual
|
||||
; The following code is inherited from hd_read. The differences are:
|
||||
; all code is protected by the cache lock; instead of static calls
|
||||
; to hd_read_dma/hd_read_pio/bd_read the dynamic call to DISKFUNC.read is used;
|
||||
; sector is 64-bit, not 32-bit.
|
||||
call mutex_lock
|
||||
mov eax, [.sector_lo]
|
||||
mov edx, [.sector_hi]
|
||||
mov esi, [ecx+DISKCACHE.pointer]
|
||||
mov ecx, [ecx+DISKCACHE.sad_size]
|
||||
add esi, 12
|
||||
|
||||
mov edi, 1
|
||||
|
||||
.hdreadcache:
|
||||
|
||||
cmp dword [esi+8], 0 ; empty
|
||||
je .nohdcache
|
||||
|
||||
cmp [esi], eax ; correct sector
|
||||
jne .nohdcache
|
||||
cmp [esi+4], edx ; correct sector
|
||||
je .yeshdcache
|
||||
|
||||
.nohdcache:
|
||||
|
||||
add esi, 12
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz .hdreadcache
|
||||
|
||||
mov esi, [.cache]
|
||||
call find_empty_slot64 ; ret in edi
|
||||
test eax, eax
|
||||
jnz .read_done
|
||||
|
||||
push 1
|
||||
push esp
|
||||
push edx
|
||||
push [.sector_lo+12]
|
||||
mov ecx, [.cache]
|
||||
mov eax, edi
|
||||
shl eax, 9
|
||||
add eax, [ecx+DISKCACHE.data]
|
||||
push eax
|
||||
mov esi, [ebp+PARTITION.Disk]
|
||||
mov al, DISKFUNC.read
|
||||
call disk_call_driver
|
||||
pop ecx
|
||||
dec ecx
|
||||
jnz .read_done
|
||||
|
||||
mov ecx, [.cache]
|
||||
lea eax, [edi*3]
|
||||
mov esi, [ecx+DISKCACHE.pointer]
|
||||
lea esi, [eax*4+esi]
|
||||
|
||||
mov eax, [.sector_lo]
|
||||
mov edx, [.sector_hi]
|
||||
mov [esi], eax ; sector number
|
||||
mov [esi+4], edx ; sector number
|
||||
mov dword [esi+8], 1; hd read - mark as same as in hd
|
||||
|
||||
.yeshdcache:
|
||||
|
||||
mov esi, edi
|
||||
mov ecx, [.cache]
|
||||
shl esi, 9
|
||||
add esi, [ecx+DISKCACHE.data]
|
||||
|
||||
mov edi, ebx
|
||||
mov ecx, 512/4
|
||||
rep movsd ; move data
|
||||
xor eax, eax ; successful read
|
||||
.read_done:
|
||||
mov ecx, [.cache]
|
||||
push eax
|
||||
call mutex_unlock
|
||||
pop eax
|
||||
add esp, 12
|
||||
pop edi esi edx ecx
|
||||
ret
|
||||
|
||||
; This function is intended to replace the old 'hd_write' function when
|
||||
; [hdd_appl_data] = 0, so its input/output parameters are the same, except
|
||||
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
|
||||
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
|
||||
; eax is relative to partition start
|
||||
; out: eax = error code; 0 = ok
|
||||
fs_write32_sys:
|
||||
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
|
||||
; this request should be processed by hd_write.
|
||||
cmp [ebp+PARTITION.Disk], 'old'
|
||||
jnz @f
|
||||
mov [hdd_appl_data], 0
|
||||
call hd_write
|
||||
mov [hdd_appl_data], 1 ; restore to default state
|
||||
ret
|
||||
@@:
|
||||
; In the normal case, save ecx, set ecx to SysCache and let the common part
|
||||
; do its work.
|
||||
push ecx
|
||||
mov ecx, [ebp+PARTITION.Disk]
|
||||
add ecx, DISK.SysCache
|
||||
jmp fs_write32_common
|
||||
|
||||
; This function is intended to replace the old 'hd_write' function when
|
||||
; [hdd_appl_data] = 1, so its input/output parameters are the same, except
|
||||
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
|
||||
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
|
||||
; eax is relative to partition start
|
||||
; out: eax = error code; 0 = ok
|
||||
fs_write32_app:
|
||||
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
|
||||
; this request should be processed by hd_write.
|
||||
cmp [ebp+PARTITION.Disk], 'old'
|
||||
jnz @f
|
||||
mov [hdd_appl_data], 1
|
||||
jmp hd_write
|
||||
@@:
|
||||
; In the normal case, save ecx, set ecx to AppCache and let the common part
|
||||
; do its work.
|
||||
push ecx
|
||||
mov ecx, [ebp+PARTITION.Disk]
|
||||
add ecx, DISK.AppCache
|
||||
|
||||
; This label is the common part of fs_read32_sys and fs_read32_app.
|
||||
fs_write32_common:
|
||||
; 1. Check that the required sector is inside the partition. If no, return
|
||||
; DISK_STATUS_END_OF_MEDIA.
|
||||
cmp dword [ebp+PARTITION.Length+4], 0
|
||||
jnz @f
|
||||
cmp dword [ebp+PARTITION.Length], eax
|
||||
ja @f
|
||||
mov eax, DISK_STATUS_END_OF_MEDIA
|
||||
pop ecx
|
||||
ret
|
||||
@@:
|
||||
push edx
|
||||
; 2. Get the absolute sector on the disk.
|
||||
xor edx, edx
|
||||
add eax, dword [ebp+PARTITION.FirstSector]
|
||||
adc edx, dword [ebp+PARTITION.FirstSector+4]
|
||||
; 3. If there is no cache for this disk, just pass request to the driver.
|
||||
cmp [ecx+DISKCACHE.pointer], 0
|
||||
jnz .scancache
|
||||
push 1
|
||||
push esp ; numsectors
|
||||
push edx ; startsector
|
||||
push eax ; startsector
|
||||
push ebx ; buffer
|
||||
mov al, DISKFUNC.write
|
||||
call disk_call_driver
|
||||
pop ecx
|
||||
pop edx
|
||||
pop ecx
|
||||
ret
|
||||
.scancache:
|
||||
; 4. Scan the cache.
|
||||
push esi edi ecx ; scan cache
|
||||
push edx eax
|
||||
virtual at esp
|
||||
.sector_lo dd ?
|
||||
.sector_hi dd ?
|
||||
.cache dd ?
|
||||
end virtual
|
||||
; The following code is inherited from hd_write. The differences are:
|
||||
; all code is protected by the cache lock;
|
||||
; sector is 64-bit, not 32-bit.
|
||||
call mutex_lock
|
||||
|
||||
; check if the cache already has the sector and overwrite it
|
||||
mov eax, [.sector_lo]
|
||||
mov edx, [.sector_hi]
|
||||
mov esi, [ecx+DISKCACHE.pointer]
|
||||
mov ecx, [ecx+DISKCACHE.sad_size]
|
||||
add esi, 12
|
||||
|
||||
mov edi, 1
|
||||
|
||||
.hdwritecache:
|
||||
cmp dword [esi+8], 0 ; if cache slot is empty
|
||||
je .not_in_cache_write
|
||||
|
||||
cmp [esi], eax ; if the slot has the sector
|
||||
jne .not_in_cache_write
|
||||
cmp [esi+4], edx ; if the slot has the sector
|
||||
je .yes_in_cache_write
|
||||
|
||||
.not_in_cache_write:
|
||||
|
||||
add esi, 12
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz .hdwritecache
|
||||
|
||||
; sector not found in cache
|
||||
; write the block to a new location
|
||||
|
||||
mov esi, [.cache]
|
||||
call find_empty_slot64 ; ret in edi
|
||||
test eax, eax
|
||||
jne .hd_write_access_denied
|
||||
|
||||
mov ecx, [.cache]
|
||||
lea eax, [edi*3]
|
||||
mov esi, [ecx+DISKCACHE.pointer]
|
||||
lea esi, [eax*4+esi]
|
||||
|
||||
mov eax, [.sector_lo]
|
||||
mov edx, [.sector_hi]
|
||||
mov [esi], eax ; sector number
|
||||
mov [esi+4], edx ; sector number
|
||||
|
||||
.yes_in_cache_write:
|
||||
|
||||
mov dword [esi+4], 2 ; write - differs from hd
|
||||
|
||||
shl edi, 9
|
||||
mov ecx, [.cache]
|
||||
add edi, [ecx+DISKCACHE.data]
|
||||
|
||||
mov esi, ebx
|
||||
mov ecx, 512/4
|
||||
rep movsd ; move data
|
||||
xor eax, eax ; success
|
||||
.hd_write_access_denied:
|
||||
mov ecx, [.cache]
|
||||
push eax
|
||||
call mutex_unlock
|
||||
pop eax
|
||||
add esp, 12
|
||||
pop edi esi edx ecx
|
||||
ret
|
||||
|
||||
; This internal function is called from fs_read32_* and fs_write32_*. It is the
|
||||
; analogue of find_empty_slot for 64-bit sectors.
|
||||
find_empty_slot64:
|
||||
;-----------------------------------------------------------
|
||||
; find empty or read slot, flush cache if next 12.5% is used by write
|
||||
; output : edi = cache slot
|
||||
;-----------------------------------------------------------
|
||||
.search_again:
|
||||
mov ecx, [esi+DISKCACHE.sad_size]
|
||||
mov edi, [esi+DISKCACHE.search_start]
|
||||
shr ecx, 3
|
||||
.search_for_empty:
|
||||
inc edi
|
||||
cmp edi, [esi+DISKCACHE.sad_size]
|
||||
jbe .inside_cache
|
||||
mov edi, 1
|
||||
.inside_cache:
|
||||
lea eax, [edi*3]
|
||||
shl eax, 2
|
||||
add eax, [esi+DISKCACHE.pointer]
|
||||
cmp dword [eax+8], 2
|
||||
jb .found_slot ; it's empty or read
|
||||
dec ecx
|
||||
jnz .search_for_empty
|
||||
call write_cache64 ; no empty slots found, write all
|
||||
test eax, eax
|
||||
jne .found_slot_access_denied
|
||||
jmp .search_again ; and start again
|
||||
.found_slot:
|
||||
mov [esi+DISKCACHE.search_start], edi
|
||||
xor eax, eax ; success
|
||||
.found_slot_access_denied:
|
||||
ret
|
||||
|
||||
; This function is intended to replace the old 'write_cache' function.
|
||||
proc write_cache64 uses ecx edx esi edi
|
||||
locals
|
||||
cache_chain_started dd ?
|
||||
cache_chain_size dd ?
|
||||
cache_chain_pos dd ?
|
||||
cache_chain_ptr dd ?
|
||||
endl
|
||||
; If there is no cache for this disk, nothing to do.
|
||||
cmp [esi+DISKCACHE.pointer], 0
|
||||
jz .flush
|
||||
;-----------------------------------------------------------
|
||||
; write all changed sectors to disk
|
||||
;-----------------------------------------------------------
|
||||
|
||||
; write difference ( 2 ) from cache to DISK
|
||||
mov ecx, [esi+DISKCACHE.sad_size]
|
||||
mov esi, [esi+DISKCACHE.pointer]
|
||||
add esi, 12
|
||||
mov edi, 1
|
||||
.write_cache_more:
|
||||
cmp dword [esi+8], 2 ; if cache slot is not different
|
||||
jne .write_chain
|
||||
mov dword [esi+8], 1 ; same as in hd
|
||||
mov eax, [esi]
|
||||
mov edx, [esi+4] ; edx:eax = sector to write
|
||||
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
cmp ecx, 1
|
||||
jz .nonext
|
||||
cmp dword [esi+12+8], 2
|
||||
jnz .nonext
|
||||
push eax edx
|
||||
add eax, 1
|
||||
adc edx, 0
|
||||
cmp eax, [esi+12]
|
||||
jnz @f
|
||||
cmp edx, [esi+12+4]
|
||||
@@:
|
||||
pop edx eax
|
||||
jnz .nonext
|
||||
cmp [cache_chain_started], 1
|
||||
jz @f
|
||||
mov [cache_chain_started], 1
|
||||
mov [cache_chain_size], 0
|
||||
mov [cache_chain_pos], edi
|
||||
mov [cache_chain_ptr], esi
|
||||
@@:
|
||||
inc [cache_chain_size]
|
||||
cmp [cache_chain_size], 16
|
||||
jnz .continue
|
||||
jmp .write_chain
|
||||
.nonext:
|
||||
call .flush_cache_chain
|
||||
test eax, eax
|
||||
jnz .nothing
|
||||
mov [cache_chain_size], 1
|
||||
mov [cache_chain_ptr], esi
|
||||
call .write_cache_sector
|
||||
test eax, eax
|
||||
jnz .nothing
|
||||
jmp .continue
|
||||
.write_chain:
|
||||
call .flush_cache_chain
|
||||
test eax, eax
|
||||
jnz .nothing
|
||||
.continue:
|
||||
add esi, 12
|
||||
inc edi
|
||||
dec ecx
|
||||
jnz .write_cache_more
|
||||
call .flush_cache_chain
|
||||
test eax, eax
|
||||
jnz .nothing
|
||||
.flush:
|
||||
mov esi, [ebp]
|
||||
mov esi, [esi+PARTITION.Disk]
|
||||
mov al, DISKFUNC.flush
|
||||
call disk_call_driver
|
||||
.nothing:
|
||||
ret
|
||||
|
||||
.flush_cache_chain:
|
||||
xor eax, eax
|
||||
cmp [cache_chain_started], eax
|
||||
jz @f
|
||||
call .write_cache_chain
|
||||
mov [cache_chain_started], 0
|
||||
@@:
|
||||
retn
|
||||
|
||||
.write_cache_sector:
|
||||
mov [cache_chain_size], 1
|
||||
mov [cache_chain_pos], edi
|
||||
.write_cache_chain:
|
||||
pusha
|
||||
mov edi, [cache_chain_pos]
|
||||
mov ecx, [ebp-12]
|
||||
shl edi, 9
|
||||
add edi, [ecx+DISKCACHE.data]
|
||||
mov ecx, [cache_chain_size]
|
||||
push ecx
|
||||
push esp ; numsectors
|
||||
mov eax, [cache_chain_ptr]
|
||||
pushd [eax+4]
|
||||
pushd [eax] ; startsector
|
||||
push edi ; buffer
|
||||
mov esi, [ebp]
|
||||
mov esi, [esi+PARTITION.Disk]
|
||||
mov al, DISKFUNC.write
|
||||
call disk_call_driver
|
||||
pop ecx
|
||||
mov [esp+28], eax
|
||||
popa
|
||||
retn
|
||||
endp
|
||||
|
||||
; This internal function is called from disk_add to initialize the caching for
|
||||
; a new DISK.
|
||||
; The algorithm is inherited from getcache.inc: take 1/32 part of the available
|
||||
; physical memory, round down to 8 pages, limit by 128K from below and by 1M
|
||||
; from above. Reserve 1/8 part of the cache for system data and 7/8 for app
|
||||
; data.
|
||||
; After the size is calculated, but before the cache is allocated, the device
|
||||
; driver can adjust the size. In particular, setting size to zero disables
|
||||
; caching: there is no sense in a cache for a ramdisk. In fact, such action
|
||||
; is most useful example of a non-trivial adjustment.
|
||||
; esi = pointer to DISK structure
|
||||
disk_init_cache:
|
||||
; 1. Calculate the suggested cache size.
|
||||
; 1a. Get the size of free physical memory in pages.
|
||||
mov eax, [pg_data.pages_free]
|
||||
; 1b. Use the value to calculate the size.
|
||||
shl eax, 12 - 5 ; 1/32 of it in bytes
|
||||
and eax, -8*4096 ; round down to the multiple of 8 pages
|
||||
; 1c. Force lower and upper limits.
|
||||
cmp eax, 1024*1024
|
||||
jb @f
|
||||
mov eax, 1024*1024
|
||||
@@:
|
||||
cmp eax, 128*1024
|
||||
ja @f
|
||||
mov eax, 128*1024
|
||||
@@:
|
||||
; 1d. Give a chance to the driver to adjust the size.
|
||||
push eax
|
||||
mov al, DISKFUNC.adjust_cache_size
|
||||
call disk_call_driver
|
||||
; Cache size calculated.
|
||||
mov [esi+DISK.cache_size], eax
|
||||
test eax, eax
|
||||
jz .nocache
|
||||
; 2. Allocate memory for the cache.
|
||||
; 2a. Call the allocator.
|
||||
stdcall kernel_alloc, eax
|
||||
test eax, eax
|
||||
jnz @f
|
||||
; 2b. If it failed, say a message and return with eax = 0.
|
||||
dbgstr 'no memory for disk cache'
|
||||
jmp .nothing
|
||||
@@:
|
||||
; 3. Fill two DISKCACHE structures.
|
||||
mov [esi+DISK.SysCache.pointer], eax
|
||||
lea ecx, [esi+DISK.SysCache.mutex]
|
||||
call mutex_init
|
||||
lea ecx, [esi+DISK.AppCache.mutex]
|
||||
call mutex_init
|
||||
; The following code is inherited from getcache.inc.
|
||||
mov edx, [esi+DISK.SysCache.pointer]
|
||||
and [esi+DISK.SysCache.search_start], 0
|
||||
and [esi+DISK.AppCache.search_start], 0
|
||||
mov eax, [esi+DISK.cache_size]
|
||||
shr eax, 3
|
||||
mov [esi+DISK.SysCache.data_size], eax
|
||||
add edx, eax
|
||||
imul eax, 7
|
||||
mov [esi+DISK.AppCache.data_size], eax
|
||||
mov [esi+DISK.AppCache.pointer], edx
|
||||
|
||||
mov eax, [esi+DISK.SysCache.data_size]
|
||||
push ebx
|
||||
call calculate_for_hd
|
||||
pop ebx
|
||||
add eax, [esi+DISK.SysCache.pointer]
|
||||
mov [esi+DISK.SysCache.data], eax
|
||||
mov [esi+DISK.SysCache.sad_size], ecx
|
||||
|
||||
push edi
|
||||
mov edi, [esi+DISK.SysCache.pointer]
|
||||
lea ecx, [ecx*3]
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop edi
|
||||
|
||||
mov eax, [esi+DISK.AppCache.data_size]
|
||||
push ebx
|
||||
call calculate_for_hd
|
||||
pop ebx
|
||||
add eax, [esi+DISK.AppCache.pointer]
|
||||
mov [esi+DISK.AppCache.data], eax
|
||||
mov [esi+DISK.AppCache.sad_size], ecx
|
||||
|
||||
push edi
|
||||
mov edi, [esi+DISK.AppCache.pointer]
|
||||
lea ecx, [ecx*3]
|
||||
xor eax, eax
|
||||
rep stosd
|
||||
pop edi
|
||||
|
||||
; 4. Return with nonzero al.
|
||||
mov al, 1
|
||||
; 5. Return.
|
||||
.nothing:
|
||||
ret
|
||||
; No caching is required for this driver. Zero cache pointers and return with
|
||||
; nonzero al.
|
||||
.nocache:
|
||||
mov [esi+DISK.SysCache.pointer], eax
|
||||
mov [esi+DISK.AppCache.pointer], eax
|
||||
mov al, 1
|
||||
ret
|
||||
|
||||
; This internal function is called from disk_media_dereference to free the
|
||||
; allocated cache, if there is one.
|
||||
; esi = pointer to DISK structure
|
||||
disk_free_cache:
|
||||
; The algorithm is straightforward.
|
||||
mov eax, [esi+DISK.SysCache.pointer]
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
stdcall kernel_free, eax
|
||||
.nothing:
|
||||
ret
|
@@ -176,7 +176,8 @@ FDCDataInput:
|
||||
@@GetByteFromFDC:
|
||||
inc DX
|
||||
in AL, DX
|
||||
@@End_6: pop DX
|
||||
@@End_6:
|
||||
pop DX
|
||||
pop ECX
|
||||
ret
|
||||
|
||||
@@ -222,7 +223,8 @@ WaitFDCInterrupt:
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mov [FDC_Status], FDC_TimeOut
|
||||
; mov [flp_status],0
|
||||
@@End_7: popa
|
||||
@@End_7:
|
||||
popa
|
||||
ret
|
||||
|
||||
;*********************************
|
||||
@@ -456,7 +458,8 @@ ReadSector:
|
||||
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
|
||||
@@ -555,7 +558,8 @@ WriteSector:
|
||||
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
|
||||
|
@@ -1169,7 +1169,8 @@ fat_next_short_name:
|
||||
add edi, 6
|
||||
cmp word [edi], ' '
|
||||
jnz .insert_tilde
|
||||
@@: dec edi
|
||||
@@:
|
||||
dec edi
|
||||
cmp byte [edi], ' '
|
||||
jz @b
|
||||
inc edi
|
||||
|
119
kernel/branches/net/bus/pci/PCIe.inc
Normal file
119
kernel/branches/net/bus/pci/PCIe.inc
Normal file
@@ -0,0 +1,119 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) 2010 KolibriOS team. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; ;;
|
||||
;; PCIe.INC ;;
|
||||
;; ;;
|
||||
;; Extended PCI express services ;;
|
||||
;; ;;
|
||||
;; art_zh <artem@jerdev.co.uk> ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 1463 $
|
||||
|
||||
;***************************************************************************
|
||||
; Function
|
||||
; pci_ext_config:
|
||||
;
|
||||
; Description
|
||||
; PCIe extended (memory-mapped) config space detection
|
||||
;
|
||||
; WARNINGs:
|
||||
; 1) Very Experimental!
|
||||
; 2) direct HT-detection (no ACPI or BIOS service used)
|
||||
; 3) Only AMD/HT processors currently supported
|
||||
;
|
||||
;***************************************************************************
|
||||
|
||||
PCIe_CONFIG_SPACE equ 0xF0000000 ; to be moved to const.inc
|
||||
mmio_pcie_cfg_addr dd 0x0 ; intel pcie space may be defined here
|
||||
mmio_pcie_cfg_lim dd 0x0 ; upper pcie space address
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
pci_ext_config:
|
||||
|
||||
mov ebx, [mmio_pcie_cfg_addr]
|
||||
or ebx, ebx
|
||||
jz @f
|
||||
or ebx, 0x7FFFFFFF ; required by PCI-SIG standards
|
||||
jnz .pcie_failed
|
||||
add ebx, 0x0FFFFC
|
||||
cmp ebx, [mmio_pcie_cfg_lim]; is the space limit correct?
|
||||
ja .pcie_failed
|
||||
jmp .pcie_cfg_mapped
|
||||
@@:
|
||||
mov ebx, [cpu_vendor]
|
||||
cmp ebx, dword [AMD_str]
|
||||
jne .pcie_failed
|
||||
mov bx, 0xC184 ; dev = 24, fn = 01, reg = 84h
|
||||
|
||||
.check_HT_mmio:
|
||||
mov cx, bx
|
||||
mov ax, 0x0002 ; bus = 0, 1dword to read
|
||||
call pci_read_reg
|
||||
mov bx, cx
|
||||
sub bl, 4
|
||||
and al, 0x80 ; check the NP bit
|
||||
jz .no_pcie_cfg
|
||||
shl eax, 8 ; bus:[27..20], dev:[19:15]
|
||||
or eax, 0x00007FFC ; fun:[14..12], reg:[11:2]
|
||||
mov [mmio_pcie_cfg_lim], eax
|
||||
mov cl, bl
|
||||
mov ax, 0x0002 ; bus = 0, 1dword to read
|
||||
call pci_read_reg
|
||||
mov bx, cx
|
||||
test al, 0x03 ; MMIO Base RW enabled?
|
||||
jz .no_pcie_cfg
|
||||
test al, 0x0C ; MMIO Base locked?
|
||||
jnz .no_pcie_cfg
|
||||
xor al, al
|
||||
shl eax, 8
|
||||
test eax, 0x000F0000 ; MMIO Base must be bus0-aligned
|
||||
jnz .no_pcie_cfg
|
||||
mov [mmio_pcie_cfg_addr], eax
|
||||
add eax, 0x000FFFFC
|
||||
sub eax, [mmio_pcie_cfg_lim]; MMIO must cover at least one bus
|
||||
ja .no_pcie_cfg
|
||||
|
||||
; -- it looks like a true PCIe config space;
|
||||
mov eax, [mmio_pcie_cfg_addr] ; physical address
|
||||
or eax, (PG_SHARED + PG_LARGE + PG_USER)
|
||||
mov ebx, PCIe_CONFIG_SPACE ; linear address
|
||||
mov ecx, ebx
|
||||
shr ebx, 20
|
||||
add ebx, sys_pgdir ; PgDir entry @
|
||||
@@:
|
||||
mov dword[ebx], eax ; map 4 buses
|
||||
invlpg [ecx]
|
||||
cmp bl, 4
|
||||
jz .pcie_cfg_mapped ; fix it later
|
||||
add bl, 4 ; next PgDir entry
|
||||
add eax, 0x400000 ; eax += 4M
|
||||
add ecx, 0x400000
|
||||
jmp @b
|
||||
|
||||
.pcie_cfg_mapped:
|
||||
|
||||
; -- glad to have the extended PCIe config field found
|
||||
; mov esi, boot_pcie_ok
|
||||
; call boot_log
|
||||
ret ; <<<<<<<<<<< OK >>>>>>>>>>>
|
||||
|
||||
.no_pcie_cfg:
|
||||
|
||||
xor eax, eax
|
||||
mov [mmio_pcie_cfg_addr], eax
|
||||
mov [mmio_pcie_cfg_lim], eax
|
||||
add bl, 12
|
||||
cmp bl, 0xC0 ; MMIO regs lay below this offset
|
||||
jb .check_HT_mmio
|
||||
.pcie_failed:
|
||||
; mov esi, boot_pcie_fail
|
||||
; call boot_log
|
||||
ret ; <<<<<<<<< FAILURE >>>>>>>>>
|
||||
|
@@ -32,63 +32,91 @@ $Revision$
|
||||
;***************************************************************************
|
||||
;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:
|
||||
|
||||
cmp [pci_access_enabled],1
|
||||
jne no_pci_access_for_applications
|
||||
;cross
|
||||
mov eax, ebx
|
||||
mov ebx, ecx
|
||||
mov ecx, edx
|
||||
|
||||
or al,al
|
||||
jnz pci_fn_1
|
||||
cmp [pci_access_enabled], 1
|
||||
jne pci_service_not_supported
|
||||
|
||||
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:
|
||||
; 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:
|
||||
|
||||
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:
|
||||
|
||||
pci_service_not_supported:
|
||||
or eax, -1
|
||||
|
||||
mov dword [esp+32], eax
|
||||
ret
|
||||
|
||||
;***************************************************************************
|
||||
@@ -464,6 +492,7 @@ pci_mmio_map:
|
||||
@@:
|
||||
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
|
||||
@@ -516,7 +545,8 @@ end if
|
||||
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
|
||||
@@ -540,9 +570,9 @@ sys_pcibios:
|
||||
cmp ebp, 1 ; PCI_FUNCTION_ID
|
||||
jnz .not_PCI_BIOS_PRESENT
|
||||
mov edx, 'PCI '
|
||||
mov al, [OS_BASE+0x2F0000 + 0x9020]
|
||||
mov bx, [OS_BASE+0x2F0000 + 0x9022]
|
||||
mov cl, [OS_BASE+0x2F0000 + 0x9021]
|
||||
mov al, [BOOT_VAR + 0x9020]
|
||||
mov bx, [BOOT_VAR + 0x9022]
|
||||
mov cl, [BOOT_VAR + 0x9021]
|
||||
xor ah, ah
|
||||
jmp .return_abcd
|
||||
|
||||
@@ -550,7 +580,8 @@ sys_pcibios:
|
||||
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
|
||||
@@ -559,7 +590,8 @@ sys_pcibios:
|
||||
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
|
||||
@@ -572,12 +604,14 @@ sys_pcibios:
|
||||
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
|
||||
@@ -612,7 +646,8 @@ sys_pcibios:
|
||||
.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
|
||||
|
@@ -143,44 +143,41 @@ SSE_FZ equ 0x8000
|
||||
|
||||
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
|
||||
|
||||
IRQ_PIC equ 0
|
||||
IRQ_APIC equ 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
|
||||
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
|
||||
rb 24
|
||||
._io_map_0 rb 4096
|
||||
._io_map_1 rb 4096
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
TSS TSS
|
||||
end virtual
|
||||
_io_map_0 rb 4096
|
||||
_io_map_1 rb 4096
|
||||
ends
|
||||
|
||||
TSS_SIZE equ (128+8192)
|
||||
|
||||
@@ -247,19 +244,20 @@ ScreenBPP equ (OS_BASE+0x000FBF1)
|
||||
;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)
|
||||
@@ -285,32 +283,34 @@ RAMDISK equ (OS_BASE+0x0100000)
|
||||
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+0x2A0000)
|
||||
SB16Buffer equ (OS_BASE+0x02A0000)
|
||||
SB16_Status equ (OS_BASE+0x02B0000)
|
||||
|
||||
BUTTON_INFO equ (OS_BASE+0x02C0000)
|
||||
RESERVED_PORTS equ (OS_BASE+0x02D0000)
|
||||
IRQ_SAVE equ (OS_BASE+0x02E0000)
|
||||
BOOT_VAR equ (OS_BASE+0x02f0000)
|
||||
BOOT_VAR equ (OS_BASE+0x02E0000)
|
||||
|
||||
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);
|
||||
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)
|
||||
|
||||
BgrDrawMode equ (OS_BASE+0x033BFF4)
|
||||
BgrDataWidth equ (OS_BASE+0x033BFF8)
|
||||
BgrDataHeight equ (OS_BASE+0x033BFFC)
|
||||
skin_data equ (OS_BASE+0x0318000)
|
||||
draw_data equ (OS_BASE+0x0320000)
|
||||
|
||||
sys_pgmap equ (OS_BASE+0x033C000)
|
||||
BgrDrawMode equ (OS_BASE+0x0323FF4)
|
||||
BgrDataWidth equ (OS_BASE+0x0323FF8)
|
||||
BgrDataHeight equ (OS_BASE+0x0323FFC)
|
||||
|
||||
sys_pgmap equ (OS_BASE+0x0324000)
|
||||
|
||||
UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000)
|
||||
|
||||
virtual at (OS_BASE+0x05FFF80)
|
||||
tss TSS
|
||||
@@ -587,20 +587,6 @@ virtual at 0
|
||||
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 ?
|
||||
@@ -639,7 +625,7 @@ virtual at 0
|
||||
end virtual
|
||||
|
||||
struc MEM_STATE
|
||||
{ .mutex rd 1
|
||||
{ .mutex MUTEX
|
||||
.smallmap rd 1
|
||||
.treemap rd 1
|
||||
.topsize rd 1
|
||||
@@ -658,7 +644,7 @@ struc PG_DATA
|
||||
.kernel_pages dd ?
|
||||
.kernel_tables dd ?
|
||||
.sys_page_dir dd ?
|
||||
.pg_mutex dd ?
|
||||
.mutex MUTEX
|
||||
}
|
||||
|
||||
;struc LIB
|
||||
@@ -765,3 +751,27 @@ end virtual
|
||||
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
|
||||
|
||||
|
417
kernel/branches/net/core/apic.inc
Normal file
417
kernel/branches/net/core/apic.inc
Normal file
@@ -0,0 +1,417 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
iglobal
|
||||
IRQ_COUNT dd 24
|
||||
endg
|
||||
|
||||
uglobal
|
||||
irq_mode rd 1
|
||||
IOAPIC_base rd 1
|
||||
LAPIC_BASE rd 1
|
||||
endg
|
||||
|
||||
APIC_ID equ 0x20
|
||||
APIC_TPR equ 0x80
|
||||
APIC_EOI equ 0xb0
|
||||
APIC_LDR equ 0xd0
|
||||
APIC_DFR equ 0xe0
|
||||
APIC_SVR equ 0xf0
|
||||
APIC_ISR equ 0x100
|
||||
APIC_ESR equ 0x280
|
||||
APIC_ICRL equ 0x300
|
||||
APIC_ICRH equ 0x310
|
||||
APIC_LVT_LINT0 equ 0x350
|
||||
APIC_LVT_LINT1 equ 0x360
|
||||
APIC_LVT_err equ 0x370
|
||||
|
||||
; APIC timer
|
||||
APIC_LVT_timer equ 0x320
|
||||
APIC_timer_div equ 0x3e0
|
||||
APIC_timer_init equ 0x380
|
||||
APIC_timer_cur equ 0x390
|
||||
; IOAPIC
|
||||
IOAPIC_ID equ 0x0
|
||||
IOAPIC_VER equ 0x1
|
||||
IOAPIC_ARB equ 0x2
|
||||
IOAPIC_REDTBL equ 0x10
|
||||
|
||||
align 4
|
||||
APIC_init:
|
||||
mov [irq_mode], IRQ_PIC
|
||||
|
||||
cmp [acpi_ioapic_base], 0
|
||||
jz .no_apic
|
||||
|
||||
cmp [acpi_lapic_base], 0
|
||||
jz .no_apic
|
||||
|
||||
stdcall load_file, dev_data_path
|
||||
test eax, eax
|
||||
jz .no_apic
|
||||
|
||||
mov [acpi_dev_data], eax
|
||||
mov [acpi_dev_size], ebx
|
||||
|
||||
call IRQ_mask_all
|
||||
|
||||
; IOAPIC init
|
||||
stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW
|
||||
mov [IOAPIC_base], eax
|
||||
|
||||
mov eax, IOAPIC_VER
|
||||
call IOAPIC_read
|
||||
shr eax, 16
|
||||
inc al
|
||||
movzx eax, al
|
||||
cmp al, IRQ_RESERVED
|
||||
jbe @f
|
||||
|
||||
mov al, IRQ_RESERVED
|
||||
@@:
|
||||
mov [IRQ_COUNT], eax
|
||||
|
||||
; Reroute IOAPIC & mask all interrupts
|
||||
xor ecx, ecx
|
||||
mov eax, IOAPIC_REDTBL
|
||||
@@:
|
||||
mov ebx, eax
|
||||
call IOAPIC_read
|
||||
mov ah, 0x09; Delivery Mode: Lowest Priority, Destination Mode: Logical
|
||||
mov al, cl
|
||||
add al, 0x20; vector
|
||||
or eax, 0x10000; Mask Interrupt
|
||||
cmp ecx, 16
|
||||
jb .set
|
||||
|
||||
or eax, 0xa000;<<< level-triggered active-low for IRQ16+
|
||||
.set:
|
||||
xchg eax, ebx
|
||||
call IOAPIC_write
|
||||
inc eax
|
||||
mov ebx, eax
|
||||
call IOAPIC_read
|
||||
or eax, 0xff000000; Destination Field
|
||||
xchg eax, ebx
|
||||
call IOAPIC_write
|
||||
inc eax
|
||||
inc ecx
|
||||
cmp ecx, [IRQ_COUNT]
|
||||
jb @b
|
||||
|
||||
call LAPIC_init
|
||||
|
||||
mov [irq_mode], IRQ_APIC
|
||||
|
||||
mov al, 0x70
|
||||
out 0x22, al
|
||||
mov al, 1
|
||||
out 0x23, al
|
||||
|
||||
call pci_irq_fixup
|
||||
.no_apic:
|
||||
|
||||
ret
|
||||
|
||||
;===========================================================
|
||||
align 4
|
||||
LAPIC_init:
|
||||
; Check MSR support
|
||||
;....
|
||||
; Get LAPIC base address
|
||||
; mov ecx, 0x1b
|
||||
; rdmsr ; it may be replaced to
|
||||
; and ax, 0xf000 ; mov eax, 0xfee00000
|
||||
|
||||
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW
|
||||
mov [LAPIC_BASE], eax
|
||||
mov esi, eax
|
||||
|
||||
; Program Destination Format Register for Flat mode.
|
||||
mov eax, [esi + APIC_DFR]
|
||||
or eax, 0xf0000000
|
||||
mov [esi + APIC_DFR], eax
|
||||
|
||||
; Program Logical Destination Register.
|
||||
mov eax, [esi + APIC_LDR]
|
||||
;and eax, 0xff000000
|
||||
and eax, 0x00ffffff
|
||||
or eax, 0x01000000;!!!!!!!!!!!!
|
||||
mov [esi + APIC_LDR], eax
|
||||
|
||||
; Task Priority Register initialization.
|
||||
mov eax, [esi + APIC_TPR]
|
||||
and eax, 0xffffff00
|
||||
mov [esi + APIC_TPR], eax
|
||||
|
||||
; Flush the queue
|
||||
mov edx, 0
|
||||
.nxt2:
|
||||
mov ecx, 32
|
||||
mov eax, [esi + APIC_ISR + edx]
|
||||
.nxt:
|
||||
shr eax, 1
|
||||
jnc @f
|
||||
mov dword [esi + APIC_EOI], 0; EOI
|
||||
@@:
|
||||
loop .nxt
|
||||
|
||||
add edx, 0x10
|
||||
cmp edx, 0x170
|
||||
jbe .nxt2
|
||||
|
||||
; Spurious-Interrupt Vector Register initialization.
|
||||
mov eax, [esi + APIC_SVR]
|
||||
or eax, 0x1ff
|
||||
and eax, 0xfffffdff
|
||||
mov [esi + APIC_SVR], eax
|
||||
|
||||
; Initialize LVT LINT0 register. (INTR)
|
||||
mov eax, 0x00700
|
||||
; mov eax, 0x10700
|
||||
mov [esi + APIC_LVT_LINT0], eax
|
||||
|
||||
; Initialize LVT LINT1 register. (NMI)
|
||||
mov eax, 0x00400
|
||||
mov [esi + APIC_LVT_LINT1], eax
|
||||
|
||||
; Initialize LVT Error register.
|
||||
mov eax, [esi + APIC_LVT_err]
|
||||
or eax, 0x10000; bit 16
|
||||
mov [esi + APIC_LVT_err], eax
|
||||
|
||||
; LAPIC timer
|
||||
; pre init
|
||||
mov dword[esi + APIC_timer_div], 1011b; 1
|
||||
mov dword[esi + APIC_timer_init], 0xffffffff; max val
|
||||
push esi
|
||||
mov esi, 640 ; wait 0.64 sec
|
||||
call delay_ms
|
||||
pop esi
|
||||
mov eax, [esi + APIC_timer_cur]; read current tick couner
|
||||
xor eax, 0xffffffff ; eax = 0xffffffff - eax
|
||||
shr eax, 6 ; eax /= 64; APIC ticks per 0.01 sec
|
||||
|
||||
; Start (every 0.01 sec)
|
||||
mov dword[esi + APIC_LVT_timer], 0x30020; periodic int 0x20
|
||||
mov dword[esi + APIC_timer_init], eax
|
||||
ret
|
||||
|
||||
;===========================================================
|
||||
; IOAPIC implementation
|
||||
align 4
|
||||
IOAPIC_read:
|
||||
; in : EAX - IOAPIC register
|
||||
; out: EAX - readed value
|
||||
push esi
|
||||
mov esi, [IOAPIC_base]
|
||||
mov [esi], eax
|
||||
mov eax, [esi + 0x10]
|
||||
pop esi
|
||||
ret
|
||||
|
||||
align 4
|
||||
IOAPIC_write:
|
||||
; in : EAX - IOAPIC register
|
||||
; EBX - value
|
||||
; out: none
|
||||
push esi
|
||||
mov esi, [IOAPIC_base]
|
||||
mov [esi], eax
|
||||
mov [esi + 0x10], ebx
|
||||
pop esi
|
||||
ret
|
||||
;===========================================================
|
||||
; Remap all IRQ to 0x20+ Vectors
|
||||
; IRQ0 to vector 0x20, IRQ1 to vector 0x21....
|
||||
align 4
|
||||
PIC_init:
|
||||
cli
|
||||
mov al, 0x11 ; icw4, edge triggered
|
||||
out 0x20, al
|
||||
out 0xA0, al
|
||||
|
||||
mov al, 0x20 ; generate 0x20 +
|
||||
out 0x21, al
|
||||
mov al, 0x28 ; generate 0x28 +
|
||||
out 0xA1, al
|
||||
|
||||
mov al, 0x04 ; slave at irq2
|
||||
out 0x21, al
|
||||
mov al, 0x02 ; at irq9
|
||||
out 0xA1, al
|
||||
|
||||
mov al, 0x01 ; 8086 mode
|
||||
out 0x21, al
|
||||
out 0xA1, al
|
||||
|
||||
call IRQ_mask_all
|
||||
; mov dword[irq_type_to_set], IRQ_TYPE_PIC
|
||||
ret
|
||||
|
||||
; -----------------------------------------
|
||||
; TIMER SET TO 1/100 S
|
||||
align 4
|
||||
PIT_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
|
||||
ret
|
||||
|
||||
; -----------------------------------------
|
||||
align 4
|
||||
unmask_timer:
|
||||
cmp [irq_mode], IRQ_APIC
|
||||
je @f
|
||||
|
||||
stdcall enable_irq, 0
|
||||
ret
|
||||
@@:
|
||||
; use PIT
|
||||
; in some systems PIT no connected to IOAPIC
|
||||
; mov eax, 0x14
|
||||
; call IOAPIC_read
|
||||
; mov ah, 0x09 ; Delivery Mode: Lowest Priority, Destination Mode: Logical
|
||||
; mov al, 0x20
|
||||
; or eax, 0x10000 ; Mask Interrupt
|
||||
; mov ebx, eax
|
||||
; mov eax, 0x14
|
||||
; call IOAPIC_write
|
||||
; stdcall enable_irq, 2
|
||||
; ret
|
||||
|
||||
; use LAPIC timer
|
||||
mov esi, [LAPIC_BASE]
|
||||
mov eax, [esi + APIC_LVT_timer]
|
||||
and eax, 0xfffeffff
|
||||
mov [esi + APIC_LVT_timer], eax
|
||||
ret
|
||||
|
||||
; -----------------------------------------
|
||||
; Disable all IRQ
|
||||
align 4
|
||||
IRQ_mask_all:
|
||||
cmp [irq_mode], IRQ_APIC
|
||||
je .APIC
|
||||
|
||||
mov al, 0xFF
|
||||
out 0x21, al
|
||||
out 0xA1, al
|
||||
mov ecx, 0x1000
|
||||
ret
|
||||
.APIC:
|
||||
mov ecx, [IRQ_COUNT]
|
||||
mov eax, 0x10
|
||||
@@:
|
||||
mov ebx, eax
|
||||
call IOAPIC_read
|
||||
or eax, 0x10000; bit 16
|
||||
xchg eax, ebx
|
||||
call IOAPIC_write
|
||||
inc eax
|
||||
inc eax
|
||||
loop @b
|
||||
ret
|
||||
|
||||
; -----------------------------------------
|
||||
; End Of Interrupt
|
||||
; cl - IRQ number
|
||||
align 4
|
||||
irq_eoi: ; __fastcall
|
||||
cmp [irq_mode], IRQ_APIC
|
||||
je .APIC
|
||||
|
||||
cmp cl, 8
|
||||
mov al, 0x20
|
||||
jb @f
|
||||
out 0xa0, al
|
||||
@@:
|
||||
out 0x20, al
|
||||
ret
|
||||
|
||||
.APIC:
|
||||
mov eax, [LAPIC_BASE]
|
||||
mov dword [eax + APIC_EOI], 0; EOI
|
||||
ret
|
||||
|
||||
; -----------------------------------------
|
||||
; from dll.inc
|
||||
align 4
|
||||
proc enable_irq stdcall, irq_line:dword
|
||||
mov ebx, [irq_line]
|
||||
cmp [irq_mode], IRQ_APIC
|
||||
je .APIC
|
||||
|
||||
mov edx, 0x21
|
||||
cmp ebx, 8
|
||||
jb @F
|
||||
|
||||
mov edx, 0xA1
|
||||
sub ebx, 8
|
||||
@@:
|
||||
in al, dx
|
||||
btr eax, ebx
|
||||
out dx, al
|
||||
ret
|
||||
.APIC:
|
||||
shl ebx, 1
|
||||
add ebx, 0x10
|
||||
mov eax, ebx
|
||||
call IOAPIC_read
|
||||
and eax, 0xfffeffff; bit 16
|
||||
xchg eax, ebx
|
||||
call IOAPIC_write
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
pci_irq_fixup:
|
||||
|
||||
push ebp
|
||||
|
||||
mov esi, [acpi_dev_data]
|
||||
mov ebx, [acpi_dev_size]
|
||||
|
||||
lea edi, [esi+ebx]
|
||||
|
||||
.iterate:
|
||||
|
||||
cmp esi, edi
|
||||
jae .done
|
||||
|
||||
mov eax, [esi]
|
||||
|
||||
cmp eax, -1
|
||||
je .done
|
||||
|
||||
movzx ebx, al
|
||||
movzx ebp, ah
|
||||
|
||||
stdcall pci_read32, ebp, ebx, 0
|
||||
|
||||
cmp eax, [esi+4]
|
||||
jne .skip
|
||||
|
||||
mov eax, [esi+8]
|
||||
stdcall pci_write8, ebp, ebx, 0x3C, eax
|
||||
.skip:
|
||||
add esi, 16
|
||||
jmp .iterate
|
||||
|
||||
.done:
|
||||
.fail:
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -13,7 +13,8 @@
|
||||
$Revision$
|
||||
|
||||
iglobal
|
||||
conf_path_sect: db 'path',0
|
||||
conf_path_sect:
|
||||
db 'path',0
|
||||
|
||||
conf_fname db '/sys/sys.conf',0
|
||||
endg
|
||||
@@ -75,62 +76,7 @@ udev db 'dev',0
|
||||
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
|
||||
@@ -262,36 +208,3 @@ proc strtoint_hex stdcall,strs
|
||||
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
|
||||
|
@@ -13,7 +13,8 @@ sys_debug_services:
|
||||
cmp ebx, 9
|
||||
ja @f
|
||||
jmp dword [sys_debug_services_table+ebx*4]
|
||||
@@: ret
|
||||
@@:
|
||||
ret
|
||||
iglobal
|
||||
align 4
|
||||
sys_debug_services_table:
|
||||
@@ -93,7 +94,8 @@ debug_suspend:
|
||||
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
|
||||
@@ -108,9 +110,12 @@ do_resume:
|
||||
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:
|
||||
@@ -122,7 +127,8 @@ debug_resume:
|
||||
shl eax, 5
|
||||
jz .ret
|
||||
call do_resume
|
||||
.ret: sti
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
|
||||
debug_getcontext:
|
||||
@@ -323,7 +329,7 @@ debug_read_process_memory:
|
||||
call get_debuggee_slot
|
||||
jc .err
|
||||
shr eax, 5
|
||||
; mov ebx, esi
|
||||
mov ecx, edi
|
||||
call read_process_memory
|
||||
sti
|
||||
mov dword [esp+32], eax
|
||||
@@ -349,7 +355,7 @@ debug_write_process_memory:
|
||||
call get_debuggee_slot
|
||||
jc debug_read_process_memory.err
|
||||
shr eax, 5
|
||||
; mov ebx, esi
|
||||
mov ecx, edi
|
||||
call write_process_memory
|
||||
sti
|
||||
mov [esp+32], eax
|
||||
@@ -368,23 +374,23 @@ debugger_notify:
|
||||
.1:
|
||||
mov eax, ebp
|
||||
shl eax, 8
|
||||
mov edx, [SLOT_BASE+eax+APPDATA.dbg_event_mem]
|
||||
test edx, edx
|
||||
mov esi, [SLOT_BASE+eax+APPDATA.dbg_event_mem]
|
||||
test esi, esi
|
||||
jz .ret
|
||||
; read buffer header
|
||||
push ecx
|
||||
push eax
|
||||
push eax
|
||||
mov eax, ebp
|
||||
mov ebx, esp
|
||||
mov ecx, 8
|
||||
mov ecx, esp
|
||||
mov edx, 8
|
||||
call read_process_memory
|
||||
cmp eax, ecx
|
||||
cmp eax, edx
|
||||
jz @f
|
||||
add esp, 12
|
||||
jmp .ret
|
||||
@@:
|
||||
cmp dword [ebx], 0
|
||||
cmp dword [ecx], 0
|
||||
jg @f
|
||||
.2:
|
||||
pop ecx
|
||||
@@ -400,26 +406,26 @@ debugger_notify:
|
||||
cli
|
||||
jmp .1
|
||||
@@:
|
||||
mov ecx, [ebx+8]
|
||||
add ecx, [ebx+4]
|
||||
cmp ecx, [ebx]
|
||||
mov edx, [ecx+8]
|
||||
add edx, [ecx+4]
|
||||
cmp edx, [ecx]
|
||||
ja .2
|
||||
; advance buffer position
|
||||
push ecx
|
||||
mov ecx, 4
|
||||
sub ebx, ecx
|
||||
push edx
|
||||
mov edx, 4
|
||||
sub ecx, edx
|
||||
mov eax, ebp
|
||||
add edx, ecx
|
||||
add esi, edx
|
||||
call write_process_memory
|
||||
pop eax
|
||||
; write message
|
||||
mov eax, ebp
|
||||
add edx, ecx
|
||||
add edx, [ebx+8]
|
||||
add ebx, 20
|
||||
pop ecx
|
||||
pop ecx
|
||||
pop ecx
|
||||
add esi, edx
|
||||
add esi, [ecx+8]
|
||||
add ecx, 20
|
||||
pop edx
|
||||
pop edx
|
||||
pop edx
|
||||
call write_process_memory
|
||||
; new debug event
|
||||
mov eax, ebp
|
||||
|
@@ -9,188 +9,12 @@ $Revision$
|
||||
|
||||
|
||||
DRV_COMPAT equ 5 ;minimal required drivers version
|
||||
DRV_CURRENT equ 5 ;current drivers model version
|
||||
DRV_CURRENT equ 6 ;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
|
||||
@@ -212,7 +36,7 @@ endp
|
||||
|
||||
align 4
|
||||
proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
|
||||
push ebx edx
|
||||
push ebx
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
mov ah, byte [bus]
|
||||
@@ -220,13 +44,13 @@ proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
|
||||
mov bh, byte [devfn]
|
||||
mov bl, byte [reg]
|
||||
call pci_read_reg
|
||||
pop edx ebx
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
|
||||
push ebx edx
|
||||
push ebx
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
mov ah, byte [bus]
|
||||
@@ -234,13 +58,13 @@ proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
|
||||
mov bh, byte [devfn]
|
||||
mov bl, byte [reg]
|
||||
call pci_read_reg
|
||||
pop edx ebx
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
|
||||
push ebx edx
|
||||
push ebx
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
mov ah, byte [bus]
|
||||
@@ -248,13 +72,13 @@ proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
|
||||
mov bh, byte [devfn]
|
||||
mov bl, byte [reg]
|
||||
call pci_read_reg
|
||||
pop edx ebx
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
|
||||
push ebx edx
|
||||
push ebx
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
mov ah, byte [bus]
|
||||
@@ -263,13 +87,13 @@ proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
|
||||
mov bl, byte [reg]
|
||||
mov ecx, [val]
|
||||
call pci_write_reg
|
||||
pop edx ebx
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
|
||||
push ebx edx
|
||||
push ebx
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
mov ah, byte [bus]
|
||||
@@ -278,13 +102,13 @@ proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
|
||||
mov bl, byte [reg]
|
||||
mov ecx, [val]
|
||||
call pci_write_reg
|
||||
pop edx ebx
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
|
||||
push ebx edx
|
||||
push ebx
|
||||
xor eax, eax
|
||||
xor ebx, ebx
|
||||
mov ah, byte [bus]
|
||||
@@ -293,7 +117,7 @@ proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
|
||||
mov bl, byte [reg]
|
||||
mov ecx, [val]
|
||||
call pci_write_reg
|
||||
pop edx ebx
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
@@ -544,10 +368,8 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
|
||||
mov [name], ebx
|
||||
|
||||
pushad
|
||||
push eax
|
||||
lea eax, [cmd]
|
||||
lea ebx, [cmd]
|
||||
call file_system_lfn
|
||||
pop eax
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
@@ -597,6 +419,8 @@ proc load_file stdcall, file_name:dword
|
||||
|
||||
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]
|
||||
@@ -797,6 +621,7 @@ proc fix_coff_relocs stdcall uses ebx esi, coff:dword, sym:dword, \
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
|
||||
delta:dword
|
||||
locals
|
||||
@@ -1620,70 +1445,3 @@ destroy_kernel_object:
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -28,7 +28,8 @@ macro export dllname,[label,string]
|
||||
local name
|
||||
dd (name-OS_BASE)
|
||||
common
|
||||
ordinal: count = 0
|
||||
ordinal:
|
||||
count = 0
|
||||
forward
|
||||
dw count
|
||||
count = count+1
|
||||
|
@@ -16,12 +16,16 @@ iglobal
|
||||
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
|
||||
@@ -71,6 +75,9 @@ iglobal
|
||||
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
|
||||
@@ -78,6 +85,13 @@ iglobal
|
||||
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
|
||||
@@ -91,13 +105,17 @@ kernel_export:
|
||||
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 szPciApi , pci_api
|
||||
dd szMutexInit , mutex_init ;gcc fastcall
|
||||
dd szMutexLock , mutex_lock ;gcc fastcall
|
||||
dd szMutexUnlock , mutex_unlock ;gcc fastcall
|
||||
|
||||
dd szPciApi , pci_api_drv
|
||||
dd szPciRead32 , pci_read32
|
||||
dd szPciRead16 , pci_read16
|
||||
dd szPciRead8 , pci_read8
|
||||
@@ -145,6 +163,9 @@ kernel_export:
|
||||
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
|
||||
@@ -152,6 +173,13 @@ kernel_export:
|
||||
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
|
||||
|
@@ -158,7 +158,8 @@ endp
|
||||
|
||||
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
|
||||
@@ -168,7 +169,8 @@ proc dll.Load, import_table:dword
|
||||
mov al, '/'
|
||||
stosb
|
||||
mov esi, sysdir_path
|
||||
@@: lodsb
|
||||
@@:
|
||||
lodsb
|
||||
stosb
|
||||
or al, al
|
||||
jnz @b
|
||||
@@ -179,7 +181,8 @@ proc dll.Load, import_table:dword
|
||||
pop esi
|
||||
push esi
|
||||
mov esi, [esi+4]
|
||||
@@: lodsb
|
||||
@@:
|
||||
lodsb
|
||||
stosb
|
||||
or al, al
|
||||
jnz @b
|
||||
@@ -195,9 +198,11 @@ proc dll.Load, import_table:dword
|
||||
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
|
||||
@@ -208,7 +213,8 @@ proc dll.Link, exp:dword,imp:dword
|
||||
mov esi, [imp]
|
||||
test esi, esi
|
||||
jz .done
|
||||
.next: lodsd
|
||||
.next:
|
||||
lodsd
|
||||
test eax, eax
|
||||
jz .done
|
||||
stdcall dll.GetProcAddress, [exp], eax
|
||||
@@ -216,8 +222,10 @@ proc dll.Link, exp:dword,imp:dword
|
||||
jz @f
|
||||
mov [esi-4], eax
|
||||
jmp .next
|
||||
@@: mov dword[esp],0
|
||||
.done: pop eax
|
||||
@@:
|
||||
mov dword[esp], 0
|
||||
.done:
|
||||
pop eax
|
||||
ret
|
||||
endp
|
||||
|
||||
@@ -234,15 +242,18 @@ endp
|
||||
|
||||
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
|
||||
jz .ok
|
||||
add edx, 8
|
||||
jmp .next
|
||||
.ok: mov eax,[edx+4]
|
||||
.end: ret
|
||||
.ok:
|
||||
mov eax, [edx+4]
|
||||
.end:
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
@@ -276,7 +287,8 @@ proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
|
||||
add ecx, -4
|
||||
cmp ecx, [eax-4]
|
||||
je .exit
|
||||
@@: mov eax,ebx
|
||||
@@:
|
||||
mov eax, ebx
|
||||
call mem.Alloc
|
||||
xchg eax, [esp]
|
||||
or eax, eax
|
||||
@@ -288,7 +300,8 @@ proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
|
||||
cmp ecx, [edi-4]
|
||||
jbe @f
|
||||
mov ecx, [edi-4]
|
||||
@@: add ecx,3
|
||||
@@:
|
||||
add ecx, 3
|
||||
shr ecx, 2
|
||||
cld
|
||||
rep movsd
|
||||
|
@@ -9,17 +9,17 @@ $Revision$
|
||||
|
||||
|
||||
struc MEM_BLOCK
|
||||
{ .next_block dd ?
|
||||
{
|
||||
.list LHEAD
|
||||
.next_block dd ? ;+8
|
||||
.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,12 +28,11 @@ virtual at 0
|
||||
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_fd
|
||||
list_bk equ MEM_BLOCK.list_bk
|
||||
list_fd equ MEM_BLOCK.list.next
|
||||
list_bk equ MEM_BLOCK.list.prev
|
||||
block_base equ MEM_BLOCK.base
|
||||
block_size equ MEM_BLOCK.size
|
||||
block_flags equ MEM_BLOCK.flags
|
||||
@@ -47,68 +46,93 @@ macro calc_index op
|
||||
@@:
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
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_free op
|
||||
{
|
||||
remove_from_list op
|
||||
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
|
||||
|
||||
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
|
||||
@@:
|
||||
}
|
||||
lea ebx, [mem_used_list+ecx*8]
|
||||
mov esi, ebx
|
||||
.next:
|
||||
mov esi, [esi+list_fd]
|
||||
cmp esi, ebx
|
||||
je .fail
|
||||
|
||||
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
|
||||
}
|
||||
cmp eax, [esi+block_base]
|
||||
jne .next
|
||||
|
||||
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
|
||||
xor eax, eax
|
||||
cld
|
||||
rep stosd
|
||||
@@:
|
||||
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
|
||||
mov ecx, 64
|
||||
mov edi, mem_used_list
|
||||
@@:
|
||||
mov eax, edi
|
||||
stosd
|
||||
stosd
|
||||
loop @B
|
||||
|
||||
stdcall alloc_pages, dword 32
|
||||
mov ecx, 32
|
||||
@@ -121,26 +145,34 @@ proc init_kernel_heap
|
||||
dec ecx
|
||||
jnz .l1
|
||||
|
||||
mov edi, HEAP_BASE
|
||||
mov ebx, HEAP_BASE+MEM_BLOCK_SIZE
|
||||
mov edi, HEAP_BASE ;descriptors
|
||||
mov ebx, HEAP_BASE+MEM_BLOCK.sizeof ;free space
|
||||
mov ecx, HEAP_BASE+MEM_BLOCK.sizeof*2 ;terminator
|
||||
|
||||
xor eax, eax
|
||||
mov [edi+block_next], ebx
|
||||
mov [edi+block_prev], eax
|
||||
mov [edi+list_fd], eax
|
||||
mov [edi+list_bk], eax
|
||||
mov [edi+block_base], HEAP_BASE
|
||||
mov [edi+block_size], 4096*MEM_BLOCK_SIZE
|
||||
mov [edi+block_size], 4096*MEM_BLOCK.sizeof
|
||||
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 [ecx+block_next], eax
|
||||
mov [ecx+block_prev], ebx
|
||||
mov [edi+list_fd], eax
|
||||
mov [edi+list_bk], eax
|
||||
mov [edi+block_base], eax
|
||||
mov [edi+block_size], eax
|
||||
mov [edi+block_flags], USED_BLOCK
|
||||
|
||||
mov [ebx+block_next], ecx
|
||||
mov [ebx+block_prev], edi
|
||||
mov [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_SIZE
|
||||
sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK.sizeof
|
||||
mov [heap_size], ecx
|
||||
mov [heap_free], ecx
|
||||
mov [ebx+block_size], ecx
|
||||
@@ -149,11 +181,24 @@ proc init_kernel_heap
|
||||
mov [mem_block_mask], eax
|
||||
mov [mem_block_mask+4], 0x80000000
|
||||
|
||||
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
|
||||
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
|
||||
ret
|
||||
endp
|
||||
|
||||
@@ -190,11 +235,18 @@ get_small_block:
|
||||
bsf edi, edx
|
||||
jz .high_mask
|
||||
add ebx, edi
|
||||
mov edi, [mem_block_list+ebx*4]
|
||||
.check_size:
|
||||
lea ecx, [mem_block_list+ebx*8]
|
||||
mov edi, ecx
|
||||
.next:
|
||||
mov edi, [edi+list_fd]
|
||||
cmp edi, ecx
|
||||
je .err
|
||||
cmp eax, [edi+block_size]
|
||||
ja .next
|
||||
ret
|
||||
.err:
|
||||
xor edi, edi
|
||||
ret
|
||||
|
||||
.high_mask:
|
||||
add esi, 4
|
||||
@@ -203,65 +255,23 @@ get_small_block:
|
||||
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 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 ebx, [next_memblock]
|
||||
mov [eax], ebx
|
||||
mov [next_memblock], eax
|
||||
xor ebx, ebx
|
||||
|
||||
sub eax, [mem_block_arr]
|
||||
shr eax, 5
|
||||
|
||||
mov ebx, mem_block_map
|
||||
bts [ebx], eax
|
||||
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
|
||||
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
|
||||
@@ -277,18 +287,20 @@ proc alloc_kernel_space stdcall, size:dword
|
||||
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
|
||||
jz .error_unlock
|
||||
|
||||
cmp [edi+block_flags], FREE_BLOCK
|
||||
jne .error
|
||||
jne .error_unlock
|
||||
|
||||
mov [block_ind], ebx ;index of allocated block
|
||||
|
||||
@@ -296,11 +308,13 @@ proc alloc_kernel_space stdcall, size:dword
|
||||
cmp eax, [size]
|
||||
je .m_eq_size
|
||||
|
||||
call alloc_mem_block
|
||||
and eax, eax
|
||||
jz .error
|
||||
mov esi, [next_memblock] ;new memory block
|
||||
test esi, esi
|
||||
jz .error_unlock
|
||||
|
||||
mov esi, eax ;esi - splitted block
|
||||
dec [free_blocks]
|
||||
mov eax, [esi]
|
||||
mov [next_memblock], eax
|
||||
|
||||
mov [esi+block_next], edi
|
||||
mov eax, [edi+block_prev]
|
||||
@@ -308,10 +322,8 @@ proc alloc_kernel_space stdcall, size:dword
|
||||
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]
|
||||
@@ -320,75 +332,48 @@ proc alloc_kernel_space stdcall, size:dword
|
||||
sub [edi+block_size], edx
|
||||
|
||||
mov eax, [edi+block_size]
|
||||
shr eax, 12
|
||||
sub eax, 1
|
||||
cmp eax, 63
|
||||
jna @f
|
||||
mov eax, 63
|
||||
@@:
|
||||
calc_index eax
|
||||
cmp eax, [block_ind]
|
||||
je .m_eq_ind
|
||||
je .add_used
|
||||
|
||||
remove_from_list edi
|
||||
list_del edi
|
||||
|
||||
mov ecx, [block_ind]
|
||||
mov [mem_block_list+ecx*4], edx
|
||||
|
||||
test edx, edx
|
||||
lea edx, [mem_block_list+ecx*8]
|
||||
cmp 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
|
||||
.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
|
||||
lea edx, [mem_block_list+eax*8] ;edx= list head
|
||||
list_add edi, edx
|
||||
.add_used:
|
||||
|
||||
mov [esi+block_flags], USED_BLOCK
|
||||
call md.add_to_used
|
||||
|
||||
mov ecx, heap_mutex
|
||||
call mutex_unlock
|
||||
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:
|
||||
remove_from_list edi
|
||||
mov [mem_block_list+ebx*4], edx
|
||||
and edx, edx
|
||||
list_del edi
|
||||
lea edx, [mem_block_list+ebx*8]
|
||||
cmp edx, [edx]
|
||||
jnz @f
|
||||
btr [mem_block_mask], ebx
|
||||
@@:
|
||||
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
|
||||
mov esi, edi
|
||||
jmp .add_used
|
||||
|
||||
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_unlock:
|
||||
mov ecx, heap_mutex
|
||||
call mutex_unlock
|
||||
.error:
|
||||
xor eax, eax
|
||||
mov [heap_mutex], eax
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
@@ -397,66 +382,49 @@ endp
|
||||
|
||||
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
|
||||
|
||||
cmp [esi+block_base], eax
|
||||
je .found
|
||||
mov esi, [esi+list_fd]
|
||||
jmp @b
|
||||
.found:
|
||||
cmp [esi+block_flags], USED_BLOCK
|
||||
jne .fail
|
||||
call md.del_from_used
|
||||
test esi, esi
|
||||
jz .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
|
||||
|
||||
remove_from_free edi
|
||||
list_del 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
|
||||
|
||||
@@ -465,67 +433,40 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
|
||||
add eax, ecx
|
||||
mov [edi+block_size], eax
|
||||
|
||||
calc_index eax
|
||||
calc_index ecx
|
||||
calc_index eax ;new index
|
||||
calc_index ecx ;old index
|
||||
cmp eax, ecx
|
||||
je .m_eq
|
||||
|
||||
push ecx
|
||||
remove_from_list edi
|
||||
list_del edi
|
||||
pop ecx
|
||||
|
||||
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
|
||||
lea edx, [mem_block_list+ecx*8]
|
||||
cmp edx, [edx]
|
||||
jne .add_block
|
||||
btr [mem_block_mask], ecx
|
||||
@@:
|
||||
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
|
||||
@@:
|
||||
.add_block:
|
||||
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
|
||||
mov [heap_mutex], eax
|
||||
dec eax
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebx
|
||||
not eax
|
||||
ret
|
||||
.insert:
|
||||
remove_from_used esi
|
||||
|
||||
mov [esi+block_flags], FREE_BLOCK
|
||||
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
|
||||
|
||||
@@ -605,37 +546,31 @@ endp
|
||||
|
||||
align 4
|
||||
proc kernel_free stdcall, base:dword
|
||||
|
||||
push ebx esi
|
||||
|
||||
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.find_used
|
||||
|
||||
cmp [esi+block_base], eax
|
||||
je .found
|
||||
mov esi, [esi+list_fd]
|
||||
jmp @b
|
||||
.found:
|
||||
mov ecx, heap_mutex
|
||||
cmp [esi+block_flags], USED_BLOCK
|
||||
jne .fail
|
||||
|
||||
and [heap_mutex], 0
|
||||
call mutex_unlock
|
||||
|
||||
push ecx
|
||||
mov ecx, [esi+block_size];
|
||||
mov eax, [esi+block_base]
|
||||
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:
|
||||
and [heap_mutex], 0
|
||||
call mutex_unlock
|
||||
xor eax, eax
|
||||
pop esi ebx
|
||||
ret
|
||||
endp
|
||||
@@ -1521,13 +1456,14 @@ proc shmem_close stdcall, name:dword
|
||||
test edi, edi
|
||||
jz .next
|
||||
|
||||
lea eax, [edi+SMEM.name]
|
||||
lea edi, [edi+SMEM.name]
|
||||
stdcall strncmp, [name], edi, 32
|
||||
test eax, eax
|
||||
jne .next
|
||||
|
||||
stdcall user_free, [esi+SMAP.base]
|
||||
|
||||
mov eax, esi
|
||||
call [esi+APPOBJ.destroy]
|
||||
@@:
|
||||
popfd
|
||||
|
229
kernel/branches/net/core/irq.inc
Normal file
229
kernel/branches/net/core/irq.inc
Normal file
@@ -0,0 +1,229 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
IRQ_RESERVED equ 24
|
||||
|
||||
IRQ_POOL_SIZE equ 48
|
||||
|
||||
uglobal
|
||||
|
||||
align 16
|
||||
irqh_tab rd LHEAD.sizeof * IRQ_RESERVED / 4
|
||||
|
||||
irqh_pool rd IRQH.sizeof * IRQ_POOL_SIZE /4
|
||||
next_irqh rd 1
|
||||
|
||||
irq_active_set rd 1
|
||||
irq_failed rd IRQ_RESERVED
|
||||
|
||||
endg
|
||||
|
||||
align 4
|
||||
init_irqs:
|
||||
|
||||
mov ecx, IRQ_RESERVED
|
||||
mov edi, irqh_tab
|
||||
@@:
|
||||
mov eax, edi
|
||||
stosd
|
||||
stosd
|
||||
loop @B
|
||||
|
||||
mov ecx, IRQ_POOL_SIZE-1
|
||||
mov eax, irqh_pool+IRQH.sizeof
|
||||
mov [next_irqh], irqh_pool
|
||||
@@:
|
||||
mov [eax-IRQH.sizeof], eax
|
||||
add eax, IRQH.sizeof
|
||||
loop @B
|
||||
|
||||
mov [eax-IRQH.sizeof], dword 0
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword
|
||||
locals
|
||||
.irqh dd ?
|
||||
endl
|
||||
|
||||
and [.irqh], 0
|
||||
|
||||
push ebx
|
||||
|
||||
mov ebx, [irq] ;irq num
|
||||
test ebx, ebx
|
||||
jz .err
|
||||
|
||||
cmp ebx, IRQ_RESERVED
|
||||
jae .err
|
||||
|
||||
mov edx, [handler]
|
||||
test edx, edx
|
||||
jz .err
|
||||
|
||||
pushfd
|
||||
cli
|
||||
|
||||
;allocate handler
|
||||
|
||||
mov ecx, [next_irqh]
|
||||
test ecx, ecx
|
||||
jz .fail
|
||||
|
||||
mov eax, [ecx]
|
||||
mov [next_irqh], eax
|
||||
mov [.irqh], ecx
|
||||
|
||||
mov [irq_failed+ebx*4], 0;clear counter
|
||||
|
||||
mov eax, [user_data]
|
||||
mov [ecx+IRQH.handler], edx
|
||||
mov [ecx+IRQH.data], eax
|
||||
|
||||
lea edx, [irqh_tab+ebx*8]
|
||||
list_add_tail ecx, edx ;clobber eax
|
||||
stdcall enable_irq, ebx
|
||||
|
||||
.fail:
|
||||
popfd
|
||||
.err:
|
||||
pop ebx
|
||||
mov eax, [.irqh]
|
||||
ret
|
||||
|
||||
endp
|
||||
|
||||
if 0
|
||||
align 4
|
||||
proc get_int_handler stdcall, irq:dword
|
||||
|
||||
mov eax, [irq]
|
||||
cmp eax, 15
|
||||
ja .fail
|
||||
mov eax, [irq_tab + 4 * eax]
|
||||
ret
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
end if
|
||||
|
||||
|
||||
align 4
|
||||
proc detach_int_handler
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
macro irq_serv_h [num] {
|
||||
forward
|
||||
align 4
|
||||
.irq_#num :
|
||||
push num
|
||||
jmp .main
|
||||
}
|
||||
|
||||
align 16
|
||||
irq_serv:
|
||||
|
||||
; .irq_1:
|
||||
; push 1
|
||||
; jmp .main
|
||||
; etc...
|
||||
|
||||
irq_serv_h 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15
|
||||
irq_serv_h 16, 17, 18, 19, 20, 21, 22, 23
|
||||
|
||||
purge irq_serv_h
|
||||
|
||||
align 16
|
||||
.main:
|
||||
save_ring3_context
|
||||
|
||||
mov ebp, [esp + 32]
|
||||
mov bx, app_data;os_data
|
||||
mov ds, bx
|
||||
mov es, bx
|
||||
|
||||
cmp [v86_irqhooks+ebp*8], 0
|
||||
jnz v86_irq
|
||||
|
||||
cmp bp, 6
|
||||
jnz @f
|
||||
push ebp
|
||||
call [fdc_irq_func]
|
||||
pop ebp
|
||||
@@:
|
||||
|
||||
cmp bp, 14
|
||||
jnz @f
|
||||
push ebp
|
||||
call [irq14_func]
|
||||
pop ebp
|
||||
@@:
|
||||
cmp bp, 15
|
||||
jnz @f
|
||||
push ebp
|
||||
call [irq15_func]
|
||||
pop ebp
|
||||
@@:
|
||||
bts [irq_active_set], ebp
|
||||
|
||||
lea esi, [irqh_tab+ebp*8] ; esi= list head
|
||||
mov ebx, esi
|
||||
.next:
|
||||
mov ebx, [ebx+IRQH.list.next]; ebx= irqh pointer
|
||||
cmp ebx, esi
|
||||
je .done
|
||||
|
||||
push ebx ; FIX THIS
|
||||
push edi
|
||||
push esi
|
||||
|
||||
push [ebx+IRQH.data]
|
||||
call [ebx+IRQH.handler]
|
||||
add esp, 4
|
||||
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebx
|
||||
|
||||
test eax, eax
|
||||
jz .next
|
||||
|
||||
btr [irq_active_set], ebp
|
||||
jmp .next
|
||||
|
||||
.done:
|
||||
btr [irq_active_set], ebp
|
||||
jnc .exit
|
||||
|
||||
inc [irq_failed+ebp*4]
|
||||
.exit:
|
||||
mov [check_idle_semaphore], 5
|
||||
|
||||
mov ecx, ebp
|
||||
call irq_eoi
|
||||
|
||||
restore_ring3_context
|
||||
add esp, 4
|
||||
iret
|
||||
|
||||
align 4
|
||||
irqD:
|
||||
push eax
|
||||
push ecx
|
||||
xor eax, eax
|
||||
out 0xf0, al
|
||||
mov cl, 13
|
||||
call irq_eoi
|
||||
pop ecx
|
||||
pop eax
|
||||
iret
|
||||
|
@@ -20,7 +20,7 @@ $Revision$
|
||||
; esi= nb
|
||||
; ebx= idx
|
||||
;
|
||||
align 16
|
||||
align 4
|
||||
malloc:
|
||||
push esi
|
||||
|
||||
@@ -31,8 +31,8 @@ malloc:
|
||||
and esi, -8
|
||||
add esi, 8
|
||||
|
||||
mov ebx, mst.mutex
|
||||
call wait_mutex ;ebx
|
||||
mov ecx, mst.mutex
|
||||
call mutex_lock
|
||||
|
||||
cmp esi, 256
|
||||
jae .large
|
||||
@@ -92,9 +92,13 @@ malloc:
|
||||
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
|
||||
|
||||
@@ -133,10 +137,10 @@ malloc:
|
||||
mov [edx+12], eax ; F->bk = r;
|
||||
mov [eax+8], edx ; r->fd = F;
|
||||
mov [eax+12], ecx ; r->bk = B;
|
||||
|
||||
mov eax, ebx
|
||||
pop esi
|
||||
mov [mst.mutex], 0
|
||||
ret
|
||||
jmp .done
|
||||
|
||||
.small:
|
||||
|
||||
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
|
||||
@@ -150,9 +154,8 @@ malloc:
|
||||
call malloc_small
|
||||
test eax, eax
|
||||
jz .from_top
|
||||
pop esi
|
||||
and [mst.mutex], 0
|
||||
ret
|
||||
jmp .done
|
||||
|
||||
.large:
|
||||
|
||||
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
|
||||
@@ -189,19 +192,19 @@ malloc:
|
||||
mov [edx+4], eax
|
||||
mov [ecx+4], esi
|
||||
lea eax, [ecx+8]
|
||||
pop esi
|
||||
and [mst.mutex], 0
|
||||
ret
|
||||
jmp .done
|
||||
|
||||
.fail:
|
||||
xor eax, eax
|
||||
pop esi
|
||||
and [mst.mutex], 0
|
||||
ret
|
||||
jmp .done
|
||||
|
||||
; param
|
||||
; eax= mem
|
||||
|
||||
align 4
|
||||
free:
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
push edi
|
||||
mov edi, eax
|
||||
add edi, -8
|
||||
@@ -211,8 +214,8 @@ free:
|
||||
test byte [edi+4], 2
|
||||
je .fail
|
||||
|
||||
mov ebx, mst.mutex
|
||||
call wait_mutex ;ebx
|
||||
mov ecx, mst.mutex
|
||||
call mutex_lock
|
||||
|
||||
; psize = p->head & (~3);
|
||||
|
||||
@@ -289,11 +292,16 @@ free:
|
||||
mov [mst.top], edi
|
||||
mov [edi+4], eax
|
||||
.fail2:
|
||||
and [mst.mutex], 0
|
||||
mov esi, eax
|
||||
mov ecx, mst.mutex
|
||||
call mutex_unlock
|
||||
mov eax, esi
|
||||
pop esi
|
||||
.fail:
|
||||
pop edi
|
||||
.exit:
|
||||
ret
|
||||
|
||||
@@:
|
||||
|
||||
; nsize = next->head & ~INUSE_BITS;
|
||||
@@ -410,13 +418,15 @@ insert_chunk:
|
||||
mov [esi+8], edx ;P->fd = F
|
||||
mov [esi+12], eax ;P->bk = B
|
||||
pop esi
|
||||
and [mst.mutex], 0
|
||||
mov ecx, mst.mutex
|
||||
call mutex_unlock
|
||||
ret
|
||||
.large:
|
||||
mov ebx, eax
|
||||
call insert_large_chunk
|
||||
pop esi
|
||||
and [mst.mutex], 0
|
||||
mov ecx, mst.mutex
|
||||
call mutex_unlock
|
||||
ret
|
||||
|
||||
|
||||
@@ -1025,5 +1035,8 @@ init_malloc:
|
||||
cmp eax, mst.smallbins+512
|
||||
jb @B
|
||||
|
||||
mov ecx, mst.mutex
|
||||
call mutex_init
|
||||
|
||||
ret
|
||||
|
||||
|
@@ -171,9 +171,14 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
|
||||
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
|
||||
@@ -189,9 +194,7 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
|
||||
or edx, [flags]
|
||||
@@:
|
||||
mov [page_tabs+eax*4], edx
|
||||
; push eax
|
||||
invlpg [ebx]
|
||||
; pop eax
|
||||
inc eax
|
||||
add ebx, edi
|
||||
add edx, edi
|
||||
@@ -214,30 +217,32 @@ endp
|
||||
|
||||
align 4
|
||||
commit_pages:
|
||||
push edi
|
||||
test ecx, ecx
|
||||
jz .fail
|
||||
|
||||
mov edi, ebx
|
||||
mov ebx, pg_data.pg_mutex
|
||||
call wait_mutex ;ebx
|
||||
push edi
|
||||
push eax
|
||||
push ecx
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_lock
|
||||
pop ecx
|
||||
pop eax
|
||||
|
||||
mov edx, 0x1000
|
||||
mov ebx, edi
|
||||
shr ebx, 12
|
||||
mov edi, ebx
|
||||
shr edi, 12
|
||||
lea edi, [page_tabs+edi*4]
|
||||
@@:
|
||||
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:
|
||||
stosd
|
||||
invlpg [ebx]
|
||||
add eax, 0x1000
|
||||
add ebx, 0x1000
|
||||
loop @B
|
||||
|
||||
pop edi
|
||||
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_unlock
|
||||
.fail:
|
||||
ret
|
||||
|
||||
|
||||
@@ -248,15 +253,21 @@ commit_pages:
|
||||
align 4
|
||||
release_pages:
|
||||
|
||||
pushad
|
||||
mov ebx, pg_data.pg_mutex
|
||||
call wait_mutex ;ebx
|
||||
push ebp
|
||||
push esi
|
||||
push edi
|
||||
push ebx
|
||||
|
||||
mov esi, eax
|
||||
mov edi, eax
|
||||
|
||||
shr esi, 10
|
||||
add esi, page_tabs
|
||||
shr esi, 12
|
||||
lea esi, [page_tabs+esi*4]
|
||||
|
||||
push ecx
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_lock
|
||||
pop ecx
|
||||
|
||||
mov ebp, [pg_data.pages_free]
|
||||
mov ebx, [page_start]
|
||||
@@ -264,9 +275,7 @@ release_pages:
|
||||
@@:
|
||||
xor eax, eax
|
||||
xchg eax, [esi]
|
||||
push eax
|
||||
invlpg [edi]
|
||||
pop eax
|
||||
|
||||
test eax, 1
|
||||
jz .next
|
||||
@@ -285,11 +294,16 @@ release_pages:
|
||||
.next:
|
||||
add edi, 0x1000
|
||||
add esi, 4
|
||||
dec ecx
|
||||
jnz @B
|
||||
loop @B
|
||||
|
||||
mov [pg_data.pages_free], ebp
|
||||
and [pg_data.pg_mutex],0
|
||||
popad
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_unlock
|
||||
|
||||
pop ebx
|
||||
pop edi
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
; param
|
||||
@@ -423,8 +437,8 @@ endp
|
||||
align 4
|
||||
proc new_mem_resize stdcall, new_size:dword
|
||||
|
||||
mov ebx, pg_data.pg_mutex
|
||||
call wait_mutex ;ebx
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_lock
|
||||
|
||||
mov edi, [new_size]
|
||||
add edi, 4095
|
||||
@@ -456,7 +470,8 @@ proc new_mem_resize stdcall, new_size:dword
|
||||
pop eax
|
||||
call free_page
|
||||
|
||||
.next: add edi, 1
|
||||
.next:
|
||||
add edi, 1
|
||||
cmp edi, esi
|
||||
jb @B
|
||||
|
||||
@@ -464,8 +479,10 @@ proc new_mem_resize stdcall, new_size:dword
|
||||
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:
|
||||
|
||||
@@ -539,9 +556,11 @@ proc new_mem_resize stdcall, new_size:dword
|
||||
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
|
||||
|
||||
@@ -779,7 +798,8 @@ proc map_mem stdcall, lin_addr:dword,slot:dword,\
|
||||
; 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
|
||||
@@ -839,7 +859,8 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
|
||||
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
|
||||
@@ -970,7 +991,8 @@ sys_IPC:
|
||||
add edx, 4095
|
||||
and edx, not 4095
|
||||
|
||||
.touch: mov eax, [ecx]
|
||||
.touch:
|
||||
mov eax, [ecx]
|
||||
add ecx, 0x1000
|
||||
cmp ecx, edx
|
||||
jb .touch
|
||||
|
@@ -283,20 +283,33 @@ __exports:
|
||||
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', \
|
||||
free, 'Kfree', \
|
||||
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', \
|
||||
pci_api, 'PciApi', \
|
||||
window._.get_rect, 'GetWindowRect', \ ; gcc fastcall
|
||||
pci_api_drv, 'PciApi', \
|
||||
pci_read8, 'PciRead8', \ ; stdcall
|
||||
pci_read16, 'PciRead16', \ ; stdcall
|
||||
pci_read32, 'PciRead32', \ ; stdcall
|
||||
@@ -304,6 +317,7 @@ __exports:
|
||||
pci_write16, 'PciWrite16', \ ; stdcall
|
||||
pci_write32, 'PciWrite32', \ ; stdcall
|
||||
\
|
||||
get_pid, 'GetPid', \
|
||||
get_service, 'GetService', \ ;
|
||||
reg_service, 'RegService', \ ; stdcall
|
||||
attach_int_handler, 'AttachIntHandler', \ ; stdcall
|
||||
@@ -311,8 +325,12 @@ __exports:
|
||||
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_mouse_data, 'SetMouseData', \ ;
|
||||
set_keyboard_data, 'SetKeyboardData', \ ; gcc fastcall
|
||||
timer_hs, 'TimerHs' ; stdcall
|
||||
|
||||
|
||||
|
||||
|
@@ -27,8 +27,8 @@ irq0:
|
||||
add [next_usage_update], 100
|
||||
call updatecputimes
|
||||
.nocounter:
|
||||
mov al,0x20 ; send End Of Interrupt signal
|
||||
out 0x20,al
|
||||
xor ecx, ecx ; send End Of Interrupt signal
|
||||
call irq_eoi
|
||||
btr dword[DONT_SWITCH], 0
|
||||
jc .return
|
||||
call find_next_task
|
||||
@@ -60,7 +60,8 @@ if 0
|
||||
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
|
||||
@@ -121,7 +122,8 @@ find_next_task:
|
||||
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
|
||||
@@ -140,7 +142,8 @@ find_next_task:
|
||||
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
|
||||
@@ -214,10 +217,96 @@ do_change_task:
|
||||
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 ?
|
||||
|
@@ -20,7 +20,8 @@ build_interrupt_table:
|
||||
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
|
||||
@@ -39,17 +40,22 @@ iglobal
|
||||
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
|
||||
else
|
||||
dd p_irq3, p_irq4 ;??? <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
end if
|
||||
dd irq_serv.irq_5, p_irq6, irq_serv.irq_7
|
||||
dd irq_serv.irq_5, irq_serv.irq_6, 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,p_irq14,p_irq15
|
||||
times 16 dd unknown_interrupt ;int_0x30..int_0x3F
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -122,8 +128,9 @@ exc_c: ;
|
||||
reg_esi equ esp+0x04
|
||||
reg_edi equ esp+0x00
|
||||
|
||||
Mov ds,ax,app_data ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mov es,ax ; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mov ax, app_data ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mov ds, ax ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mov es, ax ;<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cld ; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DF <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
movzx ebx, bl
|
||||
; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
|
||||
@@ -132,13 +139,15 @@ exc_c: ;
|
||||
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
|
||||
@@ -159,10 +168,12 @@ exc_c: ;
|
||||
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:
|
||||
@@ -186,19 +197,31 @@ IRetToUserHook:
|
||||
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
|
||||
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
|
||||
@@ -207,7 +230,8 @@ show_error_parameters:
|
||||
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
|
||||
@@ -228,154 +252,8 @@ show_error_parameters:
|
||||
restore reg_esi
|
||||
restore reg_edi
|
||||
|
||||
; irq1 -> hid/keyboard.inc
|
||||
macro irqh [num] {
|
||||
p_irq#num :
|
||||
mov edi, num
|
||||
jmp irqhandler
|
||||
}
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
set_application_table_status:
|
||||
push eax
|
||||
|
||||
@@ -390,7 +268,7 @@ set_application_table_status:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
clear_application_table_status:
|
||||
push eax
|
||||
|
||||
@@ -416,6 +294,7 @@ clear_application_table_status:
|
||||
; * eax = 0 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
; * eax = 1 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
align 4
|
||||
sys_resize_app_memory:
|
||||
; ebx = 1 - resize
|
||||
; ecx = new amount of memory
|
||||
@@ -437,6 +316,7 @@ endg
|
||||
; param
|
||||
; esi= slot
|
||||
|
||||
align 4
|
||||
terminate: ; terminate application
|
||||
|
||||
.slot equ esp ;locals
|
||||
@@ -708,25 +588,6 @@ term9:
|
||||
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
|
||||
@@ -812,17 +673,18 @@ term9:
|
||||
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 '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GDT TSS 㪠<><E3AAA0>⥫<EFBFBD>',0
|
||||
boot_sched_2 db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IDT ⠡<><E2A0A1><EFBFBD><EFBFBD>',0
|
||||
else
|
||||
boot_sched_1 db 'Building gdt tss pointer',0
|
||||
boot_sched_2 db 'Building IDT table',0
|
||||
end if
|
||||
endg
|
||||
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -17,6 +17,7 @@ cross_order:
|
||||
mov edx, esi
|
||||
mov esi, edi
|
||||
movzx edi, byte[esp+28 + 4]
|
||||
sub edi, 53
|
||||
call dword [servetable+edi*4]
|
||||
ret
|
||||
|
||||
@@ -101,78 +102,17 @@ iglobal
|
||||
|
||||
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 0
|
||||
dd 0
|
||||
dd 0 ; 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
|
||||
dd file_system_lfn ; 70-Common file system interface, version 2
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; NEW SYSTEM FUNCTIONS TABLE ;;
|
||||
@@ -180,7 +120,7 @@ iglobal
|
||||
align 4
|
||||
servetable2:
|
||||
|
||||
dd sys_drawwindow ; 0-DrawWindow
|
||||
dd syscall_draw_window ; 0-DrawWindow
|
||||
dd syscall_setpixel ; 1-SetPixel
|
||||
dd sys_getkey ; 2-GetKey
|
||||
dd sys_clock ; 3-GetTime
|
||||
@@ -221,39 +161,39 @@ iglobal
|
||||
dd syscall_drawline ; 38-DrawLine
|
||||
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
|
||||
dd set_app_param ; 40-WantEvents
|
||||
dd syscall_getirqowner ; 41-GetIrqOwner
|
||||
dd get_irq_data ; 42-ReadIrqData
|
||||
dd undefined_syscall ; 41- deprecated GetIrqOwner
|
||||
dd undefined_syscall ; 42- deprecated ReadIrqData
|
||||
dd sys_outport ; 43-SendDeviceData
|
||||
dd sys_programirq ; 44-ProgramIrqs
|
||||
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq
|
||||
dd undefined_syscall ; 44- deprecated ProgramIrqs
|
||||
dd undefined_syscall ; 45- deprecated ReserveIrq and FreeIrq
|
||||
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
|
||||
dd display_number ; 47-WriteNum
|
||||
dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
|
||||
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-Stack driver status
|
||||
dd undefined_syscall ; 53-Socket interface
|
||||
dd undefined_syscall ; 52 old network stack
|
||||
dd undefined_syscall ; 53 old network stack
|
||||
dd undefined_syscall ; 54-reserved
|
||||
dd cross_order ; 55-Sound interface
|
||||
dd sound_interface ; 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 cross_order ; 60-Inter Process Communication
|
||||
dd cross_order ; 61-Direct graphics access
|
||||
dd cross_order ; 62-PCI functions
|
||||
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 ; 63-System message board
|
||||
dd sys_resize_app_memory ; 64-Resize application memory usage
|
||||
dd cross_order ; 65-PutImagePalette
|
||||
dd cross_order ; 66-Process definitions - keyboard
|
||||
dd cross_order ; 67-Window move or resize
|
||||
dd sys_putimage_palette ; 65-PutImagePalette
|
||||
dd sys_process_def ; 66-Process definitions - keyboard
|
||||
dd syscall_move_window ; 67-Window move or resize
|
||||
dd f68 ; 68-Some internal services
|
||||
dd sys_debug_services ; 69-Debug
|
||||
dd cross_order ; 70-Common file system interface, version 2
|
||||
dd syscall_windowsettings ; 71-Window settings
|
||||
dd file_system_lfn ; 70-Common file system interface, version 2
|
||||
dd syscall_window_settings ; 71-Window settings
|
||||
dd sys_sendwindowmsg ; 72-Send window message
|
||||
dd undefined_syscall ; 73-reserved for blitter
|
||||
dd blit_32 ; 73-blitter;
|
||||
dd sys_network ; 74-Network stack
|
||||
dd sys_socket ; 75-Sockets
|
||||
dd sys_protocols ; 76-Protocols
|
||||
|
@@ -48,6 +48,7 @@ macro _clear_ op
|
||||
|
||||
fs_execute_from_sysdir:
|
||||
xor ebx, ebx
|
||||
fs_execute_from_sysdir_param:
|
||||
xor edx, edx
|
||||
mov esi, sysdir_path
|
||||
|
||||
@@ -126,7 +127,7 @@ proc fs_execute
|
||||
@@:
|
||||
lea eax, [filename]
|
||||
stdcall load_file, eax
|
||||
mov ecx, -ERROR_FILE_NOT_FOUND
|
||||
mov esi, -ERROR_FILE_NOT_FOUND
|
||||
test eax, eax
|
||||
jz .err_file
|
||||
|
||||
@@ -135,13 +136,10 @@ proc fs_execute
|
||||
|
||||
lea ebx, [hdr_cmdline]
|
||||
call test_app_header
|
||||
mov ecx, -0x1F
|
||||
mov esi, -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
|
||||
@@ -158,7 +156,7 @@ proc fs_execute
|
||||
|
||||
call get_new_process_place
|
||||
test eax, eax
|
||||
mov ecx, -0x20 ; too many processes
|
||||
mov esi, -0x20 ; too many processes
|
||||
jz .err
|
||||
|
||||
mov [slot], eax
|
||||
@@ -193,7 +191,7 @@ proc fs_execute
|
||||
mov [save_cr3], ebx
|
||||
|
||||
stdcall create_app_space, [hdr_mem], [file_base], [file_size]
|
||||
mov ecx, -30 ; no memory
|
||||
mov esi, -30; no memory
|
||||
test eax, eax
|
||||
jz .failed
|
||||
|
||||
@@ -249,7 +247,7 @@ end if
|
||||
.err_file:
|
||||
xor eax, eax
|
||||
mov [application_table_status], eax
|
||||
mov eax, ecx
|
||||
mov eax, esi
|
||||
ret
|
||||
endp
|
||||
|
||||
@@ -359,8 +357,8 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
|
||||
app_tabs dd ?
|
||||
endl
|
||||
|
||||
mov ebx, pg_data.pg_mutex
|
||||
call wait_mutex ;ebx
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_lock
|
||||
|
||||
xor eax, eax
|
||||
mov [dir_addr], eax
|
||||
@@ -479,11 +477,13 @@ end if
|
||||
.done:
|
||||
stdcall map_page, [tmp_task_pdir], dword 0, dword PG_UNMAP
|
||||
|
||||
dec [pg_data.pg_mutex]
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_unlock
|
||||
mov eax, [dir_addr]
|
||||
ret
|
||||
.fail:
|
||||
dec [pg_data.pg_mutex]
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_unlock
|
||||
cmp [dir_addr], 0
|
||||
je @f
|
||||
stdcall destroy_app_space, [dir_addr], 0
|
||||
@@ -553,10 +553,10 @@ proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword
|
||||
jg .ret
|
||||
;if there isn't threads then clear memory.
|
||||
mov esi, [dlls_list]
|
||||
call destroy_all_hdlls
|
||||
call destroy_all_hdlls;ecx=APPDATA
|
||||
|
||||
mov ebx, pg_data.pg_mutex
|
||||
call wait_mutex ;ebx
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_lock
|
||||
|
||||
mov eax, [pg_dir]
|
||||
and eax, not 0xFFF
|
||||
@@ -582,7 +582,8 @@ proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword
|
||||
.exit:
|
||||
stdcall map_page, [tmp_task_ptab], 0, PG_UNMAP
|
||||
stdcall map_page, [tmp_task_pdir], 0, PG_UNMAP
|
||||
dec [pg_data.pg_mutex]
|
||||
mov ecx, pg_data.mutex
|
||||
call mutex_unlock
|
||||
.ret:
|
||||
ret
|
||||
endp
|
||||
@@ -955,24 +956,6 @@ proc new_sys_threads
|
||||
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:
|
||||
|
||||
@@ -1166,4 +1149,13 @@ proc set_app_params stdcall,slot:dword, params:dword,\
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
get_stack_base:
|
||||
mov eax, [current_slot]
|
||||
mov eax, [eax+APPDATA.pl0_stack]
|
||||
ret
|
||||
|
||||
|
||||
include "debug.inc"
|
||||
|
205
kernel/branches/net/core/timers.inc
Normal file
205
kernel/branches/net/core/timers.inc
Normal file
@@ -0,0 +1,205 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2011. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision: 2381 $
|
||||
|
||||
; Simple implementation of timers. All timers are organized in a double-linked
|
||||
; list, and the OS loop after every timer tick processes the list.
|
||||
|
||||
; This structure describes a timer for the kernel.
|
||||
struct TIMER
|
||||
Next dd ?
|
||||
Prev dd ?
|
||||
; These fields organize a double-linked list of all timers.
|
||||
TimerFunc dd ?
|
||||
; Function to be called when the timer is activated.
|
||||
UserData dd ?
|
||||
; The value that is passed as is to .TimerFunc.
|
||||
Time dd ?
|
||||
; Time at which the timer should be activated.
|
||||
Interval dd ?
|
||||
; Interval between activations of the timer, in 0.01s.
|
||||
ends
|
||||
|
||||
iglobal
|
||||
align 4
|
||||
; The head of timer list.
|
||||
timer_list:
|
||||
dd timer_list
|
||||
dd timer_list
|
||||
endg
|
||||
uglobal
|
||||
; These two variables are used to synchronize access to the global list.
|
||||
; Logically, they form an recursive mutex. Physically, the first variable holds
|
||||
; the slot number of the current owner or 0, the second variable holds the
|
||||
; recursion count.
|
||||
; The mutex should be recursive to allow a timer function to add/delete other
|
||||
; timers or itself.
|
||||
timer_list_owner dd 0
|
||||
timer_list_numlocks dd 0
|
||||
; A timer function can delete any timer, including itself and the next timer in
|
||||
; the chain. To handle such situation correctly, we keep the next timer in a
|
||||
; global variable, so the removing operation can update it.
|
||||
timer_next dd 0
|
||||
endg
|
||||
|
||||
; This internal function acquires the lock for the global list.
|
||||
lock_timer_list:
|
||||
mov edx, [CURRENT_TASK]
|
||||
@@:
|
||||
xor eax, eax
|
||||
lock cmpxchg [timer_list_owner], edx
|
||||
jz @f
|
||||
cmp eax, edx
|
||||
jz @f
|
||||
call change_task
|
||||
jmp @b
|
||||
@@:
|
||||
inc [timer_list_numlocks]
|
||||
ret
|
||||
|
||||
; This internal function releases the lock for the global list.
|
||||
unlock_timer_list:
|
||||
dec [timer_list_numlocks]
|
||||
jnz .nothing
|
||||
mov [timer_list_owner], 0
|
||||
.nothing:
|
||||
ret
|
||||
|
||||
; This function adds a timer.
|
||||
; If deltaStart is nonzero, the timer is activated after deltaStart hundredths
|
||||
; of seconds starting from the current time. If interval is nonzero, the timer
|
||||
; is activated every deltaWork hundredths of seconds starting from the first
|
||||
; activation. The activated timer calls timerFunc as stdcall function with one
|
||||
; argument userData.
|
||||
; Return value is NULL if something has failed or some value which is opaque
|
||||
; for the caller. Later this value can be used for cancel_timer_hs.
|
||||
proc timer_hs stdcall uses ebx, deltaStart:dword, interval:dword, \
|
||||
timerFunc:dword, userData:dword
|
||||
; 1. Allocate memory for the TIMER structure.
|
||||
; 1a. Call the allocator.
|
||||
push sizeof.TIMER
|
||||
pop eax
|
||||
call malloc
|
||||
; 1b. If allocation failed, return (go to 5) with eax = 0.
|
||||
test eax, eax
|
||||
jz .nothing
|
||||
; 2. Setup the TIMER structure.
|
||||
xchg ebx, eax
|
||||
; 2a. Copy values from the arguments.
|
||||
mov ecx, [interval]
|
||||
mov [ebx+TIMER.Interval], ecx
|
||||
mov ecx, [timerFunc]
|
||||
mov [ebx+TIMER.TimerFunc], ecx
|
||||
mov ecx, [userData]
|
||||
mov [ebx+TIMER.UserData], ecx
|
||||
; 2b. Get time of the next activation.
|
||||
mov ecx, [deltaStart]
|
||||
test ecx, ecx
|
||||
jnz @f
|
||||
mov ecx, [interval]
|
||||
@@:
|
||||
add ecx, [timer_ticks]
|
||||
mov [ebx+TIMER.Time], ecx
|
||||
; 3. Insert the TIMER structure to the global list.
|
||||
; 3a. Acquire the lock.
|
||||
call lock_timer_list
|
||||
; 3b. Insert an item at ebx to the tail of the timer_list.
|
||||
mov eax, timer_list
|
||||
mov ecx, [eax+TIMER.Prev]
|
||||
mov [ebx+TIMER.Next], eax
|
||||
mov [ebx+TIMER.Prev], ecx
|
||||
mov [eax+TIMER.Prev], ebx
|
||||
mov [ecx+TIMER.Next], ebx
|
||||
; 3c. Release the lock.
|
||||
call unlock_timer_list
|
||||
; 4. Return with eax = pointer to TIMER structure.
|
||||
xchg ebx, eax
|
||||
.nothing:
|
||||
; 5. Returning.
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function removes a timer.
|
||||
; The only argument is [esp+4] = the value which was returned from timer_hs.
|
||||
cancel_timer_hs:
|
||||
push ebx ; save used register to be stdcall
|
||||
; 1. Remove the TIMER structure from the global list.
|
||||
; 1a. Acquire the lock.
|
||||
call lock_timer_list
|
||||
mov ebx, [esp+4+4]
|
||||
; 1b. Delete an item at ebx from the double-linked list.
|
||||
mov eax, [ebx+TIMER.Next]
|
||||
mov ecx, [ebx+TIMER.Prev]
|
||||
mov [eax+TIMER.Prev], ecx
|
||||
mov [ecx+TIMER.Next], eax
|
||||
; 1c. If we are removing the next timer in currently processing chain,
|
||||
; the next timer for this timer becomes new next timer.
|
||||
cmp ebx, [timer_next]
|
||||
jnz @f
|
||||
mov [timer_next], eax
|
||||
@@:
|
||||
; 1d. Release the lock.
|
||||
call unlock_timer_list
|
||||
; 2. Free the TIMER structure.
|
||||
xchg eax, ebx
|
||||
call free
|
||||
; 3. Return.
|
||||
pop ebx ; restore used register to be stdcall
|
||||
ret 4 ; purge one dword argument to be stdcall
|
||||
|
||||
; This function is regularly called from osloop. It processes the global list
|
||||
; and activates the corresponding timers.
|
||||
check_timers:
|
||||
; 1. Acquire the lock.
|
||||
call lock_timer_list
|
||||
; 2. Loop over all registered timers, checking time.
|
||||
; 2a. Get the first item.
|
||||
mov eax, [timer_list+TIMER.Next]
|
||||
mov [timer_next], eax
|
||||
.loop:
|
||||
; 2b. Check for end of list.
|
||||
cmp eax, timer_list
|
||||
jz .done
|
||||
; 2c. Get and store the next timer.
|
||||
mov edx, [eax+TIMER.Next]
|
||||
mov [timer_next], edx
|
||||
; 2d. Check time for timer activation.
|
||||
; We can't just compare [timer_ticks] and [TIMER.Time], since overflows are
|
||||
; possible: if the current time is 0FFFFFFFFh ticks and timer should be
|
||||
; activated in 3 ticks, the simple comparison will produce incorrect result.
|
||||
; So we calculate the difference [timer_ticks] - [TIMER.Time]; if it is
|
||||
; non-negative, the time is over; if it is negative, then either the time is
|
||||
; not over or we have not processed this timer for 2^31 ticks, what is very
|
||||
; unlikely.
|
||||
mov edx, [timer_ticks]
|
||||
sub edx, [eax+TIMER.Time]
|
||||
js .next
|
||||
; The timer should be activated now.
|
||||
; 2e. Store the timer data in the stack. This is required since 2f can delete
|
||||
; the timer, invalidating the content.
|
||||
push [eax+TIMER.UserData] ; parameter for TimerFunc
|
||||
push [eax+TIMER.TimerFunc] ; to be restored in 2g
|
||||
; 2f. Calculate time of next activation or delete the timer if it is one-shot.
|
||||
mov ecx, [eax+TIMER.Interval]
|
||||
add [eax+TIMER.Time], ecx
|
||||
test ecx, ecx
|
||||
jnz .nodelete
|
||||
stdcall cancel_timer_hs, eax
|
||||
.nodelete:
|
||||
; 2g. Activate timer, using data from the stack.
|
||||
pop eax
|
||||
call eax
|
||||
.next:
|
||||
; 2h. Advance to the next timer and continue the loop.
|
||||
mov eax, [timer_next]
|
||||
jmp .loop
|
||||
.done:
|
||||
; 3. Release the lock.
|
||||
call unlock_timer_list
|
||||
; 4. Return.
|
||||
ret
|
@@ -91,10 +91,10 @@ v86_create:
|
||||
; now V86 specific: initialize known addresses in first Mb
|
||||
pop eax
|
||||
; first page - BIOS data (shared between all machines!)
|
||||
; 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
|
||||
; physical address = 0
|
||||
; linear address = OS_BASE
|
||||
mov dword [eax], 111b
|
||||
mov dword [eax+800h], OS_BASE
|
||||
; page before 0xA0000 - Extended BIOS Data Area (shared between all machines!)
|
||||
; physical address = 0x9C000
|
||||
; linear address = 0x8009C000
|
||||
@@ -219,12 +219,12 @@ init_sys_v86:
|
||||
mov [sys_v86_machine], eax
|
||||
test eax, eax
|
||||
jz .ret
|
||||
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 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 esi, eax
|
||||
mov ebx, [eax+V86_machine.pagedir]
|
||||
; one page for stack, two pages for results (0x2000 bytes = 16 sectors)
|
||||
@@ -328,7 +328,7 @@ v86_start:
|
||||
cmp edx, -1
|
||||
jz .noirqhook
|
||||
uglobal
|
||||
v86_irqhooks rd 16*2
|
||||
v86_irqhooks rd IRQ_RESERVED * 2
|
||||
endg
|
||||
cmp [v86_irqhooks+edx*8], 0
|
||||
jz @f
|
||||
@@ -371,7 +371,8 @@ v86_exc_c:
|
||||
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
|
||||
@@ -805,7 +806,6 @@ end if
|
||||
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,16 +839,17 @@ end if
|
||||
; mov byte [BOOT_VAR + 48Eh], 0FFh
|
||||
; ret
|
||||
|
||||
align 4
|
||||
v86_irq:
|
||||
; push irq/pushad/jmp v86_irq
|
||||
; eax = irq
|
||||
; ebp = irq
|
||||
lea esi, [esp+1Ch]
|
||||
lea edi, [esi+4]
|
||||
mov ecx, 8
|
||||
std
|
||||
rep movsd
|
||||
cld
|
||||
mov edi, eax
|
||||
mov edi, ebp
|
||||
pop eax
|
||||
v86_irq2:
|
||||
mov esi, [v86_irqhooks+edi*8] ; get VM handle
|
||||
@@ -898,12 +899,8 @@ v86_irq2:
|
||||
pop ecx
|
||||
.cont:
|
||||
loop .scan
|
||||
mov al, 20h
|
||||
out 20h, al
|
||||
cmp edi, 8
|
||||
jb @f
|
||||
out 0A0h, al
|
||||
@@:
|
||||
mov ecx, edi
|
||||
call irq_eoi
|
||||
popad
|
||||
iretd
|
||||
.found:
|
||||
|
@@ -12,7 +12,8 @@ flm db 0
|
||||
preboot_lfb db 0
|
||||
preboot_bootlog db 0
|
||||
boot_drive db 0
|
||||
bx_from_load: dw 'r1' ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> bx ; {SPraid}[13.03.2007]
|
||||
bx_from_load:
|
||||
dw 'r1' ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> bx ; {SPraid}[13.03.2007]
|
||||
; a,b,c,d - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, r - <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
; # <20><><EFBFBD><EFBFBD><EFBFBD>... <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><> <20><><EFBFBD><EFBFBD>. '1', <20> <20><> 1
|
||||
|
||||
@@ -22,10 +23,12 @@ old_ints_h:
|
||||
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
|
||||
@@ -53,3 +56,36 @@ fwmovedesc:
|
||||
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
|
||||
|
@@ -47,20 +47,43 @@ keymap_alt:
|
||||
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
|
||||
|
||||
boot_memdetect db 'Determining amount of memory',0
|
||||
|
||||
if lang eq ru
|
||||
boot_fonts db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㦥<EFBFBD><E3A6A5>',0
|
||||
boot_memdetect db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⢮ <20><><EFBFBD><EFBFBD><EFBFBD>⨢<EFBFBD><E2A8A2><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',' ',' <20><>',0
|
||||
boot_tss db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> TSSs',0
|
||||
boot_cpuid db '<27>⥭<EFBFBD><E2A5AD> CPUIDs',0
|
||||
boot_devices db '<27><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ன<EFBFBD><E0AEA9><EFBFBD>',0
|
||||
boot_timer db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> ⠩<><E2A0A9><EFBFBD><EFBFBD>',0
|
||||
boot_irqs db '<27><>८<EFBFBD>।<EFBFBD><E0A5A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IRQ',0
|
||||
boot_setmouse db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>',0
|
||||
boot_windefs db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> 㬮<>砭<EFBFBD><E7A0AD>',0
|
||||
boot_bgr db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> 䮭<>',0
|
||||
boot_resirqports db '<27><><EFBFBD><EFBFBD>ࢨ<E0A2A8><E0AEA2><EFBFBD><EFBFBD> IRQ <20> <20><><EFBFBD>⮢',0
|
||||
boot_setrports db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ᮢ IRQ',0
|
||||
boot_setostask db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>',0
|
||||
boot_allirqs db '<27><><EFBFBD><EFBFBD><EFBFBD>⨥ <20><><EFBFBD><EFBFBD> IRQ',0
|
||||
boot_tsc db '<27>⥭<EFBFBD><E2A5AD> TSC',0
|
||||
boot_cpufreq db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ',' ',' <20><><EFBFBD>',0
|
||||
boot_pal_ega db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> EGA/CGA 320x200 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0
|
||||
boot_pal_vga db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> VGA 640x480 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0
|
||||
boot_failed db '<27><><EFBFBD><EFBFBD>㧪<EFBFBD> <20><>ࢮ<EFBFBD><E0A2AE> <20>ਫ<EFBFBD><E0A8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 㤠<><E3A4A0><EFBFBD><EFBFBD>',0
|
||||
boot_mtrr db '<27><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD> MTRR',0
|
||||
if preboot_blogesc
|
||||
boot_tasking db '<27><><EFBFBD> <20><>⮢<EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>᪠, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ESC <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0
|
||||
end if
|
||||
else
|
||||
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 all IRQs',0
|
||||
boot_allirqs db 'Unmasking 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
|
||||
@@ -70,6 +93,10 @@ keymap_alt:
|
||||
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
|
||||
@@ -101,6 +128,12 @@ szIMPORTS db 'IMPORTS',0
|
||||
|
||||
read_firstapp db '/sys/'
|
||||
firstapp db 'LAUNCHER',0
|
||||
notifyapp db '@notify',0
|
||||
if lang eq ru
|
||||
ud_user_message db '<27>訡<EFBFBD><E8A8A1>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ন<EFBFBD><E0A6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',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
|
||||
@@ -108,9 +141,10 @@ char2 db '/sys/FONTS/CHAR2.MT',0
|
||||
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
|
||||
|
||||
@@ -259,51 +293,23 @@ gdte:
|
||||
|
||||
align 16
|
||||
cur_saved_data rb 4096
|
||||
fpu_data: rb 512
|
||||
fpu_data:
|
||||
rb 512
|
||||
|
||||
; device irq owners
|
||||
irq_owner rd 16 ; process id
|
||||
mem_block_list rd 64*2
|
||||
mem_used_list rd 64*2
|
||||
mem_hash_cnt rd 64
|
||||
|
||||
; 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_mutex MUTEX
|
||||
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
|
||||
@@ -368,6 +374,7 @@ cdid rd 1
|
||||
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
|
||||
|
||||
|
@@ -28,3 +28,10 @@ wait_cmos:
|
||||
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
|
||||
@@:
|
||||
|
||||
|
@@ -124,7 +124,8 @@ ReadHDD_ID:
|
||||
ret
|
||||
@@Error6:
|
||||
mov [DevErrorCode], 6
|
||||
@@End: ret
|
||||
@@End:
|
||||
ret
|
||||
|
||||
|
||||
iglobal
|
||||
@@ -258,15 +259,20 @@ SendCommandToHDD:
|
||||
mov [DevErrorCode], 0
|
||||
ret
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@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
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ret
|
||||
|
||||
@@ -373,11 +379,14 @@ DeviceReset:
|
||||
mov [DevErrorCode], 0
|
||||
ret
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@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
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
ret
|
||||
|
||||
|
@@ -20,15 +20,20 @@ $Revision$
|
||||
mov [hdbase], 0x1f0
|
||||
mov [hdid], 0x0
|
||||
mov [hdpos], 1
|
||||
mov [fat32part],1
|
||||
mov [known_part], 1
|
||||
search_partitions_ide0_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide1
|
||||
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
|
||||
inc byte [DRIVE_DATA+2]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress], 100
|
||||
inc [fat32part]
|
||||
@@:
|
||||
inc [known_part]
|
||||
jmp search_partitions_ide0_1
|
||||
|
||||
search_partitions_ide1:
|
||||
@@ -37,15 +42,20 @@ $Revision$
|
||||
mov [hdbase], 0x1f0
|
||||
mov [hdid], 0x10
|
||||
mov [hdpos], 2
|
||||
mov [fat32part],1
|
||||
mov [known_part], 1
|
||||
search_partitions_ide1_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide2
|
||||
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
|
||||
inc byte [DRIVE_DATA+3]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress], 100
|
||||
inc [fat32part]
|
||||
@@:
|
||||
inc [known_part]
|
||||
jmp search_partitions_ide1_1
|
||||
|
||||
search_partitions_ide2:
|
||||
@@ -54,15 +64,20 @@ $Revision$
|
||||
mov [hdbase], 0x170
|
||||
mov [hdid], 0x0
|
||||
mov [hdpos], 3
|
||||
mov [fat32part],1
|
||||
mov [known_part], 1
|
||||
search_partitions_ide2_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne search_partitions_ide3
|
||||
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
|
||||
inc byte [DRIVE_DATA+4]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress], 100
|
||||
inc [fat32part]
|
||||
@@:
|
||||
inc [known_part]
|
||||
jmp search_partitions_ide2_1
|
||||
|
||||
search_partitions_ide3:
|
||||
@@ -71,15 +86,20 @@ $Revision$
|
||||
mov [hdbase], 0x170
|
||||
mov [hdid], 0x10
|
||||
mov [hdpos], 4
|
||||
mov [fat32part],1
|
||||
mov [known_part], 1
|
||||
search_partitions_ide3_1:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition],0
|
||||
jne end_search_partitions_ide
|
||||
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
|
||||
inc byte [DRIVE_DATA+5]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress], 100
|
||||
inc [fat32part]
|
||||
@@:
|
||||
inc [known_part]
|
||||
jmp search_partitions_ide3_1
|
||||
|
||||
end_search_partitions_ide:
|
||||
@@ -91,16 +111,21 @@ start_search_partitions_bd:
|
||||
push ecx
|
||||
mov eax, [hdpos]
|
||||
and [BiosDiskPartitions+(eax-80h)*4], 0
|
||||
mov [fat32part], 1
|
||||
mov [known_part], 1
|
||||
search_partitions_bd:
|
||||
call set_FAT32_variables
|
||||
cmp [problem_partition], 0
|
||||
jne end_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
|
||||
mov eax, [hdpos]
|
||||
inc [BiosDiskPartitions+(eax-80h)*4]
|
||||
call partition_data_transfer
|
||||
add [transfer_adress], 100
|
||||
inc [fat32part]
|
||||
@@:
|
||||
inc [known_part]
|
||||
jmp search_partitions_bd
|
||||
end_search_partitions_bd:
|
||||
pop ecx
|
||||
@@ -110,7 +135,7 @@ end_search_partitions_bd:
|
||||
|
||||
partition_data_transfer:
|
||||
mov edi, [transfer_adress]
|
||||
mov esi,PARTITION_START
|
||||
mov esi, PARTITION_START ;start of file_system_data
|
||||
mov ecx, (file_system_data_size+3)/4
|
||||
rep movsd
|
||||
ret
|
||||
@@ -130,24 +155,3 @@ partition_data_transfer_1:
|
||||
|
||||
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
|
||||
|
||||
|
@@ -62,13 +62,11 @@ macro DEBUGS_N _sign,_num,[_str] {
|
||||
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
|
||||
@@ -254,7 +252,8 @@ debug_endf
|
||||
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
|
||||
@@ -263,7 +262,8 @@ debug_beginf
|
||||
call ecx ; sys_msg_board
|
||||
inc edx
|
||||
jmp .l1
|
||||
.l2: ret
|
||||
.l2:
|
||||
ret
|
||||
debug_endf
|
||||
|
||||
debug_func fdo_debug_outdec
|
||||
@@ -277,20 +277,24 @@ debug_beginf
|
||||
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
|
||||
@@ -301,7 +305,8 @@ debug_beginf
|
||||
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]
|
||||
|
1318
kernel/branches/net/fs/ext2.inc
Normal file
1318
kernel/branches/net/fs/ext2.inc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -60,6 +60,7 @@ ERROR_MEMORY_POINTER = 7
|
||||
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]
|
||||
@@ -93,10 +94,13 @@ endg
|
||||
|
||||
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
|
||||
@@ -1049,6 +1053,8 @@ fs_HdRead:
|
||||
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
|
||||
@@ -1200,6 +1206,8 @@ fs_HdRead:
|
||||
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
|
||||
@@ -1586,6 +1594,8 @@ fs_HdRewrite:
|
||||
.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
|
||||
@@ -2120,6 +2130,8 @@ fs_HdWrite.ret11:
|
||||
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
|
||||
@@ -2336,7 +2348,8 @@ fs_HdWrite:
|
||||
sub dword [esp], 0x200
|
||||
jae @f
|
||||
and dword [esp], 0
|
||||
@@: jmp .write_loop
|
||||
@@:
|
||||
jmp .write_loop
|
||||
|
||||
hd_extend_file.zero_size:
|
||||
xor eax, eax
|
||||
@@ -2445,7 +2458,8 @@ hd_extend_file:
|
||||
cmp [hd_error], 0
|
||||
jz @f
|
||||
mov al, 11
|
||||
@@: stc
|
||||
@@:
|
||||
stc
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------
|
||||
@@ -2463,6 +2477,8 @@ hd_extend_file:
|
||||
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
|
||||
@@ -2695,6 +2711,8 @@ fs_HdSetFileEnd:
|
||||
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
|
||||
@@ -2723,6 +2741,8 @@ fs_HdGetFileInfo:
|
||||
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
|
||||
@@ -2773,6 +2793,8 @@ fs_HdSetFileInfo:
|
||||
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
|
||||
|
@@ -21,12 +21,14 @@ $Revision$
|
||||
|
||||
|
||||
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 '
|
||||
@@ -34,7 +36,8 @@ dir1: db 'FIRST '
|
||||
|
||||
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
|
||||
|
||||
@@ -388,7 +391,7 @@ choice_necessity_partition_1:
|
||||
.s:
|
||||
sub eax, ebx
|
||||
.f:
|
||||
add eax,[fat32part]
|
||||
add eax, [known_part]; add eax,[fat32part]
|
||||
dec eax
|
||||
xor edx, edx
|
||||
imul eax, 100
|
||||
@@ -793,5 +796,6 @@ error:
|
||||
stc
|
||||
jmp i4
|
||||
|
||||
partition_string: dd 0
|
||||
partition_string:
|
||||
dd 0
|
||||
db 32
|
||||
|
@@ -8,8 +8,8 @@
|
||||
$Revision$
|
||||
|
||||
|
||||
image_of_eax EQU esp+36
|
||||
image_of_ebx EQU esp+24
|
||||
image_of_eax EQU esp+32
|
||||
image_of_ebx EQU esp+20
|
||||
|
||||
; System function 70 - files with long names (LFN)
|
||||
; diamond, 2006
|
||||
@@ -85,13 +85,13 @@ virtual_root_query:
|
||||
|
||||
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: eax->fileinfo block
|
||||
; in: ebx->fileinfo block
|
||||
; operation codes:
|
||||
; 0 : read file
|
||||
; 1 : read folder
|
||||
@@ -105,7 +105,6 @@ file_system_lfn:
|
||||
; 9 : create directory
|
||||
|
||||
; parse file name
|
||||
xchg ebx, eax
|
||||
lea esi, [ebx+20]
|
||||
lodsb
|
||||
test al, al
|
||||
@@ -169,8 +168,8 @@ file_system_lfn:
|
||||
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
|
||||
@@ -385,7 +384,8 @@ file_system_lfn:
|
||||
.notfounda:
|
||||
cmp edi, esp
|
||||
jnz .notfound
|
||||
add esp, 8
|
||||
call dword [edi+4]
|
||||
add esp, 16
|
||||
jmp .notfound
|
||||
|
||||
.found1:
|
||||
@@ -537,7 +537,7 @@ fs_OnHdAndBd:
|
||||
mov dword [image_of_eax], 5 ; not found
|
||||
ret
|
||||
@@:
|
||||
mov [fat32part], ecx
|
||||
mov [known_part], ecx ; mov [fat32part], ecx
|
||||
push ebx esi
|
||||
call choice_necessity_partition_1
|
||||
pop esi ebx
|
||||
@@ -852,6 +852,8 @@ biosdisk_handler:
|
||||
jmp file_system_lfn.maindir_noesi
|
||||
@@:
|
||||
push ecx
|
||||
push ecx
|
||||
push biosdisk_cleanup
|
||||
push fs_OnBd
|
||||
mov edi, esp
|
||||
jmp file_system_lfn.found2
|
||||
@@ -860,10 +862,11 @@ fs_BdNext:
|
||||
cmp eax, [BiosDiskPartitions+ecx*4]
|
||||
inc eax
|
||||
cmc
|
||||
biosdisk_cleanup:
|
||||
ret
|
||||
|
||||
fs_OnBd:
|
||||
pop edx edx
|
||||
pop edx edx edx edx
|
||||
; edx = disk number, ecx = partition number
|
||||
; esi+ebp = name
|
||||
call reserve_hd1
|
||||
@@ -904,7 +907,7 @@ biosdisk_enum_root:
|
||||
xor eax, eax
|
||||
ret
|
||||
.big:
|
||||
push ecx
|
||||
push ecx edx
|
||||
push -'0'
|
||||
mov ecx, 10
|
||||
@@:
|
||||
@@ -919,7 +922,7 @@ biosdisk_enum_root:
|
||||
add al, '0'
|
||||
stosb
|
||||
jnz @b
|
||||
pop ecx
|
||||
pop edx ecx
|
||||
pop eax
|
||||
inc eax
|
||||
ret
|
||||
@@ -1015,9 +1018,11 @@ max_cur_dir equ 0x1000
|
||||
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:
|
||||
|
@@ -5,7 +5,7 @@
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision:1322 $
|
||||
$Revision$
|
||||
|
||||
|
||||
uglobal
|
||||
@@ -54,12 +54,14 @@ reserve_cd_channel:
|
||||
je .reserve_ok_2
|
||||
sti
|
||||
call change_task
|
||||
jmp .IDE_Channel_1
|
||||
jmp .IDE_Channel_2
|
||||
.reserve_ok_1:
|
||||
mov [IDE_Channel_1], 1
|
||||
sti
|
||||
ret
|
||||
.reserve_ok_2:
|
||||
mov [IDE_Channel_2], 1
|
||||
sti
|
||||
ret
|
||||
|
||||
free_cd_channel:
|
||||
@@ -67,9 +69,11 @@ free_cd_channel:
|
||||
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
|
||||
|
@@ -95,8 +95,8 @@ ntfs_test_bootsec:
|
||||
|
||||
ntfs_setup: ; CODE XREF: part_set.inc
|
||||
; By given bootsector, initialize some NTFS variables
|
||||
call ntfs_test_bootsec
|
||||
jc problem_fat_dec_count
|
||||
; call ntfs_test_bootsec ; checking boot sector was already
|
||||
; jc problem_fat_dec_count
|
||||
movzx eax, byte [ebx+13]
|
||||
mov [ntfs_data.sectors_per_cluster], eax
|
||||
mov eax, [ebx+0x28]
|
||||
@@ -942,6 +942,18 @@ ntfs_decode_mcb_entry:
|
||||
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
|
||||
@@ -1030,15 +1042,15 @@ ntfs_find_lfn:
|
||||
push edi
|
||||
@@:
|
||||
lodsw
|
||||
call uni2ansi_char
|
||||
call char_toupper
|
||||
call unichar_toupper
|
||||
push eax
|
||||
mov al, [edi]
|
||||
inc edi
|
||||
cmp al, '/'
|
||||
jz .slash
|
||||
call char_toupper
|
||||
cmp al, [esp]
|
||||
call ansi2uni_char
|
||||
cmp ax, [esp]
|
||||
pop eax
|
||||
loopz @b
|
||||
jz .found
|
||||
@@ -1641,6 +1653,7 @@ ntfs_datetime_to_bdfe:
|
||||
xchg eax, [esp]
|
||||
div [_10000000]
|
||||
pop edx
|
||||
.sec:
|
||||
; edx:eax = number of seconds since January 1, 1601
|
||||
push eax
|
||||
mov eax, edx
|
||||
@@ -1813,3 +1826,4 @@ ntfs_HdGetFileInfo:
|
||||
pop edi esi
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
|
@@ -9,6 +9,7 @@ $Revision$
|
||||
|
||||
|
||||
;*************************************************************
|
||||
;* 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
|
||||
@@ -26,7 +27,7 @@ align 4
|
||||
;******************************************************
|
||||
PARTITION_START dd 0x3f
|
||||
PARTITION_END dd 0
|
||||
fs_type db 0 ; 0=none, 1=NTFS, 16=FAT16, 32=FAT32
|
||||
fs_type db 0 ; 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32
|
||||
align 4
|
||||
|
||||
fs_dependent_data_start:
|
||||
@@ -54,7 +55,8 @@ fatStartScan dd 2
|
||||
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
|
||||
@@ -74,7 +76,33 @@ ntfs_data:
|
||||
.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 ? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <EFBFBD><EFBFBD><EFBFBD>楤<EFBFBD><EFBFBD><EFBFBD>
|
||||
.ext2_temp_block dd ? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>楤<EFBFBD><EFBFBD>
|
||||
.ext2_save_inode dd ? ; inode <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>楤<EFBFBD><EFBFBD><EFBFBD>
|
||||
.ext2_temp_inode dd ? ; inode <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>楤<EFBFBD><EFBFBD>
|
||||
.sb dd ? ; superblock
|
||||
.groups_count dd ?
|
||||
if $ > fs_dependent_data_end
|
||||
ERROR:
|
||||
increase sizeof(fs_dependent_data)!
|
||||
end if
|
||||
end virtual
|
||||
|
||||
@@ -105,6 +133,7 @@ iglobal
|
||||
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:
|
||||
|
||||
|
||||
@@ -118,18 +147,16 @@ iglobal
|
||||
endg
|
||||
|
||||
; Partition chain used:
|
||||
; 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
|
||||
; MBR <---------------------
|
||||
; | |
|
||||
; |-> PARTITION1 |
|
||||
; |-> EXTENDED PARTITION - ;not need be second partition
|
||||
; |-> PARTITION3
|
||||
; |-> PARTITION4
|
||||
|
||||
set_FAT32_variables:
|
||||
mov [problem_partition],0
|
||||
set_PARTITION_variables:
|
||||
set_FAT32_variables: ;deprecated
|
||||
and [problem_partition], 0
|
||||
call reserve_hd1
|
||||
call reserve_hd_channel
|
||||
|
||||
@@ -139,12 +166,12 @@ set_FAT32_variables:
|
||||
je problem_hd
|
||||
|
||||
xor ecx, ecx ; partition count
|
||||
mov edx,-1 ; flag for partition
|
||||
xor eax,eax ; read MBR
|
||||
;or edx,-1 ; flag for partition
|
||||
xor eax, eax ; address MBR
|
||||
xor ebp, ebp ; extended partition start
|
||||
|
||||
new_partition:
|
||||
test ebp,ebp ; is there extended partition?
|
||||
new_mbr:
|
||||
test ebp, ebp ; is there extended partition? (MBR or EMBR)
|
||||
jnz extended_already_set; yes
|
||||
xchg ebp, eax ; no. set it now
|
||||
|
||||
@@ -157,152 +184,163 @@ extended_already_set:
|
||||
|
||||
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
|
||||
; jz next_partition
|
||||
jnz .next_primary_partition
|
||||
jnz test_primary_partition_0
|
||||
cmp dword [ebx+0x1be+0xc+16], 0
|
||||
jnz next_primary_partition
|
||||
jnz test_primary_partition_1
|
||||
cmp dword [ebx+0x1be+0xc+16+16], 0
|
||||
jnz next_primary_partition_1
|
||||
jnz test_primary_partition_2
|
||||
cmp dword [ebx+0x1be+0xc+16+16+16], 0
|
||||
jnz next_primary_partition_2
|
||||
jmp next_partition
|
||||
jnz test_primary_partition_3
|
||||
pop eax
|
||||
jmp end_partition_chain
|
||||
|
||||
.next_primary_partition:
|
||||
push eax
|
||||
test_primary_partition_0:
|
||||
mov al, [ebx+0x1be+4]; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_primary_partition ; no. skip over
|
||||
jnz test_primary_partition_1; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_primary_partition ; no
|
||||
cmp ecx, [known_part]; is it wanted partition?
|
||||
jnz test_primary_partition_1; no
|
||||
|
||||
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
|
||||
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
|
||||
; when file system data will be available
|
||||
mov dl, [ebx+0x1be+4]
|
||||
mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS)
|
||||
pop edx
|
||||
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
|
||||
|
||||
next_primary_partition:
|
||||
push eax
|
||||
test_primary_partition_1:
|
||||
mov al, [ebx+0x1be+4+16]; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_primary_partition_1 ; no. skip over
|
||||
jnz test_primary_partition_2 ; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_primary_partition_1 ; no
|
||||
cmp ecx, [known_part]; is it wanted partition?
|
||||
jnz test_primary_partition_2 ; no
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
next_primary_partition_1:
|
||||
push eax
|
||||
;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:
|
||||
mov al, [ebx+0x1be+4+16+16]; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_primary_partition_2 ; no. skip over
|
||||
jnz test_primary_partition_3 ; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_primary_partition_2 ; no
|
||||
cmp ecx, [known_part]; is it wanted partition?
|
||||
jnz test_primary_partition_3 ; no
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
next_primary_partition_2:
|
||||
push eax
|
||||
test_primary_partition_3:
|
||||
mov al, [ebx+0x1be+4+16+16+16]; get primary partition type
|
||||
call scan_partition_types
|
||||
pop eax
|
||||
jnz next_partition ; no. skip over
|
||||
jnz test_ext_partition_0 ; no. skip over
|
||||
|
||||
inc ecx
|
||||
cmp ecx,[fat32part] ; is it wanted partition?
|
||||
jnz next_partition ; no
|
||||
cmp ecx, [known_part]; is it wanted partition?
|
||||
jnz test_ext_partition_0; no
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
next_partition:
|
||||
push eax
|
||||
;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 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>모<EFBFBD>뢠<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD>⥪<EFBFBD>
|
||||
mov al, [ebx+0x1be+4]; get extended partition type
|
||||
call scan_extended_types
|
||||
pop eax
|
||||
jnz next_partition_1
|
||||
jnz test_ext_partition_1
|
||||
|
||||
mov eax, [ebx+0x1be+8]; add relative start
|
||||
test eax, eax ; is there extended partition?
|
||||
jnz new_partition ; yes. read it
|
||||
jnz new_mbr ; yes. read it
|
||||
|
||||
next_partition_1:
|
||||
push eax
|
||||
test_ext_partition_1:
|
||||
mov al, [ebx+0x1be+4+16]; get extended partition type
|
||||
call scan_extended_types
|
||||
pop eax
|
||||
jnz next_partition_2
|
||||
jnz test_ext_partition_2
|
||||
|
||||
mov eax, [ebx+0x1be+8+16]; add relative start
|
||||
test eax, eax ; is there extended partition?
|
||||
jnz new_partition ; yes. read it
|
||||
jnz new_mbr ; yes. read it
|
||||
|
||||
next_partition_2:
|
||||
push eax
|
||||
test_ext_partition_2:
|
||||
mov al, [ebx+0x1be+4+16+16]; get extended partition type
|
||||
call scan_extended_types
|
||||
pop eax
|
||||
jnz next_partition_3
|
||||
jnz test_ext_partition_3
|
||||
|
||||
mov eax, [ebx+0x1be+8+16+16]; add relative start
|
||||
test eax, eax ; is there extended partition?
|
||||
jnz new_partition ; yes. read it
|
||||
jnz new_mbr ; yes. read it
|
||||
|
||||
next_partition_3:
|
||||
push eax
|
||||
test_ext_partition_3:
|
||||
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_partition ; yes. read it
|
||||
jnz new_mbr ; 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
|
||||
@@ -323,24 +361,31 @@ scan_extended_types:
|
||||
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:
|
||||
problem_hd:
|
||||
popad
|
||||
or [problem_partition], 1
|
||||
|
||||
mov [fs_type],0
|
||||
return_from_part_set:
|
||||
popad
|
||||
;mov [fs_type],0
|
||||
call free_hd_channel
|
||||
mov [hd1_status], 0 ; free
|
||||
mov [problem_partition],1
|
||||
ret
|
||||
|
||||
hd_and_partition_ok:
|
||||
mov eax,edx
|
||||
|
||||
;eax = PARTITION_START edx=PARTITION_LENGTH cl=fs_type
|
||||
mov [fs_type], cl
|
||||
;mov eax,edx
|
||||
mov [PARTITION_START], eax
|
||||
mov edx, [PARTITION_END]
|
||||
sub edx, eax
|
||||
inc edx ; edx = length of partition
|
||||
add edx, eax
|
||||
dec edx
|
||||
mov [PARTITION_END], edx
|
||||
|
||||
; mov edx, [PARTITION_END]
|
||||
; sub edx, eax
|
||||
; inc edx ; edx = length of partition <EFBFBD><EFBFBD>祬 <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>??
|
||||
|
||||
; mov [hd_setup],1
|
||||
mov ebx, buffer
|
||||
@@ -366,15 +411,22 @@ hd_and_partition_ok:
|
||||
add eax, [PARTITION_START]
|
||||
call hd_read
|
||||
cmp [hd_error], 0
|
||||
jnz problem_fat_dec_count ; <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>졠...
|
||||
jnz problem_fat_dec_count ; no chance...
|
||||
boot_read_ok:
|
||||
; mov [hd_setup], 0
|
||||
|
||||
; if we are running on NTFS, check bootsector
|
||||
; cmp [fs_type], 7
|
||||
; jz ntfs_setup
|
||||
call ntfs_test_bootsec
|
||||
|
||||
call ntfs_test_bootsec ; test ntfs
|
||||
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
|
||||
|
||||
@@ -479,3 +531,4 @@ fat16_partition:
|
||||
call free_hd_channel
|
||||
mov [hd1_status], 0 ; free
|
||||
ret
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
|
||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
@@ -8,14 +8,12 @@
|
||||
|
||||
$Revision$
|
||||
|
||||
|
||||
button._.MAX_BUTTONS = 4095
|
||||
|
||||
|
||||
;==============================================================================
|
||||
;///// public functions ///////////////////////////////////////////////////////
|
||||
;==============================================================================
|
||||
|
||||
button.MAX_BUTTONS = 4095
|
||||
|
||||
struc SYS_BUTTON
|
||||
{
|
||||
.pslot dw ?
|
||||
@@ -25,19 +23,13 @@ struc SYS_BUTTON
|
||||
.top dw ?
|
||||
.height dw ?
|
||||
.id_hi dw ?
|
||||
dw ?
|
||||
.sizeof:
|
||||
}
|
||||
virtual at 0
|
||||
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 //////////////////////////////////////
|
||||
@@ -66,7 +58,7 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
||||
; 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)
|
||||
@@ -139,7 +131,8 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
||||
call button._.incecx2
|
||||
|
||||
; set button height counter
|
||||
@@: mov edx, edi
|
||||
@@:
|
||||
mov edx, edi
|
||||
|
||||
.next_line:
|
||||
call button._.button_dececx
|
||||
@@ -227,6 +220,7 @@ syscall_button.remove_button:
|
||||
add esi, edi
|
||||
xor ecx, ecx
|
||||
add ecx, -SYS_BUTTON.sizeof
|
||||
add esi, SYS_BUTTON.sizeof
|
||||
|
||||
.next_button:
|
||||
dec ebx
|
||||
@@ -262,201 +256,123 @@ syscall_button.remove_button:
|
||||
|
||||
align 4
|
||||
;------------------------------------------------------------------------------
|
||||
check_buttons: ;///////////////////////////////////////////////////////////////
|
||||
sys_button_activate_handler: ;/////////////////////////////////////////////////
|
||||
;------------------------------------------------------------------------------
|
||||
;? <description>
|
||||
;------------------------------------------------------------------------------
|
||||
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed
|
||||
jnz @f
|
||||
mov [bPressedMouseXY_B], 0
|
||||
ret
|
||||
;> 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
|
||||
|
||||
@@: pushad
|
||||
xor esi, esi
|
||||
mov edi, [BTN_ADDR]
|
||||
mov edx, [edi]
|
||||
test edx, edx
|
||||
jne @f
|
||||
popad
|
||||
ret
|
||||
|
||||
;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
|
||||
|
||||
.bch:
|
||||
push esi
|
||||
push edx
|
||||
mov eax, esi
|
||||
shl eax, 4
|
||||
add eax, edi
|
||||
|
||||
; 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
|
||||
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
|
||||
call button._.negative_button
|
||||
|
||||
pushad
|
||||
push eax
|
||||
mov al, [BTN_DOWN]
|
||||
mov byte[btn_down_determ], al
|
||||
pop eax
|
||||
.exit:
|
||||
ret
|
||||
|
||||
.cbwaitmouseup:
|
||||
call checkidle
|
||||
call [draw_pointer]
|
||||
|
||||
pushad
|
||||
call stack_handler
|
||||
popad
|
||||
|
||||
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ?
|
||||
jnz .cbwaitmouseup
|
||||
popad
|
||||
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
|
||||
|
||||
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
|
||||
call button._.negative_button
|
||||
mov byte[MOUSE_BACKGROUND], 0 ; no mouse background
|
||||
mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse
|
||||
|
||||
; check coordinates
|
||||
pusha
|
||||
.exit:
|
||||
ret
|
||||
|
||||
; 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
|
||||
|
||||
movzx ebx, [eax + SYS_BUTTON.width]
|
||||
add edx, ebx
|
||||
cmp ecx, edx
|
||||
jg .no_on_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
|
||||
|
||||
movzx ebx, [eax + SYS_BUTTON.height]
|
||||
add edx, ebx
|
||||
cmp ecx, edx
|
||||
jg .no_on_button
|
||||
|
||||
popa
|
||||
|
||||
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
|
||||
|
||||
.no_on_button:
|
||||
mov byte[BTN_COUNT], 0 ; no of buttons in buffer
|
||||
|
||||
.yes_on_button:
|
||||
mov byte[MOUSE_DOWN], 0 ; mouse down -> do not draw
|
||||
popa
|
||||
pop ebx
|
||||
popa
|
||||
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
|
||||
|
||||
;==============================================================================
|
||||
;///// private functions //////////////////////////////////////////////////////
|
||||
;==============================================================================
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
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
|
||||
|
||||
mov edx, eax
|
||||
shr edx, 24
|
||||
and eax, 0x0ffffff
|
||||
|
||||
mov edi, [BTN_ADDR]
|
||||
mov ecx, [edi]
|
||||
imul esi, ecx, SYS_BUTTON.sizeof
|
||||
add esi, edi
|
||||
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 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
|
||||
|
||||
; does coordinates match?
|
||||
mov edi, dword[esi + SYS_BUTTON.left - 2]
|
||||
mov di, [esi + SYS_BUTTON.top]
|
||||
cmp ebx, edi
|
||||
jne .next_button
|
||||
|
||||
; okay, return it
|
||||
mov eax, esi
|
||||
jmp .exit
|
||||
|
||||
.not_found:
|
||||
xor eax, eax
|
||||
|
||||
.exit:
|
||||
pop edi esi edx ecx
|
||||
ret
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
button._.dececx: ;/////////////////////////////////////////////////////////////
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -465,14 +381,17 @@ button._.dececx: ;/////////////////////////////////////////////////////////////
|
||||
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
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -483,14 +402,17 @@ button._.incecx: ;/////////////////////////////////////////////////////////////
|
||||
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
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -501,14 +423,17 @@ button._.incecx2: ;////////////////////////////////////////////////////////////
|
||||
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
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -525,17 +450,21 @@ button._.button_dececx: ;//////////////////////////////////////////////////////
|
||||
jg @f
|
||||
mov al, 2
|
||||
|
||||
@@: sub cl, al
|
||||
jnc @f
|
||||
xor cl, cl
|
||||
@@: sub ch, al
|
||||
jnc @f
|
||||
xor ch, ch
|
||||
@@: rol ecx, 16
|
||||
@@:
|
||||
sub cl, al
|
||||
jnc @f
|
||||
xor cl, cl
|
||||
@@: rol ecx, 16
|
||||
@@:
|
||||
sub ch, al
|
||||
jnc @f
|
||||
xor ch, ch
|
||||
@@:
|
||||
rol ecx, 16
|
||||
sub cl, al
|
||||
jnc @f
|
||||
xor cl, cl
|
||||
@@:
|
||||
rol ecx, 16
|
||||
|
||||
pop eax
|
||||
|
||||
@@ -545,7 +474,7 @@ button._.button_dececx: ;//////////////////////////////////////////////////////
|
||||
;------------------------------------------------------------------------------
|
||||
button._.negative_button: ;////////////////////////////////////////////////////
|
||||
;------------------------------------------------------------------------------
|
||||
;? <description>
|
||||
;? Invert system button border
|
||||
;------------------------------------------------------------------------------
|
||||
; if requested, do not display button border on press.
|
||||
test ebx, 0x20000000
|
||||
|
@@ -7,6 +7,13 @@
|
||||
|
||||
$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 ?
|
||||
@@ -25,7 +32,8 @@ init_events: ;; used from kernel.asm
|
||||
mov ecx, EV_SPACE ; current - in allocated space
|
||||
mov ebx, FreeEvents ; previos - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
push ebx ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@: 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
|
||||
@@ -33,7 +41,8 @@ init_events: ;; used from kernel.asm
|
||||
pop eax ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
mov [ebx+EVENT.fd], eax
|
||||
mov [eax+EVENT.bk], ebx
|
||||
.fail: ret
|
||||
.fail:
|
||||
ret
|
||||
|
||||
EVENT_WATCHED equ 0x10000000 ;<EFBFBD><EFBFBD><EFBFBD> 28
|
||||
EVENT_SIGNALED equ 0x20000000 ;<EFBFBD><EFBFBD><EFBFBD> 29
|
||||
@@ -80,7 +89,8 @@ set_event: ;; INTERNAL use !!! don't use
|
||||
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
|
||||
@@ -108,7 +118,8 @@ RemoveEventTo: ;; INTERNAL use !!! don't use
|
||||
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
|
||||
@@ -206,9 +217,11 @@ DummyTest: ;; INTERNAL use (not returned
|
||||
jne @f
|
||||
cmp [eax+EVENT.id], ebx
|
||||
je .ret
|
||||
@@: pop eax
|
||||
@@:
|
||||
pop eax
|
||||
xor eax, eax
|
||||
.ret: ret
|
||||
.ret:
|
||||
ret
|
||||
|
||||
|
||||
align 4
|
||||
@@ -247,7 +260,8 @@ Wait_events_ex:
|
||||
mov [eax+TASKDATA.state], 5
|
||||
call change_task
|
||||
mov eax, [esi+APPDATA.wait_param]
|
||||
@@: ret
|
||||
@@:
|
||||
ret
|
||||
|
||||
align 4
|
||||
wait_event: ;; EXPORT use
|
||||
@@ -339,7 +353,8 @@ get_event_queue:
|
||||
mov eax, [ebx+APPOBJ.bk] ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO
|
||||
cmp eax, ebx ; empty ???
|
||||
je get_event_alone.ret0
|
||||
.ret: ret
|
||||
.ret:
|
||||
ret
|
||||
|
||||
align 4
|
||||
get_event_alone:
|
||||
@@ -357,8 +372,10 @@ get_event_alone:
|
||||
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
|
||||
@@ -368,11 +385,13 @@ sys_sendwindowmsg: ;; f72
|
||||
cli
|
||||
sub ecx, 2
|
||||
je .sendkey
|
||||
loop .retf
|
||||
dec ecx
|
||||
jnz .retf
|
||||
.sendbtn:
|
||||
cmp byte[BTN_COUNT], 1
|
||||
jae .result ;overflow
|
||||
inc byte[BTN_COUNT]
|
||||
shl edx, 8
|
||||
mov [BTN_BUFF], edx
|
||||
jmp .result
|
||||
.sendkey:
|
||||
@@ -384,7 +403,8 @@ sys_sendwindowmsg: ;; f72
|
||||
.result:
|
||||
setae byte[esp+32] ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: dword[esp+32]==72
|
||||
.retf: ;popfd
|
||||
.ret: ret
|
||||
.ret:
|
||||
ret
|
||||
|
||||
align 4
|
||||
sys_getevent: ;; f11
|
||||
@@ -426,10 +446,8 @@ get_event_for_app: ;; used from f10,f11,f23
|
||||
jz .no_events ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ???
|
||||
btr ecx, eax ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (eax) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
cmp eax,16
|
||||
jae .IRQ ; eax=[16..31]=retvals, events irq0..irq15
|
||||
cmp eax, 9
|
||||
jae .loop ; eax=[9..15], ignored
|
||||
jae .loop ; eax=[9..31], ignored
|
||||
cmp eax, 3
|
||||
je .loop ; eax=3, ignored
|
||||
ja .FlagAutoReset ; eax=[4..8], retvals=eax+1
|
||||
@@ -442,17 +460,18 @@ get_event_for_app: ;; used from f10,f11,f23
|
||||
.no_events:
|
||||
xor eax, eax
|
||||
ret
|
||||
.IRQ:
|
||||
;TODO: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD> 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
|
||||
@@ -467,7 +486,9 @@ get_event_for_app: ;; used from f10,f11,f23
|
||||
je .loop ; empty ???
|
||||
cmp edx, [TASK_COUNT]
|
||||
jne .loop ; not Top ???
|
||||
cmp dword[BTN_BUFF],0xFFFF ;-ID for Minimize-Button of Form
|
||||
mov edx, [BTN_BUFF]
|
||||
shr edx, 8
|
||||
cmp edx, 0xFFFF ;-ID for Minimize-Button of Form
|
||||
jne .result
|
||||
mov [window_minimize], 1
|
||||
dec byte[BTN_COUNT]
|
||||
@@ -477,8 +498,10 @@ get_event_for_app: ;; used from f10,f11,f23
|
||||
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
|
||||
|
@@ -1,250 +1,715 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||
;; Copyright (C) KolibriOS team 2010. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
$Revision$
|
||||
|
||||
include 'mousepointer.inc'
|
||||
|
||||
iglobal
|
||||
;==============================================================================
|
||||
;///// public functions ///////////////////////////////////////////////////////
|
||||
;==============================================================================
|
||||
|
||||
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
|
||||
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
|
||||
;------------------------------------------------------------------------------
|
||||
mouse_check_events: ;//////////////////////////////////////////////////////////
|
||||
;------------------------------------------------------------------------------
|
||||
;? Check if mouse buttons state or cursor position has changed and call
|
||||
;? appropriate handlers
|
||||
;------------------------------------------------------------------------------
|
||||
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
|
||||
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
|
||||
|
||||
; 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
|
||||
|
250
kernel/branches/net/gui/mousepointer.inc
Normal file
250
kernel/branches/net/gui/mousepointer.inc
Normal file
@@ -0,0 +1,250 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; 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: 2288 $
|
||||
|
||||
|
||||
iglobal
|
||||
|
||||
align 4
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
endg
|
@@ -68,10 +68,10 @@ ends
|
||||
|
||||
struct SKIN_BUTTONS
|
||||
type dd ?
|
||||
; pos:
|
||||
; position
|
||||
left dw ?
|
||||
top dw ?
|
||||
; size:
|
||||
; size
|
||||
width dw ?
|
||||
height dw ?
|
||||
ends
|
||||
@@ -127,7 +127,8 @@ parse_skin_data:
|
||||
|
||||
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]
|
||||
@@ -138,7 +139,8 @@ parse_skin_data:
|
||||
or ecx, ecx
|
||||
jnz @f
|
||||
mov edx, skin_inactive.left.data
|
||||
@@: jmp .next_bitmap
|
||||
@@:
|
||||
jmp .next_bitmap
|
||||
.not_left:
|
||||
dec eax
|
||||
jnz .not_oper
|
||||
@@ -150,7 +152,8 @@ parse_skin_data:
|
||||
or ecx, ecx
|
||||
jnz @f
|
||||
mov edx, skin_inactive.oper.data
|
||||
@@: jmp .next_bitmap
|
||||
@@:
|
||||
jmp .next_bitmap
|
||||
.not_oper:
|
||||
dec eax
|
||||
jnz .not_base
|
||||
@@ -160,7 +163,8 @@ parse_skin_data:
|
||||
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
|
||||
@@ -178,7 +182,8 @@ parse_skin_data:
|
||||
|
||||
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
|
||||
@@ -213,7 +218,8 @@ sys_putimage_with_check:
|
||||
or ebx, ebx
|
||||
jz @f
|
||||
call sys_putimage.forced
|
||||
@@: ret
|
||||
@@:
|
||||
ret
|
||||
|
||||
drawwindow_IV_caption:
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
|
||||
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@@ -8,8 +8,6 @@
|
||||
$Revision$
|
||||
|
||||
|
||||
;// mike.dld [
|
||||
|
||||
VKEY_LSHIFT = 0000000000000001b
|
||||
VKEY_RSHIFT = 0000000000000010b
|
||||
VKEY_LCONTROL = 0000000000000100b
|
||||
@@ -51,28 +49,32 @@ hotkey_tests dd hotkey_test0
|
||||
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]
|
||||
@@ -83,24 +85,36 @@ hotkey_do_test:
|
||||
and eax, 15
|
||||
cmp al, hotkey_tests_num
|
||||
jae .fail
|
||||
|
||||
xchg eax, edx
|
||||
and al, 3
|
||||
call [hotkey_tests + edx*4]
|
||||
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
|
||||
@@ -108,141 +122,195 @@ irq1:
|
||||
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
|
||||
@@:
|
||||
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_SHIFT ; shift on ?
|
||||
@@:
|
||||
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 ?
|
||||
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
|
||||
cmp bh, 1
|
||||
ja .nohotkey
|
||||
jb @f
|
||||
|
||||
xor eax, eax
|
||||
@@:
|
||||
mov eax, [hotkey_scancodes + eax*4]
|
||||
.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
|
||||
.hotkey_cont:
|
||||
mov eax, [eax]
|
||||
jmp .hotkey_loop
|
||||
;--------------------------------------
|
||||
.hotkey_found:
|
||||
mov eax, [eax+8]
|
||||
; put key in buffer for process in slot eax
|
||||
@@ -250,6 +318,7 @@ irq1:
|
||||
@@:
|
||||
cmp dword [edi], 0
|
||||
jz .found_free
|
||||
|
||||
add edi, 8
|
||||
cmp edi, hotkey_buffer+120*8
|
||||
jb @b
|
||||
@@ -260,43 +329,47 @@ irq1:
|
||||
movzx eax, ch
|
||||
cmp bh, 1
|
||||
jnz @f
|
||||
|
||||
xor eax, eax
|
||||
@@:
|
||||
mov [edi+4], ax
|
||||
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:
|
||||
@@ -306,26 +379,17 @@ irq1:
|
||||
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
|
||||
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
|
||||
@@ -340,4 +404,4 @@ numlock_map:
|
||||
db 0x33 ;Num 3
|
||||
db 0x30 ;Num 0
|
||||
db 0x2E ;Num .
|
||||
;..........................Part2 End................................................
|
||||
;---------------------------------------------------------------------
|
||||
|
@@ -28,7 +28,8 @@ endg
|
||||
|
||||
iglobal
|
||||
mouse_delay dd 10
|
||||
mouse_speed_factor: dd 3
|
||||
mouse_speed_factor:
|
||||
dd 3
|
||||
mouse_timer_ticks dd 0
|
||||
endg
|
||||
|
||||
@@ -292,21 +293,20 @@ __sys_disable_mouse:
|
||||
add ecx, eax
|
||||
add ecx, [_WinMapAddress]
|
||||
mov eax, [CURRENT_TASK]
|
||||
movzx ebx, byte [ecx]
|
||||
cmp eax,ebx
|
||||
cmp al, [ecx]
|
||||
je yes_mouse_disable
|
||||
movzx ebx, byte [ecx+16]
|
||||
cmp eax,ebx
|
||||
cmp al, [ecx+16]
|
||||
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
|
||||
movzx ebx, byte [ecx]
|
||||
cmp eax,ebx
|
||||
cmp al, [ecx]
|
||||
je yes_mouse_disable
|
||||
movzx ebx, byte [ecx+16]
|
||||
cmp eax,ebx
|
||||
cmp al, [ecx+16]
|
||||
je yes_mouse_disable
|
||||
jmp no_mouse_disable
|
||||
yes_mouse_disable:
|
||||
|
@@ -139,14 +139,10 @@ proc init_mem
|
||||
dec [pg_data.kernel_tables-OS_BASE]
|
||||
|
||||
mov [edx], eax
|
||||
add eax, 0x00400000
|
||||
add edx, 4
|
||||
|
||||
mov eax, 0x400000+PG_SW
|
||||
mov ecx, [tmp_page_tabs]
|
||||
sub ecx, 0x400000
|
||||
shr ecx, 12 ;ecx/=4096
|
||||
jmp .map_low
|
||||
mov edi, [tmp_page_tabs]
|
||||
jmp .map_kernel_heap ; new kernel fits to the first 4Mb - nothing to do with ".map_low"
|
||||
.no_PSE:
|
||||
mov eax, PG_SW
|
||||
mov ecx, [tmp_page_tabs]
|
||||
@@ -159,6 +155,7 @@ proc init_mem
|
||||
dec ecx
|
||||
jnz @B
|
||||
|
||||
.map_kernel_heap:
|
||||
mov ecx, [pg_data.kernel_tables-OS_BASE]
|
||||
shl ecx, 10
|
||||
xor eax, eax
|
||||
@@ -170,7 +167,6 @@ proc init_mem
|
||||
mov edi, edx
|
||||
|
||||
.map_kernel_tabs:
|
||||
|
||||
stosd
|
||||
add eax, 0x1000
|
||||
dec ecx
|
||||
@@ -270,7 +266,6 @@ proc init_page_map
|
||||
add ebx, [pg_data.pagemap_size-OS_BASE]
|
||||
mov [page_end-OS_BASE], ebx
|
||||
|
||||
mov [pg_data.pg_mutex-OS_BASE], 0
|
||||
ret
|
||||
endp
|
||||
|
||||
@@ -293,7 +288,8 @@ init_BIOS32:
|
||||
mov esi, edi
|
||||
xor eax, eax
|
||||
cld ; paranoia
|
||||
@@: lodsb
|
||||
@@:
|
||||
lodsb
|
||||
add ah, al
|
||||
loop @b
|
||||
jnz .pcibios_nxt2; control summ must be zero
|
||||
@@ -436,3 +432,123 @@ proc test_cpu
|
||||
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
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,58 +15,31 @@
|
||||
|
||||
$Revision$
|
||||
|
||||
struct POINT
|
||||
x dd ?
|
||||
y 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 RECT
|
||||
left dd ?
|
||||
top dd ?
|
||||
right dd ?
|
||||
bottom dd ?
|
||||
ends
|
||||
|
||||
struc RECT {
|
||||
.left dd ?
|
||||
.top dd ?
|
||||
.right dd ?
|
||||
.bottom dd ?
|
||||
}
|
||||
virtual at 0
|
||||
RECT RECT
|
||||
end virtual
|
||||
struct BOX
|
||||
left dd ?
|
||||
top dd ?
|
||||
width dd ?
|
||||
height dd ?
|
||||
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
|
||||
}
|
||||
struct DISPMODE
|
||||
width dw ?
|
||||
height dw ?
|
||||
bpp dw ?
|
||||
freq dw ?
|
||||
ends
|
||||
|
||||
; constants definition
|
||||
WSTATE_NORMAL = 00000000b
|
||||
@@ -80,24 +53,20 @@ WSTATE_WNDDRAWN = 00000010b
|
||||
WSTYLE_HASCAPTION = 00010000b
|
||||
WSTYLE_CLIENTRELATIVE = 00100000b
|
||||
|
||||
struc TASKDATA
|
||||
{
|
||||
.event_mask dd ?
|
||||
.pid dd ?
|
||||
struct 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 ?
|
||||
}
|
||||
virtual at 0
|
||||
TASKDATA TASKDATA
|
||||
end virtual
|
||||
mem_start dd ?
|
||||
counter_sum dd ?
|
||||
counter_add dd ?
|
||||
cpu_usage dd ?
|
||||
ends
|
||||
|
||||
TSTATE_RUNNING = 0
|
||||
TSTATE_RUN_SUSPENDED = 1
|
||||
@@ -108,81 +77,86 @@ TSTATE_WAITING = 5
|
||||
TSTATE_FREE = 9
|
||||
|
||||
; structures definition
|
||||
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
|
||||
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
|
||||
|
||||
label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3
|
||||
|
||||
struc APPDATA
|
||||
{
|
||||
.app_name db 11 dup(?)
|
||||
db 5 dup(?)
|
||||
struct DBG_REGS
|
||||
dr0 dd ?
|
||||
dr1 dd ?
|
||||
dr2 dd ?
|
||||
dr3 dd ?
|
||||
dr7 dd ?
|
||||
ends
|
||||
|
||||
.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
|
||||
struct APPDATA
|
||||
app_name rb 11
|
||||
rb 5
|
||||
|
||||
.wnd_shape dd ? ;+128
|
||||
.wnd_shape_scale dd ? ;+132
|
||||
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
|
||||
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 ?
|
||||
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
|
||||
keyboard_mode db ?
|
||||
rb 3
|
||||
dir_table dd ?
|
||||
dbg_event_mem dd ?
|
||||
dbg_regs DBG_REGS
|
||||
wnd_caption dd ?
|
||||
wnd_clientbox BOX
|
||||
|
||||
ends
|
||||
|
||||
|
||||
|
||||
|
||||
;// mike.dld, 2006-29-01 ]
|
||||
|
||||
struct MUTEX
|
||||
lhead LHEAD
|
||||
count dd ?
|
||||
ends
|
||||
|
||||
|
||||
; Core functions
|
||||
include "core/sync.inc" ; macros for synhronization objects
|
||||
@@ -199,6 +173,9 @@ include "core/peload.inc" ;
|
||||
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"
|
||||
@@ -210,6 +187,8 @@ include "gui/button.inc"
|
||||
|
||||
; 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
|
||||
@@ -217,6 +196,7 @@ include "fs/fat12.inc" ; read / write for fat12 filesystem
|
||||
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
|
||||
|
||||
@@ -226,6 +206,7 @@ include "sound/playnote.inc" ; player Note for Speaker PC
|
||||
|
||||
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
|
||||
|
||||
|
@@ -11,6 +11,9 @@ macro $Revision a {
|
||||
|
||||
$Revision$
|
||||
|
||||
|
||||
;// mike.dld, 2006-29-01 [
|
||||
|
||||
; macros definition
|
||||
macro diff16 title,l1,l2
|
||||
{
|
||||
@@ -80,45 +83,31 @@ macro Mov op1,op2,op3 ; op1 = op2 = op3
|
||||
mov op1, op2
|
||||
}
|
||||
|
||||
|
||||
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, prev, next
|
||||
{
|
||||
mov [next+LHEAD.prev], new
|
||||
mov [new+LHEAD.next], next
|
||||
mov [new+LHEAD.prev], prev
|
||||
mov [prev+LHEAD.next], new
|
||||
}
|
||||
|
||||
cmovne fix cmovnz
|
||||
macro cmovnz reg1, reg2 {
|
||||
|
||||
local .jumpaddr
|
||||
|
||||
jz .jumpaddr
|
||||
mov reg1, reg2
|
||||
.jumpaddr:
|
||||
macro list_add new, head
|
||||
{
|
||||
mov eax, [head+LHEAD.next]
|
||||
__list_add new, head, eax
|
||||
}
|
||||
|
||||
macro cmovg reg1, reg2 {
|
||||
|
||||
local .jumpaddr
|
||||
|
||||
jle .jumpaddr
|
||||
mov reg1, reg2
|
||||
.jumpaddr:
|
||||
macro list_add_tail new, head
|
||||
{
|
||||
mov eax, [head+LHEAD.prev]
|
||||
__list_add new, eax, head
|
||||
}
|
||||
|
||||
macro cmovl reg1, reg2 {
|
||||
|
||||
local .jumpaddr
|
||||
|
||||
jge .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
|
||||
}
|
||||
|
||||
end if
|
||||
|
@@ -62,33 +62,36 @@
|
||||
; 3c dword cpu usage in cpu timer tics
|
||||
;
|
||||
;
|
||||
; 5000 -> 68FF free
|
||||
; 6900 -> 6EFF saved picture under mouse pointer
|
||||
; 5000 -> 68FF free (6k6)
|
||||
; 6900 -> 6EFF saved picture under mouse pointer (1k5)
|
||||
;
|
||||
; 6F00 -> 6FFF free
|
||||
; 6F00 -> 6FFF free (256)
|
||||
;
|
||||
; 7000 -> 7FFF used CD driver
|
||||
;
|
||||
; 8000 -> A3FF used FLOPPY driver
|
||||
;
|
||||
; A400 -> B0FF free
|
||||
; A400 -> B0FF free (3k3), unused ACTIVE_PROC_STACK
|
||||
|
||||
; B100 -> B307 IDT for int_0x00..int_0x40
|
||||
|
||||
; B308 -> BFFF free
|
||||
; B308 -> BFFF free (3k3)
|
||||
|
||||
; 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
|
||||
; D400 -> DFFF free (3k)
|
||||
; 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
|
||||
@@ -96,8 +99,13 @@
|
||||
; F501 dword 'buffer'
|
||||
; F502 -> F5FF reserved for buttons
|
||||
; F600 dword tsc / second
|
||||
; F604 byte mouse port: 1 ps2, 2 com1, 3 com2
|
||||
; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y
|
||||
; 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
|
||||
; FB10 -> FB17 mouse color mem
|
||||
; FB21 x move
|
||||
; FB22 y move
|
||||
@@ -109,18 +117,21 @@
|
||||
; 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 dword free
|
||||
; FFF0 byte 1 = redraw background request from app
|
||||
; FFF1 byte 1 = diskette int occur
|
||||
; FF01 byte task activation request?
|
||||
; FFF0 byte >0 if redraw background request from app
|
||||
; FFF1 byte >0 if background changed
|
||||
; 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
|
||||
@@ -177,20 +188,22 @@
|
||||
; BC dword address of debug event memory
|
||||
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
|
||||
;
|
||||
; 0x80090000 -> 9FFFF tmp
|
||||
; 0x80090000 -> 9FFFF tmp (64k) - unused?
|
||||
; 0x800A0000 -> AFFFF screen access area
|
||||
; 0x800B0000 -> FFFFF bios rest in peace -area
|
||||
; 0x80100000 -> 27FFFF diskette image
|
||||
; 0x80280000 -> 281FFF ramdisk fat
|
||||
; 0x80282000 -> 283FFF floppy fat
|
||||
; 0x800B0000 -> FFFFF bios rest in peace -area (320k) ?
|
||||
; 0x80100000 -> 27FFFF diskette image (1m5)
|
||||
; 0x80280000 -> 281FFF ramdisk fat (8k)
|
||||
; 0x80282000 -> 283FFF floppy fat (8k)
|
||||
;
|
||||
; 0x80284000 -> 28BFFF HDD DMA AREA
|
||||
; 0x8028C000 -> 297FFF free (48 Kb)
|
||||
; 0x80284000 -> 28BFFF HDD DMA AREA (32k)
|
||||
; 0x8028C000 -> 297FFF free (48k)
|
||||
;
|
||||
; 0x80298000 -> 29ffff auxiliary table for background smoothing code
|
||||
; 0x80298000 -> 29ffff auxiliary table for background smoothing code (32k)
|
||||
;
|
||||
; 0x802A0000 -> 2B00ff wav device data
|
||||
; 0x802C0000 -> 2C3fff button info
|
||||
; 0x802A0000 -> 2B00ff wav device buffer (64k)
|
||||
; 0x802A0000 -> 2B00ff wav device status (256)
|
||||
; 0x802B0100 -> 2Bffff free (63k8)
|
||||
; 0x802C0000 -> 2C3fff button info (8k)
|
||||
;
|
||||
; 0000 word number of buttons
|
||||
; first button entry at 0x10
|
||||
@@ -202,9 +215,9 @@
|
||||
; +000A word y size
|
||||
; +000C word button id number : bits 16-31
|
||||
;
|
||||
; 0x802C4000 -> 2CFFFF free (48Kb)
|
||||
; 0x802C4000 -> 2CFFFF free (48k)
|
||||
;
|
||||
; 0x802D0000 -> 2DFFFF reserved port area
|
||||
; 0x802D0000 -> 2DFFFF reserved port area (64k)
|
||||
;
|
||||
; 0000 dword no of port areas reserved
|
||||
; 0010 dword process id
|
||||
@@ -212,34 +225,37 @@
|
||||
; dword end port
|
||||
; dword 0
|
||||
;
|
||||
; 0x802E0000 -> 2EFFFF irq data area
|
||||
; 0x802F0000 -> 2FFFFF low memory save
|
||||
; 0x802E0000 -> 2EFFFF irq data area (64k)
|
||||
; 0x802F0000 -> 2FFFFF low memory save (64k)
|
||||
;
|
||||
; 0x80300000 -> 31FFFF tcp memory 128 Kb
|
||||
; 0x80320000 -> 327FFF tcp memory 32 Kb
|
||||
; 0x80300000 -> 31FFFF tcp memory (128k)
|
||||
; 0x80320000 -> 327FFF tcp memory (32k)
|
||||
;
|
||||
; 0x80328000 -> 32FFFF !vrr driver 32 Kb
|
||||
; 0x80328000 -> 32FFFF !vrr driver (32k)
|
||||
|
||||
; 0x80330000 -> 377FFF skin data
|
||||
; 0x80330000 -> 377FFF skin data (32k)
|
||||
|
||||
; 0x80338000 -> 33AFFF draw data - 256 entries
|
||||
; 0x80338000 -> 338FFF draw data - 256 entries (4k)
|
||||
; 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
|
||||
|
||||
; 0x8033C000 -> 47BFFF display info
|
||||
; 0x803FFFFF <- no direct address translation beyond this point
|
||||
; =============================================================
|
||||
|
||||
; 0x8047CF80 -> 47CFFF TSS 128 bytes
|
||||
; 0x8047D000 -> 47EFFF IO map for (8192*8)=65536 ports
|
||||
|
||||
; 0x8047F000 -> 48FFFF page map max 128 Kb
|
||||
;
|
||||
; 0x805FF000 -> 5FFF80 TSS
|
||||
; 0x80600000 -> 601FFF i/o maps
|
||||
|
||||
; 0x80800000 -> kernel heap
|
||||
; 0x81FFFFFF heap min limit
|
||||
; 0x80FFFFFF 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
|
||||
|
@@ -150,6 +150,13 @@ macro ntohw reg {
|
||||
|
||||
}
|
||||
|
||||
|
||||
wait_mutex: ; stub
|
||||
inc dword [ebx]
|
||||
|
||||
ret
|
||||
|
||||
|
||||
include "queue.inc"
|
||||
|
||||
include "ethernet.inc"
|
||||
|
@@ -21,7 +21,7 @@ $Revision$
|
||||
align 4
|
||||
sound_interface:
|
||||
|
||||
cmp eax, edi ; this is subfunction #55 ?
|
||||
cmp eax, ebx ; this is subfunction #55 ?
|
||||
jne retFunc55 ; if no then return.
|
||||
|
||||
cmp byte [sound_flag], 0
|
||||
@@ -31,12 +31,12 @@ sound_interface:
|
||||
or al, al ; player is busy ?
|
||||
jnz retFunc55 ; return counter delay Note
|
||||
|
||||
mov [memAdrNote],edx
|
||||
mov [memAdrNote], esi;edx
|
||||
call get_pid
|
||||
mov [pidProcessNote], eax
|
||||
xor eax, eax ; Ok! EAX = 0
|
||||
retFunc55:
|
||||
mov [esp+36], eax ; return value EAX for application
|
||||
mov [esp+32], eax ; return value EAX for application
|
||||
ret
|
||||
|
||||
iglobal
|
||||
|
@@ -21,7 +21,7 @@ unpack:
|
||||
push eax
|
||||
add esi, 12
|
||||
and al, not 0xC0
|
||||
dec eax
|
||||
dec al
|
||||
jz .lzma
|
||||
.failed:
|
||||
pop eax
|
||||
@@ -219,7 +219,8 @@ end if
|
||||
cmp bl, 10
|
||||
jb @f
|
||||
mov al, 6
|
||||
@@: sub bl, al
|
||||
@@:
|
||||
sub bl, al
|
||||
jmp .main_loop
|
||||
.1:
|
||||
lea eax, [.IsRep*4 + ebx*4]
|
||||
|
444
kernel/branches/net/video/blitter.inc
Normal file
444
kernel/branches/net/video/blitter.inc
Normal file
@@ -0,0 +1,444 @@
|
||||
|
||||
|
||||
|
||||
struc BLITTER
|
||||
{
|
||||
.dc.xmin rd 1 ; 0
|
||||
.dc.ymin rd 1 ; 4
|
||||
.dc.xmax rd 1 ; 8
|
||||
.dc.ymax rd 1 ; 12
|
||||
|
||||
.sc:
|
||||
.sc.xmin rd 1 ; 16
|
||||
.sc.ymin rd 1 ; 20
|
||||
.sc.xmax rd 1 ; 24
|
||||
.sc.ymax rd 1 ; 28
|
||||
|
||||
.dst_x rd 1 ; 32
|
||||
.dst_y rd 1 ; 36
|
||||
.src_x rd 1 ; 40
|
||||
.src_y rd 1 ; 44
|
||||
.w rd 1 ; 48
|
||||
.h rd 1 ; 52
|
||||
|
||||
.bitmap rd 1 ; 56
|
||||
.stride rd 1 ; 60
|
||||
|
||||
}
|
||||
|
||||
virtual at 0
|
||||
BLITTER BLITTER
|
||||
end virtual
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
__L1OutCode:
|
||||
push ebx
|
||||
mov ebx, 8
|
||||
cmp edx, [eax]
|
||||
jl .L2
|
||||
xor ebx, ebx
|
||||
cmp edx, [eax+8]
|
||||
setg bl
|
||||
sal ebx, 2
|
||||
.L2:
|
||||
cmp ecx, [eax+4]
|
||||
jge .L3
|
||||
or ebx, 1
|
||||
jmp .L4
|
||||
|
||||
.L3:
|
||||
cmp ecx, [eax+12]
|
||||
jle .L4
|
||||
or ebx, 2
|
||||
.L4:
|
||||
mov eax, ebx
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
align 4
|
||||
block_clip:
|
||||
push ebp
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
sub esp, 4
|
||||
|
||||
mov ebx, eax
|
||||
mov [esp], edx
|
||||
mov ebp, ecx
|
||||
mov ecx, [ecx]
|
||||
mov edx, [edx]
|
||||
call __L1OutCode
|
||||
|
||||
mov esi, eax
|
||||
mov edx, [esp+28]
|
||||
mov ecx, [edx]
|
||||
.L21:
|
||||
mov eax, [esp+24]
|
||||
mov edx, [eax]
|
||||
mov eax, ebx
|
||||
call __L1OutCode
|
||||
|
||||
mov edi, eax
|
||||
.L20:
|
||||
mov eax, edi
|
||||
and eax, esi
|
||||
jne .L9
|
||||
cmp esi, edi
|
||||
je .L9
|
||||
test esi, esi
|
||||
jne .L10
|
||||
test edi, 1
|
||||
je .L11
|
||||
mov eax, [ebx+4]
|
||||
jmp .L25
|
||||
.L11:
|
||||
test edi, 2
|
||||
je .L13
|
||||
mov eax, [ebx+12]
|
||||
.L25:
|
||||
mov edx, [esp+28]
|
||||
jmp .L22
|
||||
.L13:
|
||||
test edi, 4
|
||||
je .L14
|
||||
mov eax, [ebx+8]
|
||||
jmp .L26
|
||||
.L14:
|
||||
and edi, 8
|
||||
je .L12
|
||||
mov eax, [ebx]
|
||||
.L26:
|
||||
mov edx, [esp+24]
|
||||
.L22:
|
||||
mov [edx], eax
|
||||
.L12:
|
||||
mov eax, [esp+28]
|
||||
mov ecx, [eax]
|
||||
jmp .L21
|
||||
.L10:
|
||||
test esi, 1
|
||||
je .L16
|
||||
mov eax, [ebx+4]
|
||||
jmp .L23
|
||||
.L16:
|
||||
test esi, 2
|
||||
je .L18
|
||||
mov eax, [ebx+12]
|
||||
.L23:
|
||||
mov [ebp+0], eax
|
||||
jmp .L17
|
||||
.L18:
|
||||
test esi, 4
|
||||
je .L19
|
||||
mov eax, [ebx+8]
|
||||
jmp .L24
|
||||
.L19:
|
||||
and esi, 8
|
||||
je .L17
|
||||
mov eax, [ebx]
|
||||
.L24:
|
||||
mov edx, [esp]
|
||||
mov [edx], eax
|
||||
.L17:
|
||||
mov ecx, [ebp+0]
|
||||
mov eax, [esp]
|
||||
mov edx, [eax]
|
||||
mov eax, ebx
|
||||
call __L1OutCode
|
||||
mov esi, eax
|
||||
jmp .L20
|
||||
.L9:
|
||||
add esp, 4
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
align 4
|
||||
blit_clip:
|
||||
|
||||
.sx0 equ 36
|
||||
.sy0 equ 32
|
||||
.sx1 equ 28
|
||||
.sy1 equ 24
|
||||
|
||||
.dx0 equ 20
|
||||
.dy0 equ 16
|
||||
.dx1 equ 12
|
||||
.dy1 equ 8
|
||||
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
sub esp, 40
|
||||
|
||||
mov ebx, ecx
|
||||
mov edx, [ecx+BLITTER.src_x]
|
||||
mov [esp+.sx0], edx
|
||||
mov eax, [ecx+BLITTER.src_y]
|
||||
mov [esp+.sy0], eax
|
||||
add edx, [ecx+BLITTER.w]
|
||||
dec edx
|
||||
mov [esp+.sx1], edx
|
||||
add eax, [ecx+BLITTER.h]
|
||||
dec eax
|
||||
mov [esp+.sy1], eax
|
||||
|
||||
lea ecx, [esp+.sy0]
|
||||
lea edx, [esp+.sx0]
|
||||
lea eax, [ebx+BLITTER.sc]
|
||||
lea esi, [esp+.sy1]
|
||||
|
||||
mov [esp+4], esi
|
||||
lea esi, [esp+.sx1]
|
||||
mov [esp], esi
|
||||
call block_clip
|
||||
|
||||
mov esi, 1
|
||||
test eax, eax
|
||||
jne .L28
|
||||
|
||||
mov edi, [esp+.sx0]
|
||||
mov edx, [ebx+BLITTER.dst_x]
|
||||
add edx, edi
|
||||
sub edx, [ebx+BLITTER.src_x]
|
||||
mov [esp+.dx0], edx
|
||||
|
||||
mov ecx, [esp+.sy0]
|
||||
mov eax, [ebx+BLITTER.dst_y]
|
||||
add eax, ecx
|
||||
sub eax, [ebx+BLITTER.src_y]
|
||||
mov [esp+.dy0], eax
|
||||
sub edx, edi
|
||||
add edx, [esp+.sx1]
|
||||
mov [esp+.dx1], edx
|
||||
|
||||
sub eax, ecx
|
||||
add eax, [esp+.sy1]
|
||||
mov [esp+.dy1], eax
|
||||
|
||||
lea ecx, [esp+.dy0]
|
||||
lea edx, [esp+.dx0]
|
||||
lea eax, [esp+.dy1]
|
||||
mov [esp+4], eax
|
||||
lea eax, [esp+.dx1]
|
||||
mov [esp], eax
|
||||
mov eax, ebx
|
||||
call block_clip
|
||||
test eax, eax
|
||||
jne .L28
|
||||
|
||||
mov edx, [esp+.dx0]
|
||||
mov eax, [esp+.dx1]
|
||||
inc eax
|
||||
sub eax, edx
|
||||
mov [ebx+BLITTER.w], eax
|
||||
|
||||
mov eax, [esp+.dy0]
|
||||
mov ecx, [esp+.dy1]
|
||||
inc ecx
|
||||
sub ecx, eax
|
||||
mov [ebx+BLITTER.h], ecx
|
||||
|
||||
mov ecx, [ebx+BLITTER.src_x]
|
||||
add ecx, edx
|
||||
sub ecx, [ebx+BLITTER.dst_x]
|
||||
mov [ebx+BLITTER.src_x], ecx
|
||||
|
||||
mov ecx, [ebx+BLITTER.src_y]
|
||||
add ecx, eax
|
||||
sub ecx, [ebx+BLITTER.dst_y]
|
||||
mov [ebx+BLITTER.src_y], ecx
|
||||
mov [ebx+BLITTER.dst_x], edx
|
||||
mov [ebx+BLITTER.dst_y], eax
|
||||
xor esi, esi
|
||||
.L28:
|
||||
mov eax, esi
|
||||
add esp, 40
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
|
||||
|
||||
purge .sx0
|
||||
purge .sy0
|
||||
purge .sx1
|
||||
purge .sy1
|
||||
|
||||
purge .dx0
|
||||
purge .dy0
|
||||
purge .dx1
|
||||
purge .dy1
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
|
||||
blit_32:
|
||||
push ebp
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
sub esp, 72
|
||||
|
||||
mov eax, [TASK_BASE]
|
||||
mov ebx, [eax-twdw + WDATA.box.width]
|
||||
mov edx, [eax-twdw + WDATA.box.height]
|
||||
|
||||
xor eax, eax
|
||||
|
||||
mov [esp+BLITTER.dc.xmin], eax
|
||||
mov [esp+BLITTER.dc.ymin], eax
|
||||
mov [esp+BLITTER.dc.xmax], ebx
|
||||
mov [esp+BLITTER.dc.ymax], edx
|
||||
|
||||
mov [esp+BLITTER.sc.xmin], eax
|
||||
mov [esp+BLITTER.sc.ymin], eax
|
||||
mov eax, [ecx+24]
|
||||
dec eax
|
||||
mov [esp+BLITTER.sc.xmax], eax
|
||||
mov eax, [ecx+28]
|
||||
dec eax
|
||||
mov [esp+BLITTER.sc.ymax], eax
|
||||
|
||||
mov eax, [ecx]
|
||||
mov [esp+BLITTER.dst_x], eax
|
||||
mov eax, [ecx+4]
|
||||
mov [esp+BLITTER.dst_y], eax
|
||||
|
||||
mov eax, [ecx+16]
|
||||
mov [esp+BLITTER.src_x], eax
|
||||
mov eax, [ecx+20]
|
||||
mov [esp+BLITTER.src_y], eax
|
||||
mov eax, [ecx+8]
|
||||
mov [esp+BLITTER.w], eax
|
||||
mov eax, [ecx+12]
|
||||
mov [esp+BLITTER.h], eax
|
||||
|
||||
|
||||
mov eax, [ecx+32]
|
||||
mov [esp+56], eax
|
||||
mov eax, [ecx+36]
|
||||
mov [esp+60], eax
|
||||
|
||||
mov ecx, esp
|
||||
call blit_clip
|
||||
test eax, eax
|
||||
jne .L57
|
||||
|
||||
inc [mouse_pause]
|
||||
call [_display.disable_mouse]
|
||||
|
||||
mov eax, [TASK_BASE]
|
||||
|
||||
mov ebx, [esp+BLITTER.dst_x]
|
||||
mov ebp, [esp+BLITTER.dst_y]
|
||||
add ebx, [eax-twdw + WDATA.box.left]
|
||||
add ebp, [eax-twdw + WDATA.box.top]
|
||||
mov edi, ebp
|
||||
|
||||
imul edi, [_display.pitch]
|
||||
imul ebp, [_display.width]
|
||||
add ebp, ebx
|
||||
add ebp, [_WinMapAddress]
|
||||
|
||||
mov eax, [esp+BLITTER.src_y]
|
||||
imul eax, [esp+BLITTER.stride]
|
||||
mov esi, [esp+BLITTER.src_x]
|
||||
lea esi, [eax+esi*4]
|
||||
add esi, [esp+BLITTER.bitmap]
|
||||
|
||||
mov ecx, [esp+BLITTER.h]
|
||||
mov edx, [esp+BLITTER.w]
|
||||
|
||||
test ecx, ecx ;FIXME check clipping
|
||||
jz .L57
|
||||
|
||||
test edx, edx
|
||||
jz .L57
|
||||
|
||||
cmp [_display.bpp], 32
|
||||
jne .core_24
|
||||
|
||||
lea edi, [edi+ebx*4]
|
||||
|
||||
mov ebx, [CURRENT_TASK]
|
||||
|
||||
align 4
|
||||
.outer32:
|
||||
xor ecx, ecx
|
||||
|
||||
align 4
|
||||
.inner32:
|
||||
cmp [ebp+ecx], bl
|
||||
jne @F
|
||||
|
||||
mov eax, [esi+ecx*4]
|
||||
mov [LFB_BASE+edi+ecx*4], eax
|
||||
@@:
|
||||
inc ecx
|
||||
dec edx
|
||||
jnz .inner32
|
||||
|
||||
add esi, [esp+BLITTER.stride]
|
||||
add edi, [_display.pitch]
|
||||
add ebp, [_display.width]
|
||||
|
||||
mov edx, [esp+BLITTER.w]
|
||||
dec [esp+BLITTER.h]
|
||||
jnz .outer32
|
||||
|
||||
.done:
|
||||
dec [mouse_pause]
|
||||
call [draw_pointer]
|
||||
.L57:
|
||||
add esp, 72
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
.core_24:
|
||||
lea ebx, [ebx+ebx*2]
|
||||
lea edi, [LFB_BASE+edi+ebx]
|
||||
mov ebx, [CURRENT_TASK]
|
||||
|
||||
align 4
|
||||
.outer24:
|
||||
mov [esp+64], edi
|
||||
xor ecx, ecx
|
||||
|
||||
align 4
|
||||
.inner24:
|
||||
cmp [ebp+ecx], bl
|
||||
jne @F
|
||||
|
||||
mov eax, [esi+ecx*4]
|
||||
|
||||
lea edi, [edi+ecx*2]
|
||||
mov [edi+ecx], ax
|
||||
shr eax, 16
|
||||
mov [edi+ecx+2], al
|
||||
@@:
|
||||
mov edi, [esp+64]
|
||||
inc ecx
|
||||
dec edx
|
||||
jnz .inner24
|
||||
|
||||
add esi, [esp+BLITTER.stride]
|
||||
add edi, [_display.pitch]
|
||||
add ebp, [_display.width]
|
||||
|
||||
mov edx, [esp+BLITTER.w]
|
||||
dec [esp+BLITTER.h]
|
||||
jnz .outer24
|
||||
|
||||
jmp .done
|
@@ -332,19 +332,13 @@ create_cursor:
|
||||
|
||||
stdcall init_cursor, eax, esi
|
||||
|
||||
mov eax, [.hcursor]
|
||||
lea eax, [eax+CURSOR.list_next]
|
||||
mov ecx, [.hcursor]
|
||||
lea ecx, [ecx+CURSOR.list_next]
|
||||
lea edx, [_display.cr_list.next]
|
||||
|
||||
pushfd
|
||||
cli
|
||||
mov ecx, [edx]
|
||||
|
||||
mov [eax], ecx
|
||||
mov [eax+4], edx
|
||||
|
||||
mov [ecx+4], eax
|
||||
mov [edx], eax
|
||||
list_add ecx, edx ;list_add_tail(new, head)
|
||||
popfd
|
||||
|
||||
mov eax, [.hcursor]
|
||||
@@ -458,8 +452,16 @@ destroy_cursor:
|
||||
|
||||
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
|
||||
|
||||
@@ -792,14 +794,6 @@ init_display:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
def_arrow:
|
||||
file 'arrow.cur'
|
||||
|
@@ -445,6 +445,14 @@ dl_dy equ esp+0
|
||||
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
|
||||
@@ -466,6 +474,14 @@ dl_dy equ esp+0
|
||||
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
|
||||
@@ -474,10 +490,25 @@ dl_dy equ esp+0
|
||||
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
|
||||
|
Reference in New Issue
Block a user