kolibri-process:update

git-svn-id: svn://kolibrios.org@5116 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2014-09-12 19:16:32 +00:00
parent 0f8b75bb05
commit c6de386b0b
43 changed files with 1033 additions and 1321 deletions

View File

@ -1,271 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 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 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2455 $
sys_cd_audio:
cmp word [cdbase], word 0
jnz @f
mov eax, 1
ret
@@:
; eax=1 cdplay at ebx 0x00FFSSMM
; eax=2 get tracklist size of ecx to [ebx]
; eax=3 stop/pause playing
cmp eax, 1
jnz nocdp
call sys_cdplay
ret
nocdp:
cmp eax, 2
jnz nocdtl
mov edi, [TASK_BASE]
add edi, TASKDATA.mem_start
add ebx, [edi]
call sys_cdtracklist
ret
nocdtl:
cmp eax, 3
jnz nocdpause
call sys_cdpause
ret
nocdpause:
mov eax, 0xffffff01
ret
sys_cd_atapi_command:
pushad
mov dx, word [cdbase]
add dx, 6
mov ax, word [cdid]
out dx, al
mov esi, 10
call delay_ms
mov dx, word [cdbase]
add dx, 7
in al, dx
and al, 0x80
cmp al, 0
jnz res
jmp cdl6
res:
mov dx, word [cdbase]
add dx, 7
mov al, 0x8
out dx, al
mov dx, word [cdbase]
add dx, 0x206
mov al, 0xe
out dx, al
mov esi, 1
call delay_ms
mov dx, word [cdbase]
add dx, 0x206
mov al, 0x8
out dx, al
mov esi, 30
call delay_ms
xor cx, cx
cdl5:
inc cx
cmp cx, 10
jz cdl6
mov dx, word [cdbase]
add dx, 7
in al, dx
and al, 0x88
cmp al, 0x00
jz cdl5
mov esi, 100
call delay_ms
jmp cdl5
cdl6:
mov dx, word [cdbase]
add dx, 4
mov al, 0
out dx, al
mov dx, word [cdbase]
add dx, 5
mov al, 0
out dx, al
mov dx, word [cdbase]
add dx, 7
mov al, 0xec
out dx, al
mov esi, 5
call delay_ms
mov dx, word [cdbase]
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 128
out dx, al
add dx, 2
mov al, 0xa0
out dx, al
xor cx, cx
mov dx, word [cdbase]
add dx, 7
cdl1:
inc cx
cmp cx, 100
jz cdl2
in al, dx
and ax, 0x88
cmp al, 0x8
jz cdl2
mov esi, 2
call delay_ms
jmp cdl1
cdl2:
popad
ret
sys_cdplay:
mov ax, 5
push ax
push ebx
cdplay:
call sys_cd_atapi_command
cli
mov dx, word [cdbase]
mov ax, 0x0047
out dx, ax
mov al, 1
mov ah, [esp+0]; min xx
out dx, ax
mov ax, [esp+1]; fr sec
out dx, ax
mov ax, 256+99
out dx, ax
mov ax, 0x0001
out dx, ax
mov ax, 0x0000
out dx, ax
mov esi, 10
call delay_ms
sti
add dx, 7
in al, dx
test al, 1
jz cdplayok
mov ax, [esp+4]
dec ax
mov [esp+4], ax
cmp ax, 0
jz cdplayfail
jmp cdplay
cdplayfail:
cdplayok:
pop ebx
pop ax
xor eax, eax
ret
sys_cdtracklist:
push ebx
tcdplay:
call sys_cd_atapi_command
mov dx, word [cdbase]
mov ax, 0x43+2*256
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 200
out dx, ax
mov ax, 0x0
out dx, ax
in al, dx
mov cx, 1000
mov dx, word [cdbase]
add dx, 7
cld
cdtrnwewait:
mov esi, 10
call delay_ms
in al, dx
and al, 128
cmp al, 0
jz cdtrl1
loop cdtrnwewait
cdtrl1:
; read the result
mov ecx, [esp+0]
mov dx, word [cdbase]
cdtrread:
add dx, 7
in al, dx
and al, 8
cmp al, 8
jnz cdtrdone
sub dx, 7
in ax, dx
mov [ecx], ax
add ecx, 2
jmp cdtrread
cdtrdone:
pop ecx
xor eax, eax
ret
sys_cdpause:
call sys_cd_atapi_command
mov dx, word [cdbase]
mov ax, 0x004B
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov esi, 10
call delay_ms
add dx, 7
in al, dx
xor eax, eax
ret

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4437 $ $Revision: 5089 $
; ============================================================================= ; =============================================================================
; ================================= Constants ================================= ; ================================= Constants =================================
@ -108,6 +108,7 @@ struct DISKCACHE
data dd ? data dd ?
sad_size dd ? sad_size dd ?
search_start dd ? search_start dd ?
sector_size_log dd ?
ends ends
; This structure represents a disk device and its media for the kernel. ; This structure represents a disk device and its media for the kernel.
@ -271,13 +272,13 @@ disk_list_mutex MUTEX
endg endg
iglobal 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 ; 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. ; 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 ; 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' ; 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 ; 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 ; 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 ; 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 ; is normally 0 and temporarily can become greater. The function increments
@ -638,28 +639,25 @@ disk_scan_partitions:
; 1. Initialize .NumPartitions and .Partitions fields as zeros: empty list. ; 1. Initialize .NumPartitions and .Partitions fields as zeros: empty list.
and [esi+DISK.NumPartitions], 0 and [esi+DISK.NumPartitions], 0
and [esi+DISK.Partitions], 0 and [esi+DISK.Partitions], 0
; 2. Currently we can work only with 512-bytes sectors. Check this restriction. ; 2. Acquire the buffer for MBR and bootsector tests. See the comment before
; 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
; the 'partition_buffer_users' variable. ; 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 mov ebx, mbr_buffer ; assume the global buffer is free
lock inc [partition_buffer_users] lock inc [partition_buffer_users]
jz .buffer_acquired ; yes, it is free jz .buffer_acquired ; yes, it is free
lock dec [partition_buffer_users] ; no, we must allocate 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 test eax, eax
jz .nothing jz .nothing
xchg eax, ebx xchg eax, ebx
.buffer_acquired: .buffer_acquired:
; MBR/EBRs are organized in the chain. We use a loop over MBR/EBRs, but no ; MBR/EBRs are organized in the chain. We use a loop over MBR/EBRs, but no
; more than MAX_NUM_PARTITION times. ; 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. ; ebp will hold the sector number for current MBR/EBR.
; [esp] will hold the sector number for current extended partition, if there ; [esp] will hold the sector number for current extended partition, if there
; is one. ; is one.
@ -668,6 +666,10 @@ disk_scan_partitions:
push MAX_NUM_PARTITIONS ; the counter of max MBRs to process push MAX_NUM_PARTITIONS ; the counter of max MBRs to process
xor ebp, ebp ; start from sector zero xor ebp, ebp ; start from sector zero
push ebp ; no extended partition yet 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: .new_mbr:
; 5. Read the current sector. ; 5. Read the current sector.
; Note that 'read' callback operates with 64-bit sector numbers, so we must ; Note that 'read' callback operates with 64-bit sector numbers, so we must
@ -986,7 +988,7 @@ end virtual
; a three-sectors-sized buffer. This function saves ebx in the stack ; a three-sectors-sized buffer. This function saves ebx in the stack
; immediately before ebp. ; immediately before ebp.
mov ebx, [ebp-4] ; get buffer 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 add ebp, 8 ; ebp points to part of PARTITION structure
xor eax, eax ; first sector of the partition xor eax, eax ; first sector of the partition
call fs_read32_sys call fs_read32_sys
@ -997,7 +999,7 @@ end virtual
; ebp -> first three fields of PARTITION structure, .start, .length, .disk; ; ebp -> first three fields of PARTITION structure, .start, .length, .disk;
; [esp] = error code after bootsector read: 0 = ok, otherwise = failed, ; [esp] = error code after bootsector read: 0 = ok, otherwise = failed,
; ebx points to the buffer for bootsector, ; 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 call fat_create_partition
test eax, eax test eax, eax
jnz .success jnz .success

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4465 $ $Revision: 5095 $
; Read/write functions try to do large operations, ; Read/write functions try to do large operations,
; it is significantly faster than several small operations. ; it is significantly faster than several small operations.
@ -49,7 +49,7 @@ CACHE_ITEM_MODIFIED = 2
; out: ecx = number of sectors that were read ; out: ecx = number of sectors that were read
fs_read64_sys: fs_read64_sys:
; Save ebx, set ebx to SysCache and let the common part do its work. ; Save ebx, set ebx to SysCache and let the common part do its work.
push ebx push ebx ebx
mov ebx, [ebp+PARTITION.Disk] mov ebx, [ebp+PARTITION.Disk]
add ebx, DISK.SysCache add ebx, DISK.SysCache
jmp fs_read64_common jmp fs_read64_common
@ -63,7 +63,7 @@ fs_read64_sys:
; out: ecx = number of sectors that were read ; out: ecx = number of sectors that were read
fs_read64_app: fs_read64_app:
; Save ebx, set ebx to AppCache and let the common part do its work. ; Save ebx, set ebx to AppCache and let the common part do its work.
push ebx push ebx ebx
mov ebx, [ebp+PARTITION.Disk] mov ebx, [ebp+PARTITION.Disk]
add ebx, DISK.AppCache add ebx, DISK.AppCache
@ -118,7 +118,6 @@ end virtual
add [.sector_lo], eax add [.sector_lo], eax
adc [.sector_hi], edx adc [.sector_hi], edx
; 5. If the cache is disabled, pass the request directly to the driver. ; 5. If the cache is disabled, pass the request directly to the driver.
mov edi, [.buffer]
cmp [ebx+DISKCACHE.pointer], 0 cmp [ebx+DISKCACHE.pointer], 0
jz .nocache jz .nocache
; 6. Look for sectors in the cache, sequentially from the beginning. ; 6. Look for sectors in the cache, sequentially from the beginning.
@ -137,13 +136,15 @@ end virtual
; release the lock and go to 7. ; release the lock and go to 7.
jc .not_found_in_cache jc .not_found_in_cache
; The sector is found in cache. ; The sector is found in cache.
; 6d. Copy data for the caller. ; 6d. Copy data for the caller, advance [.buffer].
; Note that buffer in edi is advanced automatically. mov esi, edi
mov esi, ecx mov edi, [.buffer]
shl esi, 9 mov eax, 1
add esi, [ebx+DISKCACHE.data] shl eax, cl
mov ecx, 512/4 mov ecx, eax
shr ecx, 2
rep movsd rep movsd
mov [.buffer], edi
; 6e. Advance the sector. ; 6e. Advance the sector.
add [.sector_lo], 1 add [.sector_lo], 1
adc [.sector_hi], 0 adc [.sector_hi], 0
@ -161,7 +162,7 @@ end virtual
sub ecx, [.num_sectors] sub ecx, [.num_sectors]
.nothing: .nothing:
add esp, .local_vars_size 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 ret
.not_found_in_cache: .not_found_in_cache:
; Release the lock acquired at 6a. ; Release the lock acquired at 6a.
@ -177,6 +178,7 @@ end virtual
; However, for extra-large requests make an upper limit: ; However, for extra-large requests make an upper limit:
; do not use more than half of the free memory ; do not use more than half of the free memory
; or more than CACHE_MAX_ALLOC_SIZE bytes. ; or more than CACHE_MAX_ALLOC_SIZE bytes.
mov ecx, [ebx+DISKCACHE.sector_size_log]
mov ebx, [pg_data.pages_free] mov ebx, [pg_data.pages_free]
shr ebx, 1 shr ebx, 1
jz .nomemory jz .nomemory
@ -184,13 +186,15 @@ end virtual
jbe @f jbe @f
mov ebx, CACHE_MAX_ALLOC_SIZE shr 12 mov ebx, CACHE_MAX_ALLOC_SIZE shr 12
@@: @@:
shl ebx, 12 - 9 shl ebx, 12
shr ebx, cl
jz .nomemory
cmp ebx, [.num_sectors] cmp ebx, [.num_sectors]
jbe @f jbe @f
mov ebx, [.num_sectors] mov ebx, [.num_sectors]
@@: @@:
mov eax, ebx mov eax, ebx
shl eax, 9 shl eax, cl
stdcall kernel_alloc, eax stdcall kernel_alloc, eax
; If failed, return the appropriate error code. ; If failed, return the appropriate error code.
test eax, eax test eax, eax
@ -233,28 +237,31 @@ end virtual
jz @f jz @f
mov [.error_code+.local_vars2_size], eax mov [.error_code+.local_vars2_size], eax
@@: @@:
; 11. Copy data for the caller. ; 11. Copy data for the caller, advance .buffer.
; Note that buffer in edi is advanced automatically.
cmp [.current_num_sectors], 0 cmp [.current_num_sectors], 0
jz .copy_done jz .copy_done
mov ecx, [.current_num_sectors] mov ebx, [.cache+.local_vars2_size]
shl ecx, 9-2 mov eax, [.current_num_sectors]
mov ecx, [ebx+DISKCACHE.sector_size_log]
shl eax, cl
mov esi, [.allocated_buffer] mov esi, [.allocated_buffer]
mov edi, [.buffer+.local_vars2_size]
mov ecx, eax
shr ecx, 2
rep movsd rep movsd
mov [.buffer+.local_vars2_size], edi
; 12. Copy data to the cache. ; 12. Copy data to the cache.
; 12a. Acquire the lock. ; 12a. Acquire the lock.
mov ebx, [.cache+.local_vars2_size]
mov ecx, [ebp+PARTITION.Disk] mov ecx, [ebp+PARTITION.Disk]
add ecx, DISK.CacheLock add ecx, DISK.CacheLock
call mutex_lock 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. ; stores number of sectors to be copied.
push edi push [.current_num_sectors]
push [.current_num_sectors+4]
.store_to_cache: .store_to_cache:
; 12c. For each sector, call the lookup function with adding to the cache, if not yet. ; 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 eax, [.sector_lo+.local_vars2_size+4]
mov edx, [.sector_hi+.local_vars2_size+8] mov edx, [.sector_hi+.local_vars2_size+4]
call cache_lookup_write call cache_lookup_write
test eax, eax test eax, eax
jnz .cache_error jnz .cache_error
@ -263,39 +270,39 @@ end virtual
; so rewrite data for the caller from the cache. ; so rewrite data for the caller from the cache.
cmp [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED cmp [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED
jnz .not_modified jnz .not_modified
mov esi, ecx mov esi, edi
shl esi, 9 mov edi, [.buffer+.local_vars2_size+4]
add esi, [ebx+DISKCACHE.data] mov eax, [esp]
mov edi, [esp+4] shl eax, cl
mov ecx, [esp] sub edi, eax
shl ecx, 9-2 mov eax, 1
sub edi, ecx shl eax, cl
mov ecx, 512/4 mov ecx, eax
shr ecx, 2
rep movsd rep movsd
add [.current_buffer+8], 512 add [.current_buffer+4], eax
jmp .sector_done jmp .sector_done
.not_modified: .not_modified:
; 12e. For each not-modified sector, ; 12e. For each not-modified sector,
; copy data, mark the item as not-modified copy of the disk, ; copy data, mark the item as not-modified copy of the disk,
; advance .current_buffer and .sector_hi:.sector_lo to the next sector. ; advance .current_buffer and .sector_hi:.sector_lo to the next sector.
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
mov esi, [.current_buffer+8] mov eax, 1
mov edi, ecx shl eax, cl
shl edi, 9 mov esi, [.current_buffer+4]
add edi, [ebx+DISKCACHE.data] mov ecx, eax
mov ecx, 512/4 shr ecx, 2
rep movsd rep movsd
mov [.current_buffer+8], esi mov [.current_buffer+4], esi
.sector_done: .sector_done:
add [.sector_lo+.local_vars2_size+8], 1 add [.sector_lo+.local_vars2_size+4], 1
adc [.sector_hi+.local_vars2_size+8], 0 adc [.sector_hi+.local_vars2_size+4], 0
; 12f. Continue the loop 12c-12e until all sectors are read. ; 12f. Continue the loop 12c-12e until all sectors are read.
dec dword [esp] dec dword [esp]
jnz .store_to_cache jnz .store_to_cache
.cache_error: .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 ecx
pop edi
; 12h. Release the lock. ; 12h. Release the lock.
mov ecx, [ebp+PARTITION.Disk] mov ecx, [ebp+PARTITION.Disk]
add ecx, DISK.CacheLock add ecx, DISK.CacheLock
@ -328,7 +335,7 @@ end virtual
push eax ; numsectors push eax ; numsectors
push [.sector_hi+4] ; startsector push [.sector_hi+4] ; startsector
push [.sector_lo+8] ; startsector push [.sector_lo+8] ; startsector
push edi ; buffer push [.buffer+12] ; buffer
mov esi, [ebp+PARTITION.Disk] mov esi, [ebp+PARTITION.Disk]
mov al, DISKFUNC.read mov al, DISKFUNC.read
call disk_call_driver call disk_call_driver
@ -440,11 +447,11 @@ end virtual
; 6c. For each sector, copy data, mark the item as modified and not saved, ; 6c. For each sector, copy data, mark the item as modified and not saved,
; advance .current_buffer to the next sector. ; advance .current_buffer to the next sector.
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED mov [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED
mov eax, 1
shl eax, cl
mov esi, [.cur_buffer] mov esi, [.cur_buffer]
mov edi, ecx mov ecx, eax
shl edi, 9 shr ecx, 2
add edi, [ebx+DISKCACHE.data]
mov ecx, 512/4
rep movsd rep movsd
mov [.cur_buffer], esi mov [.cur_buffer], esi
; 6d. Remove the sector from the other cache. ; 6d. Remove the sector from the other cache.
@ -592,11 +599,12 @@ end virtual
jc .not_found_in_cache jc .not_found_in_cache
.found_in_cache: .found_in_cache:
; 4c. Copy the data. ; 4c. Copy the data.
mov esi, edi
mov edi, [.buffer] mov edi, [.buffer]
mov esi, ecx mov eax, 1
shl esi, 9 shl eax, cl
add esi, [ebx+DISKCACHE.data] mov ecx, eax
mov ecx, 512/4 shr ecx, 2
rep movsd rep movsd
; 4d. Release the lock and return success. ; 4d. Release the lock and return success.
mov ecx, [ebp+PARTITION.Disk] mov ecx, [ebp+PARTITION.Disk]
@ -627,7 +635,10 @@ end virtual
add ecx, DISK.CacheLock add ecx, DISK.CacheLock
call mutex_unlock call mutex_unlock
; 7. Allocate buffer for CACHE_LEGACY_READ_SIZE sectors. ; 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. ; If failed, return the corresponding error code.
test eax, eax test eax, eax
jz .nomemory jz .nomemory
@ -656,7 +667,11 @@ end virtual
; 10. Copy data for the caller. ; 10. Copy data for the caller.
mov esi, [.allocated_buffer] mov esi, [.allocated_buffer]
mov edi, [.buffer+.local_vars2_size] 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 rep movsd
; 11. Store all sectors that were successfully read to the cache. ; 11. Store all sectors that were successfully read to the cache.
; 11a. Acquire the lock. ; 11a. Acquire the lock.
@ -671,19 +686,19 @@ end virtual
test eax, eax test eax, eax
jnz .cache_error jnz .cache_error
; 11c. Ignore sectors marked as modified: for them the cache is more recent that disk data. ; 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 cmp [esi+CACHE_ITEM.Status], CACHE_ITEM_MODIFIED
jnz .not_modified jnz .not_modified
add [.current_buffer], 512 add [.current_buffer], eax
jmp .sector_done jmp .sector_done
.not_modified: .not_modified:
; 11d. For each sector, copy data, mark the item as not-modified copy of the disk, ; 11d. For each sector, copy data, mark the item as not-modified copy of the disk,
; advance .current_buffer and .sector_hi:.sector_lo to the next sector. ; advance .current_buffer and .sector_hi:.sector_lo to the next sector.
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
mov esi, [.current_buffer] mov esi, [.current_buffer]
mov edi, ecx mov ecx, eax
shl edi, 9 shr ecx, 2
add edi, [ebx+DISKCACHE.data]
mov ecx, 512/4
rep movsd rep movsd
mov [.current_buffer], esi mov [.current_buffer], esi
.sector_done: .sector_done:
@ -721,16 +736,14 @@ end virtual
call cache_lookup_write call cache_lookup_write
test eax, eax test eax, eax
jnz .floppy_cache_error jnz .floppy_cache_error
push ecx push esi
; 14. Call the driver to read one sector. ; 14. Call the driver to read one sector.
push 1 push 1
push esp push esp
push edx push edx
push [.sector_lo+16] push [.sector_lo+16]
shl ecx, 9 push edi
add ecx, [ebx+DISKCACHE.data]
push ecx
mov esi, [ebp+PARTITION.Disk] mov esi, [ebp+PARTITION.Disk]
mov al, DISKFUNC.read mov al, DISKFUNC.read
call disk_call_driver call disk_call_driver
@ -740,10 +753,7 @@ end virtual
; 15. Get the slot and pointer to the cache item, ; 15. Get the slot and pointer to the cache item,
; change the status to not-modified copy of the disk ; change the status to not-modified copy of the disk
; and go to 4c. ; and go to 4c.
pop ecx pop esi
lea esi, [ecx*sizeof.CACHE_ITEM/4]
shl esi, 2
add esi, [ebx+DISKCACHE.pointer]
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
jmp .found_in_cache jmp .found_in_cache
@ -795,13 +805,14 @@ fs_write32_app:
; in: edx:eax = sector ; in: edx:eax = sector
; in: ebx -> DISKCACHE structure ; in: ebx -> DISKCACHE structure
; out: CF set if sector is not in cache ; out: CF set if sector is not in cache
; out: ecx = index in cache ; out: ecx = sector_size_log
; out: esi -> sector:status ; out: esi -> sector:status
; out: edi -> sector data
proc cache_lookup_read proc cache_lookup_read
mov esi, [ebx+DISKCACHE.pointer] mov esi, [ebx+DISKCACHE.pointer]
add esi, sizeof.CACHE_ITEM add esi, sizeof.CACHE_ITEM
mov ecx, 1 mov edi, 1
.hdreadcache: .hdreadcache:
@ -812,14 +823,17 @@ proc cache_lookup_read
jne .nohdcache jne .nohdcache
cmp [esi+CACHE_ITEM.SectorHi], edx cmp [esi+CACHE_ITEM.SectorHi], edx
jne .nohdcache jne .nohdcache
mov ecx, [ebx+DISKCACHE.sector_size_log]
shl edi, cl
add edi, [ebx+DISKCACHE.data]
clc clc
ret ret
.nohdcache: .nohdcache:
add esi, sizeof.CACHE_ITEM add esi, sizeof.CACHE_ITEM
inc ecx inc edi
cmp ecx, [ebx+DISKCACHE.sad_size] cmp edi, [ebx+DISKCACHE.sad_size]
jbe .hdreadcache jbe .hdreadcache
stc stc
ret ret
@ -832,8 +846,8 @@ endp
; in: ebx -> DISKCACHE structure ; in: ebx -> DISKCACHE structure
; in: ebp -> PARTITION structure ; in: ebp -> PARTITION structure
; out: eax = error code ; out: eax = error code
; out: ecx = index in cache
; out: esi -> sector:status ; out: esi -> sector:status
; out: edi -> sector data
proc cache_lookup_write proc cache_lookup_write
call cache_lookup_read call cache_lookup_read
jnc .return0 jnc .return0
@ -874,6 +888,10 @@ proc cache_lookup_write
popd [esi+CACHE_ITEM.SectorLo] popd [esi+CACHE_ITEM.SectorLo]
popd [esi+CACHE_ITEM.SectorHi] popd [esi+CACHE_ITEM.SectorHi]
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_EMPTY 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: .return0:
xor eax, eax ; success xor eax, eax ; success
ret ret
@ -902,7 +920,7 @@ virtual at esp
.sequential dd ? .sequential dd ?
; boolean variable, 1 if the current chain is sequential in the cache, ; boolean variable, 1 if the current chain is sequential in the cache,
; 0 if additional buffer is needed to perform the operation ; 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_start_ptr dd ? ; pointer to chain start item
.chain_size dd ? ; chain size (thanks, C.O.) .chain_size dd ? ; chain size (thanks, C.O.)
.iteration_size dd ? .iteration_size dd ?
@ -951,6 +969,9 @@ end virtual
mov eax, [ebx+DISKCACHE.sad_size] mov eax, [ebx+DISKCACHE.sad_size]
sub eax, [.size_left] sub eax, [.size_left]
inc eax inc eax
mov ecx, [ebx+DISKCACHE.sector_size_log]
shl eax, cl
add eax, [ebx+DISKCACHE.data]
mov [.chain_start_pos], eax mov [.chain_start_pos], eax
mov [.chain_size], 0 mov [.chain_size], 0
mov [.sequential], 1 mov [.sequential], 1
@ -978,7 +999,7 @@ end virtual
; before returning to 6b; if there is a sequential block indeed, this saves some ; before returning to 6b; if there is a sequential block indeed, this saves some
; time instead of many full-fledged lookups. ; time instead of many full-fledged lookups.
mov [.sequential], 0 mov [.sequential], 0
mov [.chain_start_pos], ecx mov [.chain_start_pos], edi
.look_backward: .look_backward:
; 6e. For each sector, update chain start pos/ptr, decrement sector number, ; 6e. For each sector, update chain start pos/ptr, decrement sector number,
; look at the previous item. ; look at the previous item.
@ -1001,7 +1022,9 @@ end virtual
; ...expand the chain one sector backwards and continue the loop at 6e. ; ...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 ; Otherwise, advance to step 7 if the previous item describes the correct sector
; but is not modified, and return to step 6b otherwise. ; 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 jmp .look_backward
.found_chain_start: .found_chain_start:
; 7. Expand the chain forward. ; 7. Expand the chain forward.
@ -1046,14 +1069,11 @@ end virtual
; 9. Write a sequential chain to disk. ; 9. Write a sequential chain to disk.
; 9a. Pass the entire chain to the driver. ; 9a. Pass the entire chain to the driver.
mov eax, [.chain_start_ptr] mov eax, [.chain_start_ptr]
mov edx, [.chain_start_pos]
shl edx, 9
add edx, [ebx+DISKCACHE.data]
lea ecx, [.chain_size] lea ecx, [.chain_size]
push ecx ; numsectors push ecx ; numsectors
pushd [eax+CACHE_ITEM.SectorHi] ; startsector pushd [eax+CACHE_ITEM.SectorHi] ; startsector
pushd [eax+CACHE_ITEM.SectorLo] ; startsector pushd [eax+CACHE_ITEM.SectorLo] ; startsector
push edx ; buffer push [.chain_start_pos+12] ; buffer
mov esi, [ebp+PARTITION.Disk] mov esi, [ebp+PARTITION.Disk]
mov al, DISKFUNC.write mov al, DISKFUNC.write
call disk_call_driver call disk_call_driver
@ -1088,13 +1108,15 @@ end virtual
jbe @f jbe @f
mov eax, CACHE_MAX_ALLOC_SIZE shr 12 mov eax, CACHE_MAX_ALLOC_SIZE shr 12
@@: @@:
shl eax, 12 - 9 shl eax, 12
shr eax, cl
jz .nomemory
cmp eax, [.chain_size] cmp eax, [.chain_size]
jbe @f jbe @f
mov eax, [.chain_size] mov eax, [.chain_size]
@@: @@:
mov [.iteration_size], eax mov [.iteration_size], eax
shl eax, 9 shl eax, cl
stdcall kernel_alloc, eax stdcall kernel_alloc, eax
test eax, eax test eax, eax
jz .nomemory jz .nomemory
@ -1123,10 +1145,13 @@ end virtual
; 13b. For each sector, copy the data. ; 13b. For each sector, copy the data.
; Note that edi is advanced automatically. ; Note that edi is advanced automatically.
mov esi, [.chain_start_pos+24] mov esi, [.chain_start_pos+24]
shl esi, 9 mov ecx, [ebx+DISKCACHE.sector_size_log]
add esi, [ebx+DISKCACHE.data] mov eax, 1
mov ecx, 512/4 shl eax, cl
mov ecx, eax
shr ecx, 2
rep movsd rep movsd
mov ecx, eax ; keep for 13e
; 13c. Mark the item as not-modified. ; 13c. Mark the item as not-modified.
mov esi, [.chain_start_ptr+24] mov esi, [.chain_start_ptr+24]
mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY mov [esi+CACHE_ITEM.Status], CACHE_ITEM_COPY
@ -1145,7 +1170,7 @@ end virtual
jnz .no_forward jnz .no_forward
; 13e. Increment position/pointer to the chain and ; 13e. Increment position/pointer to the chain and
; continue the loop. ; continue the loop.
inc [.chain_start_pos+24] add [.chain_start_pos+24], ecx
mov [.chain_start_ptr+24], esi mov [.chain_start_ptr+24], esi
dec dword [esp] dec dword [esp]
jnz .copy_loop jnz .copy_loop
@ -1153,11 +1178,13 @@ end virtual
.no_forward: .no_forward:
; 13f. Call the lookup function without adding to the cache. ; 13f. Call the lookup function without adding to the cache.
; Update position/pointer with returned value. ; 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. ; garbage; we are not going to use them in this case.
push edi
call cache_lookup_read call cache_lookup_read
mov [.chain_start_pos+24], ecx mov [.chain_start_pos+28], edi
mov [.chain_start_ptr+24], esi mov [.chain_start_ptr+28], esi
pop edi
dec dword [esp] dec dword [esp]
jnz .copy_loop jnz .copy_loop
.copy_done: .copy_done:
@ -1203,13 +1230,32 @@ endp
; is most useful example of a non-trivial adjustment. ; is most useful example of a non-trivial adjustment.
; esi = pointer to DISK structure ; esi = pointer to DISK structure
disk_init_cache: disk_init_cache:
; 1. Calculate the suggested cache size. ; 1. Verify sector size. The code requires it to be a power of 2 not less than 4.
; 1a. Get the size of free physical memory in pages. ; 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] 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 shl eax, 12 - 5 ; 1/32 of it in bytes
and eax, -8*4096 ; round down to the multiple of 8 pages 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 cmp eax, 1024*1024
jb @f jb @f
mov eax, 1024*1024 mov eax, 1024*1024
@ -1218,7 +1264,7 @@ disk_init_cache:
ja @f ja @f
mov eax, 128*1024 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 push eax
mov al, DISKFUNC.adjust_cache_size mov al, DISKFUNC.adjust_cache_size
call disk_call_driver call disk_call_driver
@ -1226,16 +1272,16 @@ disk_init_cache:
mov [esi+DISK.cache_size], eax mov [esi+DISK.cache_size], eax
test eax, eax test eax, eax
jz .nocache jz .nocache
; 2. Allocate memory for the cache. ; 3. Allocate memory for the cache.
; 2a. Call the allocator. ; 3a. Call the allocator.
stdcall kernel_alloc, eax stdcall kernel_alloc, eax
test eax, eax test eax, eax
jnz @f 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' dbgstr 'no memory for disk cache'
jmp .nothing jmp .nothing
@@: @@:
; 3. Fill two DISKCACHE structures. ; 4. Fill two DISKCACHE structures.
mov [esi+DISK.SysCache.pointer], eax mov [esi+DISK.SysCache.pointer], eax
lea ecx, [esi+DISK.CacheLock] lea ecx, [esi+DISK.CacheLock]
call mutex_init call mutex_init
@ -1252,9 +1298,7 @@ disk_init_cache:
mov [esi+DISK.AppCache.pointer], edx mov [esi+DISK.AppCache.pointer], edx
mov eax, [esi+DISK.SysCache.data_size] mov eax, [esi+DISK.SysCache.data_size]
push ebx call calculate_cache_slots
call calculate_for_hd64
pop ebx
add eax, [esi+DISK.SysCache.pointer] add eax, [esi+DISK.SysCache.pointer]
mov [esi+DISK.SysCache.data], eax mov [esi+DISK.SysCache.data], eax
mov [esi+DISK.SysCache.sad_size], ecx mov [esi+DISK.SysCache.sad_size], ecx
@ -1267,9 +1311,7 @@ disk_init_cache:
pop edi pop edi
mov eax, [esi+DISK.AppCache.data_size] mov eax, [esi+DISK.AppCache.data_size]
push ebx call calculate_cache_slots
call calculate_for_hd64
pop ebx
add eax, [esi+DISK.AppCache.pointer] add eax, [esi+DISK.AppCache.pointer]
mov [esi+DISK.AppCache.data], eax mov [esi+DISK.AppCache.data], eax
mov [esi+DISK.AppCache.sad_size], ecx mov [esi+DISK.AppCache.sad_size], ecx
@ -1281,9 +1323,9 @@ disk_init_cache:
rep stosd rep stosd
pop edi pop edi
; 4. Return with nonzero al. ; 5. Return with nonzero al.
mov al, 1 mov al, 1
; 5. Return. ; 6. Return.
.nothing: .nothing:
ret ret
; No caching is required for this driver. Zero cache pointers and return with ; No caching is required for this driver. Zero cache pointers and return with
@ -1294,18 +1336,16 @@ disk_init_cache:
mov al, 1 mov al, 1
ret ret
calculate_for_hd64: calculate_cache_slots:
push eax push eax
mov ebx, eax mov ecx, [esi+DISK.MediaInfo.SectorSize]
shr eax, 9 add ecx, sizeof.CACHE_ITEM
lea eax, [eax*3] xor edx, edx
shl eax, 2 div ecx
sub ebx, eax mov ecx, eax
shr ebx, 9 imul eax, [esi+DISK.MediaInfo.SectorSize]
mov ecx, ebx sub [esp], eax
shl ebx, 9
pop eax pop eax
sub eax, ebx
dec ecx dec ecx
ret ret

View File

@ -6,7 +6,7 @@
;; RAMDISK functions ;; ;; RAMDISK functions ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4273 $ $Revision: 5057 $
iglobal iglobal
align 4 align 4
@ -22,11 +22,6 @@ ramdisk_functions:
.size = $ - ramdisk_functions .size = $ - ramdisk_functions
endg 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 iglobal
align 4 align 4
ramdisk_actual_size dd RAMDISK_CAPACITY ramdisk_actual_size dd RAMDISK_CAPACITY

View File

@ -394,7 +394,6 @@ sayerr:
push 0 push 0
popf popf
sti
; set up esp ; set up esp
movzx esp, sp movzx esp, sp
@ -402,15 +401,20 @@ sayerr:
push 0 push 0
pop es pop es
xor cx, cx
@@:
in al, 64h
test al, 2
loopnz @b
mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование mov al, 0xf6 ; Сброс клавиатуры, разрешить сканирование
out 0x60, al out 0x60, al
xor cx, cx xor cx, cx
wait_loop: ; variant 2 @@:
; reading state of port of 8042 controller
in al, 64h in al, 64h
and al, 00000010b ; ready flag test al, 1
; wait until 8042 controller is ready loopz @b
loopnz wait_loop in al, 0x60
;;;/diamond today 5.02.2008 ;;;/diamond today 5.02.2008
; set keyboard typematic rate & delay ; set keyboard typematic rate & delay
@ -419,16 +423,19 @@ wait_loop: ; variant 2
xor cx, cx xor cx, cx
@@: @@:
in al, 64h in al, 64h
test al, 2 test al, 1
loopnz @b loopz @b
in al, 0x60
mov al, 0 mov al, 0
out 0x60, al out 0x60, al
xor cx, cx xor cx, cx
@@: @@:
in al, 64h in al, 64h
test al, 2 test al, 1
loopnz @b loopz @b
in al, 0x60
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sti
; --------------- APM --------------------- ; --------------- APM ---------------------
and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found) and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found)
mov ax, 0x5300 mov ax, 0x5300

