/kernel/branches/kolibri-process/blkdev/cdrom.inc |
---|
File deleted |
/kernel/branches/kolibri-process/blkdev/disk.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4437 $ |
$Revision: 5089 $ |
; ============================================================================= |
; ================================= Constants ================================= |
108,6 → 108,7 |
data dd ? |
sad_size dd ? |
search_start dd ? |
sector_size_log dd ? |
ends |
; This structure represents a disk device and its media for the kernel. |
271,13 → 272,13 |
endg |
iglobal |
; The function 'disk_scan_partitions' needs three 512-byte buffers for |
; The function 'disk_scan_partitions' needs three sector-sized buffers for |
; MBR, bootsector and fs-temporary sector data. It can not use the static |
; buffers always, since it can be called for two or more disks in parallel. |
; However, this case is not typical. We reserve three static 512-byte buffers |
; and a flag that these buffers are currently used. If 'disk_scan_partitions' |
; detects that the buffers are currently used, it allocates buffers from the |
; heap. |
; heap. Also, the heap is used when sector size is other than 512. |
; The flag is implemented as a global dword variable. When the static buffers |
; are not used, the value is -1. When the static buffers are used, the value |
; is normally 0 and temporarily can become greater. The function increments |
638,21 → 639,18 |
; 1. Initialize .NumPartitions and .Partitions fields as zeros: empty list. |
and [esi+DISK.NumPartitions], 0 |
and [esi+DISK.Partitions], 0 |
; 2. Currently we can work only with 512-bytes sectors. Check this restriction. |
; The only exception is 2048-bytes CD/DVD, but they are not supported yet by |
; this code. |
cmp [esi+DISK.MediaInfo.SectorSize], 512 |
jz .doscan |
DEBUGF 1,'K : sector size is %d, only 512 is supported\n',[esi+DISK.MediaInfo.SectorSize] |
ret |
.doscan: |
; 3. Acquire the buffer for MBR and bootsector tests. See the comment before |
; 2. Acquire the buffer for MBR and bootsector tests. See the comment before |
; the 'partition_buffer_users' variable. |
mov eax, [esi+DISK.MediaInfo.SectorSize] |
cmp eax, 512 |
jnz @f |
mov ebx, mbr_buffer ; assume the global buffer is free |
lock inc [partition_buffer_users] |
jz .buffer_acquired ; yes, it is free |
lock dec [partition_buffer_users] ; no, we must allocate |
stdcall kernel_alloc, 512*3 |
@@: |
lea eax, [eax*3] |
stdcall kernel_alloc, eax |
test eax, eax |
jz .nothing |
xchg eax, ebx |
659,7 → 657,7 |
.buffer_acquired: |
; MBR/EBRs are organized in the chain. We use a loop over MBR/EBRs, but no |
; more than MAX_NUM_PARTITION times. |
; 4. Prepare things for the loop. |
; 3. Prepare things for the loop. |
; ebp will hold the sector number for current MBR/EBR. |
; [esp] will hold the sector number for current extended partition, if there |
; is one. |
668,6 → 666,10 |
push MAX_NUM_PARTITIONS ; the counter of max MBRs to process |
xor ebp, ebp ; start from sector zero |
push ebp ; no extended partition yet |
; 4. MBR is 512 bytes long. If sector size is less than 512 bytes, |
; assume no MBR, no partitions and go to 10. |
cmp [esi+DISK.MediaInfo.SectorSize], 512 |
jb .notmbr |
.new_mbr: |
; 5. Read the current sector. |
; Note that 'read' callback operates with 64-bit sector numbers, so we must |
986,7 → 988,7 |
; a three-sectors-sized buffer. This function saves ebx in the stack |
; immediately before ebp. |
mov ebx, [ebp-4] ; get buffer |
add ebx, 512 ; advance over MBR data to bootsector data |
add ebx, [esi+DISK.MediaInfo.SectorSize] ; advance over MBR data to bootsector data |
add ebp, 8 ; ebp points to part of PARTITION structure |
xor eax, eax ; first sector of the partition |
call fs_read32_sys |
997,7 → 999,7 |
; ebp -> first three fields of PARTITION structure, .start, .length, .disk; |
; [esp] = error code after bootsector read: 0 = ok, otherwise = failed, |
; ebx points to the buffer for bootsector, |
; ebx+512 points to 512-bytes buffer that can be used for anything. |
; ebx+[esi+DISK.MediaInfo.SectorSize] points to sector-sized buffer that can be used for anything. |
call fat_create_partition |
test eax, eax |
jnz .success |
/kernel/branches/kolibri-process/blkdev/disk_cache.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4465 $ |
$Revision: 5095 $ |
; Read/write functions try to do large operations, |
; it is significantly faster than several small operations. |
49,7 → 49,7 |
; out: ecx = number of sectors that were read |
fs_read64_sys: |
; Save ebx, set ebx to SysCache and let the common part do its work. |
push ebx |
push ebx ebx |
mov ebx, [ebp+PARTITION.Disk] |
add ebx, DISK.SysCache |
jmp fs_read64_common |
63,7 → 63,7 |
; out: ecx = number of sectors that were read |
fs_read64_app: |
; Save ebx, set ebx to AppCache and let the common part do its work. |
push ebx |
push ebx ebx |
mov ebx, [ebp+PARTITION.Disk] |
add ebx, DISK.AppCache |
118,7 → 118,6 |
add [.sector_lo], eax |
adc [.sector_hi], edx |
; 5. If the cache is disabled, pass the request directly to the driver. |
mov edi, [.buffer] |
cmp [ebx+DISKCACHE.pointer], 0 |
jz .nocache |
; 6. Look for sectors in the cache, sequentially from the beginning. |
137,13 → 136,15 |
; release the lock and go to 7. |
jc .not_found_in_cache |
; The sector is found in cache. |
; 6d. Copy data for the caller. |
; Note that buffer in edi is advanced automatically. |
mov esi, ecx |
shl esi, 9 |
add esi, [ebx+DISKCACHE.data] |
mov ecx, 512/4 |
; 6d. Copy data for the caller, advance [.buffer]. |
mov esi, edi |
mov edi, [.buffer] |
mov eax, 1 |
shl eax, cl |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
mov [.buffer], edi |
; 6e. Advance the sector. |
add [.sector_lo], 1 |
adc [.sector_hi], 0 |
161,7 → 162,7 |
sub ecx, [.num_sectors] |
.nothing: |
add esp, .local_vars_size |
pop edi esi ebx ; restore used registers to be stdcall |
pop edi esi ebx ebx ; restore used registers to be stdcall |
ret |
.not_found_in_cache: |
; Release the lock acquired at 6a. |
177,6 → 178,7 |
; However, for extra-large requests make an upper limit: |
; do not use more than half of the free memory |
; or more than CACHE_MAX_ALLOC_SIZE bytes. |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
mov ebx, [pg_data.pages_free] |
shr ebx, 1 |
jz .nomemory |
184,13 → 186,15 |
jbe @f |
mov ebx, CACHE_MAX_ALLOC_SIZE shr 12 |
@@: |
shl ebx, 12 - 9 |
shl ebx, 12 |
shr ebx, cl |
jz .nomemory |
cmp ebx, [.num_sectors] |
jbe @f |
mov ebx, [.num_sectors] |
@@: |
mov eax, ebx |
shl eax, 9 |
shl eax, cl |
stdcall kernel_alloc, eax |
; If failed, return the appropriate error code. |
test eax, eax |
233,28 → 237,31 |
jz @f |
mov [.error_code+.local_vars2_size], eax |
@@: |
; 11. Copy data for the caller. |
; Note that buffer in edi is advanced automatically. |
; 11. Copy data for the caller, advance .buffer. |
cmp [.current_num_sectors], 0 |
jz .copy_done |
mov ecx, [.current_num_sectors] |
shl ecx, 9-2 |
mov ebx, [.cache+.local_vars2_size] |
mov eax, [.current_num_sectors] |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
shl eax, cl |
mov esi, [.allocated_buffer] |
mov edi, [.buffer+.local_vars2_size] |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
mov [.buffer+.local_vars2_size], edi |
; 12. Copy data to the cache. |
; 12a. Acquire the lock. |
mov ebx, [.cache+.local_vars2_size] |
mov ecx, [ebp+PARTITION.Disk] |
add ecx, DISK.CacheLock |
call mutex_lock |
; 12b. Prepare for the loop: save edi and create a local variable that |
; 12b. Prepare for the loop: create a local variable that |
; stores number of sectors to be copied. |
push edi |
push [.current_num_sectors+4] |
push [.current_num_sectors] |
.store_to_cache: |
; 12c. For each sector, call the lookup function with adding to the cache, if not yet. |
mov eax, [.sector_lo+.local_vars2_size+8] |
mov edx, [.sector_hi+.local_vars2_size+8] |
mov eax, [.sector_lo+.local_vars2_size+4] |
mov edx, [.sector_hi+.local_vars2_size+4] |
call cache_lookup_write |
test eax, eax |
jnz .cache_error |
263,16 → 270,17 |
; so rewrite data for the caller from the cache. |
cmp [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED |
jnz .not_modified |
mov esi, ecx |
shl esi, 9 |
add esi, [ebx+DISKCACHE.data] |
mov edi, [esp+4] |
mov ecx, [esp] |
shl ecx, 9-2 |
sub edi, ecx |
mov ecx, 512/4 |
mov esi, edi |
mov edi, [.buffer+.local_vars2_size+4] |
mov eax, [esp] |
shl eax, cl |
sub edi, eax |
mov eax, 1 |
shl eax, cl |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
add [.current_buffer+8], 512 |
add [.current_buffer+4], eax |
jmp .sector_done |
.not_modified: |
; 12e. For each not-modified sector, |
279,23 → 287,22 |
; copy data, mark the item as not-modified copy of the disk, |
; advance .current_buffer and .sector_hi:.sector_lo to the next sector. |
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY |
mov esi, [.current_buffer+8] |
mov edi, ecx |
shl edi, 9 |
add edi, [ebx+DISKCACHE.data] |
mov ecx, 512/4 |
mov eax, 1 |
shl eax, cl |
mov esi, [.current_buffer+4] |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
mov [.current_buffer+8], esi |
mov [.current_buffer+4], esi |
.sector_done: |
add [.sector_lo+.local_vars2_size+8], 1 |
adc [.sector_hi+.local_vars2_size+8], 0 |
add [.sector_lo+.local_vars2_size+4], 1 |
adc [.sector_hi+.local_vars2_size+4], 0 |
; 12f. Continue the loop 12c-12e until all sectors are read. |
dec dword [esp] |
jnz .store_to_cache |
.cache_error: |
; 12g. Restore after the loop: pop the local variable and restore edi. |
; 12g. Restore after the loop: pop the local variable. |
pop ecx |
pop edi |
; 12h. Release the lock. |
mov ecx, [ebp+PARTITION.Disk] |
add ecx, DISK.CacheLock |
328,7 → 335,7 |
push eax ; numsectors |
push [.sector_hi+4] ; startsector |
push [.sector_lo+8] ; startsector |
push edi ; buffer |
push [.buffer+12] ; buffer |
mov esi, [ebp+PARTITION.Disk] |
mov al, DISKFUNC.read |
call disk_call_driver |
440,11 → 447,11 |
; 6c. For each sector, copy data, mark the item as modified and not saved, |
; advance .current_buffer to the next sector. |
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED |
mov eax, 1 |
shl eax, cl |
mov esi, [.cur_buffer] |
mov edi, ecx |
shl edi, 9 |
add edi, [ebx+DISKCACHE.data] |
mov ecx, 512/4 |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
mov [.cur_buffer], esi |
; 6d. Remove the sector from the other cache. |
592,11 → 599,12 |
jc .not_found_in_cache |
.found_in_cache: |
; 4c. Copy the data. |
mov esi, edi |
mov edi, [.buffer] |
mov esi, ecx |
shl esi, 9 |
add esi, [ebx+DISKCACHE.data] |
mov ecx, 512/4 |
mov eax, 1 |
shl eax, cl |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
; 4d. Release the lock and return success. |
mov ecx, [ebp+PARTITION.Disk] |
627,7 → 635,10 |
add ecx, DISK.CacheLock |
call mutex_unlock |
; 7. Allocate buffer for CACHE_LEGACY_READ_SIZE sectors. |
stdcall kernel_alloc, CACHE_LEGACY_READ_SIZE shl 9 |
mov eax, CACHE_LEGACY_READ_SIZE |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
shl eax, cl |
stdcall kernel_alloc, eax |
; If failed, return the corresponding error code. |
test eax, eax |
jz .nomemory |
656,7 → 667,11 |
; 10. Copy data for the caller. |
mov esi, [.allocated_buffer] |
mov edi, [.buffer+.local_vars2_size] |
mov ecx, 512/4 |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
mov eax, 1 |
shl eax, cl |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
; 11. Store all sectors that were successfully read to the cache. |
; 11a. Acquire the lock. |
671,9 → 686,11 |
test eax, eax |
jnz .cache_error |
; 11c. Ignore sectors marked as modified: for them the cache is more recent that disk data. |
mov eax, 1 |
shl eax, cl |
cmp [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED |
jnz .not_modified |
add [.current_buffer], 512 |
add [.current_buffer], eax |
jmp .sector_done |
.not_modified: |
; 11d. For each sector, copy data, mark the item as not-modified copy of the disk, |
680,10 → 697,8 |
; advance .current_buffer and .sector_hi:.sector_lo to the next sector. |
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY |
mov esi, [.current_buffer] |
mov edi, ecx |
shl edi, 9 |
add edi, [ebx+DISKCACHE.data] |
mov ecx, 512/4 |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
mov [.current_buffer], esi |
.sector_done: |
721,7 → 736,7 |
call cache_lookup_write |
test eax, eax |
jnz .floppy_cache_error |
push ecx |
push esi |
; 14. Call the driver to read one sector. |
push 1 |
728,9 → 743,7 |
push esp |
push edx |
push [.sector_lo+16] |
shl ecx, 9 |
add ecx, [ebx+DISKCACHE.data] |
push ecx |
push edi |
mov esi, [ebp+PARTITION.Disk] |
mov al, DISKFUNC.read |
call disk_call_driver |
740,10 → 753,7 |
; 15. Get the slot and pointer to the cache item, |
; change the status to not-modified copy of the disk |
; and go to 4c. |
pop ecx |
lea esi, [ecx*sizeof.CACHE_ITEM/4] |
shl esi, 2 |
add esi, [ebx+DISKCACHE.pointer] |
pop esi |
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY |
jmp .found_in_cache |
795,13 → 805,14 |
; in: edx:eax = sector |
; in: ebx -> DISKCACHE structure |
; out: CF set if sector is not in cache |
; out: ecx = index in cache |
; out: ecx = sector_size_log |
; out: esi -> sector:status |
; out: edi -> sector data |
proc cache_lookup_read |
mov esi, [ebx+DISKCACHE.pointer] |
add esi, sizeof.CACHE_ITEM |
mov ecx, 1 |
mov edi, 1 |
.hdreadcache: |
812,6 → 823,9 |
jne .nohdcache |
cmp [esi+CACHE_ITEM.SectorHi], edx |
jne .nohdcache |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
shl edi, cl |
add edi, [ebx+DISKCACHE.data] |
clc |
ret |
818,8 → 832,8 |
.nohdcache: |
add esi, sizeof.CACHE_ITEM |
inc ecx |
cmp ecx, [ebx+DISKCACHE.sad_size] |
inc edi |
cmp edi, [ebx+DISKCACHE.sad_size] |
jbe .hdreadcache |
stc |
ret |
832,8 → 846,8 |
; in: ebx -> DISKCACHE structure |
; in: ebp -> PARTITION structure |
; out: eax = error code |
; out: ecx = index in cache |
; out: esi -> sector:status |
; out: edi -> sector data |
proc cache_lookup_write |
call cache_lookup_read |
jnc .return0 |
874,6 → 888,10 |
popd [esi+CACHE_ITEM.SectorLo] |
popd [esi+CACHE_ITEM.SectorHi] |
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_EMPTY |
mov edi, ecx |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
shl edi, cl |
add edi, [ebx+DISKCACHE.data] |
.return0: |
xor eax, eax ; success |
ret |
902,7 → 920,7 |
.sequential dd ? |
; boolean variable, 1 if the current chain is sequential in the cache, |
; 0 if additional buffer is needed to perform the operation |
.chain_start_pos dd ? ; slot of chain start item |
.chain_start_pos dd ? ; data of chain start item |
.chain_start_ptr dd ? ; pointer to chain start item |
.chain_size dd ? ; chain size (thanks, C.O.) |
.iteration_size dd ? |
951,6 → 969,9 |
mov eax, [ebx+DISKCACHE.sad_size] |
sub eax, [.size_left] |
inc eax |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
shl eax, cl |
add eax, [ebx+DISKCACHE.data] |
mov [.chain_start_pos], eax |
mov [.chain_size], 0 |
mov [.sequential], 1 |
978,7 → 999,7 |
; before returning to 6b; if there is a sequential block indeed, this saves some |
; time instead of many full-fledged lookups. |
mov [.sequential], 0 |
mov [.chain_start_pos], ecx |
mov [.chain_start_pos], edi |
.look_backward: |
; 6e. For each sector, update chain start pos/ptr, decrement sector number, |
; look at the previous item. |
1001,7 → 1022,9 |
; ...expand the chain one sector backwards and continue the loop at 6e. |
; Otherwise, advance to step 7 if the previous item describes the correct sector |
; but is not modified, and return to step 6b otherwise. |
dec [.chain_start_pos] |
mov edi, 1 |
shl edi, cl |
sub [.chain_start_pos], edi |
jmp .look_backward |
.found_chain_start: |
; 7. Expand the chain forward. |
1046,14 → 1069,11 |
; 9. Write a sequential chain to disk. |
; 9a. Pass the entire chain to the driver. |
mov eax, [.chain_start_ptr] |
mov edx, [.chain_start_pos] |
shl edx, 9 |
add edx, [ebx+DISKCACHE.data] |
lea ecx, [.chain_size] |
push ecx ; numsectors |
pushd [eax+CACHE_ITEM.SectorHi] ; startsector |
pushd [eax+CACHE_ITEM.SectorLo] ; startsector |
push edx ; buffer |
push [.chain_start_pos+12] ; buffer |
mov esi, [ebp+PARTITION.Disk] |
mov al, DISKFUNC.write |
call disk_call_driver |
1088,13 → 1108,15 |
jbe @f |
mov eax, CACHE_MAX_ALLOC_SIZE shr 12 |
@@: |
shl eax, 12 - 9 |
shl eax, 12 |
shr eax, cl |
jz .nomemory |
cmp eax, [.chain_size] |
jbe @f |
mov eax, [.chain_size] |
@@: |
mov [.iteration_size], eax |
shl eax, 9 |
shl eax, cl |
stdcall kernel_alloc, eax |
test eax, eax |
jz .nomemory |
1123,10 → 1145,13 |
; 13b. For each sector, copy the data. |
; Note that edi is advanced automatically. |
mov esi, [.chain_start_pos+24] |
shl esi, 9 |
add esi, [ebx+DISKCACHE.data] |
mov ecx, 512/4 |
mov ecx, [ebx+DISKCACHE.sector_size_log] |
mov eax, 1 |
shl eax, cl |
mov ecx, eax |
shr ecx, 2 |
rep movsd |
mov ecx, eax ; keep for 13e |
; 13c. Mark the item as not-modified. |
mov esi, [.chain_start_ptr+24] |
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY |
1145,7 → 1170,7 |
jnz .no_forward |
; 13e. Increment position/pointer to the chain and |
; continue the loop. |
inc [.chain_start_pos+24] |
add [.chain_start_pos+24], ecx |
mov [.chain_start_ptr+24], esi |
dec dword [esp] |
jnz .copy_loop |
1153,11 → 1178,13 |
.no_forward: |
; 13f. Call the lookup function without adding to the cache. |
; Update position/pointer with returned value. |
; Note: for the last sector in the chain, ecx/esi may contain |
; Note: for the last sector in the chain, edi/esi may contain |
; garbage; we are not going to use them in this case. |
push edi |
call cache_lookup_read |
mov [.chain_start_pos+24], ecx |
mov [.chain_start_ptr+24], esi |
mov [.chain_start_pos+28], edi |
mov [.chain_start_ptr+28], esi |
pop edi |
dec dword [esp] |
jnz .copy_loop |
.copy_done: |
1203,13 → 1230,32 |
; 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. |
; 1. Verify sector size. The code requires it to be a power of 2 not less than 4. |
; In the name of sanity check that sector size is not too small or too large. |
bsf ecx, [esi+DISK.MediaInfo.SectorSize] |
jz .invalid_sector_size |
mov eax, 1 |
shl eax, cl |
cmp eax, [esi+DISK.MediaInfo.SectorSize] |
jnz .invalid_sector_size |
cmp ecx, 6 |
jb .invalid_sector_size |
cmp ecx, 14 |
jbe .normal_sector_size |
.invalid_sector_size: |
DEBUGF 1,'K : sector size %x is invalid\n',[esi+DISK.MediaInfo.SectorSize] |
xor eax, eax |
ret |
.normal_sector_size: |
mov [esi+DISK.SysCache.sector_size_log], ecx |
mov [esi+DISK.AppCache.sector_size_log], ecx |
; 2. Calculate the suggested cache size. |
; 2a. Get the size of free physical memory in pages. |
mov eax, [pg_data.pages_free] |
; 1b. Use the value to calculate the size. |
; 2b. 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. |
; 2c. Force lower and upper limits. |
cmp eax, 1024*1024 |
jb @f |
mov eax, 1024*1024 |
1218,7 → 1264,7 |
ja @f |
mov eax, 128*1024 |
@@: |
; 1d. Give a chance to the driver to adjust the size. |
; 2d. Give a chance to the driver to adjust the size. |
push eax |
mov al, DISKFUNC.adjust_cache_size |
call disk_call_driver |
1226,16 → 1272,16 |
mov [esi+DISK.cache_size], eax |
test eax, eax |
jz .nocache |
; 2. Allocate memory for the cache. |
; 2a. Call the allocator. |
; 3. Allocate memory for the cache. |
; 3a. Call the allocator. |
stdcall kernel_alloc, eax |
test eax, eax |
jnz @f |
; 2b. If it failed, say a message and return with eax = 0. |
; 3b. If it failed, say a message and return with eax = 0. |
dbgstr 'no memory for disk cache' |
jmp .nothing |
@@: |
; 3. Fill two DISKCACHE structures. |
; 4. Fill two DISKCACHE structures. |
mov [esi+DISK.SysCache.pointer], eax |
lea ecx, [esi+DISK.CacheLock] |
call mutex_init |
1252,9 → 1298,7 |
mov [esi+DISK.AppCache.pointer], edx |
mov eax, [esi+DISK.SysCache.data_size] |
push ebx |
call calculate_for_hd64 |
pop ebx |
call calculate_cache_slots |
add eax, [esi+DISK.SysCache.pointer] |
mov [esi+DISK.SysCache.data], eax |
mov [esi+DISK.SysCache.sad_size], ecx |
1267,9 → 1311,7 |
pop edi |
mov eax, [esi+DISK.AppCache.data_size] |
push ebx |
call calculate_for_hd64 |
pop ebx |
call calculate_cache_slots |
add eax, [esi+DISK.AppCache.pointer] |
mov [esi+DISK.AppCache.data], eax |
mov [esi+DISK.AppCache.sad_size], ecx |
1281,9 → 1323,9 |
rep stosd |
pop edi |
; 4. Return with nonzero al. |
; 5. Return with nonzero al. |
mov al, 1 |
; 5. Return. |
; 6. Return. |
.nothing: |
ret |
; No caching is required for this driver. Zero cache pointers and return with |
1294,18 → 1336,16 |
mov al, 1 |
ret |
calculate_for_hd64: |
calculate_cache_slots: |
push eax |
mov ebx, eax |
shr eax, 9 |
lea eax, [eax*3] |
shl eax, 2 |
sub ebx, eax |
shr ebx, 9 |
mov ecx, ebx |
shl ebx, 9 |
mov ecx, [esi+DISK.MediaInfo.SectorSize] |
add ecx, sizeof.CACHE_ITEM |
xor edx, edx |
div ecx |
mov ecx, eax |
imul eax, [esi+DISK.MediaInfo.SectorSize] |
sub [esp], eax |
pop eax |
sub eax, ebx |
dec ecx |
ret |
/kernel/branches/kolibri-process/blkdev/rd.inc |
---|
6,7 → 6,7 |
;; RAMDISK functions ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4273 $ |
$Revision: 5057 $ |
iglobal |
align 4 |
22,11 → 22,6 |
.size = $ - ramdisk_functions |
endg |
; See memmap.inc. |
; Currently size of memory allocated for the ramdisk is fixed. |
; This should be revisited when/if memory map would become more dynamic. |
RAMDISK_CAPACITY = 2880 ; in sectors |
iglobal |
align 4 |
ramdisk_actual_size dd RAMDISK_CAPACITY |
/kernel/branches/kolibri-process/boot/bootcode.inc |
---|
394,7 → 394,6 |
push 0 |
popf |
sti |
; set up esp |
movzx esp, sp |
402,15 → 401,20 |
push 0 |
pop es |
xor cx, cx |
@@: |
in al, 64h |
test al, 2 |
loopnz @b |
mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование |
out 0x60, al |
xor cx, cx |
wait_loop: ; variant 2 |
; reading state of port of 8042 controller |
@@: |
in al, 64h |
and al, 00000010b ; ready flag |
; wait until 8042 controller is ready |
loopnz wait_loop |
test al, 1 |
loopz @b |
in al, 0x60 |
;;;/diamond today 5.02.2008 |
; set keyboard typematic rate & delay |
419,16 → 423,19 |
xor cx, cx |
@@: |
in al, 64h |
test al, 2 |
loopnz @b |
test al, 1 |
loopz @b |
in al, 0x60 |
mov al, 0 |
out 0x60, al |
xor cx, cx |
@@: |
in al, 64h |
test al, 2 |
loopnz @b |
test al, 1 |
loopz @b |
in al, 0x60 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
sti |
; --------------- APM --------------------- |
and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) |
mov ax, 0x5300 |
/kernel/branches/kolibri-process/boot/shutdown.inc |
---|
13,8 → 13,24 |
$Revision: 2455 $ |
use32 |
become_real: |
cli |
lgdt [realmode_gdt-OS_BASE] |
jmp 8:@f |
use16 |
@@: |
mov ax, 10h |
mov ds, ax |
mov es, ax |
mov fs, ax |
mov gs, ax |
mov ss, ax |
mov eax, cr0 |
and eax, not 80000001h |
mov cr0, eax |
jmp 0x1000:pr_mode_exit |
align 4 |
pr_mode_exit: |
; setup stack |
/kernel/branches/kolibri-process/const.inc |
---|
228,10 → 228,6 |
CLEAN_ZONE equ (_CLEAN_ZONE-OS_BASE) |
IDE_DMA equ (_IDE_DMA-OS_BASE) |
; unused? |
SB16Buffer equ (OS_BASE+0x02A0000) |
SB16_Status equ (OS_BASE+0x02B0000) |
UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000) |
virtual at (OS_BASE+0x05FFF80) |
621,6 → 617,28 |
NumAuxSymbols db ? |
ends |
struct STRIPPED_PE_HEADER |
Signature dw ? |
Characteristics dw ? |
AddressOfEntryPoint dd ? |
ImageBase dd ? |
SectionAlignmentLog db ? |
FileAlignmentLog db ? |
MajorOSVersion db ? |
MinorOSVersion db ? |
SizeOfImage dd ? |
SizeOfStackReserve dd ? |
SizeOfHeapReserve dd ? |
SizeOfHeaders dd ? |
Subsystem db ? |
NumberOfRvaAndSizes db ? |
NumberOfSections dw ? |
ends |
STRIPPED_PE_SIGNATURE = 0x4503 ; 'PE' xor 'S' |
SPE_DIRECTORY_IMPORT = 0 |
SPE_DIRECTORY_EXPORT = 1 |
SPE_DIRECTORY_BASERELOC = 2 |
struct IOCTL |
handle dd ? |
io_code dd ? |
/kernel/branches/kolibri-process/core/dll.inc |
---|
209,13 → 209,13 |
stdcall strncmp, edx, [sz_name], 16 |
test eax, eax |
je .ok |
mov eax, edx |
je .nothing |
mov edx, [edx+SRV.fd] |
jmp @B |
.not_load: |
mov eax, [sz_name] |
; Try to load .dll driver first. If not, fallback to .obj. |
push edi |
sub esp, 36 |
mov edi, esp |
236,12 → 236,6 |
stdcall load_pe_driver, edi, 0 |
add esp, 36 |
pop edi |
test eax, eax |
jnz .nothing |
pop ebp |
jmp load_driver |
.ok: |
mov eax, edx |
.nothing: |
ret |
endp |
880,177 → 874,6 |
ret |
endp |
align 4 |
proc load_driver stdcall, driver_name:dword |
locals |
coff dd ? |
sym dd ? |
strings dd ? |
img_size dd ? |
img_base dd ? |
start dd ? |
file_name rb 13+16+4+1 ; '/sys/drivers/<up-to-16-chars>.obj' |
endl |
lea edx, [file_name] |
mov dword [edx], '/sys' |
mov dword [edx+4], '/dri' |
mov dword [edx+8], 'vers' |
mov byte [edx+12], '/' |
mov esi, [driver_name] |
.redo: |
lea edx, [file_name] |
lea edi, [edx+13] |
mov ecx, 16 |
@@: |
lodsb |
test al, al |
jz @f |
stosb |
loop @b |
@@: |
mov dword [edi], '.obj' |
mov byte [edi+4], 0 |
stdcall load_file, edx |
test eax, eax |
jz .exit |
mov [coff], eax |
movzx ecx, [eax+COFF_HEADER.nSections] |
xor ebx, ebx |
lea edx, [eax+20] |
@@: |
add ebx, [edx+COFF_SECTION.SizeOfRawData] |
add ebx, 15 |
and ebx, not 15 |
add edx, sizeof.COFF_SECTION |
dec ecx |
jnz @B |
mov [img_size], ebx |
stdcall kernel_alloc, ebx |
test eax, eax |
jz .fail |
mov [img_base], eax |
mov edi, eax |
xor eax, eax |
mov ecx, [img_size] |
add ecx, 4095 |
and ecx, not 4095 |
shr ecx, 2 |
cld |
rep stosd |
mov edx, [coff] |
movzx ebx, [edx+COFF_HEADER.nSections] |
mov edi, [img_base] |
lea eax, [edx+20] |
@@: |
mov [eax+COFF_SECTION.VirtualAddress], edi |
mov esi, [eax+COFF_SECTION.PtrRawData] |
test esi, esi |
jnz .copy |
add edi, [eax+COFF_SECTION.SizeOfRawData] |
jmp .next |
.copy: |
add esi, edx |
mov ecx, [eax+COFF_SECTION.SizeOfRawData] |
cld |
rep movsb |
.next: |
add edi, 15 |
and edi, not 15 |
add eax, sizeof.COFF_SECTION |
dec ebx |
jnz @B |
mov ebx, [edx+COFF_HEADER.pSymTable] |
add ebx, edx |
mov [sym], ebx |
mov ecx, [edx+COFF_HEADER.nSymbols] |
add ecx, ecx |
lea ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE |
add ecx, [sym] |
mov [strings], ecx |
lea eax, [edx+20] |
stdcall fix_coff_symbols, eax, [sym], [edx+COFF_HEADER.nSymbols], \ |
[strings], __exports |
test eax, eax |
jz .link_fail |
mov ebx, [coff] |
stdcall fix_coff_relocs, ebx, [sym], 0 |
stdcall get_coff_sym, [sym], [ebx+COFF_HEADER.nSymbols], szVersion |
test eax, eax |
jz .link_fail |
mov eax, [eax] |
shr eax, 16 |
cmp eax, DRV_COMPAT |
jb .ver_fail |
cmp eax, DRV_CURRENT |
ja .ver_fail |
mov ebx, [coff] |
stdcall get_coff_sym, [sym], [ebx+COFF_HEADER.nSymbols], szSTART |
mov [start], eax |
stdcall kernel_free, [coff] |
mov ebx, [start] |
stdcall ebx, DRV_ENTRY |
test eax, eax |
jnz .ok |
stdcall kernel_free, [img_base] |
xor eax, eax |
ret |
.ok: |
mov ebx, [img_base] |
mov [eax+SRV.base], ebx |
mov ecx, [start] |
mov [eax+SRV.entry], ecx |
ret |
.ver_fail: |
mov esi, msg_CR |
call sys_msg_board_str |
mov esi, [driver_name] |
call sys_msg_board_str |
mov esi, msg_CR |
call sys_msg_board_str |
mov esi, msg_version |
call sys_msg_board_str |
mov esi, msg_www |
call sys_msg_board_str |
jmp .cleanup |
.link_fail: |
mov esi, msg_module |
call sys_msg_board_str |
mov esi, [driver_name] |
call sys_msg_board_str |
mov esi, msg_CR |
call sys_msg_board_str |
.cleanup: |
stdcall kernel_free, [img_base] |
.fail: |
stdcall kernel_free, [coff] |
.exit: |
xor eax, eax |
ret |
endp |
; in: edx -> COFF_SECTION struct |
; out: eax = alignment as mask for bits to drop |
coff_get_align: |
/kernel/branches/kolibri-process/core/exports.inc |
---|
5,13 → 5,8 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4418 $ |
$Revision: 5088 $ |
iglobal |
szKernel db 'KERNEL', 0 |
szVersion db 'version',0 |
endg |
align 4 |
__exports: |
export 'KERNEL', \ |
48,6 → 43,7 |
get_phys_addr, 'GetPhysAddr', \ ; eax |
map_space, 'MapSpace', \ |
release_pages, 'ReleasePages', \ |
alloc_dma24, 'AllocDMA24', \ ; stdcall |
\ |
mutex_init, 'MutexInit', \ ; gcc fastcall |
mutex_lock, 'MutexLock', \ ; gcc fastcall |
/kernel/branches/kolibri-process/core/memory.inc |
---|
232,24 → 232,12 |
mov edi, ebx |
shr edi, 12 |
lea edi, [page_tabs+edi*4] |
if USE_FIX_FOR_INVALID_MS_VIRTUAL_PC_2007 |
mov edx, eax |
@@: |
mov eax, edx |
stosd |
invlpg [ebx] |
add edx, 0x1000 |
add ebx, 0x1000 |
loop @B |
else |
@@: |
stosd |
invlpg [ebx] |
add eax, 0x1000 |
add ebx, 0x1000 |
loop @B |
end if |
pop edi |
362,6 → 350,59 |
ret |
endp |
uglobal |
sb16_buffer_allocated db 0 |
endg |
; Allocates [.size] bytes so that the target memory block |
; is inside one 64K page for 24-bit DMA controller, |
; that is, somewhere between 00xx0000h and 00xxFFFFh. |
proc alloc_dma24 |
; Implementation note. |
; The only user of that function is SB16 driver, |
; so just return a statically allocated buffer. |
virtual at esp |
dd ? ; return address |
.size dd ? |
end virtual |
cmp [sb16_buffer_allocated], 0 |
jnz .fail |
inc [sb16_buffer_allocated] |
mov eax, SB16Buffer |
ret 4 |
.fail: |
xor eax, eax |
ret 4 |
endp |
; Allocates a physical page for master page table |
; that duplicates first Mb of OS_BASE at address 0; |
; used for starting APs and for shutting down, |
; where it is important to execute code in trivial-mapped pages. |
; Returns eax = allocated physical page. |
proc create_trampoline_pgmap |
; The only non-trivial moment: |
; we need a linear address to fill information, |
; but we don't need it outside of this function, |
; so we're returning physical address. |
; Therefore, allocate memory with kernel_alloc, |
; this will allocate physical page and a linear address somewhere, |
; and deallocate only linear address with free_kernel_space. |
stdcall kernel_alloc, 0x1000 |
mov edi, eax |
mov esi, master_tab |
mov ecx, 1024 |
rep movsd |
mov ecx, [master_tab+(OS_BASE shr 20)] |
mov [eax], ecx |
mov edi, eax |
call get_pg_addr |
push eax |
stdcall free_kernel_space, edi |
pop eax |
ret |
endp |
align 4 |
proc init_LFB |
locals |
/kernel/branches/kolibri-process/core/peload.inc |
---|
24,15 → 24,30 |
mov [image], eax |
mov edx, [eax+STRIPPED_PE_HEADER.SizeOfImage] |
; mov cl, [eax+STRIPPED_PE_HEADER.Subsystem] |
cmp word [eax], STRIPPED_PE_SIGNATURE |
jz @f |
mov edx, [eax+60] |
; mov cl, [eax+5Ch+edx] |
mov edx, [eax+80+edx] |
stdcall kernel_alloc, [eax+80+edx] |
@@: |
mov [entry], 0 |
; cmp cl, 1 |
; jnz .cleanup |
stdcall kernel_alloc, edx |
test eax, eax |
jz .cleanup |
mov [base], eax |
stdcall map_PE, eax, [image] |
push ebx ebp |
mov ebx, [image] |
mov ebp, eax |
call map_PE |
pop ebp ebx |
mov [entry], eax |
test eax, eax |
48,199 → 63,200 |
ret |
endp |
DWORD equ dword |
PTR equ |
align 4 |
map_PE: ;stdcall base:dword, image:dword |
cld |
push ebp |
map_PE: ;ebp=base:dword, ebx=image:dword |
push edi |
push esi |
push ebx |
sub esp, 60 |
mov ebx, DWORD PTR [esp+84] |
mov ebp, DWORD PTR [esp+80] |
sub esp, .locals_size |
virtual at esp |
.numsections dd ? |
.import_names dd ? |
.import_targets dd ? |
.peheader dd ? |
.bad_import dd ? |
.import_idx dd ? |
.import_descr dd ? |
.relocs_rva dd ? |
.relocs_size dd ? |
.section_header_size dd ? |
.AddressOfEntryPoint dd ? |
.ImageBase dd ? |
.locals_size = $ - esp |
end virtual |
cmp word [ebx], STRIPPED_PE_SIGNATURE |
jz .stripped |
mov edx, ebx |
add edx, [ebx+60] |
movzx eax, word [edx+6] |
mov [.numsections], eax |
mov eax, [edx+40] |
mov [.AddressOfEntryPoint], eax |
mov eax, [edx+52] |
mov [.ImageBase], eax |
mov ecx, [edx+84] |
mov [.section_header_size], 40 |
mov eax, [edx+128] |
mov [.import_descr], eax |
mov eax, [edx+160] |
mov [.relocs_rva], eax |
mov eax, [edx+164] |
mov [.relocs_size], eax |
add edx, 256 |
jmp .common |
.stripped: |
mov eax, [ebx+STRIPPED_PE_HEADER.AddressOfEntryPoint] |
mov [.AddressOfEntryPoint], eax |
mov eax, [ebx+STRIPPED_PE_HEADER.ImageBase] |
mov [.ImageBase], eax |
movzx eax, [ebx+STRIPPED_PE_HEADER.NumberOfSections] |
mov [.numsections], eax |
movzx ecx, [ebx+STRIPPED_PE_HEADER.NumberOfRvaAndSizes] |
xor eax, eax |
mov [.relocs_rva], eax |
mov [.relocs_size], eax |
test ecx, ecx |
jz @f |
mov eax, [ebx+sizeof.STRIPPED_PE_HEADER+SPE_DIRECTORY_IMPORT*8] |
@@: |
mov [.import_descr], eax |
cmp ecx, SPE_DIRECTORY_BASERELOC |
jbe @f |
mov eax, [ebx+sizeof.STRIPPED_PE_HEADER+SPE_DIRECTORY_BASERELOC*8] |
mov [.relocs_rva], eax |
mov eax, [ebx+sizeof.STRIPPED_PE_HEADER+SPE_DIRECTORY_BASERELOC*8+4] |
mov [.relocs_size], eax |
@@: |
mov [.section_header_size], 28 |
lea edx, [ebx+ecx*8+sizeof.STRIPPED_PE_HEADER+8] |
mov ecx, [ebx+STRIPPED_PE_HEADER.SizeOfHeaders] |
.common: |
mov esi, ebx |
add edx, DWORD PTR [ebx+60] |
mov edi, ebp |
mov DWORD PTR [esp+32], edx |
mov ecx, DWORD PTR [edx+84] |
shr ecx, 2 |
rep movsd |
movzx eax, WORD PTR [edx+6] |
mov DWORD PTR [esp+36], 0 |
mov DWORD PTR [esp+16], eax |
jmp L2 |
L3: |
mov eax, DWORD PTR [edx+264] |
cmp [.numsections], 0 |
jz .nosections |
.copy_sections: |
mov eax, [edx+8] |
test eax, eax |
je L4 |
je .no_section_data |
mov esi, ebx |
mov edi, ebp |
add esi, DWORD PTR [edx+268] |
add esi, [edx+12] |
mov ecx, eax |
add edi, DWORD PTR [edx+260] |
add edi, [edx+4] |
add ecx, 3 |
shr ecx, 2 |
rep movsd |
L4: |
mov ecx, DWORD PTR [edx+256] |
.no_section_data: |
mov ecx, [edx] |
cmp ecx, eax |
jbe L6 |
jbe .no_section_fill |
sub ecx, eax |
add eax, DWORD PTR [edx+260] |
add eax, [edx+4] |
lea edi, [eax+ebp] |
xor eax, eax |
rep stosb |
L6: |
inc DWORD PTR [esp+36] |
add edx, 40 |
L2: |
mov esi, DWORD PTR [esp+16] |
cmp DWORD PTR [esp+36], esi |
jne L3 |
mov edi, DWORD PTR [esp+32] |
cmp DWORD PTR [edi+164], 0 |
je L9 |
pushd [edi+164] |
.no_section_fill: |
add edx, [.section_header_size] |
dec [.numsections] |
jnz .copy_sections |
.nosections: |
cmp [.relocs_size], 0 |
je .no_relocations |
mov esi, ebp |
mov ecx, ebp |
sub esi, DWORD PTR [edi+52] |
add ecx, DWORD PTR [edi+160] |
mov eax, esi |
shr eax, 16 |
mov DWORD PTR [esp+16], eax |
L12: |
mov eax, [ecx+4] |
sub [esp], eax |
lea ebx, [eax-8] |
xor edi, edi |
sub esi, [.ImageBase] |
add ecx, [.relocs_rva] |
.relocs_block: |
mov edi, [ecx] |
add edi, ebp |
mov ebx, [ecx+4] |
add ecx, 8 |
sub [.relocs_size], ebx |
sub ebx, 8 |
shr ebx, 1 |
jmp L13 |
L14: |
movzx eax, WORD PTR [ecx+8+edi*2] |
jz .relocs_next_block |
.one_reloc: |
movzx eax, word [ecx] |
add ecx, 2 |
mov edx, eax |
shr eax, 12 |
and edx, 4095 |
add edx, DWORD PTR [ecx] |
cmp ax, 2 |
je L17 |
cmp ax, 3 |
je L18 |
dec ax |
jne L15 |
mov eax, DWORD PTR [esp+16] |
add WORD PTR [edx+ebp], ax |
L17: |
add WORD PTR [edx+ebp], si |
L18: |
add DWORD PTR [edx+ebp], esi |
L15: |
inc edi |
L13: |
cmp edi, ebx |
jne L14 |
add ecx, DWORD PTR [ecx+4] |
L11: |
cmp dword [esp], 0 |
jg L12 |
pop eax |
L9: |
mov edx, DWORD PTR [esp+32] |
cmp DWORD PTR [edx+132], 0 |
je L20 |
mov eax, ebp |
add eax, DWORD PTR [edx+128] |
mov DWORD PTR [esp+40], 0 |
add eax, 20 |
mov DWORD PTR [esp+56], eax |
L22: |
mov ecx, DWORD PTR [esp+56] |
cmp DWORD PTR [ecx-16], 0 |
jne L23 |
cmp DWORD PTR [ecx-8], 0 |
je L25 |
L23: |
mov edi, DWORD PTR [__exports+32] |
mov esi, DWORD PTR [__exports+28] |
mov eax, DWORD PTR [esp+56] |
mov DWORD PTR [esp+20], edi |
add edi, OS_BASE |
add esi, OS_BASE |
mov DWORD PTR [esp+44], esi |
mov ecx, DWORD PTR [eax-4] |
mov DWORD PTR [esp+48], edi |
mov edx, DWORD PTR [eax-20] |
cmp eax, 3 |
jne @f |
add [edx+edi], esi |
@@: |
dec ebx |
jnz .one_reloc |
.relocs_next_block: |
cmp [.relocs_size], 0 |
jg .relocs_block |
.no_relocations: |
cmp [.import_descr], 0 |
je .no_imports |
add [.import_descr], ebp |
mov [.bad_import], 0 |
.import_block: |
mov ecx, [.import_descr] |
cmp dword [ecx+4], 0 |
jne @f |
cmp dword [ecx+12], 0 |
je .done_imports |
@@: |
mov edx, dword [ecx] |
mov ecx, dword [ecx+16] |
test edx, edx |
jnz @f |
mov edx, ecx |
@@: |
mov DWORD PTR [esp+52], 0 |
mov [.import_idx], 0 |
add ecx, ebp |
add edx, ebp |
mov DWORD PTR [esp+24], edx |
mov DWORD PTR [esp+28], ecx |
L26: |
mov esi, DWORD PTR [esp+52] |
mov edi, DWORD PTR [esp+24] |
mov eax, DWORD PTR [edi+esi*4] |
mov [.import_names], edx |
mov [.import_targets], ecx |
.import_func: |
mov esi, [.import_idx] |
mov edi, [.import_names] |
mov eax, [edi+esi*4] |
test eax, eax |
je L27 |
test eax, eax |
js L27 |
je .next_import_block |
js .next_import_block |
lea edi, [ebp+eax] |
mov eax, DWORD PTR [esp+28] |
mov DWORD PTR [eax+esi*4], 0 |
mov eax, [.import_targets] |
mov dword [eax+esi*4], 0 |
lea esi, [edi+2] |
push eax |
movzx ebx, word [edi] |
push 32 |
movzx eax, WORD PTR [edi] |
mov edx, DWORD PTR [esp+56] |
mov eax, DWORD PTR [edx+eax*4] |
mov ecx, [__exports+32] |
mov eax, [ecx+OS_BASE+ebx*4] |
add eax, OS_BASE |
push eax |
push esi |
call strncmp |
pop ebx |
test eax, eax |
jz .import_func_found |
xor ebx, ebx |
test eax, eax |
jne L32 |
jmp L30 |
L33: |
push ecx |
.import_func_candidate: |
push 32 |
mov ecx, DWORD PTR [esp+28] |
mov eax, DWORD PTR [ecx+OS_BASE+ebx*4] |
mov ecx, [__exports+32] |
mov eax, [ecx+OS_BASE+ebx*4] |
add eax, OS_BASE |
push eax |
push esi |
call strncmp |
pop edx |
test eax, eax |
jne L34 |
mov esi, DWORD PTR [esp+44] |
mov edx, DWORD PTR [esp+52] |
mov ecx, DWORD PTR [esp+28] |
mov eax, DWORD PTR [esi+ebx*4] |
add eax, OS_BASE |
mov DWORD PTR [ecx+edx*4], eax |
jmp L36 |
L34: |
je .import_func_found |
inc ebx |
L32: |
cmp ebx, DWORD PTR [__exports+24] |
jb L33 |
L36: |
cmp ebx, DWORD PTR [__exports+24] |
jne L37 |
cmp ebx, [__exports+24] |
jb .import_func_candidate |
mov esi, msg_unresolved |
call sys_msg_board_str |
249,34 → 265,30 |
mov esi, msg_CR |
call sys_msg_board_str |
mov DWORD PTR [esp+40], 1 |
jmp L37 |
L30: |
movzx eax, WORD PTR [edi] |
mov esi, DWORD PTR [esp+44] |
mov edi, DWORD PTR [esp+52] |
mov edx, DWORD PTR [esp+28] |
mov eax, DWORD PTR [esi+eax*4] |
mov [.bad_import], 1 |
jmp .next_import_func |
.import_func_found: |
mov esi, [__exports+28] |
mov edx, [.import_idx] |
mov ecx, [.import_targets] |
mov eax, [esi+OS_BASE+ebx*4] |
add eax, OS_BASE |
mov DWORD PTR [edx+edi*4], eax |
L37: |
inc DWORD PTR [esp+52] |
jmp L26 |
L27: |
add DWORD PTR [esp+56], 20 |
jmp L22 |
L25: |
mov [ecx+edx*4], eax |
.next_import_func: |
inc [.import_idx] |
jmp .import_func |
.next_import_block: |
add [.import_descr], 20 |
jmp .import_block |
.done_imports: |
xor eax, eax |
cmp DWORD PTR [esp+40], 0 |
jne L40 |
L20: |
mov ecx, DWORD PTR [esp+32] |
cmp [.bad_import], 0 |
jne @f |
.no_imports: |
mov eax, ebp |
add eax, DWORD PTR [ecx+40] |
L40: |
add esp, 60 |
pop ebx |
add eax, [.AddressOfEntryPoint] |
@@: |
add esp, .locals_size |
pop esi |
pop edi |
pop ebp |
ret 8 |
ret |
/kernel/branches/kolibri-process/data32.inc |
---|
140,24 → 140,20 |
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 |
msg_unresolved db 'unresolved ',0 |
msg_module db 'in module ',0 |
if ~ lang eq sp |
msg_version db 'incompatible driver version',13,10,0 |
msg_www db 'please visit www.kolibrios.org',13,10,0 |
end if |
;msg_module db 'in module ',0 |
;if ~ lang eq sp |
;msg_version db 'incompatible driver version',13,10,0 |
;msg_www db 'please visit www.kolibrios.org',13,10,0 |
;end if |
msg_CR db 13,10,0 |
intel_str db "GenuineIntel",0 |
AMD_str db "AuthenticAMD",0 |
szHwMouse db 'ATI2D',0 |
szPS2MDriver db 'PS2MOUSE',0 |
szPS2MDriver db '/rd/1/drivers/PS2MOUSE.SYS',0 |
;szCOM_MDriver db 'COM_MOUSE',0 |
szVidintel db 'vidintel',0 |
szVidintel db '/rd/1/drivers/vidintel.sys',0 |
szUSB db 'USB',0 |
szAtiHW db '/rd/1/drivers/ati2d.drv',0 |
szSTART db 'START',0 |
szEXPORTS db 'EXPORTS',0 |
sz_EXPORTS db '_EXPORTS',0 |
529,16 → 525,21 |
org (OS_BASE+0x0100000) |
RAMDISK: rb 2880*512 |
rb 2856*4 ; not used |
; Currently size of memory allocated for the ramdisk is fixed. |
; This should be revisited when/if memory map would become more dynamic. |
RAMDISK_CAPACITY = 2880 ; in sectors |
RAMDISK: rb RAMDISK_CAPACITY*512 |
_CLEAN_ZONE: |
BgrAuxTable rb 32768 |
align 65536 |
SB16Buffer rb 65536 |
align 4096 |
_IDE_DMA rb 16*512 |
BgrAuxTable rb 32768 |
BUTTON_INFO rb 64*1024 |
RESERVED_PORTS: rb 64*1024 |
FLOPPY_BUFF: rb 18*512 ;one track |
sys_pgmap: rb 1024*1024/8 |
/kernel/branches/kolibri-process/data32sp.inc |
---|
47,8 → 47,8 |
boot_tasking: cp850 'Todo configurado - presiona ESC para iniciar',0 |
end if |
msg_version: cp850 'versión incompatible del controlador',13,10,0 |
msg_www: cp850 'por favor, visita www.kolibrios.org',13,10,0 |
;msg_version: cp850 'versión incompatible del controlador',13,10,0 |
;msg_www: cp850 'por favor, visita www.kolibrios.org',13,10,0 |
ud_user_message:cp850 'Error: instrucción no soportada por el procesador',0 |
mtrr_user_message cp850 '"There is a problem with MTRR configuration.\nPerformance can be low" -dW',0 |
/kernel/branches/kolibri-process/detect/dev_hdcd.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3881 $ |
$Revision: 5030 $ |
;****************************************************** |
68,6 → 68,8 |
push ebx ecx |
call ReadHDD_ID |
pop ecx ebx |
cmp [DevErrorCode], 7 |
je .end |
cmp [DevErrorCode], 0 |
jne .FindCD |
274,7 → 276,7 |
; интервал ожидания, 2 - неверный код режима адресации, |
; 3 - неверный номер канала, 4 - неверный номер диска, |
; 5 - неверный номер головки, 6 - ошибка при выполнении |
; команды) |
; команды, 7 - таймаут при выборе канала) |
DevErrorCode dd ? |
endg |
;----------------------------------------------------------------------------- |
380,7 → 382,7 |
ret |
; Записать код ошибки |
@@Err1: |
mov [DevErrorCode], 1 |
mov [DevErrorCode], 7 |
ret |
@@Err2: |
mov [DevErrorCode], 2 |
/kernel/branches/kolibri-process/detect/getcache.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3742 $ |
$Revision: 4711 $ |
;----------------------------------------------------------------------------- |
pusha |
/kernel/branches/kolibri-process/detect/sear_par.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3742 $ |
$Revision: 4711 $ |
search_partitions: |
push ecx |
/kernel/branches/kolibri-process/encoding.inc |
---|
5,154 → 5,129 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4850 $ |
$Revision: 5082 $ |
; fetch the UTF-8 character in string+offs to char |
; common part for all encodings: translate pseudographics |
; Pseudographics for the boot screen: |
; 0x2500 -> 0xC4, 0x2502 -> 0xB3, 0x250C -> 0xDA, 0x2510 -> 0xBF, |
; 0x2514 -> 0xC0, 0x2518 -> 0xD9, 0x252C -> 0xC2, 0x2534 -> 0xC1, 0x2551 -> 0xBA |
macro fetch_utf8_char string, offs, char, graph |
; fetch the UTF-8 character in addrspace:offs to char |
macro fetch_utf8_char addrspace, offs, char |
{ local first_byte, b |
virtual at 0 |
db string |
if offs >= $ |
char = -1 |
else |
; fetch first byte |
load first_byte byte from offs |
load first_byte byte from addrspace:offs |
if first_byte < 0x80 |
char = first_byte |
offs = offs + 1 |
else if first_byte < 0xC0 |
.err Invalid UTF-8 string |
err Invalid UTF-8 string |
else if first_byte < 0xE0 |
char = first_byte and 0x1F |
load b byte from offs + 1 |
load b byte from addrspace:offs + 1 |
char = (char shl 6) + (b and 0x3F) |
offs = offs + 2 |
else if first_byte < 0xF0 |
char = first_byte and 0xF |
load b byte from offs + 1 |
load b byte from addrspace:offs + 1 |
char = (char shl 6) + (b and 0x3F) |
load b byte from offs + 2 |
load b byte from addrspace:offs + 2 |
char = (char shl 6) + (b and 0x3F) |
offs = offs + 3 |
else if first_byte < 0xF8 |
char = first_byte and 0x7 |
load b byte from offs + 1 |
load b byte from addrspace:offs + 1 |
char = (char shl 6) + (b and 0x3F) |
load b byte from offs + 2 |
load b byte from addrspace:offs + 2 |
char = (char shl 6) + (b and 0x3F) |
load b byte from offs + 3 |
load b byte from addrspace:offs + 3 |
char = (char shl 6) + (b and 0x3F) |
offs = offs + 4 |
else |
.err Invalid UTF-8 string |
err Invalid UTF-8 string |
end if |
end if |
} |
; Worker macro for all encodings. |
; Common part for all encodings: map characters 0-0x7F trivially, |
; translate pseudographics. |
; Pseudographics for the boot screen: |
; 0x2500 -> 0xC4, 0x2502 -> 0xB3, 0x250C -> 0xDA, 0x2510 -> 0xBF, |
; 0x2514 -> 0xC0, 0x2518 -> 0xD9, 0x252C -> 0xC2, 0x2534 -> 0xC1, 0x2551 -> 0xBA |
macro convert_utf8 encoding, [arg] |
{ common |
local ..addrspace, offs, char |
offs = 0 |
virtual at 0 |
..addrspace:: db arg |
..addrspace#.size = $ |
end virtual |
while offs < ..addrspace#.size |
fetch_utf8_char ..addrspace, offs, char |
if char = 0x2500 |
graph = 0xC4 |
db 0xC4 |
else if char = 0x2502 |
graph = 0xB3 |
db 0xB3 |
else if char = 0x250C |
graph = 0xDA |
db 0xDA |
else if char = 0x2510 |
graph = 0xBF |
db 0xBF |
else if char = 0x2514 |
graph = 0xC0 |
db 0xC0 |
else if char = 0x2518 |
graph = 0xD9 |
db 0xD9 |
else if char = 0x252C |
graph = 0xC2 |
db 0xC2 |
else if char = 0x2534 |
graph = 0xC1 |
db 0xC1 |
else if char = 0x2551 |
graph = 0xBA |
db 0xBA |
else if char < 0x80 |
db char |
else |
graph = 0 |
encoding char |
end if |
end while |
} |
macro declare_encoding encoding |
{ |
macro encoding [arg] |
\{ common convert_utf8 encoding#char, arg \} |
struc encoding [arg] |
\{ common convert_utf8 encoding#char, arg \} |
macro encoding#char char |
} |
; Russian: use CP866. |
; 0x00-0x7F - trivial map |
; 0x410-0x43F -> 0x80-0xAF |
; 0x440-0x44F -> 0xE0-0xEF |
; 0x401 -> 0xF0, 0x451 -> 0xF1 |
macro cp866 [arg] |
{ local offs, char, graph |
offs = 0 |
while 1 |
fetch_utf8_char arg, offs, char, graph |
if char = -1 |
break |
end if |
if graph |
db graph |
else if char < 0x80 |
db char |
else if char = 0x401 |
declare_encoding cp866 |
{ |
if char = 0x401 |
db 0xF0 |
else if char = 0x451 |
db 0xF1 |
else if (char < 0x410) | (char > 0x44F) |
.err Failed to convert to CP866 |
err Failed to convert to CP866 |
else if char < 0x440 |
db char - 0x410 + 0x80 |
else |
db char - 0x440 + 0xE0 |
end if |
end while |
} |
struc cp866 [arg] |
{ |
common |
cp866 arg |
} |
; Latin-1 encoding |
; 0x00-0xFF - trivial map |
macro latin1 [arg] |
{ local offs, char, graph |
offs = 0 |
while 1 |
fetch_utf8_char arg, offs, char, graph |
if char = -1 |
break |
end if |
if graph |
db graph |
else if char < 0x100 |
declare_encoding latin1 |
{ |
if char < 0x100 |
db char |
else |
.err Failed to convert to Latin-1 |
err Failed to convert to Latin-1 |
end if |
end while |
} |
struc latin1 [arg] |
; CP850 encoding |
declare_encoding cp850 |
{ |
common |
latin1 arg |
} |
; CP850 encoding |
macro cp850 [arg] |
{ local offs, char, graph |
offs = 0 |
while 1 |
fetch_utf8_char arg, offs, char, graph |
if char = -1 |
break |
end if |
if graph |
db graph |
else if char < 0x80 |
db char |
else if char = 0xBF |
if char = 0xBF |
db 0xA8 |
else if char = 0xE1 |
db 0xA0 |
167,11 → 142,4 |
else |
err Failed to convert to CP850 |
end if |
end while |
} |
struc cp850 [arg] |
{ |
common |
cp850 arg |
} |
/kernel/branches/kolibri-process/fs/ext2/ext2.asm |
---|
7,7 → 7,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4891 $ |
$Revision: 5089 $ |
include 'ext2.inc' |
59,6 → 59,8 |
;--------------------------------------------------------------------- |
proc ext2_create_partition |
push ebx |
cmp dword [esi+DISK.MediaInfo.SectorSize], 512 |
jnz .fail |
mov eax, 2 ; Superblock starts at 1024-bytes. |
add ebx, 512 ; Get pointer to fs-specific buffer. |
/kernel/branches/kolibri-process/fs/fat.inc |
---|
44,7 → 44,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4273 $ |
$Revision: 5089 $ |
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00 |
154,6 → 154,9 |
xor eax, eax |
ret |
fat_create_partition: |
; sector size must be 512 |
cmp dword [esi+DISK.MediaInfo.SectorSize], 512 |
jnz .return0 |
; bootsector must have been successfully read |
cmp dword [esp+4], 0 |
jnz .return0 |
/kernel/branches/kolibri-process/fs/fs_lfn.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4277 $ |
$Revision: 4700 $ |
ERROR_SUCCESS = 0 |
ERROR_DISK_BASE = 1 |
/kernel/branches/kolibri-process/fs/ntfs.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3742 $ |
$Revision: 5089 $ |
struct NTFS PARTITION |
Lock MUTEX ? ; currently operations with one partition |
152,6 → 152,8 |
ret |
proc ntfs_create_partition |
cmp dword [esi+DISK.MediaInfo.SectorSize], 512 |
jnz .nope |
mov edx, dword [ebp+PARTITION.Length] |
cmp dword [esp+4], 0 |
jz .boot_read_ok |
/kernel/branches/kolibri-process/fs/xfs.asm |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4850 $ |
$Revision: 5089 $ |
include 'xfs.inc' |
25,6 → 25,8 |
; returns 0 (not XFS or invalid) / pointer to partition structure |
xfs_create_partition: |
push ebx ecx edx esi edi |
cmp dword [esi+DISK.MediaInfo.SectorSize], 512 |
jnz .error |
cmp dword[ebx + xfs_sb.sb_magicnum], XFS_SB_MAGIC ; signature |
jne .error |
/kernel/branches/kolibri-process/hid/keyboard.inc |
---|
5,7 → 5,7 |
;; Distributed under terms of the GNU General Public License ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3598 $ |
$Revision: 5027 $ |
VKEY_LSHIFT = 0000000000000001b |
25,8 → 25,6 |
VKEY_ALT = 0000000000110000b |
uglobal |
align 4 |
kb_state dd 0 |
ext_code db 0 |
keyboard_mode db 0 |
35,7 → 33,6 |
altmouseb db 0 |
ctrl_alt_del db 0 |
kb_lights db 0 |
old_kb_lights db 0 |
align 4 |
45,6 → 42,13 |
endg |
iglobal |
kb_lights db 2 |
align 4 |
kb_state dd VKEY_NUMLOCK |
endg |
iglobal |
align 4 |
hotkey_tests dd hotkey_test0 |
dd hotkey_test1 |
dd hotkey_test2 |
551,9 → 555,9 |
ps2_set_lights: |
stdcall disable_irq, 1 |
mov al, 0xED |
call kb_write |
call kb_write_wait_ack |
mov al, [esp+8] |
call kb_write |
call kb_write_wait_ack |
stdcall enable_irq, 1 |
ret 8 |
/kernel/branches/kolibri-process/hid/mousedrv.inc |
---|
5,7 → 5,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3606 $ |
$Revision: 4592 $ |
; check mouse |
/kernel/branches/kolibri-process/init.inc |
---|
345,9 → 345,6 |
proc test_cpu |
locals |
cpu_type dd ? |
cpu_id dd ? |
cpu_Intel dd ? |
cpu_AMD dd ? |
endl |
xor eax, eax |
386,13 → 383,7 |
mov [cpu_vendor-OS_BASE], ebx |
mov [cpu_vendor+4-OS_BASE], edx |
mov [cpu_vendor+8-OS_BASE], ecx |
cmp ebx, dword [intel_str-OS_BASE] |
jne .check_AMD |
cmp edx, dword [intel_str+4-OS_BASE] |
jne .check_AMD |
cmp ecx, dword [intel_str+8-OS_BASE] |
jne .check_AMD |
mov [cpu_Intel], 1 |
cmp eax, 1 |
jl .end_cpuid |
mov eax, 1 |
422,36 → 413,6 |
.end_cpuid: |
mov eax, [cpu_type] |
ret |
.check_AMD: |
cmp ebx, dword [AMD_str-OS_BASE] |
jne .unknown |
cmp edx, dword [AMD_str+4-OS_BASE] |
jne .unknown |
cmp ecx, dword [AMD_str+8-OS_BASE] |
jne .unknown |
mov [cpu_AMD], 1 |
cmp eax, 1 |
jl .unknown |
mov eax, 1 |
cpuid |
mov [cpu_sign-OS_BASE], eax |
mov [cpu_info-OS_BASE], ebx |
mov [cpu_caps-OS_BASE], edx |
mov [cpu_caps+4-OS_BASE], ecx |
shr eax, 8 |
and eax, 0x0f |
ret |
.unknown: |
mov eax, 1 |
cpuid |
mov [cpu_sign-OS_BASE], eax |
mov [cpu_info-OS_BASE], ebx |
mov [cpu_caps-OS_BASE], edx |
mov [cpu_caps+4-OS_BASE], ecx |
shr eax, 8 |
and eax, 0x0f |
ret |
endp |
iglobal |
/kernel/branches/kolibri-process/kernel.asm |
---|
74,8 → 74,6 |
$Revision: 4381 $ |
USE_FIX_FOR_INVALID_MS_VIRTUAL_PC_2007 equ 0 |
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
283,6 → 281,25 |
org $-0x10000 |
include "boot/shutdown.inc" ; shutdown or restart |
org $+0x10000 |
ap_init16: |
cli |
lgdt [cs:gdts_ap-ap_init16] |
mov eax, [cs:cr3_ap-ap_init16] |
mov cr3, eax |
mov eax, [cs:cr4_ap-ap_init16] |
mov cr4, eax |
mov eax, CR0_PE+CR0_PG+CR0_WP |
mov cr0, eax |
jmp pword os_code:ap_init_high |
align 16 |
gdts_ap: |
dw gdte-gdts-1 |
dd gdts |
dw 0 |
cr3_ap dd ? |
cr4_ap dd ? |
ap_init16_size = $ - ap_init16 |
use32 |
__DEBUG__ fix 1 |
668,7 → 685,70 |
mov dword [current_slot], SLOT_BASE + 256*2 |
mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
; Move other CPUs to deep sleep, if it is useful |
uglobal |
use_mwait_for_idle db 0 |
endg |
cmp [cpu_vendor+8], 'ntel' |
jnz .no_wake_cpus |
bt [cpu_caps+4], CAPS_MONITOR-32 |
jnc .no_wake_cpus |
dbgstr 'using mwait for idle loop' |
inc [use_mwait_for_idle] |
mov ebx, [cpu_count] |
cmp ebx, 1 |
jbe .no_wake_cpus |
call create_trampoline_pgmap |
mov [cr3_ap+OS_BASE], eax |
mov eax, cr4 |
mov [cr4_ap+OS_BASE], eax |
mov esi, OS_BASE + ap_init16 |
mov edi, OS_BASE + 8000h |
mov ecx, (ap_init16_size + 3) / 4 |
rep movsd |
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE |
mov [LAPIC_BASE], eax |
lea edi, [eax+300h] |
mov esi, smpt+4 |
dec ebx |
.wake_cpus_loop: |
lodsd |
push esi |
xor esi, esi |
inc esi |
shl eax, 24 |
mov [edi+10h], eax |
; assert INIT IPI |
mov dword [edi], 0C500h |
call delay_ms |
@@: |
test dword [edi], 1000h |
jnz @b |
; deassert INIT IPI |
mov dword [edi], 8500h |
call delay_ms |
@@: |
test dword [edi], 1000h |
jnz @b |
; send STARTUP IPI |
mov dword [edi], 600h + (8000h shr 12) |
call delay_ms |
@@: |
test dword [edi], 1000h |
jnz @b |
pop esi |
dec ebx |
jnz .wake_cpus_loop |
mov eax, [cpu_count] |
dec eax |
@@: |
cmp [ap_initialized], eax |
jnz @b |
mov eax, [cr3_ap+OS_BASE] |
call free_page |
.no_wake_cpus: |
; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
mov esi, boot_initirq |
call boot_log |
681,11 → 761,6 |
mov esi, boot_v86machine |
call boot_log |
; Initialize system V86 machine |
; call init_sys_v86 |
xchg bx, bx |
; call v86_init |
call init_sys_v86 |
mov esi, boot_inittimer |
838,7 → 913,7 |
include "detect/vortex86.inc" ; Vortex86 SoC detection code |
stdcall load_driver, szVidintel |
stdcall load_pe_driver, szVidintel, 0 |
call usb_init |
877,6 → 952,7 |
mov esi, 250 ; wait 1/4 a second |
call delay_ms |
rdtsc |
sti |
sub eax, ecx |
xor edx, edx |
944,39 → 1020,12 |
stdcall map_page, tss._io_map_1, \ |
[SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
; LOAD FIRST APPLICATION |
cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
jnz first_app_found |
cli |
mov ebp, firstapp |
call fs_execute_from_sysdir |
test eax, eax |
jns first_app_found |
mov esi, boot_failed |
call boot_log |
mov eax, 0xDEADBEEF ; otherwise halt |
hlt |
first_app_found: |
cli |
; SET KEYBOARD PARAMETERS |
mov al, 0xf6 ; reset keyboard, scan enabled |
call kb_write |
call kb_write_wait_ack |
test ah, ah |
jnz .no_keyboard |
; wait until 8042 is ready |
xor ecx, ecx |
@@: |
in al, 64h |
and al, 00000010b |
loopnz @b |
iglobal |
align 4 |
ps2_keyboard_functions: |
987,18 → 1036,14 |
endg |
stdcall register_keyboard, ps2_keyboard_functions, 0 |
; mov al, 0xED ; Keyboard LEDs - only for testing! |
; call kb_write |
; call kb_read |
; call kb_write_wait_ack |
; mov al, 111b |
; call kb_write |
; call kb_read |
; call kb_write_wait_ack |
mov al, 0xF3 ; set repeat rate & delay |
call kb_write |
; call kb_read |
call kb_write_wait_ack |
mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
call kb_write |
; call kb_read |
call kb_write_wait_ack |
;// mike.dld [ |
call set_lights |
;// mike.dld ] |
1008,12 → 1053,30 |
; Load PS/2 mouse driver |
stdcall load_driver, szPS2MDriver |
stdcall load_pe_driver, szPS2MDriver, 0 |
mov esi, boot_setmouse |
call boot_log |
call setmouse |
; LOAD FIRST APPLICATION |
cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
jnz first_app_found |
cli |
mov ebp, firstapp |
call fs_execute_from_sysdir |
test eax, eax |
jns first_app_found |
mov esi, boot_failed |
call boot_log |
mov eax, 0xDEADBEEF ; otherwise halt |
hlt |
first_app_found: |
; START MULTITASKING |
; A 'All set - press ESC to start' messages if need |
1037,6 → 1100,27 |
; Fly :) |
uglobal |
align 4 |
ap_initialized dd 0 |
endg |
ap_init_high: |
mov ax, os_stack |
mov bx, app_data |
mov cx, app_tls |
mov ss, ax |
mov ds, bx |
mov es, bx |
mov fs, cx |
mov gs, bx |
xor esp, esp |
mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
mov cr3, eax |
lock inc [ap_initialized] |
jmp idle_loop |
include 'unpacker.inc' |
align 4 |
1171,13 → 1255,35 |
osloop_nonperiodic_work dd ? |
endg |
align 4 |
uglobal |
align 64 |
idle_addr rb 64 |
endg |
idle_thread: |
sti |
; The following code can be executed by all CPUs in the system. |
; All other parts of the kernel do not expect multi-CPU. |
; Also, APs don't even have a stack here. |
; Beware. Don't do anything here. Anything at all. |
idle_loop: |
cmp [use_mwait_for_idle], 0 |
jnz idle_loop_mwait |
idle_loop_hlt: |
hlt |
jmp idle_loop |
jmp idle_loop_hlt |
idle_loop_mwait: |
mov eax, idle_addr |
xor ecx, ecx |
xor edx, edx |
monitor |
xor ecx, ecx |
mov eax, 20h ; or 10h |
mwait |
jmp idle_loop_mwait |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2246,10 → 2352,10 |
;* mouse centered - start code- Mario79 |
;mouse_centered: |
; push eax |
mov eax, [_display.width] |
mov eax, [Screen_Max_X] |
shr eax, 1 |
mov [MOUSE_X], ax |
mov eax, [_display.height] |
mov eax, [Screen_Max_Y] |
shr eax, 1 |
mov [MOUSE_Y], ax |
call wakeup_osloop |
2291,11 → 2397,11 |
; cmp ecx,4 ; set mouse pointer position |
dec ecx |
jnz .set_mouse_button |
cmp dx, word[_display.height] |
jae .end |
cmp dx, word[Screen_Max_Y] |
ja .end |
rol edx, 16 |
cmp dx, word[_display.width] |
jae .end |
cmp dx, word[Screen_Max_X] |
ja .end |
mov [MOUSE_X], edx |
mov [mouse_active], 1 |
call wakeup_osloop |
2722,22 → 2828,22 |
jnz nosb9 |
; ecx = [left]*65536 + [right] |
; edx = [top]*65536 + [bottom] |
mov eax, [_display.width] |
mov ebx, [_display.height] |
mov eax, [Screen_Max_X] |
mov ebx, [Screen_Max_Y] |
; check [right] |
cmp cx, ax |
jae .exit |
ja .exit |
; check [left] |
ror ecx, 16 |
cmp cx, ax |
jae .exit |
ja .exit |
; check [bottom] |
cmp dx, bx |
jae .exit |
ja .exit |
; check [top] |
ror edx, 16 |
cmp dx, bx |
jae .exit |
ja .exit |
movzx eax, cx ; [left] |
movzx ebx, dx ; [top] |
4463,114 → 4569,40 |
; ret |
;----------------------------------------------------------------------------- |
align 4 |
kb_read: |
kb_write_wait_ack: |
push ecx edx |
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
kr_loop: |
in al, 0x64 |
test al, 1 |
jnz kr_ready |
loop kr_loop |
mov ah, 1 |
jmp kr_exit |
kr_ready: |
push ecx |
mov ecx, 32 |
kr_delay: |
loop kr_delay |
pop ecx |
in al, 0x60 |
xor ah, ah |
kr_exit: |
pop edx ecx |
ret |
;----------------------------------------------------------------------------- |
align 4 |
kb_write: |
push ecx edx |
mov dl, al |
; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
; kw_loop1: |
; in al,0x64 |
; test al,0x20 |
; jz kw_ok1 |
; loop kw_loop1 |
; mov ah,1 |
; jmp kw_exit |
; kw_ok1: |
in al, 0x60 |
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
kw_loop: |
.wait_output_ready: |
in al, 0x64 |
test al, 2 |
jz kw_ok |
loop kw_loop |
jz @f |
loop .wait_output_ready |
mov ah, 1 |
jmp kw_exit |
kw_ok: |
jmp .nothing |
@@: |
mov al, dl |
out 0x60, al |
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
kw_loop3: |
mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
.wait_ack: |
in al, 0x64 |
test al, 2 |
jz kw_ok3 |
loop kw_loop3 |
test al, 1 |
jnz @f |
loop .wait_ack |
mov ah, 1 |
jmp kw_exit |
kw_ok3: |
mov ah, 8 |
kw_loop4: |
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
kw_loop5: |
in al, 0x64 |
test al, 1 |
jnz kw_ok4 |
loop kw_loop5 |
dec ah |
jnz kw_loop4 |
kw_ok4: |
jmp .nothing |
@@: |
in al, 0x60 |
xor ah, ah |
kw_exit: |
.nothing: |
pop edx ecx |
ret |
;----------------------------------------------------------------------------- |
align 4 |
kb_cmd: |
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
c_wait: |
in al, 0x64 |
test al, 2 |
jz c_send |
loop c_wait |
jmp c_error |
c_send: |
mov al, bl |
out 0x64, al |
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
c_accept: |
in al, 0x64 |
test al, 2 |
jz c_ok |
loop c_accept |
c_error: |
mov ah, 1 |
jmp c_exit |
c_ok: |
xor ah, ah |
c_exit: |
ret |
setmouse: ; set mousepicture -pointer |
; ps2 mouse enable |
4707,9 → 4739,9 |
jnz @f |
mov word [msg_board_pos+2], (42*6) |
add word [msg_board_pos], 10 |
mov ax, word [_display.height] |
mov ax, word [Screen_Max_Y] |
cmp word [msg_board_pos], ax |
jb @f |
jbe @f |
mov word [msg_board_pos], 10 |
@@: |
; // end if |
5092,10 → 5124,10 |
;----------------------------------------------------------------------------- |
align 4 |
syscall_getpixel_WinMap: ; GetPixel WinMap |
cmp ebx, [_display.width] |
jb @f |
cmp ecx, [_display.height] |
jb @f |
cmp ebx, [Screen_Max_X] |
jbe @f |
cmp ecx, [Screen_Max_Y] |
jbe @f |
xor eax, eax |
jmp .store |
;-------------------------------------- |
5112,7 → 5144,8 |
;----------------------------------------------------------------------------- |
align 4 |
syscall_getpixel: ; GetPixel |
mov ecx, [_display.width] |
mov ecx, [Screen_Max_X] |
inc ecx |
xor edx, edx |
mov eax, ebx |
div ecx |
5487,6 → 5520,39 |
call stop_all_services |
yes_shutdown_param: |
; Shutdown other CPUs, if initialized |
cmp [ap_initialized], 0 |
jz .no_shutdown_cpus |
mov edi, [LAPIC_BASE] |
add edi, 300h |
mov esi, smpt+4 |
mov ebx, [cpu_count] |
dec ebx |
.shutdown_cpus_loop: |
lodsd |
push esi |
xor esi, esi |
inc esi |
shl eax, 24 |
mov [edi+10h], eax |
; assert INIT IPI |
mov dword [edi], 0C500h |
call delay_ms |
@@: |
test dword [edi], 1000h |
jnz @b |
; deassert INIT IPI |
mov dword [edi], 8500h |
call delay_ms |
@@: |
test dword [edi], 1000h |
jnz @b |
; don't send STARTUP IPI: let other CPUs be in wait-for-startup state |
pop esi |
dec ebx |
jnz .shutdown_cpus_loop |
.no_shutdown_cpus: |
cli |
if ~ defined extended_primary_loader |
5510,22 → 5576,6 |
call IRQ_mask_all |
if 0 |
mov word [OS_BASE+0x467+0], pr_mode_exit |
mov word [OS_BASE+0x467+2], 0x1000 |
mov al, 0x0F |
out 0x70, al |
mov al, 0x05 |
out 0x71, al |
mov al, 0xFE |
out 0x64, al |
hlt |
jmp $-1 |
else |
cmp byte [OS_BASE + 0x9030], 2 |
jnz no_acpi_power_off |
5671,21 → 5721,6 |
jmp $ |
no_acpi_power_off: |
mov word [OS_BASE+0x467+0], pr_mode_exit |
mov word [OS_BASE+0x467+2], 0x1000 |
mov al, 0x0F |
out 0x70, al |
mov al, 0x05 |
out 0x71, al |
mov al, 0xFE |
out 0x64, al |
hlt |
jmp $-1 |
scan_rsdp: |
add eax, OS_BASE |
.s: |
5708,8 → 5743,34 |
stc |
.ok: |
ret |
end if |
no_acpi_power_off: |
call create_trampoline_pgmap |
mov cr3, eax |
jmp become_real+0x10000 |
iglobal |
align 4 |
realmode_gdt: |
; selector 0 - not used |
dw 23 |
dd realmode_gdt-OS_BASE |
dw 0 |
; selector 8 - code from 1000:0000 to 1000:FFFF |
dw 0FFFFh |
dw 0 |
db 1 |
db 10011011b |
db 00000000b |
db 0 |
; selector 10h - data from 1000:0000 to 1000:FFFF |
dw 0FFFFh |
dw 0 |
db 1 |
db 10010011b |
db 00000000b |
db 0 |
endg |
if ~ lang eq sp |
diff16 "end of .text segment",0,$ |
end if |
/kernel/branches/kolibri-process/network/ARP.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ARP.INC ;; |
16,7 → 16,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3386 $ |
$Revision: 5015 $ |
ARP_NO_ENTRY = 0 |
ARP_VALID_MAPPING = 1 |
318,10 → 318,9 |
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u device=0x%x\n",\ |
[esp]:1, [esp + 1]:1, [esp + 2]:1, [esp + 3]:1, ebx |
lea eax, [ebx + ETH_DEVICE.mac] ; local device mac |
mov ax, ETHER_PROTO_ARP |
mov ecx, sizeof.ARP_header |
mov edx, ETH_BROADCAST ; broadcast mac |
mov ecx, sizeof.ARP_header |
mov di, ETHER_PROTO_ARP |
call ETH_output |
jz .exit |
/kernel/branches/kolibri-process/network/IPv4.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; IPv4.INC ;; |
16,7 → 16,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3515 $ |
$Revision: 5015 $ |
IPv4_MAX_FRAGMENTS = 64 |
IPv4_MAX_ROUTES = 64 |
576,11 → 576,11 |
; edx = Source IP |
; di = TTL shl 8 + protocol |
; |
; OUT: eax = pointer to buffer start |
; ebx = pointer to device struct (needed for sending procedure) |
; ecx = unchanged (packet size of embedded data) |
; edx = size of complete buffer |
; edi = pointer to start of data (0 on error) |
; OUT: eax = pointer to buffer start / 0 on error |
; ebx = device ptr (send packet through this device) |
; ecx = data length |
; edx = size of complete frame |
; edi = start of IPv4 payload |
; |
;------------------------------------------------------------------ |
align 4 |
594,7 → 594,6 |
push ecx di eax |
call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx |
push edx |
test edi, edi |
jz .loopback |
606,12 → 605,11 |
inc [IPv4_packets_tx + edi] ; update stats |
mov ax, ETHER_PROTO_IPv4 |
mov ebx, [NET_DRV_LIST + edi] |
lea eax, [ebx + ETH_DEVICE.mac] |
mov edx, esp |
mov ecx, [esp + 6 + 8 + 2] |
add ecx, sizeof.IPv4_header |
mov di, ETHER_PROTO_IPv4 |
mov edx, esp |
call ETH_output |
jz .eth_error |
add esp, 6 ; pop the mac out of the stack |
641,18 → 639,18 |
.eth_error: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n" |
add esp, 3*4+2+6 |
xor edi, edi |
xor eax, eax |
ret |
.arp_error: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax |
add esp, 3*4+2 |
xor edi, edi |
xor eax, eax |
ret |
.too_large: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n" |
xor edi, edi |
xor eax, eax |
ret |
.loopback: |
674,7 → 672,7 |
; ecx = data length |
; esi = data ptr |
; |
; OUT: / |
; OUT: eax = -1 on error |
; |
;------------------------------------------------------------------ |
align 4 |
698,15 → 696,13 |
push ax |
inc [IPv4_packets_tx + 4*edi] |
mov ax, ETHER_PROTO_IPv4 |
mov ebx, [NET_DRV_LIST + 4*edi] |
lea eax, [ebx + ETH_DEVICE.mac] |
mov edx, esp |
mov ecx, [esp + 6 + 4] |
add ecx, sizeof.IPv4_header |
mov di, ETHER_PROTO_IPv4 |
mov edx, esp |
call ETH_output |
jz .error |
add esp, 6 ; pop the mac |
mov dword[esp+4+4], edx |
745,7 → 741,7 |
add esp, 8+4+4 |
.too_large: |
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output_raw: Failed\n" |
sub edi, edi |
or eax, -1 |
ret |
794,13 → 790,9 |
.new_fragment: |
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment" |
mov eax, [esp + 3*4] |
mov ax, ETHER_PROTO_IPv4 |
lea ebx, [esp + 4*4] |
mov di , ETHER_PROTO_IPv4 |
call ETH_output |
cmp edi, -1 |
jz .err |
; copy header |
/kernel/branches/kolibri-process/network/IPv6.inc |
---|
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3251 $ |
$Revision: 4850 $ |
struct IPv6_header |
/kernel/branches/kolibri-process/network/PPPoE.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2012-2013. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2012-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; PPPoE.INC ;; |
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4850 $ |
$Revision: 5015 $ |
struct PPPoE_frame |
243,17 → 243,15 |
; |
; PPPoE_output |
; |
; IN: |
; IN: ax = protocol |
; ebx = device ptr |
; ecx = packet size |
; |
; di = protocol |
; |
; OUT: edi = 0 on error, pointer to buffer otherwise |
; eax = buffer start |
; ebx = to device structure |
; ecx = unchanged (packet size of embedded data) |
; OUT: eax = buffer start / 0 on error |
; ebx = device ptr |
; ecx = packet size |
; edx = size of complete buffer |
; edi = start of PPP payload |
; |
;----------------------------------------------------------------- |
align 4 |
261,13 → 259,12 |
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx |
pushw di |
pushw ax |
pushw [PPPoE_SID] |
lea eax, [ebx + ETH_DEVICE.mac] |
mov ax, ETHER_PROTO_PPP_SESSION |
add ecx, PPPoE_frame.Payload + 2 |
lea edx, [PPPoE_MAC] |
add ecx, PPPoE_frame.Payload + 2 |
mov di, ETHER_PROTO_PPP_SESSION |
call ETH_output |
jz .eth_error |
290,8 → 287,7 |
.eth_error: |
add esp, 4 |
xor edi, edi |
xor eax, eax |
ret |
/kernel/branches/kolibri-process/network/ethernet.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; ETHERNET.INC ;; |
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3346 $ |
$Revision: 5015 $ |
ETH_FRAME_MINIMUM = 60 |
ETH_QUEUE_SIZE = 255 |
145,14 → 145,14 |
cmp ax, ETHER_PROTO_ARP |
je ARP_input |
cmp ax, ETHER_PROTO_IPv6 |
je IPv6_input |
; cmp ax, ETHER_PROTO_IPv6 |
; je IPv6_input |
cmp ax, ETHER_PROTO_PPP_DISCOVERY |
je PPPoE_discovery_input |
; cmp ax, ETHER_PROTO_PPP_DISCOVERY |
; je PPPoE_discovery_input |
cmp ax, ETHER_PROTO_PPP_SESSION |
je PPPoE_session_input |
; cmp ax, ETHER_PROTO_PPP_SESSION |
; je PPPoE_session_input |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax |
166,17 → 166,16 |
; |
; ETH_output |
; |
; IN: eax = pointer to source mac |
; IN: ax = protocol |
; ebx = device ptr |
; ecx = packet size |
; ecx = payload size |
; edx = pointer to destination mac |
; di = protocol |
; |
; OUT: edi = 0 on error, pointer to buffer otherwise |
; eax = buffer start |
; ebx = to device structure |
; ecx = unchanged (packet size of embedded data) |
; edx = size of complete buffer |
; OUT: eax = start of ethernet frame / 0 on error |
; ebx = device ptr |
; ecx = payload size |
; edx = ethernet frame size |
; edi = start of ethernet payload |
; |
;----------------------------------------------------------------- |
align 4 |
184,11 → 183,11 |
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx |
cmp ecx, [ebx + NET_DEVICE.mtu] |
cmp ecx, [ebx + ETH_DEVICE.mtu] |
ja .exit |
push ecx |
push di eax edx |
push ax edx |
add ecx, sizeof.ETH_header |
stdcall kernel_alloc, ecx |
199,7 → 198,7 |
pop esi |
movsd |
movsw |
pop esi |
lea esi, [ebx + ETH_DEVICE.mac] |
movsd |
movsw |
pop ax |
222,13 → 221,13 |
.out_of_ram: |
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n" |
add esp, 4+4+2+4 |
sub edi, edi |
add esp, 4+2+4 |
xor eax, eax |
ret |
.exit: |
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n" |
sub edi, edi |
xor eax, eax |
ret |
/kernel/branches/kolibri-process/network/icmp.inc |
---|
16,7 → 16,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 2924 $ |
$Revision: 4892 $ |
; ICMP types & codes |
/kernel/branches/kolibri-process/network/loopback.inc |
---|
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 2891 $ |
$Revision: 4850 $ |
iglobal |
align 4 |
/kernel/branches/kolibri-process/network/queue.inc |
---|
12,7 → 12,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 2305 $ |
$Revision: 4850 $ |
; The Queues implemented by these macros form a ring-buffer. |
; The data to these queue's always looks like this: |
/kernel/branches/kolibri-process/network/socket.inc |
---|
15,7 → 15,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3514 $ |
$Revision: 4850 $ |
struct SOCKET |
/kernel/branches/kolibri-process/network/stack.inc |
---|
21,7 → 21,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3523 $ |
$Revision: 5013 $ |
uglobal |
net_10ms dd ? |
313,10 → 313,15 |
test [net_10ms], 0x3f ; 640ms |
jnz .exit |
TCP_timer_640ms |
ARP_decrease_entry_ttls |
IPv4_decrease_fragment_ttls |
xor edx, edx |
mov eax, [TCP_timer1_event] |
mov ebx, [eax + EVENT.id] |
xor esi, esi |
call raise_event |
.exit: |
ret |
/kernel/branches/kolibri-process/network/tcp.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; Part of the TCP/IP network stack for KolibriOS ;; |
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3406 $ |
$Revision: 5015 $ |
; Socket states |
TCPS_CLOSED = 0 |
141,6 → 141,7 |
TCP_sequence_num dd ? |
TCP_queue rd (TCP_QUEUE_SIZE*sizeof.TCP_queue_entry + sizeof.queue)/4 |
TCP_input_event dd ? |
TCP_timer1_event dd ? |
endg |
uglobal |
224,9 → 225,17 |
call new_sys_threads |
test eax, eax |
jns @f |
DEBUGF DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP, error %d\n', eax |
DEBUGF DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP input, error %d\n', eax |
@@: |
movi ebx, 1 |
mov ecx, TCP_timer_640ms |
call new_sys_threads |
test eax, eax |
jns @f |
DEBUGF DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP timer, error %d\n', eax |
@@: |
} |
264,6 → 273,8 |
jz .packets_missed ; 2 |
dec bl |
jz .packets_dumped ; 3 |
dec bl |
jz .packets_queued ; 4 |
.error: |
mov eax, -1 |
284,3 → 295,7 |
.packets_dumped: |
mov eax, [TCP_segments_dumped + eax] |
ret |
.packets_queued: |
mov eax, [TCP_queue + queue.size] |
ret |
/kernel/branches/kolibri-process/network/tcp_input.inc |
---|
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3407 $ |
$Revision: 5000 $ |
;----------------------------------------------------------------- |
; |
58,7 → 58,6 |
ret |
.fail: |
popf |
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n" |
call NET_ptr_to_num4 |
/kernel/branches/kolibri-process/network/tcp_output.inc |
---|
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3289 $ |
$Revision: 4850 $ |
;----------------------------------------------------------------- |
; |
/kernel/branches/kolibri-process/network/tcp_subr.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; Part of the TCP/IP network stack for KolibriOS ;; |
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3514 $ |
$Revision: 5015 $ |
align 4 |
iglobal |
143,7 → 143,7 |
; |
;------------------------- |
align 4 |
TCP_drop: |
TCP_drop: ; FIXME CHECKME TODO |
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_drop: %x\n", eax |
290,7 → 290,6 |
mov ecx, sizeof.TCP_header |
mov di, IP_PROTO_TCP shl 8 + 128 |
call IPv4_output |
test edi, edi |
jz .error |
pop esi cx |
push edx eax |
/kernel/branches/kolibri-process/network/tcp_timer.inc |
---|
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3143 $ |
$Revision: 5013 $ |
timer_flag_retransmission = 1 shl 0 |
timer_flag_keepalive = 1 shl 1 |
61,14 → 61,19 |
} |
;---------------------- |
; 640 ms timer |
;---------------------- |
macro TCP_timer_640ms { ; TODO: implement timed wait timer! |
align 4 |
proc TCP_timer_640ms ; TODO: implement timed wait timer! |
local .loop |
local .exit |
xor esi, esi |
mov ecx, MANUAL_DESTROY |
call create_event |
mov [TCP_timer1_event], eax |
.wait: |
mov eax, [TCP_timer1_event] |
mov ebx, [eax + EVENT.id] |
call wait_event |
; Update TCP sequence number |
add [TCP_sequence_num], 64000 |
81,7 → 86,7 |
mov eax, [eax + SOCKET.NextPtr] |
.check_only: |
or eax, eax |
jz .exit |
jz .wait |
cmp [eax + SOCKET.Domain], AF_INET4 |
jne .loop |
157,9 → 162,8 |
mov [eax + TCP_SOCKET.t_force], 0 |
jmp .loop |
.exit: |
} |
endp |
/kernel/branches/kolibri-process/network/udp.inc |
---|
1,6 → 1,6 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;; UDP.INC ;; |
14,7 → 14,7 |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 2995 $ |
$Revision: 5015 $ |
struct UDP_header |
245,6 → 245,8 |
; ecx = number of bytes to send |
; esi = pointer to data |
; |
; OUT: eax = -1 on error |
; |
;----------------------------------------------------------------- |
align 4 |
/kernel/branches/kolibri-process/video/vesa20.inc |
---|
23,7 → 23,14 |
; If you're planning to write your own video driver I suggest |
; you replace the VESA12.INC file and see those instructions. |
;Screen_Max_X equ 0xfe00 |
;Screen_Max_Y equ 0xfe04 |
;BytesPerScanLine equ 0xfe08 |
;LFBAddress equ 0xfe80 |
;ScreenBPP equ 0xfbf1 |
;----------------------------------------------------------------------------- |
; getpixel |
; |
218,7 → 225,8 |
add eax, [putimg.arg_0] |
mov [putimg.line_increment], eax |
; winmap new line increment |
mov eax, [_display.width] |
mov eax, [Screen_Max_X] |
inc eax |
sub eax, [putimg.real_sx] |
mov [putimg.winmap_newline], eax |
; screen new line increment |
241,6 → 249,8 |
add edx, eax |
; pointer to pixel map |
mov eax, [putimg.abs_cy] |
; imul eax, [Screen_Max_X] |
; add eax, [putimg.abs_cy] |
mov eax, [d_width_calc_area + eax*4] |
add eax, [putimg.abs_cx] |
685,11 → 695,12 |
; for example drawwindow_III and drawwindow_IV |
; edi = 0x00000001 force |
;;; mov [novesachecksum], dword 0 |
pushad |
cmp eax, [_display.width] |
jae .exit |
cmp ebx, [_display.height] |
jae .exit |
cmp [Screen_Max_X], eax |
jb .exit |
cmp [Screen_Max_Y], ebx |
jb .exit |
test edi, 1 ; force ? |
jnz .forced |
878,6 → 889,9 |
;----------------------------------------------------------------------------- |
align 4 |
calculate_edi: |
; mov edi, ebx |
; imul edi, [Screen_Max_X] |
; add edi, ebx |
mov edi, [d_width_calc_area + ebx*4] |
add edi, eax |
ret |
1209,8 → 1223,9 |
.end_y: |
mov [drbar.real_sy], ebx |
; line_inc_map |
mov eax, [_display.width] |
mov eax, [Screen_Max_X] |
sub eax, [drbar.real_sx] |
inc eax |
mov [drbar.line_inc_map], eax |
; line_inc_scr |
mov eax, [drbar.real_sx] |
1924,7 → 1939,8 |
; advance edi, ebp to next scan line |
sub eax, [draw_data+32+RECT.left] |
sub ebp, eax |
add ebp, [_display.width] |
add ebp, [Screen_Max_X] |
add ebp, 1 |
sub edi, eax |
sub edi, eax |
sub edi, eax |
1955,7 → 1971,8 |
push edi |
mov esi, bgr_next_line |
mov edi, bgr_cur_line |
mov ecx, [_display.width] |
mov ecx, [Screen_Max_X] |
inc ecx |
rep movsd |
jmp bgr_resmooth1 |
;-------------------------------------- |