View File

@ -13,8 +13,24 @@
$Revision: 2455 $ $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: pr_mode_exit:
; setup stack ; setup stack

View File

@ -228,10 +228,6 @@ VGABasePtr equ (OS_BASE+0x00A0000)
CLEAN_ZONE equ (_CLEAN_ZONE-OS_BASE) CLEAN_ZONE equ (_CLEAN_ZONE-OS_BASE)
IDE_DMA equ (_IDE_DMA-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) UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000)
virtual at (OS_BASE+0x05FFF80) virtual at (OS_BASE+0x05FFF80)
@ -621,6 +617,28 @@ struct COFF_SYM
NumAuxSymbols db ? NumAuxSymbols db ?
ends 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 struct IOCTL
handle dd ? handle dd ?
io_code dd ? io_code dd ?

View File

@ -209,13 +209,13 @@ proc get_service stdcall, sz_name:dword
stdcall strncmp, edx, [sz_name], 16 stdcall strncmp, edx, [sz_name], 16
test eax, eax test eax, eax
je .ok mov eax, edx
je .nothing
mov edx, [edx+SRV.fd] mov edx, [edx+SRV.fd]
jmp @B jmp @B
.not_load: .not_load:
mov eax, [sz_name] mov eax, [sz_name]
; Try to load .dll driver first. If not, fallback to .obj.
push edi push edi
sub esp, 36 sub esp, 36
mov edi, esp mov edi, esp
@ -236,12 +236,6 @@ proc get_service stdcall, sz_name:dword
stdcall load_pe_driver, edi, 0 stdcall load_pe_driver, edi, 0
add esp, 36 add esp, 36
pop edi pop edi
test eax, eax
jnz .nothing
pop ebp
jmp load_driver
.ok:
mov eax, edx
.nothing: .nothing:
ret ret
endp endp
@ -880,177 +874,6 @@ proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
ret ret
endp 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 ; in: edx -> COFF_SECTION struct
; out: eax = alignment as mask for bits to drop ; out: eax = alignment as mask for bits to drop
coff_get_align: coff_get_align:

View File

@ -5,12 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4418 $ $Revision: 5088 $
iglobal
szKernel db 'KERNEL', 0
szVersion db 'version',0
endg
align 4 align 4
__exports: __exports:
@ -48,6 +43,7 @@ __exports:
get_phys_addr, 'GetPhysAddr', \ ; eax get_phys_addr, 'GetPhysAddr', \ ; eax
map_space, 'MapSpace', \ map_space, 'MapSpace', \
release_pages, 'ReleasePages', \ release_pages, 'ReleasePages', \
alloc_dma24, 'AllocDMA24', \ ; stdcall
\ \
mutex_init, 'MutexInit', \ ; gcc fastcall mutex_init, 'MutexInit', \ ; gcc fastcall
mutex_lock, 'MutexLock', \ ; gcc fastcall mutex_lock, 'MutexLock', \ ; gcc fastcall

View File

@ -232,24 +232,12 @@ commit_pages:
mov edi, ebx mov edi, ebx
shr edi, 12 shr edi, 12
lea edi, [page_tabs+edi*4] 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 stosd
invlpg [ebx] invlpg [ebx]
add eax, 0x1000 add eax, 0x1000
add ebx, 0x1000 add ebx, 0x1000
loop @B loop @B
end if
pop edi pop edi
@ -362,6 +350,59 @@ proc map_page_table stdcall, lin_addr:dword, phis_addr:dword
ret ret
endp 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 align 4
proc init_LFB proc init_LFB
locals locals

View File

@ -24,15 +24,30 @@ proc load_PE stdcall, file_name:dword
mov [image], eax mov [image], eax
mov edx, [eax+60] mov edx, [eax+STRIPPED_PE_HEADER.SizeOfImage]
; mov cl, [eax+STRIPPED_PE_HEADER.Subsystem]
cmp word [eax], STRIPPED_PE_SIGNATURE
jz @f
stdcall kernel_alloc, [eax+80+edx] mov edx, [eax+60]
; mov cl, [eax+5Ch+edx]
mov edx, [eax+80+edx]
@@:
mov [entry], 0
; cmp cl, 1
; jnz .cleanup
stdcall kernel_alloc, edx
test eax, eax test eax, eax
jz .cleanup jz .cleanup
mov [base], eax 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 mov [entry], eax
test eax, eax test eax, eax
@ -48,199 +63,200 @@ proc load_PE stdcall, file_name:dword
ret ret
endp endp
DWORD equ dword map_PE: ;ebp=base:dword, ebx=image:dword
PTR equ
align 4
map_PE: ;stdcall base:dword, image:dword
cld
push ebp
push edi push edi
push esi push esi
push ebx sub esp, .locals_size
sub esp, 60 virtual at esp
mov ebx, DWORD PTR [esp+84] .numsections dd ?
mov ebp, DWORD PTR [esp+80] .import_names dd ?
mov edx, ebx .import_targets dd ?
mov esi, ebx .peheader dd ?
add edx, DWORD PTR [ebx+60] .bad_import dd ?
mov edi, ebp .import_idx dd ?
mov DWORD PTR [esp+32], edx .import_descr dd ?
mov ecx, DWORD PTR [edx+84] .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
mov edi, ebp
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
movzx eax, WORD PTR [edx+6] cmp [.numsections], 0
mov DWORD PTR [esp+36], 0 jz .nosections
mov DWORD PTR [esp+16], eax .copy_sections:
jmp L2 mov eax, [edx+8]
L3:
mov eax, DWORD PTR [edx+264]
test eax, eax test eax, eax
je L4 je .no_section_data
mov esi, ebx mov esi, ebx
mov edi, ebp mov edi, ebp
add esi, DWORD PTR [edx+268] add esi, [edx+12]
mov ecx, eax mov ecx, eax
add edi, DWORD PTR [edx+260] add edi, [edx+4]
add ecx, 3 add ecx, 3
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
L4: .no_section_data:
mov ecx, DWORD PTR [edx+256] mov ecx, [edx]
cmp ecx, eax cmp ecx, eax
jbe L6 jbe .no_section_fill
sub ecx, eax sub ecx, eax
add eax, DWORD PTR [edx+260] add eax, [edx+4]
lea edi, [eax+ebp] lea edi, [eax+ebp]
xor eax, eax xor eax, eax
rep stosb rep stosb
L6: .no_section_fill:
inc DWORD PTR [esp+36] add edx, [.section_header_size]
add edx, 40 dec [.numsections]
L2: jnz .copy_sections
mov esi, DWORD PTR [esp+16] .nosections:
cmp DWORD PTR [esp+36], esi cmp [.relocs_size], 0
jne L3 je .no_relocations
mov edi, DWORD PTR [esp+32]
cmp DWORD PTR [edi+164], 0
je L9
pushd [edi+164]
mov esi, ebp mov esi, ebp
mov ecx, ebp mov ecx, ebp
sub esi, DWORD PTR [edi+52] sub esi, [.ImageBase]
add ecx, DWORD PTR [edi+160] add ecx, [.relocs_rva]
mov eax, esi .relocs_block:
shr eax, 16 mov edi, [ecx]
mov DWORD PTR [esp+16], eax add edi, ebp
L12: mov ebx, [ecx+4]
mov eax, [ecx+4] add ecx, 8
sub [esp], eax sub [.relocs_size], ebx
lea ebx, [eax-8] sub ebx, 8
xor edi, edi
shr ebx, 1 shr ebx, 1
jmp L13 jz .relocs_next_block
L14: .one_reloc:
movzx eax, WORD PTR [ecx+8+edi*2] movzx eax, word [ecx]
add ecx, 2
mov edx, eax mov edx, eax
shr eax, 12 shr eax, 12
and edx, 4095 and edx, 4095
add edx, DWORD PTR [ecx] cmp eax, 3
cmp ax, 2 jne @f
je L17 add [edx+edi], esi
cmp ax, 3 @@:
je L18 dec ebx
dec ax jnz .one_reloc
jne L15 .relocs_next_block:
mov eax, DWORD PTR [esp+16] cmp [.relocs_size], 0
add WORD PTR [edx+ebp], ax jg .relocs_block
L17: .no_relocations:
add WORD PTR [edx+ebp], si cmp [.import_descr], 0
L18: je .no_imports
add DWORD PTR [edx+ebp], esi add [.import_descr], ebp
L15: mov [.bad_import], 0
inc edi .import_block:
L13: mov ecx, [.import_descr]
cmp edi, ebx cmp dword [ecx+4], 0
jne L14 jne @f
add ecx, DWORD PTR [ecx+4] cmp dword [ecx+12], 0
L11: je .done_imports
cmp dword [esp], 0 @@:
jg L12 mov edx, dword [ecx]
pop eax mov ecx, dword [ecx+16]
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]
test edx, edx test edx, edx
jnz @f jnz @f
mov edx, ecx mov edx, ecx
@@: @@:
mov DWORD PTR [esp+52], 0 mov [.import_idx], 0
add ecx, ebp add ecx, ebp
add edx, ebp add edx, ebp
mov DWORD PTR [esp+24], edx mov [.import_names], edx
mov DWORD PTR [esp+28], ecx mov [.import_targets], ecx
L26: .import_func:
mov esi, DWORD PTR [esp+52] mov esi, [.import_idx]
mov edi, DWORD PTR [esp+24] mov edi, [.import_names]
mov eax, DWORD PTR [edi+esi*4] mov eax, [edi+esi*4]
test eax, eax test eax, eax
je L27 je .next_import_block
test eax, eax js .next_import_block
js L27
lea edi, [ebp+eax] lea edi, [ebp+eax]
mov eax, DWORD PTR [esp+28] mov eax, [.import_targets]
mov DWORD PTR [eax+esi*4], 0 mov dword [eax+esi*4], 0
lea esi, [edi+2] lea esi, [edi+2]
push eax movzx ebx, word [edi]
push 32 push 32
movzx eax, WORD PTR [edi] mov ecx, [__exports+32]
mov edx, DWORD PTR [esp+56] mov eax, [ecx+OS_BASE+ebx*4]
mov eax, DWORD PTR [edx+eax*4]
add eax, OS_BASE add eax, OS_BASE
push eax push eax
push esi push esi
call strncmp call strncmp
pop ebx test eax, eax
jz .import_func_found
xor ebx, ebx xor ebx, ebx
test eax, eax .import_func_candidate:
jne L32
jmp L30
L33:
push ecx
push 32 push 32
mov ecx, DWORD PTR [esp+28] mov ecx, [__exports+32]
mov eax, DWORD PTR [ecx+OS_BASE+ebx*4] mov eax, [ecx+OS_BASE+ebx*4]
add eax, OS_BASE add eax, OS_BASE
push eax push eax
push esi push esi
call strncmp call strncmp
pop edx
test eax, eax test eax, eax
jne L34 je .import_func_found
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:
inc ebx inc ebx
L32: cmp ebx, [__exports+24]
cmp ebx, DWORD PTR [__exports+24] jb .import_func_candidate
jb L33
L36:
cmp ebx, DWORD PTR [__exports+24]
jne L37
mov esi, msg_unresolved mov esi, msg_unresolved
call sys_msg_board_str call sys_msg_board_str
@ -249,34 +265,30 @@ L36:
mov esi, msg_CR mov esi, msg_CR
call sys_msg_board_str call sys_msg_board_str
mov DWORD PTR [esp+40], 1 mov [.bad_import], 1
jmp L37 jmp .next_import_func
L30: .import_func_found:
movzx eax, WORD PTR [edi] mov esi, [__exports+28]
mov esi, DWORD PTR [esp+44] mov edx, [.import_idx]
mov edi, DWORD PTR [esp+52] mov ecx, [.import_targets]
mov edx, DWORD PTR [esp+28] mov eax, [esi+OS_BASE+ebx*4]
mov eax, DWORD PTR [esi+eax*4]
add eax, OS_BASE add eax, OS_BASE
mov DWORD PTR [edx+edi*4], eax mov [ecx+edx*4], eax
L37: .next_import_func:
inc DWORD PTR [esp+52] inc [.import_idx]
jmp L26 jmp .import_func
L27: .next_import_block:
add DWORD PTR [esp+56], 20 add [.import_descr], 20
jmp L22 jmp .import_block
L25: .done_imports:
xor eax, eax xor eax, eax
cmp DWORD PTR [esp+40], 0 cmp [.bad_import], 0
jne L40 jne @f
L20: .no_imports:
mov ecx, DWORD PTR [esp+32]
mov eax, ebp mov eax, ebp
add eax, DWORD PTR [ecx+40] add eax, [.AddressOfEntryPoint]
L40: @@:
add esp, 60 add esp, .locals_size
pop ebx
pop esi pop esi
pop edi pop edi
pop ebp ret
ret 8

View File

@ -140,24 +140,20 @@ end if
start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 start_not_enough_memory db 'K : New Process - not enough memory',13,10,0
msg_unresolved db 'unresolved ',0 msg_unresolved db 'unresolved ',0
msg_module db 'in module ',0 ;msg_module db 'in module ',0
if ~ lang eq sp ;if ~ lang eq sp
msg_version db 'incompatible driver version',13,10,0 ;msg_version db 'incompatible driver version',13,10,0
msg_www db 'please visit www.kolibrios.org',13,10,0 ;msg_www db 'please visit www.kolibrios.org',13,10,0
end if ;end if
msg_CR db 13,10,0 msg_CR db 13,10,0
intel_str db "GenuineIntel",0
AMD_str db "AuthenticAMD",0
szHwMouse db 'ATI2D',0 szHwMouse db 'ATI2D',0
szPS2MDriver db 'PS2MOUSE',0 szPS2MDriver db '/rd/1/drivers/PS2MOUSE.SYS',0
;szCOM_MDriver db 'COM_MOUSE',0 ;szCOM_MDriver db 'COM_MOUSE',0
szVidintel db 'vidintel',0 szVidintel db '/rd/1/drivers/vidintel.sys',0
szUSB db 'USB',0 szUSB db 'USB',0
szAtiHW db '/rd/1/drivers/ati2d.drv',0 szAtiHW db '/rd/1/drivers/ati2d.drv',0
szSTART db 'START',0
szEXPORTS db 'EXPORTS',0 szEXPORTS db 'EXPORTS',0
sz_EXPORTS db '_EXPORTS',0 sz_EXPORTS db '_EXPORTS',0
@ -529,16 +525,21 @@ end if
org (OS_BASE+0x0100000) org (OS_BASE+0x0100000)
RAMDISK: rb 2880*512 ; Currently size of memory allocated for the ramdisk is fixed.
rb 2856*4 ; not used ; This should be revisited when/if memory map would become more dynamic.
RAMDISK_CAPACITY = 2880 ; in sectors
RAMDISK: rb RAMDISK_CAPACITY*512
_CLEAN_ZONE: _CLEAN_ZONE:
BgrAuxTable rb 32768
align 65536
SB16Buffer rb 65536
align 4096 align 4096
_IDE_DMA rb 16*512 _IDE_DMA rb 16*512
BgrAuxTable rb 32768
BUTTON_INFO rb 64*1024 BUTTON_INFO rb 64*1024
RESERVED_PORTS: rb 64*1024 RESERVED_PORTS: rb 64*1024
FLOPPY_BUFF: rb 18*512 ;one track
sys_pgmap: rb 1024*1024/8 sys_pgmap: rb 1024*1024/8

View File

@ -47,8 +47,8 @@ if preboot_blogesc
boot_tasking: cp850 'Todo configurado - presiona ESC para iniciar',0 boot_tasking: cp850 'Todo configurado - presiona ESC para iniciar',0
end if end if
msg_version: cp850 'versión incompatible del controlador',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 ;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 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 mtrr_user_message cp850 '"There is a problem with MTRR configuration.\nPerformance can be low" -dW',0

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3881 $ $Revision: 5030 $
;****************************************************** ;******************************************************
@ -68,6 +68,8 @@ FindHDD_1:
push ebx ecx push ebx ecx
call ReadHDD_ID call ReadHDD_ID
pop ecx ebx pop ecx ebx
cmp [DevErrorCode], 7
je .end
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .FindCD jne .FindCD
@ -274,7 +276,7 @@ ATACommand db ? ;код команды, подлежащей выполне
; интервал ожидания, 2 - неверный код режима адресации, ; интервал ожидания, 2 - неверный код режима адресации,
; 3 - неверный номер канала, 4 - неверный номер диска, ; 3 - неверный номер канала, 4 - неверный номер диска,
; 5 - неверный номер головки, 6 - ошибка при выполнении ; 5 - неверный номер головки, 6 - ошибка при выполнении
; команды) ; команды, 7 - таймаут при выборе канала)
DevErrorCode dd ? DevErrorCode dd ?
endg endg
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@ -380,7 +382,7 @@ SendCommandToHDD:
ret ret
; Записать код ошибки ; Записать код ошибки
@@Err1: @@Err1:
mov [DevErrorCode], 1 mov [DevErrorCode], 7
ret ret
@@Err2: @@Err2:
mov [DevErrorCode], 2 mov [DevErrorCode], 2

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3742 $ $Revision: 4711 $
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
pusha pusha

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3742 $ $Revision: 4711 $
search_partitions: search_partitions:
push ecx push ecx

View File

@ -5,154 +5,129 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $ $Revision: 5082 $
; fetch the UTF-8 character in addrspace:offs to char
; fetch the UTF-8 character in string+offs to char macro fetch_utf8_char addrspace, offs, 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
{ local first_byte, b { local first_byte, b
virtual at 0
db string
if offs >= $
char = -1
else
; fetch first byte ; fetch first byte
load first_byte byte from offs load first_byte byte from addrspace:offs
if first_byte < 0x80 if first_byte < 0x80
char = first_byte char = first_byte
offs = offs + 1 offs = offs + 1
else if first_byte < 0xC0 else if first_byte < 0xC0
.err Invalid UTF-8 string err Invalid UTF-8 string
else if first_byte < 0xE0 else if first_byte < 0xE0
char = first_byte and 0x1F 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) char = (char shl 6) + (b and 0x3F)
offs = offs + 2 offs = offs + 2
else if first_byte < 0xF0 else if first_byte < 0xF0
char = first_byte and 0xF 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) 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) char = (char shl 6) + (b and 0x3F)
offs = offs + 3 offs = offs + 3
else if first_byte < 0xF8 else if first_byte < 0xF8
char = first_byte and 0x7 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) 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) 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) char = (char shl 6) + (b and 0x3F)
offs = offs + 4 offs = offs + 4
else else
.err Invalid UTF-8 string err Invalid UTF-8 string
end if
end if
end virtual
if char = 0x2500
graph = 0xC4
else if char = 0x2502
graph = 0xB3
else if char = 0x250C
graph = 0xDA
else if char = 0x2510
graph = 0xBF
else if char = 0x2514
graph = 0xC0
else if char = 0x2518
graph = 0xD9
else if char = 0x252C
graph = 0xC2
else if char = 0x2534
graph = 0xC1
else if char = 0x2551
graph = 0xBA
else
graph = 0
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
db 0xC4
else if char = 0x2502
db 0xB3
else if char = 0x250C
db 0xDA
else if char = 0x2510
db 0xBF
else if char = 0x2514
db 0xC0
else if char = 0x2518
db 0xD9
else if char = 0x252C
db 0xC2
else if char = 0x2534
db 0xC1
else if char = 0x2551
db 0xBA
else if char < 0x80
db char
else
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. ; Russian: use CP866.
; 0x00-0x7F - trivial map
; 0x410-0x43F -> 0x80-0xAF ; 0x410-0x43F -> 0x80-0xAF
; 0x440-0x44F -> 0xE0-0xEF ; 0x440-0x44F -> 0xE0-0xEF
; 0x401 -> 0xF0, 0x451 -> 0xF1 ; 0x401 -> 0xF0, 0x451 -> 0xF1
macro cp866 [arg] declare_encoding cp866
{ local offs, char, graph {
offs = 0 if char = 0x401
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
db 0xF0 db 0xF0
else if char = 0x451 else if char = 0x451
db 0xF1 db 0xF1
else if (char < 0x410) | (char > 0x44F) else if (char < 0x410) | (char > 0x44F)
.err Failed to convert to CP866 err Failed to convert to CP866
else if char < 0x440 else if char < 0x440
db char - 0x410 + 0x80 db char - 0x410 + 0x80
else else
db char - 0x440 + 0xE0 db char - 0x440 + 0xE0
end if end if
end while
}
struc cp866 [arg]
{
common
cp866 arg
} }
; Latin-1 encoding ; Latin-1 encoding
; 0x00-0xFF - trivial map ; 0x00-0xFF - trivial map
macro latin1 [arg] declare_encoding latin1
{ local offs, char, graph {
offs = 0 if char < 0x100
while 1
fetch_utf8_char arg, offs, char, graph
if char = -1
break
end if
if graph
db graph
else if char < 0x100
db char db char
else else
.err Failed to convert to Latin-1 err Failed to convert to Latin-1
end if end if
end while
}
struc latin1 [arg]
{
common
latin1 arg
} }
; CP850 encoding ; CP850 encoding
macro cp850 [arg] declare_encoding cp850
{ local offs, char, graph {
offs = 0 if char = 0xBF
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
db 0xA8 db 0xA8
else if char = 0xE1 else if char = 0xE1
db 0xA0 db 0xA0
@ -167,11 +142,4 @@ macro cp850 [arg]
else else
err Failed to convert to CP850 err Failed to convert to CP850
end if end if
end while
}
struc cp850 [arg]
{
common
cp850 arg
} }

View File

@ -7,7 +7,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $ $Revision: 5089 $
include 'ext2.inc' include 'ext2.inc'
@ -59,6 +59,8 @@ endp
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
proc ext2_create_partition proc ext2_create_partition
push ebx push ebx
cmp dword [esi+DISK.MediaInfo.SectorSize], 512
jnz .fail
mov eax, 2 ; Superblock starts at 1024-bytes. mov eax, 2 ; Superblock starts at 1024-bytes.
add ebx, 512 ; Get pointer to fs-specific buffer. add ebx, 512 ; Get pointer to fs-specific buffer.

View File

@ -44,7 +44,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4273 $ $Revision: 5089 $
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00 cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00
@ -154,6 +154,9 @@ fat_create_partition.return0:
xor eax, eax xor eax, eax
ret ret
fat_create_partition: fat_create_partition:
; sector size must be 512
cmp dword [esi+DISK.MediaInfo.SectorSize], 512
jnz .return0
; bootsector must have been successfully read ; bootsector must have been successfully read
cmp dword [esp+4], 0 cmp dword [esp+4], 0
jnz .return0 jnz .return0

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4277 $ $Revision: 4700 $
ERROR_SUCCESS = 0 ERROR_SUCCESS = 0
ERROR_DISK_BASE = 1 ERROR_DISK_BASE = 1

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3742 $ $Revision: 5089 $
struct NTFS PARTITION struct NTFS PARTITION
Lock MUTEX ? ; currently operations with one partition Lock MUTEX ? ; currently operations with one partition
@ -152,6 +152,8 @@ ntfs_test_bootsec:
ret ret
proc ntfs_create_partition proc ntfs_create_partition
cmp dword [esi+DISK.MediaInfo.SectorSize], 512
jnz .nope
mov edx, dword [ebp+PARTITION.Length] mov edx, dword [ebp+PARTITION.Length]
cmp dword [esp+4], 0 cmp dword [esp+4], 0
jz .boot_read_ok jz .boot_read_ok

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $ $Revision: 5089 $
include 'xfs.inc' include 'xfs.inc'
@ -25,6 +25,8 @@ include 'xfs.inc'
; returns 0 (not XFS or invalid) / pointer to partition structure ; returns 0 (not XFS or invalid) / pointer to partition structure
xfs_create_partition: xfs_create_partition:
push ebx ecx edx esi edi 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 cmp dword[ebx + xfs_sb.sb_magicnum], XFS_SB_MAGIC ; signature
jne .error jne .error

View File

@ -5,7 +5,7 @@
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3598 $ $Revision: 5027 $
VKEY_LSHIFT = 0000000000000001b VKEY_LSHIFT = 0000000000000001b
@ -25,8 +25,6 @@ VKEY_CONTROL = 0000000000001100b
VKEY_ALT = 0000000000110000b VKEY_ALT = 0000000000110000b
uglobal uglobal
align 4
kb_state dd 0
ext_code db 0 ext_code db 0
keyboard_mode db 0 keyboard_mode db 0
@ -35,7 +33,6 @@ uglobal
altmouseb db 0 altmouseb db 0
ctrl_alt_del db 0 ctrl_alt_del db 0
kb_lights db 0
old_kb_lights db 0 old_kb_lights db 0
align 4 align 4
@ -45,6 +42,13 @@ align 4
endg endg
iglobal iglobal
kb_lights db 2
align 4
kb_state dd VKEY_NUMLOCK
endg
iglobal
align 4
hotkey_tests dd hotkey_test0 hotkey_tests dd hotkey_test0
dd hotkey_test1 dd hotkey_test1
dd hotkey_test2 dd hotkey_test2
@ -551,9 +555,9 @@ set_lights:
ps2_set_lights: ps2_set_lights:
stdcall disable_irq, 1 stdcall disable_irq, 1
mov al, 0xED mov al, 0xED
call kb_write call kb_write_wait_ack
mov al, [esp+8] mov al, [esp+8]
call kb_write call kb_write_wait_ack
stdcall enable_irq, 1 stdcall enable_irq, 1
ret 8 ret 8

View File

@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3606 $ $Revision: 4592 $
; check mouse ; check mouse

View File

@ -345,9 +345,6 @@ align 4
proc test_cpu proc test_cpu
locals locals
cpu_type dd ? cpu_type dd ?
cpu_id dd ?
cpu_Intel dd ?
cpu_AMD dd ?
endl endl
xor eax, eax xor eax, eax
@ -386,13 +383,7 @@ proc test_cpu
mov [cpu_vendor-OS_BASE], ebx mov [cpu_vendor-OS_BASE], ebx
mov [cpu_vendor+4-OS_BASE], edx mov [cpu_vendor+4-OS_BASE], edx
mov [cpu_vendor+8-OS_BASE], ecx 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 cmp eax, 1
jl .end_cpuid jl .end_cpuid
mov eax, 1 mov eax, 1
@ -422,36 +413,6 @@ proc test_cpu
.end_cpuid: .end_cpuid:
mov eax, [cpu_type] mov eax, [cpu_type]
ret 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 endp
iglobal iglobal

View File

@ -74,8 +74,6 @@ include 'struct.inc'
$Revision: 4381 $ $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 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 VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions
@ -283,6 +281,25 @@ use16
org $-0x10000 org $-0x10000
include "boot/shutdown.inc" ; shutdown or restart include "boot/shutdown.inc" ; shutdown or restart
org $+0x10000 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 use32
__DEBUG__ fix 1 __DEBUG__ fix 1
@ -668,6 +685,69 @@ no_mode_0x12:
mov dword [current_slot], SLOT_BASE + 256*2 mov dword [current_slot], SLOT_BASE + 256*2
mov dword [TASK_BASE], CURRENT_TASK + 32*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 ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f
mov esi, boot_initirq mov esi, boot_initirq
@ -681,11 +761,6 @@ no_mode_0x12:
mov esi, boot_v86machine mov esi, boot_v86machine
call boot_log call boot_log
; Initialize system V86 machine ; Initialize system V86 machine
; call init_sys_v86
xchg bx, bx
; call v86_init
call init_sys_v86 call init_sys_v86
mov esi, boot_inittimer mov esi, boot_inittimer
@ -838,7 +913,7 @@ end if
include "detect/vortex86.inc" ; Vortex86 SoC detection code include "detect/vortex86.inc" ; Vortex86 SoC detection code
stdcall load_driver, szVidintel stdcall load_pe_driver, szVidintel, 0
call usb_init call usb_init
@ -877,6 +952,7 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
mov esi, 250 ; wait 1/4 a second mov esi, 250 ; wait 1/4 a second
call delay_ms call delay_ms
rdtsc rdtsc
sti
sub eax, ecx sub eax, ecx
xor edx, edx xor edx, edx
@ -944,6 +1020,45 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
stdcall map_page, tss._io_map_1, \ stdcall map_page, tss._io_map_1, \
[SLOT_BASE+256+APPDATA.io_map+4], PG_MAP [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP
; SET KEYBOARD PARAMETERS
mov al, 0xf6 ; reset keyboard, scan enabled
call kb_write_wait_ack
test ah, ah
jnz .no_keyboard
iglobal
align 4
ps2_keyboard_functions:
dd .end - $
dd 0 ; no close
dd ps2_set_lights
.end:
endg
stdcall register_keyboard, ps2_keyboard_functions, 0
; mov al, 0xED ; Keyboard LEDs - only for testing!
; call kb_write_wait_ack
; mov al, 111b
; call kb_write_wait_ack
mov al, 0xF3 ; set repeat rate & delay
call kb_write_wait_ack
mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500
call kb_write_wait_ack
;// mike.dld [
call set_lights
;// mike.dld ]
stdcall attach_int_handler, 1, irq1, 0
DEBUGF 1, "K : IRQ1 return code %x\n", eax
.no_keyboard:
; Load PS/2 mouse driver
stdcall load_pe_driver, szPS2MDriver, 0
mov esi, boot_setmouse
call boot_log
call setmouse
; LOAD FIRST APPLICATION ; LOAD FIRST APPLICATION
cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes)
jnz first_app_found jnz first_app_found
@ -962,58 +1077,6 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
first_app_found: first_app_found:
cli
; SET KEYBOARD PARAMETERS
mov al, 0xf6 ; reset keyboard, scan enabled
call kb_write
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:
dd .end - $
dd 0 ; no close
dd ps2_set_lights
.end:
endg
stdcall register_keyboard, ps2_keyboard_functions, 0
; mov al, 0xED ; Keyboard LEDs - only for testing!
; call kb_write
; call kb_read
; mov al, 111b
; call kb_write
; call kb_read
mov al, 0xF3 ; set repeat rate & delay
call kb_write
; call kb_read
mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500
call kb_write
; call kb_read
;// mike.dld [
call set_lights
;// mike.dld ]
stdcall attach_int_handler, 1, irq1, 0
DEBUGF 1, "K : IRQ1 return code %x\n", eax
.no_keyboard:
; Load PS/2 mouse driver
stdcall load_driver, szPS2MDriver
mov esi, boot_setmouse
call boot_log
call setmouse
; START MULTITASKING ; START MULTITASKING
; A 'All set - press ESC to start' messages if need ; A 'All set - press ESC to start' messages if need
@ -1037,6 +1100,27 @@ end if
; Fly :) ; 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' include 'unpacker.inc'
align 4 align 4
@ -1171,13 +1255,35 @@ align 4
osloop_nonperiodic_work dd ? osloop_nonperiodic_work dd ?
endg endg
align 4 uglobal
align 64
idle_addr rb 64
endg
idle_thread: idle_thread:
sti sti
idle_loop:
hlt
jmp idle_loop
; 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_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 @@ sysfn_centermouse: ; 18.15 = mouse centered
;* mouse centered - start code- Mario79 ;* mouse centered - start code- Mario79
;mouse_centered: ;mouse_centered:
; push eax ; push eax
mov eax, [_display.width] mov eax, [Screen_Max_X]
shr eax, 1 shr eax, 1
mov [MOUSE_X], ax mov [MOUSE_X], ax
mov eax, [_display.height] mov eax, [Screen_Max_Y]
shr eax, 1 shr eax, 1
mov [MOUSE_Y], ax mov [MOUSE_Y], ax
call wakeup_osloop call wakeup_osloop
@ -2291,11 +2397,11 @@ sysfn_mouse_acceleration: ; 18.19 = set/get mouse features
; cmp ecx,4 ; set mouse pointer position ; cmp ecx,4 ; set mouse pointer position
dec ecx dec ecx
jnz .set_mouse_button jnz .set_mouse_button
cmp dx, word[_display.height] cmp dx, word[Screen_Max_Y]
jae .end ja .end
rol edx, 16 rol edx, 16
cmp dx, word[_display.width] cmp dx, word[Screen_Max_X]
jae .end ja .end
mov [MOUSE_X], edx mov [MOUSE_X], edx
mov [mouse_active], 1 mov [mouse_active], 1
call wakeup_osloop call wakeup_osloop
@ -2722,22 +2828,22 @@ nosb8:
jnz nosb9 jnz nosb9
; ecx = [left]*65536 + [right] ; ecx = [left]*65536 + [right]
; edx = [top]*65536 + [bottom] ; edx = [top]*65536 + [bottom]
mov eax, [_display.width] mov eax, [Screen_Max_X]
mov ebx, [_display.height] mov ebx, [Screen_Max_Y]
; check [right] ; check [right]
cmp cx, ax cmp cx, ax
jae .exit ja .exit
; check [left] ; check [left]
ror ecx, 16 ror ecx, 16
cmp cx, ax cmp cx, ax
jae .exit ja .exit
; check [bottom] ; check [bottom]
cmp dx, bx cmp dx, bx
jae .exit ja .exit
; check [top] ; check [top]
ror edx, 16 ror edx, 16
cmp dx, bx cmp dx, bx
jae .exit ja .exit
movzx eax, cx ; [left] movzx eax, cx ; [left]
movzx ebx, dx ; [top] movzx ebx, dx ; [top]
@ -4463,113 +4569,39 @@ putimage_get16bpp:
; ret ; ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 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 push ecx edx
mov dl, al 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 mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's
kw_loop: .wait_output_ready:
in al, 0x64 in al, 0x64
test al, 2 test al, 2
jz kw_ok jz @f
loop kw_loop loop .wait_output_ready
mov ah, 1 mov ah, 1
jmp kw_exit jmp .nothing
kw_ok: @@:
mov al, dl mov al, dl
out 0x60, al out 0x60, al
mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's
kw_loop3: .wait_ack:
in al, 0x64
test al, 2
jz kw_ok3
loop kw_loop3
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 in al, 0x64
test al, 1 test al, 1
jnz kw_ok4 jnz @f
loop kw_loop5 loop .wait_ack
dec ah mov ah, 1
jnz kw_loop4 jmp .nothing
kw_ok4: @@:
in al, 0x60
xor ah, ah xor ah, ah
kw_exit:
.nothing:
pop edx ecx pop edx ecx
ret 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 setmouse: ; set mousepicture -pointer
; ps2 mouse enable ; ps2 mouse enable
@ -4707,9 +4739,9 @@ endg
jnz @f jnz @f
mov word [msg_board_pos+2], (42*6) mov word [msg_board_pos+2], (42*6)
add word [msg_board_pos], 10 add word [msg_board_pos], 10
mov ax, word [_display.height] mov ax, word [Screen_Max_Y]
cmp word [msg_board_pos], ax cmp word [msg_board_pos], ax
jb @f jbe @f
mov word [msg_board_pos], 10 mov word [msg_board_pos], 10
@@: @@:
; // end if ; // end if
@ -5092,10 +5124,10 @@ syscall_cdaudio:
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
syscall_getpixel_WinMap: ; GetPixel WinMap syscall_getpixel_WinMap: ; GetPixel WinMap
cmp ebx, [_display.width] cmp ebx, [Screen_Max_X]
jb @f jbe @f
cmp ecx, [_display.height] cmp ecx, [Screen_Max_Y]
jb @f jbe @f
xor eax, eax xor eax, eax
jmp .store jmp .store
;-------------------------------------- ;--------------------------------------
@ -5112,7 +5144,8 @@ align 4
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
syscall_getpixel: ; GetPixel syscall_getpixel: ; GetPixel
mov ecx, [_display.width] mov ecx, [Screen_Max_X]
inc ecx
xor edx, edx xor edx, edx
mov eax, ebx mov eax, ebx
div ecx div ecx
@ -5487,6 +5520,39 @@ system_shutdown: ; shut down the system
call stop_all_services call stop_all_services
yes_shutdown_param: 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 cli
if ~ defined extended_primary_loader if ~ defined extended_primary_loader
@ -5510,22 +5576,6 @@ end if
call IRQ_mask_all 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 cmp byte [OS_BASE + 0x9030], 2
jnz no_acpi_power_off jnz no_acpi_power_off
@ -5671,21 +5721,6 @@ do_acpi_power_off:
jmp $ 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: scan_rsdp:
add eax, OS_BASE add eax, OS_BASE
.s: .s:
@ -5708,7 +5743,33 @@ scan_rsdp:
stc stc
.ok: .ok:
ret 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 if ~ lang eq sp
diff16 "end of .text segment",0,$ diff16 "end of .text segment",0,$

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; ARP.INC ;; ;; ARP.INC ;;
@ -16,7 +16,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3386 $ $Revision: 5015 $
ARP_NO_ENTRY = 0 ARP_NO_ENTRY = 0
ARP_VALID_MAPPING = 1 ARP_VALID_MAPPING = 1
@ -318,10 +318,9 @@ ARP_output_request:
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u device=0x%x\n",\ 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 [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 edx, ETH_BROADCAST ; broadcast mac
mov ecx, sizeof.ARP_header mov ecx, sizeof.ARP_header
mov di, ETHER_PROTO_ARP mov edx, ETH_BROADCAST ; broadcast mac
call ETH_output call ETH_output
jz .exit jz .exit

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; IPv4.INC ;; ;; IPv4.INC ;;
@ -16,7 +16,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3515 $ $Revision: 5015 $
IPv4_MAX_FRAGMENTS = 64 IPv4_MAX_FRAGMENTS = 64
IPv4_MAX_ROUTES = 64 IPv4_MAX_ROUTES = 64
@ -576,11 +576,11 @@ IPv4_find_fragment_slot:
; edx = Source IP ; edx = Source IP
; di = TTL shl 8 + protocol ; di = TTL shl 8 + protocol
; ;
; OUT: eax = pointer to buffer start ; OUT: eax = pointer to buffer start / 0 on error
; ebx = pointer to device struct (needed for sending procedure) ; ebx = device ptr (send packet through this device)
; ecx = unchanged (packet size of embedded data) ; ecx = data length
; edx = size of complete buffer ; edx = size of complete frame
; edi = pointer to start of data (0 on error) ; edi = start of IPv4 payload
; ;
;------------------------------------------------------------------ ;------------------------------------------------------------------
align 4 align 4
@ -594,7 +594,6 @@ IPv4_output:
push ecx di eax push ecx di eax
call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
push edx push edx
test edi, edi test edi, edi
jz .loopback jz .loopback
@ -606,12 +605,11 @@ IPv4_output:
inc [IPv4_packets_tx + edi] ; update stats inc [IPv4_packets_tx + edi] ; update stats
mov ax, ETHER_PROTO_IPv4
mov ebx, [NET_DRV_LIST + edi] mov ebx, [NET_DRV_LIST + edi]
lea eax, [ebx + ETH_DEVICE.mac]
mov edx, esp
mov ecx, [esp + 6 + 8 + 2] mov ecx, [esp + 6 + 8 + 2]
add ecx, sizeof.IPv4_header add ecx, sizeof.IPv4_header
mov di, ETHER_PROTO_IPv4 mov edx, esp
call ETH_output call ETH_output
jz .eth_error jz .eth_error
add esp, 6 ; pop the mac out of the stack add esp, 6 ; pop the mac out of the stack
@ -641,18 +639,18 @@ IPv4_output:
.eth_error: .eth_error:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n" DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n"
add esp, 3*4+2+6 add esp, 3*4+2+6
xor edi, edi xor eax, eax
ret ret
.arp_error: .arp_error:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax
add esp, 3*4+2 add esp, 3*4+2
xor edi, edi xor eax, eax
ret ret
.too_large: .too_large:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n" DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n"
xor edi, edi xor eax, eax
ret ret
.loopback: .loopback:
@ -674,7 +672,7 @@ IPv4_output:
; ecx = data length ; ecx = data length
; esi = data ptr ; esi = data ptr
; ;
; OUT: / ; OUT: eax = -1 on error
; ;
;------------------------------------------------------------------ ;------------------------------------------------------------------
align 4 align 4
@ -698,15 +696,13 @@ IPv4_output_raw:
push ax push ax
inc [IPv4_packets_tx + 4*edi] inc [IPv4_packets_tx + 4*edi]
mov ax, ETHER_PROTO_IPv4
mov ebx, [NET_DRV_LIST + 4*edi] mov ebx, [NET_DRV_LIST + 4*edi]
lea eax, [ebx + ETH_DEVICE.mac]
mov edx, esp
mov ecx, [esp + 6 + 4] mov ecx, [esp + 6 + 4]
add ecx, sizeof.IPv4_header add ecx, sizeof.IPv4_header
mov di, ETHER_PROTO_IPv4 mov edx, esp
call ETH_output call ETH_output
jz .error jz .error
add esp, 6 ; pop the mac add esp, 6 ; pop the mac
mov dword[esp+4+4], edx mov dword[esp+4+4], edx
@ -745,7 +741,7 @@ IPv4_output_raw:
add esp, 8+4+4 add esp, 8+4+4
.too_large: .too_large:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output_raw: Failed\n" DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output_raw: Failed\n"
sub edi, edi or eax, -1
ret ret
@ -794,13 +790,9 @@ IPv4_fragment:
.new_fragment: .new_fragment:
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment" DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment"
mov ax, ETHER_PROTO_IPv4
mov eax, [esp + 3*4]
lea ebx, [esp + 4*4] lea ebx, [esp + 4*4]
mov di , ETHER_PROTO_IPv4
call ETH_output call ETH_output
cmp edi, -1
jz .err jz .err
; copy header ; copy header

View File

@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3251 $ $Revision: 4850 $
struct IPv6_header struct IPv6_header

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; PPPoE.INC ;; ;; PPPoE.INC ;;
@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $ $Revision: 5015 $
struct PPPoE_frame struct PPPoE_frame
@ -243,17 +243,15 @@ PPPoE_session_input:
; ;
; PPPoE_output ; PPPoE_output
; ;
; IN: ; IN: ax = protocol
; ebx = device ptr ; ebx = device ptr
; ecx = packet size ; ecx = packet size
; ;
; di = protocol ; OUT: eax = buffer start / 0 on error
; ; ebx = device ptr
; OUT: edi = 0 on error, pointer to buffer otherwise ; ecx = packet size
; eax = buffer start
; ebx = to device structure
; ecx = unchanged (packet size of embedded data)
; edx = size of complete buffer ; edx = size of complete buffer
; edi = start of PPP payload
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
@ -261,13 +259,12 @@ PPPoE_output:
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
pushw di pushw ax
pushw [PPPoE_SID] pushw [PPPoE_SID]
lea eax, [ebx + ETH_DEVICE.mac] mov ax, ETHER_PROTO_PPP_SESSION
lea edx, [PPPoE_MAC]
add ecx, PPPoE_frame.Payload + 2 add ecx, PPPoE_frame.Payload + 2
mov di, ETHER_PROTO_PPP_SESSION lea edx, [PPPoE_MAC]
call ETH_output call ETH_output
jz .eth_error jz .eth_error
@ -290,8 +287,7 @@ PPPoE_output:
.eth_error: .eth_error:
add esp, 4 add esp, 4
xor edi, edi xor eax, eax
ret ret

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; ETHERNET.INC ;; ;; ETHERNET.INC ;;
@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3346 $ $Revision: 5015 $
ETH_FRAME_MINIMUM = 60 ETH_FRAME_MINIMUM = 60
ETH_QUEUE_SIZE = 255 ETH_QUEUE_SIZE = 255
@ -145,14 +145,14 @@ ETH_process_input:
cmp ax, ETHER_PROTO_ARP cmp ax, ETHER_PROTO_ARP
je ARP_input je ARP_input
cmp ax, ETHER_PROTO_IPv6 ; cmp ax, ETHER_PROTO_IPv6
je IPv6_input ; je IPv6_input
cmp ax, ETHER_PROTO_PPP_DISCOVERY ; cmp ax, ETHER_PROTO_PPP_DISCOVERY
je PPPoE_discovery_input ; je PPPoE_discovery_input
cmp ax, ETHER_PROTO_PPP_SESSION ; cmp ax, ETHER_PROTO_PPP_SESSION
je PPPoE_session_input ; je PPPoE_session_input
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax
@ -166,17 +166,16 @@ ETH_process_input:
; ;
; ETH_output ; ETH_output
; ;
; IN: eax = pointer to source mac ; IN: ax = protocol
; ebx = device ptr ; ebx = device ptr
; ecx = packet size ; ecx = payload size
; edx = pointer to destination mac ; edx = pointer to destination mac
; di = protocol
; ;
; OUT: edi = 0 on error, pointer to buffer otherwise ; OUT: eax = start of ethernet frame / 0 on error
; eax = buffer start ; ebx = device ptr
; ebx = to device structure ; ecx = payload size
; ecx = unchanged (packet size of embedded data) ; edx = ethernet frame size
; edx = size of complete buffer ; edi = start of ethernet payload
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
@ -184,11 +183,11 @@ ETH_output:
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx 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 ja .exit
push ecx push ecx
push di eax edx push ax edx
add ecx, sizeof.ETH_header add ecx, sizeof.ETH_header
stdcall kernel_alloc, ecx stdcall kernel_alloc, ecx
@ -199,7 +198,7 @@ ETH_output:
pop esi pop esi
movsd movsd
movsw movsw
pop esi lea esi, [ebx + ETH_DEVICE.mac]
movsd movsd
movsw movsw
pop ax pop ax
@ -222,13 +221,13 @@ ETH_output:
.out_of_ram: .out_of_ram:
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n" DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n"
add esp, 4+4+2+4 add esp, 4+2+4
sub edi, edi xor eax, eax
ret ret
.exit: .exit:
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n" DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n"
sub edi, edi xor eax, eax
ret ret

View File

@ -16,7 +16,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2924 $ $Revision: 4892 $
; ICMP types & codes ; ICMP types & codes

View File

@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2891 $ $Revision: 4850 $
iglobal iglobal
align 4 align 4

View File

@ -12,7 +12,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2305 $ $Revision: 4850 $
; The Queues implemented by these macros form a ring-buffer. ; The Queues implemented by these macros form a ring-buffer.
; The data to these queue's always looks like this: ; The data to these queue's always looks like this:

View File

@ -15,7 +15,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3514 $ $Revision: 4850 $
struct SOCKET struct SOCKET

View File

@ -21,7 +21,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3523 $ $Revision: 5013 $
uglobal uglobal
net_10ms dd ? net_10ms dd ?
@ -313,10 +313,15 @@ stack_handler:
test [net_10ms], 0x3f ; 640ms test [net_10ms], 0x3f ; 640ms
jnz .exit jnz .exit
TCP_timer_640ms
ARP_decrease_entry_ttls ARP_decrease_entry_ttls
IPv4_decrease_fragment_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: .exit:
ret ret

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;; ;; Part of the TCP/IP network stack for KolibriOS ;;
@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3406 $ $Revision: 5015 $
; Socket states ; Socket states
TCPS_CLOSED = 0 TCPS_CLOSED = 0
@ -141,6 +141,7 @@ align 4
TCP_sequence_num dd ? TCP_sequence_num dd ?
TCP_queue rd (TCP_QUEUE_SIZE*sizeof.TCP_queue_entry + sizeof.queue)/4 TCP_queue rd (TCP_QUEUE_SIZE*sizeof.TCP_queue_entry + sizeof.queue)/4
TCP_input_event dd ? TCP_input_event dd ?
TCP_timer1_event dd ?
endg endg
uglobal uglobal
@ -224,7 +225,15 @@ macro TCP_init {
call new_sys_threads call new_sys_threads
test eax, eax test eax, eax
jns @f 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 @@ TCP_api:
jz .packets_missed ; 2 jz .packets_missed ; 2
dec bl dec bl
jz .packets_dumped ; 3 jz .packets_dumped ; 3
dec bl
jz .packets_queued ; 4
.error: .error:
mov eax, -1 mov eax, -1
@ -284,3 +295,7 @@ TCP_api:
.packets_dumped: .packets_dumped:
mov eax, [TCP_segments_dumped + eax] mov eax, [TCP_segments_dumped + eax]
ret ret
.packets_queued:
mov eax, [TCP_queue + queue.size]
ret

View File

@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3407 $ $Revision: 5000 $
;----------------------------------------------------------------- ;-----------------------------------------------------------------
; ;
@ -58,7 +58,6 @@ TCP_input:
ret ret
.fail: .fail:
popf
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
call NET_ptr_to_num4 call NET_ptr_to_num4

View File

@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3289 $ $Revision: 4850 $
;----------------------------------------------------------------- ;-----------------------------------------------------------------
; ;

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;; ;; Part of the TCP/IP network stack for KolibriOS ;;
@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3514 $ $Revision: 5015 $
align 4 align 4
iglobal iglobal
@ -143,7 +143,7 @@ TCP_pull_out_of_band:
; ;
;------------------------- ;-------------------------
align 4 align 4
TCP_drop: TCP_drop: ; FIXME CHECKME TODO
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_drop: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_drop: %x\n", eax
@ -290,7 +290,6 @@ TCP_respond:
mov ecx, sizeof.TCP_header mov ecx, sizeof.TCP_header
mov di, IP_PROTO_TCP shl 8 + 128 mov di, IP_PROTO_TCP shl 8 + 128
call IPv4_output call IPv4_output
test edi, edi
jz .error jz .error
pop esi cx pop esi cx
push edx eax push edx eax

View File

@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3143 $ $Revision: 5013 $
timer_flag_retransmission = 1 shl 0 timer_flag_retransmission = 1 shl 0
timer_flag_keepalive = 1 shl 1 timer_flag_keepalive = 1 shl 1
@ -61,13 +61,18 @@ local .exit
} }
;---------------------- align 4
; 640 ms timer proc TCP_timer_640ms ; TODO: implement timed wait timer!
;----------------------
macro TCP_timer_640ms { ; TODO: implement timed wait timer!
local .loop xor esi, esi
local .exit 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 ; Update TCP sequence number
@ -81,7 +86,7 @@ local .exit
mov eax, [eax + SOCKET.NextPtr] mov eax, [eax + SOCKET.NextPtr]
.check_only: .check_only:
or eax, eax or eax, eax
jz .exit jz .wait
cmp [eax + SOCKET.Domain], AF_INET4 cmp [eax + SOCKET.Domain], AF_INET4
jne .loop jne .loop
@ -157,9 +162,8 @@ local .exit
mov [eax + TCP_SOCKET.t_force], 0 mov [eax + TCP_SOCKET.t_force], 0
jmp .loop jmp .loop
.exit:
} endp

View File

@ -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 ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; UDP.INC ;; ;; UDP.INC ;;
@ -14,7 +14,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2995 $ $Revision: 5015 $
struct UDP_header struct UDP_header
@ -245,6 +245,8 @@ UDP_input:
; ecx = number of bytes to send ; ecx = number of bytes to send
; esi = pointer to data ; esi = pointer to data
; ;
; OUT: eax = -1 on error
;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4

View File

@ -23,6 +23,13 @@ $Revision: 3606 $
; If you're planning to write your own video driver I suggest ; If you're planning to write your own video driver I suggest
; you replace the VESA12.INC file and see those instructions. ; 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 ; getpixel
@ -218,7 +225,8 @@ align 4
add eax, [putimg.arg_0] add eax, [putimg.arg_0]
mov [putimg.line_increment], eax mov [putimg.line_increment], eax
; winmap new line increment ; winmap new line increment
mov eax, [_display.width] mov eax, [Screen_Max_X]
inc eax
sub eax, [putimg.real_sx] sub eax, [putimg.real_sx]
mov [putimg.winmap_newline], eax mov [putimg.winmap_newline], eax
; screen new line increment ; screen new line increment
@ -241,6 +249,8 @@ align 4
add edx, eax add edx, eax
; pointer to pixel map ; pointer to pixel map
mov eax, [putimg.abs_cy] mov eax, [putimg.abs_cy]
; imul eax, [Screen_Max_X]
; add eax, [putimg.abs_cy]
mov eax, [d_width_calc_area + eax*4] mov eax, [d_width_calc_area + eax*4]
add eax, [putimg.abs_cx] add eax, [putimg.abs_cx]
@ -685,11 +695,12 @@ __sys_putpixel:
; for example drawwindow_III and drawwindow_IV ; for example drawwindow_III and drawwindow_IV
; edi = 0x00000001 force ; edi = 0x00000001 force
;;; mov [novesachecksum], dword 0
pushad pushad
cmp eax, [_display.width] cmp [Screen_Max_X], eax
jae .exit jb .exit
cmp ebx, [_display.height] cmp [Screen_Max_Y], ebx
jae .exit jb .exit
test edi, 1 ; force ? test edi, 1 ; force ?
jnz .forced jnz .forced
@ -878,6 +889,9 @@ align 4
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
calculate_edi: calculate_edi:
; mov edi, ebx
; imul edi, [Screen_Max_X]
; add edi, ebx
mov edi, [d_width_calc_area + ebx*4] mov edi, [d_width_calc_area + ebx*4]
add edi, eax add edi, eax
ret ret
@ -1209,8 +1223,9 @@ align 4
.end_y: .end_y:
mov [drbar.real_sy], ebx mov [drbar.real_sy], ebx
; line_inc_map ; line_inc_map
mov eax, [_display.width] mov eax, [Screen_Max_X]
sub eax, [drbar.real_sx] sub eax, [drbar.real_sx]
inc eax
mov [drbar.line_inc_map], eax mov [drbar.line_inc_map], eax
; line_inc_scr ; line_inc_scr
mov eax, [drbar.real_sx] mov eax, [drbar.real_sx]
@ -1924,7 +1939,8 @@ sdp4:
; advance edi, ebp to next scan line ; advance edi, ebp to next scan line
sub eax, [draw_data+32+RECT.left] sub eax, [draw_data+32+RECT.left]
sub ebp, eax sub ebp, eax
add ebp, [_display.width] add ebp, [Screen_Max_X]
add ebp, 1
sub edi, eax sub edi, eax
sub edi, eax sub edi, eax
sub edi, eax sub edi, eax
@ -1955,7 +1971,8 @@ align 4
push edi push edi
mov esi, bgr_next_line mov esi, bgr_next_line
mov edi, bgr_cur_line mov edi, bgr_cur_line
mov ecx, [_display.width] mov ecx, [Screen_Max_X]
inc ecx
rep movsd rep movsd
jmp bgr_resmooth1 jmp bgr_resmooth1
;-------------------------------------- ;--------------------------------------