diff --git a/kernel/branches/net/blkdev/disk.inc b/kernel/branches/net/blkdev/disk.inc index fecdf96c27..dd098de4e0 100644 --- a/kernel/branches/net/blkdev/disk.inc +++ b/kernel/branches/net/blkdev/disk.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Revision: 2381 $ @@ -347,16 +347,16 @@ disk_add: push eax ; save allocated pointer to DISK xor eax, eax ; the argument of malloc() is in eax @@: - inc eax - cmp byte [ebx+eax-1], 0 - jnz @b -; 2b. Call the heap manager. Note that it can change ebx. - push ebx - call malloc - pop ebx -; 2c. Check the result. If allocation failed, go to 7. - pop esi ; restore allocated pointer to DISK - test eax, eax + inc eax + cmp byte [ebx+eax-1], 0 + jnz @b +; 2b. Call the heap manager. Note that it can change ebx. + push ebx + call malloc + pop ebx +; 2c. Check the result. If allocation failed, go to 7. + pop esi ; restore allocated pointer to DISK + test eax, eax jz .free ; 2d. Store the allocated pointer to the DISK structure. mov [esi+DISK.Name], eax @@ -417,13 +417,13 @@ disk_add: ; [esp+4] = handle of the disk, i.e. the pointer to the DISK structure. ; Return value: none. disk_del: - push esi ; save used registers to be stdcall -; 1. Force media to be removed. If the media is already removed, the -; call does nothing. - mov esi, [esp+4+4] ; esi = handle of the disk - stdcall disk_media_changed, esi, 0 -; 2. Delete the structure from the global list. -; 2a. Acquire the mutex. + push esi ; save used registers to be stdcall +; 1. Force media to be removed. If the media is already removed, the +; call does nothing. + mov esi, [esp+4+4] ; esi = handle of the disk + stdcall disk_media_changed, esi, 0 +; 2. Delete the structure from the global list. +; 2a. Acquire the mutex. mov ecx, disk_list_mutex call mutex_lock ; 2b. Delete item from double-linked list. @@ -459,7 +459,9 @@ disk_dereference: stdcall disk_call_driver ; 3b. Free the structure. xchg eax, esi + push ebx call free + pop ebx ; 4. Return. .nothing: ret @@ -623,14 +625,14 @@ disk_default_closemedia: disk_default_flush: xor eax, eax ret 4 - -; The default implementation of DISKFUNC.adjust_cache_size. -disk_default_adjust_cache_size: - mov eax, [esp+8] - ret 8 - -; This is an internal function called from 'disk_media_changed' when a new media -; is detected. It creates the list of partitions for the media. + +; The default implementation of DISKFUNC.adjust_cache_size. +disk_default_adjust_cache_size: + mov eax, [esp+8] + ret 8 + +; This is an internal function called from 'disk_media_changed' when a new media +; is detected. It creates the list of partitions for the media. ; If media is not partitioned, then the list consists of one partition which ; covers all the media. ; esi = pointer to the DISK structure. @@ -974,53 +976,53 @@ disk_detect_partition: ; with ebp-based frame arguments start from ebp+8, since [ebp]=saved ebp ; and [ebp+4]=return address. virtual at ebp+8 -.start dq ? -.length dq ? -end virtual -; When disk_add_partition is called, ebx contains a pointer to -; a two-sectors-sized buffer. This function saves ebx in the stack -; immediately before ebp. -virtual at ebp-4 -.buffer dd ? -end virtual -; 1. Read the bootsector to the buffer. - mov al, DISKFUNC.read - mov ebx, [.buffer] - add ebx, 512 - push 1 - stdcall disk_call_driver, ebx, dword [.start], dword [.start+4], esp -; 2. Run tests for all supported filesystems. If at least one test succeeded, -; go to 4. -; For tests: qword [ebp+8] = partition start, qword [ebp+10h] = partition -; length, [esp] = 0 if reading bootsector failed or 1 if succeeded, -; ebx points to the buffer for bootsector. - call fat_create_partition - test eax, eax - jnz .success -; 3. No file system has recognized the volume, so just allocate the PARTITION -; structure without extra fields. - push sizeof.PARTITION - pop eax - call malloc - test eax, eax - jz .nothing - mov edx, dword [.start] - mov dword [eax+PARTITION.FirstSector], edx - mov edx, dword [.start+4] +.start dq ? +.length dq ? +end virtual +; When disk_add_partition is called, ebx contains a pointer to +; a two-sectors-sized buffer. This function saves ebx in the stack +; immediately before ebp. +virtual at ebp-4 +.buffer dd ? +end virtual +; 1. Read the bootsector to the buffer. + mov al, DISKFUNC.read + mov ebx, [.buffer] + add ebx, 512 + push 1 + stdcall disk_call_driver, ebx, dword [.start], dword [.start+4], esp +; 2. Run tests for all supported filesystems. If at least one test succeeded, +; go to 4. +; For tests: qword [ebp+8] = partition start, qword [ebp+10h] = partition +; length, [esp] = 0 if reading bootsector failed or 1 if succeeded, +; ebx points to the buffer for bootsector. + call fat_create_partition + test eax, eax + jnz .success +; 3. No file system has recognized the volume, so just allocate the PARTITION +; structure without extra fields. + push sizeof.PARTITION + pop eax + call malloc + test eax, eax + jz .nothing + mov edx, dword [.start] + mov dword [eax+PARTITION.FirstSector], edx + mov edx, dword [.start+4] mov dword [eax+PARTITION.FirstSector+4], edx mov edx, dword [.length] - mov dword [eax+PARTITION.Length], edx - mov edx, dword [.length+4] - mov dword [eax+PARTITION.Length+4], edx - mov [eax+PARTITION.Disk], esi - and [eax+PARTITION.FSUserFunctions], 0 -.success: -.nothing: -; 4. Return with eax = pointer to PARTITION or NULL. - pop ecx - ret - -; This function is called from file_system_lfn. + mov dword [eax+PARTITION.Length], edx + mov edx, dword [.length+4] + mov dword [eax+PARTITION.Length+4], edx + mov [eax+PARTITION.Disk], esi + and [eax+PARTITION.FSUserFunctions], 0 +.success: +.nothing: +; 4. Return with eax = pointer to PARTITION or NULL. + pop ecx + ret + +; This function is called from file_system_lfn. ; This handler gets the control each time when fn 70 is called ; with unknown item of root subdirectory. ; in: esi -> name @@ -1082,13 +1084,13 @@ dyndisk_handler: ; We found the addressed DISK structure. ; 5. Reference the disk. lock inc [ebx+DISK.RefCount] -; 6. Now we are sure that the DISK structure is not going to die at least -; while we are working with it, so release the global mutex. - call mutex_unlock - pop ecx ; pop from the stack saved value of esi -; 7. Acquire the mutex for media object. - pop edi ; restore edi - lea ecx, [ebx+DISK.MediaLock] +; 6. Now we are sure that the DISK structure is not going to die at least +; while we are working with it, so release the global mutex. + call mutex_unlock + pop ecx ; pop from the stack saved value of esi +; 7. Acquire the mutex for media object. + pop edi ; restore edi + lea ecx, [ebx+DISK.MediaLock] call mutex_lock ; 8. Get the media object. If it is not NULL, reference it. xor edx, edx @@ -1197,50 +1199,50 @@ fs_dyndisk: pop edx edx edx eax ; edx = pointer to DISK, eax = NULL or edx test eax, eax jz .nomedia -.main: - cmp ecx, [edx+DISK.NumPartitions] - jae .notfound - mov eax, [edx+DISK.Partitions] - mov eax, [eax+ecx*4] - mov edi, [eax+PARTITION.FSUserFunctions] - test edi, edi - jz .nofs - mov ecx, [ebx] - cmp [edi], ecx - jbe .unsupported - push edx - push ebp - mov ebp, eax - call dword [edi+4+ecx*4] - pop ebp - pop edx - mov dword [esp+32], eax - mov dword [esp+20], ebx -.cleanup: - mov esi, edx - call disk_media_dereference - call disk_dereference - ret -.nofs: - mov dword [esp+32], ERROR_UNKNOWN_FS - jmp .cleanup -.notfound: - mov dword [esp+32], ERROR_FILE_NOT_FOUND - jmp .cleanup -.unsupported: - mov dword [esp+32], ERROR_UNSUPPORTED_FS - jmp .cleanup -.nomedia: - test ecx, ecx - jnz .notfound +.main: + cmp ecx, [edx+DISK.NumPartitions] + jae .notfound + mov eax, [edx+DISK.Partitions] + mov eax, [eax+ecx*4] + mov edi, [eax+PARTITION.FSUserFunctions] + test edi, edi + jz .nofs + mov ecx, [ebx] + cmp [edi], ecx + jbe .unsupported + push edx + push ebp + mov ebp, eax + call dword [edi+4+ecx*4] + pop ebp + pop edx + mov dword [esp+32], eax + mov dword [esp+20], ebx +.cleanup: + mov esi, edx + call disk_media_dereference + call disk_dereference + ret +.nofs: + mov dword [esp+32], ERROR_UNKNOWN_FS + jmp .cleanup +.notfound: + mov dword [esp+32], ERROR_FILE_NOT_FOUND + jmp .cleanup +.unsupported: + mov dword [esp+32], ERROR_UNSUPPORTED_FS + jmp .cleanup +.nomedia: + test ecx, ecx + jnz .notfound test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION jz .deverror -; if the driver does not support insert notifications and we are the only fs -; operation with this disk, issue the fake insert notification; if media is -; still not inserted, 'disk_media_changed' will detect this and do nothing - lea ecx, [edx+DISK.MediaLock] - call mutex_lock - cmp [edx+DISK.MediaRefCount], 1 +; if the driver does not support insert notifications and we are the only fs +; operation with this disk, issue the fake insert notification; if media is +; still not inserted, 'disk_media_changed' will detect this and do nothing + lea ecx, [edx+DISK.MediaLock] + call mutex_lock + cmp [edx+DISK.MediaRefCount], 1 jnz .noluck call mutex_unlock push edx diff --git a/kernel/branches/net/blkdev/disk_cache.inc b/kernel/branches/net/blkdev/disk_cache.inc index 6542796f40..ed4117ea26 100644 --- a/kernel/branches/net/blkdev/disk_cache.inc +++ b/kernel/branches/net/blkdev/disk_cache.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Revision: 2381 $ @@ -15,17 +15,17 @@ $Revision: 2381 $ ; out: eax = error code; 0 = ok fs_read32_sys: ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, -; this request should be processed by hd_read. - cmp [ebp+PARTITION.Disk], 'old' - jnz @f - add eax, dword [ebp+PARTITION.FirstSector] - mov [hdd_appl_data], 0 - call hd_read - mov [hdd_appl_data], 1 ; restore to default state - mov eax, [hd_error] - ret -@@: -; In the normal case, save ecx, set ecx to SysCache and let the common part +; this request should be processed by hd_read. + cmp [ebp+PARTITION.Disk], 'old' + jnz @f + add eax, dword [ebp+PARTITION.FirstSector] + mov [hdd_appl_data], 0 + call hd_read + mov [hdd_appl_data], 1 ; restore to default state + mov eax, [hd_error] + ret +@@: +; In the normal case, save ecx, set ecx to SysCache and let the common part ; do its work. push ecx mov ecx, [ebp+PARTITION.Disk] @@ -40,17 +40,17 @@ fs_read32_sys: ; out: eax = error code; 0 = ok fs_read32_app: ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, -; this request should be processed by hd_read. - cmp [ebp+PARTITION.Disk], 'old' - jnz @f - add eax, dword [ebp+PARTITION.FirstSector] - mov [hdd_appl_data], 1 - call hd_read - mov eax, [hd_error] - ret -@@: -; In the normal case, save ecx, set ecx to AppCache and let the common part -; do its work. +; this request should be processed by hd_read. + cmp [ebp+PARTITION.Disk], 'old' + jnz @f + add eax, dword [ebp+PARTITION.FirstSector] + mov [hdd_appl_data], 1 + call hd_read + mov eax, [hd_error] + ret +@@: +; In the normal case, save ecx, set ecx to AppCache and let the common part +; do its work. push ecx mov ecx, [ebp+PARTITION.Disk] add ecx, DISK.AppCache @@ -65,34 +65,34 @@ fs_read32_common: ja @f mov eax, DISK_STATUS_END_OF_MEDIA pop ecx - ret -@@: -; 2. Get the absolute sector on the disk. - push edx esi - xor edx, edx - add eax, dword [ebp+PARTITION.FirstSector] - adc edx, dword [ebp+PARTITION.FirstSector+4] + ret +@@: +; 2. Get the absolute sector on the disk. + push edx esi + xor edx, edx + add eax, dword [ebp+PARTITION.FirstSector] + adc edx, dword [ebp+PARTITION.FirstSector+4] ; 3. If there is no cache for this disk, just pass the request to the driver. cmp [ecx+DISKCACHE.pointer], 0 jnz .scancache push 1 push esp ; numsectors - push edx ; startsector - push eax ; startsector - push ebx ; buffer - mov esi, [ebp+PARTITION.Disk] - mov al, DISKFUNC.read - call disk_call_driver - pop ecx - pop esi edx - pop ecx - ret -.scancache: -; 4. Scan the cache. - push edi ecx ; scan cache - push edx eax -virtual at esp -.sector_lo dd ? + push edx ; startsector + push eax ; startsector + push ebx ; buffer + mov esi, [ebp+PARTITION.Disk] + mov al, DISKFUNC.read + call disk_call_driver + pop ecx + pop esi edx + pop ecx + ret +.scancache: +; 4. Scan the cache. + push edi ecx ; scan cache + push edx eax +virtual at esp +.sector_lo dd ? .sector_hi dd ? .cache dd ? end virtual @@ -132,13 +132,13 @@ end virtual jnz .read_done push 1 - push esp - push edx - push [.sector_lo+12] - mov ecx, [.cache+16] - mov eax, edi - shl eax, 9 - add eax, [ecx+DISKCACHE.data] + push esp + push edx + push [.sector_lo+12] + mov ecx, [.cache+16] + mov eax, edi + shl eax, 9 + add eax, [ecx+DISKCACHE.data] push eax mov esi, [ebp+PARTITION.Disk] mov al, DISKFUNC.read @@ -186,17 +186,17 @@ end virtual ; out: eax = error code; 0 = ok fs_write32_sys: ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, -; this request should be processed by hd_write. - cmp [ebp+PARTITION.Disk], 'old' - jnz @f - add eax, dword [ebp+PARTITION.FirstSector] - mov [hdd_appl_data], 0 - call hd_write - mov [hdd_appl_data], 1 ; restore to default state - mov eax, [hd_error] - ret -@@: -; In the normal case, save ecx, set ecx to SysCache and let the common part +; this request should be processed by hd_write. + cmp [ebp+PARTITION.Disk], 'old' + jnz @f + add eax, dword [ebp+PARTITION.FirstSector] + mov [hdd_appl_data], 0 + call hd_write + mov [hdd_appl_data], 1 ; restore to default state + mov eax, [hd_error] + ret +@@: +; In the normal case, save ecx, set ecx to SysCache and let the common part ; do its work. push ecx mov ecx, [ebp+PARTITION.Disk] @@ -211,17 +211,17 @@ fs_write32_sys: ; out: eax = error code; 0 = ok fs_write32_app: ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, -; this request should be processed by hd_write. - cmp [ebp+PARTITION.Disk], 'old' - jnz @f - add eax, dword [ebp+PARTITION.FirstSector] - mov [hdd_appl_data], 1 - call hd_write - mov eax, [hd_error] - ret -@@: -; In the normal case, save ecx, set ecx to AppCache and let the common part -; do its work. +; this request should be processed by hd_write. + cmp [ebp+PARTITION.Disk], 'old' + jnz @f + add eax, dword [ebp+PARTITION.FirstSector] + mov [hdd_appl_data], 1 + call hd_write + mov eax, [hd_error] + ret +@@: +; In the normal case, save ecx, set ecx to AppCache and let the common part +; do its work. push ecx mov ecx, [ebp+PARTITION.Disk] add ecx, DISK.AppCache @@ -235,35 +235,35 @@ fs_write32_common: cmp dword [ebp+PARTITION.Length], eax ja @f mov eax, DISK_STATUS_END_OF_MEDIA - pop ecx - ret -@@: - push edx esi -; 2. Get the absolute sector on the disk. - xor edx, edx - add eax, dword [ebp+PARTITION.FirstSector] + pop ecx + ret +@@: + push edx esi +; 2. Get the absolute sector on the disk. + xor edx, edx + add eax, dword [ebp+PARTITION.FirstSector] adc edx, dword [ebp+PARTITION.FirstSector+4] ; 3. If there is no cache for this disk, just pass request to the driver. cmp [ecx+DISKCACHE.pointer], 0 jnz .scancache push 1 push esp ; numsectors - push edx ; startsector - push eax ; startsector - push ebx ; buffer - mov esi, [ebp+PARTITION.Disk] - mov al, DISKFUNC.write - call disk_call_driver - pop ecx - pop esi edx - pop ecx - ret -.scancache: -; 4. Scan the cache. - push edi ecx ; scan cache - push edx eax -virtual at esp -.sector_lo dd ? + push edx ; startsector + push eax ; startsector + push ebx ; buffer + mov esi, [ebp+PARTITION.Disk] + mov al, DISKFUNC.write + call disk_call_driver + pop ecx + pop esi edx + pop ecx + ret +.scancache: +; 4. Scan the cache. + push edi ecx ; scan cache + push edx eax +virtual at esp +.sector_lo dd ? .sector_hi dd ? .cache dd ? end virtual @@ -314,13 +314,13 @@ end virtual mov edx, [.sector_hi] mov [esi], eax ; sector number mov [esi+4], edx ; sector number - -.yes_in_cache_write: - - mov dword [esi+8], 2 ; write - differs from hd - - shl edi, 9 - mov ecx, [.cache] + +.yes_in_cache_write: + + mov dword [esi+8], 2 ; write - differs from hd + + shl edi, 9 + mov ecx, [.cache] add edi, [ecx+DISKCACHE.data] mov esi, ebx @@ -357,31 +357,31 @@ find_empty_slot64: shl eax, 2 add eax, [esi+DISKCACHE.pointer] cmp dword [eax+8], 2 - jb .found_slot ; it's empty or read - dec ecx - jnz .search_for_empty - stdcall write_cache64, [ebp+PARTITION.Disk] ; no empty slots found, write all - test eax, eax - jne .found_slot_access_denied - jmp .search_again ; and start again + jb .found_slot ; it's empty or read + dec ecx + jnz .search_for_empty + stdcall write_cache64, [ebp+PARTITION.Disk] ; no empty slots found, write all + test eax, eax + jne .found_slot_access_denied + jmp .search_again ; and start again .found_slot: mov [esi+DISKCACHE.search_start], edi xor eax, eax ; success .found_slot_access_denied: - ret - -; This function is intended to replace the old 'write_cache' function. -proc write_cache64 uses ecx edx esi edi, disk:dword -locals -cache_chain_started dd 0 -cache_chain_size dd ? -cache_chain_pos dd ? -cache_chain_ptr dd ? -endl -saved_esi_pos = 16+12 ; size of local variables + size of registers before esi -; If there is no cache for this disk, nothing to do. - cmp [esi+DISKCACHE.pointer], 0 - jz .flush + ret + +; This function is intended to replace the old 'write_cache' function. +proc write_cache64 uses ecx edx esi edi, disk:dword +locals +cache_chain_started dd 0 +cache_chain_size dd ? +cache_chain_pos dd ? +cache_chain_ptr dd ? +endl +saved_esi_pos = 16+12 ; size of local variables + size of registers before esi +; If there is no cache for this disk, nothing to do. + cmp [esi+DISKCACHE.pointer], 0 + jz .flush ;----------------------------------------------------------- ; write all changed sectors to disk ;----------------------------------------------------------- @@ -442,13 +442,13 @@ saved_esi_pos = 16+12 ; size of local variables + size of registers before esi dec ecx jnz .write_cache_more call .flush_cache_chain - test eax, eax - jnz .nothing -.flush: - mov esi, [disk] - mov al, DISKFUNC.flush - call disk_call_driver -.nothing: + test eax, eax + jnz .nothing +.flush: + mov esi, [disk] + mov al, DISKFUNC.flush + call disk_call_driver +.nothing: ret .flush_cache_chain: @@ -463,13 +463,13 @@ saved_esi_pos = 16+12 ; size of local variables + size of registers before esi .write_cache_sector: mov [cache_chain_size], 1 mov [cache_chain_pos], edi -.write_cache_chain: - pusha - mov edi, [cache_chain_pos] - mov ecx, [ebp-saved_esi_pos] - shl edi, 9 - add edi, [ecx+DISKCACHE.data] - mov ecx, [cache_chain_size] +.write_cache_chain: + pusha + mov edi, [cache_chain_pos] + mov ecx, [ebp-saved_esi_pos] + shl edi, 9 + add edi, [ecx+DISKCACHE.data] + mov ecx, [cache_chain_size] push ecx push esp ; numsectors mov eax, [cache_chain_ptr] @@ -547,13 +547,13 @@ disk_init_cache: imul eax, 7 mov [esi+DISK.AppCache.data_size], eax mov [esi+DISK.AppCache.pointer], edx - - mov eax, [esi+DISK.SysCache.data_size] - push ebx - call calculate_for_hd64 - pop ebx - add eax, [esi+DISK.SysCache.pointer] - mov [esi+DISK.SysCache.data], eax + + mov eax, [esi+DISK.SysCache.data_size] + push ebx + call calculate_for_hd64 + pop ebx + add eax, [esi+DISK.SysCache.pointer] + mov [esi+DISK.SysCache.data], eax mov [esi+DISK.SysCache.sad_size], ecx push edi @@ -562,13 +562,13 @@ disk_init_cache: xor eax, eax rep stosd pop edi - - mov eax, [esi+DISK.AppCache.data_size] - push ebx - call calculate_for_hd64 - pop ebx - add eax, [esi+DISK.AppCache.pointer] - mov [esi+DISK.AppCache.data], eax + + mov eax, [esi+DISK.AppCache.data_size] + push ebx + call calculate_for_hd64 + pop ebx + add eax, [esi+DISK.AppCache.pointer] + mov [esi+DISK.AppCache.data], eax mov [esi+DISK.AppCache.sad_size], ecx push edi @@ -588,56 +588,58 @@ disk_init_cache: .nocache: mov [esi+DISK.SysCache.pointer], eax mov [esi+DISK.AppCache.pointer], eax - mov al, 1 - ret - -calculate_for_hd64: - push eax - mov ebx, eax - shr eax, 9 - lea eax, [eax*3] - shl eax, 2 - sub ebx, eax - shr ebx, 9 - mov ecx, ebx - shl ebx, 9 - pop eax - sub eax, ebx - dec ecx - ret - - -; This internal function is called from disk_media_dereference to free the -; allocated cache, if there is one. -; esi = pointer to DISK structure + mov al, 1 + ret + +calculate_for_hd64: + push eax + mov ebx, eax + shr eax, 9 + lea eax, [eax*3] + shl eax, 2 + sub ebx, eax + shr ebx, 9 + mov ecx, ebx + shl ebx, 9 + pop eax + sub eax, ebx + dec ecx + ret + + +; This internal function is called from disk_media_dereference to free the +; allocated cache, if there is one. +; esi = pointer to DISK structure disk_free_cache: ; The algorithm is straightforward. mov eax, [esi+DISK.SysCache.pointer] test eax, eax jz .nothing - stdcall kernel_free, eax -.nothing: - ret - -; This function flushes all modified data from both caches for the given DISK. -; esi = pointer to DISK -disk_sync: -; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, -; this request should be processed by write_cache. - cmp esi, 'old' - jnz @f - mov [hdd_appl_data], 0 - call write_cache - mov [hdd_appl_data], 1 - jmp write_cache -@@: -; The algorithm is straightforward. - push esi - push esi ; for second write_cache64 - push esi ; for first write_cache64 - add esi, DISK.SysCache - call write_cache64 - add esi, DISK.AppCache - DISK.SysCache - call write_cache64 - pop esi - ret + stdcall kernel_free, eax +.nothing: + ret + +; This function flushes all modified data from both caches for the given DISK. +; esi = pointer to DISK +disk_sync: +; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, +; this request should be processed by write_cache. + cmp esi, 'old' + jnz @f + mov [hdd_appl_data], 0 + call write_cache + mov [hdd_appl_data], 1 + call write_cache + mov eax, [hd_error] + ret +@@: +; The algorithm is straightforward. + push esi + push esi ; for second write_cache64 + push esi ; for first write_cache64 + add esi, DISK.SysCache + call write_cache64 + add esi, DISK.AppCache - DISK.SysCache + call write_cache64 + pop esi + ret diff --git a/kernel/branches/net/blkdev/hd_drv.inc b/kernel/branches/net/blkdev/hd_drv.inc index 374a178087..ce465cde37 100644 --- a/kernel/branches/net/blkdev/hd_drv.inc +++ b/kernel/branches/net/blkdev/hd_drv.inc @@ -340,7 +340,11 @@ hd_timeout_error: ; call clear_application_table_status ; mov esi,hd_timeout_str ; call sys_msg_board_str + if lang eq sp + DEBUGF 1,"K : FS - HD tiempo de espera agotado\n" + else DEBUGF 1,"K : FS - HD timeout\n" + end if mov [hd_error], 1 pop eax @@ -352,7 +356,11 @@ hd_read_error: ; call clear_application_table_status ; mov esi,hd_read_str ; call sys_msg_board_str + if lang eq sp + DEBUGF 1,"K : FS - HD error de lectura\n" + else DEBUGF 1,"K : FS - HD read error\n" + end if pop edx eax ret @@ -362,7 +370,11 @@ hd_write_error: ; call clear_application_table_status ; mov esi,hd_write_str ; call sys_msg_board_str + if lang eq sp + DEBUGF 1,"K : FS - HD error de escritura\n" + else DEBUGF 1,"K : FS - HD write error\n" + end if ret hd_write_error_dma: @@ -370,7 +382,11 @@ hd_write_error_dma: ; call clear_application_table_status ; mov esi, hd_write_str ; call sys_msg_board_str - DEBUGF 1,"K : FS - HD read error\n" + if lang eq sp + DEBUGF 1,"K : FS - HD error de escritura\n" + else + DEBUGF 1,"K : FS - HD write error\n" + end if pop esi ret @@ -379,7 +395,11 @@ hd_lba_error: ; call clear_application_table_status ; mov esi,hd_lba_str ; call sys_msg_board_str + if lang eq sp + DEBUGF 1,"K : FS - HD error en LBA\n" + else DEBUGF 1,"K : FS - HD LBA error\n" + end if jmp LBA_read_ret @@ -942,86 +962,86 @@ int13_call: test byte [int13_regs_out+v86_regs.eflags], 1 jnz @f mov edx, ecx -@@: - ret -; \end{diamond} - -reserve_hd1: - - cli - cmp [hd1_status], 0 - je reserve_ok1 - - sti - call change_task - jmp reserve_hd1 - - reserve_ok1: - - push eax - mov eax, [CURRENT_TASK] - shl eax, 5 - mov eax, [eax+CURRENT_TASK+TASKDATA.pid] - mov [hd1_status], eax - pop eax - sti - ret -;******************************************** - -uglobal -hd_in_cache db ? -endg - -reserve_hd_channel: -; BIOS disk accesses are protected with common mutex hd1_status -; This must be modified when hd1_status will not be valid! - cmp [hdpos], 0x80 - jae .ret - cmp [hdbase], 0x1F0 - jne .IDE_Channel_2 -.IDE_Channel_1: - cli - cmp [IDE_Channel_1], 0 - je .reserve_ok_1 - sti - call change_task - jmp .IDE_Channel_1 -.IDE_Channel_2: - cli - cmp [IDE_Channel_2], 0 - je .reserve_ok_2 - sti - call change_task - jmp .IDE_Channel_2 -.reserve_ok_1: - mov [IDE_Channel_1], 1 - push eax - mov al, 1 - jmp @f -.reserve_ok_2: - mov [IDE_Channel_2], 1 - push eax - mov al, 3 -@@: - cmp [hdid], 1 - sbb al, -1 - mov [hd_in_cache], al - pop eax - sti -.ret: - ret - -free_hd_channel: -; see comment at reserve_hd_channel - cmp [hdpos], 0x80 - jae .ret - cmp [hdbase], 0x1F0 - jne .IDE_Channel_2 -.IDE_Channel_1: - mov [IDE_Channel_1], 0 -.ret: - ret -.IDE_Channel_2: - mov [IDE_Channel_2], 0 - ret -;******************************************** +@@: + ret +; \end{diamond} + +reserve_hd1: + + cli + cmp [hd1_status], 0 + je reserve_ok1 + + sti + call change_task + jmp reserve_hd1 + + reserve_ok1: + + push eax + mov eax, [CURRENT_TASK] + shl eax, 5 + mov eax, [eax+CURRENT_TASK+TASKDATA.pid] + mov [hd1_status], eax + pop eax + sti + ret +;******************************************** + +uglobal +hd_in_cache db ? +endg + +reserve_hd_channel: +; BIOS disk accesses are protected with common mutex hd1_status +; This must be modified when hd1_status will not be valid! + cmp [hdpos], 0x80 + jae .ret + cmp [hdbase], 0x1F0 + jne .IDE_Channel_2 +.IDE_Channel_1: + cli + cmp [IDE_Channel_1], 0 + je .reserve_ok_1 + sti + call change_task + jmp .IDE_Channel_1 +.IDE_Channel_2: + cli + cmp [IDE_Channel_2], 0 + je .reserve_ok_2 + sti + call change_task + jmp .IDE_Channel_2 +.reserve_ok_1: + mov [IDE_Channel_1], 1 + push eax + mov al, 1 + jmp @f +.reserve_ok_2: + mov [IDE_Channel_2], 1 + push eax + mov al, 3 +@@: + cmp [hdid], 1 + sbb al, -1 + mov [hd_in_cache], al + pop eax + sti +.ret: + ret + +free_hd_channel: +; see comment at reserve_hd_channel + cmp [hdpos], 0x80 + jae .ret + cmp [hdbase], 0x1F0 + jne .IDE_Channel_2 +.IDE_Channel_1: + mov [IDE_Channel_1], 0 +.ret: + ret +.IDE_Channel_2: + mov [IDE_Channel_2], 0 + ret +;******************************************** diff --git a/kernel/branches/net/blkdev/ide_cache.inc b/kernel/branches/net/blkdev/ide_cache.inc index 309cb27282..78186f14fd 100644 --- a/kernel/branches/net/blkdev/ide_cache.inc +++ b/kernel/branches/net/blkdev/ide_cache.inc @@ -134,12 +134,12 @@ found_slot: call calculate_cache_5 found_slot_access_denied: ret -;-------------------------------------------------------------------- -align 4 -clear_hd_cache: - ret -;-------------------------------------------------------------------- -align 4 +;-------------------------------------------------------------------- +align 4 +clear_hd_cache: + ret +;-------------------------------------------------------------------- +align 4 calculate_cache: ; mov ecx,cache_max ; entries in cache ; mov esi,HD_CACHE+8 diff --git a/kernel/branches/net/blkdev/rdsave.inc b/kernel/branches/net/blkdev/rdsave.inc index a79171cd42..63001fc28c 100644 --- a/kernel/branches/net/blkdev/rdsave.inc +++ b/kernel/branches/net/blkdev/rdsave.inc @@ -24,7 +24,7 @@ sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only) mov ebx, saverd_fileinfo mov [saverd_fileinfo.name], ecx pushad - call file_system_lfn ;in ebx + call file_system_lfn_protected ;in ebx popad mov [esp+32], eax ret diff --git a/kernel/branches/net/boot/bootcode.inc b/kernel/branches/net/boot/bootcode.inc index 5deb6695cb..be8d5251cb 100644 --- a/kernel/branches/net/boot/bootcode.inc +++ b/kernel/branches/net/boot/bootcode.inc @@ -42,7 +42,7 @@ printplain: @@: call putchar lodsb - test al,al + test al, al jnz @b popa ret @@ -91,6 +91,7 @@ boot_read_floppy: inc si cmp si, 10 jb @b +sayerr_badsect: mov si, badsect sayerr_plain: call printplain @@ -110,18 +111,18 @@ sayerr_plain: ; dh - head number conv_abs_to_THS: push bx - mov bx,word [BPB_SecPerTrk] - xor dx,dx + mov bx, word [BPB_SecPerTrk] + xor dx, dx div bx inc dx mov cl, dl ; cl = sector number - mov bx,word [BPB_NumHeads] - xor dx,dx + mov bx, word [BPB_NumHeads] + xor dx, dx div bx ; !!!!!!! ax = track number, dx = head number - mov ch,al ; ch=track number - xchg dh,dl ; dh=head number - mov dl,0 ; dl=0 (drive 0 (a:)) + mov ch, al ; ch=track number + xchg dh, dl ; dh=head number + mov dl, 0 ; dl=0 (drive 0 (a:)) pop bx retn ; needed variables @@ -145,8 +146,119 @@ FirstDataSector dw 0 ; begin of data ;========================================================================= include 'bootvesa.inc' ;Include source for boot vesa +if defined extended_primary_loader +include 'parsers.inc' +end if start_of_code: + +if defined extended_primary_loader +; save data from primary loader + mov word [cs:bootcallback], si + mov word [cs:bootcallback+2], ds + push cs + pop ds + mov [bootdevice], ax + mov [bootfs], bx + +; set up stack + mov ax, 3000h + mov ss, ax + mov sp, 0EC00h + +; try to load configuration file + mov ax, 1 + mov di, config_file_struct + call [bootcallback] + cld + push cs + pop es +; bx=0 - ok, bx=1 - part of file loaded, assume this is ok + cmp bx, 1 + ja .config_bad +; configuration file was loaded, parse +; if length is too big, use first 0FFFFh bytes + test dx, dx + jz @f + mov ax, 0FFFFh +@@: +; ds:si will be pointer to current data, dx = limit + xchg ax, dx + push 4000h + pop ds + xor si, si +.parse_loop: +; skip spaces + cmp si, dx + jae .parse_done + lodsb + cmp al, ' ' + jbe .parse_loop + dec si +; loop over all possible configuration values + mov bx, config_file_variables +.find_variant: +; get length + mov cx, [es:bx] +; zero length = end of list + jecxz .find_newline +; skip over length + inc bx + inc bx + mov di, bx +; skip over string + add bx, cx +; test whether we have at least cx symbols left + mov ax, cx + add ax, si + jc .next_variant1 + cmp ax, dx + jae .next_variant1 +; save current position + push si +; compare strings + repz cmpsb + jnz .next_variant2 +; strings are equal; look for "=" with possible spaces before and after +@@: + cmp si, dx + jae .next_variant2 + lodsb + cmp al, ' ' + jbe @b + cmp al, '=' + jnz .next_variant2 +; ok, we found the true variant +; ignore saved position on the stack + pop ax +; call the parser + call word [es:bx] +; line parsed, find next +.find_newline: + cmp si, dx + jae .parse_done + lodsb + cmp al, 13 + jz .parse_loop + cmp al, 10 + jz .parse_loop + jmp .find_newline +.next_variant2: +; continue to the next variant, restoring current position + pop si +.next_variant1: +; continue to the next variant +; skip over the parser + inc bx + inc bx + jmp .find_variant +.parse_done: +.config_bad: + +; set up segment registers + push cs + pop ds +else cld ; \begin{diamond}[02.12.2005] ; if bootloader sets ax = 'KL', then ds:si points to loader block @@ -161,7 +273,7 @@ start_of_code: ; (see comment to bx_from_load) cmp cx, 'HA' jnz no_hd_load - cmp dx,'RD' + cmp dx, 'RD' jnz no_hd_load mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007] no_hd_load: @@ -175,6 +287,7 @@ no_hd_load: pop ds push cs pop es +end if ; set videomode mov ax, 3 @@ -378,6 +491,7 @@ wait_loop: ; variant 2 apm_end: _setcursor d80x25_top_num, 0 +if ~ defined extended_primary_loader ;CHECK current of code cmp [cfgmanager.loader_block], -1 jz noloaderblock @@ -387,12 +501,13 @@ apm_end: jnz sayerr push 0 pop es +end if noloaderblock: ; DISPLAY VESA INFORMATION - call print_vesa_info - call calc_vmodes_table - call check_first_parm ;check and enable cursor_pos + call print_vesa_info + call calc_vmodes_table + call check_first_parm ;check and enable cursor_pos ; \begin{diamond}[30.11.2005] cfgmanager: @@ -404,7 +519,9 @@ cfgmanager: ; d) preboot_device = from what boot? ; determine default settings +if ~ defined extended_primary_loader mov [.bSettingsChanged], 0 +end if ;.preboot_gr_end: mov di, preboot_device @@ -412,6 +529,12 @@ cfgmanager: ; set it to use this preloaded image cmp byte [di], 0 jnz .preboot_device_inited +if defined extended_primary_loader + inc byte [di] + cmp byte [bootdevice], 'f' ; floppy? + jz .preboot_device_inited + inc byte [di] +else cmp [.loader_block], -1 jz @f les bx, [.loader_block] @@ -422,17 +545,18 @@ cfgmanager: @@: ; otherwise, set [preboot_device] to 1 (default value - boot from floppy) mov byte [di], 1 +end if .preboot_device_inited: ; following 4 lines set variables to 1 if its current value is 0 cmp byte [di+preboot_dma-preboot_device], 1 adc byte [di+preboot_dma-preboot_device], 0 cmp byte [di+preboot_biosdisk-preboot_device], 1 adc byte [di+preboot_biosdisk-preboot_device], 0 -; default value for VRR is OFF - cmp byte [di+preboot_vrrm-preboot_device], 0 - jnz @f - mov byte [di+preboot_vrrm-preboot_device], 2 -@@: +;; default value for VRR is OFF +; cmp byte [di+preboot_vrrm-preboot_device], 0 +; jnz @f +; mov byte [di+preboot_vrrm-preboot_device], 2 +;@@: ; notify user _setcursor 5,2 @@ -455,18 +579,22 @@ cfgmanager: mov si, curvideo_msg call print - call draw_current_vmode + call draw_current_vmode mov si, usebd_msg cmp [preboot_biosdisk], 1 call .say_on_off - mov si, vrrm_msg - cmp [preboot_vrrm], 1 - call .say_on_off +; mov si, vrrm_msg +; cmp [preboot_vrrm], 1 +; call .say_on_off mov si, preboot_device_msg call print mov al, [preboot_device] +if defined extended_primary_loader + and eax, 3 +else and eax, 7 +end if mov si, [preboot_device_msgs+eax*2] call printplain .show_remarks: @@ -502,14 +630,14 @@ cfgmanager: push dword [es:8*4] pop dword [.oldtimer] push dword [.timer] - pop dword [es:8*4] + pop dword [es:8*4] ; mov eax, [es:8*4] ; mov [.oldtimer], eax ; mov eax, [.timer] ; mov [es:8*4], eax sti ; wait for keypressed - xor ax,ax + xor ax, ax int 16h push ax ; restore timer interrupt @@ -532,7 +660,7 @@ cfgmanager: @@: push cx mov cx, 76 - rep stosw + rep stosw pop cx add di, 4*2 loop @b @@ -546,46 +674,54 @@ cfgmanager: jz .change_a cmp al, 'b' jz .change_b - cmp al, 'c' - jz .change_c - cmp al, 'd' +; cmp al, 'c' +; jz .change_c + cmp al, 'c' ; 'd' jnz .show_remarks _setcursor 15,0 mov si, bdev call print +if defined extended_primary_loader + mov bx, '12' +else mov bx, '14' +end if call getkey mov [preboot_device], al _setcursor 13,0 .d: +if ~ defined extended_primary_loader mov [.bSettingsChanged], 1 +end if call clear_vmodes_table ;clear vmodes_table - jmp .printcfg + jmp .printcfg .change_a: .loops: call draw_vmodes_table _setcursor 25,0 ; out of screen - xor ax,ax + xor ax, ax int 0x16 ; call clear_table_cursor ;clear current position of cursor - mov si,word [cursor_pos] + mov si, word [cursor_pos] - cmp ah,0x48;x,0x48E0 ; up + cmp ah, 0x48;x,0x48E0 ; up jne .down - cmp si,modes_table + cmp si, modes_table jbe .loops - sub word [cursor_pos],size_of_step + sub word [cursor_pos], size_of_step jmp .loops -.down: cmp ah,0x50;x,0x50E0 ; down +.down: + cmp ah, 0x50;x,0x50E0 ; down jne .pgup - cmp word[es:si+10],-1 - je .loops - add word [cursor_pos],size_of_step + cmp word[es:si+10], -1 + je .loops + add word [cursor_pos], size_of_step jmp .loops -.pgup: cmp ah,0x49 ; page up +.pgup: + cmp ah, 0x49 ; page up jne .pgdn sub si, size_of_step*long_v_table cmp si, modes_table @@ -602,7 +738,8 @@ cfgmanager: mov word [home_cursor], si jmp .loops -.pgdn: cmp ah,0x51 ; page down +.pgdn: + cmp ah, 0x51 ; page down jne .enter mov ax, [end_cursor] add si, size_of_step*long_v_table @@ -622,7 +759,8 @@ cfgmanager: mov word [home_cursor], si jmp .loops -.enter: cmp al,0x0D;x,0x1C0D ; enter +.enter: + cmp al, 0x0D;x,0x1C0D ; enter jne .loops push word [cursor_pos] pop bp @@ -632,9 +770,9 @@ cfgmanager: pop word [y_save] push word [es:bp+6] pop word [number_vm] - mov word [preboot_graph],bp ;save choose + mov word [preboot_graph], bp ;save choose - jmp .d + jmp .d .change_b: _setcursor 15,0 @@ -650,15 +788,15 @@ cfgmanager: mov [preboot_biosdisk], al _setcursor 11,0 jmp .d -.change_c: - _setcursor 15,0 - mov si, vrrmprint - call print - mov bx, '12' - call getkey - mov [preboot_vrrm], al - _setcursor 12,0 - jmp .d +;.change_c: +; _setcursor 15,0 +; mov si, vrrmprint +; call print +; mov bx, '12' +; call getkey +; mov [preboot_vrrm], al +; _setcursor 12,0 +; jmp .d ;;;;;;;;;;;;;;;;;;;;;;;;;;;; .say_on_off: pushf @@ -667,15 +805,20 @@ cfgmanager: popf jz @f mov si, off_msg -@@: jmp printplain +@@: + jmp printplain ; novesa and vervesa strings are not used at the moment of executing this code virtual at novesa .oldtimer dd ? .starttime dd ? +if ~ defined extended_primary_loader .bSettingsChanged db ? +end if .timer dd ? end virtual +if ~ defined extended_primary_loader .loader_block dd -1 +end if .gettime: mov ah, 0 int 1Ah @@ -692,7 +835,11 @@ end virtual pushad call .gettime sub eax, [.starttime] +if defined extended_primary_loader + sub ax, [preboot_timeout] +else sub ax, 18*5 +end if jae .timergo neg ax add ax, 18-1 @@ -708,20 +855,30 @@ if lang eq ru mov cl, 'ã' jz @f mov cl, 'ë' -@@: mov [time_str+9], cl +@@: + mov [time_str+9], cl else if lang eq et cmp al, 1 ja @f mov [time_str+9], ' ' - mov [time_str+10],' ' + mov [time_str+10], ' ' @@: +else if lang eq sp +; esperar 5/4/3/2 segundos, 1 segundo + cmp al, 1 + mov cl, 's' + ja @f + mov cl, ' ' +@@: + mov [time_str+10], cl else ; wait 5/4/3/2 seconds, 1 second cmp al, 1 mov cl, 's' ja @f mov cl, ' ' -@@: mov [time_str+9], cl +@@: + mov [time_str+9], cl end if add al, '0' mov [time_str+1], al @@ -748,6 +905,7 @@ end if mov si, loading_msg call print _setcursor 15,0 +if ~ defined extended_primary_loader cmp [.bSettingsChanged], 0 jz .load cmp [.loader_block], -1 @@ -788,6 +946,7 @@ end if call printplain _setcursor 15,0 .load: +end if ; \end{diamond}[02.12.2005] ; ASK GRAPHICS MODE @@ -796,18 +955,17 @@ end if ; GRAPHICS ACCELERATION ; force yes - mov [es:0x901C], byte 1 + mov [es:BOOT_MTRR], byte 1 ; DMA ACCESS TO HD mov al, [preboot_dma] - mov [es:0x901F], al + mov [es:BOOT_DMA], al -; VRR_M USE - - mov al,[preboot_vrrm] - mov [es:0x9030], al - mov [es:0x901E], byte 1 +;; VRR_M USE +; +; mov al,[preboot_vrrm] +; mov [es:0x9030], al ; BOOT DEVICE @@ -820,9 +978,9 @@ include '../detect/biosmem.inc' ; READ DISKETTE TO MEMORY - cmp [boot_dev],0 + cmp [boot_dev], 0 jne no_sys_on_floppy - mov si,diskload + mov si, diskload call print xor ax, ax ; reset drive xor dx, dx @@ -967,6 +1125,7 @@ sayerr_floppy: mov dx, 0x3f2 mov al, 0 out dx, al +sayerr_memmove: mov si, memmovefailed jmp sayerr_plain @@: @@ -1145,6 +1304,40 @@ no_sys_on_floppy: mov al, 0 out dx, al +if defined extended_primary_loader + cmp [boot_dev], 1 + jne no_sys_from_primary +; load kolibri.img using callback from primary loader + and word [movedesc + 24 + 2], 0 + mov byte [movedesc + 24 + 4], 10h +; read in blocks of 64K until file is fully loaded + mov ax, 1 +.repeat: + mov di, image_file_struct + call [bootcallback] + push cs + pop ds + push cs + pop es + cmp bx, 1 + ja sayerr_badsect + push bx + mov si, movedesc + and word [si + 16 + 2], 0 + mov byte [si + 16 + 4], 4 + mov ah, 87h + mov cx, 8000h + int 15h + pop bx + test ah, ah + jnz sayerr_memmove + inc byte [si + 24 + 4] + test bx, bx + jz no_sys_from_primary + mov ax, 2 + jmp .repeat +no_sys_from_primary: +end if ; SET GRAPHICS diff --git a/kernel/branches/net/boot/booteng.inc b/kernel/branches/net/boot/booten.inc similarity index 69% rename from kernel/branches/net/boot/booteng.inc rename to kernel/branches/net/boot/booten.inc index 4a4ab96afc..9ccc12f562 100644 --- a/kernel/branches/net/boot/booteng.inc +++ b/kernel/branches/net/boot/booten.inc @@ -11,7 +11,7 @@ ; ;====================================================================== -$Revision $ +$Revision: 2455 $ d80x25_bottom: @@ -23,39 +23,27 @@ d80x25_bottom: d80x25_bottom_num = 3 msg_apm db " APM x.x ", 0 -vervesa db "Version of Vesa: Vesa x.x",13,10,0 novesa db "Display: EGA/CGA",13,10,0 s_vesa db "Version of VESA: " .ver db "?.?",13,10,0 gr_mode db "Select a videomode: ",13,10,0 -;s_bpp db 13,10,186," ƒ«ã¡š­  梥â : " -; .bpp dw "??" -; db 13,10,0 - -vrrmprint db "Apply VRR? (picture frequency greater than 60Hz" - db " only for transfers:",13,10 - db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0 - ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0 +if defined extended_primary_loader +bdev db "Load ramdisk from [1-floppy; 2-kolibri.img]: ",0 +else bdev db "Load ramdisk from [1-floppy; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-use preloaded ram-image from kernel restart;" db 13,10,186," " db "4-create blank image]: ",0 -probetext db 13,10,13,10,186," Use standart graphics mode? [1-yes, " - db "2-probe bios (Vesa 3.0)]: ",0 -;memokz256 db 13,10,186," RAM 256 Mb",0 -;memokz128 db 13,10,186," RAM 128 Mb",0 -;memokz64 db 13,10,186," RAM 64 Mb",0 -;memokz32 db 13,10,186," RAM 32 Mb",0 -;memokz16 db 13,10,186," RAM 16 Mb",0 +end if + prnotfnd db "Fatal - Videomode not found.",0 -;modena db "Fatal - VBE 0x112+ required.",0 + not386 db "Fatal - CPU 386+ required.",0 -btns db "Fatal - Can't determine color depth.",0 fatalsel db "Fatal - Graphics mode not supported by hardware.",0 pres_key db "Press any key to choose a new videomode.",0 badsect db 13,10,186," Fatal - Bad sector. Replace floppy.",0 @@ -73,29 +61,33 @@ time_str db " 5 seconds" current_cfg_msg db "Current settings:",13,10,0 curvideo_msg db " [a] Videomode: ",0 -;modes_msg dw mode4,mode1,mode2,mode3 -;modevesa20 db " with LFB",0 -;modevesa12 db ", VESA 1.2 Bnk",0 mode0 db "320x200, EGA/CGA 256 colors",13,10,0 mode9 db "640x480, VGA 16 colors",13,10,0 -;probeno_msg db " (standard mode)",0 -;probeok_msg db " (check nonstandard modes)",0 -;dma_msg db " [b] Use DMA for HDD access:",0 usebd_msg db " [b] Add disks visible by BIOS:",0 on_msg db " on",13,10,0 off_msg db " off",13,10,0 -;readonly_msg db " only for reading",13,10,0 -vrrm_msg db " [c] Use VRR:",0 -preboot_device_msg db " [d] Floppy image: ",0 + +preboot_device_msg db " [c] Floppy image: ",0 + +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "real floppy",13,10,0 +pdm2 db "C:\kolibri.img (FAT32)",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3 pdm1 db "real floppy",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "use already loaded image",13,10,0 pdm4 db "create blank image",13,10,0 +end if + loading_msg db "Loading KolibriOS...",0 + +if ~ defined extended_primary_loader save_quest db "Remember current settings? [y/n]: ",0 loader_block_error db "Bootloader data invalid, I cannot continue. Stopped.",0 +end if _st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿',13,10,0 _r1 db 186,' ³ 320x200 EGA/CGA 256 colors ³ ³',13,10,0 @@ -104,7 +96,6 @@ _rs db 186,' _bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0 remark1 db "Default values were selected to match most of configurations, but not all.",0 -remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 -remark3 db "If the system does not boot, try to disable the item [b].",0 -remarks dw remark1, remark2, remark3 -num_remarks = 3 +remark2 db "If the system does not boot, try to disable the item [b].",0 +remarks dw remark1, remark2 +num_remarks = 2 diff --git a/kernel/branches/net/boot/bootet.inc b/kernel/branches/net/boot/bootet.inc index 0371b144db..d720c5fb58 100644 --- a/kernel/branches/net/boot/bootet.inc +++ b/kernel/branches/net/boot/bootet.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;====================================================================== ; @@ -13,60 +13,39 @@ $Revision$ - + d80x25_bottom: - db 186,' KolibriOS based on MenuetOS and comes with ABSOLUTELY ' - db 'NO WARRANTY ',186 - db 186,' See file COPYING for details ' + db 186,' KolibriOS pohineb MenuetOS ja kaasas IGASUGUSE GARANTI' + db 'ITA ',186 + db 186,' Naha faili COPYING detailid ' db ' ',186 line_full_bottom d80x25_bottom_num = 3 +msg_apm db " APM x.x ", 0 novesa db "Ekraan: EGA/CGA",13,10,0 -vervesa db "Vesa versioon: Vesa x.x",13,10,0 -vervesa_off=20 -msg_apm db " APM x.x ", 0 -gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, " - db "[3] 1024x768, [4] 1280x1024",13,10 - db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, " - db "[7] 1024x768, [8] 1280x1024",13,10 - db 186," EGA/CGA 256 värvi: [9] 320x200, " - db "VGA 16 värvi: [0] 640x480",13,10 - db 186," Vali reziim: ",0 -bt24 db "Bitti pikseli kohta: 24",13,10,0 -bt32 db "Bitti pikseli kohta: 32",13,10,0 -vrrmprint db "Kinnita VRR? (ekraani sagedus suurem kui 60Hz" - db " ainult:",13,10 - db 186," 1024*768->800*600 ja 800*600->640*480) [1-jah,2-ei]:",0 -;askmouse db " Hiir:" -; db " [1] PS/2 (USB), [2] Com1, [3] Com2." -; db " Vali port [1-3]: ",0 -;no_com1 db 13,10,186, " No COM1 mouse",0 -;no_com2 db 13,10,186, " No COM2 mouse",0 -;ask_dma db "Use DMA for HDD access? [1-yes, 2-only for reading, 3-no]: ",0 -ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0 -;gr_direct db 186," Use direct LFB writing? " -; db "[1-yes/2-no] ? ",0 -;mem_model db 13,10,186," Motherboard memory [1-16 Mb / 2-32 Mb / " -; db "3-64Mb / 4-128 Mb / 5-256 Mb] ? ",0 -;bootlog db 13,10,186," After bootlog display [1-continue/2-pause] ? ",0 +s_vesa db "Vesa versioon: " + .ver db "?.?",13,10,0 + +gr_mode db "Vali videomode: ",13,10,0 + +ask_bd db "Lisa kettad nahtavaks BIOS reziim V86? [1-jah, 2-no]: ",0 + +if defined extended_primary_loader +bdev db "Paigalda mäluketas [1-diskett; 2-kolibri.img]: ",0 +else bdev db "Paigalda mäluketas [1-diskett; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-kasuta eellaaditud mäluketast kerneli restardist;" db 13,10,186," " db "4-loo tühi pilt]: ",0 -probetext db 13,10,13,10,186," Kasuta standartset graafika reziimi? [1-jah, " - db "2-leia biosist (Vesa 3.0)]: ",0 -;memokz256 db 13,10,186," RAM 256 Mb",0 -;memokz128 db 13,10,186," RAM 128 Mb",0 -;memokz64 db 13,10,186," RAM 64 Mb",0 -;memokz32 db 13,10,186," RAM 32 Mb",0 -;memokz16 db 13,10,186," RAM 16 Mb",0 +end if + prnotfnd db "Fataalne - Videoreziimi ei leitud.",0 -;modena db "Fataalne - VBE 0x112+ on vajalik.",0 + not386 db "Fataalne - CPU 386+ on vajalik.",0 -btns db "Fataalne - Ei suuda värvisügavust määratleda.",0 fatalsel db "Fataalne - Graafilist reziimi riistvara ei toeta.",0 +pres_key db "Vajutage suvalist klahvi, et valida uus videomode.",0 badsect db 13,10,186," Fataalne - Vigane sektor. Asenda diskett.",0 memmovefailed db 13,10,186," Fataalne - Int 0x15 liigutamine ebaõnnestus.",0 okt db " ... OK" @@ -81,35 +60,42 @@ time_str db " 5 sekundit" db " automaatseks jätkamiseks",13,10,0 current_cfg_msg db "Praegused seaded:",13,10,0 curvideo_msg db " [a] Videoreziim: ",0 -mode1 db "640x480",0 -mode2 db "800x600",0 -mode3 db "1024x768",0 -mode4 db "1280x1024",0 -modes_msg dw mode4,mode1,mode2,mode3 -modevesa20 db " koos LFB",0 -modevesa12 db ", VESA 1.2 Bnk",0 -mode9 db "320x200, EGA/CGA 256 värvi",0 -mode10 db "640x480, VGA 16 värvi",0 -probeno_msg db " (standard reziim)",0 -probeok_msg db " (kontrolli ebastandardseid reziime)",0 -;dma_msg db " [b] Kasuta DMA'd HDD juurdepääsuks:",0 -usebd_msg db " [b] Add disks visible by BIOS:",0 + +mode0 db "320x200, EGA/CGA 256 värvi",0 +mode9 db "640x480, VGA 16 värvi",0 + +usebd_msg db " [b] Lisa kettad nahtavaks BIOS:",0 on_msg db " sees",13,10,0 off_msg db " väljas",13,10,0 -;readonly_msg db " ainult lugemiseks",13,10,0 -vrrm_msg db " [c] Kasuta VRR:",0 -preboot_device_msg db " [d] Disketi kujutis: ",0 + +preboot_device_msg db " [c] Disketi kujutis: ",0 + +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "reaalne diskett",13,10,0 +pdm2 db "kolibri.img",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3 pdm1 db "reaalne diskett",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "kasuta juba laaditud kujutist",13,10,0 pdm4 db "loo tühi pilt",13,10,0 +end if + loading_msg db "Laadin KolibriOS...",0 + +if ~ defined extended_primary_loader save_quest db "Jäta meelde praegused seaded? [y/n]: ",0 loader_block_error db "Alglaaduri andmed vigased, ei saa jätkata. Peatatud.",0 +end if -remark1 db "Default values were selected to match most of configurations, but not all.",0 -remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 -remark3 db "If the system does not boot, try to disable the item [b].",0 -remarks dw remark1, remark2, remark3 -num_remarks = 3 +_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿',13,10,0 +_r1 db 186,' ³ 320x200 EGA/CGA 256 colors ³ ³',13,10,0 +_r2 db 186,' ³ 640x480 VGA 16 colors ³ ³',13,10,0 +_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³',13,10,0 +_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0 + +remark1 db "Vaikimisi maaratud vaartused on valitud mugavuse enamikes, kuid mitte koik.",0 +remark2 db "Kui susteem ei kaivitu, proovige lulitada kirje [b].",0 +remarks dw remark1, remark2 +num_remarks = 2 diff --git a/kernel/branches/net/boot/bootge.inc b/kernel/branches/net/boot/bootge.inc index 3ed18b0e31..c62ebe4821 100644 --- a/kernel/branches/net/boot/bootge.inc +++ b/kernel/branches/net/boot/bootge.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;====================================================================== ; @@ -15,11 +15,6 @@ $Revision$ d80x25_bottom: -; db 186,' KolibriOS based on MenuetOS and comes with ABSOLUTELY ' -; db 'NO WARRANTY ',186 -; db 186,' See file COPYING for details ' -; db ' ',186 - db 186,' KolibriOS basiert auf MenuetOS und wird ohne jegliche ' db ' Garantie vertrieben ',186 db 186,' Details stehen in der Datei COPYING ' @@ -27,51 +22,30 @@ d80x25_bottom: line_full_bottom d80x25_bottom_num = 3 +msg_apm db " APM x.x ", 0 novesa db "Anzeige: EGA/CGA ",13,10,0 -vervesa db "Vesa-Version: Vesa ",13,10,0 -vervesa_off=22 -msg_apm db " APM x.x ", 0 -gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, " - db "[3] 1024x768, [4] 1280x1024",13,10 - db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, " - db "[7] 1024x768, [8] 1280x1024",13,10 - db 186," EGA/CGA 256 Farben: [9] 320x200, " - db "VGA 16 Farben: [0] 640x480",13,10 - db 186," Waehle Modus: ",0 -bt24 db "Bits Per Pixel: 24",13,10,0 -bt32 db "Bits Per Pixel: 32",13,10,0 -vrrmprint db "VRR verwenden? (Monitorfrequenz groesser als 60Hz" - db " only for transfers:",13,10 - db 186," 1024*768->800*600 und 800*600->640*480) [1-ja,2-nein]:",0 -;askmouse db " Maus angeschlossen an:" -; db " [1] PS/2 (USB), [2] Com1, [3] Com2." -; db " Waehle Port [1-3]: ",0 -;no_com1 db 13,10,186, " Keine COM1 Maus",0 -;no_com2 db 13,10,186, " Keine COM2 Maus",0 -;ask_dma db "Nutze DMA zum HDD Zugriff? [1-ja, 2-allein fur Lesen, 3-nein]: ",0 -ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0 -;gr_direct db 186," Benutze direct LFB? " -; db "[1-ja/2-nein] ? ",0 -;mem_model db 13,10,186," Hauptspeicher [1-16 Mb / 2-32 Mb / " -; db "3-64Mb / 4-128 Mb / 5-256 Mb] ? ",0 -;bootlog db 13,10,186," After bootlog display [1-continue/2-pause] ? ",0 +s_vesa db "Vesa-Version: " + .ver db "?.?",13,10,0 + +gr_mode db "Wahlen Sie einen videomode: ",13,10,0 + +ask_bd db "Add-Festplatten sichtbar BIOS in V86-Modus emuliert? [1-ja, 2 nein]: ",0 + +if defined extended_primary_loader +bdev db "Lade die Ramdisk von [1-Diskette; 2-kolibri.img]: ",0 +else bdev db "Lade die Ramdisk von [1-Diskette; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-benutze ein bereits geladenes Kernel image;" db 13,10,186," " db "4-create blank image]: ",0 -probetext db 13,10,13,10,186," Nutze Standardgrafikmodi? [1-ja, " - db "2-BIOS Test (Vesa 3.0)]: ",0 -;memokz256 db 13,10,186," RAM 256 Mb",0 -;memokz128 db 13,10,186," RAM 128 Mb",0 -;memokz64 db 13,10,186," RAM 64 Mb",0 -;memokz32 db 13,10,186," RAM 32 Mb",0 -;memokz16 db 13,10,186," RAM 16 Mb",0 +end if + prnotfnd db "Fatal - Videomodus nicht gefunden.",0 -;modena db "Fatal - VBE 0x112+ required.",0 + not386 db "Fatal - CPU 386+ benoetigt.",0 -btns db "Fatal - konnte Farbtiefe nicht erkennen.",0 fatalsel db "Fatal - Grafikmodus nicht unterstuetzt.",0 +pres_key db "Drucken Sie eine beliebige Taste, um eine neue videomode wahlen.",0 badsect db 13,10,186," Fatal - Sektorfehler, Andere Diskette neutzen.",0 memmovefailed db 13,10,186," Fatal - Int 0x15 Fehler.",0 okt db " ... OK" @@ -80,41 +54,48 @@ diskload db "Lade Diskette: 00 %",8,8,8,8,0 pros db "00" backspace2 db 8,8,0 boot_dev db 0 ; 0=floppy, 1=hd -start_msg db "Druecke [abcd], um die Einstellungen zu aendern , druecke [Enter] zum starten",13,10,0 +start_msg db "Druecke [abcd], um die Einstellungen zu aendern, druecke [Enter] zum starten",13,10,0 time_msg db " oder warte " time_str db " 5 Sekunden" db " bis zum automatischen Start",13,10,0 current_cfg_msg db "Aktuelle Einstellungen:",13,10,0 curvideo_msg db " [a] Videomodus: ",0 -mode1 db "640x480",0 -mode2 db "800x600",0 -mode3 db "1024x768",0 -mode4 db "1280x1024",0 -modes_msg dw mode4,mode1,mode2,mode3 -modevesa20 db " mit LFB",0 -modevesa12 db ", VESA 1.2 Bnk",0 -mode9 db "320x200, EGA/CGA 256 colors",0 -mode10 db "640x480, VGA 16 colors",0 -probeno_msg db " (Standard Modus)",0 -probeok_msg db " (teste nicht-standard Modi)",0 -;dma_msg db " [b] Nutze DMA zum HDD Aufschreiben:",0 -usebd_msg db " [b] Add disks visible by BIOS:",0 + +mode0 db "320x200, EGA/CGA 256 colors",13,10,0 +mode9 db "640x480, VGA 16 colors",13,10,0 + +usebd_msg db " [b] Add-Festplatten sichtbar durch das BIOS:",0 on_msg db " an",13,10,0 off_msg db " aus",13,10,0 -;readonly_msg db " fur Lesen",13,10,0 -vrrm_msg db " [c] Nutze VRR:",0 -preboot_device_msg db " [d] Diskettenimage: ",0 + +preboot_device_msg db " [c] Diskettenimage: ",0 + +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "Echte Diskette",13,10,0 +pdm2 db "kolibri.img",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3 pdm1 db "Echte Diskette",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "Nutze bereits geladenes Image",13,10,0 pdm4 db "create blank image",13,10,0 +end if + loading_msg db "Lade KolibriOS...",0 + +if ~ defined extended_primary_loader save_quest db "Aktuelle Einstellungen speichern? [y/n]: ",0 loader_block_error db "Bootloader Daten ungueltig, Kann nicht fortfahren. Angehalten.",0 +end if -remark1 db "Default values were selected to match most of configurations, but not all.",0 -remark2 db "If you have CRT-monitor, enable VRR in the item [c].",0 -remark3 db "If the system does not boot, try to disable the item [b].",0 -remarks dw remark1, remark2, remark3 -num_remarks = 3 +_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿',13,10,0 +_r1 db 186,' ³ 320x200 EGA/CGA 256 colors ³ ³',13,10,0 +_r2 db 186,' ³ 640x480 VGA 16 colors ³ ³',13,10,0 +_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³',13,10,0 +_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0 + +remark1 db "Die Standardwerte sind fur die meisten gewahlt, aber nicht fur jedermann.",0 +remark2 db "Wenn das System nicht bootet, versuchen, das Element [b] deaktivieren.",0 +remarks dw remark1, remark2 +num_remarks = 2 diff --git a/kernel/branches/net/boot/bootru.inc b/kernel/branches/net/boot/bootru.inc index 79c6964ec4..ffa5241ea0 100644 --- a/kernel/branches/net/boot/bootru.inc +++ b/kernel/branches/net/boot/bootru.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;================================================================= ; @@ -15,8 +15,8 @@ $Revision$ d80x25_bottom: - db 186,' Kolibri OS ®á­®¢ ­  ­  Menuet OS š ­¥ ¯à¥€®áâ ¢«ï¥â ' - db '­šª ªšå £ àa­âš©. ',186 + db 186,' KolibriOS ®á­®¢ ­  ­  MenuetOS š … …„Ž‘’€‚‹Ÿ…’ ˆ' + db 'Š€Šˆ• ƒ€A’ˆ‰. ',186 db 186,' ®€à®¡­¥¥ ᬮâàšâ¥ ¢ ä ©«¥ COPYING.TXT ' db ' ',186 line_full_bottom @@ -28,17 +28,21 @@ s_vesa db " .ver db "?.?",13,10,0 gr_mode db "‚ë¡¥àšâ¥ ¢š€¥®à¥Šš¬: ",13,10,0 -vrrmprint db "ˆá¯®«ì§®¢ âì VRR? (ç áâ®â  ª €à®¢ ¢ëè¥ 60 ƒæ" - db " ⮫쪮 €«ï ¯¥à¥å®€®¢:",13,10 - db 186," 1024*768>800*600 š 800*600>640*480) [1-€ , 2-­¥â]: ",0 -;ask_dma db "ˆá¯®«ì§®¢ âì DMA €«ï €®áâ㯠 ª HDD? [1-€ , 2-⮫쪮 ç⥭š¥, 3-­¥â]: ",0 + ask_bd db "„®¡ ¢šâì €šáªš, ¢š€š¬ë¥ ç¥à¥§ BIOS ¢ ॊš¬¥ V86? [1-€ , 2-­¥â]: ",0 + +if defined extended_primary_loader +bdev db "‡ £à㧚âì ®¡à § š§ [1-€šáª¥â ; 2-kolibri.img š§ ¯ ¯ªš § £à㧪š]: ",0 +else bdev db "‡ £à㧚âì ®¡à § š§ [1-€šáª¥â ; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "3-šá¯®«ì§®¢ âì ㊥ § £à㊥­­ë© ®¡à §;" db 13,10,186," " db "4-ᮧ€ âì çšáâë© ®¡à §]: ",0 +end if + prnotfnd db "Žèš¡ª  - ‚š€¥®à¥Šš¬ ­¥ ­ ©€¥­.",0 + not386 db "Žèš¡ª  - ’ॡã¥âáï ¯à®æ¥áá®à 386+.",0 fatalsel db "Žèš¡ª  - ‚ë¡à ­­ë© ¢š€¥®à¥Šš¬ ­¥ ¯®€€¥àŠš¢ ¥âáï.",0 pres_key db " Šš¬šâ¥ «î¡ãî ª« ¢šèã, €«ï ¯¥à¥å®€  ¢ ¢ë¡®à ॊš¬®¢.",0 @@ -57,25 +61,33 @@ time_str db " 5 ᥪ㭀 " current_cfg_msg db "’¥ªã隥 ­ áâனªš:",13,10,0 curvideo_msg db " [a] ‚š€¥®à¥Šš¬: ",0 - mode0 db "320x200, EGA/CGA 256 梥⮢",13,10,0 mode9 db "640x480, VGA 16 梥⮢",13,10,0 usebd_msg db " [b] „®¡ ¢šâì €šáªš, ¢š€š¬ë¥ ç¥à¥§ BIOS:",0 on_msg db " ¢ª«",13,10,0 off_msg db " ¢ëª«",13,10,0 -readonly_msg db " ⮫쪮 ç⥭š¥",13,10,0 -vrrm_msg db " [c] ˆá¯®«ì§®¢ ­š¥ VRR:",0 -preboot_device_msg db " [d] Ž¡à § €šáª¥âë: ",0 + +preboot_device_msg db " [c] Ž¡à § €šáª¥âë: ",0 + +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "­ áâ®ïé ï €šáª¥â ",13,10,0 +pdm2 db "kolibri.img š§ ¯ ¯ªš § £à㧪š",13,10,0 +else preboot_device_msgs dw 0,pdm1,pdm2,pdm3,pdm4 pdm1 db "­ áâ®ïé ï €šáª¥â ",13,10,0 pdm2 db "C:\kolibri.img (FAT32)",13,10,0 pdm3 db "šá¯®«ì§®¢ âì ㊥ § £à㊥­­ë© ®¡à §",13,10,0 pdm4 db "ᮧ€ âì çšáâë© ®¡à §",13,10,0 +end if + loading_msg db "ˆ€ñâ § £à㧪  KolibriOS...",0 + +if ~ defined extended_primary_loader ; saving not supported in this case save_quest db "‡ ¯®¬­šâì ⥪ã隥 ­ áâனªš? [y/n]: ",0 loader_block_error db "Žèš¡ª  ¢ € ­­ëå ­ ç «ì­®£® § £àã§çšª , ¯à®€®«Š¥­š¥ ­¥¢®§¬®Š­®.",0 - +end if _st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿ ',13,10,0 _r1 db 186,' ³ 320x200 EGA/CGA 256 梥⮢ ³ ³ ',13,10,0 @@ -83,9 +95,7 @@ _r2 db 186,' _rs db 186,' ³ ????x????@?? SVGA VESA ³ ³ ',13,10,0 _bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ ',13,10,0 - remark1 db "‡­ ç¥­šï ¯® 㬮«ç ­šî ¢ë¡à ­ë €«ï 〮¡á⢠ ¡®«ìèš­á⢠, ­® ­¥ ¢á¥å.",0 -remark2 db "…á«š 㠂 á ‹’-¬®­šâ®à, ¢ª«îçšâ¥ VRR ¢ ¯ã­ªâ¥ [c].",0 -remark3 db "…á«š 㠂 á ­¥ £à㧚âáï ášá⥬ , ¯®¯à®¡ã©â¥ ®âª«îçšâì ¯ã­ªâ [b].",0 -remarks dw remark1, remark2, remark3 -num_remarks = 3 +remark2 db "…á«š 㠂 á ­¥ £à㧚âáï ášá⥬ , ¯®¯à®¡ã©â¥ ®âª«îçšâì ¯ã­ªâ [b].",0 +remarks dw remark1, remark2 +num_remarks = 2 diff --git a/kernel/branches/net/boot/bootsp.inc b/kernel/branches/net/boot/bootsp.inc new file mode 100644 index 0000000000..4ec2c0327c --- /dev/null +++ b/kernel/branches/net/boot/bootsp.inc @@ -0,0 +1,103 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;====================================================================== +; +; BOOT DATA +; +;====================================================================== + +; Para modificar ‚ste archivo es necesario abrirlo con codificaci¢n CP850 + +$Revision: 2455 $ + + +d80x25_bottom: + db 186,' KolibriOS est  basado en MenuetOS y viene ABSOLUTAMENTE ' + db 'SIN GARANT¡A ',186 + db 186,' Lee el archivo COPYING por m s detalles ' + db ' ',186 + line_full_bottom +d80x25_bottom_num = 3 + +msg_apm db " APM x.x ", 0 +novesa db "Monitor: EGA/CGA",13,10,0 +s_vesa db "Versi¢n de VESA: " + .ver db "?.?",13,10,0 + +gr_mode db "Selecciona un modo de video: ",13,10,0 + +ask_bd db "šAgregar discos visibles por el BIOS emulados en modo V86? [1-si, 2-no]: ",0 + +if defined extended_primary_loader +bdev db "Cargar unidad ram desde [1-disquete; 2-kolibri.img]: ",0 +else +bdev db "Cargar unidad ram desde [1-disquete; 2-C:\kolibri.img (FAT32);" + db 13,10,186," " + db "3-usar imagen precargada en el reinicio del n£cleo;" + db 13,10,186," " + db "4-crear imagen vac¡a]: ",0 +end if + +prnotfnd db "Fatal - Modo de video no encontrado.",0 + +not386 db "Fatal - CPU 386+ requerido.",0 +fatalsel db "Fatal - Modo de gr ficos no soportado por hardware.",0 +pres_key db "Presiona una tecla para seleccionar otro modo de video.",0 +badsect db 13,10,186," Fatal - Sector mal. Reemplaze el disquete.",0 +memmovefailed db 13,10,186," Fatal - Int 0x15 move failed.",0 +okt db " ... BIEN" +linef db 13,10,0 +diskload db "Cargando disquete: 00 %",8,8,8,8,0 +pros db "00" +backspace2 db 8,8,0 +boot_dev db 0 ; 0=floppy, 1=hd +start_msg db "Presiona [abcd] para cambiar la configuraci¢n, [Enter] para continuar",13,10,0 +time_msg db " o espera " +time_str db " 5 segundos" + db " para que inicie autom ticamente",13,10,0 +current_cfg_msg db "Configuraci¢n actual:",13,10,0 +curvideo_msg db " [a] Modo de video: ",0 + +mode0 db "320x200, EGA/CGA 256 colores",13,10,0 +mode9 db "640x480, VGA 16 colores",13,10,0 + +usebd_msg db " [b] Agregar discos visibles por el BIOS:",0 +on_msg db " activado",13,10,0 +off_msg db " desactivado",13,10,0 + +preboot_device_msg db " [c] Imagen de disquete: ",0 + +if defined extended_primary_loader +preboot_device_msgs dw 0,pdm1,pdm2,0 +pdm1 db "disquete real",13,10,0 +pdm2 db "C:\kolibri.img (FAT32)",13,10,0 +else +preboot_device_msgs dw 0,pdm1,pdm2,pdm3 +pdm1 db "disquete real",13,10,0 +pdm2 db "C:\kolibri.img (FAT32)",13,10,0 +pdm3 db "usar imagen ya cargada",13,10,0 +pdm4 db "crear imagen vac¡a",13,10,0 +end if + +loading_msg db "Cargando KolibriOS...",0 + +if ~ defined extended_primary_loader +save_quest db "šRecordar configuraci¢n actual? [s/n]: ",0 +loader_block_error db "Bootloader inv lido, no puedo continuar. Detenido.",0 +end if + +_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿',13,10,0 +_r1 db 186,' ³ 320x200 EGA/CGA 256 colores ³ ³',13,10,0 +_r2 db 186,' ³ 640x480 VGA 16 colores ³ ³',13,10,0 +_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³',13,10,0 +_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0 + +remark1 db "Los valores por defecto puede que no funcionen en algunas configuraciones.",0 +remark2 db "Si el sistema no inicia, prueba deshabilitar la opci¢n [b].",0 +remarks dw remark1, remark2 +num_remarks = 2 diff --git a/kernel/branches/net/boot/bootstr.inc b/kernel/branches/net/boot/bootstr.inc index c32af80700..861de4f5a6 100644 --- a/kernel/branches/net/boot/bootstr.inc +++ b/kernel/branches/net/boot/bootstr.inc @@ -42,7 +42,8 @@ end while store byte ' ' at d80x25_top+cur_line_pos store dword ' SVN' at d80x25_top+cur_line_pos-4 -space_msg: line_space +space_msg: + line_space verstr: ; line_space ; version string diff --git a/kernel/branches/net/boot/bootvesa.inc b/kernel/branches/net/boot/bootvesa.inc index a7f762f2e8..69205895e4 100644 --- a/kernel/branches/net/boot/bootvesa.inc +++ b/kernel/branches/net/boot/bootvesa.inc @@ -89,26 +89,28 @@ scroll_area_size equ (long_v_table-2) int2str: dec bl jz @f - xor edx,edx + xor edx, edx div ecx push edx call int2str pop eax - @@: or al,0x30 - mov [ds:di],al + @@: + or al, 0x30 + mov [ds:di], al inc di ret int2strnz: - cmp eax,ecx + cmp eax, ecx jb @f - xor edx,edx + xor edx, edx div ecx push edx call int2strnz pop eax - @@: or al,0x30 - mov [es:di],al + @@: + or al, 0x30 + mov [es:di], al inc di ret @@ -119,9 +121,9 @@ v_mode_error: mov si, fatalsel call printplain _setcursor 20,2 - mov si,pres_key + mov si, pres_key call printplain - xor eax,eax + xor eax, eax int 16h jmp cfgmanager.d ;------------------------------------------------------- @@ -133,45 +135,45 @@ v_mode_error: print_vesa_info: _setcursor 5,2 - mov [es:vi.VESASignature],'VBE2' - mov ax,0x4F00 - mov di,vi ;0xa000 + mov [es:vi.VESASignature], 'VBE2' + mov ax, 0x4F00 + mov di, vi ;0xa000 int 0x10 - or ah,ah + or ah, ah jz @f - mov [es:vi.VESASignature],'VESA' - mov ax,$4F00 - mov di,vi + mov [es:vi.VESASignature], 'VESA' + mov ax, $4F00 + mov di, vi int 0x10 - or ah,ah + or ah, ah jnz .exit @@: - cmp [es:vi.VESASignature],'VESA' + cmp [es:vi.VESASignature], 'VESA' jne .exit - cmp [es:vi.VESAVersion],0x0100 + cmp [es:vi.VESAVersion], 0x0100 jb .exit jmp .vesaok2 .exit: - mov si,novesa + mov si, novesa call printplain ret .vesaok2: - mov ax,[es:vi.VESAVersion] - add ax,'00' + mov ax, [es:vi.VESAVersion] + add ax, '00' mov [s_vesa.ver], ah mov [s_vesa.ver+2], al - mov si,s_vesa + mov si, s_vesa call printplain _setcursor 4,2 - mov si,word[es:vi.OemStringPtr] - mov di,si + mov si, word[es:vi.OemStringPtr] + mov di, si push ds - mov ds,word[es:vi.OemStringPtr+2] + mov ds, word[es:vi.OemStringPtr+2] call printplain pop ds @@ -186,33 +188,33 @@ calc_vmodes_table: lfs si, [es:vi.VideoModePtr] - mov bx,modes_table + mov bx, modes_table ;save no vesa mode of work 320x200, EGA/CGA 256 梥⮢ and 640x480, VGA 16 梥⮢ - mov word [es:bx],640 - mov word [es:bx+2],480 - mov word [es:bx+6],0x13 + mov word [es:bx], 640 + mov word [es:bx+2], 480 + mov word [es:bx+6], 0x13 - mov word [es:bx+10],640 - mov word [es:bx+12],480 - mov word [es:bx+16],0x12 - add bx,20 + mov word [es:bx+10], 640 + mov word [es:bx+12], 480 + mov word [es:bx+16], 0x12 + add bx, 20 .next_mode: - mov cx,word [fs:si] ; mode number - cmp cx,-1 + mov cx, word [fs:si]; mode number + cmp cx, -1 je .modes_ok.2 - mov ax,0x4F01 - mov di,mi + mov ax, 0x4F01 + mov di, mi int 0x10 - or ah,ah + or ah, ah jnz .modes_ok.2;vesa_info.exit - test [es:mi.ModeAttributes],00000001b ;videomode support ? + test [es:mi.ModeAttributes], 00000001b ;videomode support ? jz @f - test [es:mi.ModeAttributes],00010000b ;picture ? + test [es:mi.ModeAttributes], 00010000b ;picture ? jz @f - test [es:mi.ModeAttributes],10000000b ;LFB ? + test [es:mi.ModeAttributes], 10000000b ;LFB ? jz @f cmp [es:mi.BitsPerPixel], 24 ;It show only videomodes to have support 24 and 32 bpp @@ -226,38 +228,39 @@ calc_vmodes_table: .l0: - cmp [es:mi.XRes],640 + cmp [es:mi.XRes], 640 jb @f - cmp [es:mi.YRes],480 + cmp [es:mi.YRes], 480 jb @f ; cmp [es:mi.BitsPerPixel],8 ; jb @f - mov ax,[es:mi.XRes] - mov [es:bx+0],ax ; +0[2] : resolution X - mov ax,[es:mi.YRes] - mov [es:bx+2],ax ; +2[2] : resolution Y - mov ax,[es:mi.ModeAttributes] - mov [es:bx+4],ax ; +4[2] : attributes + mov ax, [es:mi.XRes] + mov [es:bx+0], ax ; +0[2] : resolution X + mov ax, [es:mi.YRes] + mov [es:bx+2], ax ; +2[2] : resolution Y + mov ax, [es:mi.ModeAttributes] + mov [es:bx+4], ax ; +4[2] : attributes cmp [s_vesa.ver], '2' ; jb .lp1 jb @f ; We do not use Vesa 1.2 mode is now or cx, 0x4000 ; use LFB -.lp1: mov [es:bx+6],cx ; +6 : mode number - movzx ax,byte [es:mi.BitsPerPixel] - mov word [es:bx+8],ax ; +8 : bits per pixel - add bx,size_of_step ; size of record +.lp1: + mov [es:bx+6], cx ; +6 : mode number + movzx ax, byte [es:mi.BitsPerPixel] + mov word [es:bx+8], ax ; +8 : bits per pixel + add bx, size_of_step ; size of record @@: - add si,2 + add si, 2 jmp .next_mode .modes_ok.2: - mov word[es:bx],-1 ;end video table - mov word[end_cursor],bx ;save end cursor position + mov word[es:bx], -1 ;end video table + mov word[end_cursor], bx ;save end cursor position ;;;;;;;;;;;;;;;;;; ;Sort array ; mov si,modes_table @@ -307,28 +310,36 @@ draw_current_vmode: push 0 pop es - mov si,word [cursor_pos] + mov si, word [cursor_pos] - cmp word [es:si+6],0x12 + cmp word [es:si+6], 0x12 je .no_vesa_0x12 - cmp word [es:si+6],0x13 + cmp word [es:si+6], 0x13 je .no_vesa_0x13 - mov di,loader_block_error - movzx eax,word[es:si+0] - mov ecx,10 +if defined extended_primary_loader + mov di, config_file_variables +else + mov di, loader_block_error +end if + movzx eax, word[es:si+0] + mov ecx, 10 call int2strnz - mov byte[es:di],'x' + mov byte[es:di], 'x' inc di - movzx eax,word[es:si+2] + movzx eax, word[es:si+2] call int2strnz - mov byte[es:di],'x' + mov byte[es:di], 'x' inc di - movzx eax,word[es:si+8] + movzx eax, word[es:si+8] call int2strnz - mov dword[es:di],0x00000d0a - mov si,loader_block_error + mov dword[es:di], 0x00000d0a +if defined extended_primary_loader + mov si, config_file_variables +else + mov si, loader_block_error +end if push ds push es pop ds @@ -336,18 +347,44 @@ draw_current_vmode: pop ds ret .no_vesa_0x13: - mov si,mode0 + mov si, mode0 jmp .print .no_vesa_0x12: - mov si,mode9 + mov si, mode9 .print: call printplain - ret + ret ;----------------------------------------------------------------------------- check_first_parm: - mov si,word [preboot_graph] - test si,si - jnz .no_zero ;if no zero +if defined extended_primary_loader + mov cx, [number_vm] + jcxz .novbemode + mov si, modes_table +.findvbemode: + cmp [es:si+6], cx + jnz @f + cmp word [es:si+8], 32 + je .ok_found_mode + cmp word [es:si+8], 24 + je .ok_found_mode +@@: + add si, size_of_step + cmp word [es:si], -1 + jnz .findvbemode +.novbemode: + mov ax, [x_save] + test ax, ax + jz .zerro + mov bx, [y_save] + mov si, modes_table + call .loops + test ax, ax + jz .ok_found_mode +else + mov si, word [preboot_graph] + test si, si + jnz .no_zero ;if no zero +end if .zerro: ; mov ax,modes_table ; mov word [cursor_pos],ax @@ -355,69 +392,72 @@ check_first_parm: ; mov word [preboot_graph],ax ;SET default video of mode first probe will fined a move of work 1024x768@32 - mov ax,1024 - mov bx,768 - mov si,modes_table + mov ax, 1024 + mov bx, 768 + mov si, modes_table call .loops - test ax,ax - jz .ok_found_mode - mov ax,800 - mov bx,600 - mov si,modes_table + test ax, ax + jz .ok_found_mode + mov ax, 800 + mov bx, 600 + mov si, modes_table call .loops - test ax,ax - jz .ok_found_mode - mov ax,640 - mov bx,480 - mov si,modes_table + test ax, ax + jz .ok_found_mode + mov ax, 640 + mov bx, 480 + mov si, modes_table call .loops - test ax,ax - jz .ok_found_mode + test ax, ax + jz .ok_found_mode - mov si,modes_table + mov si, modes_table +if ~ defined extended_primary_loader jmp .ok_found_mode .no_zero: - mov bp,word [number_vm] - cmp bp,word [es:si+6] + mov bp, word [number_vm] + cmp bp, word [es:si+6] jz .ok_found_mode - mov ax,word [x_save] - mov bx,word [y_save] - mov si,modes_table + mov ax, word [x_save] + mov bx, word [y_save] + mov si, modes_table call .loops - test ax,ax - jz .ok_found_mode + test ax, ax + jz .ok_found_mode - mov si,modes_table + mov si, modes_table ; cmp ax,modes_table ; jb .zerro ;check on correct if bellow ; cmp ax,word [end_cursor] ; ja .zerro ;check on correct if anymore +end if .ok_found_mode: - mov word [home_cursor],si + mov word [home_cursor], si ; mov word [cursor_pos],si - mov word [preboot_graph],si - mov ax,si + mov word [preboot_graph], si + mov ax, si - mov ecx,long_v_table + mov ecx, long_v_table -.loop: add ax,size_of_step - cmp ax,word [end_cursor] +.loop: + add ax, size_of_step + cmp ax, word [end_cursor] jae .next_step loop .loop .next_step: - sub ax,size_of_step*long_v_table - cmp ax,modes_table + sub ax, size_of_step*long_v_table + cmp ax, modes_table jae @f - mov ax,modes_table + mov ax, modes_table @@: - mov word [home_cursor],ax - mov si,[preboot_graph] - mov word [cursor_pos],si + mov word [home_cursor], ax + mov si, [preboot_graph] + mov word [cursor_pos], si push word [es:si] pop word [x_save] @@ -429,21 +469,24 @@ check_first_parm: ret ;;;;;;;;;;;;;;;;;;;;;;;;;;; .loops: - cmp ax,word [es:si] + cmp ax, word [es:si] jne .next - cmp bx,word [es:si+2] + cmp bx, word [es:si+2] jne .next - cmp word [es:si+8],32 + cmp word [es:si+8], 32 je .ok - cmp word [es:si+8],24 + cmp word [es:si+8], 24 je .ok -.next: add si,size_of_step - cmp word [es:si],-1 +.next: + add si, size_of_step + cmp word [es:si], -1 je .exit jmp .loops -.ok: xor ax,ax +.ok: + xor ax, ax ret -.exit: or ax,-1 +.exit: + or ax, -1 ret @@ -454,40 +497,41 @@ check_first_parm: ;----------------------------------------------------------------------------- draw_vmodes_table: _setcursor 9, 2 - mov si,gr_mode + mov si, gr_mode call printplain - mov si,_st + mov si, _st call printplain push word [cursor_pos] pop ax push word [home_cursor] pop si - mov cx,si + mov cx, si - cmp ax,si + cmp ax, si je .ok jb .low - add cx,size_of_step*long_v_table + add cx, size_of_step*long_v_table - cmp ax,cx + cmp ax, cx jb .ok - sub cx,size_of_step*long_v_table - add cx,size_of_step - cmp cx,word[end_cursor] + sub cx, size_of_step*long_v_table + add cx, size_of_step + cmp cx, word[end_cursor] jae .ok - add si,size_of_step + add si, size_of_step push si pop word [home_cursor] jmp .ok -.low: sub cx,size_of_step - cmp cx,modes_table +.low: + sub cx, size_of_step + cmp cx, modes_table jb .ok push cx push cx @@ -540,52 +584,52 @@ draw_vmodes_table: add ax, cx mov [scroll_end], ax pop si - mov bp,long_v_table ;show rows + mov bp, long_v_table ;show rows .@@_next_bit: ;clear cursor - mov ax,' ' - mov word[ds:_r1+21],ax - mov word[ds:_r1+50],ax + mov ax, ' ' + mov word[ds:_r1+21], ax + mov word[ds:_r1+50], ax - mov word[ds:_r2+21],ax - mov word[ds:_r2+45],ax + mov word[ds:_r2+21], ax + mov word[ds:_r2+45], ax - mov word[ds:_rs+21],ax - mov word[ds:_rs+46],ax + mov word[ds:_rs+21], ax + mov word[ds:_rs+46], ax ; draw string - cmp word [es:si+6],0x12 + cmp word [es:si+6], 0x12 je .show_0x12 - cmp word [es:si+6],0x13 + cmp word [es:si+6], 0x13 je .show_0x13 - movzx eax,word[es:si] - cmp ax,-1 + movzx eax, word[es:si] + cmp ax, -1 je .@@_end - mov di,_rs+23 - mov ecx,10 - mov bl,4 + mov di, _rs+23 + mov ecx, 10 + mov bl, 4 call int2str - movzx eax,word[es:si+2] + movzx eax, word[es:si+2] inc di - mov bl,4 + mov bl, 4 call int2str - movzx eax,word[es:si+8] + movzx eax, word[es:si+8] inc di - mov bl,2 + mov bl, 2 call int2str cmp si, word [cursor_pos] jne .next ;draw cursor - mov word[ds:_rs+21],'>>' - mov word[ds:_rs+46],'<<' + mov word[ds:_rs+21], '>>' + mov word[ds:_rs+46], '<<' .next: push si - mov si,_rs + mov si, _rs .@@_sh: ; add to the string pseudographics for scrollbar pop bx @@ -615,13 +659,13 @@ draw_vmodes_table: @@: call printplain pop si - add si,size_of_step + add si, size_of_step dec bp jnz .@@_next_bit .@@_end: - mov si,_bt + mov si, _bt call printplain ret .show_0x13: @@ -629,20 +673,20 @@ draw_vmodes_table: cmp si, word [cursor_pos] jne @f - mov word[ds:_r1+21],'>>' - mov word[ds:_r1+50],'<<' + mov word[ds:_r1+21], '>>' + mov word[ds:_r1+50], '<<' @@: - mov si,_r1 + mov si, _r1 jmp .@@_sh .show_0x12: push si cmp si, word [cursor_pos] jne @f - mov word[ds:_r2+21],'>>' - mov word[ds:_r2+45],'<<' + mov word[ds:_r2+21], '>>' + mov word[ds:_r2+45], '<<' @@: - mov si,_r2 + mov si, _r2 jmp .@@_sh ;----------------------------------------------------------------------------- @@ -653,17 +697,17 @@ clear_vmodes_table: push es push 0xb800 pop es - mov di,1444 - xor ax,ax + mov di, 1444 + xor ax, ax mov ah, 1*16+15 - mov cx,70 - mov bp,12 + mov cx, 70 + mov bp, 12 .loop_start: - rep stosw - mov cx,70 - add di,20 + rep stosw + mov cx, 70 + add di, 20 dec bp - jns .loop_start + jns .loop_start pop es popa ret @@ -674,11 +718,11 @@ set_vmode: push 0 ;0;x1000 pop es - mov si,word [preboot_graph] ;[preboot_graph] - mov cx,word [es:si+6] ; number of mode + mov si, word [preboot_graph] ;[preboot_graph] + mov cx, word [es:si+6] ; number of mode - mov ax,word [es:si+0] ; resolution X + mov ax, word [es:si+0] ; resolution X mov bx, word [es:si+2] ; resolution Y @@ -688,7 +732,7 @@ set_vmode: cmp cx, 0x12 je .mode0x12_0x13 - cmp cx,0x13 + cmp cx, 0x13 je .mode0x12_0x13 @@ -697,9 +741,9 @@ set_vmode: ; VESA 2 and Vesa 3 - mov ax,0x4f01 - and cx,0xfff - mov di,mi;0xa000 + mov ax, 0x4f01 + and cx, 0xfff + mov di, mi;0xa000 int 0x10 ; LFB mov eax, [es:mi.PhysBasePtr];di+0x28] @@ -711,7 +755,7 @@ set_vmode: ; BPP cmp [es:mi.BitsPerPixel], 16 jne .l0 - cmp [es:mi.GreenMaskSize],5 + cmp [es:mi.GreenMaskSize], 5 jne .l0 mov [es:mi.BitsPerPixel], 15 .l0: diff --git a/kernel/branches/net/boot/et.inc b/kernel/branches/net/boot/et.inc index 95398010ae..adb2f7c692 100644 --- a/kernel/branches/net/boot/et.inc +++ b/kernel/branches/net/boot/et.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Revision$ diff --git a/kernel/branches/net/boot/parsers.inc b/kernel/branches/net/boot/parsers.inc new file mode 100644 index 0000000000..78c4284a81 --- /dev/null +++ b/kernel/branches/net/boot/parsers.inc @@ -0,0 +1,170 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +$Revision: 2288 $ + +; All parsers are called with ds:si -> value of the variable, +; possibly with spaces before, and dx = limit of config file. + +; Three subroutines parse_char, parse_number and parse_bool set CF +; if something has failed, otherwise return the value in al/ax. + +parse_timeout: +; timeout is a number not greater than 9 + call parse_number + jc .nothing + cmp ax, 9 + jbe @f + mov ax, 9 +@@: + imul ax, 18 + mov [es:preboot_timeout], ax +.nothing: + ret + +parse_resolution: +; resolution is *, 'x' can be used instead of '*' +; parse width + call parse_number + jc .nothing +; save width + xchg ax, bx +; test for 'x' or '*' + call parse_char + cmp al, 'x' + jz @f + cmp al, '*' + jnz .nothing +@@: +; parse height + call parse_number + jc .nothing +; write width and height + mov [es:x_save], bx + mov [es:y_save], ax +.nothing: + ret + +parse_vbemode: +; vbemode is a number + call parse_number + jc .nothing + mov [es:number_vm], ax +.nothing: + ret + +;parse_vrr: +;; vrr is a boolean setting +; call parse_bool +; jc .nothing +;; convert 0 to 2, 1 to 1 +; inc ax +; xor al, 3 +; mov [es:preboot_vrrm], al +;.nothing: +; ret + +parse_biosdisks: +; using biosdisks is a boolean setting + call parse_bool + jc .nothing +; convert 0 to 2, 1 to 1 + inc ax + xor al, 3 + mov [es:preboot_biosdisk], al +.nothing: + ret + +parse_imgfrom: +; boot device (1-floppy 2-kolibri.img using primary loader) + call parse_number + jc .nothing + cmp al, 1 + jb .nothing + cmp al, 2 + ja .nothing + mov [es:preboot_device], al +.nothing: + ret + +parse_char: +; skip spaces and return the next character or CF if EOF. + cmp si, dx + jae .eof + lodsb + cmp al, ' ' + jbe parse_char + ret +.eof: + stc + ret + +parse_number: +; initialize high part of ax to zero + xor ax, ax +; skip spaces + call parse_char + jc .bad +; al should be a digit + sub al, '0' + cmp al, 9 + ja .bad +; accumulate the value in cx + xchg cx, ax +@@: + cmp si, dx + jae .eof + lodsb + sub al, '0' + cmp al, 9 + ja .end + imul cx, 10 + add cx, ax + jmp @b +; if the end is caused by non-digit, unwind the last character +.end: + dec si +.eof: + xchg cx, ax + clc + ret +.bad: + stc + ret + +parse_bool: +; skip spaces + call parse_char + jc .bad +; Boolean false can be represented as 0=no=off, +; boolean true can be represented as 1=yes=on. + cmp al, '0' + jz .false + cmp al, '1' + jz .true + mov ah, al + cmp si, dx + jae .bad + lodsb + cmp ax, 'n'*256 + 'o' + jz .false + cmp ax, 'o'*256 + 'f' + jz .false + cmp ax, 'y'*256 + 'e' + jz .true + cmp ax, 'o'*256 + 'n' + jz .true +.bad: + stc + ret +.true: + xor ax, ax + inc ax + ret +.false: + xor ax, ax + ret diff --git a/kernel/branches/net/boot/preboot.inc b/kernel/branches/net/boot/preboot.inc index 1938b126be..59fec4e549 100644 --- a/kernel/branches/net/boot/preboot.inc +++ b/kernel/branches/net/boot/preboot.inc @@ -23,16 +23,20 @@ y_save dw 0 ; y number_vm dw 0 ; ;pixel_save dw 0 ; per to pixel preboot_gprobe db 0 ; probe vesa3 videomodes (1-no, 2-yes) -preboot_vrrm db 0 ; use VRR_M (1-yes, 2- no) +;preboot_vrrm db 0 ; use VRR_M (1-yes, 2- no) preboot_dma db 0 ; use DMA for access to HDD (1-always, 2-only for read, 3-never) preboot_device db 0 ; boot device ; (1-floppy 2-harddisk 3-kernel restart 4-format ram disk) ;!!!! 0 - autodetect !!!! preboot_blogesc = 0 ; start immediately after bootlog preboot_biosdisk db 0 ; use V86 to access disks through BIOS (1-yes, 2-no) +if defined extended_primary_loader +preboot_timeout dw 5*18 ; timeout in 1/18th of second for config settings screen +end if if $>0x200 -ERROR: prebooting parameters must fit in first sector!!! - end if -hdsysimage db 'KOLIBRI IMG' ; load from -image_save db 'KOLIBRI IMG' ; save to +ERROR: + prebooting parameters must fit in first sector!!! + end if +hdsysimage db 'KOLIBRI.IMG',0 ; load from +image_save db 'KOLIBRI.IMG',0 ; save to diff --git a/kernel/branches/net/boot/rdload.inc b/kernel/branches/net/boot/rdload.inc index 4393e7575d..1491b38cc0 100644 --- a/kernel/branches/net/boot/rdload.inc +++ b/kernel/branches/net/boot/rdload.inc @@ -10,125 +10,125 @@ $Revision $ ; READ RAMDISK IMAGE FROM HD - cmp [boot_dev+OS_BASE+0x10000],1 - jne no_sys_on_hd + cmp [boot_dev+OS_BASE+0x10000], 1 + jne no_sys_on_hd - test [DRIVE_DATA+1],byte 0x40 - jz position_2 - mov [hdbase],0x1f0 - mov [hdid],0x0 - mov [hdpos],1 - mov [fat32part],0 + test [DRIVE_DATA+1], byte 0x40 + jz position_2 + mov [hdbase], 0x1f0 + mov [hdid], 0x0 + mov [hdpos], 1 + mov [fat32part], 0 position_1_1: - inc [fat32part] - call search_and_read_image - cmp [image_retrieved],1 - je yes_sys_on_hd - movzx eax,byte [DRIVE_DATA+2] - cmp [fat32part],eax + inc [fat32part] + call search_and_read_image + cmp [image_retrieved], 1 + je yes_sys_on_hd + movzx eax, byte [DRIVE_DATA+2] + cmp [fat32part], eax jle position_1_1 position_2: - test [DRIVE_DATA+1],byte 0x10 - jz position_3 - mov [hdbase],0x1f0 - mov [hdid],0x10 - mov [hdpos],2 - mov [fat32part],0 + test [DRIVE_DATA+1], byte 0x10 + jz position_3 + mov [hdbase], 0x1f0 + mov [hdid], 0x10 + mov [hdpos], 2 + mov [fat32part], 0 position_2_1: - inc [fat32part] - call search_and_read_image - cmp [image_retrieved],1 - je yes_sys_on_hd - movzx eax,byte [DRIVE_DATA+3] - cmp eax,[fat32part] + inc [fat32part] + call search_and_read_image + cmp [image_retrieved], 1 + je yes_sys_on_hd + movzx eax, byte [DRIVE_DATA+3] + cmp eax, [fat32part] jle position_2_1 position_3: - test [DRIVE_DATA+1],byte 0x4 - jz position_4 - mov [hdbase],0x170 - mov [hdid],0x0 - mov [hdpos],3 - mov [fat32part],0 + test [DRIVE_DATA+1], byte 0x4 + jz position_4 + mov [hdbase], 0x170 + mov [hdid], 0x0 + mov [hdpos], 3 + mov [fat32part], 0 position_3_1: - inc [fat32part] - call search_and_read_image - cmp [image_retrieved],1 - je yes_sys_on_hd - movzx eax,byte [DRIVE_DATA+4] - cmp eax,[fat32part] + inc [fat32part] + call search_and_read_image + cmp [image_retrieved], 1 + je yes_sys_on_hd + movzx eax, byte [DRIVE_DATA+4] + cmp eax, [fat32part] jle position_3_1 position_4: - test [DRIVE_DATA+1],byte 0x1 - jz no_sys_on_hd - mov [hdbase],0x170 - mov [hdid],0x10 - mov [hdpos],4 - mov [fat32part],0 + test [DRIVE_DATA+1], byte 0x1 + jz no_sys_on_hd + mov [hdbase], 0x170 + mov [hdid], 0x10 + mov [hdpos], 4 + mov [fat32part], 0 position_4_1: - inc [fat32part] - call search_and_read_image - cmp [image_retrieved],1 - je yes_sys_on_hd - movzx eax,byte [DRIVE_DATA+5] - cmp eax,[fat32part] + inc [fat32part] + call search_and_read_image + cmp [image_retrieved], 1 + je yes_sys_on_hd + movzx eax, byte [DRIVE_DATA+5] + cmp eax, [fat32part] jle position_4_1 - jmp yes_sys_on_hd + jmp yes_sys_on_hd search_and_read_image: - call set_FAT32_variables - mov edx, bootpath - call read_image - test eax, eax - jz image_present - mov edx, bootpath2 - call read_image - test eax, eax - jz image_present + call set_FAT32_variables + mov edx, bootpath + call read_image + test eax, eax + jz image_present + mov edx, bootpath2 + call read_image + test eax, eax + jz image_present ret image_present: - mov [image_retrieved], 1 - ret - -iglobal -align 4 -read_image_fsinfo: - dd 0 ; function: read - dq 0 ; offset: zero - dd 1474560/512 ; size - dd RAMDISK ; buffer - db 0 - dd hdsysimage+OS_BASE+0x10000 -endg - -read_image: - mov ebx, read_image_fsinfo - pushad - call file_system_lfn - popad - ret - -image_retrieved db 0 + mov [image_retrieved], 1 + ret + +iglobal +align 4 +read_image_fsinfo: + dd 0 ; function: read + dq 0 ; offset: zero + dd 1474560/512 ; size + dd RAMDISK ; buffer + db 0 + dd hdsysimage+OS_BASE+0x10000 +endg + +read_image: + mov ebx, read_image_fsinfo + pushad + call file_system_lfn_protected + popad + ret + +image_retrieved db 0 counter_of_partitions db 0 no_sys_on_hd: ; test_to_format_ram_disk (need if not using ram disk) - cmp [boot_dev+OS_BASE+0x10000],3 - jne not_format_ram_disk + cmp [boot_dev+OS_BASE+0x10000], 3 + jne not_format_ram_disk ; format_ram_disk - mov edi, RAMDISK - mov ecx, 0x1080 - xor eax,eax + mov edi, RAMDISK + mov ecx, 0x1080 + xor eax, eax @@: - stosd - loop @b + stosd + loop @b - mov ecx, 0x58F7F - mov eax,0xF6F6F6F6 + mov ecx, 0x58F7F + mov eax, 0xF6F6F6F6 @@: - stosd - loop @b + stosd + loop @b - mov [RAMDISK+0x200],dword 0xFFFFF0 ; fat table - mov [RAMDISK+0x4200],dword 0xFFFFF0 + mov [RAMDISK+0x200], dword 0xFFFFF0 ; fat table + mov [RAMDISK+0x4200], dword 0xFFFFF0 not_format_ram_disk: yes_sys_on_hd: diff --git a/kernel/branches/net/boot/ru.inc b/kernel/branches/net/boot/ru.inc index 3da137fb47..29acfa1440 100644 --- a/kernel/branches/net/boot/ru.inc +++ b/kernel/branches/net/boot/ru.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Revision$ diff --git a/kernel/branches/net/boot/shutdown.inc b/kernel/branches/net/boot/shutdown.inc index aa0a8f693e..50fa5431a9 100644 --- a/kernel/branches/net/boot/shutdown.inc +++ b/kernel/branches/net/boot/shutdown.inc @@ -18,92 +18,94 @@ align 4 pr_mode_exit: ; setup stack - mov ax, 0x3000 - mov ss, ax - mov esp, 0x0EC00 + mov ax, 0x3000 + mov ss, ax + mov esp, 0x0EC00 ; setup ds push cs - pop ds + pop ds - lidt [old_ints_h] + lidt [old_ints_h] ;remap IRQs - mov al,0x11 - out 0x20,al - call rdelay - out 0xA0,al - call rdelay + mov al, 0x11 + out 0x20, al + call rdelay + out 0xA0, al + call rdelay - mov al,0x08 - out 0x21,al - call rdelay - mov al,0x70 - out 0xA1,al - call rdelay + mov al, 0x08 + out 0x21, al + call rdelay + mov al, 0x70 + out 0xA1, al + call rdelay - mov al,0x04 - out 0x21,al - call rdelay - mov al,0x02 - out 0xA1,al - call rdelay + mov al, 0x04 + out 0x21, al + call rdelay + mov al, 0x02 + out 0xA1, al + call rdelay - mov al,0x01 - out 0x21,al - call rdelay - out 0xA1,al - call rdelay + mov al, 0x01 + out 0x21, al + call rdelay + out 0xA1, al + call rdelay - mov al,0xB8 - out 0x21,al - call rdelay - mov al,0xBD - out 0xA1,al + mov al, 0xB8 + out 0x21, al + call rdelay + mov al, 0xBD + out 0xA1, al sti temp_3456: - xor ax,ax - mov es,ax - mov al,byte [es:0x9030] - cmp al,1 - jl nbw - cmp al,4 - jle nbw32 + xor ax, ax + mov es, ax + mov al, byte [es:0x9030] + cmp al, 1 + jl nbw + cmp al, 4 + jle nbw32 nbw: - in al,0x60 - cmp al,6 - jae nbw - mov bl,al + in al, 0x60 + cmp al, 6 + jae nbw + mov bl, al nbw2: - in al,0x60 - cmp al,bl - je nbw2 - cmp al,240 ;ax,240 - jne nbw31 - mov al,bl - dec ax - jmp nbw32 + in al, 0x60 + cmp al, bl + je nbw2 + cmp al, 240;ax,240 + jne nbw31 + mov al, bl + dec ax + jmp nbw32 nbw31: - add bl,128 - cmp al,bl - jne nbw - sub al,129 + add bl, 128 + cmp al, bl + jne nbw + sub al, 129 nbw32: - dec ax - dec ax ; 2 = power off - jnz no_apm_off - call APM_PowerOff - jmp $ + dec ax + dec ax ; 2 = power off + jnz no_apm_off + call APM_PowerOff + jmp $ no_apm_off: - dec ax ; 3 = reboot - jnz restart_kernel ; 4 = restart kernel - push 0x40 - pop ds - mov word[0x0072],0x1234 - jmp 0xF000:0xFFF0 +if ~ defined extended_primary_loader ; kernel restarting is not supported + dec ax ; 3 = reboot + jnz restart_kernel ; 4 = restart kernel +end if + push 0x40 + pop ds + mov word[0x0072], 0x1234 + jmp 0xF000:0xFFF0 rdelay: @@ -114,45 +116,46 @@ APM_PowerOff: xor bx, bx int 15h ;!!!!!!!!!!!!!!!!!!!!!!!! - mov ax,0x5300 - xor bx,bx - int 0x15 - push ax + mov ax, 0x5300 + xor bx, bx + int 0x15 + push ax - mov ax,0x5301 - xor bx,bx - int 0x15 + mov ax, 0x5301 + xor bx, bx + int 0x15 - mov ax,0x5308 - mov bx,1 - mov cx,bx - int 0x15 + mov ax, 0x5308 + mov bx, 1 + mov cx, bx + int 0x15 - mov ax,0x530E - xor bx,bx - pop cx - int 0x15 + mov ax, 0x530E + xor bx, bx + pop cx + int 0x15 - mov ax,0x530D - mov bx,1 - mov cx,bx - int 0x15 + mov ax, 0x530D + mov bx, 1 + mov cx, bx + int 0x15 - mov ax,0x530F - mov bx,1 - mov cx,bx - int 0x15 + mov ax, 0x530F + mov bx, 1 + mov cx, bx + int 0x15 - mov ax,0x5307 - mov bx,1 - mov cx,3 - int 0x15 + mov ax, 0x5307 + mov bx, 1 + mov cx, 3 + int 0x15 ;!!!!!!!!!!!!!!!!!!!!!!!! ret +if ~ defined extended_primary_loader restart_kernel: - mov ax,0x0003 ; set text mode for screen + mov ax, 0x0003 ; set text mode for screen int 0x10 jmp 0x4000:0000 @@ -167,28 +170,28 @@ restart_kernel_4000: pop ds xor si, si xor di, di - rep movsw + rep movsw pop cx mov ds, cx push 0x2000 pop es - rep movsw + rep movsw push 0x9000 pop ds push 0x3000 pop es mov cx, 0xE000/2 - rep movsw + rep movsw wbinvd ; write and invalidate cache - mov al, 00110100b - out 43h, al + mov al, 00110100b + out 43h, al jcxz $+2 - mov al, 0xFF - out 40h, al + mov al, 0xFF + out 40h, al jcxz $+2 - out 40h, al + out 40h, al jcxz $+2 sti @@ -201,9 +204,9 @@ restart_kernel_4000: ; bootloader interface push 0x1000 - pop ds - mov si, kernel_restart_bootblock - mov ax, 'KL' + pop ds + mov si, kernel_restart_bootblock + mov ax, 'KL' jmp 0x1000:0000 - +end if diff --git a/kernel/branches/net/bus/pci/PCIe.inc b/kernel/branches/net/bus/pci/PCIe.inc index c7b6d62d4e..213b6b6814 100644 --- a/kernel/branches/net/bus/pci/PCIe.inc +++ b/kernel/branches/net/bus/pci/PCIe.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2010-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2010-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; ;; ;; PCIe.INC ;; ;; ;; ;; Extended PCI express services ;; diff --git a/kernel/branches/net/core/apic.inc b/kernel/branches/net/core/apic.inc index 08ac43a837..0f5d49b4c5 100644 --- a/kernel/branches/net/core/apic.inc +++ b/kernel/branches/net/core/apic.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; iglobal @@ -58,13 +58,13 @@ APIC_init: mov [acpi_dev_data], eax mov [acpi_dev_size], ebx - call IRQ_mask_all - -; IOAPIC init - stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW+PG_NOCACHE - mov [IOAPIC_base], eax - - mov eax, IOAPIC_VER + call IRQ_mask_all + +; IOAPIC init + stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW+PG_NOCACHE + mov [IOAPIC_base], eax + + mov eax, IOAPIC_VER call IOAPIC_read shr eax, 16 inc al @@ -118,17 +118,17 @@ APIC_init: ret -;=========================================================== -align 4 -LAPIC_init: - - cmp [LAPIC_BASE], 0 - jne .done - - stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE - mov [LAPIC_BASE], eax - mov esi, eax - +;=========================================================== +align 4 +LAPIC_init: + + cmp [LAPIC_BASE], 0 + jne .done + + stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW+PG_NOCACHE + mov [LAPIC_BASE], eax + mov esi, eax + ; Program Destination Format Register for Flat mode. mov eax, [esi + APIC_DFR] or eax, 0xf0000000 @@ -194,14 +194,14 @@ LAPIC_init: xor eax, 0xffffffff ; eax = 0xffffffff - eax shr eax, 6 ; eax /= 64; APIC ticks per 0.01 sec - ; Start (every 0.01 sec) - mov dword[esi + APIC_LVT_timer], 0x30020; periodic int 0x20 - mov dword[esi + APIC_timer_init], eax - -.done: - ret - -;=========================================================== + ; Start (every 0.01 sec) + mov dword[esi + APIC_LVT_timer], 0x30020; periodic int 0x20 + mov dword[esi + APIC_timer_init], eax + +.done: + ret + +;=========================================================== ; IOAPIC implementation align 4 IOAPIC_read: @@ -371,6 +371,33 @@ proc enable_irq stdcall, irq_line:dword ret endp +proc disable_irq stdcall, irq_line:dword + mov ebx, [irq_line] + cmp [irq_mode], IRQ_APIC + je .APIC + + mov edx, 0x21 + cmp ebx, 8 + jb @F + + mov edx, 0xA1 + sub ebx, 8 +@@: + in al, dx + bts eax, ebx + out dx, al + ret +.APIC: + shl ebx, 1 + add ebx, 0x10 + mov eax, ebx + call IOAPIC_read + or eax, 0x10000; bit 16 + xchg eax, ebx + call IOAPIC_write + ret +endp + align 4 pci_irq_fixup: diff --git a/kernel/branches/net/core/conf_lib-sp.inc b/kernel/branches/net/core/conf_lib-sp.inc new file mode 100644 index 0000000000..65acc92fdd --- /dev/null +++ b/kernel/branches/net/core/conf_lib-sp.inc @@ -0,0 +1,11 @@ +; ste archivo debe ser editado con codificaci¢n CP866 + +ugui_mouse_speed db 'velocidad del rat¢n',0 +ugui_mouse_delay db 'demora del rat¢n',0 + +udev db 'disp',0 +unet db 'red',0 +unet_active db 'activa',0 +unet_addr db 'direc',0 +unet_mask db 'm sc',0 +unet_gate db 'puer',0 diff --git a/kernel/branches/net/core/conf_lib.inc b/kernel/branches/net/core/conf_lib.inc index 4d9acb0972..ec07e24f84 100644 --- a/kernel/branches/net/core/conf_lib.inc +++ b/kernel/branches/net/core/conf_lib.inc @@ -67,16 +67,27 @@ proc set_kernel_conf endp iglobal ugui db 'gui',0 -ugui_mouse_speed db 'mouse_speed',0 ugui_mouse_speed_def db '2',0 -ugui_mouse_delay db 'mouse_delay',0 ugui_mouse_delay_def db '0x00A',0 - -udev db 'dev',0 udev_midibase db 'midibase',0 udev_midibase_def db '0x320',0 endg +iglobal +if lang eq sp + include 'core/conf_lib-sp.inc' +else + ugui_mouse_speed db 'mouse_speed',0 + ugui_mouse_delay db 'mouse_delay',0 + udev db 'dev',0 + unet db 'net',0 + unet_active db 'active',0 + unet_addr db 'addr',0 + unet_mask db 'mask',0 + unet_gate db 'gate',0 +end if +unet_def db 0 +endg ; convert string to DWord proc strtoint stdcall,strs pushad diff --git a/kernel/branches/net/core/dll.inc b/kernel/branches/net/core/dll.inc index 024c1eed7b..67158c1a99 100644 --- a/kernel/branches/net/core/dll.inc +++ b/kernel/branches/net/core/dll.inc @@ -369,7 +369,7 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\ pushad lea ebx, [cmd] - call file_system_lfn + call file_system_lfn_protected popad ret endp @@ -807,13 +807,13 @@ proc load_driver stdcall, driver_name:dword mov ebx, [start] stdcall ebx, DRV_ENTRY test eax, eax - jnz .ok - - stdcall kernel_free, [img_base] - - xor eax, eax - ret -.ok: + jnz .ok + + stdcall kernel_free, [img_base] + + xor eax, eax + ret +.ok: mov ebx, [img_base] mov [eax+SRV.base], ebx mov ecx, [start] diff --git a/kernel/branches/net/core/heap.inc b/kernel/branches/net/core/heap.inc index 3f89c4560a..06b636975f 100644 --- a/kernel/branches/net/core/heap.inc +++ b/kernel/branches/net/core/heap.inc @@ -54,7 +54,7 @@ md: inc [mem_hash_cnt+eax*4] lea ecx, [mem_used_list+eax*8] - list_add esi, ecx + list_add esi, ecx mov [esi+block_flags], USED_BLOCK mov eax, [esi+block_size] sub [heap_free], eax @@ -95,7 +95,7 @@ align 4 jne .fatal dec [mem_hash_cnt+ecx*4] - list_del esi + list_del esi .done: ret .fatal: ;FIXME panic here @@ -176,7 +176,7 @@ proc init_kernel_heap mov [mem_block_mask+4], 0x80000000 mov ecx, mem_block_list+63*8 - list_add ebx, ecx + list_add ebx, ecx mov ecx, 4096-3-1 mov eax, HEAP_BASE+sizeof.MEM_BLOCK*4 @@ -393,7 +393,7 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword cmp [edi+block_flags], FREE_BLOCK jne .prev - list_del edi + list_del edi mov edx, [edi+block_next] mov [esi+block_next], edx @@ -401,7 +401,7 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword mov ecx, [edi+block_size] add [esi+block_size], ecx - calc_index ecx + calc_index ecx lea edx, [mem_block_list+ecx*8] cmp edx, [edx] @@ -427,23 +427,24 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword add eax, ecx mov [edi+block_size], eax - calc_index eax ;new index - calc_index ecx ;old index + calc_index eax ;new index + calc_index ecx ;old index cmp eax, ecx je .m_eq push ecx - list_del edi + list_del edi pop ecx lea edx, [mem_block_list+ecx*8] cmp edx, [edx] jne .add_block btr [mem_block_mask], ecx + .add_block: bts [mem_block_mask], eax lea edx, [mem_block_list+eax*8] - list_add edi, edx + list_add edi, edx .m_eq: mov ecx, heap_mutex call mutex_unlock @@ -453,7 +454,7 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword .insert: mov [esi+block_flags], FREE_BLOCK mov eax, [esi+block_size] - calc_index eax + calc_index eax mov edi, esi jmp .add_block @@ -466,10 +467,10 @@ endp align 4 proc kernel_alloc stdcall, size:dword - locals - lin_addr dd ? - pages_count dd ? - endl + locals + lin_addr dd ? + pages_count dd ? + endl push ebx push edi @@ -758,11 +759,13 @@ proc user_alloc_at stdcall, address:dword, alloc_size:dword inc ebx dec eax jnz .fill + .second_nofill: sub ecx, edx jz .nothird or cl, FREE_BLOCK mov [page_tabs+ebx*4], ecx + .nothird: mov edx, [current_slot] @@ -822,6 +825,7 @@ proc user_free stdcall, base:dword inc esi dec ecx jnz .release + .released: push edi @@ -1288,11 +1292,11 @@ SHM_OPEN_MASK equ (3 shl 2) align 4 proc shmem_open stdcall name:dword, size:dword, access:dword - locals - action dd ? - owner_access dd ? - mapped dd ? - endl + locals + action dd ? + owner_access dd ? + mapped dd ? + endl push ebx push esi diff --git a/kernel/branches/net/core/irq.inc b/kernel/branches/net/core/irq.inc index f1e8e279eb..f0f7f407f0 100644 --- a/kernel/branches/net/core/irq.inc +++ b/kernel/branches/net/core/irq.inc @@ -1,23 +1,23 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IRQ_RESERVED equ 24 IRQ_POOL_SIZE equ 48 -uglobal - -align 16 -irqh_tab rd sizeof.LHEAD * IRQ_RESERVED / 4 - -irqh_pool rd sizeof.IRQH * IRQ_POOL_SIZE /4 -next_irqh rd 1 - -irq_active_set rd 1 +uglobal + +align 16 +irqh_tab rd sizeof.LHEAD * IRQ_RESERVED / 4 + +irqh_pool rd sizeof.IRQH * IRQ_POOL_SIZE /4 +next_irqh rd 1 + +irq_active_set rd 1 irq_failed rd IRQ_RESERVED endg @@ -31,20 +31,20 @@ init_irqs: mov eax, edi stosd stosd - loop @B - - mov ecx, IRQ_POOL_SIZE-1 - mov eax, irqh_pool+sizeof.IRQH - mov [next_irqh], irqh_pool -@@: - mov [eax-sizeof.IRQH], eax - add eax, sizeof.IRQH - loop @B - - mov [eax-sizeof.IRQH], dword 0 - ret - - + loop @B + + mov ecx, IRQ_POOL_SIZE-1 + mov eax, irqh_pool+sizeof.IRQH + mov [next_irqh], irqh_pool +@@: + mov [eax-sizeof.IRQH], eax + add eax, sizeof.IRQH + loop @B + + mov [eax-sizeof.IRQH], dword 0 + ret + + align 4 proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword locals diff --git a/kernel/branches/net/core/malloc.inc b/kernel/branches/net/core/malloc.inc index 9c72e5051b..3d3354a090 100644 --- a/kernel/branches/net/core/malloc.inc +++ b/kernel/branches/net/core/malloc.inc @@ -338,15 +338,15 @@ free: mov [esi+edi], esi -; insert_chunk(p,psize); - - mov eax, esi - mov ecx, edi - call insert_chunk - jmp .fail2 -.unl_large: - -; unlink_large_chunk((tchunkptr)next); +; insert_chunk(p,psize); + + mov eax, esi + mov ecx, edi + call insert_chunk + jmp .fail2 +.unl_large: + +; unlink_large_chunk((tchunkptr)next); mov edx, ebx call unlink_large_chunk @@ -360,15 +360,15 @@ free: mov [esi+edi], esi -; insert_chunk(p,psize); - - mov eax, esi - mov ecx, edi - call insert_chunk - jmp .fail2 -.fix_next: - -; (p+psize)->prev_foot = psize; +; insert_chunk(p,psize); + + mov eax, esi + mov ecx, edi + call insert_chunk + jmp .fail2 +.fix_next: + +; (p+psize)->prev_foot = psize; ; next->head &= ~PINUSE_BIT; ; p->head = psize|PINUSE_BIT; @@ -381,15 +381,15 @@ free: ; (p+psize)->prev_foot = psize; mov [esi+edi], esi -; insert_chunk(p,psize); - - mov eax, esi - mov ecx, edi - call insert_chunk - jmp .fail2 - -; param -; ecx = chunk +; insert_chunk(p,psize); + + mov eax, esi + mov ecx, edi + call insert_chunk + jmp .fail2 + +; param +; ecx = chunk ; eax = size insert_chunk: @@ -412,17 +412,17 @@ insert_chunk: mov edx, [eax+8] ;F = B->fd mov [eax+8], esi ;B->fd = P mov [edx+12], esi ;F->bk = P - mov [esi+8], edx ;P->fd = F - mov [esi+12], eax ;P->bk = B - pop esi - ret -.large: - mov ebx, eax - call insert_large_chunk - pop esi - ret - - + mov [esi+8], edx ;P->fd = F + mov [esi+12], eax ;P->bk = B + pop esi + ret +.large: + mov ebx, eax + call insert_large_chunk + pop esi + ret + + ; param ; esi= chunk ; ebx= size diff --git a/kernel/branches/net/core/memory.inc b/kernel/branches/net/core/memory.inc index 0fd08df800..084a927807 100644 --- a/kernel/branches/net/core/memory.inc +++ b/kernel/branches/net/core/memory.inc @@ -439,89 +439,89 @@ proc init_LFB ret endp -align 4 -proc new_mem_resize stdcall, new_size:dword - - push ebx - push esi - push edi - - mov edx, [current_slot] - cmp [edx+APPDATA.heap_base], 0 - jne .exit - - mov edi, [new_size] - add edi, 4095 - and edi, not 4095 - mov [new_size], edi - - mov esi, [edx+APPDATA.mem_size] - add esi, 4095 - and esi, not 4095 - - cmp edi, esi - ja .expand - je .exit - - mov ebx, edi - shr edi, 12 - shr esi, 12 - - mov ecx, pg_data.mutex - call mutex_lock -@@: - mov eax, [app_page_tabs+edi*4] - test eax, 1 - jz .next - - mov dword [app_page_tabs+edi*4], 0 - invlpg [ebx] - call free_page - -.next: - inc edi - add ebx, 0x1000 - cmp edi, esi - jb @B - - mov ecx, pg_data.mutex - call mutex_unlock - -.update_size: - mov edx, [current_slot] - mov ebx, [new_size] - call update_mem_size -.exit: - pop edi - pop esi - pop ebx - xor eax, eax - ret - -.expand: - - mov ecx, pg_data.mutex - call mutex_lock - - xchg esi, edi - - push esi ;new size - push edi ;old size - - add edi, 0x3FFFFF - and edi, not(0x3FFFFF) - add esi, 0x3FFFFF - and esi, not(0x3FFFFF) - - cmp edi, esi - jae .grow - @@: - call alloc_page - test eax, eax - jz .exit_fail - - stdcall map_page_table, edi, eax - +align 4 +proc new_mem_resize stdcall, new_size:dword + + push ebx + push esi + push edi + + mov edx, [current_slot] + cmp [edx+APPDATA.heap_base], 0 + jne .exit + + mov edi, [new_size] + add edi, 4095 + and edi, not 4095 + mov [new_size], edi + + mov esi, [edx+APPDATA.mem_size] + add esi, 4095 + and esi, not 4095 + + cmp edi, esi + ja .expand + je .exit + + mov ebx, edi + shr edi, 12 + shr esi, 12 + + mov ecx, pg_data.mutex + call mutex_lock +@@: + mov eax, [app_page_tabs+edi*4] + test eax, 1 + jz .next + + mov dword [app_page_tabs+edi*4], 0 + invlpg [ebx] + call free_page + +.next: + inc edi + add ebx, 0x1000 + cmp edi, esi + jb @B + + mov ecx, pg_data.mutex + call mutex_unlock + +.update_size: + mov edx, [current_slot] + mov ebx, [new_size] + call update_mem_size +.exit: + pop edi + pop esi + pop ebx + xor eax, eax + ret + +.expand: + + mov ecx, pg_data.mutex + call mutex_lock + + xchg esi, edi + + push esi ;new size + push edi ;old size + + add edi, 0x3FFFFF + and edi, not(0x3FFFFF) + add esi, 0x3FFFFF + and esi, not(0x3FFFFF) + + cmp edi, esi + jae .grow + @@: + call alloc_page + test eax, eax + jz .exit_fail + + stdcall map_page_table, edi, eax + push edi shr edi, 10 add edi, page_tabs @@ -532,44 +532,44 @@ proc new_mem_resize stdcall, new_size:dword pop edi add edi, 0x00400000 - cmp edi, esi - jb @B -.grow: - pop edi ;old size - pop ecx ;new size - - shr edi, 10 - shr ecx, 10 - sub ecx, edi - shr ecx, 2 ;pages count - mov eax, 2 - - add edi, app_page_tabs - rep stosd - - mov ecx, pg_data.mutex - call mutex_unlock - - jmp .update_size - -.exit_fail: - mov ecx, pg_data.mutex - call mutex_unlock - - add esp, 8 - pop edi - pop esi - pop ebx - xor eax, eax - inc eax - ret -endp - - -align 4 -update_mem_size: -; in: edx = slot base -; ebx = new memory size + cmp edi, esi + jb @B +.grow: + pop edi ;old size + pop ecx ;new size + + shr edi, 10 + shr ecx, 10 + sub ecx, edi + shr ecx, 2 ;pages count + mov eax, 2 + + add edi, app_page_tabs + rep stosd + + mov ecx, pg_data.mutex + call mutex_unlock + + jmp .update_size + +.exit_fail: + mov ecx, pg_data.mutex + call mutex_unlock + + add esp, 8 + pop edi + pop esi + pop ebx + xor eax, eax + inc eax + ret +endp + + +align 4 +update_mem_size: +; in: edx = slot base +; ebx = new memory size ; destroys eax,ecx,edx mov [APPDATA.mem_size+edx], ebx @@ -603,18 +603,18 @@ update_mem_size: ; ; retval ; eax= phisical page address - -align 4 -get_pg_addr: - sub eax, OS_BASE - cmp eax, 0x400000 - jb @f - shr eax, 12 - mov eax, [page_tabs+(eax+(OS_BASE shr 12))*4] -@@: - and eax, 0xFFFFF000 - ret - + +align 4 +get_pg_addr: + sub eax, OS_BASE + cmp eax, 0x400000 + jb @f + shr eax, 12 + mov eax, [page_tabs+(eax+(OS_BASE shr 12))*4] +@@: + and eax, 0xFFFFF000 + ret + align 4 ; Now it is called from core/sys32::exc_c (see stack frame there) @@ -1252,13 +1252,13 @@ f68: mov [esp+32], eax ret .21: - cmp ecx, OS_BASE - jae .fail - - cmp edx, OS_BASE - jae .fail - - mov edi, edx + cmp ecx, OS_BASE + jae .fail + + cmp edx, OS_BASE + jae .fail + + mov edi, edx stdcall load_PE, ecx mov esi, eax test eax, eax diff --git a/kernel/branches/net/core/peload.inc b/kernel/branches/net/core/peload.inc index eb686c3cec..7fbc66d9e5 100644 --- a/kernel/branches/net/core/peload.inc +++ b/kernel/branches/net/core/peload.inc @@ -297,13 +297,13 @@ __exports: free_page, 'FreePage', \ ; eax kernel_alloc, 'KernelAlloc', \ ; stdcall kernel_free, 'KernelFree', \ ; stdcall - malloc, 'Kmalloc', \ - free, 'Kfree', \ - map_io_mem, 'MapIoMem', \ ; stdcall - map_page, 'MapPage', \ ; stdcall - get_pg_addr, 'GetPgAddr', \ ; eax -\ - mutex_init, 'MutexInit', \ ; gcc fastcall + malloc, 'Kmalloc', \ + free, 'Kfree', \ + map_io_mem, 'MapIoMem', \ ; stdcall + map_page, 'MapPage', \ ; stdcall + get_pg_addr, 'GetPgAddr', \ ; eax +\ + mutex_init, 'MutexInit', \ ; gcc fastcall mutex_lock, 'MutexLock', \ ; gcc fastcall mutex_unlock, 'MutexUnlock', \ ; gcc fastcall \ diff --git a/kernel/branches/net/core/sys32-sp.inc b/kernel/branches/net/core/sys32-sp.inc new file mode 100644 index 0000000000..20e759d987 --- /dev/null +++ b/kernel/branches/net/core/sys32-sp.inc @@ -0,0 +1,4 @@ +; ste archivo debe ser editado con codificaci¢n CP866 + + msg_sel_ker db "n£cleo", 0 + msg_sel_app db "aplicaci¢n", 0 diff --git a/kernel/branches/net/core/sys32.inc b/kernel/branches/net/core/sys32.inc index 7b45691e25..b496c887cd 100644 --- a/kernel/branches/net/core/sys32.inc +++ b/kernel/branches/net/core/sys32.inc @@ -75,8 +75,12 @@ iglobal msg_exc_d db "General protection fault", 0 msg_exc_e db "Page fault", 0 - msg_sel_ker db "kernel", 0 - msg_sel_app db "application", 0 + if lang eq sp + include 'core/sys32-sp.inc' + else + msg_sel_ker db "kernel", 0 + msg_sel_app db "application", 0 + end if endg @@ -219,7 +223,11 @@ show_error_parameters: pop ebx .no_ud: mov edx, [TASK_BASE];not scratched below - DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] + if lang eq sp + DEBUGF 1, "K : Proceso - terminado forzado PID: %x [%s]\n", [edx+TASKDATA.pid], [current_slot] + else + DEBUGF 1, "K : Process - forced terminate PID: %x [%s]\n", [edx+TASKDATA.pid], [current_slot] + end if cmp bl, 0x08 jb .l0 cmp bl, 0x0e @@ -428,23 +436,23 @@ term9: mov [eax+8], ecx mov [eax+12], ecx .cont: - add eax, 16 - cmp eax, hotkey_list+256*16 - jb .loop -; get process PID - mov eax, esi - shl eax, 5 - mov eax, [eax+CURRENT_TASK+TASKDATA.pid] -; compare current lock input with process PID - cmp eax, [PID_lock_input] - jne @f - - xor eax, eax - mov [PID_lock_input], eax -@@: -; remove hotkeys in buffer - mov eax, hotkey_buffer -.loop2: + add eax, 16 + cmp eax, hotkey_list+256*16 + jb .loop +; get process PID + mov eax, esi + shl eax, 5 + mov eax, [eax+CURRENT_TASK+TASKDATA.pid] +; compare current lock input with process PID + cmp eax, [PID_lock_input] + jne @f + + xor eax, eax + mov [PID_lock_input], eax +@@: +; remove hotkeys in buffer + mov eax, hotkey_buffer +.loop2: cmp [eax], esi jnz .cont2 and dword [eax+4], 0 @@ -691,25 +699,100 @@ term9: ;mov esi,process_terminated ;call sys_msg_board_str add esp, 4 - ret -restore .slot - -;iglobal -;if lang eq ru -; boot_sched_1 db '‘®§€ ­š¥ GDT TSS 㪠§ â¥«ï',0 -; boot_sched_2 db '‘®§€ ­š¥ IDT â ¡«šæë',0 -;else -; boot_sched_1 db 'Building gdt tss pointer',0 -; boot_sched_2 db 'Building IDT table',0 -;end if -;endg - - -;build_scheduler: -; mov esi, boot_sched_1 -; call boot_log -; call build_process_gdt_tss_pointer - -; mov esi,boot_sched_2 -; call boot_log -; ret + ret +restore .slot + +;iglobal +;if lang eq ru +; boot_sched_1 db '‘®§€ ­š¥ GDT TSS 㪠§ â¥«ï',0 +; boot_sched_2 db '‘®§€ ­š¥ IDT â ¡«šæë',0 +;else +; boot_sched_1 db 'Building gdt tss pointer',0 +; boot_sched_2 db 'Building IDT table',0 +;end if +;endg + + +;build_scheduler: +; mov esi, boot_sched_1 +; call boot_log +; call build_process_gdt_tss_pointer + +; mov esi,boot_sched_2 +; call boot_log +; ret + +; Three following procedures are used to guarantee that +; some part of kernel code will not be terminated from outside +; while it is running. +; Note: they do not protect a thread from terminating due to errors inside +; the thread; accessing a nonexisting memory would still terminate it. + +; First two procedures must be used in pair by thread-to-be-protected +; to signal the beginning and the end of an important part. +; It is OK to have nested areas. + +; The last procedure must be used by outside wanna-be-terminators; +; if it is safe to terminate the given thread immediately, it returns eax=1; +; otherwise, it returns eax=0 and notifies the target thread that it should +; terminate itself when leaving a critical area (the last critical area if +; they are nested). + +; Implementation. Those procedures use one dword in APPDATA for the thread, +; APPDATA.terminate_protection. +; * The upper bit is 1 during normal operations and 0 when terminate is requested. +; * Other bits form a number = depth of critical regions, +; plus 1 if the upper bit is 1. +; * When this dword goes to zero, the thread should be destructed, +; and the procedure in which it happened becomes responsible for destruction. + +; Enter critical area. Called by thread which wants to be protected. +proc protect_from_terminate + mov edx, [current_slot] +; Atomically increment depth of critical areas and get the old value. + mov eax, 1 + lock xadd [edx+APPDATA.terminate_protection], eax +; If the old value was zero, somebody has started to terminate us, +; so we are destructing and cannot do anything protected. +; Otherwise, return to the caller. + test eax, eax + jz @f + ret +@@: +; Wait for somebody to finish us. + call change_task + jmp @b +endp + +; Leave critical area. Called by thread which wants to be protected. +proc unprotect_from_terminate + mov edx, [current_slot] +; Atomically decrement depth of critical areas. + lock dec [edx+APPDATA.terminate_protection] +; If the result of decrement is zero, somebody has requested termination, +; but at that moment we were inside a critical area; terminate now. + jz sys_end +; Otherwise, return to the caller. + ret +endp + +; Request termination of thread identified by edx = SLOT_BASE + slot*256. +; Called by anyone. +proc request_terminate + xor eax, eax ; set return value +; Atomically clear the upper bit. If it was already zero, then +; somebody has requested termination before us, so just exit. + lock btr [edx+APPDATA.terminate_protection], 31 + jnc .unsafe +; Atomically decrement depth of critical areas. + lock dec [edx+APPDATA.terminate_protection] +; If the result of decrement is nonzero, the target thread is inside a +; critical area; leave termination to leaving that area. + jnz .unsafe +; Otherwise, it is safe to kill the target now and the caller is responsible +; for this. Return eax=1. + inc eax +.unsafe: + ret +endp + diff --git a/kernel/branches/net/core/syscall.inc b/kernel/branches/net/core/syscall.inc index 32d1cc6372..3114364519 100644 --- a/kernel/branches/net/core/syscall.inc +++ b/kernel/branches/net/core/syscall.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision $ +$Revision$ ; Old style system call converter align 16 @@ -38,9 +38,13 @@ sysenter_entry: pushad cld - movzx eax, al + call protect_from_terminate + + movzx eax, byte [esp+28] + mov edx, dword [esp+20] call dword [servetable2 + eax * 4] + call unprotect_from_terminate popad ;------------------ xchg ecx, [ss:esp] ; â âåðøèí ñòåêà - app ecx, ecx - app esp + 4 @@ -62,8 +66,11 @@ align 16 i40: pushad cld - movzx eax, al + call protect_from_terminate + movzx eax, byte [esp+28] + mov edx, dword [esp+20] call dword [servetable2 + eax * 4] + call unprotect_from_terminate popad iretd @@ -85,10 +92,13 @@ syscall_entry: ;------------------ pushad cld + call protect_from_terminate - movzx eax, al + movzx eax, byte [esp+28] + mov edx, dword [esp+20] call dword [servetable2 + eax * 4] + call unprotect_from_terminate popad ;------------------ mov ecx, [ss:esp+4] @@ -125,7 +135,7 @@ iglobal dd sys_getkey ; 2-GetKey dd sys_clock ; 3-GetTime dd syscall_writetext ; 4-WriteText - dd delay_hs ; 5-DelayHs + dd delay_hs_unprotected ; 5-DelayHs dd syscall_openramdiskfile ; 6-OpenRamdiskFile dd syscall_putimage ; 7-PutImage dd syscall_button ; 8-DefineButton diff --git a/kernel/branches/net/core/taskman.inc b/kernel/branches/net/core/taskman.inc index c76257a821..267e257875 100644 --- a/kernel/branches/net/core/taskman.inc +++ b/kernel/branches/net/core/taskman.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision $ +$Revision$ GREEDY_KERNEL equ 0 @@ -307,7 +307,6 @@ end if .failed: mov eax, [save_cr3] call set_cr3 - .err: .err_hdr: stdcall kernel_free, [file_base] @@ -1076,6 +1075,7 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov [eax+SLOT_BASE+APPDATA.fpu_state], edi mov [eax+SLOT_BASE+APPDATA.exc_handler], 0 mov [eax+SLOT_BASE+APPDATA.except_mask], 0 + mov [eax+SLOT_BASE+APPDATA.terminate_protection], 80000001h ;set default io permission map mov ecx, [SLOT_BASE+256+APPDATA.io_map] @@ -1200,6 +1200,14 @@ proc set_app_params stdcall,slot:dword, params:dword,\ mov eax, [esi+0x08] ;app_eip mov [ebx+REG_EIP], eax;app_entry mov [ebx+REG_CS], dword app_code + mov eax, [CURRENT_TASK] + shl eax, 8 ; created by kernel? + cmp [SLOT_BASE+eax+APPDATA.dir_table], sys_pgdir - OS_BASE + jnz @f + cmp [app_path], 0 ; it is a thread? + jnz @f + mov [ebx+REG_CS], dword os_code ; kernel thread +@@: mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF mov eax, [esi+0x0C] ;app_esp diff --git a/kernel/branches/net/core/test_malloc.asm b/kernel/branches/net/core/test_malloc.asm index 1197e24184..0112c91e19 100644 --- a/kernel/branches/net/core/test_malloc.asm +++ b/kernel/branches/net/core/test_malloc.asm @@ -1,13 +1,13 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; Tests of malloc()/free() from the kernel heap. -; This file is not included in the kernel, it is just test application. -use32 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Tests of malloc()/free() from the kernel heap. +; This file is not included in the kernel, it is just test application. +use32 db 'MENUET01' dd 1, start, i_end, mem, mem, 0, 0 @@ -47,18 +47,18 @@ run_test1: ret run_test2: - ret - -run_test3: -; 1024 times run random operation. -; Randomly select malloc(random size from 1 to 1023) -; or free(random of previously allocated areas) - mov edi, 0x12345678 - xor esi, esi ; 0 areas allocated - mov ebx, 1024 -.loop: - imul edi, 1103515245 - add edi, 12345 + ret + +run_test3: +; 1024 times run random operation. +; Randomly select malloc(random size from 1 to 1023) +; or free(random of previously allocated areas) + mov edi, 0x12345678 + xor esi, esi ; 0 areas allocated + mov ebx, 1024 +.loop: + imul edi, 1103515245 + add edi, 12345 mov eax, edi shr eax, 16 test ebx, 64 @@ -75,17 +75,17 @@ run_test3: and eax, 1023 jz .loop push ebx - push eax -; mov ecx, [saved_state_num] -; mov [saved_state+ecx*8], eax - push edi - call malloc_with_test - pop ecx - cmp ecx, edi - jnz edi_destroyed -; mov ecx, [saved_state_num] -; mov [saved_state+ecx*8+4], eax -; inc [saved_state_num] + push eax +; mov ecx, [saved_state_num] +; mov [saved_state+ecx*8], eax + push edi + call malloc_with_test + pop ecx + cmp ecx, edi + jnz edi_destroyed +; mov ecx, [saved_state_num] +; mov [saved_state+ecx*8+4], eax +; inc [saved_state_num] pop ecx pop ebx inc esi @@ -114,17 +114,17 @@ run_test3: mov edi, eax mov al, [edi] repz scasb - jnz memory_destroyed - pop eax edi - push ebx edx - push edi - call free - pop ecx - cmp ecx, edi - jnz edi_destroyed - pop edx ebx - dec esi - pop eax ecx + jnz memory_destroyed + pop eax edi + push ebx edx + push edi + call free + pop ecx + cmp ecx, edi + jnz edi_destroyed + pop edx ebx + dec esi + pop eax ecx push edi lea edi, [esp+4] @@: @@ -155,21 +155,21 @@ malloc_with_test: jz generic_malloc_fail call check_mutex call check_range - ret - -; Stubs for kernel procedures used by heap code -mutex_init: - and dword [ecx], 0 - ret -mutex_lock: - inc dword [ecx] - ret -mutex_unlock: - dec dword [ecx] - ret - -kernel_alloc: - cmp dword [esp+4], bufsize + ret + +; Stubs for kernel procedures used by heap code +mutex_init: + and dword [ecx], 0 + ret +mutex_lock: + inc dword [ecx] + ret +mutex_unlock: + dec dword [ecx] + ret + +kernel_alloc: + cmp dword [esp+4], bufsize jnz error1 mov eax, buffer ret 4 @@ -185,13 +185,13 @@ error1: generic_malloc_fail: mov eax, 2 - jmp error_with_code - -check_mutex: - cmp dword [mst.mutex], 0 - jnz @f - ret -@@: + jmp error_with_code + +check_mutex: + cmp dword [mst.mutex], 0 + jnz @f + ret +@@: mov eax, 3 jmp error_with_code @@ -206,16 +206,16 @@ check_range: jmp error_with_code memory_destroyed: - mov eax, 5 - jmp error_with_code - -edi_destroyed: - mov eax, 6 - jmp error_with_code - -error_with_code: - mov edx, saved_state_num -; eax = error code + mov eax, 5 + jmp error_with_code + +edi_destroyed: + mov eax, 6 + jmp error_with_code + +error_with_code: + mov edx, saved_state_num +; eax = error code ; 1 signals error in testing code (wrong bufsize) ; 2 = malloc() returned NULL ; 3 = mutex not released @@ -223,13 +223,13 @@ error_with_code: ; 5 = memory destroyed by malloc() or free() int3 ; simplest way to report error jmp $-1 ; just in case - -; Include main heap code -include '../proc32.inc' -include '../struct.inc' -include '../const.inc' -include 'malloc.inc' - + +; Include main heap code +include '../proc32.inc' +include '../struct.inc' +include '../const.inc' +include 'malloc.inc' + i_end: align 4 diff --git a/kernel/branches/net/core/timers.inc b/kernel/branches/net/core/timers.inc index d622ebe611..f9030de248 100644 --- a/kernel/branches/net/core/timers.inc +++ b/kernel/branches/net/core/timers.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Revision: 2381 $ diff --git a/kernel/branches/net/data32.inc b/kernel/branches/net/data32.inc index dcb4572e23..01c52b414a 100644 --- a/kernel/branches/net/data32.inc +++ b/kernel/branches/net/data32.inc @@ -46,29 +46,29 @@ keymap_alt: db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - - -if lang eq ru - boot_initirq db 'ˆ­šæš «š§ æšï IRQ',0 - boot_picinit db 'ˆ­šæš «š§ æšï PIC',0 - boot_v86machine db 'ˆ­šæš «š§ æšï ášá⥬ë V86 ¬ èš­ë',0 - boot_inittimer db 'ˆ­šæš «š§ æšï ášá⥬­®£® â ©¬¥à  (IRQ0)',0 - boot_initapic db '®¯ë⪠ š­šæš «š§ æšš APIC',0 - boot_enableirq db '‚ª«îçšâì ¯à¥à뢠­šï 2, 6, 13, 14, 15',0 - boot_enablint_ide db ' §à¥è¥­š¥ ¯à¥à뢠­š© ¢ ª®­â஫«¥à¥ IDE',0 - boot_detectfloppy db '®šáª floppy €šáª®¢®€®¢',0 - boot_detecthdcd db '®šáª Š¥áâªšå €šáª®¢ š ATAPI ¯àš¢®€®¢',0 - boot_getcache db '®«ã祭š¥ ¯ ¬ïâš €«ï ªíè ',0 - boot_detectpart db '®šáª à §€¥«®¢ ­  €šáª®¢ëå ãáâனá⢠å',0 - boot_init_sys db 'ˆ­šæš «š§ æšï ášá⥬­®£® ª â «®£  /sys',0 - boot_loadlibs db '‡ £à㧪  ¡š¡«š®â¥ª (.obj)',0 - boot_memdetect db 'Š®«šç¥á⢮ ®¯¥à âš¢­®© ¯ ¬ïâš',' ',' Œ¡',0 - boot_tss db '“áâ ­®¢ª  TSSs',0 - boot_cpuid db '—⥭š¥ CPUIDs',0 -; boot_devices db '®šáª ãáâனáâ¢',0 - boot_timer db '“áâ ­®¢ª  â ©¬¥à ',0 - boot_irqs db '¥à¥®¯à¥€¥«¥­š¥ IRQ',0 - boot_setmouse db '“áâ ­®¢ª  ¬ëèš',0 + + +if lang eq ru + boot_initirq db 'ˆ­šæš «š§ æšï IRQ',0 + boot_picinit db 'ˆ­šæš «š§ æšï PIC',0 + boot_v86machine db 'ˆ­šæš «š§ æšï ášá⥬ë V86 ¬ èš­ë',0 + boot_inittimer db 'ˆ­šæš «š§ æšï ášá⥬­®£® â ©¬¥à  (IRQ0)',0 + boot_initapic db '®¯ë⪠ š­šæš «š§ æšš APIC',0 + boot_enableirq db '‚ª«îçšâì ¯à¥à뢠­šï 2, 6, 13, 14, 15',0 + boot_enablint_ide db ' §à¥è¥­š¥ ¯à¥à뢠­š© ¢ ª®­â஫«¥à¥ IDE',0 + boot_detectfloppy db '®šáª floppy €šáª®¢®€®¢',0 + boot_detecthdcd db '®šáª Š¥áâªšå €šáª®¢ š ATAPI ¯àš¢®€®¢',0 + boot_getcache db '®«ã祭š¥ ¯ ¬ïâš €«ï ªíè ',0 + boot_detectpart db '®šáª à §€¥«®¢ ­  €šáª®¢ëå ãáâனá⢠å',0 + boot_init_sys db 'ˆ­šæš «š§ æšï ášá⥬­®£® ª â «®£  /sys',0 + boot_loadlibs db '‡ £à㧪  ¡š¡«š®â¥ª (.obj)',0 + boot_memdetect db 'Š®«šç¥á⢮ ®¯¥à âš¢­®© ¯ ¬ïâš',' ',' Œ¡',0 + boot_tss db '“áâ ­®¢ª  TSSs',0 + boot_cpuid db '—⥭š¥ CPUIDs',0 +; boot_devices db '®šáª ãáâனáâ¢',0 + boot_timer db '“áâ ­®¢ª  â ©¬¥à ',0 + boot_irqs db '¥à¥®¯à¥€¥«¥­š¥ IRQ',0 + boot_setmouse db '“áâ ­®¢ª  ¬ëèš',0 boot_windefs db '“áâ ­®¢ª  ­ áâ஥ª ®ª®­ ¯® 㬮«ç ­šî',0 boot_bgr db '“áâ ­®¢ª  ä®­ ',0 boot_resirqports db '¥§¥à¢šà®¢ ­š¥ IRQ š ¯®à⮢',0 @@ -78,69 +78,73 @@ if lang eq ru boot_tsc db '—⥭š¥ TSC',0 boot_cpufreq db '— áâ®â  ¯à®æ¥áá®à  ',' ',' Œƒæ',0 boot_pal_ega db '“áâ ­®¢ª  EGA/CGA 320x200 ¯ «šâàë',0 - boot_pal_vga db '“áâ ­®¢ª  VGA 640x480 ¯ «šâàë',0 - boot_failed db '‡ £à㧪  ¯¥à¢®£® ¯àš«®Š¥­šï ­¥ 〠« áì',0 - boot_mtrr db '“áâ ­®¢ª  MTRR',0 - - boot_APIC_found db 'APIC ¢ª«î祭', 0 - boot_APIC_nfound db 'APIC ­¥ ­ ©€¥­', 0 -if preboot_blogesc - boot_tasking db '‚ᥠ£®â®¢® €«ï § ¯ã᪠, ­ Š¬šâॠESC €«ï áâ àâ ',0 -end if -else - boot_initirq db 'Initialize IRQ',0 - boot_picinit db 'Initialize PIC',0 - boot_v86machine db 'Initialize system V86 machine',0 - boot_inittimer db 'Initialize system timer (IRQ0)',0 - boot_initapic db 'Try to initialize APIC',0 - boot_enableirq db 'Enable interrupts 2, 6, 13, 14, 15',0 - boot_enablint_ide db 'Enable interrupts in IDE controller',0 - boot_detectfloppy db 'Search floppy drives',0 - boot_detecthdcd db 'Search hard drives and ATAPI drives',0 - boot_getcache db 'Get memory for cache',0 - boot_detectpart db 'Search partitions on disk devices',0 - boot_init_sys db 'Initialize system directory /sys',0 - boot_loadlibs db 'Loading librares (.obj)',0 - boot_memdetect db 'Determining amount of memory',0 - boot_tss db 'Setting TSSs',0 - boot_cpuid db 'Reading CPUIDs',0 -; boot_devices db 'Detecting devices',0 - boot_setmouse db 'Setting mouse',0 - boot_windefs db 'Setting window defaults',0 - boot_bgr db 'Calculating background',0 + boot_pal_vga db '“áâ ­®¢ª  VGA 640x480 ¯ «šâàë',0 + boot_failed db '‡ £à㧪  ¯¥à¢®£® ¯àš«®Š¥­šï ­¥ 〠« áì',0 + boot_mtrr db '“áâ ­®¢ª  MTRR',0 + + boot_APIC_found db 'APIC ¢ª«î祭', 0 + boot_APIC_nfound db 'APIC ­¥ ­ ©€¥­', 0 +if preboot_blogesc + boot_tasking db '‚ᥠ£®â®¢® €«ï § ¯ã᪠, ­ Š¬šâॠESC €«ï áâ àâ ',0 +end if +else if lang eq sp + include 'data32sp.inc' +else + boot_initirq db 'Initialize IRQ',0 + boot_picinit db 'Initialize PIC',0 + boot_v86machine db 'Initialize system V86 machine',0 + boot_inittimer db 'Initialize system timer (IRQ0)',0 + boot_initapic db 'Try to initialize APIC',0 + boot_enableirq db 'Enable interrupts 2, 6, 13, 14, 15',0 + boot_enablint_ide db 'Enable interrupts in IDE controller',0 + boot_detectfloppy db 'Search floppy drives',0 + boot_detecthdcd db 'Search hard drives and ATAPI drives',0 + boot_getcache db 'Get memory for cache',0 + boot_detectpart db 'Search partitions on disk devices',0 + boot_init_sys db 'Initialize system directory /sys',0 + boot_loadlibs db 'Loading librares (.obj)',0 + boot_memdetect db 'Determining amount of memory',0 + boot_tss db 'Setting TSSs',0 + boot_cpuid db 'Reading CPUIDs',0 +; boot_devices db 'Detecting devices',0 + boot_setmouse db 'Setting mouse',0 + boot_windefs db 'Setting window defaults',0 + boot_bgr db 'Calculating background',0 boot_resirqports db 'Reserving IRQs & ports',0 boot_setostask db 'Setting OS task',0 boot_allirqs db 'Unmasking IRQs',0 boot_tsc db 'Reading TSC',0 boot_cpufreq db 'CPU frequency is ',' ',' MHz',0 boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0 - boot_pal_vga db 'Setting VGA 640x480 palette',0 - boot_failed db 'Failed to start first app',0 - boot_mtrr db 'Setting MTRR',0 - - boot_APIC_found db 'APIC enabled', 0 - boot_APIC_nfound db 'APIC not found', 0 -if preboot_blogesc - boot_tasking db 'All set - press ESC to start',0 -end if -end if - -;new_process_loading db 'K : New Process - loading',13,10,0 -;new_process_running db 'K : New Process - done',13,10,0 -start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 + boot_pal_vga db 'Setting VGA 640x480 palette',0 + boot_failed db 'Failed to start first app',0 + boot_mtrr db 'Setting MTRR',0 + + boot_APIC_found db 'APIC enabled', 0 + boot_APIC_nfound db 'APIC not found', 0 +if preboot_blogesc + boot_tasking db 'All set - press ESC to start',0 +end if +end if + +;new_process_loading db 'K : New Process - loading',13,10,0 +;new_process_running db 'K : New Process - done',13,10,0 +start_not_enough_memory db 'K : New Process - not enough memory',13,10,0 msg_unresolved db 'unresolved ',0 msg_module db 'in module ',0 -msg_version db 'incompatible driver version',13,10,0 -msg_www db 'please visit www.kolibrios.org',13,10,0 -msg_CR db 13,10,0 - -intel_str db "GenuineIntel",0 -AMD_str db "AuthenticAMD",0 - -szHwMouse db 'ATI2D',0 -szPS2MDriver db 'PS2MOUSE',0 -;szCOM_MDriver db 'COM_MOUSE',0 +if ~ lang eq sp +msg_version db 'incompatible driver version',13,10,0 +msg_www db 'please visit www.kolibrios.org',13,10,0 +end if +msg_CR db 13,10,0 + +intel_str db "GenuineIntel",0 +AMD_str db "AuthenticAMD",0 + +szHwMouse db 'ATI2D',0 +szPS2MDriver db 'PS2MOUSE',0 +;szCOM_MDriver db 'COM_MOUSE',0 szUSB db 'USB',0 szAtiHW db '/rd/1/drivers/ati2d.drv',0 @@ -155,13 +159,13 @@ firstapp db 'LAUNCHER',0 notifyapp db '@notify',0 if lang eq ru ud_user_message db 'Žèš¡ª : ­¥¯®€€¥àŠš¢ ¥¬ ï š­áâàãªæšï ¯à®æ¥áá®à ',0 -else -ud_user_message db 'Error: unsupported processor instruction',0 -end if - -bootpath db '/KOLIBRI ' -bootpath2 db 0 -vmode db '/sys/drivers/VMODE.MDR',0 +else if ~ lang eq sp +ud_user_message db 'Error: unsupported processor instruction',0 +end if + +bootpath db '/KOLIBRI ' +bootpath2 db 0 +vmode db '/sys/drivers/VMODE.MDR',0 ;vrr_m db 'VRR_M',0 kernel_file db 'KERNEL MNT' diff --git a/kernel/branches/net/data32sp.inc b/kernel/branches/net/data32sp.inc new file mode 100644 index 0000000000..1634abe754 --- /dev/null +++ b/kernel/branches/net/data32sp.inc @@ -0,0 +1,40 @@ + boot_initirq db 'Inicializar IRQ',0 + boot_picinit db 'Inicializar PIC',0 + boot_v86machine db 'Inicializar sistema V86',0 + boot_inittimer db 'Inicializar reloj del sistema (IRQ0)',0 + boot_initapic db 'Prueba inicializar APIC',0 + boot_enableirq db 'Habilitar interrupciones 2, 6, 13, 14, 15',0 + boot_enablint_ide db 'Habiliar interrupciones en controladores IDE',0 + boot_detectfloppy db 'Buscar unidades de disquete',0 + boot_detecthdcd db 'Buscar discos duros y unidades ATAPI',0 + boot_getcache db 'Tomar memoria para cach‚',0 + boot_detectpart db 'Buscar particiones en discos',0 + boot_init_sys db 'Inicializar directorio del sistema /sys',0 + boot_loadlibs db 'Cargando librer¡as (.obj)',0 + boot_memdetect db 'Determinando cantidad de memoria',0 + boot_tss db 'Configurando TSSs',0 + boot_cpuid db 'Leyendo CPUIDs',0 +; boot_devices db 'Detectando dispositivos',0 + boot_setmouse db 'Configurando el rat¢n',0 + boot_windefs db 'Setting window defaults',0 + boot_bgr db 'Calculating background',0 + boot_resirqports db 'Reservando IRQs y puertos',0 + boot_setostask db 'Configurando tarea OS',0 + boot_allirqs db 'Desenmascarando IRQs',0 + boot_tsc db 'Leyendo TSC',0 + boot_cpufreq db 'La frequencia del CPU es ',' ',' MHz',0 + boot_pal_ega db 'Configurando paleta EGA/CGA 320x200',0 + boot_pal_vga db 'Configurando paleta VGA 640x480',0 + boot_failed db 'Fallo al iniciar la primer aplicaci¢n',0 + boot_mtrr db 'Configurando MTRR',0 + + boot_APIC_found db 'APIC habilitado', 0 + boot_APIC_nfound db 'APIC no encontrado', 0 +if preboot_blogesc + boot_tasking db 'Todo configurado - presiona ESC para iniciar',0 +end if + +msg_version db 'versi¢n incompatible del controlador',13,10,0 +msg_www db 'por favor, visita www.kolibrios.org',13,10,0 + +ud_user_message db 'Error: instrucci¢n no soportada por el procesador',0 diff --git a/kernel/branches/net/detect/biosdisk.inc b/kernel/branches/net/detect/biosdisk.inc index eb1c6688b8..acabba277b 100644 --- a/kernel/branches/net/detect/biosdisk.inc +++ b/kernel/branches/net/detect/biosdisk.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2008-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2008-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Detect all BIOS hard drives. ; diamond, 2008 diff --git a/kernel/branches/net/detect/biosmem.inc b/kernel/branches/net/detect/biosmem.inc index 2bb66a600f..85cf0d1f41 100644 --- a/kernel/branches/net/detect/biosmem.inc +++ b/kernel/branches/net/detect/biosmem.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Query physical memory map from BIOS. ; diamond, 2009 @@ -20,14 +20,14 @@ mov edx, 0x534D4150 int 15h jc no_E820 - cmp eax, 0x534D4150 - jnz no_E820 -e820_mem_loop: -; cmp byte [di+16], 1 ; ignore non-free areas -; jnz e820_mem_next - inc byte [0x9100] - add di, 20 -e820_mem_next: + cmp eax, 0x534D4150 + jnz no_E820 +e820_mem_loop: +; cmp byte [di+16], 1 ; ignore non-free areas +; jnz e820_mem_next + inc byte [0x9100] + add di, 20 +e820_mem_next: ; consequent calls to fn E820 test ebx, ebx jz e820_test_done diff --git a/kernel/branches/net/detect/sear_par.inc b/kernel/branches/net/detect/sear_par.inc index 61c74e7012..1013e66fcf 100644 --- a/kernel/branches/net/detect/sear_par.inc +++ b/kernel/branches/net/detect/sear_par.inc @@ -130,16 +130,16 @@ search_partitions_bd: end_search_partitions_bd: pop ecx inc [hdpos] - loop start_search_partitions_bd - jmp end_search_partitions - -problem_partition db 0 ; used for partitions search - -include '../fs/part_set.inc' - -partition_data_transfer: - mov edi, [transfer_adress] - mov esi, PARTITION_START ;start of file_system_data + loop start_search_partitions_bd + jmp end_search_partitions + +problem_partition db 0 ; used for partitions search + +include '../fs/part_set.inc' + +partition_data_transfer: + mov edi, [transfer_adress] + mov esi, PARTITION_START ;start of file_system_data mov ecx, (file_system_data_size+3)/4 rep movsd ret diff --git a/kernel/branches/net/fs/ext2.inc b/kernel/branches/net/fs/ext2.inc index 477e402452..16ff505b77 100644 --- a/kernel/branches/net/fs/ext2.inc +++ b/kernel/branches/net/fs/ext2.inc @@ -1,50 +1,50 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; 02.02.2010 turbanoff - support 70.5 ;; -;; 23.01.2010 turbanoff - support 70.0 70.1 ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; 02.02.2010 turbanoff - support 70.5 ;; +;; 23.01.2010 turbanoff - support 70.0 70.1 ;; ;; ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $Revision: 2381 $ - -EXT2_BAD_INO = 1 -EXT2_ROOT_INO = 2 -EXT2_ACL_IDX_INO = 3 -EXT2_ACL_DATA_INO = 4 -EXT2_BOOT_LOADER_INO = 5 -EXT2_UNDEL_DIR_INO = 6 - -;флагО, указываеЌый в inode файла -EXT2_S_IFREG = 0x8000 -EXT2_S_IFDIR = 0x4000 -EXT2_S_IFMT = 0xF000 ;Ќаска Ўля тОпа файла - -;флагО, указываеЌые в linked list рПЎОтельскПй папкО -EXT2_FT_REG_FILE = 1 ;этП файл, запОсь в рПЎОтельскПЌ каталПге -EXT2_FT_DIR = 2 ;этП папка - -;флагО ОспПльзуеЌые KolibriOS -FS_FT_HIDDEN = 2 -FS_FT_DIR = 0x10 ;этП папка -FS_FT_ASCII = 0 ;ОЌя в ascii -FS_FT_UNICODE = 1 ;ОЌя в unicode - -EXT2_FEATURE_INCOMPAT_FILETYPE = 0x0002 ;тОп файла ЎПлжеМ указываться в ЎОректПрОО -EXT4_FEATURE_INCOMPAT_EXTENTS = 0x0040 ;экстеМты -EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x0200 ;гОбкОе группы блПкПв -;реалОзПваММые ext[234] features -EXT4_FEATURE_INCOMPAT_SUPP = EXT2_FEATURE_INCOMPAT_FILETYPE \ - or EXT4_FEATURE_INCOMPAT_EXTENTS \ - or EXT4_FEATURE_INCOMPAT_FLEX_BG - - -;флагО, указываеЌые Ўля inode в i_flags -EXT2_EXTENTS_FL = 0x00080000 - -struct EXT2_INODE_STRUC + +EXT2_BAD_INO = 1 +EXT2_ROOT_INO = 2 +EXT2_ACL_IDX_INO = 3 +EXT2_ACL_DATA_INO = 4 +EXT2_BOOT_LOADER_INO = 5 +EXT2_UNDEL_DIR_INO = 6 + +;флагО, указываеЌый в inode файла +EXT2_S_IFREG = 0x8000 +EXT2_S_IFDIR = 0x4000 +EXT2_S_IFMT = 0xF000 ;Ќаска Ўля тОпа файла + +;флагО, указываеЌые в linked list рПЎОтельскПй папкО +EXT2_FT_REG_FILE = 1 ;этП файл, запОсь в рПЎОтельскПЌ каталПге +EXT2_FT_DIR = 2 ;этП папка + +;флагО ОспПльзуеЌые KolibriOS +FS_FT_HIDDEN = 2 +FS_FT_DIR = 0x10 ;этП папка +FS_FT_ASCII = 0 ;ОЌя в ascii +FS_FT_UNICODE = 1 ;ОЌя в unicode + +EXT2_FEATURE_INCOMPAT_FILETYPE = 0x0002 ;тОп файла ЎПлжеМ указываться в ЎОректПрОО +EXT4_FEATURE_INCOMPAT_EXTENTS = 0x0040 ;экстеМты +EXT4_FEATURE_INCOMPAT_FLEX_BG = 0x0200 ;гОбкОе группы блПкПв +;реалОзПваММые ext[234] features +EXT4_FEATURE_INCOMPAT_SUPP = EXT2_FEATURE_INCOMPAT_FILETYPE \ + or EXT4_FEATURE_INCOMPAT_EXTENTS \ + or EXT4_FEATURE_INCOMPAT_FLEX_BG + + +;флагО, указываеЌые Ўля inode в i_flags +EXT2_EXTENTS_FL = 0x00080000 + +struct EXT2_INODE_STRUC i_mode dw ? i_uid dw ? i_size dd ? @@ -71,20 +71,20 @@ struct EXT2_DIR_STRUC name_len db ? file_type db ? name db ? ; 0..255 -ends - -struct EXT2_BLOCK_GROUP_DESC - block_bitmap dd ? ;+0 - inode_bitmap dd ? ;+4 - inode_table dd ? ;+8 - free_blocks_count dw ? ;+12 - free_inodes_count dw ? ;+14 - used_dirs_count dw ? ;+16 - pad dw ? ;+18 - reserved rb 12;+20 -ends - -struct EXT2_SB_STRUC +ends + +struct EXT2_BLOCK_GROUP_DESC + block_bitmap dd ? ;+0 + inode_bitmap dd ? ;+4 + inode_table dd ? ;+8 + free_blocks_count dw ? ;+12 + free_inodes_count dw ? ;+14 + used_dirs_count dw ? ;+16 + pad dw ? ;+18 + reserved rb 12;+20 +ends + +struct EXT2_SB_STRUC inodes_count dd ? ;+0 blocks_count dd ? ;+4 r_block_count dd ? ;+8 @@ -119,80 +119,80 @@ struct EXT2_SB_STRUC uuid rb 16 ;+104 volume_name rb 16 ;+120 last_mounted rb 64 ;+136 - algo_bitmap dd ? ;+200 - prealloc_blocks db ? ;+204 - preallock_dir_blocks db ? ;+205 - reserved_gdt_blocks dw ? ;+206 - journal_uuid rb 16 ;+208 - journal_inum dd ? ;+224 - journal_dev dd ? ;+228 + algo_bitmap dd ? ;+200 + prealloc_blocks db ? ;+204 + preallock_dir_blocks db ? ;+205 + reserved_gdt_blocks dw ? ;+206 + journal_uuid rb 16 ;+208 + journal_inum dd ? ;+224 + journal_dev dd ? ;+228 last_orphan dd ? ;+232 hash_seed rd 4 ;+236 def_hash_version db ? ;+252 - rb 3 ;+253 reserved - default_mount_options dd ? ;+256 - first_meta_bg dd ? ;+260 - mkfs_time dd ? ;+264 - jnl_blocks rd 17 ;+268 - blocks_count_hi dd ? ;+336 - r_blocks_count_hi dd ? ;+340 - free_blocks_count_hi dd ? ;+344 - min_extra_isize dw ? ;+348 - want_extra_isize dw ? ;+350 - flags dd ? ;+352 - raid_stride dw ? ;+356 - mmp_interval dw ? ;+358 - mmp_block dq ? ;+360 - raid_stripe_width dd ? ;+368 - log_groups_per_flex db ? ;+372 -ends - -struct EXT4_EXTENT_HEADER ;загПлПвПк блПка экстеМтПв/ОМЎексПв - eh_magic dw ? ;в текущей реалОзацОО ext4 ЎПлжМП быть 0xF30A - eh_entries dw ? ;кПлОчествП экстеМтПв/ОМЎексПв в блПке - eh_max dw ? ;max кПлОчествП (ОспПльзуется прО запОсО) - eh_depth dw ? ;глубОМа Ўерева (0, еслО этП блПк экстеМтПв) - eh_generation dd ? ;??? -ends - -struct EXT4_EXTENT ;экстеМт - ee_block dd ? ;МПЌер ext4 блПка - ee_len dw ? ;ЎлОМа экстеМта - ee_start_hi dw ? ;старшОе 16 бОт 48-бОтМПгП аЎреса (пПка Ме ОспПльзуются в KOS) - ee_start_lo dd ? ;ЌлаЎшОе 32 бОта 48-бОтМПгП аЎреса -ends - -struct EXT4_EXTENT_IDX ;ОМЎес - указатель Ма блПк с экстеМтаЌО/ОМЎексаЌО - ei_block dd ? ;МПЌер ext4 блПка - ei_leaf_lo dd ? ;ЌлаЎшОе 32 бОт 48-бОтМПгП аЎреса - ei_leaf_hi dw ? ;старшОе 16 бОт 48-бОтМПгП аЎреса (пПка Ме ОспПльзуются в KOS) - ei_unused dw ? ;зарезервОрПваМП -ends - -ext2_test_superblock: - cmp [fs_type], 0x83 - jne .no + rb 3 ;+253 reserved + default_mount_options dd ? ;+256 + first_meta_bg dd ? ;+260 + mkfs_time dd ? ;+264 + jnl_blocks rd 17 ;+268 + blocks_count_hi dd ? ;+336 + r_blocks_count_hi dd ? ;+340 + free_blocks_count_hi dd ? ;+344 + min_extra_isize dw ? ;+348 + want_extra_isize dw ? ;+350 + flags dd ? ;+352 + raid_stride dw ? ;+356 + mmp_interval dw ? ;+358 + mmp_block dq ? ;+360 + raid_stripe_width dd ? ;+368 + log_groups_per_flex db ? ;+372 +ends + +struct EXT4_EXTENT_HEADER ;загПлПвПк блПка экстеМтПв/ОМЎексПв + eh_magic dw ? ;в текущей реалОзацОО ext4 ЎПлжМП быть 0xF30A + eh_entries dw ? ;кПлОчествП экстеМтПв/ОМЎексПв в блПке + eh_max dw ? ;max кПлОчествП (ОспПльзуется прО запОсО) + eh_depth dw ? ;глубОМа Ўерева (0, еслО этП блПк экстеМтПв) + eh_generation dd ? ;??? +ends + +struct EXT4_EXTENT ;экстеМт + ee_block dd ? ;МПЌер ext4 блПка + ee_len dw ? ;ЎлОМа экстеМта + ee_start_hi dw ? ;старшОе 16 бОт 48-бОтМПгП аЎреса (пПка Ме ОспПльзуются в KOS) + ee_start_lo dd ? ;ЌлаЎшОе 32 бОта 48-бОтМПгП аЎреса +ends + +struct EXT4_EXTENT_IDX ;ОМЎес - указатель Ма блПк с экстеМтаЌО/ОМЎексаЌО + ei_block dd ? ;МПЌер ext4 блПка + ei_leaf_lo dd ? ;ЌлаЎшОе 32 бОт 48-бОтМПгП аЎреса + ei_leaf_hi dw ? ;старшОе 16 бОт 48-бОтМПгП аЎреса (пПка Ме ОспПльзуются в KOS) + ei_unused dw ? ;зарезервОрПваМП +ends + +ext2_test_superblock: + cmp [fs_type], 0x83 + jne .no mov eax, [PARTITION_START] - add eax, 2 ;superblock start at 1024b - call hd_read - - cmp [ebx + EXT2_SB_STRUC.log_block_size], 3 ;0,1,2,3 - ja .no - cmp [ebx + EXT2_SB_STRUC.magic], 0xEF53 - jne .no - cmp [ebx + EXT2_SB_STRUC.state], 1 ;EXT_VALID_FS=1 - jne .no - cmp [ebx + EXT2_SB_STRUC.inodes_per_group], 0 - je .no - - mov eax, [ebx + EXT2_SB_STRUC.feature_incompat] - test eax, EXT2_FEATURE_INCOMPAT_FILETYPE - jz .no - test eax, not EXT4_FEATURE_INCOMPAT_SUPP - jnz .no - - ; OK, this is correct EXT2 superblock + add eax, 2 ;superblock start at 1024b + call hd_read + + cmp [ebx + EXT2_SB_STRUC.log_block_size], 3 ;0,1,2,3 + ja .no + cmp [ebx + EXT2_SB_STRUC.magic], 0xEF53 + jne .no + cmp [ebx + EXT2_SB_STRUC.state], 1 ;EXT_VALID_FS=1 + jne .no + cmp [ebx + EXT2_SB_STRUC.inodes_per_group], 0 + je .no + + mov eax, [ebx + EXT2_SB_STRUC.feature_incompat] + test eax, EXT2_FEATURE_INCOMPAT_FILETYPE + jz .no + test eax, not EXT4_FEATURE_INCOMPAT_SUPP + jnz .no + + ; OK, this is correct EXT2 superblock clc ret .no: @@ -217,13 +217,13 @@ ext2_setup: dec eax xor edx, edx div [ebx + EXT2_SB_STRUC.blocks_per_group] - inc eax - mov [ext2_data.groups_count], eax - - mov ecx, [ebx + EXT2_SB_STRUC.log_block_size] - inc ecx - mov [ext2_data.log_block_size], ecx ; 1, 2, 3, 4 equ 1kb, 2kb, 4kb, 8kb - + inc eax + mov [ext2_data.groups_count], eax + + mov ecx, [ebx + EXT2_SB_STRUC.log_block_size] + inc ecx + mov [ext2_data.log_block_size], ecx ; 1, 2, 3, 4 equ 1kb, 2kb, 4kb, 8kb + mov eax, 1 shl eax, cl mov [ext2_data.count_block_in_block], eax @@ -243,17 +243,17 @@ ext2_setup: call kernel_alloc mov [ext2_data.ext2_save_block], eax ; and for temp block - call kernel_alloc - mov [ext2_data.ext2_temp_block], eax ; and for get_inode proc - - movzx ebp, word [ebx + EXT2_SB_STRUC.inode_size] - mov ecx, [ebx + EXT2_SB_STRUC.blocks_per_group] - - mov [ext2_data.inode_size], ebp - mov [ext2_data.blocks_per_group], ecx - - push ebp ebp ebp ;3 kernel_alloc - call kernel_alloc + call kernel_alloc + mov [ext2_data.ext2_temp_block], eax ; and for get_inode proc + + movzx ebp, word [ebx + EXT2_SB_STRUC.inode_size] + mov ecx, [ebx + EXT2_SB_STRUC.blocks_per_group] + + mov [ext2_data.inode_size], ebp + mov [ext2_data.blocks_per_group], ecx + + push ebp ebp ebp ;3 kernel_alloc + call kernel_alloc mov [ext2_data.ext2_save_inode], eax call kernel_alloc mov [ext2_data.ext2_temp_inode], eax @@ -264,242 +264,242 @@ ext2_setup: mov eax, EXT2_ROOT_INO call ext2_get_inode ; read root inode - jmp return_from_part_set - -;================================================================== -;read ext2 block form FS to memory -;in: eax = i_block (address of block in ext2 terms) -; ebx = pointer to return memory -;out: eax - error code (0 = no_error) -ext2_get_block: - push ebx ecx - mov ecx, [ext2_data.log_block_size] - shl eax, cl - add eax, [PARTITION_START] - mov ecx, [ext2_data.count_block_in_block] - @@: - call hd_read - cmp [hd_error], 0 - jnz .fail - inc eax - add ebx, 512 - loop @B - xor eax, eax - @@: - pop ecx ebx - ret - .fail: - mov eax, ERROR_DEVICE - jmp @B - - -;=================================================================== -;пПлучает МПЌер блПка Оз extent inode -;in: ecx = МПЌер блПка пП пПряЎку -; ebp = аЎрес extent header`а -;out: ecx - аЎрес ПчереЎМПгП блПка в случае успеха -; eax - МПЌер ПшОбкО (еслО равМП 0, тП ПшОбкО Мет) -ext4_block_recursive_search: - cmp word [ebp + EXT4_EXTENT_HEADER.eh_magic], 0xF30A ;EXT4_EXT_MAGIC - jne .fail - - movzx ebx, [ebp + EXT4_EXTENT_HEADER.eh_entries] - add ebp, sizeof.EXT4_EXTENT_HEADER - cmp word [ebp - sizeof.EXT4_EXTENT_HEADER + EXT4_EXTENT_HEADER.eh_depth], 0 - je .leaf_block ;лОстПвПй лО этП блПк? - - ;Ме лОстПвПй блПк, а ОМЎексМый ; eax - ext4_extent_idx - test ebx, ebx - jz .fail ;пустПй ОМЎексМый блПк -> ПшОбка - - ;цОкл пП ОМЎексаЌ экстеМтПв - @@: - cmp ebx, 1 ;у ОМЎексПв Ме храМОтся ЎлОМа, - je .end_search_index ;пПэтПЌу, еслО Пстался пПслеЎМОй - тП этП МужМый - - cmp ecx, [ebp + EXT4_EXTENT_IDX.ei_block] - jb .fail - - cmp ecx, [ebp + sizeof.EXT4_EXTENT_IDX + EXT4_EXTENT_IDX.ei_block] ;блПк слeЎующегП ОМЎекса - jb .end_search_index ;слеЎующОй Ўальше - зМачОт текущОй, тП чтП МаЌ МужеМ - - add ebp, sizeof.EXT4_EXTENT_IDX - dec ebx - jmp @B - - .end_search_index: - ;ebp указывает Ма МужМый extent_idx, счОтываеЌ слеЎующОй блПк - mov ebx, [ext2_data.ext2_temp_block] - mov eax, [ebp + EXT4_EXTENT_IDX.ei_leaf_lo] - call ext2_get_block - test eax, eax - jnz .fail - mov ebp, ebx - jmp ext4_block_recursive_search ;рекурсОвМП прыгаеЌ в МачалП - - .leaf_block: ;лОстПвПй блПк ebp - ext4_extent - ;цОкл пП экстеМтаЌ - @@: - test ebx, ebx - jz .fail ;МО ПЎОМ узел Ме пПЎПшел - ПшОбка - - mov edx, [ebp + EXT4_EXTENT.ee_block] - cmp ecx, edx - jb .fail ;еслО ЌеМьше, зМачОт ПМ был в преЎыЎущОх блПках -> ПшОбка - - movzx edi, [ebp + EXT4_EXTENT.ee_len] - add edx, edi - cmp ecx, edx - jb .end_search_extent ;МашлО МужМый блПк - - add ebp, sizeof.EXT4_EXTENT - dec ebx - jmp @B - - .end_search_extent: - mov edx, [ebp + EXT4_EXTENT.ee_start_lo] - sub ecx, [ebp + EXT4_EXTENT.ee_block] ;разМОца в ext4 блПках - add ecx, edx - xor eax, eax - ret - - .fail: - mov eax, ERROR_FS_FAIL - ret - -;=================================================================== -;пПлучает аЎрес ext2 блПка Оз inode с ПпреЎелММыЌ МПЌерПЌ -;in: ecx = МПЌер блПка в inode (0..) -; ebp = аЎрес inode -;out: ecx = аЎрес ПчереЎМПгП блПка -; eax - error code -ext2_get_inode_block: - test [ebp + EXT2_INODE_STRUC.i_flags], EXT2_EXTENTS_FL - jz @F - - pushad - add ebp, EXT2_INODE_STRUC.i_block ;ebp - extent_header - call ext4_block_recursive_search - mov PUSHAD_ECX, ecx - mov PUSHAD_EAX, eax - popad - ret - - @@: - cmp ecx, 12 ; 0..11 - direct block address - jb .get_direct_block - - sub ecx, 12 - cmp ecx, [ext2_data.count_pointer_in_block] ; 12.. - indirect blocks - jb .get_indirect_block - - sub ecx, [ext2_data.count_pointer_in_block] + jmp return_from_part_set + +;================================================================== +;read ext2 block form FS to memory +;in: eax = i_block (address of block in ext2 terms) +; ebx = pointer to return memory +;out: eax - error code (0 = no_error) +ext2_get_block: + push ebx ecx + mov ecx, [ext2_data.log_block_size] + shl eax, cl + add eax, [PARTITION_START] + mov ecx, [ext2_data.count_block_in_block] + @@: + call hd_read + cmp [hd_error], 0 + jnz .fail + inc eax + add ebx, 512 + loop @B + xor eax, eax + @@: + pop ecx ebx + ret + .fail: + mov eax, ERROR_DEVICE + jmp @B + + +;=================================================================== +;пПлучает МПЌер блПка Оз extent inode +;in: ecx = МПЌер блПка пП пПряЎку +; ebp = аЎрес extent header`а +;out: ecx - аЎрес ПчереЎМПгП блПка в случае успеха +; eax - МПЌер ПшОбкО (еслО равМП 0, тП ПшОбкО Мет) +ext4_block_recursive_search: + cmp word [ebp + EXT4_EXTENT_HEADER.eh_magic], 0xF30A ;EXT4_EXT_MAGIC + jne .fail + + movzx ebx, [ebp + EXT4_EXTENT_HEADER.eh_entries] + add ebp, sizeof.EXT4_EXTENT_HEADER + cmp word [ebp - sizeof.EXT4_EXTENT_HEADER + EXT4_EXTENT_HEADER.eh_depth], 0 + je .leaf_block ;лОстПвПй лО этП блПк? + + ;Ме лОстПвПй блПк, а ОМЎексМый ; eax - ext4_extent_idx + test ebx, ebx + jz .fail ;пустПй ОМЎексМый блПк -> ПшОбка + + ;цОкл пП ОМЎексаЌ экстеМтПв + @@: + cmp ebx, 1 ;у ОМЎексПв Ме храМОтся ЎлОМа, + je .end_search_index ;пПэтПЌу, еслО Пстался пПслеЎМОй - тП этП МужМый + + cmp ecx, [ebp + EXT4_EXTENT_IDX.ei_block] + jb .fail + + cmp ecx, [ebp + sizeof.EXT4_EXTENT_IDX + EXT4_EXTENT_IDX.ei_block] ;блПк слeЎующегП ОМЎекса + jb .end_search_index ;слеЎующОй Ўальше - зМачОт текущОй, тП чтП МаЌ МужеМ + + add ebp, sizeof.EXT4_EXTENT_IDX + dec ebx + jmp @B + + .end_search_index: + ;ebp указывает Ма МужМый extent_idx, счОтываеЌ слеЎующОй блПк + mov ebx, [ext2_data.ext2_temp_block] + mov eax, [ebp + EXT4_EXTENT_IDX.ei_leaf_lo] + call ext2_get_block + test eax, eax + jnz .fail + mov ebp, ebx + jmp ext4_block_recursive_search ;рекурсОвМП прыгаеЌ в МачалП + + .leaf_block: ;лОстПвПй блПк ebp - ext4_extent + ;цОкл пП экстеМтаЌ + @@: + test ebx, ebx + jz .fail ;МО ПЎОМ узел Ме пПЎПшел - ПшОбка + + mov edx, [ebp + EXT4_EXTENT.ee_block] + cmp ecx, edx + jb .fail ;еслО ЌеМьше, зМачОт ПМ был в преЎыЎущОх блПках -> ПшОбка + + movzx edi, [ebp + EXT4_EXTENT.ee_len] + add edx, edi + cmp ecx, edx + jb .end_search_extent ;МашлО МужМый блПк + + add ebp, sizeof.EXT4_EXTENT + dec ebx + jmp @B + + .end_search_extent: + mov edx, [ebp + EXT4_EXTENT.ee_start_lo] + sub ecx, [ebp + EXT4_EXTENT.ee_block] ;разМОца в ext4 блПках + add ecx, edx + xor eax, eax + ret + + .fail: + mov eax, ERROR_FS_FAIL + ret + +;=================================================================== +;пПлучает аЎрес ext2 блПка Оз inode с ПпреЎелММыЌ МПЌерПЌ +;in: ecx = МПЌер блПка в inode (0..) +; ebp = аЎрес inode +;out: ecx = аЎрес ПчереЎМПгП блПка +; eax - error code +ext2_get_inode_block: + test [ebp + EXT2_INODE_STRUC.i_flags], EXT2_EXTENTS_FL + jz @F + + pushad + add ebp, EXT2_INODE_STRUC.i_block ;ebp - extent_header + call ext4_block_recursive_search + mov PUSHAD_ECX, ecx + mov PUSHAD_EAX, eax + popad + ret + + @@: + cmp ecx, 12 ; 0..11 - direct block address + jb .get_direct_block + + sub ecx, 12 + cmp ecx, [ext2_data.count_pointer_in_block] ; 12.. - indirect blocks + jb .get_indirect_block + + sub ecx, [ext2_data.count_pointer_in_block] cmp ecx, [ext2_data.count_pointer_in_block_square] - jb .get_double_indirect_block - - sub ecx, [ext2_data.count_pointer_in_block_square] - ;triple indirect block - push edx ebx - - mov eax, [ebx + EXT2_INODE_STRUC.i_block + 14*4] - mov ebx, [ext2_data.ext2_temp_block] - call ext2_get_block - test eax, eax - jnz .fail - - xor edx, edx - mov eax, ecx + jb .get_double_indirect_block + + sub ecx, [ext2_data.count_pointer_in_block_square] + ;triple indirect block + push edx ebx + + mov eax, [ebx + EXT2_INODE_STRUC.i_block + 14*4] + mov ebx, [ext2_data.ext2_temp_block] + call ext2_get_block + test eax, eax + jnz .fail + + xor edx, edx + mov eax, ecx div [ext2_data.count_pointer_in_block_square] - ;eax - МПЌер в пПлучеММПЌ блПке edx - МПЌер Ўальше - mov eax, [ebx + eax*4] - call ext2_get_block - test eax, eax - jnz .fail - - mov eax, edx - jmp @F - - .get_double_indirect_block: - push edx ebx - - mov eax, [ebp + EXT2_INODE_STRUC.i_block + 13*4] - mov ebx, [ext2_data.ext2_temp_block] - call ext2_get_block - test eax, eax - jnz .fail - - mov eax, ecx - @@: - xor edx, edx - div [ext2_data.count_pointer_in_block] - - mov eax, [ebx + eax*4] - call ext2_get_block - test eax, eax - jnz .fail - - mov ecx, [ebx + edx*4] - .fail: - pop ebx edx - ret - - .get_indirect_block: - push ebx - mov eax, [ebp + EXT2_INODE_STRUC.i_block + 12*4] - mov ebx, [ext2_data.ext2_temp_block] - call ext2_get_block - test eax, eax - jz @F ;еслО Ме былП ПшОбкО - - mov ecx, [ebx + ecx*4] ;заМПсОЌ результат - @@: - pop ebx - ret - - .get_direct_block: - mov ecx, [ebp + EXT2_INODE_STRUC.i_block + ecx*4] - xor eax, eax - ret - -;=================================================================== -;get content inode by num -;in: eax = inode_num -; ebx = address of inode content -;out: eax - error code -ext2_get_inode: - pushad - mov edi, ebx ;сПхраМОЌ аЎрес inode - dec eax - xor edx, edx - - mov ecx, [ext2_data.sb] - div [ecx + EXT2_SB_STRUC.inodes_per_group] - - push edx ;locale num in group - + ;eax - МПЌер в пПлучеММПЌ блПке edx - МПЌер Ўальше + mov eax, [ebx + eax*4] + call ext2_get_block + test eax, eax + jnz .fail + + mov eax, edx + jmp @F + + .get_double_indirect_block: + push edx ebx + + mov eax, [ebp + EXT2_INODE_STRUC.i_block + 13*4] + mov ebx, [ext2_data.ext2_temp_block] + call ext2_get_block + test eax, eax + jnz .fail + + mov eax, ecx + @@: + xor edx, edx + div [ext2_data.count_pointer_in_block] + + mov eax, [ebx + eax*4] + call ext2_get_block + test eax, eax + jnz .fail + + mov ecx, [ebx + edx*4] + .fail: + pop ebx edx + ret + + .get_indirect_block: + push ebx + mov eax, [ebp + EXT2_INODE_STRUC.i_block + 12*4] + mov ebx, [ext2_data.ext2_temp_block] + call ext2_get_block + test eax, eax + jnz @F ;еслО Ме былП ПшОбкО + + mov ecx, [ebx + ecx*4] ;заМПсОЌ результат + @@: + pop ebx + ret + + .get_direct_block: + mov ecx, [ebp + EXT2_INODE_STRUC.i_block + ecx*4] + xor eax, eax + ret + +;=================================================================== +;get content inode by num +;in: eax = inode_num +; ebx = address of inode content +;out: eax - error code +ext2_get_inode: + pushad + mov edi, ebx ;сПхраМОЌ аЎрес inode + dec eax + xor edx, edx + + mov ecx, [ext2_data.sb] + div [ecx + EXT2_SB_STRUC.inodes_per_group] + + push edx ;locale num in group + mov edx, 32 mul edx ; address block_group in global_desc_table - - ; в eax - сЌещеМОе группы с inode-ПЌ ПтМПсОтельМП Мачала глПбальМПй ЎескрОптПрМПй таблОцы - ; МайЎеЌ блПк в кПтПрПЌ ПМ МахПЎОтся - div [ext2_data.block_size] - add eax, [ecx + EXT2_SB_STRUC.first_data_block] - inc eax - mov ebx, [ext2_data.ext2_temp_block] - call ext2_get_block - test eax, eax - jnz .fail - - add ebx, edx ; лПкальМый МПЌер в блПке - mov eax, [ebx + EXT2_BLOCK_GROUP_DESC.inode_table]; МПЌер блПка - в терЌОМах ext2 - - mov ecx, [ext2_data.log_block_size] - shl eax, cl - add eax, [PARTITION_START] ; а старт разЎела - в терЌОМах hdd (512) - - ;eax - указывает Ма таблОцу inode-Пв Ма hdd - mov esi, eax ;сПхраМОЌ егП пПка в esi + + ; в eax - сЌещеМОе группы с inode-ПЌ ПтМПсОтельМП Мачала глПбальМПй ЎескрОптПрМПй таблОцы + ; МайЎеЌ блПк в кПтПрПЌ ПМ МахПЎОтся + div [ext2_data.block_size] + add eax, [ecx + EXT2_SB_STRUC.first_data_block] + inc eax + mov ebx, [ext2_data.ext2_temp_block] + call ext2_get_block + test eax, eax + jnz .fail + + add ebx, edx ; лПкальМый МПЌер в блПке + mov eax, [ebx + EXT2_BLOCK_GROUP_DESC.inode_table]; МПЌер блПка - в терЌОМах ext2 + + mov ecx, [ext2_data.log_block_size] + shl eax, cl + add eax, [PARTITION_START] ; а старт разЎела - в терЌОМах hdd (512) + + ;eax - указывает Ма таблОцу inode-Пв Ма hdd + mov esi, eax ;сПхраМОЌ егП пПка в esi ; прОбавОЌ лПкальМый аЎрес inode-а pop eax ; index @@ -508,25 +508,25 @@ ext2_get_inode: mov ebp, 512 div ebp ;пПЎелОЌ Ма разЌер блПка - add eax, esi ;МашлО аЎрес блПка Ўля чтеМОя - mov ebx, [ext2_data.ext2_temp_block] - call hd_read - cmp [hd_error], 0 - jnz .fail - - mov esi, edx ;ЎПбавОЌ "ПстатПк" - add esi, ebx ;к аЎресу - rep movsb ;кПпОруеЌ inode - xor eax, eax - .fail: - mov PUSHAD_EAX, eax - popad - ret - -;---------------------------------------------------------------- -; -; ext2_HdReadFolder - read disk folder -; + add eax, esi ;МашлО аЎрес блПка Ўля чтеМОя + mov ebx, [ext2_data.ext2_temp_block] + call hd_read + cmp [hd_error], 0 + jnz .fail + + mov esi, edx ;ЎПбавОЌ "ПстатПк" + add esi, ebx ;к аЎресу + rep movsb ;кПпОруеЌ inode + xor eax, eax + .fail: + mov PUSHAD_EAX, eax + popad + ret + +;---------------------------------------------------------------- +; +; ext2_HdReadFolder - read disk folder +; ; esi points to filename ; ebx pointer to structure 32-bit number = first wanted block, 0+ ; & flags (bitfields) @@ -537,147 +537,147 @@ ext2_get_inode: ; ret ebx = blocks read or 0xffffffff folder not found ; eax = 0 ok read or other = errormsg ; -;-------------------------------------------------------------- -ext2_HdReadFolder: - cmp byte [esi], 0 - jz .root_folder - - push ebx ecx edx - call ext2_find_lfn ;верМет в ebp аЎрес inode - pop edx ecx ebx - test eax, eax - jnz .error_ret - test [ebp + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR - jz .error_not_found - jmp @F - - .root_folder: - mov ebp, [ext2_data.root_inode] - test [ebp + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR - jz .error_root - ;прОЎется кПпОрПвать inode - push ecx - mov esi, ebp - mov edi, [ext2_data.ext2_save_inode] - mov ecx, [ext2_data.inode_size] - shr ecx, 2 - mov ebp, edi - rep movsd - pop ecx - @@: - cmp [ebp + EXT2_INODE_STRUC.i_blocks], 0 ;папка пуста - je .error_empty_dir - - push edx ;аЎрес результата [edi + 28] - push 0 ;кПМец ПчереЎМПгП блПка папкО [edi + 24] - push ecx ;скПлькП файлПв МужМП прПчОтать [edi + 20] - push dword [ebx] ;первый "МужМый" файл [edi + 16] - push dword [ebx + 4];флагО [edi + 12] - push 0 ;[EXT2_read_in_folder] [edi + 8] - push 0 ;[EXT2_files_in_folder] [edi + 4] - push 0 ;МПЌер блПка пП пПряЎку [edi] - - mov edi, edx - mov ecx, 32/4 - rep stosd ; fill header zero - - mov edi, esp ; edi - указатель Ма лПкальМые переЌеММые - add edx, 32 ; edx = current mem for return - - xor ecx, ecx ; пПлучОЌ МПЌер первПгП блПка - call ext2_get_inode_block - test eax, eax - jnz .error_get_block - - mov eax, ecx - mov ebx, [ext2_data.ext2_save_block] - call ext2_get_block ; О счОтываеЌ блПк с hdd - test eax, eax - jnz .error_get_block - - mov esi, ebx ; esi = current dir record - add ebx, [ext2_data.block_size] - mov [edi + 24], ebx ; запПЌМОЌ кПМец ПчереЎМПгП блПка - - mov ecx, [edi + 16] ; ecx = first wanted (flags ommited) - - .find_wanted_start: - jecxz .find_wanted_end - .find_wanted_cycle: - cmp [esi + EXT2_DIR_STRUC.inode], 0 ; if (inode = 0) => not used - jz @F - inc dword [edi + 4] ; EXT2_files_in_folder - dec ecx - @@: - movzx ebx, [esi + EXT2_DIR_STRUC.rec_len] - - cmp ebx, 12 ; ЌОМОЌальМая ЎлОМа запОсО - jb .error_bad_len - test ebx, 0x3 ; ЎлОМа запОсО ЎПлжМа ЎелОться Ма 4 - jnz .error_bad_len - - add esi, ebx ; к слеЎующей запОсО - cmp esi, [edi + 24] ; сравМОваеЌ с кПМцПЌ блПка - jb .find_wanted_start - - push .find_wanted_start - .end_block: ;вылетелО Оз цОкла - mov ebx, [ext2_data.count_block_in_block] - sub [ebp + EXT2_INODE_STRUC.i_blocks], ebx ;вычОтаеЌ МапряЌую Оз структуры inode - jle .end_dir - - inc dword [edi] ;пПлучаеЌ МПвый блПк - push ecx - mov ecx, [edi] - call ext2_get_inode_block - test eax, eax - jnz .error_get_block - - mov eax, ecx - mov ebx, [ext2_data.ext2_save_block] - call ext2_get_block - test eax, eax - jnz .error_get_block - - pop ecx - mov esi, ebx - add ebx, [ext2_data.block_size] - mov [edi + 24], ebx ;запПЌМОЌ кПМец блПка - ret ; Ппять в цОкл - - .wanted_end: - loop .find_wanted_cycle ; ecx 0 => -1 МужМП пПсчОтать скПлькП файлПв - - ;ЎПшлО ЎП первПгП "МужМПгП" файла - .find_wanted_end: - mov ecx, [edi + 20] - .wanted_start: ; ОщеЌ first_wanted+count - jecxz .wanted_end - cmp [esi + EXT2_DIR_STRUC.inode], 0 ; if (inode = 0) => not used - jz .empty_rec - inc dword [edi + 8] - inc dword [edi + 4] - - push edi ecx - mov edi, edx ;ПбМуляеЌ ЌестП пПЎ ПчереМПе ОЌя файла/папкО - xor eax, eax - mov ecx, 40 / 4 - rep stosd - pop ecx edi - - push esi edi edx - mov eax, [esi + EXT2_DIR_STRUC.inode] ;пПлучОЌ ЎПчерМОй inode - mov ebx, [ext2_data.ext2_temp_inode] - call ext2_get_inode - test eax, eax - jnz .error_read_subinode - - lea edi, [edx + 8] - - mov eax, [ebx + EXT2_INODE_STRUC.i_ctime] ; перевеЎеЌ вреЌя в ntfs фПрЌат - xor edx, edx - add eax, 3054539008 ;(369 * 365 + 89) * 24 * 3600 - adc edx, 2 +;-------------------------------------------------------------- +ext2_HdReadFolder: + cmp byte [esi], 0 + jz .root_folder + + push ebx ecx edx + call ext2_find_lfn ;верМет в ebp аЎрес inode + pop edx ecx ebx + test eax, eax + jnz .error_ret + test [ebp + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR + jz .error_not_found + jmp @F + + .root_folder: + mov ebp, [ext2_data.root_inode] + test [ebp + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR + jz .error_root + ;прОЎется кПпОрПвать inode + push ecx + mov esi, ebp + mov edi, [ext2_data.ext2_save_inode] + mov ecx, [ext2_data.inode_size] + shr ecx, 2 + mov ebp, edi + rep movsd + pop ecx + @@: + cmp [ebp + EXT2_INODE_STRUC.i_blocks], 0 ;папка пуста + je .error_empty_dir + + push edx ;аЎрес результата [edi + 28] + push 0 ;кПМец ПчереЎМПгП блПка папкО [edi + 24] + push ecx ;скПлькП файлПв МужМП прПчОтать [edi + 20] + push dword [ebx] ;первый "МужМый" файл [edi + 16] + push dword [ebx + 4];флагО [edi + 12] + push 0 ;[EXT2_read_in_folder] [edi + 8] + push 0 ;[EXT2_files_in_folder] [edi + 4] + push 0 ;МПЌер блПка пП пПряЎку [edi] + + mov edi, edx + mov ecx, 32/4 + rep stosd ; fill header zero + + mov edi, esp ; edi - указатель Ма лПкальМые переЌеММые + add edx, 32 ; edx = current mem for return + + xor ecx, ecx ; пПлучОЌ МПЌер первПгП блПка + call ext2_get_inode_block + test eax, eax + jnz .error_get_block + + mov eax, ecx + mov ebx, [ext2_data.ext2_save_block] + call ext2_get_block ; О счОтываеЌ блПк с hdd + test eax, eax + jnz .error_get_block + + mov esi, ebx ; esi = current dir record + add ebx, [ext2_data.block_size] + mov [edi + 24], ebx ; запПЌМОЌ кПМец ПчереЎМПгП блПка + + mov ecx, [edi + 16] ; ecx = first wanted (flags ommited) + + .find_wanted_start: + jecxz .find_wanted_end + .find_wanted_cycle: + cmp [esi + EXT2_DIR_STRUC.inode], 0 ; if (inode = 0) => not used + jz @F + inc dword [edi + 4] ; EXT2_files_in_folder + dec ecx + @@: + movzx ebx, [esi + EXT2_DIR_STRUC.rec_len] + + cmp ebx, 12 ; ЌОМОЌальМая ЎлОМа запОсО + jb .error_bad_len + test ebx, 0x3 ; ЎлОМа запОсО ЎПлжМа ЎелОться Ма 4 + jnz .error_bad_len + + add esi, ebx ; к слеЎующей запОсО + cmp esi, [edi + 24] ; сравМОваеЌ с кПМцПЌ блПка + jb .find_wanted_start + + push .find_wanted_start + .end_block: ;вылетелО Оз цОкла + mov ebx, [ext2_data.count_block_in_block] + sub [ebp + EXT2_INODE_STRUC.i_blocks], ebx ;вычОтаеЌ МапряЌую Оз структуры inode + jle .end_dir + + inc dword [edi] ;пПлучаеЌ МПвый блПк + push ecx + mov ecx, [edi] + call ext2_get_inode_block + test eax, eax + jnz .error_get_block + + mov eax, ecx + mov ebx, [ext2_data.ext2_save_block] + call ext2_get_block + test eax, eax + jnz .error_get_block + + pop ecx + mov esi, ebx + add ebx, [ext2_data.block_size] + mov [edi + 24], ebx ;запПЌМОЌ кПМец блПка + ret ; Ппять в цОкл + + .wanted_end: + loop .find_wanted_cycle ; ecx 0 => -1 МужМП пПсчОтать скПлькП файлПв + + ;ЎПшлО ЎП первПгП "МужМПгП" файла + .find_wanted_end: + mov ecx, [edi + 20] + .wanted_start: ; ОщеЌ first_wanted+count + jecxz .wanted_end + cmp [esi + EXT2_DIR_STRUC.inode], 0 ; if (inode = 0) => not used + jz .empty_rec + inc dword [edi + 8] + inc dword [edi + 4] + + push edi ecx + mov edi, edx ;ПбМуляеЌ ЌестП пПЎ ПчереМПе ОЌя файла/папкО + xor eax, eax + mov ecx, 40 / 4 + rep stosd + pop ecx edi + + push esi edi edx + mov eax, [esi + EXT2_DIR_STRUC.inode] ;пПлучОЌ ЎПчерМОй inode + mov ebx, [ext2_data.ext2_temp_inode] + call ext2_get_inode + test eax, eax + jnz .error_read_subinode + + lea edi, [edx + 8] + + mov eax, [ebx + EXT2_INODE_STRUC.i_ctime] ; перевеЎеЌ вреЌя в ntfs фПрЌат + xor edx, edx + add eax, 3054539008 ;(369 * 365 + 89) * 24 * 3600 + adc edx, 2 call ntfs_datetime_to_bdfe.sec mov eax, [ebx + EXT2_INODE_STRUC.i_atime] @@ -690,94 +690,94 @@ ext2_HdReadFolder: xor edx, edx add eax, 3054539008 adc edx, 2 - call ntfs_datetime_to_bdfe.sec - - pop edx ; пПка ЎПстаеЌ тПлькП буфер - test [ebx + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR ; Ўля папкО разЌер - jnz @F ; Ме вПзвращаеЌ - - mov eax, [ebx + EXT2_INODE_STRUC.i_size] ;low size - stosd - mov eax, [ebx + EXT2_INODE_STRUC.i_dir_acl] ;high size - stosd - xor dword [edx], FS_FT_DIR ;пПЌечаеЌ, чтП этП файл(2 раза xor) - @@: - xor dword [edx], FS_FT_DIR ;пПЌечаеЌ, чтП этП файл - - ;теперь скПпОруеЌ ОЌя, скПМвертОрПвав Оз UTF-8 в CP866 - push ecx ;edi О esi уже сПхраМеМы в стеке - movzx ecx, [esi + EXT2_DIR_STRUC.name_len] - lea edi, [edx + 40] - lea esi, [esi + EXT2_DIR_STRUC.name] - call utf8_to_cp866 - and byte [edi], 0 - pop ecx edi esi - - cmp byte [edx + 40], '.' ; в linux файл, МачОМающОйся с тПчкО - скрытый - jne @F - or dword [edx], FS_FT_HIDDEN - @@: - - add edx, 40 + 264 ; go to next record - dec ecx ; еслО запОсь пустая ecx Ме МаЎП уЌеМьшать - .empty_rec: - movzx ebx, [esi + EXT2_DIR_STRUC.rec_len] - cmp ebx, 12 ; ЌОМОЌальМая ЎлОМа запОсО - jb .error_bad_len - test ebx, 0x3 ; ЎлОМа запОсО ЎПлжМа ЎелОться Ма 4 - jnz .error_bad_len - - add esi, ebx - cmp esi, [edi + 24] ;ЎПшлО лО ЎП кПМца блПка? - jb .wanted_start - - push .wanted_start ; ЎПшлО - jmp .end_block - - .end_dir: ;кПМец папкО, кПгЎа еще Ме ЎПшлО ЎП МужМПгП файла - mov edx, [edi + 28] ;аЎрес структуры результата - mov ebx, [edi + 8] ;EXT2_read_in_folder - mov ecx, [edi + 4] ;EXT2_files_in_folder - mov dword [edx], 1 ;version - mov [edx + 4], ebx - mov [edx + 8], ecx - - lea esp, [edi + 32] - - xor eax, eax ;зарезервОрПваМП: МулО в текущей реалОзацОО - lea edi, [edx + 12] - mov ecx, 20 / 4 - rep stosd - ret - - .error_bad_len: - mov eax, ERROR_FS_FAIL - .error_read_subinode: - .error_get_block: - lea esp, [edi + 32] - .error_ret: - or ebx, -1 - ret - - .error_empty_dir: ;inode папкО без блПкПв - .error_root: ;root - Ме папка - mov eax, ERROR_FS_FAIL - jmp .error_ret - - .error_not_found: ;файл Ме МайЎеМ - mov eax, ERROR_FILE_NOT_FOUND - jmp .error_ret - -;============================================ -;convert UTF-8 string to ASCII-string (codepage 866) -;in: ecx = length source -; esi = source -; edi = buffer -; destroys: eax,esi,edi -utf8_to_cp866: - jecxz .ret - .start: - lodsw + call ntfs_datetime_to_bdfe.sec + + pop edx ; пПка ЎПстаеЌ тПлькП буфер + test [ebx + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR ; Ўля папкО разЌер + jnz @F ; Ме вПзвращаеЌ + + mov eax, [ebx + EXT2_INODE_STRUC.i_size] ;low size + stosd + mov eax, [ebx + EXT2_INODE_STRUC.i_dir_acl] ;high size + stosd + xor dword [edx], FS_FT_DIR ;пПЌечаеЌ, чтП этП файл(2 раза xor) + @@: + xor dword [edx], FS_FT_DIR ;пПЌечаеЌ, чтП этП файл + + ;теперь скПпОруеЌ ОЌя, скПМвертОрПвав Оз UTF-8 в CP866 + push ecx ;edi О esi уже сПхраМеМы в стеке + movzx ecx, [esi + EXT2_DIR_STRUC.name_len] + lea edi, [edx + 40] + lea esi, [esi + EXT2_DIR_STRUC.name] + call utf8_to_cp866 + and byte [edi], 0 + pop ecx edi esi + + cmp byte [edx + 40], '.' ; в linux файл, МачОМающОйся с тПчкО - скрытый + jne @F + or dword [edx], FS_FT_HIDDEN + @@: + + add edx, 40 + 264 ; go to next record + dec ecx ; еслО запОсь пустая ecx Ме МаЎП уЌеМьшать + .empty_rec: + movzx ebx, [esi + EXT2_DIR_STRUC.rec_len] + cmp ebx, 12 ; ЌОМОЌальМая ЎлОМа запОсО + jb .error_bad_len + test ebx, 0x3 ; ЎлОМа запОсО ЎПлжМа ЎелОться Ма 4 + jnz .error_bad_len + + add esi, ebx + cmp esi, [edi + 24] ;ЎПшлО лО ЎП кПМца блПка? + jb .wanted_start + + push .wanted_start ; ЎПшлО + jmp .end_block + + .end_dir: ;кПМец папкО, кПгЎа еще Ме ЎПшлО ЎП МужМПгП файла + mov edx, [edi + 28] ;аЎрес структуры результата + mov ebx, [edi + 8] ;EXT2_read_in_folder + mov ecx, [edi + 4] ;EXT2_files_in_folder + mov dword [edx], 1 ;version + mov [edx + 4], ebx + mov [edx + 8], ecx + + lea esp, [edi + 32] + + xor eax, eax ;зарезервОрПваМП: МулО в текущей реалОзацОО + lea edi, [edx + 12] + mov ecx, 20 / 4 + rep stosd + ret + + .error_bad_len: + mov eax, ERROR_FS_FAIL + .error_read_subinode: + .error_get_block: + lea esp, [edi + 32] + .error_ret: + or ebx, -1 + ret + + .error_empty_dir: ;inode папкО без блПкПв + .error_root: ;root - Ме папка + mov eax, ERROR_FS_FAIL + jmp .error_ret + + .error_not_found: ;файл Ме МайЎеМ + mov eax, ERROR_FILE_NOT_FOUND + jmp .error_ret + +;============================================ +;convert UTF-8 string to ASCII-string (codepage 866) +;in: ecx = length source +; esi = source +; edi = buffer +; destroys: eax,esi,edi +utf8_to_cp866: + jecxz .ret + .start: + lodsw cmp al, 0x80 jb .ascii @@ -829,111 +829,109 @@ utf8_to_cp866: ; may be ebx=0 - start from first byte ; ecx number of bytes to read, 0+ ; edx mem location to return data -; -; ret ebx = bytes read or 0xffffffff file not found -; eax = 0 ok read or other = errormsg - -;-------------------------------------------------------------- -ext2_HdRead: - cmp byte [esi], 0 +; +; ret ebx = bytes read or 0xffffffff file not found +; eax = 0 ok read or other = errormsg + +;-------------------------------------------------------------- +ext2_HdRead: + cmp byte [esi], 0 jnz @F .this_is_nofile: or ebx, -1 mov eax, ERROR_ACCESS_DENIED - ret - - @@: - push ecx ebx edx - call ext2_find_lfn - pop edx ebx ecx - test eax, eax - jz @F - - or ebx, -1 - mov eax, ERROR_FILE_NOT_FOUND - ret - - @@: - mov ax, [ebp + EXT2_INODE_STRUC.i_mode] - and ax, EXT2_S_IFMT ;ПставляеЌ тПлькП тОп inode в ax - cmp ax, EXT2_S_IFREG - jne .this_is_nofile - - mov edi, edx ; edi = pointer to return mem - - test ebx, ebx - jz @F - mov esi, ebx ; esi = pointer to first_wanted - mov ebx, [esi+4] - mov eax, [esi] ; ebx : eax - стартПвый МПЌер байта - - ;///// сравМОЌ хватОт лО МаЌ файла ОлО Мет - cmp [ebp + EXT2_INODE_STRUC.i_dir_acl], ebx - ja .size_great - jb .size_less + ret + + @@: + push ecx ebx edx + call ext2_find_lfn + pop edx ebx ecx + test eax, eax + jz @F + + or ebx, -1 + mov eax, ERROR_FILE_NOT_FOUND + ret + + @@: + mov ax, [ebp + EXT2_INODE_STRUC.i_mode] + and ax, EXT2_S_IFMT ;ПставляеЌ тПлькП тОп inode в ax + cmp ax, EXT2_S_IFREG + jne .this_is_nofile + + mov edi, edx ; edi = pointer to return mem + + test ebx, ebx + jz @F + mov esi, ebx ; esi = pointer to first_wanted + mov ebx, [esi+4] + mov eax, [esi] ; ebx : eax - стартПвый МПЌер байта + + ;///// сравМОЌ хватОт лО МаЌ файла ОлО Мет + cmp [ebp + EXT2_INODE_STRUC.i_dir_acl], ebx + ja .size_great + jb .size_less cmp [ebp + EXT2_INODE_STRUC.i_size], eax ja .size_great .size_less: - xor ebx, ebx - mov eax, ERROR_END_OF_FILE - ret - - @@: - xor ebx, ebx - xor eax, eax - .size_great: - add eax, ecx ;add to first_wanted кПл-вП байт Ўля чтеМОя - adc ebx, 0 + xor ebx, ebx + mov eax, ERROR_END_OF_FILE + ret + + @@: + xor ebx, ebx + xor eax, eax + .size_great: + add eax, ecx ;add to first_wanted кПл-вП байт Ўля чтеМОя + adc ebx, 0 cmp [ebp + EXT2_INODE_STRUC.i_dir_acl], ebx - ja .size_great_great - jb .size_great_less - cmp [ebp + EXT2_INODE_STRUC.i_size], eax - jae .size_great_great - - .size_great_less: - push 1 -; or [EXT2_files_in_folder], 1 ;чОтаеЌ пП граМОце разЌера - mov ecx, [ebp + EXT2_INODE_STRUC.i_size] - sub ecx, [esi] ;(разЌер - старт) = скПлькП чОтать - jmp @F - - .size_great_great: - push 0 -; and [EXT2_files_in_folder], 0 ;чОтаеЌ стПлькП скПлькП запрПсОлО - - @@: - ;зЎесь Ќы тПчМП зМаеЌ скПлькП байт чОтать - ecx - ;edi - return memory - ;esi -> first wanted - - push ecx ;кПлОчествП счОтаММых байт - test esi, esi - jz .zero_start - - ;пПлучОЌ кусПк Оз первПгП блПка - mov edx, [esi+4] - mov eax, [esi] - div [ext2_data.block_size] - - push eax ;МПЌер блПка запПЌОМаеЌ - - push ecx - mov ecx, eax - call ext2_get_inode_block - test eax, eax - jnz .error_at_first_block - mov ebx, [ext2_data.ext2_save_block] - mov eax, ecx - call ext2_get_block - test eax, eax - jnz .error_at_first_block - pop ecx - add ebx, edx - + ja .size_great_great + jb .size_great_less + cmp [ebp + EXT2_INODE_STRUC.i_size], eax + jae .size_great_great + + .size_great_less: + push 1 ;чОтаеЌ пП граМОце разЌера + mov ecx, [ebp + EXT2_INODE_STRUC.i_size] + sub ecx, [esi] ;(разЌер - старт) = скПлькП чОтать + jmp @F + + .size_great_great: + push 0 ;чОтаеЌ стПлькП скПлькП запрПсОлО + + @@: + ;зЎесь Ќы тПчМП зМаеЌ скПлькП байт чОтать - ecx + ;edi - return memory + ;esi -> first wanted + + push ecx ;кПлОчествП счОтаММых байт + test esi, esi + jz .zero_start + + ;пПлучОЌ кусПк Оз первПгП блПка + mov edx, [esi+4] + mov eax, [esi] + div [ext2_data.block_size] + + push eax ;счетчОк блПкПв лПжОЌ в стек + + push ecx + mov ecx, eax + call ext2_get_inode_block + test eax, eax + jnz .error_at_first_block + mov ebx, [ext2_data.ext2_save_block] + mov eax, ecx + call ext2_get_block + test eax, eax + jnz .error_at_first_block + pop ecx + add ebx, edx + neg edx add edx, [ext2_data.block_size] ;block_size - стартПвый байт = скПлькП байт 1-гП блПка cmp ecx, edx @@ -942,255 +940,258 @@ ext2_HdRead: mov eax, ecx sub eax, edx mov ecx, edx - - mov esi, ebx - rep movsb ;кусПк 1-гП блПка - jmp .calc_blocks_count - - .zero_start: - mov eax, ecx - push 0 ;счетчОк блПкПв - ;теперь в eax кПл-вП ПставшОхся байт Ўля чтеМОя - .calc_blocks_count: - mov ebx, edi ;чтеМОе блПка пряЌ в ->ebx - xor edx, edx - div [ext2_data.block_size] ;кПл-вП байт в пПслеЎМеЌ блПке (ПстатПк) в edx - mov edi, eax ;кПл-вП целых блПкПв в edi - @@: - test edi, edi - jz .finish_block - inc dword [esp] - mov ecx, [esp] - call ext2_get_inode_block - test eax, eax - jnz .error_at_read_cycle - - mov eax, ecx ;а ebx уже забОт МужМыЌ зМачеМОеЌ - call ext2_get_block - test eax, eax - jnz .error_at_read_cycle - add ebx, [ext2_data.block_size] - - dec edi + + mov esi, ebx + rep movsb ;кусПк 1-гП блПка + jmp .calc_blocks_count + + .zero_start: + mov eax, ecx + push 0 ;счетчОк блПкПв лПжОЌ в стек + ;теперь в eax кПл-вП ПставшОхся байт Ўля чтеМОя + .calc_blocks_count: + mov ebx, edi ;чтеМОе блПка пряЌ в ->ebx + xor edx, edx + div [ext2_data.block_size] ;кПл-вП байт в пПслеЎМеЌ блПке (ПстатПк) в edx + mov edi, eax ;кПл-вП целых блПкПв в edi + @@: + test edi, edi + jz .finish_block + inc dword [esp] + mov ecx, [esp] + call ext2_get_inode_block + test eax, eax + jnz .error_at_read_cycle + + mov eax, ecx ;а ebx уже забОт МужМыЌ зМачеМОеЌ + call ext2_get_block + test eax, eax + jnz .error_at_read_cycle + add ebx, [ext2_data.block_size] + + dec edi jmp @B .finish_block: ;в edx - кПл-вП байт в пПслеЎМеЌ блПке - test edx, edx - jz .end_read - - pop ecx ;счетчОк блПкПв -> ecx - inc ecx - call ext2_get_inode_block - test eax, eax - jz .error_at_finish_block - - mov edi, ebx - mov eax, ecx - mov ebx, [ext2_data.ext2_save_block] - call ext2_get_block - test eax, eax - jnz .error_at_finish_block - - mov ecx, edx - mov esi, ebx - rep movsb ;кусПк last блПка - .end_read: - pop ebx - pop eax - test eax, eax - jz @F - - mov eax, ERROR_END_OF_FILE + test edx, edx + jz .end_read + + pop ecx ;счетчОк блПкПв -> ecx + inc ecx + call ext2_get_inode_block + test eax, eax + jnz .error_at_finish_block + + mov edi, ebx + mov eax, ecx + mov ebx, [ext2_data.ext2_save_block] + call ext2_get_block + test eax, eax + jnz .error_at_finish_block + + mov ecx, edx + mov esi, ebx + rep movsb ;кусПк last блПка + jmp @F + + .end_read: + pop ecx ;счетчОк блПкПв, кПтПрый храМОлся в стеке + @@: + pop ebx ;кПлОчествП счОтаММых байт + pop eax ; 1 ОлО 0 - ЎПстОглО лО кПМца файла + test eax, eax + jz @F + + mov eax, ERROR_END_OF_FILE ret - @@: - xor eax, eax - ret - - .only_one_block: - mov esi, ebx - rep movsb ;кусПк last блПка - pop eax - jmp .end_read - - .error_at_first_block: - pop edx - .error_at_read_cycle: - pop ebx - .error_at_finish_block: - pop ecx edx - or ebx, -1 - ret - -;---------------------------------------------------------------- -; in: esi = file path -; ebx = pointer to dir block -; out: esi - name without parent or not_changed -; ebx - dir_rec of inode children -ext2_test_block_by_name: - sub esp, 256 ;EXT2_filename - mov edx, ebx - add edx, [ext2_data.block_size] ;запПЌМОЌ кПМец блПка - - .start_rec: - cmp [ebx + EXT2_DIR_STRUC.inode], 0 - jz .next_rec - - mov edi, esp - push esi - movzx ecx, [ebx + EXT2_DIR_STRUC.name_len] - lea esi, [ebx + EXT2_DIR_STRUC.name] - call utf8_to_cp866 - - mov ecx, edi - lea edi, [esp + 4] - sub ecx, edi ;кПл-вП байт в пПлучОвшейся стрПке - - mov esi, [esp] - @@: - jecxz .test_find - dec ecx - - lodsb - call char_toupper - - mov ah, [edi] - inc edi - xchg al, ah - call char_toupper - cmp al, ah - je @B - @@: ;Ме пПЎПшлП - pop esi - .next_rec: - movzx eax, [ebx + EXT2_DIR_STRUC.rec_len] - add ebx, eax ;к слеЎ. запОсО - cmp ebx, edx ;прПверОЌ кПМец лО - jb .start_rec - add esp, 256 - ret - - .test_find: - cmp byte [esi], 0 - je .ret ;МашлО кПМец - cmp byte [esi], '/' - jne @B - inc esi - .ret: - add esp, 256 + 4 - ret - -;======================== -;Ищет inode пП стрПке путО -;in: esi = name -;out: eax - error code -; ebp = inode -; dl - первый байт Оз ОЌеМО файла/папкО -ext2_find_lfn: - mov ebp, [ext2_data.root_inode] - cmp [ebp + EXT2_INODE_STRUC.i_blocks], 0 - je .error_empty_root - - .next_path_part: - push [ebp + EXT2_INODE_STRUC.i_blocks] - xor ecx, ecx - .folder_block_cycle: - call ext2_get_inode_block - test eax, eax - jnz .error_get_inode_block - - mov eax, ecx - mov ebx, [ext2_data.ext2_save_block] ;ebx = cur dir record - call ext2_get_block - test eax, eax - jnz .error_get_block - - push esi - call ext2_test_block_by_name - pop edi - - cmp edi, esi ;МашлО ОЌя? - je .next_folder_block ;Ме МашлО -> к слеЎ. блПку - - cmp byte [esi], 0 ;ЎПшлО ЎП "кПМца" путО -> вПзваращаеЌся - jz .get_inode_ret - - cmp [ebx + EXT2_DIR_STRUC.file_type], EXT2_FT_DIR ;МашлО, МП этП Ме папка - jne .not_found - - mov eax, [ebx + EXT2_DIR_STRUC.inode] - mov ebx, [ext2_data.ext2_save_inode] ;все же папка. - call ext2_get_inode - test eax, eax - jnz .error_get_inode - pop ecx ;в стеке лежОт кПл-вП блПкПв - mov ebp, ebx - jmp .next_path_part - - .next_folder_block: - ;к слеЎующеЌу блПку в текущей папке - pop eax ;счетчОк блПкПв - sub eax, [ext2_data.count_block_in_block] - jle .not_found - - inc ecx - jmp .folder_block_cycle - - .not_found: - pop ebx - mov eax, ERROR_FILE_NOT_FOUND - ret - - .get_inode_ret: - pop ecx ;в стеке лежОт кПл-вП блПкПв - mov dl, [ebx + EXT2_DIR_STRUC.name] ;в dl - первый сОЌвПл () - mov eax, [ebx + EXT2_DIR_STRUC.inode] - mov ebx, [ext2_data.ext2_save_inode] - call ext2_get_inode - mov ebp, ebx - xor eax, eax - ret - - .error_get_inode_block: - .error_get_block: - .error_get_inode: - pop ebx - .error_empty_root: - mov eax, ERROR_FS_FAIL - ret - -;---------------------------------------------------------------- -;ext2_HdGetFileInfo - read file info from block device -; -;in: esi points to filename -; edx mem location to return data -;-------------------------------------------------------------- -ext2_HdGetFileInfo: - xchg bx, bx - cmp byte [esi], 0 - jz .is_root - - push edx - call ext2_find_lfn - mov ebx, edx - pop edx - test eax, eax - jz @F - ret - - .is_root: - xor ebx, ebx ;root Ме ЌПжет быть скрытыЌ - mov ebp, [ext2_data.root_inode] - @@: - xor eax, eax - mov edi, edx - mov ecx, 40/4 - rep stosd ; fill zero - - cmp bl, '.' - jne @F - or dword [edx], FS_FT_HIDDEN - @@: - + @@: + xor eax, eax + ret + + .only_one_block: + mov esi, ebx + rep movsb ;кусПк last блПка + jmp .end_read + + .error_at_first_block: + pop edx + .error_at_read_cycle: + pop ebx + .error_at_finish_block: + pop ecx edx + or ebx, -1 + ret + +;---------------------------------------------------------------- +; in: esi = file path +; ebx = pointer to dir block +; out: esi - name without parent or not_changed +; ebx - dir_rec of inode children +ext2_test_block_by_name: + sub esp, 256 ;EXT2_filename + mov edx, ebx + add edx, [ext2_data.block_size] ;запПЌМОЌ кПМец блПка + + .start_rec: + cmp [ebx + EXT2_DIR_STRUC.inode], 0 + jz .next_rec + + mov edi, esp + push esi + movzx ecx, [ebx + EXT2_DIR_STRUC.name_len] + lea esi, [ebx + EXT2_DIR_STRUC.name] + call utf8_to_cp866 + + mov ecx, edi + lea edi, [esp + 4] + sub ecx, edi ;кПл-вП байт в пПлучОвшейся стрПке + + mov esi, [esp] + @@: + jecxz .test_find + dec ecx + + lodsb + call char_toupper + + mov ah, [edi] + inc edi + xchg al, ah + call char_toupper + cmp al, ah + je @B + @@: ;Ме пПЎПшлП + pop esi + .next_rec: + movzx eax, [ebx + EXT2_DIR_STRUC.rec_len] + add ebx, eax ;к слеЎ. запОсО + cmp ebx, edx ;прПверОЌ кПМец лО + jb .start_rec + add esp, 256 + ret + + .test_find: + cmp byte [esi], 0 + je .ret ;МашлО кПМец + cmp byte [esi], '/' + jne @B + inc esi + .ret: + add esp, 256 + 4 + ret + +;======================== +;Ищет inode пП стрПке путО +;in: esi = name +;out: eax - error code +; ebp = inode +; dl - первый байт Оз ОЌеМО файла/папкО +ext2_find_lfn: + mov ebp, [ext2_data.root_inode] + cmp [ebp + EXT2_INODE_STRUC.i_blocks], 0 + je .error_empty_root + + .next_path_part: + push [ebp + EXT2_INODE_STRUC.i_blocks] + xor ecx, ecx + .folder_block_cycle: + call ext2_get_inode_block + test eax, eax + jnz .error_get_inode_block + + mov eax, ecx + mov ebx, [ext2_data.ext2_save_block] ;ebx = cur dir record + call ext2_get_block + test eax, eax + jnz .error_get_block + + push esi + call ext2_test_block_by_name + pop edi + + cmp edi, esi ;МашлО ОЌя? + je .next_folder_block ;Ме МашлО -> к слеЎ. блПку + + cmp byte [esi], 0 ;ЎПшлО ЎП "кПМца" путО -> вПзваращаеЌся + jz .get_inode_ret + + cmp [ebx + EXT2_DIR_STRUC.file_type], EXT2_FT_DIR ;МашлО, МП этП Ме папка + jne .not_found + + mov eax, [ebx + EXT2_DIR_STRUC.inode] + mov ebx, [ext2_data.ext2_save_inode] ;все же папка. + call ext2_get_inode + test eax, eax + jnz .error_get_inode + pop ecx ;в стеке лежОт кПл-вП блПкПв + mov ebp, ebx + jmp .next_path_part + + .next_folder_block: + ;к слеЎующеЌу блПку в текущей папке + pop eax ;счетчОк блПкПв + sub eax, [ext2_data.count_block_in_block] + jle .not_found + + push eax + inc ecx + jmp .folder_block_cycle + + .not_found: + mov eax, ERROR_FILE_NOT_FOUND + ret + + .get_inode_ret: + pop ecx ;в стеке лежОт кПл-вП блПкПв + mov dl, [ebx + EXT2_DIR_STRUC.name] ;в dl - первый сОЌвПл () + mov eax, [ebx + EXT2_DIR_STRUC.inode] + mov ebx, [ext2_data.ext2_save_inode] + call ext2_get_inode + mov ebp, ebx + xor eax, eax + ret + + .error_get_inode_block: + .error_get_block: + .error_get_inode: + pop ebx + .error_empty_root: + mov eax, ERROR_FS_FAIL + ret + +;---------------------------------------------------------------- +;ext2_HdGetFileInfo - read file info from block device +; +;in: esi points to filename +; edx mem location to return data +;-------------------------------------------------------------- +ext2_HdGetFileInfo: + xchg bx, bx + cmp byte [esi], 0 + jz .is_root + + push edx + call ext2_find_lfn + mov ebx, edx + pop edx + test eax, eax + jz @F + ret + + .is_root: + xor ebx, ebx ;root Ме ЌПжет быть скрытыЌ + mov ebp, [ext2_data.root_inode] + @@: + xor eax, eax + mov edi, edx + mov ecx, 40/4 + rep stosd ; fill zero + + cmp bl, '.' + jne @F + or dword [edx], FS_FT_HIDDEN + @@: + test [ebp + EXT2_INODE_STRUC.i_mode], EXT2_S_IFDIR jnz @F mov eax, [ebp + EXT2_INODE_STRUC.i_size] ;low size @@ -1199,25 +1200,25 @@ ext2_HdGetFileInfo: mov dword [edx+36], ebx xor dword [edx], FS_FT_DIR @@: - xor dword [edx], FS_FT_DIR - - lea edi, [edx + 8] - mov eax, [ebp + EXT2_INODE_STRUC.i_ctime] - xor edx, edx - add eax, 3054539008 - adc edx, 2 - call ntfs_datetime_to_bdfe.sec - - mov eax, [ebp + EXT2_INODE_STRUC.i_atime] - xor edx, edx - add eax, 3054539008 - adc edx, 2 - call ntfs_datetime_to_bdfe.sec - - mov eax, [ebp + EXT2_INODE_STRUC.i_mtime] - xor edx, edx - add eax, 3054539008 - adc edx, 2 + xor dword [edx], FS_FT_DIR + + lea edi, [edx + 8] + mov eax, [ebp + EXT2_INODE_STRUC.i_ctime] + xor edx, edx + add eax, 3054539008 + adc edx, 2 + call ntfs_datetime_to_bdfe.sec + + mov eax, [ebp + EXT2_INODE_STRUC.i_atime] + xor edx, edx + add eax, 3054539008 + adc edx, 2 + call ntfs_datetime_to_bdfe.sec + + mov eax, [ebp + EXT2_INODE_STRUC.i_mtime] + xor edx, edx + add eax, 3054539008 + adc edx, 2 call ntfs_datetime_to_bdfe.sec xor eax, eax @@ -1229,6 +1230,6 @@ ext2_HdSetFileEnd: ext2_HdSetFileInfo: ext2_HdDelete: ext2_HdCreateFolder: - xor ebx, ebx - mov eax, ERROR_UNSUPPORTED_FS - ret + xor ebx, ebx + mov eax, ERROR_UNSUPPORTED_FS + ret diff --git a/kernel/branches/net/fs/fat12.inc b/kernel/branches/net/fs/fat12.inc index c7152794e7..7dfd65d9d8 100644 --- a/kernel/branches/net/fs/fat12.inc +++ b/kernel/branches/net/fs/fat12.inc @@ -631,40 +631,40 @@ found_file_analyze_flp: ; \begin{diamond} fat_find_lfn: ; in: esi->name -; [esp+4] = next -; [esp+8] = first -; [esp+C]... - possibly parameters for first and next -; out: CF=1 - file not found, eax=error code -; else CF=0, esi->next name component, edi->direntry - pusha - lea eax, [esp+0Ch+20h] - call dword [eax-4] - jc .reterr - sub esp, 262*2 ; reserve place for LFN - push 0 ; for fat_get_name: read ASCII name -.l1: - lea ebp, [esp+4] - call fat_get_name - jc .l2 - call fat_compare_name - jz .found -.l2: - mov ebp, [esp+8+262*2+4] - lea eax, [esp+0Ch+20h+262*2+4] - call dword [eax-8] - jnc .l1 - add esp, 262*2+4 -.reterr: - mov [esp+28], eax - stc - popa - ret -.found: - add esp, 262*2+4 - mov ebp, [esp+8] -; if this is LFN entry, advance to true entry - cmp byte [edi+11], 0xF - jnz @f +; [esp+4] = next +; [esp+8] = first +; [esp+C]... - possibly parameters for first and next +; out: CF=1 - file not found, eax=error code +; else CF=0, esi->next name component, edi->direntry + pusha + lea eax, [esp+0Ch+20h] + call dword [eax-4] + jc .reterr + sub esp, 262*2 ; reserve place for LFN + push 0 ; for fat_get_name: read ASCII name +.l1: + lea ebp, [esp+4] + call fat_get_name + jc .l2 + call fat_compare_name + jz .found +.l2: + mov ebp, [esp+8+262*2+4] + lea eax, [esp+0Ch+20h+262*2+4] + call dword [eax-8] + jnc .l1 + add esp, 262*2+4 +.reterr: + mov [esp+28], eax + stc + popa + ret +.found: + add esp, 262*2+4 + mov ebp, [esp+8] +; if this is LFN entry, advance to true entry + cmp byte [edi+11], 0xF + jnz @f lea eax, [esp+0Ch+20h] call dword [eax-8] jc .reterr diff --git a/kernel/branches/net/fs/fat32.inc b/kernel/branches/net/fs/fat32.inc index 644a3080ae..73b371df14 100644 --- a/kernel/branches/net/fs/fat32.inc +++ b/kernel/branches/net/fs/fat32.inc @@ -46,444 +46,444 @@ $Revision $ - -cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00 - -PUSHAD_EAX equ [esp+28] -PUSHAD_ECX equ [esp+24] -PUSHAD_EDX equ [esp+20] + +cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00 + +PUSHAD_EAX equ [esp+28] +PUSHAD_ECX equ [esp+24] +PUSHAD_EDX equ [esp+20] PUSHAD_EBX equ [esp+16] PUSHAD_EBP equ [esp+8] -PUSHAD_ESI equ [esp+4] -PUSHAD_EDI equ [esp+0] - -; Internal data for every FAT partition. -struct FAT -p PARTITION ; must be the first item -fs_type db ? -fat16_root db 0 ; flag for fat16 rootdir -fat_change db 0 ; 1=fat has changed - db ? ; alignment -Lock MUTEX ? ; currently operations with one partition - ; can not be executed in parallel since the - ; legacy code is not ready; this mutex guards - ; all operations -SECTORS_PER_FAT dd 0x1f3a -NUMBER_OF_FATS dd 0x2 -SECTORS_PER_CLUSTER dd 0x8 -BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes -ROOT_CLUSTER dd 2 ; first rootdir cluster -FAT_START dd 0 ; start of fat table -ROOT_START dd 0 ; start of rootdir (only fat16) -ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16) -DATA_START dd 0 ; start of data area (=first cluster 2) -LAST_CLUSTER dd 0 ; last availabe cluster -ADR_FSINFO dd 0 ; used only by fat32 - -fatRESERVED dd 0x0FFFFFF6 -fatBAD dd 0x0FFFFFF7 -fatEND dd 0x0FFFFFF8 -fatMASK dd 0x0FFFFFFF - -fatStartScan dd 2 - -cluster_tmp dd 0 ; used by analyze_directory - ; and analyze_directory_to_write - -longname_sec1 dd 0 ; used by analyze_directory to save 2 previous -longname_sec2 dd 0 ; directory sectors for delete long filename - -fat_in_cache dd -1 - -fat_cache rb 512 -buffer rb 512 -fsinfo_buffer rb 512 -ends - -uglobal -align 4 -partition_count dd 0 ; partitions found by set_FAT32_variables - -hd_error dd 0 ; set by wait_for_sector_buffer -hd_setup dd 0 -hd_wait_timeout dd 0 - -cache_search_start dd 0 ; used by find_empty_slot -endg - -uglobal -align 4 - Sector512: ; label for dev_hdcd.inc - buffer: - times 512 db 0 -endg - -iglobal -align 4 -fat_user_functions: - dd (fat_user_functions_end - fat_user_functions - 4) / 4 - dd fat_Read - dd fat_ReadFolder - dd fat_Rewrite - dd fat_Write - dd fat_SetFileEnd - dd fat_GetFileInfo - dd fat_SetFileInfo - dd 0 - dd fat_Delete - dd fat_CreateFolder -fat_user_functions_end: -endg - -; these labels are located before the main function to make -; most of jumps to these be short -fat_create_partition.free_return0: - push ebx - mov eax, ebp - call free - pop ebx - pop ebp -fat_create_partition.return0: - xor eax, eax - ret -fat_create_partition: -; bootsector must have been successfully read - cmp dword [esp+4], 1 - jnz .return0 -; bootsector signature must be correct - cmp word [ebx+0x1fe], 0xaa55 - jnz .return0 -; sectors per cluster must be nonzero - cmp byte [ebx+0xd], 0 - jz .return0 -; bytes per sector must be 0x200 - cmp word [ebx+0xb], 0x200 - jnz .return0 -; number of fats must be nonzero - cmp byte [ebx+0x10], 0 - jz .return0 -; The only reason to be invalid partition now is FAT12. Since the test for -; FAT size requires knowledge of some calculated values, which are also used -; in the normal operation, let's hope for the best and allocate data now; if -; it will prove wrong, just deallocate it. - push ebx - push sizeof.FAT - pop eax - call malloc - pop ebx - test eax, eax - jz .return0 - mov ecx, [ebp+8] - mov dword [eax+FAT.p.FirstSector], ecx - mov ecx, [ebp+12] - mov dword [eax+FAT.p.FirstSector+4], ecx - mov ecx, [ebp+16] - mov dword [eax+FAT.p.Length], ecx - mov ecx, [ebp+20] - mov dword [eax+FAT.p.Length+4], ecx - mov [eax+FAT.p.Disk], esi - mov [eax+FAT.p.FSUserFunctions], fat_user_functions - or [eax+FAT.fat_in_cache], -1 - mov [eax+FAT.fat_change], 0 - push ebp - mov ebp, eax - - lea ecx, [ebp+FAT.Lock] - call mutex_init - - movzx eax, word [ebx+0xe] ; sectors reserved - mov [ebp+FAT.FAT_START], eax - - movzx eax, byte [ebx+0xd] ; sectors per cluster - mov [ebp+FAT.SECTORS_PER_CLUSTER], eax - - movzx ecx, word [ebx+0xb] ; bytes per sector - mov [ebp+FAT.BYTES_PER_SECTOR], ecx - - movzx eax, word [ebx+0x11] ; count of rootdir entries (=0 fat32) - shl eax, 5 ; mul 32 - dec ecx - add eax, ecx ; round up if not equal count - inc ecx ; bytes per sector - xor edx, edx - div ecx - mov [ebp+FAT.ROOT_SECTORS], eax ; count of rootdir sectors - - movzx eax, word [ebx+0x16] ; sectors per fat <65536 - test eax, eax - jnz @f - mov eax, [ebx+0x24] ; sectors per fat -@@: - mov [ebp+FAT.SECTORS_PER_FAT], eax - - movzx eax, byte [ebx+0x10] ; number of fats - mov [ebp+FAT.NUMBER_OF_FATS], eax - imul eax, [ebp+FAT.SECTORS_PER_FAT] - add eax, [ebp+FAT.FAT_START] - mov [ebp+FAT.ROOT_START], eax ; rootdir = fat_start + fat_size * fat_count - add eax, [ebp+FAT.ROOT_SECTORS] ; rootdir sectors should be 0 on fat32 - mov [ebp+FAT.DATA_START], eax ; data area = rootdir + rootdir_size - - movzx eax, word [ebx+0x13] ; total sector count <65536 - test eax, eax - jnz @f - mov eax, [ebx+0x20] ; total sector count -@@: - mov dword [ebp+FAT.p.Length], eax - and dword [ebp+FAT.p.Length+4], 0 - sub eax, [ebp+FAT.DATA_START] ; eax = count of data sectors - xor edx, edx - div [ebp+FAT.SECTORS_PER_CLUSTER] - inc eax - mov [ebp+FAT.LAST_CLUSTER], eax - dec eax ; cluster count - mov [ebp+FAT.fatStartScan], 2 - - ; limits by Microsoft Hardware White Paper v1.03 - cmp eax, 4085 ; 0xff5 - jb .free_return0 ; fat12 not supported - cmp eax, 65525 ; 0xfff5 - jb .fat16 -.fat32: - mov eax, [ebx+0x2c] ; rootdir cluster - mov [ebp+FAT.ROOT_CLUSTER], eax - movzx eax, word [ebx+0x30] - mov [ebp+FAT.ADR_FSINFO], eax - push ebx - add ebx, 512 - call fs_read32_sys - test eax, eax - jnz @f - mov eax, [ebx+0x1ec] - cmp eax, -1 - jz @f - mov [ebp+FAT.fatStartScan], eax -@@: - pop ebx - mov [ebp+FAT.fatRESERVED], 0x0FFFFFF6 - mov [ebp+FAT.fatBAD], 0x0FFFFFF7 - mov [ebp+FAT.fatEND], 0x0FFFFFF8 - mov [ebp+FAT.fatMASK], 0x0FFFFFFF - mov al, 32 - mov [fs_type], al - mov [ebp+FAT.fs_type], al - mov eax, ebp - pop ebp - ret -.fat16: - and [ebp+FAT.ROOT_CLUSTER], 0 - mov [ebp+FAT.fatRESERVED], 0x0000FFF6 - mov [ebp+FAT.fatBAD], 0x0000FFF7 - mov [ebp+FAT.fatEND], 0x0000FFF8 - mov [ebp+FAT.fatMASK], 0x0000FFFF - mov al, 16 - mov [fs_type], al - mov [ebp+FAT.fs_type], al - mov eax, ebp - pop ebp - ret - -set_FAT: -;-------------------------------- -; input : EAX = cluster -; EDX = value to save -; EBP = pointer to FAT structure -; output : EDX = old value -;-------------------------------- -; out: CF set <=> error - push eax ebx esi - - cmp eax, 2 - jb sfc_error - cmp eax, [ebp+FAT.LAST_CLUSTER] - ja sfc_error - cmp [ebp+FAT.fs_type], 16 - je sfc_1 - add eax, eax - sfc_1: +PUSHAD_ESI equ [esp+4] +PUSHAD_EDI equ [esp+0] + +; Internal data for every FAT partition. +struct FAT +p PARTITION ; must be the first item +fs_type db ? +fat16_root db 0 ; flag for fat16 rootdir +fat_change db 0 ; 1=fat has changed + db ? ; alignment +Lock MUTEX ? ; currently operations with one partition + ; can not be executed in parallel since the + ; legacy code is not ready; this mutex guards + ; all operations +SECTORS_PER_FAT dd 0x1f3a +NUMBER_OF_FATS dd 0x2 +SECTORS_PER_CLUSTER dd 0x8 +BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes +ROOT_CLUSTER dd 2 ; first rootdir cluster +FAT_START dd 0 ; start of fat table +ROOT_START dd 0 ; start of rootdir (only fat16) +ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16) +DATA_START dd 0 ; start of data area (=first cluster 2) +LAST_CLUSTER dd 0 ; last availabe cluster +ADR_FSINFO dd 0 ; used only by fat32 + +fatRESERVED dd 0x0FFFFFF6 +fatBAD dd 0x0FFFFFF7 +fatEND dd 0x0FFFFFF8 +fatMASK dd 0x0FFFFFFF + +fatStartScan dd 2 + +cluster_tmp dd 0 ; used by analyze_directory + ; and analyze_directory_to_write + +longname_sec1 dd 0 ; used by analyze_directory to save 2 previous +longname_sec2 dd 0 ; directory sectors for delete long filename + +fat_in_cache dd -1 + +fat_cache rb 512 +buffer rb 512 +fsinfo_buffer rb 512 +ends + +uglobal +align 4 +partition_count dd 0 ; partitions found by set_FAT32_variables + +hd_error dd 0 ; set by wait_for_sector_buffer +hd_setup dd 0 +hd_wait_timeout dd 0 + +cache_search_start dd 0 ; used by find_empty_slot +endg + +uglobal +align 4 + Sector512: ; label for dev_hdcd.inc + buffer: + times 512 db 0 +endg + +iglobal +align 4 +fat_user_functions: + dd (fat_user_functions_end - fat_user_functions - 4) / 4 + dd fat_Read + dd fat_ReadFolder + dd fat_Rewrite + dd fat_Write + dd fat_SetFileEnd + dd fat_GetFileInfo + dd fat_SetFileInfo + dd 0 + dd fat_Delete + dd fat_CreateFolder +fat_user_functions_end: +endg + +; these labels are located before the main function to make +; most of jumps to these be short +fat_create_partition.free_return0: + push ebx + mov eax, ebp + call free + pop ebx + pop ebp +fat_create_partition.return0: + xor eax, eax + ret +fat_create_partition: +; bootsector must have been successfully read + cmp dword [esp+4], 1 + jnz .return0 +; bootsector signature must be correct + cmp word [ebx+0x1fe], 0xaa55 + jnz .return0 +; sectors per cluster must be nonzero + cmp byte [ebx+0xd], 0 + jz .return0 +; bytes per sector must be 0x200 + cmp word [ebx+0xb], 0x200 + jnz .return0 +; number of fats must be nonzero + cmp byte [ebx+0x10], 0 + jz .return0 +; The only reason to be invalid partition now is FAT12. Since the test for +; FAT size requires knowledge of some calculated values, which are also used +; in the normal operation, let's hope for the best and allocate data now; if +; it will prove wrong, just deallocate it. + push ebx + push sizeof.FAT + pop eax + call malloc + pop ebx + test eax, eax + jz .return0 + mov ecx, [ebp+8] + mov dword [eax+FAT.p.FirstSector], ecx + mov ecx, [ebp+12] + mov dword [eax+FAT.p.FirstSector+4], ecx + mov ecx, [ebp+16] + mov dword [eax+FAT.p.Length], ecx + mov ecx, [ebp+20] + mov dword [eax+FAT.p.Length+4], ecx + mov [eax+FAT.p.Disk], esi + mov [eax+FAT.p.FSUserFunctions], fat_user_functions + or [eax+FAT.fat_in_cache], -1 + mov [eax+FAT.fat_change], 0 + push ebp + mov ebp, eax + + lea ecx, [ebp+FAT.Lock] + call mutex_init + + movzx eax, word [ebx+0xe] ; sectors reserved + mov [ebp+FAT.FAT_START], eax + + movzx eax, byte [ebx+0xd] ; sectors per cluster + mov [ebp+FAT.SECTORS_PER_CLUSTER], eax + + movzx ecx, word [ebx+0xb] ; bytes per sector + mov [ebp+FAT.BYTES_PER_SECTOR], ecx + + movzx eax, word [ebx+0x11] ; count of rootdir entries (=0 fat32) + shl eax, 5 ; mul 32 + dec ecx + add eax, ecx ; round up if not equal count + inc ecx ; bytes per sector + xor edx, edx + div ecx + mov [ebp+FAT.ROOT_SECTORS], eax ; count of rootdir sectors + + movzx eax, word [ebx+0x16] ; sectors per fat <65536 + test eax, eax + jnz @f + mov eax, [ebx+0x24] ; sectors per fat +@@: + mov [ebp+FAT.SECTORS_PER_FAT], eax + + movzx eax, byte [ebx+0x10] ; number of fats + mov [ebp+FAT.NUMBER_OF_FATS], eax + imul eax, [ebp+FAT.SECTORS_PER_FAT] + add eax, [ebp+FAT.FAT_START] + mov [ebp+FAT.ROOT_START], eax ; rootdir = fat_start + fat_size * fat_count + add eax, [ebp+FAT.ROOT_SECTORS] ; rootdir sectors should be 0 on fat32 + mov [ebp+FAT.DATA_START], eax ; data area = rootdir + rootdir_size + + movzx eax, word [ebx+0x13] ; total sector count <65536 + test eax, eax + jnz @f + mov eax, [ebx+0x20] ; total sector count +@@: + mov dword [ebp+FAT.p.Length], eax + and dword [ebp+FAT.p.Length+4], 0 + sub eax, [ebp+FAT.DATA_START] ; eax = count of data sectors + xor edx, edx + div [ebp+FAT.SECTORS_PER_CLUSTER] + inc eax + mov [ebp+FAT.LAST_CLUSTER], eax + dec eax ; cluster count + mov [ebp+FAT.fatStartScan], 2 + + ; limits by Microsoft Hardware White Paper v1.03 + cmp eax, 4085 ; 0xff5 + jb .free_return0 ; fat12 not supported + cmp eax, 65525 ; 0xfff5 + jb .fat16 +.fat32: + mov eax, [ebx+0x2c] ; rootdir cluster + mov [ebp+FAT.ROOT_CLUSTER], eax + movzx eax, word [ebx+0x30] + mov [ebp+FAT.ADR_FSINFO], eax + push ebx + add ebx, 512 + call fs_read32_sys + test eax, eax + jnz @f + mov eax, [ebx+0x1ec] + cmp eax, -1 + jz @f + mov [ebp+FAT.fatStartScan], eax +@@: + pop ebx + mov [ebp+FAT.fatRESERVED], 0x0FFFFFF6 + mov [ebp+FAT.fatBAD], 0x0FFFFFF7 + mov [ebp+FAT.fatEND], 0x0FFFFFF8 + mov [ebp+FAT.fatMASK], 0x0FFFFFFF + mov al, 32 + mov [fs_type], al + mov [ebp+FAT.fs_type], al + mov eax, ebp + pop ebp + ret +.fat16: + and [ebp+FAT.ROOT_CLUSTER], 0 + mov [ebp+FAT.fatRESERVED], 0x0000FFF6 + mov [ebp+FAT.fatBAD], 0x0000FFF7 + mov [ebp+FAT.fatEND], 0x0000FFF8 + mov [ebp+FAT.fatMASK], 0x0000FFFF + mov al, 16 + mov [fs_type], al + mov [ebp+FAT.fs_type], al + mov eax, ebp + pop ebp + ret + +set_FAT: +;-------------------------------- +; input : EAX = cluster +; EDX = value to save +; EBP = pointer to FAT structure +; output : EDX = old value +;-------------------------------- +; out: CF set <=> error + push eax ebx esi + + cmp eax, 2 + jb sfc_error + cmp eax, [ebp+FAT.LAST_CLUSTER] + ja sfc_error + cmp [ebp+FAT.fs_type], 16 + je sfc_1 add eax, eax - mov esi, 511 - and esi, eax ; esi = position in fat sector - shr eax, 9 ; eax = fat sector - add eax, [ebp+FAT.FAT_START] - lea ebx, [ebp+FAT.fat_cache] - - cmp eax, [ebp+FAT.fat_in_cache]; is fat sector already in memory? - je sfc_in_cache ; yes - - cmp [ebp+FAT.fat_change], 0; is fat changed? - je sfc_no_change ; no - call write_fat_sector; yes. write it into disk - jc sfc_error - - sfc_no_change: - mov [ebp+FAT.fat_in_cache], eax; save fat sector - call fs_read32_sys - test eax, eax - jne sfc_error - - - sfc_in_cache: - cmp [ebp+FAT.fs_type], 16 - jne sfc_test32 - - sfc_set16: + sfc_1: + add eax, eax + mov esi, 511 + and esi, eax ; esi = position in fat sector + shr eax, 9 ; eax = fat sector + add eax, [ebp+FAT.FAT_START] + lea ebx, [ebp+FAT.fat_cache] + + cmp eax, [ebp+FAT.fat_in_cache]; is fat sector already in memory? + je sfc_in_cache ; yes + + cmp [ebp+FAT.fat_change], 0; is fat changed? + je sfc_no_change ; no + call write_fat_sector; yes. write it into disk + jc sfc_error + + sfc_no_change: + mov [ebp+FAT.fat_in_cache], eax; save fat sector + call fs_read32_sys + test eax, eax + jne sfc_error + + + sfc_in_cache: + cmp [ebp+FAT.fs_type], 16 + jne sfc_test32 + + sfc_set16: xchg [ebx+esi], dx ; save new value and get old value - jmp sfc_write - - sfc_test32: - mov eax, [ebp+FAT.fatMASK] - - sfc_set32: - and edx, eax + jmp sfc_write + + sfc_test32: + mov eax, [ebp+FAT.fatMASK] + + sfc_set32: + and edx, eax xor eax, -1 ; mask for high bits and eax, [ebx+esi] ; get high 4 bits or eax, edx mov edx, [ebx+esi] ; get old value - mov [ebx+esi], eax ; save new value - - sfc_write: - mov [ebp+FAT.fat_change], 1; fat has changed - - sfc_nonzero: - and edx, [ebp+FAT.fatMASK] - - sfc_return: - pop esi ebx eax - ret - sfc_error: - stc - jmp sfc_return - - -get_FAT: -;-------------------------------- -; input : EAX = cluster -; EBP = pointer to FAT structure -; output : EAX = next cluster -;-------------------------------- -; out: CF set <=> error - push ebx esi - - cmp [ebp+FAT.fs_type], 16 - je gfc_1 - add eax, eax - gfc_1: + mov [ebx+esi], eax ; save new value + + sfc_write: + mov [ebp+FAT.fat_change], 1; fat has changed + + sfc_nonzero: + and edx, [ebp+FAT.fatMASK] + + sfc_return: + pop esi ebx eax + ret + sfc_error: + stc + jmp sfc_return + + +get_FAT: +;-------------------------------- +; input : EAX = cluster +; EBP = pointer to FAT structure +; output : EAX = next cluster +;-------------------------------- +; out: CF set <=> error + push ebx esi + + cmp [ebp+FAT.fs_type], 16 + je gfc_1 add eax, eax - mov esi, 511 - and esi, eax ; esi = position in fat sector - shr eax, 9 ; eax = fat sector - add eax, [ebp+FAT.FAT_START] - lea ebx, [ebp+FAT.fat_cache] - - cmp eax, [ebp+FAT.fat_in_cache]; is fat sector already in memory? - je gfc_in_cache - - cmp [ebp+FAT.fat_change], 0; is fat changed? - je gfc_no_change ; no - call write_fat_sector; yes. write it into disk - jc hd_error_01 - - gfc_no_change: - mov [ebp+FAT.fat_in_cache], eax - call fs_read32_sys - test eax, eax - jne hd_error_01 - - gfc_in_cache: - mov eax, [ebx+esi] - and eax, [ebp+FAT.fatMASK] - gfc_return: - pop esi ebx - ret - hd_error_01: - stc - jmp gfc_return - - -get_free_FAT: + gfc_1: + add eax, eax + mov esi, 511 + and esi, eax ; esi = position in fat sector + shr eax, 9 ; eax = fat sector + add eax, [ebp+FAT.FAT_START] + lea ebx, [ebp+FAT.fat_cache] + + cmp eax, [ebp+FAT.fat_in_cache]; is fat sector already in memory? + je gfc_in_cache + + cmp [ebp+FAT.fat_change], 0; is fat changed? + je gfc_no_change ; no + call write_fat_sector; yes. write it into disk + jc hd_error_01 + + gfc_no_change: + mov [ebp+FAT.fat_in_cache], eax + call fs_read32_sys + test eax, eax + jne hd_error_01 + + gfc_in_cache: + mov eax, [ebx+esi] + and eax, [ebp+FAT.fatMASK] + gfc_return: + pop esi ebx + ret + hd_error_01: + stc + jmp gfc_return + + +get_free_FAT: ;----------------------------------------------------------- ; output : if CARRY=0 EAX = # first cluster found free ; if CARRY=1 disk full -; Note : for more speed need to use fat_cache directly -;----------------------------------------------------------- - push ecx - mov ecx, [ebp+FAT.LAST_CLUSTER]; counter for full disk - sub ecx, 2 - mov eax, [ebp+FAT.fatStartScan] - cmp eax, 2 - jb gff_reset - - gff_test: - cmp eax, [ebp+FAT.LAST_CLUSTER]; if above last cluster start at cluster 2 - jbe gff_in_range - gff_reset: - mov eax, 2 +; Note : for more speed need to use fat_cache directly +;----------------------------------------------------------- + push ecx + mov ecx, [ebp+FAT.LAST_CLUSTER]; counter for full disk + sub ecx, 2 + mov eax, [ebp+FAT.fatStartScan] + cmp eax, 2 + jb gff_reset - gff_in_range: - push eax - call get_FAT ; get cluster state - jc gff_not_found_1 - - test eax, eax ; is it free? - pop eax + gff_test: + cmp eax, [ebp+FAT.LAST_CLUSTER]; if above last cluster start at cluster 2 + jbe gff_in_range + gff_reset: + mov eax, 2 + + gff_in_range: + push eax + call get_FAT ; get cluster state + jc gff_not_found_1 + + test eax, eax ; is it free? + pop eax je gff_found ; yes inc eax ; next cluster - dec ecx ; is all checked? - jns gff_test ; no - - gff_not_found: - pop ecx ; yes. disk is full - stc - ret - - gff_not_found_1: - pop eax - jmp gff_not_found - - gff_found: - lea ecx, [eax+1] - mov [ebp+FAT.fatStartScan], ecx - pop ecx - clc - ret + dec ecx ; is all checked? + jns gff_test ; no + + gff_not_found: + pop ecx ; yes. disk is full + stc + ret + + gff_not_found_1: + pop eax + jmp gff_not_found + + gff_found: + lea ecx, [eax+1] + mov [ebp+FAT.fatStartScan], ecx + pop ecx + clc + ret write_fat_sector: ;----------------------------------------------------------- ; write changed fat to disk -;----------------------------------------------------------- - push eax ebx ecx - - mov [ebp+FAT.fat_change], 0 - mov eax, [ebp+FAT.fat_in_cache] - cmp eax, -1 - jz write_fat_not_used - lea ebx, [ebp+FAT.fat_cache] - mov ecx, [ebp+FAT.NUMBER_OF_FATS] - - write_next_fat: - push eax - call fs_write32_sys - test eax, eax - pop eax - jnz write_fat_not_used - - add eax, [ebp+FAT.SECTORS_PER_FAT] - dec ecx - jnz write_next_fat - +;----------------------------------------------------------- + push eax ebx ecx + + mov [ebp+FAT.fat_change], 0 + mov eax, [ebp+FAT.fat_in_cache] + cmp eax, -1 + jz write_fat_not_used + lea ebx, [ebp+FAT.fat_cache] + mov ecx, [ebp+FAT.NUMBER_OF_FATS] + + write_next_fat: + push eax + call fs_write32_sys + test eax, eax + pop eax + jnz write_fat_not_used + + add eax, [ebp+FAT.SECTORS_PER_FAT] + dec ecx + jnz write_next_fat + write_fat_not_used: pop ecx ebx eax - ret - - - - - -bcd2bin: -;---------------------------------- -; input : AL=BCD number (eg. 0x11) + ret + + + + + +bcd2bin: +;---------------------------------- +; input : AL=BCD number (eg. 0x11) ; output : AH=0 ; AL=decimal number (eg. 11) ;---------------------------------- @@ -570,167 +570,167 @@ add_disk_free_space: ; input : ecx = cluster count ; Note : negative = remove clusters from free space ; positive = add clusters to free space -;----------------------------------------------------- - test ecx, ecx ; no change - je add_dfs_no - cmp [ebp+FAT.fs_type], 32 ; free disk space only used by fat32 - jne add_dfs_no - - push eax ebx - mov eax, [ebp+FAT.ADR_FSINFO] - lea ebx, [ebp+FAT.fsinfo_buffer] - call fs_read32_sys - test eax, eax - jnz add_not_fs - - cmp dword [ebx+0x1fc], 0xaa550000; check sector id - jne add_not_fs - - add [ebx+0x1e8], ecx - push [ebp+FAT.fatStartScan] - pop dword [ebx+0x1ec] - mov eax, [ebp+FAT.ADR_FSINFO] - call fs_write32_sys -; jc add_not_fs - - add_not_fs: - pop ebx eax +;----------------------------------------------------- + test ecx, ecx ; no change + je add_dfs_no + cmp [ebp+FAT.fs_type], 32 ; free disk space only used by fat32 + jne add_dfs_no + + push eax ebx + mov eax, [ebp+FAT.ADR_FSINFO] + lea ebx, [ebp+FAT.fsinfo_buffer] + call fs_read32_sys + test eax, eax + jnz add_not_fs + + cmp dword [ebx+0x1fc], 0xaa550000; check sector id + jne add_not_fs + + add [ebx+0x1e8], ecx + push [ebp+FAT.fatStartScan] + pop dword [ebx+0x1ec] + mov eax, [ebp+FAT.ADR_FSINFO] + call fs_write32_sys +; jc add_not_fs + + add_not_fs: + pop ebx eax add_dfs_no: - ret - - - -clear_cluster_chain: -;----------------------------------------------------- -; input : eax = first cluster + ret + + + +clear_cluster_chain: +;----------------------------------------------------- +; input : eax = first cluster ;----------------------------------------------------- push eax ecx edx - xor ecx, ecx ; cluster count - - clean_new_chain: - cmp eax, [ebp+FAT.LAST_CLUSTER]; end of file - ja delete_OK - cmp eax, 2 ; unfinished fat chain or zero length file - jb delete_OK - cmp eax, [ebp+FAT.ROOT_CLUSTER]; don't remove root cluster - jz delete_OK - - xor edx, edx - call set_FAT ; clear fat entry - jc access_denied_01 - - inc ecx ; update cluster count - mov eax, edx ; old cluster + xor ecx, ecx ; cluster count + + clean_new_chain: + cmp eax, [ebp+FAT.LAST_CLUSTER]; end of file + ja delete_OK + cmp eax, 2 ; unfinished fat chain or zero length file + jb delete_OK + cmp eax, [ebp+FAT.ROOT_CLUSTER]; don't remove root cluster + jz delete_OK + + xor edx, edx + call set_FAT ; clear fat entry + jc access_denied_01 + + inc ecx ; update cluster count + mov eax, edx ; old cluster jmp clean_new_chain - - delete_OK: - call add_disk_free_space; add clusters to free disk space - clc - access_denied_01: - pop edx ecx eax - ret - - -if 0 -get_hd_info: -;----------------------------------------------------------- -; output : eax = 0 - ok + + delete_OK: + call add_disk_free_space; add clusters to free disk space + clc + access_denied_01: + pop edx ecx eax + ret + + +if 0 +get_hd_info: +;----------------------------------------------------------- +; output : eax = 0 - ok ; 3 - unknown FS ; 10 - access denied ; edx = cluster size in bytes -; ebx = total clusters on disk -; ecx = free clusters on disk -;----------------------------------------------------------- - cmp [ebp+FAT.fs_type], 16 - jz info_fat_ok - cmp [ebp+FAT.fs_type], 32 - jz info_fat_ok - xor edx, edx - xor ebx, ebx +; ebx = total clusters on disk +; ecx = free clusters on disk +;----------------------------------------------------------- + cmp [ebp+FAT.fs_type], 16 + jz info_fat_ok + cmp [ebp+FAT.fs_type], 32 + jz info_fat_ok + xor edx, edx + xor ebx, ebx xor ecx, ecx mov eax, ERROR_UNKNOWN_FS ret info_fat_ok: ; call reserve_hd1 - - xor ecx, ecx ; count of free clusters - mov eax, 2 - mov ebx, [ebp+FAT.LAST_CLUSTER] - - info_cluster: - push eax - call get_FAT ; get cluster info - jc info_access_denied - - test eax, eax ; is it free? - jnz info_used ; no + + xor ecx, ecx ; count of free clusters + mov eax, 2 + mov ebx, [ebp+FAT.LAST_CLUSTER] + + info_cluster: + push eax + call get_FAT ; get cluster info + jc info_access_denied + + test eax, eax ; is it free? + jnz info_used ; no inc ecx info_used: pop eax inc eax cmp eax, ebx ; is above last cluster? - jbe info_cluster ; no. test next cluster - - dec ebx ; cluster count - imul edx, [ebp+FAT.SECTORS_PER_CLUSTER], 512; cluster size in bytes - xor eax, eax - ret - + jbe info_cluster ; no. test next cluster + + dec ebx ; cluster count + imul edx, [ebp+FAT.SECTORS_PER_CLUSTER], 512; cluster size in bytes + xor eax, eax + ret + info_access_denied: add esp, 4 xor edx, edx xor ebx, ebx - xor ecx, ecx - mov eax, ERROR_ACCESS_DENIED - ret -end if - -update_disk: -;----------------------------------------------------------- -; write changed fat and cache to disk -;----------------------------------------------------------- - cmp [ebp+FAT.fat_change], 0 ; is fat changed? - je upd_no_change - - call write_fat_sector - jc update_disk_acces_denied - - upd_no_change: - - push esi - mov esi, [ebp+PARTITION.Disk] - call disk_sync - pop esi - update_disk_acces_denied: - ret - -fat_lock: - lea ecx, [ebp+FAT.Lock] - jmp mutex_lock -fat_unlock: - lea ecx, [ebp+FAT.Lock] - jmp mutex_unlock - -; \begin{diamond} -hd_find_lfn: -; in: ebp -> FAT structure -; in: esi+[esp+4] -> name -; out: CF=1 - file not found, eax=error code -; else CF=0 and edi->direntry, eax=sector -; destroys eax - push esi edi + xor ecx, ecx + mov eax, ERROR_ACCESS_DENIED + ret +end if + +update_disk: +;----------------------------------------------------------- +; write changed fat and cache to disk +;----------------------------------------------------------- + cmp [ebp+FAT.fat_change], 0 ; is fat changed? + je upd_no_change + + call write_fat_sector + jc update_disk_acces_denied + + upd_no_change: + + push esi + mov esi, [ebp+PARTITION.Disk] + call disk_sync + pop esi + update_disk_acces_denied: + ret + +fat_lock: + lea ecx, [ebp+FAT.Lock] + jmp mutex_lock +fat_unlock: + lea ecx, [ebp+FAT.Lock] + jmp mutex_unlock + +; \begin{diamond} +hd_find_lfn: +; in: ebp -> FAT structure +; in: esi+[esp+4] -> name +; out: CF=1 - file not found, eax=error code +; else CF=0 and edi->direntry, eax=sector +; destroys eax + push esi edi push 0 - push 0 - push fat16_root_first - push fat16_root_next - mov eax, [ebp+FAT.ROOT_CLUSTER] - cmp [ebp+FAT.fs_type], 32 - jz .fat32 -.loop: - call fat_find_lfn + push 0 + push fat16_root_first + push fat16_root_next + mov eax, [ebp+FAT.ROOT_CLUSTER] + cmp [ebp+FAT.fs_type], 32 + jz .fat32 +.loop: + call fat_find_lfn jc .notfound cmp byte [esi], 0 jz .found @@ -746,40 +746,40 @@ hd_find_lfn: mov dword [esp], fat_notroot_next jmp .loop .notfound: - add esp, 16 - pop edi esi - stc - ret 4 -.found: - lea eax, [esp+4+24] - cmp dword [eax], 0 - jz @f - mov esi, [eax] - and dword [eax], 0 - jmp .continue -@@: - lea eax, [esp+8] + add esp, 16 + pop edi esi + stc + ret 4 +.found: + lea eax, [esp+4+24] + cmp dword [eax], 0 + jz @f + mov esi, [eax] + and dword [eax], 0 + jmp .continue +@@: + lea eax, [esp+8] cmp dword [eax], 0 jz .root call fat_get_sector - jmp .cmn -.root: - mov eax, [eax+4] - add eax, [ebp+FAT.ROOT_START] -.cmn: - add esp, 20 ; CF=0 - pop esi - ret 4 - -;---------------------------------------------------------------- -; -; fs_HdRead - LFN variant for reading hard disk -; -; Obsolete, will be replaced with filesystem-specific functions. -; -; esi points to filename -; ebx pointer to 64-bit number = first wanted byte, 0+ -; may be ebx=0 - start from first byte + jmp .cmn +.root: + mov eax, [eax+4] + add eax, [ebp+FAT.ROOT_START] +.cmn: + add esp, 20 ; CF=0 + pop esi + ret 4 + +;---------------------------------------------------------------- +; +; fs_HdRead - LFN variant for reading hard disk +; +; Obsolete, will be replaced with filesystem-specific functions. +; +; esi points to filename +; ebx pointer to 64-bit number = first wanted byte, 0+ +; may be ebx=0 - start from first byte ; ecx number of bytes to read, 0+ ; edx mem location to return data ; @@ -797,65 +797,65 @@ fs_HdRead: cmp [fs_type], 2 jz ext2_HdRead or ebx, -1 - mov eax, ERROR_UNKNOWN_FS - ret -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - call fat_Read - pop ebp - ret - -;---------------------------------------------------------------- -; fat_Read - FAT16/32 implementation of reading a file -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_Read: - call fat_lock - push edi - cmp byte [esi], 0 - jnz @f -.noaccess: - pop edi -.noaccess_2: - call fat_unlock - or ebx, -1 - mov eax, ERROR_ACCESS_DENIED - ret - -@@: - stdcall hd_find_lfn, [esp+4+4] - jnc .found - pop edi - push eax - call fat_unlock - pop eax - or ebx, -1 - ret - -.found: - test byte [edi+11], 0x10; do not allow read directories - jnz .noaccess - cmp dword [ebx+8], 0 - jz @f - xor ebx, ebx -.reteof: - call fat_unlock - mov eax, ERROR_END_OF_FILE - pop edi - ret -@@: - mov ecx, [ebx+12] ; size - mov edx, [ebx+16] ; pointer - mov ebx, [ebx+4] ; file offset - push edx - push 0 - mov eax, [edi+28] - sub eax, ebx + mov eax, ERROR_UNKNOWN_FS + ret +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + call fat_Read + pop ebp + ret + +;---------------------------------------------------------------- +; fat_Read - FAT16/32 implementation of reading a file +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_Read: + call fat_lock + push edi + cmp byte [esi], 0 + jnz @f +.noaccess: + pop edi +.noaccess_2: + call fat_unlock + or ebx, -1 + mov eax, ERROR_ACCESS_DENIED + ret + +@@: + stdcall hd_find_lfn, [esp+4+4] + jnc .found + pop edi + push eax + call fat_unlock + pop eax + or ebx, -1 + ret + +.found: + test byte [edi+11], 0x10; do not allow read directories + jnz .noaccess + cmp dword [ebx+8], 0 + jz @f + xor ebx, ebx +.reteof: + call fat_unlock + mov eax, ERROR_END_OF_FILE + pop edi + ret +@@: + mov ecx, [ebx+12] ; size + mov edx, [ebx+16] ; pointer + mov ebx, [ebx+4] ; file offset + push edx + push 0 + mov eax, [edi+28] + sub eax, ebx jb .eof cmp eax, ecx jae @f @@ -864,49 +864,49 @@ fat_Read: @@: mov eax, [edi+20-2] mov ax, [edi+26] -; now eax=cluster, ebx=position, ecx=count, edx=buffer for data -.new_cluster: - jecxz .new_sector - cmp eax, 2 - jb .eof - cmp eax, [ebp+FAT.fatRESERVED] - jae .eof - mov [ebp+FAT.cluster_tmp], eax - dec eax - dec eax - mov edi, [ebp+FAT.SECTORS_PER_CLUSTER] - imul eax, edi - add eax, [ebp+FAT.DATA_START] -.new_sector: - test ecx, ecx - jz .done +; now eax=cluster, ebx=position, ecx=count, edx=buffer for data +.new_cluster: + jecxz .new_sector + cmp eax, 2 + jb .eof + cmp eax, [ebp+FAT.fatRESERVED] + jae .eof + mov [ebp+FAT.cluster_tmp], eax + dec eax + dec eax + mov edi, [ebp+FAT.SECTORS_PER_CLUSTER] + imul eax, edi + add eax, [ebp+FAT.DATA_START] +.new_sector: + test ecx, ecx + jz .done sub ebx, 512 jae .skip add ebx, 512 jnz .force_buf - cmp ecx, 512 - jb .force_buf -; we may read directly to given buffer - push eax ebx - mov ebx, edx - call fs_read32_app - test eax, eax - pop ebx eax - jne .noaccess_1 - add edx, 512 - sub ecx, 512 + cmp ecx, 512 + jb .force_buf +; we may read directly to given buffer + push eax ebx + mov ebx, edx + call fs_read32_app + test eax, eax + pop ebx eax + jne .noaccess_1 + add edx, 512 + sub ecx, 512 jmp .skip -.force_buf: -; we must read sector to temporary buffer and then copy it to destination - push eax ebx - lea ebx, [ebp+FAT.buffer] - call fs_read32_app - test eax, eax - mov eax, ebx - pop ebx - jne .noaccess_3 - add eax, ebx - push ecx +.force_buf: +; we must read sector to temporary buffer and then copy it to destination + push eax ebx + lea ebx, [ebp+FAT.buffer] + call fs_read32_app + test eax, eax + mov eax, ebx + pop ebx + jne .noaccess_3 + add eax, ebx + push ecx add ecx, ebx cmp ecx, 512 jbe @f @@ -921,394 +921,394 @@ fat_Read: pop eax xor ebx, ebx .skip: - inc eax - dec edi - jnz .new_sector - mov eax, [ebp+FAT.cluster_tmp] - call get_FAT - jc .noaccess_1 - - jmp .new_cluster -.noaccess_3: - pop eax -.noaccess_1: - pop eax - push ERROR_DEVICE -.done: - mov ebx, edx - call fat_unlock - pop eax edx edi - sub ebx, edx - ret -.eof: - mov ebx, edx - pop eax edx - sub ebx, edx - jmp .reteof - + inc eax + dec edi + jnz .new_sector + mov eax, [ebp+FAT.cluster_tmp] + call get_FAT + jc .noaccess_1 + + jmp .new_cluster +.noaccess_3: + pop eax +.noaccess_1: + pop eax + push ERROR_DEVICE +.done: + mov ebx, edx + call fat_unlock + pop eax edx edi + sub ebx, edx + ret +.eof: + mov ebx, edx + pop eax edx + sub ebx, edx + jmp .reteof + ;---------------------------------------------------------------- -; -; fs_HdReadFolder - LFN variant for reading hard disk folder -; -; Obsolete, will be replaced with filesystem-specific functions. -; -; esi points to filename -; ebx pointer to structure 32-bit number = first wanted block, 0+ -; & flags (bitfields) +; +; fs_HdReadFolder - LFN variant for reading hard disk folder +; +; Obsolete, will be replaced with filesystem-specific functions. +; +; esi points to filename +; ebx pointer to structure 32-bit number = first wanted block, 0+ +; & flags (bitfields) ; flags: bit 0: 0=ANSI names, 1=UNICODE names ; ecx number of blocks to read, 0+ ; edx mem location to return data ; ; ret ebx = blocks read or 0xffffffff folder not found ; eax = 0 ok read or other = errormsg -; -;-------------------------------------------------------------- -fs_HdReadFolder: - cmp [fs_type], 16 - jz @f - cmp [fs_type], 32 - jz @f - cmp [fs_type], 1 - jz ntfs_HdReadFolder - cmp [fs_type], 2 - jz ext2_HdReadFolder - push ERROR_UNSUPPORTED_FS - pop eax - or ebx, -1 - ret -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - call fat_ReadFolder - pop ebp - ret - -;---------------------------------------------------------------- -; fat_ReadFolder - FAT16/32 implementation of reading a folder -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_ReadFolder: - call fat_lock - mov eax, [ebp+FAT.ROOT_CLUSTER] - push edi - cmp byte [esi], 0 - jz .doit - stdcall hd_find_lfn, [esp+4+4] - jnc .found - pop edi - push eax - call fat_unlock - pop eax - or ebx, -1 - ret -.found: - test byte [edi+11], 0x10 ; do not allow read files - jnz .found_dir - pop edi - call fat_unlock - or ebx, -1 - mov eax, ERROR_ACCESS_DENIED - ret +; +;-------------------------------------------------------------- +fs_HdReadFolder: + cmp [fs_type], 16 + jz @f + cmp [fs_type], 32 + jz @f + cmp [fs_type], 1 + jz ntfs_HdReadFolder + cmp [fs_type], 2 + jz ext2_HdReadFolder + push ERROR_UNSUPPORTED_FS + pop eax + or ebx, -1 + ret +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + call fat_ReadFolder + pop ebp + ret + +;---------------------------------------------------------------- +; fat_ReadFolder - FAT16/32 implementation of reading a folder +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_ReadFolder: + call fat_lock + mov eax, [ebp+FAT.ROOT_CLUSTER] + push edi + cmp byte [esi], 0 + jz .doit + stdcall hd_find_lfn, [esp+4+4] + jnc .found + pop edi + push eax + call fat_unlock + pop eax + or ebx, -1 + ret +.found: + test byte [edi+11], 0x10 ; do not allow read files + jnz .found_dir + pop edi + call fat_unlock + or ebx, -1 + mov eax, ERROR_ACCESS_DENIED + ret .found_dir: - mov eax, [edi+20-2] - mov ax, [edi+26] ; eax=cluster -.doit: - push esi - sub esp, 262*2 ; reserve space for LFN - push dword [ebx+8] ; for fat_get_name: read ANSI/UNICODE name - mov edx, [ebx+16] ; pointer to buffer -; init header - push eax - mov edi, edx - mov ecx, 32/4 - xor eax, eax - rep stosd - pop eax - mov byte [edx], 1 ; version - mov esi, edi ; esi points to BDFE - mov ecx, [ebx+12] ; number of blocks to read - mov ebx, [ebx+4] ; index of the first block -.new_cluster: - mov [ebp+FAT.cluster_tmp], eax - test eax, eax - jnz @f - cmp [ebp+FAT.fs_type], 32 - jz .notfound - mov eax, [ebp+FAT.ROOT_START] - push [ebp+FAT.ROOT_SECTORS] - push ebx - jmp .new_sector -@@: - dec eax - dec eax - imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] - push [ebp+FAT.SECTORS_PER_CLUSTER] - add eax, [ebp+FAT.DATA_START] - push ebx -.new_sector: - lea ebx, [ebp+FAT.buffer] - mov edi, ebx - push eax - call fs_read32_sys - test eax, eax - pop eax - jnz .notfound2 - add ebx, 512 - push eax -.l1: - push ebp - lea ebp, [esp+20] - call fat_get_name - pop ebp - jc .l2 - cmp byte [edi+11], 0xF - jnz .do_bdfe + mov eax, [edi+20-2] + mov ax, [edi+26] ; eax=cluster +.doit: + push esi + sub esp, 262*2 ; reserve space for LFN + push dword [ebx+8] ; for fat_get_name: read ANSI/UNICODE name + mov edx, [ebx+16] ; pointer to buffer +; init header + push eax + mov edi, edx + mov ecx, 32/4 + xor eax, eax + rep stosd + pop eax + mov byte [edx], 1 ; version + mov esi, edi ; esi points to BDFE + mov ecx, [ebx+12] ; number of blocks to read + mov ebx, [ebx+4] ; index of the first block +.new_cluster: + mov [ebp+FAT.cluster_tmp], eax + test eax, eax + jnz @f + cmp [ebp+FAT.fs_type], 32 + jz .notfound + mov eax, [ebp+FAT.ROOT_START] + push [ebp+FAT.ROOT_SECTORS] + push ebx + jmp .new_sector +@@: + dec eax + dec eax + imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] + push [ebp+FAT.SECTORS_PER_CLUSTER] + add eax, [ebp+FAT.DATA_START] + push ebx +.new_sector: + lea ebx, [ebp+FAT.buffer] + mov edi, ebx + push eax + call fs_read32_sys + test eax, eax + pop eax + jnz .notfound2 + add ebx, 512 + push eax +.l1: + push ebp + lea ebp, [esp+20] + call fat_get_name + pop ebp + jc .l2 + cmp byte [edi+11], 0xF + jnz .do_bdfe add edi, 0x20 cmp edi, ebx jb .do_bdfe pop eax - inc eax - dec dword [esp+4] - jnz @f - mov eax, [ebp+FAT.cluster_tmp] - test eax, eax - jz .done - call get_FAT - jc .notfound2 - cmp eax, 2 - jb .done - cmp eax, [ebp+FAT.fatRESERVED] - jae .done - push eax - mov eax, [ebp+FAT.SECTORS_PER_CLUSTER] - mov [esp+8], eax - pop eax - mov [ebp+FAT.cluster_tmp], eax - dec eax - dec eax - imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] - add eax, [ebp+FAT.DATA_START] -@@: - lea ebx, [ebp+FAT.buffer] - mov edi, ebx - push eax - call fs_read32_sys - test eax, eax - pop eax - jnz .notfound2 - add ebx, 512 - push eax + inc eax + dec dword [esp+4] + jnz @f + mov eax, [ebp+FAT.cluster_tmp] + test eax, eax + jz .done + call get_FAT + jc .notfound2 + cmp eax, 2 + jb .done + cmp eax, [ebp+FAT.fatRESERVED] + jae .done + push eax + mov eax, [ebp+FAT.SECTORS_PER_CLUSTER] + mov [esp+8], eax + pop eax + mov [ebp+FAT.cluster_tmp], eax + dec eax + dec eax + imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] + add eax, [ebp+FAT.DATA_START] +@@: + lea ebx, [ebp+FAT.buffer] + mov edi, ebx + push eax + call fs_read32_sys + test eax, eax + pop eax + jnz .notfound2 + add ebx, 512 + push eax .do_bdfe: inc dword [edx+8] ; new file found dec dword [esp+4] jns .l2 - dec ecx - js .l2 - inc dword [edx+4] ; new file block copied - push ebp - lea ebp, [esp+20] - call fat_entry_to_bdfe - pop ebp -.l2: - add edi, 0x20 - cmp edi, ebx + dec ecx + js .l2 + inc dword [edx+4] ; new file block copied + push ebp + lea ebp, [esp+20] + call fat_entry_to_bdfe + pop ebp +.l2: + add edi, 0x20 + cmp edi, ebx jb .l1 pop eax - inc eax - dec dword [esp+4] - jnz .new_sector - mov eax, [ebp+FAT.cluster_tmp] - test eax, eax - jz .done - call get_FAT - jc .notfound2 - cmp eax, 2 - jb .done - cmp eax, [ebp+FAT.fatRESERVED] - jae .done - push eax - mov eax, [ebp+FAT.SECTORS_PER_CLUSTER] - mov [esp+8], eax - pop eax - pop ebx + inc eax + dec dword [esp+4] + jnz .new_sector + mov eax, [ebp+FAT.cluster_tmp] + test eax, eax + jz .done + call get_FAT + jc .notfound2 + cmp eax, 2 + jb .done + cmp eax, [ebp+FAT.fatRESERVED] + jae .done + push eax + mov eax, [ebp+FAT.SECTORS_PER_CLUSTER] + mov [esp+8], eax + pop eax + pop ebx add esp, 4 jmp .new_cluster .notfound2: - add esp, 8 -.notfound: - add esp, 262*2+4 - pop esi edi - mov ebx, [edx+4] - call fat_unlock - mov eax, ERROR_DEVICE - ret -.done: - add esp, 262*2+4+8 - mov ebx, [edx+4] - xor eax, eax - dec ecx - js @f - mov al, ERROR_END_OF_FILE -@@: - push eax - call fat_unlock - pop eax - pop esi edi - ret - -fat16_root_next: - push ecx - lea ecx, [ebp+FAT.buffer+0x200-0x20] - cmp edi, ecx - jae fat16_root_next_sector - pop ecx - add edi, 0x20 - ret ; CF=0 -fat16_root_next_sector: -; read next sector - push [ebp+FAT.longname_sec2] - pop [ebp+FAT.longname_sec1] - mov ecx, [eax+4] - push ecx - add ecx, [ebp+FAT.ROOT_START] - mov [ebp+FAT.longname_sec2], ecx - pop ecx - inc ecx - mov [eax+4], ecx - cmp ecx, [ebp+FAT.ROOT_SECTORS] - pop ecx - jb fat16_root_first - mov eax, ERROR_FILE_NOT_FOUND - stc - ret -fat16_root_first: - mov eax, [eax+4] - add eax, [ebp+FAT.ROOT_START] - push ebx - lea edi, [ebp+FAT.buffer] - mov ebx, edi - call fs_read32_sys - pop ebx - test eax, eax - jnz .readerr - ret ; CF=0 -.readerr: - mov eax, ERROR_DEVICE - stc - ret -.notfound: - mov eax, ERROR_FILE_NOT_FOUND - stc - ret -fat16_root_begin_write: - push edi eax - call fat16_root_first + add esp, 8 +.notfound: + add esp, 262*2+4 + pop esi edi + mov ebx, [edx+4] + call fat_unlock + mov eax, ERROR_DEVICE + ret +.done: + add esp, 262*2+4+8 + mov ebx, [edx+4] + xor eax, eax + dec ecx + js @f + mov al, ERROR_END_OF_FILE +@@: + push eax + call fat_unlock + pop eax + pop esi edi + ret + +fat16_root_next: + push ecx + lea ecx, [ebp+FAT.buffer+0x200-0x20] + cmp edi, ecx + jae fat16_root_next_sector + pop ecx + add edi, 0x20 + ret ; CF=0 +fat16_root_next_sector: +; read next sector + push [ebp+FAT.longname_sec2] + pop [ebp+FAT.longname_sec1] + mov ecx, [eax+4] + push ecx + add ecx, [ebp+FAT.ROOT_START] + mov [ebp+FAT.longname_sec2], ecx + pop ecx + inc ecx + mov [eax+4], ecx + cmp ecx, [ebp+FAT.ROOT_SECTORS] + pop ecx + jb fat16_root_first + mov eax, ERROR_FILE_NOT_FOUND + stc + ret +fat16_root_first: + mov eax, [eax+4] + add eax, [ebp+FAT.ROOT_START] + push ebx + lea edi, [ebp+FAT.buffer] + mov ebx, edi + call fs_read32_sys + pop ebx + test eax, eax + jnz .readerr + ret ; CF=0 +.readerr: + mov eax, ERROR_DEVICE + stc + ret +.notfound: + mov eax, ERROR_FILE_NOT_FOUND + stc + ret +fat16_root_begin_write: + push edi eax + call fat16_root_first pop eax edi ret -fat16_root_end_write: - pusha - mov eax, [eax+4] - add eax, [ebp+FAT.ROOT_START] - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - popa - ret -fat16_root_next_write: - push ecx - lea ecx, [ebp+FAT.buffer+0x200] - cmp edi, ecx - jae @f - pop ecx - ret -@@: - call fat16_root_end_write +fat16_root_end_write: + pusha + mov eax, [eax+4] + add eax, [ebp+FAT.ROOT_START] + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + popa + ret +fat16_root_next_write: + push ecx + lea ecx, [ebp+FAT.buffer+0x200] + cmp edi, ecx + jae @f + pop ecx + ret +@@: + call fat16_root_end_write jmp fat16_root_next_sector fat16_root_extend_dir: stc - ret - -fat_notroot_next: - push ecx - lea ecx, [ebp+FAT.buffer+0x200-0x20] - cmp edi, ecx - jae fat_notroot_next_sector - pop ecx - add edi, 0x20 - ret ; CF=0 -fat_notroot_next_sector: - push [ebp+FAT.longname_sec2] - pop [ebp+FAT.longname_sec1] - push eax - call fat_get_sector - mov [ebp+FAT.longname_sec2], eax - pop eax - mov ecx, [eax+4] - inc ecx - cmp ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - jae fat_notroot_next_cluster - mov [eax+4], ecx - jmp @f + ret + +fat_notroot_next: + push ecx + lea ecx, [ebp+FAT.buffer+0x200-0x20] + cmp edi, ecx + jae fat_notroot_next_sector + pop ecx + add edi, 0x20 + ret ; CF=0 +fat_notroot_next_sector: + push [ebp+FAT.longname_sec2] + pop [ebp+FAT.longname_sec1] + push eax + call fat_get_sector + mov [ebp+FAT.longname_sec2], eax + pop eax + mov ecx, [eax+4] + inc ecx + cmp ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + jae fat_notroot_next_cluster + mov [eax+4], ecx + jmp @f fat_notroot_next_cluster: push eax mov eax, [eax] - call get_FAT - mov ecx, eax - pop eax - jc fat_notroot_first.deverr - cmp ecx, 2 - jb fat_notroot_next_err - cmp ecx, [ebp+FAT.fatRESERVED] - jae fat_notroot_next_err - mov [eax], ecx - and dword [eax+4], 0 + call get_FAT + mov ecx, eax + pop eax + jc fat_notroot_first.deverr + cmp ecx, 2 + jb fat_notroot_next_err + cmp ecx, [ebp+FAT.fatRESERVED] + jae fat_notroot_next_err + mov [eax], ecx + and dword [eax+4], 0 @@: pop ecx -fat_notroot_first: - call fat_get_sector - push ebx - lea edi, [ebp+FAT.buffer] - mov ebx, edi - call fs_read32_sys - pop ebx - test eax, eax - jz .ret ; CF=0 - push ecx -.deverr: - pop ecx - mov eax, ERROR_DEVICE - stc -.ret: - ret -fat_notroot_next_err: - pop ecx - mov eax, ERROR_FILE_NOT_FOUND - stc - ret -fat_notroot_begin_write: +fat_notroot_first: + call fat_get_sector + push ebx + lea edi, [ebp+FAT.buffer] + mov ebx, edi + call fs_read32_sys + pop ebx + test eax, eax + jz .ret ; CF=0 + push ecx +.deverr: + pop ecx + mov eax, ERROR_DEVICE + stc +.ret: + ret +fat_notroot_next_err: + pop ecx + mov eax, ERROR_FILE_NOT_FOUND + stc + ret +fat_notroot_begin_write: push eax edi call fat_notroot_first pop edi eax ret -fat_notroot_end_write: - call fat_get_sector - push ebx - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - pop ebx - ret -fat_notroot_next_write: - push ecx - lea ecx, [ebp+FAT.buffer+0x200] - cmp edi, ecx - jae @f - pop ecx - ret -@@: - push eax +fat_notroot_end_write: + call fat_get_sector + push ebx + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + pop ebx + ret +fat_notroot_next_write: + push ecx + lea ecx, [ebp+FAT.buffer+0x200] + cmp edi, ecx + jae @f + pop ecx + ret +@@: + push eax call fat_notroot_end_write pop eax jmp fat_notroot_next_sector @@ -1317,34 +1317,34 @@ fat_notroot_extend_dir: call get_free_FAT jnc .found pop eax - ret ; CF=1 -.found: - push edx - mov edx, [ebp+FAT.fatEND] - call set_FAT - jc .writeerr - mov edx, eax - mov eax, [esp+4] - mov eax, [eax] - push edx - call set_FAT - pop edx - jnc @f -.writeerr: - pop edx - pop eax - stc + ret ; CF=1 +.found: + push edx + mov edx, [ebp+FAT.fatEND] + call set_FAT + jc .writeerr + mov edx, eax + mov eax, [esp+4] + mov eax, [eax] + push edx + call set_FAT + pop edx + jnc @f +.writeerr: + pop edx + pop eax + stc ret @@: push ecx or ecx, -1 - call add_disk_free_space -; zero new cluster - mov ecx, 512/4 - lea edi, [ebp+FAT.buffer] - push edi - xor eax, eax - rep stosd + call add_disk_free_space +; zero new cluster + mov ecx, 512/4 + lea edi, [ebp+FAT.buffer] + push edi + xor eax, eax + rep stosd pop edi pop ecx mov eax, [esp+4] @@ -1352,225 +1352,225 @@ fat_notroot_extend_dir: and dword [eax+4], 0 pop edx mov eax, [eax] - dec eax - dec eax - push ebx ecx - mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - imul eax, ecx - add eax, [ebp+FAT.DATA_START] - mov ebx, edi -@@: - push eax - call fs_write32_sys - pop eax - inc eax - loop @b - pop ecx ebx eax + dec eax + dec eax + push ebx ecx + mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + imul eax, ecx + add eax, [ebp+FAT.DATA_START] + mov ebx, edi +@@: + push eax + call fs_write32_sys + pop eax + inc eax + loop @b + pop ecx ebx eax clc ret fat_get_sector: push ecx - mov ecx, [eax] - dec ecx - dec ecx - imul ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - add ecx, [ebp+FAT.DATA_START] - add ecx, [eax+4] - mov eax, ecx - pop ecx + mov ecx, [eax] + dec ecx + dec ecx + imul ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + add ecx, [ebp+FAT.DATA_START] + add ecx, [eax+4] + mov eax, ecx + pop ecx ret ;---------------------------------------------------------------- -; -; fs_HdRewrite - LFN variant for writing hard disk -; -; Obsolete, will be replaced with filesystem-specific functions. -; -; esi points to filename -; ebx ignored (reserved) -; ecx number of bytes to write, 0+ +; +; fs_HdRewrite - LFN variant for writing hard disk +; +; Obsolete, will be replaced with filesystem-specific functions. +; +; esi points to filename +; ebx ignored (reserved) +; ecx number of bytes to write, 0+ ; edx mem location to data ; ; ret ebx = number of written bytes -; eax = 0 ok read or other = errormsg -; -;-------------------------------------------------------------- -fs_HdCreateFolder: - mov al, 1 - jmp fs_HdRewrite.common +; eax = 0 ok read or other = errormsg +; +;-------------------------------------------------------------- +fs_HdCreateFolder: + mov al, 1 + jmp fs_HdRewrite.common -fs_HdRewrite: - xor eax, eax -.common: - cmp [fs_type], 16 - jz @f - cmp [fs_type], 32 - jz @f - cmp [fs_type], 1 - jz ntfs_HdRewrite - cmp [fs_type], 2 - jz ext2_HdRewrite - mov eax, ERROR_UNKNOWN_FS - xor ebx, ebx - ret -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - test eax, eax - mov eax, fat_CreateFolder - jnz @f - mov eax, fat_Rewrite -@@: - call eax - pop ebp - ret - -fshrad: - call fat_unlock - mov eax, ERROR_ACCESS_DENIED - xor ebx, ebx - ret - -;---------------------------------------------------------------- -; fat_CreateFolder - FAT16/32 implementation of creating a folder -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_CreateFolder: - push 1 - jmp fat_Rewrite.common - -;---------------------------------------------------------------- -; fat_HdRewrite - FAT16/32 implementation of creating a new file -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_Rewrite: - push 0 -.common: - call fat_lock - pop eax - cmp byte [esi], 0 - jz fshrad - mov ecx, [ebx+12] - mov edx, [ebx+16] - pushad - xor edi, edi - mov edx, [esp+4+20h] - push esi - test edx, edx - jz @f - mov esi, edx -@@: - lodsb - test al, al +fs_HdRewrite: + xor eax, eax +.common: + cmp [fs_type], 16 + jz @f + cmp [fs_type], 32 + jz @f + cmp [fs_type], 1 + jz ntfs_HdRewrite + cmp [fs_type], 2 + jz ext2_HdRewrite + mov eax, ERROR_UNKNOWN_FS + xor ebx, ebx + ret +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + test eax, eax + mov eax, fat_CreateFolder + jnz @f + mov eax, fat_Rewrite +@@: + call eax + pop ebp + ret + +fshrad: + call fat_unlock + mov eax, ERROR_ACCESS_DENIED + xor ebx, ebx + ret + +;---------------------------------------------------------------- +; fat_CreateFolder - FAT16/32 implementation of creating a folder +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_CreateFolder: + push 1 + jmp fat_Rewrite.common + +;---------------------------------------------------------------- +; fat_HdRewrite - FAT16/32 implementation of creating a new file +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_Rewrite: + push 0 +.common: + call fat_lock + pop eax + cmp byte [esi], 0 + jz fshrad + mov ecx, [ebx+12] + mov edx, [ebx+16] + pushad + xor edi, edi + mov edx, [esp+4+20h] + push esi + test edx, edx + jz @f + mov esi, edx +@@: + lodsb + test al, al jz @f cmp al, '/' jnz @b lea edi, [esi-1] jmp @b @@: - pop esi - test edi, edi - jnz .noroot - test edx, edx - jnz .hasebp - mov edx, [ebp+FAT.ROOT_CLUSTER] - cmp [ebp+FAT.fs_type], 32 - jz .pushnotroot - xor edx, edx - push edx - push fat16_root_extend_dir - push fat16_root_end_write - push fat16_root_next_write - push fat16_root_begin_write - push edx - push edx - push fat16_root_first - push fat16_root_next - jmp .common1 -.hasebp: - mov eax, ERROR_ACCESS_DENIED - cmp byte [edx], 0 - jz .ret1 - stdcall hd_find_lfn, 0 - mov esi, [esp+4+20h] - jc .ret1 - jmp .common0 -.noroot: - mov eax, ERROR_ACCESS_DENIED + pop esi + test edi, edi + jnz .noroot + test edx, edx + jnz .hasebp + mov edx, [ebp+FAT.ROOT_CLUSTER] + cmp [ebp+FAT.fs_type], 32 + jz .pushnotroot + xor edx, edx + push edx + push fat16_root_extend_dir + push fat16_root_end_write + push fat16_root_next_write + push fat16_root_begin_write + push edx + push edx + push fat16_root_first + push fat16_root_next + jmp .common1 +.hasebp: + mov eax, ERROR_ACCESS_DENIED + cmp byte [edx], 0 + jz .ret1 + stdcall hd_find_lfn, 0 + mov esi, [esp+4+20h] + jc .ret1 + jmp .common0 +.noroot: + mov eax, ERROR_ACCESS_DENIED cmp byte [edi+1], 0 jz .ret1 -; check existence - mov byte [edi], 0 - push edi - stdcall hd_find_lfn, [esp+4+24h] - pop esi - mov byte [esi], '/' - jnc @f +; check existence + mov byte [edi], 0 + push edi + stdcall hd_find_lfn, [esp+4+24h] + pop esi + mov byte [esi], '/' + jnc @f .notfound0: - mov eax, ERROR_FILE_NOT_FOUND -.ret1: - mov [esp+28], eax - call fat_unlock - popad - xor ebx, ebx - ret + mov eax, ERROR_FILE_NOT_FOUND +.ret1: + mov [esp+28], eax + call fat_unlock + popad + xor ebx, ebx + ret @@: inc esi .common0: - test byte [edi+11], 0x10 ; must be directory - mov eax, ERROR_ACCESS_DENIED - jz .ret1 - mov edx, [edi+20-2] - mov dx, [edi+26] ; ebp=cluster - mov eax, ERROR_FAT_TABLE - cmp edx, 2 - jb .ret1 -.pushnotroot: - push edx - push fat_notroot_extend_dir - push fat_notroot_end_write - push fat_notroot_next_write - push fat_notroot_begin_write - push 0 - push edx - push fat_notroot_first - push fat_notroot_next -.common1: + test byte [edi+11], 0x10 ; must be directory + mov eax, ERROR_ACCESS_DENIED + jz .ret1 + mov edx, [edi+20-2] + mov dx, [edi+26] ; ebp=cluster + mov eax, ERROR_FAT_TABLE + cmp edx, 2 + jb .ret1 +.pushnotroot: + push edx + push fat_notroot_extend_dir + push fat_notroot_end_write + push fat_notroot_next_write + push fat_notroot_begin_write + push 0 + push edx + push fat_notroot_first + push fat_notroot_next +.common1: call fat_find_lfn jc .notfound ; found test byte [edi+11], 10h - jz .exists_file -; found directory; if we are creating directory, return OK, -; if we are creating file, say "access denied" - add esp, 36 - call fat_unlock - popad - test al, al - mov eax, ERROR_ACCESS_DENIED + jz .exists_file +; found directory; if we are creating directory, return OK, +; if we are creating file, say "access denied" + add esp, 36 + call fat_unlock + popad + test al, al + mov eax, ERROR_ACCESS_DENIED jz @f mov al, 0 @@: xor ebx, ebx ret -.exists_file: -; found file; if we are creating directory, return "access denied", -; if we are creating file, delete existing file and continue - cmp byte [esp+36+28], 0 - jz @f - add esp, 36 - call fat_unlock - popad - mov eax, ERROR_ACCESS_DENIED - xor ebx, ebx +.exists_file: +; found file; if we are creating directory, return "access denied", +; if we are creating file, delete existing file and continue + cmp byte [esp+36+28], 0 + jz @f + add esp, 36 + call fat_unlock + popad + mov eax, ERROR_ACCESS_DENIED + xor ebx, ebx ret @@: ; delete FAT chain @@ -1582,20 +1582,20 @@ fat_Rewrite: mov ax, [edi+26] mov word [edi+20], cx mov word [edi+26], cx - test eax, eax - jz .done1 -@@: - cmp eax, [ebp+FAT.fatRESERVED] - jae .done1 - push edx - xor edx, edx - call set_FAT - mov eax, edx - pop edx - jc .done1 - inc ecx - jmp @b -.done1: + test eax, eax + jz .done1 +@@: + cmp eax, [ebp+FAT.fatRESERVED] + jae .done1 + push edx + xor edx, edx + call set_FAT + mov eax, edx + pop edx + jc .done1 + inc ecx + jmp @b +.done1: pop edi call get_time_for_file mov [edi+22], ax @@ -1605,28 +1605,28 @@ fat_Rewrite: or byte [edi+11], 20h ; set 'archive' attribute jmp .doit .notfound: -; file is not found; generate short name - call fat_name_is_legal - jc @f - add esp, 36 - call fat_unlock - popad - mov eax, ERROR_FILE_NOT_FOUND - xor ebx, ebx +; file is not found; generate short name + call fat_name_is_legal + jc @f + add esp, 36 + call fat_unlock + popad + mov eax, ERROR_FILE_NOT_FOUND + xor ebx, ebx ret @@: sub esp, 12 mov edi, esp call fat_gen_short_name .test_short_name_loop: - push esi edi ecx - mov esi, edi - lea eax, [esp+12+12+8] - mov edx, [eax+24] - mov [eax], edx - and dword [eax+4], 0 - call dword [eax-4] - jc .found + push esi edi ecx + mov esi, edi + lea eax, [esp+12+12+8] + mov edx, [eax+24] + mov [eax], edx + and dword [eax+4], 0 + call dword [eax-4] + jc .found .test_short_name_entry: cmp byte [edi+11], 0xF jz .test_short_name_cont @@ -1642,14 +1642,14 @@ fat_Rewrite: jmp .found .short_name_found: pop ecx edi esi - call fat_next_short_name - jnc .test_short_name_loop -.disk_full: - add esp, 12+36 - call fat_unlock - popa - mov eax, ERROR_DISK_FULL - xor ebx, ebx + call fat_next_short_name + jnc .test_short_name_loop +.disk_full: + add esp, 12+36 + call fat_unlock + popa + mov eax, ERROR_DISK_FULL + xor ebx, ebx ret .found: pop ecx edi esi @@ -1683,47 +1683,47 @@ fat_Rewrite: push -1 push -1 ; find successive entries in directory - xor ecx, ecx - push eax - lea eax, [esp+16+8+12+8] - mov edx, [eax+24] - mov [eax], edx - and dword [eax+4], 0 - call dword [eax-4] - pop eax - jnc .scan_dir -.fsfrfe3: - add esp, 12+8+12+36 - call fat_unlock - popad - mov eax, ERROR_DEVICE - xor ebx, ebx - ret -.scan_dir: + xor ecx, ecx + push eax + lea eax, [esp+16+8+12+8] + mov edx, [eax+24] + mov [eax], edx + and dword [eax+4], 0 + call dword [eax-4] + pop eax + jnc .scan_dir +.fsfrfe3: + add esp, 12+8+12+36 + call fat_unlock + popad + mov eax, ERROR_DEVICE + xor ebx, ebx + ret +.scan_dir: cmp byte [edi], 0 jz .free cmp byte [edi], 0xE5 jz .free xor ecx, ecx .scan_cont: - push eax - lea eax, [esp+16+8+12+8] - call dword [eax-8] - mov edx, eax - pop eax - jnc .scan_dir - cmp edx, ERROR_DEVICE - jz .fsfrfe3 - push eax - lea eax, [esp+16+8+12+8] - call dword [eax+20] ; extend directory - pop eax - jnc .scan_dir - add esp, 12+8+12+36 - call fat_unlock - popad - mov eax, ERROR_DISK_FULL - xor ebx, ebx + push eax + lea eax, [esp+16+8+12+8] + call dword [eax-8] + mov edx, eax + pop eax + jnc .scan_dir + cmp edx, ERROR_DEVICE + jz .fsfrfe3 + push eax + lea eax, [esp+16+8+12+8] + call dword [eax+20] ; extend directory + pop eax + jnc .scan_dir + add esp, 12+8+12+36 + call fat_unlock + popad + mov eax, ERROR_DISK_FULL + xor ebx, ebx ret .free: test ecx, ecx @@ -1736,29 +1736,29 @@ fat_Rewrite: xor ecx, ecx @@: inc ecx - cmp ecx, eax - jb .scan_cont -; found! - push esi ecx -; If creating a directory, allocate one data cluster now and fail immediately -; if this is impossible. This prevents from creating an invalid directory entry -; on a full disk. -; yup, the argument is quite non-intuitive... but what should I do if -; the entire function uses such arguments? BTW, it refers to al from pushad, -; which in turn is filled with 0 in fat_Rewrite and 1 in fat_CreateFolder. - cmp byte [esp+8+12+8+12+36+28], 0 - jz .no.preallocate.folder.data - call get_free_FAT - jnc @f - add esp, 8+12+8 - jmp .disk_full -@@: - mov [esp+8+12+8+12+36+20], eax ; store the cluster somewhere -.no.preallocate.folder.data: -; calculate name checksum - mov esi, [esp+8+12] - mov ecx, 11 - xor eax, eax + cmp ecx, eax + jb .scan_cont +; found! + push esi ecx +; If creating a directory, allocate one data cluster now and fail immediately +; if this is impossible. This prevents from creating an invalid directory entry +; on a full disk. +; yup, the argument is quite non-intuitive... but what should I do if +; the entire function uses such arguments? BTW, it refers to al from pushad, +; which in turn is filled with 0 in fat_Rewrite and 1 in fat_CreateFolder. + cmp byte [esp+8+12+8+12+36+28], 0 + jz .no.preallocate.folder.data + call get_free_FAT + jnc @f + add esp, 8+12+8 + jmp .disk_full +@@: + mov [esp+8+12+8+12+36+20], eax ; store the cluster somewhere +.no.preallocate.folder.data: +; calculate name checksum + mov esi, [esp+8+12] + mov ecx, 11 + xor eax, eax @@: ror al, 1 add al, [esi] @@ -1822,154 +1822,154 @@ fat_Rewrite: mov [edi+24], ax ; last write date mov [edi+18], ax ; last access date xor ecx, ecx - mov word [edi+20], cx ; high word of cluster - mov word [edi+26], cx ; low word of cluster - to be filled - mov dword [edi+28], ecx ; file size - to be filled - cmp byte [esp+36+28], cl - jz .doit -; create directory - mov byte [edi+11], 10h ; attributes: folder - mov esi, edi - lea eax, [esp+8] - call dword [eax+16] ; flush directory - mov eax, [esp+36+20] ; extract saved cluster - mov [esp+36+20], edi ; this is needed for calculating arg of add_disk_free_space! - push ecx - mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - shl ecx, 9 - push ecx - push edi - jmp .doit2 -.doit: - mov esi, [esp+36+20] - lea eax, [esp+8] - call dword [eax+16] ; flush directory - push ecx - mov ecx, [esp+4+36+24] - push ecx - push edi - test ecx, ecx - jz .done - call get_free_FAT - jc .diskfull -.doit2: - push eax - mov [edi+26], ax - shr eax, 16 + mov word [edi+20], cx ; high word of cluster + mov word [edi+26], cx ; low word of cluster - to be filled + mov dword [edi+28], ecx ; file size - to be filled + cmp byte [esp+36+28], cl + jz .doit +; create directory + mov byte [edi+11], 10h ; attributes: folder + mov esi, edi + lea eax, [esp+8] + call dword [eax+16] ; flush directory + mov eax, [esp+36+20] ; extract saved cluster + mov [esp+36+20], edi ; this is needed for calculating arg of add_disk_free_space! + push ecx + mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + shl ecx, 9 + push ecx + push edi + jmp .doit2 +.doit: + mov esi, [esp+36+20] + lea eax, [esp+8] + call dword [eax+16] ; flush directory + push ecx + mov ecx, [esp+4+36+24] + push ecx + push edi + test ecx, ecx + jz .done + call get_free_FAT + jc .diskfull +.doit2: + push eax + mov [edi+26], ax + shr eax, 16 mov [edi+20], ax lea eax, [esp+16+8] - call dword [eax+16] ; flush directory - pop eax - push edx - mov edx, [ebp+FAT.fatEND] - call set_FAT - pop edx -.write_cluster: - push eax - dec eax - dec eax - imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] - add eax, [ebp+FAT.DATA_START] - push [ebp+FAT.SECTORS_PER_CLUSTER] -; write data -.write_sector: - cmp byte [esp+20+36+28], 0 - jnz .writedir - mov ecx, 512 - cmp dword [esp+12], ecx - jb .writeshort -; we can write directly from given buffer - mov ebx, esi - add esi, ecx - jmp .writecommon -.writeshort: - mov ecx, [esp+12] - push ecx - lea edi, [ebp+FAT.buffer] - mov ebx, edi - rep movsb -.writedircont: - lea ecx, [ebp+FAT.buffer+0x200] - sub ecx, edi - push eax - xor eax, eax + call dword [eax+16] ; flush directory + pop eax + push edx + mov edx, [ebp+FAT.fatEND] + call set_FAT + pop edx +.write_cluster: + push eax + dec eax + dec eax + imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] + add eax, [ebp+FAT.DATA_START] + push [ebp+FAT.SECTORS_PER_CLUSTER] +; write data +.write_sector: + cmp byte [esp+20+36+28], 0 + jnz .writedir + mov ecx, 512 + cmp dword [esp+12], ecx + jb .writeshort +; we can write directly from given buffer + mov ebx, esi + add esi, ecx + jmp .writecommon +.writeshort: + mov ecx, [esp+12] + push ecx + lea edi, [ebp+FAT.buffer] + mov ebx, edi + rep movsb +.writedircont: + lea ecx, [ebp+FAT.buffer+0x200] + sub ecx, edi + push eax + xor eax, eax rep stosb - pop eax - pop ecx -.writecommon: - push eax - call fs_write32_app - test eax, eax - pop eax - jnz .writeerr - inc eax - sub dword [esp+12], ecx - jz .writedone - dec dword [esp] - jnz .write_sector - pop eax -; allocate new cluster - pop eax - mov ecx, eax - call get_free_FAT - jc .diskfull - push edx - mov edx, [ebp+FAT.fatEND] - call set_FAT - xchg eax, ecx - mov edx, ecx + pop eax + pop ecx +.writecommon: + push eax + call fs_write32_app + test eax, eax + pop eax + jnz .writeerr + inc eax + sub dword [esp+12], ecx + jz .writedone + dec dword [esp] + jnz .write_sector + pop eax +; allocate new cluster + pop eax + mov ecx, eax + call get_free_FAT + jc .diskfull + push edx + mov edx, [ebp+FAT.fatEND] + call set_FAT + xchg eax, ecx + mov edx, ecx call set_FAT pop edx xchg eax, ecx jmp .write_cluster .diskfull: - mov eax, ERROR_DISK_FULL - jmp .ret -.writeerr: - pop eax eax - sub esi, ecx - mov eax, ERROR_DEVICE - jmp .ret -.writedone: - pop eax eax -.done: - xor eax, eax -.ret: - pop edi ecx - sub esi, [esp+4+36+20] - mov [esp+4+36+28], eax - mov [esp+4+36+16], esi - lea eax, [esp+12] - call dword [eax+8] - mov [edi+28], esi - call dword [eax+16] - mov [esp+36+16], ebx - lea eax, [esi+511] - shr eax, 9 - mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - lea eax, [eax+ecx-1] - xor edx, edx - div ecx - pop ecx - sub ecx, eax - call add_disk_free_space - add esp, 36 - call update_disk - call fat_unlock - popad - ret -.writedir: - push 512 - lea edi, [ebp+FAT.buffer] - mov ebx, edi - mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - shl ecx, 9 - cmp ecx, [esp+16] - jnz .writedircont - dec dword [esp+20] - push esi - mov ecx, 32/4 - rep movsd + mov eax, ERROR_DISK_FULL + jmp .ret +.writeerr: + pop eax eax + sub esi, ecx + mov eax, ERROR_DEVICE + jmp .ret +.writedone: + pop eax eax +.done: + xor eax, eax +.ret: + pop edi ecx + sub esi, [esp+4+36+20] + mov [esp+4+36+28], eax + mov [esp+4+36+16], esi + lea eax, [esp+12] + call dword [eax+8] + mov [edi+28], esi + call dword [eax+16] + mov [esp+36+16], ebx + lea eax, [esi+511] + shr eax, 9 + mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + lea eax, [eax+ecx-1] + xor edx, edx + div ecx + pop ecx + sub ecx, eax + call add_disk_free_space + add esp, 36 + call update_disk + call fat_unlock + popad + ret +.writedir: + push 512 + lea edi, [ebp+FAT.buffer] + mov ebx, edi + mov ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + shl ecx, 9 + cmp ecx, [esp+16] + jnz .writedircont + dec dword [esp+20] + push esi + mov ecx, 32/4 + rep movsd pop esi mov dword [edi-32], '. ' mov dword [edi-32+4], ' ' @@ -1980,106 +1980,106 @@ fat_Rewrite: rep movsd pop esi mov dword [edi-32], '.. ' - mov dword [edi-32+4], ' ' - mov dword [edi-32+8], ' ' - mov byte [edi-32+11], 10h - mov ecx, [esp+20+36] - cmp ecx, [ebp+FAT.ROOT_CLUSTER] - jnz @f - xor ecx, ecx -@@: + mov dword [edi-32+4], ' ' + mov dword [edi-32+8], ' ' + mov byte [edi-32+11], 10h + mov ecx, [esp+20+36] + cmp ecx, [ebp+FAT.ROOT_CLUSTER] + jnz @f + xor ecx, ecx +@@: mov word [edi-32+26], cx shr ecx, 16 mov [edi-32+20], cx jmp .writedircont ;---------------------------------------------------------------- -; -; fs_HdWrite - LFN variant for writing to hard disk -; -; Obsolete, will be replaced with filesystem-specific functions. -; -; esi points to filename -; ebx pointer to 64-bit number = first wanted byte, 0+ -; may be ebx=0 - start from first byte +; +; fs_HdWrite - LFN variant for writing to hard disk +; +; Obsolete, will be replaced with filesystem-specific functions. +; +; esi points to filename +; ebx pointer to 64-bit number = first wanted byte, 0+ +; may be ebx=0 - start from first byte ; ecx number of bytes to write, 0+ ; edx mem location to data ; ; ret ebx = bytes written (maybe 0) -; eax = 0 ok write or other = errormsg -; -;-------------------------------------------------------------- -fat_Write.access_denied: - push ERROR_ACCESS_DENIED -fs_HdWrite.ret0: - pop eax +; eax = 0 ok write or other = errormsg +; +;-------------------------------------------------------------- +fat_Write.access_denied: + push ERROR_ACCESS_DENIED +fs_HdWrite.ret0: + pop eax xor ebx, ebx - ret - -fs_HdWrite.ret11: - push ERROR_DEVICE - jmp fs_HdWrite.ret0 - -fs_HdWrite: - cmp [fs_type], 16 - jz @f - cmp [fs_type], 32 - jz @f - cmp [fs_type], 1 - jz ntfs_HdWrite - cmp [fs_type], 2 - jz ext2_HdWrite - push ERROR_UNKNOWN_FS - jmp .ret0 -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - call fat_Write - pop ebp - ret - -;---------------------------------------------------------------- -; fat_Write - FAT16/32 implementation of writing to file -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_Write: - cmp byte [esi], 0 - jz .access_denied - call fat_lock - push edi - stdcall hd_find_lfn, [esp+4+4] - jnc .found - pop edi - push eax - call fat_unlock - jmp fs_HdWrite.ret0 -.found: -; FAT does not support files larger than 4GB - cmp dword [ebx+8], 0 - jz @f -.eof: - pop edi - push ERROR_END_OF_FILE - call fat_unlock - jmp fs_HdWrite.ret0 -@@: - mov ecx, [ebx+12] - mov edx, [ebx+16] - mov ebx, [ebx+4] -; now edi points to direntry, ebx=start byte to write, -; ecx=number of bytes to write, edx=data pointer - -; extend file if needed - add ecx, ebx - jc .eof ; FAT does not support files larger than 4GB - push edx - push eax ; save directory sector - push 0 ; return value=0 - + ret + +fs_HdWrite.ret11: + push ERROR_DEVICE + jmp fs_HdWrite.ret0 + +fs_HdWrite: + cmp [fs_type], 16 + jz @f + cmp [fs_type], 32 + jz @f + cmp [fs_type], 1 + jz ntfs_HdWrite + cmp [fs_type], 2 + jz ext2_HdWrite + push ERROR_UNKNOWN_FS + jmp .ret0 +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + call fat_Write + pop ebp + ret + +;---------------------------------------------------------------- +; fat_Write - FAT16/32 implementation of writing to file +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_Write: + cmp byte [esi], 0 + jz .access_denied + call fat_lock + push edi + stdcall hd_find_lfn, [esp+4+4] + jnc .found + pop edi + push eax + call fat_unlock + jmp fs_HdWrite.ret0 +.found: +; FAT does not support files larger than 4GB + cmp dword [ebx+8], 0 + jz @f +.eof: + pop edi + push ERROR_END_OF_FILE + call fat_unlock + jmp fs_HdWrite.ret0 +@@: + mov ecx, [ebx+12] + mov edx, [ebx+16] + mov ebx, [ebx+4] +; now edi points to direntry, ebx=start byte to write, +; ecx=number of bytes to write, edx=data pointer + +; extend file if needed + add ecx, ebx + jc .eof ; FAT does not support files larger than 4GB + push edx + push eax ; save directory sector + push 0 ; return value=0 + call get_time_for_file mov [edi+22], ax ; last write time call get_date_for_file @@ -2095,70 +2095,70 @@ fat_Write: jnc .length_ok mov [esp+4], eax ; hd_extend_file can return three error codes: FAT table error, device error or disk full. -; First two cases are fatal errors, in third case we may write some data - cmp al, ERROR_DISK_FULL - jz .disk_full - call fat_unlock - pop eax - pop eax - pop ecx - pop edx - pop edi - xor ebx, ebx - ret -.disk_full: +; First two cases are fatal errors, in third case we may write some data + cmp al, ERROR_DISK_FULL + jz .disk_full + call fat_unlock + pop eax + pop eax + pop ecx + pop edx + pop edi + xor ebx, ebx + ret +.disk_full: ; correct number of bytes to write - mov ecx, [edi+28] - cmp ecx, ebx - ja .length_ok - push 0 -.ret: - pop eax - sub edx, [esp+12] - mov ebx, edx ; ebx=number of written bytes - call update_disk - test eax, eax - jz @f - mov byte [esp+4], ERROR_DEVICE -@@: - call fat_unlock - pop eax - pop eax - pop ecx - pop edx - pop edi - ret -.length_ok: - mov esi, [edi+28] - mov eax, [edi+20-2] - mov ax, [edi+26] - mov edi, eax ; edi=current cluster - push 0 ; current sector in cluster -; save directory - mov eax, [esp+12] - push ebx - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - pop ebx - test eax, eax - jz @f -.device_err: - mov byte [esp+8], ERROR_DEVICE - jmp .ret -.fat_err: - mov byte [esp+8], ERROR_FAT_TABLE - jmp .ret -@@: - -; now ebx=start pos, ecx=end pos, both lie inside file + mov ecx, [edi+28] + cmp ecx, ebx + ja .length_ok + push 0 +.ret: + pop eax + sub edx, [esp+12] + mov ebx, edx ; ebx=number of written bytes + call update_disk + test eax, eax + jz @f + mov byte [esp+4], ERROR_DEVICE +@@: + call fat_unlock + pop eax + pop eax + pop ecx + pop edx + pop edi + ret +.length_ok: + mov esi, [edi+28] + mov eax, [edi+20-2] + mov ax, [edi+26] + mov edi, eax ; edi=current cluster + push 0 ; current sector in cluster +; save directory + mov eax, [esp+12] + push ebx + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + pop ebx + test eax, eax + jz @f +.device_err: + mov byte [esp+8], ERROR_DEVICE + jmp .ret +.fat_err: + mov byte [esp+8], ERROR_FAT_TABLE + jmp .ret +@@: + +; now ebx=start pos, ecx=end pos, both lie inside file sub ecx, ebx - jz .ret -.write_loop: -; skip unmodified sectors - cmp dword [esp+4], 0x200 - jb .modify - sub ebx, 0x200 - jae .skip + jz .ret +.write_loop: +; skip unmodified sectors + cmp dword [esp+4], 0x200 + jb .modify + sub ebx, 0x200 + jae .skip add ebx, 0x200 .modify: ; get length of data in current sector @@ -2175,147 +2175,147 @@ fat_Write: mov ecx, ebx @@: ; get current sector number - mov eax, edi - dec eax - dec eax - imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] - add eax, [ebp+FAT.DATA_START] - add eax, [esp+4] -; load sector if needed - cmp dword [esp+8], 0 ; we don't need to read uninitialized data - jz .noread - cmp ecx, 0x200 ; we don't need to read sector if it is fully rewritten - jz .noread - cmp ecx, esi ; (same for the last sector) - jz .noread - push eax ebx - lea ebx, [ebp+FAT.buffer] - call fs_read32_app - test eax, eax - pop ebx eax - jz @f -.device_err2: - pop ecx + mov eax, edi + dec eax + dec eax + imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] + add eax, [ebp+FAT.DATA_START] + add eax, [esp+4] +; load sector if needed + cmp dword [esp+8], 0 ; we don't need to read uninitialized data + jz .noread + cmp ecx, 0x200 ; we don't need to read sector if it is fully rewritten + jz .noread + cmp ecx, esi ; (same for the last sector) + jz .noread + push eax ebx + lea ebx, [ebp+FAT.buffer] + call fs_read32_app + test eax, eax + pop ebx eax + jz @f +.device_err2: + pop ecx jmp .device_err @@: .noread: ; zero uninitialized data if file was extended (because hd_extend_file does not this) - push eax ecx edi - xor eax, eax - mov ecx, 0x200 - sub ecx, [esp+8+12] - jbe @f - lea edi, [ebp+FAT.buffer] - add edi, [esp+8+12] - rep stosb -@@: -; zero uninitialized data in the last sector - mov ecx, 0x200 - sub ecx, esi - jbe @f - lea edi, [ebp+FAT.buffer+esi] - rep stosb -@@: - pop edi ecx + push eax ecx edi + xor eax, eax + mov ecx, 0x200 + sub ecx, [esp+8+12] + jbe @f + lea edi, [ebp+FAT.buffer] + add edi, [esp+8+12] + rep stosb +@@: +; zero uninitialized data in the last sector + mov ecx, 0x200 + sub ecx, esi + jbe @f + lea edi, [ebp+FAT.buffer+esi] + rep stosb +@@: + pop edi ecx ; copy new data - mov eax, edx - neg ebx - jecxz @f - lea ebx, [ebp+FAT.buffer+0x200+ebx] - call memmove - xor ebx, ebx -@@: - pop eax -; save sector - push ebx - lea ebx, [ebp+FAT.buffer] - call fs_write32_app - pop ebx - test eax, eax - jnz .device_err2 - add edx, ecx - sub [esp], ecx + mov eax, edx + neg ebx + jecxz @f + lea ebx, [ebp+FAT.buffer+0x200+ebx] + call memmove + xor ebx, ebx +@@: + pop eax +; save sector + push ebx + lea ebx, [ebp+FAT.buffer] + call fs_write32_app + pop ebx + test eax, eax + jnz .device_err2 + add edx, ecx + sub [esp], ecx pop ecx - jz .ret -.skip: -; next sector - pop eax - inc eax - push eax - cmp eax, [ebp+FAT.SECTORS_PER_CLUSTER] - jb @f - and dword [esp], 0 - mov eax, edi - call get_FAT - mov edi, eax - jc .device_err - cmp edi, 2 - jb .fat_err - cmp edi, [ebp+FAT.fatRESERVED] - jae .fat_err -@@: - sub esi, 0x200 - jae @f - xor esi, esi -@@: - sub dword [esp+4], 0x200 - jae @f - and dword [esp+4], 0 -@@: - jmp .write_loop - + jz .ret +.skip: +; next sector + pop eax + inc eax + push eax + cmp eax, [ebp+FAT.SECTORS_PER_CLUSTER] + jb @f + and dword [esp], 0 + mov eax, edi + call get_FAT + mov edi, eax + jc .device_err + cmp edi, 2 + jb .fat_err + cmp edi, [ebp+FAT.fatRESERVED] + jae .fat_err +@@: + sub esi, 0x200 + jae @f + xor esi, esi +@@: + sub dword [esp+4], 0x200 + jae @f + and dword [esp+4], 0 +@@: + jmp .write_loop + hd_extend_file.zero_size: xor eax, eax jmp hd_extend_file.start_extend -; extends file on hd to given size (new data area is undefined) -; in: edi->direntry, ecx=new size -; out: CF=0 => OK, eax=0 -; CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL or ERROR_DEVICE) -hd_extend_file: - push esi - mov esi, [ebp+FAT.SECTORS_PER_CLUSTER] - imul esi, [ebp+FAT.BYTES_PER_SECTOR] - push ecx -; find the last cluster of file - mov eax, [edi+20-2] +; extends file on hd to given size (new data area is undefined) +; in: edi->direntry, ecx=new size +; out: CF=0 => OK, eax=0 +; CF=1 => error, eax=code (ERROR_FAT_TABLE or ERROR_DISK_FULL or ERROR_DEVICE) +hd_extend_file: + push esi + mov esi, [ebp+FAT.SECTORS_PER_CLUSTER] + imul esi, [ebp+FAT.BYTES_PER_SECTOR] + push ecx +; find the last cluster of file + mov eax, [edi+20-2] mov ax, [edi+26] - mov ecx, [edi+28] - jecxz .zero_size -.last_loop: - sub ecx, esi - jbe .last_found - call get_FAT - jnc @f -.device_err: - pop ecx -.device_err2: - pop esi - push ERROR_DEVICE -.ret_err: - pop eax - stc + mov ecx, [edi+28] + jecxz .zero_size +.last_loop: + sub ecx, esi + jbe .last_found + call get_FAT + jnc @f +.device_err: + pop ecx +.device_err2: + pop esi + push ERROR_DEVICE +.ret_err: + pop eax + stc ret -@@: - cmp eax, 2 - jb .fat_err - cmp eax, [ebp+FAT.fatRESERVED] - jb .last_loop -.fat_err: - pop ecx esi - push ERROR_FAT_TABLE - jmp .ret_err -.last_found: - push eax - call get_FAT - jnc @f - pop eax - jmp .device_err -@@: - cmp eax, [ebp+FAT.fatRESERVED] - pop eax - jb .fat_err -; set length to full number of clusters +@@: + cmp eax, 2 + jb .fat_err + cmp eax, [ebp+FAT.fatRESERVED] + jb .last_loop +.fat_err: + pop ecx esi + push ERROR_FAT_TABLE + jmp .ret_err +.last_found: + push eax + call get_FAT + jnc @f + pop eax + jmp .device_err +@@: + cmp eax, [ebp+FAT.fatRESERVED] + pop eax + jb .fat_err +; set length to full number of clusters sub [edi+28], ecx .start_extend: pop ecx @@ -2326,13 +2326,13 @@ hd_extend_file: cmp [edi+28], ecx jae .extend_done ; add new cluster - push eax - call get_free_FAT - jc .disk_full - mov edx, [ebp+FAT.fatEND] - call set_FAT - mov edx, eax - pop eax + push eax + call get_free_FAT + jc .disk_full + mov edx, [ebp+FAT.fatEND] + call set_FAT + mov edx, eax + pop eax test eax, eax jz .first_cluster push edx @@ -2347,468 +2347,468 @@ hd_extend_file: @@: push ecx mov ecx, -1 - call add_disk_free_space - pop ecx - mov eax, edx - add [edi+28], esi - jmp .extend_loop -.extend_done: - mov [edi+28], ecx - pop edx esi - xor eax, eax ; CF=0 - ret -.device_err3: - pop edx - jmp .device_err2 -.disk_full: - pop eax edx esi - push ERROR_DISK_FULL - pop eax - stc - ret - + call add_disk_free_space + pop ecx + mov eax, edx + add [edi+28], esi + jmp .extend_loop +.extend_done: + mov [edi+28], ecx + pop edx esi + xor eax, eax ; CF=0 + ret +.device_err3: + pop edx + jmp .device_err2 +.disk_full: + pop eax edx esi + push ERROR_DISK_FULL + pop eax + stc + ret + ;---------------------------------------------------------------- -; -; fs_HdSetFileEnd - set end of file on hard disk -; -; Obsolete, will be replaced with filesystem-specific functions. -; -; esi points to filename -; ebx points to 64-bit number = new file size -; ecx ignored (reserved) +; +; fs_HdSetFileEnd - set end of file on hard disk +; +; Obsolete, will be replaced with filesystem-specific functions. +; +; esi points to filename +; ebx points to 64-bit number = new file size +; ecx ignored (reserved) ; edx ignored (reserved) ; ; ret eax = 0 ok or other = errormsg -; -;-------------------------------------------------------------- -fs_HdSetFileEnd: - cmp [fs_type], 16 - jz @f - cmp [fs_type], 32 - jz @f - cmp [fs_type], 1 - jz ntfs_HdSetFileEnd - cmp [fs_type], 2 - jz ext2_HdSetFileEnd - push ERROR_UNKNOWN_FS - pop eax - ret -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - call fat_SetFileEnd - pop ebp - ret - -;---------------------------------------------------------------- -; fat_SetFileEnd - FAT16/32 implementation of setting end-of-file -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_SetFileEnd: - call fat_lock - push edi - cmp byte [esi], 0 - jnz @f -.access_denied: - push ERROR_ACCESS_DENIED -.ret: - call fat_unlock - pop eax - pop edi - ret -@@: - stdcall hd_find_lfn, [esp+4+4] - jnc @f -.reteax: - push eax - jmp .ret -@@: -; must not be directory - test byte [edi+11], 10h - jnz .access_denied -; file size must not exceed 4 Gb - cmp dword [ebx+8], 0 - jz @f - push ERROR_END_OF_FILE - jmp .ret -@@: - push eax ; save directory sector -; set file modification date/time to current - call fat_update_datetime - mov eax, [ebx+4] - cmp eax, [edi+28] - jb .truncate - ja .expand - pop eax - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - pop edi - test eax, eax - jz @f - push ERROR_DEVICE - jmp .ret -@@: - push 0 - jmp .ret -.expand: - push ebx ebp ecx - push dword [edi+28] ; save old size +; +;-------------------------------------------------------------- +fs_HdSetFileEnd: + cmp [fs_type], 16 + jz @f + cmp [fs_type], 32 + jz @f + cmp [fs_type], 1 + jz ntfs_HdSetFileEnd + cmp [fs_type], 2 + jz ext2_HdSetFileEnd + push ERROR_UNKNOWN_FS + pop eax + ret +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + call fat_SetFileEnd + pop ebp + ret + +;---------------------------------------------------------------- +; fat_SetFileEnd - FAT16/32 implementation of setting end-of-file +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_SetFileEnd: + call fat_lock + push edi + cmp byte [esi], 0 + jnz @f +.access_denied: + push ERROR_ACCESS_DENIED +.ret: + call fat_unlock + pop eax + pop edi + ret +@@: + stdcall hd_find_lfn, [esp+4+4] + jnc @f +.reteax: + push eax + jmp .ret +@@: +; must not be directory + test byte [edi+11], 10h + jnz .access_denied +; file size must not exceed 4 Gb + cmp dword [ebx+8], 0 + jz @f + push ERROR_END_OF_FILE + jmp .ret +@@: + push eax ; save directory sector +; set file modification date/time to current + call fat_update_datetime + mov eax, [ebx+4] + cmp eax, [edi+28] + jb .truncate + ja .expand + pop eax + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + pop edi + test eax, eax + jz @f + push ERROR_DEVICE + jmp .ret +@@: + push 0 + jmp .ret +.expand: + push ebx ebp ecx + push dword [edi+28] ; save old size mov ecx, eax call hd_extend_file push eax ; return code jnc .expand_ok cmp al, ERROR_DISK_FULL - jz .disk_full -.pop_ret: - call update_disk - pop eax ecx ecx ebp ebx ecx - jmp .reteax -.expand_ok: -.disk_full: -; save directory - mov eax, [edi+28] - xchg eax, [esp+20] - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - test eax, eax - mov eax, [edi+20-2] - mov ax, [edi+26] - mov edi, eax - jz @f -.pop_ret11: - mov byte [esp], ERROR_DEVICE - jmp .pop_ret -@@: - test edi, edi - jz .pop_ret -; now zero new data - push 0 -; edi=current cluster, [esp]=sector in cluster -; [esp+24]=new size, [esp+8]=old size, [esp+4]=return code -.zero_loop: - cmp edi, 2 - jb .error_fat - cmp edi, [ebp+FAT.fatRESERVED] - jae .error_fat - sub dword [esp+8], 0x200 - jae .next_cluster - lea eax, [edi-2] - imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] - add eax, [ebp+FAT.DATA_START] - add eax, [esp] - cmp dword [esp+8], -0x200 - jz .noread - push eax - lea ebx, [ebp+FAT.buffer] - call fs_read32_app - test eax, eax - pop eax - jnz .err_next -.noread: - mov ecx, [esp+8] - neg ecx - push edi - lea edi, [ebp+FAT.buffer+0x200] - add edi, [esp+12] - push eax - xor eax, eax - mov [esp+16], eax - rep stosb - pop eax - pop edi - call fs_write32_app - test eax, eax - jz .next_cluster -.err_next: - mov byte [esp+4], ERROR_DEVICE -.next_cluster: - pop eax - sub dword [esp+20], 0x200 - jbe .pop_ret - inc eax - push eax - cmp eax, [ebp+FAT.SECTORS_PER_CLUSTER] - jb .zero_loop - and dword [esp], 0 - mov eax, edi - call get_FAT - mov edi, eax - jnc .zero_loop - pop eax - jmp .pop_ret11 -.truncate: - mov [edi+28], eax - push ecx + jz .disk_full +.pop_ret: + call update_disk + pop eax ecx ecx ebp ebx ecx + jmp .reteax +.expand_ok: +.disk_full: +; save directory + mov eax, [edi+28] + xchg eax, [esp+20] + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + test eax, eax + mov eax, [edi+20-2] + mov ax, [edi+26] + mov edi, eax + jz @f +.pop_ret11: + mov byte [esp], ERROR_DEVICE + jmp .pop_ret +@@: + test edi, edi + jz .pop_ret +; now zero new data + push 0 +; edi=current cluster, [esp]=sector in cluster +; [esp+24]=new size, [esp+8]=old size, [esp+4]=return code +.zero_loop: + cmp edi, 2 + jb .error_fat + cmp edi, [ebp+FAT.fatRESERVED] + jae .error_fat + sub dword [esp+8], 0x200 + jae .next_cluster + lea eax, [edi-2] + imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] + add eax, [ebp+FAT.DATA_START] + add eax, [esp] + cmp dword [esp+8], -0x200 + jz .noread + push eax + lea ebx, [ebp+FAT.buffer] + call fs_read32_app + test eax, eax + pop eax + jnz .err_next +.noread: + mov ecx, [esp+8] + neg ecx + push edi + lea edi, [ebp+FAT.buffer+0x200] + add edi, [esp+12] + push eax + xor eax, eax + mov [esp+16], eax + rep stosb + pop eax + pop edi + call fs_write32_app + test eax, eax + jz .next_cluster +.err_next: + mov byte [esp+4], ERROR_DEVICE +.next_cluster: + pop eax + sub dword [esp+20], 0x200 + jbe .pop_ret + inc eax + push eax + cmp eax, [ebp+FAT.SECTORS_PER_CLUSTER] + jb .zero_loop + and dword [esp], 0 + mov eax, edi + call get_FAT + mov edi, eax + jnc .zero_loop + pop eax + jmp .pop_ret11 +.truncate: + mov [edi+28], eax + push ecx mov ecx, [edi+20-2] mov cx, [edi+26] push eax test eax, eax - jz .zero_size -; find new last cluster -@@: - cmp ecx, 2 - jb .error_fat2 - cmp ecx, [ebp+FAT.fatRESERVED] - jae .error_fat2 - mov eax, [ebp+FAT.SECTORS_PER_CLUSTER] - shl eax, 9 - sub [esp], eax - jbe @f - mov eax, ecx - call get_FAT - mov ecx, eax - jnc @b -.device_err3: - pop eax ecx eax edi - call update_disk - call fat_unlock - push ERROR_DEVICE - pop eax - ret -@@: + jz .zero_size +; find new last cluster +@@: + cmp ecx, 2 + jb .error_fat2 + cmp ecx, [ebp+FAT.fatRESERVED] + jae .error_fat2 + mov eax, [ebp+FAT.SECTORS_PER_CLUSTER] + shl eax, 9 + sub [esp], eax + jbe @f + mov eax, ecx + call get_FAT + mov ecx, eax + jnc @b +.device_err3: + pop eax ecx eax edi + call update_disk + call fat_unlock + push ERROR_DEVICE + pop eax + ret +@@: ; we will zero data at the end of last sector - remember it push ecx -; terminate FAT chain - push edx - mov eax, ecx - mov edx, [ebp+FAT.fatEND] - call set_FAT - mov eax, edx - pop edx - jnc @f -.device_err4: - pop ecx - jmp .device_err3 +; terminate FAT chain + push edx + mov eax, ecx + mov edx, [ebp+FAT.fatEND] + call set_FAT + mov eax, edx + pop edx + jnc @f +.device_err4: + pop ecx + jmp .device_err3 .zero_size: and word [edi+20], 0 and word [edi+26], 0 push 0 mov eax, ecx -@@: -; delete FAT chain - call clear_cluster_chain - jc .device_err4 -; save directory - mov eax, [esp+12] - push ebx - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - pop ebx - test eax, eax - jnz .device_err4 -; zero last sector, ignore errors - pop ecx - pop eax - dec ecx - imul ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - add ecx, [ebp+FAT.DATA_START] - push eax - sar eax, 9 - add ecx, eax +@@: +; delete FAT chain + call clear_cluster_chain + jc .device_err4 +; save directory + mov eax, [esp+12] + push ebx + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + pop ebx + test eax, eax + jnz .device_err4 +; zero last sector, ignore errors + pop ecx + pop eax + dec ecx + imul ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + add ecx, [ebp+FAT.DATA_START] + push eax + sar eax, 9 + add ecx, eax pop eax and eax, 0x1FF - jz .truncate_done - push ebx eax - mov eax, ecx - lea ebx, [ebp+FAT.buffer] - call fs_read32_app - pop eax - lea edi, [ebp+FAT.buffer+eax] - push ecx - mov ecx, 0x200 - sub ecx, eax - xor eax, eax - rep stosb - pop eax - call fs_write32_app - pop ebx -.truncate_done: - pop ecx eax edi - call update_disk - call fat_unlock - xor eax, eax - ret -.error_fat: - pop eax - mov byte [esp], ERROR_FAT_TABLE - jmp .pop_ret -.error_fat2: - pop eax ecx eax edi - call update_disk - call fat_unlock - push ERROR_FAT_TABLE - pop eax - ret - -fs_HdGetFileInfo: - cmp [fs_type], 16 - jz @f - cmp [fs_type], 32 - jz @f - cmp [fs_type], 1 - jz ntfs_HdGetFileInfo - cmp [fs_type], 2 - jz ext2_HdGetFileInfo - mov eax, ERROR_UNKNOWN_FS - ret -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - call fat_GetFileInfo - pop ebp - ret - -;---------------------------------------------------------------- -; fat_GetFileInfo - FAT16/32 implementation of getting file info -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_GetFileInfo: - cmp byte [esi], 0 - jnz @f - mov eax, 2 - ret -@@: - push edi - call fat_lock - stdcall hd_find_lfn, [esp+4+4] - jc .error - push ebp - xor ebp, ebp - mov esi, [ebx+16] - mov dword [esi+4], ebp - call fat_entry_to_bdfe2 - pop ebp - call fat_unlock - xor eax, eax - pop edi - ret -.error: - push eax - call fat_unlock - pop eax - pop edi - ret - -fs_HdSetFileInfo: - cmp [fs_type], 16 - jz @f - cmp [fs_type], 32 - jz @f - cmp [fs_type], 1 - jz ntfs_HdSetFileInfo - cmp [fs_type], 2 - jz ext2_HdSetFileInfo - mov eax, ERROR_UNKNOWN_FS - ret -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - call fat_SetFileInfo - pop ebp - ret - -;---------------------------------------------------------------- -; fat_SetFileInfo - FAT16/32 implementation of setting file info -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_SetFileInfo: - cmp byte [esi], 0 - jnz @f - mov eax, 2 - ret -@@: - push edi - call fat_lock - stdcall hd_find_lfn, [esp+4+4] - jc .error - push eax - mov edx, [ebx+16] - call bdfe_to_fat_entry - pop eax - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - call update_disk - call fat_unlock - pop edi - xor eax, eax - ret -.error: - push eax - call fat_unlock - pop eax - pop edi - ret - -;---------------------------------------------------------------- -; -; fs_HdDelete - delete file or empty folder from hard disk -; -; Obsolete, will be replaced with filesystem-specific functions. -; -; esi points to filename -; -; ret eax = 0 ok or other = errormsg -; -;-------------------------------------------------------------- -fs_HdDelete: - cmp [fs_type], 16 - jz @f - cmp [fs_type], 32 - jz @f - cmp [fs_type], 1 - jz ntfs_HdDelete - cmp [fs_type], 2 - jz ext2_HdDelete - push ERROR_UNKNOWN_FS - pop eax - ret -@@: - sub ebx, 4 - push ebp - mov ebp, [fs_dependent_data_start.partition] - call fat_Delete - pop ebp - ret - -;---------------------------------------------------------------- -; fat_Delete - FAT16/32 implementation of deleting a file/folder -; in: ebp = pointer to FAT structure -; in: esi+[esp+4] = name -; in: ebx = pointer to parameters from sysfunc 70 -; out: eax, ebx = return values for sysfunc 70 -;---------------------------------------------------------------- -fat_Delete: - call fat_lock - cmp byte [esi], 0 - jnz @f -; cannot delete root! -.access_denied: - push ERROR_ACCESS_DENIED -.pop_ret: - call fat_unlock - pop eax - xor ebx, ebx - ret -@@: - and [ebp+FAT.longname_sec1], 0 - and [ebp+FAT.longname_sec2], 0 - push edi - stdcall hd_find_lfn, [esp+4+4] - jnc .found - pop edi - push ERROR_FILE_NOT_FOUND + jz .truncate_done + push ebx eax + mov eax, ecx + lea ebx, [ebp+FAT.buffer] + call fs_read32_app + pop eax + lea edi, [ebp+FAT.buffer+eax] + push ecx + mov ecx, 0x200 + sub ecx, eax + xor eax, eax + rep stosb + pop eax + call fs_write32_app + pop ebx +.truncate_done: + pop ecx eax edi + call update_disk + call fat_unlock + xor eax, eax + ret +.error_fat: + pop eax + mov byte [esp], ERROR_FAT_TABLE + jmp .pop_ret +.error_fat2: + pop eax ecx eax edi + call update_disk + call fat_unlock + push ERROR_FAT_TABLE + pop eax + ret + +fs_HdGetFileInfo: + cmp [fs_type], 16 + jz @f + cmp [fs_type], 32 + jz @f + cmp [fs_type], 1 + jz ntfs_HdGetFileInfo + cmp [fs_type], 2 + jz ext2_HdGetFileInfo + mov eax, ERROR_UNKNOWN_FS + ret +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + call fat_GetFileInfo + pop ebp + ret + +;---------------------------------------------------------------- +; fat_GetFileInfo - FAT16/32 implementation of getting file info +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_GetFileInfo: + cmp byte [esi], 0 + jnz @f + mov eax, 2 + ret +@@: + push edi + call fat_lock + stdcall hd_find_lfn, [esp+4+4] + jc .error + push ebp + xor ebp, ebp + mov esi, [ebx+16] + mov dword [esi+4], ebp + call fat_entry_to_bdfe2 + pop ebp + call fat_unlock + xor eax, eax + pop edi + ret +.error: + push eax + call fat_unlock + pop eax + pop edi + ret + +fs_HdSetFileInfo: + cmp [fs_type], 16 + jz @f + cmp [fs_type], 32 + jz @f + cmp [fs_type], 1 + jz ntfs_HdSetFileInfo + cmp [fs_type], 2 + jz ext2_HdSetFileInfo + mov eax, ERROR_UNKNOWN_FS + ret +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + call fat_SetFileInfo + pop ebp + ret + +;---------------------------------------------------------------- +; fat_SetFileInfo - FAT16/32 implementation of setting file info +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_SetFileInfo: + cmp byte [esi], 0 + jnz @f + mov eax, 2 + ret +@@: + push edi + call fat_lock + stdcall hd_find_lfn, [esp+4+4] + jc .error + push eax + mov edx, [ebx+16] + call bdfe_to_fat_entry + pop eax + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + call update_disk + call fat_unlock + pop edi + xor eax, eax + ret +.error: + push eax + call fat_unlock + pop eax + pop edi + ret + +;---------------------------------------------------------------- +; +; fs_HdDelete - delete file or empty folder from hard disk +; +; Obsolete, will be replaced with filesystem-specific functions. +; +; esi points to filename +; +; ret eax = 0 ok or other = errormsg +; +;-------------------------------------------------------------- +fs_HdDelete: + cmp [fs_type], 16 + jz @f + cmp [fs_type], 32 + jz @f + cmp [fs_type], 1 + jz ntfs_HdDelete + cmp [fs_type], 2 + jz ext2_HdDelete + push ERROR_UNKNOWN_FS + pop eax + ret +@@: + sub ebx, 4 + push ebp + mov ebp, [fs_dependent_data_start.partition] + call fat_Delete + pop ebp + ret + +;---------------------------------------------------------------- +; fat_Delete - FAT16/32 implementation of deleting a file/folder +; in: ebp = pointer to FAT structure +; in: esi+[esp+4] = name +; in: ebx = pointer to parameters from sysfunc 70 +; out: eax, ebx = return values for sysfunc 70 +;---------------------------------------------------------------- +fat_Delete: + call fat_lock + cmp byte [esi], 0 + jnz @f +; cannot delete root! +.access_denied: + push ERROR_ACCESS_DENIED +.pop_ret: + call fat_unlock + pop eax + xor ebx, ebx + ret +@@: + and [ebp+FAT.longname_sec1], 0 + and [ebp+FAT.longname_sec2], 0 + push edi + stdcall hd_find_lfn, [esp+4+4] + jnc .found + pop edi + push ERROR_FILE_NOT_FOUND jmp .pop_ret .found: cmp dword [edi], '. ' @@ -2816,128 +2816,128 @@ fat_Delete: cmp dword [edi], '.. ' jz .access_denied2 test byte [edi+11], 10h - jz .dodel -; we can delete only empty folders! - pushad - mov esi, [edi+20-2] - mov si, [edi+26] - xor ecx, ecx - lea eax, [esi-2] - imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] - add eax, [ebp+FAT.DATA_START] - lea ebx, [ebp+FAT.buffer] - call fs_read32_sys - test eax, eax - jnz .err1 - lea eax, [ebx+0x200] - add ebx, 2*0x20 -.checkempty: - cmp byte [ebx], 0 + jz .dodel +; we can delete only empty folders! + pushad + mov esi, [edi+20-2] + mov si, [edi+26] + xor ecx, ecx + lea eax, [esi-2] + imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] + add eax, [ebp+FAT.DATA_START] + lea ebx, [ebp+FAT.buffer] + call fs_read32_sys + test eax, eax + jnz .err1 + lea eax, [ebx+0x200] + add ebx, 2*0x20 +.checkempty: + cmp byte [ebx], 0 jz .empty - cmp byte [ebx], 0xE5 - jnz .notempty - add ebx, 0x20 - cmp ebx, eax - jb .checkempty - inc ecx - cmp ecx, [ebp+FAT.SECTORS_PER_CLUSTER] - jb @f - mov eax, esi - call get_FAT - jc .err1 - cmp eax, 2 - jb .error_fat - cmp eax, [ebp+FAT.fatRESERVED] - jae .empty - mov esi, eax - xor ecx, ecx -@@: - lea eax, [esi-2] - imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] - add eax, [ebp+FAT.DATA_START] - add eax, ecx - lea ebx, [ebp+FAT.buffer] - call fs_read32_sys - test eax, eax - lea eax, [ebx+0x200] - jz .checkempty -.err1: - popad -.err2: - pop edi - call fat_unlock - push ERROR_DEVICE - pop eax - ret -.error_fat: - popad - pop edi - call fat_unlock - push ERROR_FAT_TABLE - pop eax - ret -.notempty: - popad -.access_denied2: - pop edi - call fat_unlock - push ERROR_ACCESS_DENIED - pop eax - ret -.empty: - popad - push eax ebx - lea ebx, [ebp+FAT.buffer] - call fs_read32_sys - test eax, eax - pop ebx eax - jnz .err2 -.dodel: - push eax + cmp byte [ebx], 0xE5 + jnz .notempty + add ebx, 0x20 + cmp ebx, eax + jb .checkempty + inc ecx + cmp ecx, [ebp+FAT.SECTORS_PER_CLUSTER] + jb @f + mov eax, esi + call get_FAT + jc .err1 + cmp eax, 2 + jb .error_fat + cmp eax, [ebp+FAT.fatRESERVED] + jae .empty + mov esi, eax + xor ecx, ecx +@@: + lea eax, [esi-2] + imul eax, [ebp+FAT.SECTORS_PER_CLUSTER] + add eax, [ebp+FAT.DATA_START] + add eax, ecx + lea ebx, [ebp+FAT.buffer] + call fs_read32_sys + test eax, eax + lea eax, [ebx+0x200] + jz .checkempty +.err1: + popad +.err2: + pop edi + call fat_unlock + push ERROR_DEVICE + pop eax + ret +.error_fat: + popad + pop edi + call fat_unlock + push ERROR_FAT_TABLE + pop eax + ret +.notempty: + popad +.access_denied2: + pop edi + call fat_unlock + push ERROR_ACCESS_DENIED + pop eax + ret +.empty: + popad + push eax ebx + lea ebx, [ebp+FAT.buffer] + call fs_read32_sys + test eax, eax + pop ebx eax + jnz .err2 +.dodel: + push eax mov eax, [edi+20-2] mov ax, [edi+26] xchg eax, [esp] ; delete folder entry - mov byte [edi], 0xE5 -; delete LFN (if present) -.lfndel: - lea edx, [ebp+FAT.buffer] - cmp edi, edx - ja @f - cmp [ebp+FAT.longname_sec2], 0 - jz .lfndone - push [ebp+FAT.longname_sec2] - push [ebp+FAT.longname_sec1] - pop [ebp+FAT.longname_sec2] - and [ebp+FAT.longname_sec1], 0 - push ebx - mov ebx, edx - call fs_write32_sys - mov eax, [esp+4] - call fs_read32_sys - pop ebx - pop eax - lea edi, [ebp+FAT.buffer+0x200] -@@: - sub edi, 0x20 - cmp byte [edi], 0xE5 + mov byte [edi], 0xE5 +; delete LFN (if present) +.lfndel: + lea edx, [ebp+FAT.buffer] + cmp edi, edx + ja @f + cmp [ebp+FAT.longname_sec2], 0 + jz .lfndone + push [ebp+FAT.longname_sec2] + push [ebp+FAT.longname_sec1] + pop [ebp+FAT.longname_sec2] + and [ebp+FAT.longname_sec1], 0 + push ebx + mov ebx, edx + call fs_write32_sys + mov eax, [esp+4] + call fs_read32_sys + pop ebx + pop eax + lea edi, [ebp+FAT.buffer+0x200] +@@: + sub edi, 0x20 + cmp byte [edi], 0xE5 jz .lfndone cmp byte [edi+11], 0xF jnz .lfndone mov byte [edi], 0xE5 - jmp .lfndel -.lfndone: - push ebx - lea ebx, [ebp+FAT.buffer] - call fs_write32_sys - pop ebx -; delete FAT chain - pop eax - call clear_cluster_chain - call update_disk - call fat_unlock - pop edi - xor eax, eax - ret - -; \end{diamond} + jmp .lfndel +.lfndone: + push ebx + lea ebx, [ebp+FAT.buffer] + call fs_write32_sys + pop ebx +; delete FAT chain + pop eax + call clear_cluster_chain + call update_disk + call fat_unlock + pop edi + xor eax, eax + ret + +; \end{diamond} diff --git a/kernel/branches/net/fs/fs-sp.inc b/kernel/branches/net/fs/fs-sp.inc new file mode 100644 index 0000000000..a7e64e12ac --- /dev/null +++ b/kernel/branches/net/fs/fs-sp.inc @@ -0,0 +1,13 @@ +dir0: + db 'DISCO DURO ' + db 'UNIDAD RAM ' + db 'DISQUETE ' + db 0 + +dir1: + db 'PRIMERO ' + db 'SEGUNDO ' + db 'TERCERO ' + db 'CUARTO ' + db 0 + diff --git a/kernel/branches/net/fs/fs.inc b/kernel/branches/net/fs/fs.inc index 6f22526b9a..2d3fdeecd0 100644 --- a/kernel/branches/net/fs/fs.inc +++ b/kernel/branches/net/fs/fs.inc @@ -21,6 +21,10 @@ $Revision $ iglobal + +if lang eq sp +include 'fs/fs-sp.inc' +else dir0: db 'HARDDISK ' db 'RAMDISK ' @@ -33,6 +37,7 @@ dir1: db 'THIRD ' db 'FOURTH ' db 0 +end if not_select_IDE db 0 @@ -166,12 +171,12 @@ endg and dword [esp+36], 0; ok read mov dword [esp+24], 32*2; size of root ret - - fs_info: ;start of code - Mihasik - push eax - cmp [eax+21], byte 'r' - je fs_info_r - cmp [eax+21], byte 'R' + + fs_info: ;start of code - Mihasik + push eax + cmp [eax+21], byte 'r' + je fs_info_r + cmp [eax+21], byte 'R' je fs_info_r mov eax, 3 ;if unknown disk xor ebx, ebx @@ -182,12 +187,12 @@ endg call ramdisk_free_space;if ramdisk mov ecx, edi ;free space in ecx shr ecx, 9 ;free clusters - mov ebx, 2847 ;total clusters - mov edx, 512 ;cluster size - xor eax, eax ;always 0 - fs_info1: - pop edi - mov [esp+36], eax + mov ebx, 2847 ;total clusters + mov edx, 512 ;cluster size + xor eax, eax ;always 0 + fs_info1: + pop edi + mov [esp+36], eax mov [esp+24], ebx ; total clusters on disk mov [esp+32], ecx ; free clusters on disk mov [edi], edx ; cluster size in bytes @@ -427,15 +432,15 @@ choice_necessity_partition_1: hd_err_return: call free_hd_channel and [hd1_status], 0 - jmp file_system_return -@@: - - call free_hd_channel - and [hd1_status], 0 - - fs_noharddisk: -; \begin{diamond}[18.03.2006] - mov eax, 5 ; file not found + jmp file_system_return +@@: + + call free_hd_channel + and [hd1_status], 0 + + fs_noharddisk: +; \begin{diamond}[18.03.2006] + mov eax, 5 ; file not found ; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè? mov ebx, [esp+24+24]; do not change ebx in application ; \end{diamond}[18.03.2006] diff --git a/kernel/branches/net/fs/fs_lfn.inc b/kernel/branches/net/fs/fs_lfn.inc index ef97f6295e..a8964b71f3 100644 --- a/kernel/branches/net/fs/fs_lfn.inc +++ b/kernel/branches/net/fs/fs_lfn.inc @@ -134,6 +134,15 @@ fs_additional_handlers: endg +file_system_lfn_protected: + pushad + call protect_from_terminate + call file_system_lfn + call unprotect_from_terminate + popad + mov [image_of_eax], eax + mov [image_of_ebx], ebx + ret file_system_lfn: ; in: ebx->fileinfo block diff --git a/kernel/branches/net/fs/part_set.inc b/kernel/branches/net/fs/part_set.inc index 235ca8223e..0dae14df83 100644 --- a/kernel/branches/net/fs/part_set.inc +++ b/kernel/branches/net/fs/part_set.inc @@ -30,15 +30,15 @@ PARTITION_END dd 0 fs_type db 0 ; 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32 align 4 -fs_dependent_data_start: -; FATxx data - -.partition dd ? - rb 80 - -fs_dependent_data_end: -file_system_data_size = $ - PARTITION_START -if file_system_data_size > 96 +fs_dependent_data_start: +; FATxx data + +.partition dd ? + rb 80 + +fs_dependent_data_end: +file_system_data_size = $ - PARTITION_START +if file_system_data_size > 96 ERROR: sizeof(file system data) too big! end if @@ -69,12 +69,12 @@ virtual at fs_dependent_data_start ; EXT2 data ext2_data: .log_block_size dd ? - .block_size dd ? - .count_block_in_block dd ? - .blocks_per_group dd ? - .global_desc_table dd ? - .root_inode dd ? ; pointer to root inode in memory - .inode_size dd ? + .block_size dd ? + .count_block_in_block dd ? + .blocks_per_group dd ? + .global_desc_table dd ? + .root_inode dd ? ; pointer to root inode in memory + .inode_size dd ? .count_pointer_in_block dd ? ; block_size / 4 .count_pointer_in_block_square dd ? ; (block_size / 4)**2 .ext2_save_block dd ? ; ¡«®ª ­  £«®¡ «ì­ãî 1 ¯à®æ¥€ãàã @@ -407,30 +407,30 @@ boot_read_ok: mov eax, [PARTITION_START] ;ext2 test changes [buffer] call hd_read - cmp [hd_error], 0 - jnz problem_fat_dec_count - - push 0 - mov eax, [PARTITION_END] - sub eax, [PARTITION_START] - inc eax - push eax - push 0 - push [PARTITION_START] - push ebp - push ebp - mov ebp, esp - mov esi, 'old' ; special value: there is no DISK structure - push 1 ; bootsector read successfully - call fat_create_partition - add esp, 4*7 - test eax, eax - jz problem_fat_dec_count - mov [fs_dependent_data_start.partition], eax - mov al, [eax+FAT.fs_type] - mov [fs_type], al - - popad - call free_hd_channel - mov [hd1_status], 0 ; free - ret + cmp [hd_error], 0 + jnz problem_fat_dec_count + + push 0 + mov eax, [PARTITION_END] + sub eax, [PARTITION_START] + inc eax + push eax + push 0 + push [PARTITION_START] + push ebp + push ebp + mov ebp, esp + mov esi, 'old' ; special value: there is no DISK structure + push 1 ; bootsector read successfully + call fat_create_partition + add esp, 4*7 + test eax, eax + jz problem_fat_dec_count + mov [fs_dependent_data_start.partition], eax + mov al, [eax+FAT.fs_type] + mov [fs_type], al + + popad + call free_hd_channel + mov [hd1_status], 0 ; free + ret diff --git a/kernel/branches/net/gui/event.inc b/kernel/branches/net/gui/event.inc index 8601e2fa5f..2b715ddd7f 100644 --- a/kernel/branches/net/gui/event.inc +++ b/kernel/branches/net/gui/event.inc @@ -467,9 +467,11 @@ sys_waitforevent: ;; f10 ;-------------------------------------- align 4 sys_wait_event_timeout: ;; f23 + call unprotect_from_terminate mov edx, get_event_for_app; wait_test call Wait_events_ex ; ebx - timeout mov [esp+32], eax + call protect_from_terminate ret ;----------------------------------------------------------------------------- align 4 diff --git a/kernel/branches/net/gui/font.inc b/kernel/branches/net/gui/font.inc index 1f3b3c57ff..c0d563875d 100644 --- a/kernel/branches/net/gui/font.inc +++ b/kernel/branches/net/gui/font.inc @@ -225,15 +225,15 @@ draw_text_to_user_area: add eax, 8 and ecx, 0xffffff or ecx, 0xff000000 ; not transparent - mov [eax], ecx ; store pixel - popad - ret -;------------------------------------------------------------------------------ -align 4 -FONT_I: - file 'char.mt' -;------------------------------------------------------------------------------ -align 4 -FONT_II: - file 'char2.mt' + mov [eax], ecx ; store pixel + popad + ret +;------------------------------------------------------------------------------ +align 4 +FONT_I: + file 'char.mt' +;------------------------------------------------------------------------------ +align 4 +FONT_II: + file 'char2.mt' ;------------------------------------------------------------------------------ \ No newline at end of file diff --git a/kernel/branches/net/gui/mouse.inc b/kernel/branches/net/gui/mouse.inc index e5885e933e..399f8c4fa4 100644 --- a/kernel/branches/net/gui/mouse.inc +++ b/kernel/branches/net/gui/mouse.inc @@ -255,14 +255,14 @@ mouse._.left_button_press_handler: ;/////////////////////////////////////////// @@: test dl, mouse.WINDOW_RESIZE_E_FLAG jz .call_window_handler - call .calculate_e_delta - - .call_window_handler: -; mov eax, mouse.active_sys_window.old_box -; call sys_window_start_moving_handler - - .exit: - ret + call .calculate_e_delta + + .call_window_handler: +; mov eax, mouse.active_sys_window.old_box +; call sys_window_start_moving_handler + + .exit: + ret .calculate_n_delta: mov eax, [mouse.state.pos.y] diff --git a/kernel/branches/net/gui/mousepointer.inc b/kernel/branches/net/gui/mousepointer.inc index e5c1393dd7..ca12e3d081 100644 --- a/kernel/branches/net/gui/mousepointer.inc +++ b/kernel/branches/net/gui/mousepointer.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; 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 ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; 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: 2288 $ diff --git a/kernel/branches/net/gui/window.inc b/kernel/branches/net/gui/window.inc index e077eaddcd..09643277ef 100644 --- a/kernel/branches/net/gui/window.inc +++ b/kernel/branches/net/gui/window.inc @@ -1023,61 +1023,61 @@ align 4 mov byte[MOUSE_DOWN], 0 inc eax ret -;------------------------------------------------------------------------------ -align 4 -;------------------------------------------------------------------------------ -minimize_all_window: - push ebx ecx edx esi edi - pushfd - cli - xor edx, edx - mov eax, 2 ; we do not minimize the kernel thread N1 - mov ebx, [TASK_COUNT] -;-------------------------------------- -align 4 -.loop: - movzx edi, word[WIN_POS + eax * 2] - shl edi, 5 -; it is a unused slot? - cmp dword [edi+CURRENT_TASK+TASKDATA.state], 9 - je @f -; it is a hidden thread? - lea esi, [edi*8+SLOT_BASE+APPDATA.app_name] - cmp [esi], byte '@' - je @f -; is it already minimized? - test [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED - jnz @f -; no it's not, let's do that - or [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED - inc edx -;-------------------------------------- -align 4 -@@: - inc eax - cmp eax, ebx - jbe .loop -; If nothing has changed - test edx, edx - jz @f - - push edx - call syscall_display_settings._.calculate_whole_screen - call syscall_display_settings._.redraw_whole_screen - pop edx -;-------------------------------------- -align 4 -@@: - mov eax, edx - popfd - pop edi esi edx ecx ebx - ret -;------------------------------------------------------------------------------ -align 4 -;------------------------------------------------------------------------------ -minimize_window: ;///////////////////////////////////////////////////////////// -;------------------------------------------------------------------------------ -;> eax = window number on screen +;------------------------------------------------------------------------------ +align 4 +;------------------------------------------------------------------------------ +minimize_all_window: + push ebx ecx edx esi edi + pushfd + cli + xor edx, edx + mov eax, 2 ; we do not minimize the kernel thread N1 + mov ebx, [TASK_COUNT] +;-------------------------------------- +align 4 +.loop: + movzx edi, word[WIN_POS + eax * 2] + shl edi, 5 +; it is a unused slot? + cmp dword [edi+CURRENT_TASK+TASKDATA.state], 9 + je @f +; it is a hidden thread? + lea esi, [edi*8+SLOT_BASE+APPDATA.app_name] + cmp [esi], byte '@' + je @f +; is it already minimized? + test [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED + jnz @f +; no it's not, let's do that + or [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED + inc edx +;-------------------------------------- +align 4 +@@: + inc eax + cmp eax, ebx + jbe .loop +; If nothing has changed + test edx, edx + jz @f + + push edx + call syscall_display_settings._.calculate_whole_screen + call syscall_display_settings._.redraw_whole_screen + pop edx +;-------------------------------------- +align 4 +@@: + mov eax, edx + popfd + pop edi esi edx ecx ebx + ret +;------------------------------------------------------------------------------ +align 4 +;------------------------------------------------------------------------------ +minimize_window: ;///////////////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +;> eax = window number on screen ;------------------------------------------------------------------------------ ;# corrupts [dl*] ;------------------------------------------------------------------------------ @@ -1093,43 +1093,43 @@ minimize_window: ;///////////////////////////////////////////////////////////// jnz .exit push eax ebx ecx edx esi - - ; no it's not, let's do that - or [edi + WDATA.fl_wstate], WSTATE_MINIMIZED -; If the window width is 0, then the action is not needed. - cmp [edi + WDATA.box.width], dword 0 - je @f -; If the window height is 0, then the action is not needed. - cmp [edi + WDATA.box.height], dword 0 - je @f - - mov eax, [edi + WDATA.box.left] - mov [draw_limits.left], eax - mov ecx, eax + + ; no it's not, let's do that + or [edi + WDATA.fl_wstate], WSTATE_MINIMIZED +; If the window width is 0, then the action is not needed. + cmp [edi + WDATA.box.width], dword 0 + je @f +; If the window height is 0, then the action is not needed. + cmp [edi + WDATA.box.height], dword 0 + je @f + + mov eax, [edi + WDATA.box.left] + mov [draw_limits.left], eax + mov ecx, eax add ecx, [edi + WDATA.box.width] mov [draw_limits.right], ecx mov ebx, [edi + WDATA.box.top] mov [draw_limits.top], ebx - mov edx, ebx - add edx, [edi + WDATA.box.height] - mov [draw_limits.bottom], edx - -; DEBUGF 1, "K : minimize_window\n" -; DEBUGF 1, "K : dl_left %x\n",[draw_limits.left] -; DEBUGF 1, "K : dl_right %x\n",[draw_limits.right] -; DEBUGF 1, "K : dl_top %x\n",[draw_limits.top] -; DEBUGF 1, "K : dl_bottom %x\n",[draw_limits.bottom] - call calculatescreen -; xor esi, esi -; xor eax, eax - mov eax, edi - call redrawscreen -;-------------------------------------- -align 4 -@@: - pop esi edx ecx ebx eax -;-------------------------------------- -align 4 + mov edx, ebx + add edx, [edi + WDATA.box.height] + mov [draw_limits.bottom], edx + +; DEBUGF 1, "K : minimize_window\n" +; DEBUGF 1, "K : dl_left %x\n",[draw_limits.left] +; DEBUGF 1, "K : dl_right %x\n",[draw_limits.right] +; DEBUGF 1, "K : dl_top %x\n",[draw_limits.top] +; DEBUGF 1, "K : dl_bottom %x\n",[draw_limits.bottom] + call calculatescreen +; xor esi, esi +; xor eax, eax + mov eax, edi + call redrawscreen +;-------------------------------------- +align 4 +@@: + pop esi edx ecx ebx eax +;-------------------------------------- +align 4 .exit: popfd pop edi @@ -1328,35 +1328,35 @@ align 4 call window._.set_window_box add esp, sizeof.BOX ret -;------------------------------------------------------------------------------ -align 4 -;------------------------------------------------------------------------------ -;sys_window_start_moving_handler: ;///////////////////////////////////////////// -;------------------------------------------------------------------------------ -;? -;------------------------------------------------------------------------------ -;> eax = old (original) window box -;> esi = process slot -;------------------------------------------------------------------------------ -; mov edi, eax -; call window._.draw_negative_box -; ret -;------------------------------------------------------------------------------ -align 4 -;------------------------------------------------------------------------------ +;------------------------------------------------------------------------------ +align 4 +;------------------------------------------------------------------------------ +;sys_window_start_moving_handler: ;///////////////////////////////////////////// +;------------------------------------------------------------------------------ +;? +;------------------------------------------------------------------------------ +;> eax = old (original) window box +;> esi = process slot +;------------------------------------------------------------------------------ +; mov edi, eax +; call window._.draw_negative_box +; ret +;------------------------------------------------------------------------------ +align 4 +;------------------------------------------------------------------------------ sys_window_end_moving_handler: ;/////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? ;------------------------------------------------------------------------------ ;> eax = old (original) window box -;> ebx = new (final) window box -;> esi = process slot -;------------------------------------------------------------------------------ -; mov edi, ebx -; call window._.end_moving__box - - mov edi, esi - shl edi, 5 +;> ebx = new (final) window box +;> esi = process slot +;------------------------------------------------------------------------------ +; mov edi, ebx +; call window._.end_moving__box + + mov edi, esi + shl edi, 5 add edi, window_data mov eax, ebx @@ -2381,23 +2381,23 @@ align 4 mov bx, word[edi + BOX.top] add bx, word[edi + BOX.height] call draw_rectangle.forced - pop esi ebx eax - ret -;------------------------------------------------------------------------------ -;align 4 -;------------------------------------------------------------------------------ -;window._.end_moving__box: ;////////////////////////////////////////////////// -;------------------------------------------------------------------------------ -;? Draw positive box -;------------------------------------------------------------------------------ -;> edi = pointer to BOX struct -;------------------------------------------------------------------------------ -; push eax ebx esi -; xor esi, esi -; jmp window._.draw_negative_box.1 -;------------------------------------------------------------------------------ -align 4 -;------------------------------------------------------------------------------ + pop esi ebx eax + ret +;------------------------------------------------------------------------------ +;align 4 +;------------------------------------------------------------------------------ +;window._.end_moving__box: ;////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +;? Draw positive box +;------------------------------------------------------------------------------ +;> edi = pointer to BOX struct +;------------------------------------------------------------------------------ +; push eax ebx esi +; xor esi, esi +; jmp window._.draw_negative_box.1 +;------------------------------------------------------------------------------ +align 4 +;------------------------------------------------------------------------------ window._.get_rect: ;///////////////////////////////////////////////////// ;------------------------------------------------------------------------------ ;? void __fastcall get_window_rect(struct RECT* rc); diff --git a/kernel/branches/net/hid/keyboard.inc b/kernel/branches/net/hid/keyboard.inc index 409663da2b..dad6f37a3a 100644 --- a/kernel/branches/net/hid/keyboard.inc +++ b/kernel/branches/net/hid/keyboard.inc @@ -17,6 +17,8 @@ VKEY_RALT = 0000000000100000b VKEY_CAPSLOCK = 0000000001000000b VKEY_NUMLOCK = 0000000010000000b VKEY_SCRLOCK = 0000000100000000b +VKEY_LWIN = 0000001000000000b +VKEY_RWIN = 0000010000000000b VKEY_SHIFT = 0000000000000011b VKEY_CONTROL = 0000000000001100b @@ -224,6 +226,29 @@ send_scancode: xchg cl, [ext_code] and al, 0x7F mov bh, 1 +;-------------------------------------- +@@: + cmp al, 0x5B + jne @f + + cmp cl, 0xE0 + jne @f + + mov eax, VKEY_LWIN + mov bh, 0 + jmp .modifier +;-------------------------------------- +@@: + cmp al, 0x5C + jne @f + + cmp cl, 0xE0 + jne @f + + mov eax, VKEY_RWIN + mov bh, 0 + jmp .modifier +;-------------------------------------- @@: cmp al, 0x2A jne @f @@ -359,9 +384,6 @@ send_scancode: xor [kb_state], eax xor [kb_lights], bl - push ecx - call set_lights - pop ecx .writekey: pushad ; test for system hotkeys @@ -495,10 +517,12 @@ set_lights: ret ps2_set_lights: + stdcall disable_irq, 1 mov al, 0xED call kb_write mov al, [esp+8] call kb_write + stdcall enable_irq, 1 ret 8 ;// mike.dld ] diff --git a/kernel/branches/net/hid/mousedrv.inc b/kernel/branches/net/hid/mousedrv.inc index c6bb821748..6ff81d3400 100644 --- a/kernel/branches/net/hid/mousedrv.inc +++ b/kernel/branches/net/hid/mousedrv.inc @@ -23,20 +23,20 @@ $Revision $ uglobal ;-------------------------------------- -align 4 - mousecount dd 0x0 - mousedata dd 0x0 -Y_UNDER_sub_CUR_hot_y_add_curh: - dw 0 -Y_UNDER_subtraction_CUR_hot_y: - dw 0 -X_UNDER_sub_CUR_hot_x_add_curh: - dw 0 -X_UNDER_subtraction_CUR_hot_x: - dw 0 -endg - -iglobal +align 4 + mousecount dd 0x0 + mousedata dd 0x0 +Y_UNDER_sub_CUR_hot_y_add_curh: + dw 0 +Y_UNDER_subtraction_CUR_hot_y: + dw 0 +X_UNDER_sub_CUR_hot_x_add_curh: + dw 0 +X_UNDER_subtraction_CUR_hot_x: + dw 0 +endg + +iglobal ;-------------------------------------- align 4 mouse_delay dd 10 @@ -121,24 +121,24 @@ save_draw_mouse: shl edx, 8 mov esi, [edx+SLOT_BASE+APPDATA.cursor] - cmp esi, [current_cursor] - je .draw - - mov eax, [TASK_COUNT] - movzx eax, word [WIN_POS+eax*2] - shl eax, 8 - - cmp eax, edx - je @F - - mov esi, [def_cursor] - cmp esi, [current_cursor] - je .draw - -@@: - push esi - call [_display.select_cursor] - mov [current_cursor], esi + cmp esi, [current_cursor] + je .draw + + mov eax, [TASK_COUNT] + movzx eax, word [WIN_POS+eax*2] + shl eax, 8 + + cmp eax, edx + je @F + + mov esi, [def_cursor] + cmp esi, [current_cursor] + je .draw + +@@: + push esi + call [_display.select_cursor] + mov [current_cursor], esi ;-------------------------------------- align 4 .draw: @@ -456,21 +456,21 @@ redrawmouse: xor eax, eax mov esi, [current_cursor] - - mov ax, [Y_UNDER] - sub eax, [esi+CURSOR.hot_y] - mov [Y_UNDER_subtraction_CUR_hot_y], ax - add eax, [cur.h] - mov [Y_UNDER_sub_CUR_hot_y_add_curh], ax - - mov ax, [X_UNDER] - sub eax, [esi+CURSOR.hot_x] - mov [X_UNDER_subtraction_CUR_hot_x], ax - add eax, [cur.w] - mov [X_UNDER_sub_CUR_hot_x_add_curh], ax -;-------------------------------------- -align 4 -@@: + + mov ax, [Y_UNDER] + sub eax, [esi+CURSOR.hot_y] + mov [Y_UNDER_subtraction_CUR_hot_y], ax + add eax, [cur.h] + mov [Y_UNDER_sub_CUR_hot_y_add_curh], ax + + mov ax, [X_UNDER] + sub eax, [esi+CURSOR.hot_x] + mov [X_UNDER_subtraction_CUR_hot_x], ax + add eax, [cur.w] + mov [X_UNDER_sub_CUR_hot_x_add_curh], ax +;-------------------------------------- +align 4 +@@: popfd ;-------------------------------------- align 4 diff --git a/kernel/branches/net/kernel.asm b/kernel/branches/net/kernel.asm index 54302f1b6a..6e74ca3e68 100644 --- a/kernel/branches/net/kernel.asm +++ b/kernel/branches/net/kernel.asm @@ -77,7 +77,7 @@ $Revision $ USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices ; Enabling the next line will enable serial output console -;debug_com_base equ 0x2f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used +;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used include "proc32.inc" include "kglobals.inc" @@ -133,13 +133,19 @@ use16 org 0x0 jmp start_of_code -version db 'Kolibri OS network branch ',13,10,13,10,0 +if lang eq sp +include "kernelsp.inc" ; spanish kernel messages +else +version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 +end if include "boot/bootstr.inc" ; language-independent boot messages include "boot/preboot.inc" -if lang eq en -include "boot/booteng.inc" ; english system boot messages +if lang eq ge +include "boot/bootge.inc" ; german system boot messages +else if lang eq sp +include "boot/bootsp.inc" ; spanish system boot messages else if lang eq ru include "boot/bootru.inc" ; russian system boot messages include "boot/ru.inc" ; Russian font @@ -147,7 +153,7 @@ else if lang eq et include "boot/bootet.inc" ; estonian system boot messages include "boot/et.inc" ; Estonian font else -include "boot/bootge.inc" ; german system boot messages +include "boot/booten.inc" ; english system boot messages end if include "boot/bootcode.inc" ; 16 bit system boot code @@ -608,6 +614,52 @@ no_mode_0x12: mov [mem_BACKGROUND], 4 mov [img_background], static_background_data +; SET UP OS TASK + + mov esi, boot_setostask + call boot_log + + xor eax, eax + mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data + mov dword [SLOT_BASE+APPDATA.exc_handler], eax + mov dword [SLOT_BASE+APPDATA.except_mask], eax + + ; name for OS/IDLE process + + mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' + mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' + mov edi, [os_stack_seg] + mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi + add edi, 0x2000-512 + mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi + mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi; just for case + mov dword [SLOT_BASE+256+APPDATA.terminate_protection], 80000001h + + mov esi, fpu_data + mov ecx, 512/4 + cld + rep movsd + + mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax + mov dword [SLOT_BASE+256+APPDATA.except_mask], eax + + mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET + mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx + mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx + + mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path + mov dword [SLOT_BASE+256+APPDATA.tls_base], eax + + ; task list + mov dword [TASK_DATA+TASKDATA.mem_start], eax; process base address + inc eax + mov dword [CURRENT_TASK], eax + mov dword [TASK_COUNT], eax + mov [current_slot], SLOT_BASE+256 + mov [TASK_BASE], dword TASK_DATA + mov byte[TASK_DATA+TASKDATA.wnd_number], al ; on screen number + mov dword [TASK_DATA+TASKDATA.pid], eax ; process id number + mov [SLOT_BASE + 256 + APPDATA.dir_table], sys_pgdir - OS_BASE ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f @@ -718,9 +770,11 @@ end if movzx ecx, word [boot_y] if lang eq ru or ecx, (10+30*6) shl 16 - else + else if lang eq sp + or ecx, (10+33*6) shl 16 + else or ecx, (10+29*6) shl 16 - end if + end if sub ecx, 10 mov edx, 0xFFFFFF mov ebx, [MEM_AMOUNT] @@ -739,7 +793,6 @@ end if mov [pci_access_enabled], 1 - ; SET PRELIMINARY WINDOW STACK AND POSITIONS mov esi, boot_windefs @@ -759,52 +812,6 @@ end if call boot_log call reserve_irqs_ports -; SET UP OS TASK - - mov esi, boot_setostask - call boot_log - - xor eax, eax - mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data - mov dword [SLOT_BASE+APPDATA.exc_handler], eax - mov dword [SLOT_BASE+APPDATA.except_mask], eax - - ; name for OS/IDLE process - - mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' - mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' - mov edi, [os_stack_seg] - mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi - add edi, 0x2000-512 - mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi - mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi; just for case - ; [SLOT_BASE+256+APPDATA.io_map] was set earlier - - mov esi, fpu_data - mov ecx, 512/4 - cld - rep movsd - - mov dword [SLOT_BASE+256+APPDATA.exc_handler], eax - mov dword [SLOT_BASE+256+APPDATA.except_mask], eax - - mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET - mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx - mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx - - mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path - mov dword [SLOT_BASE+256+APPDATA.tls_base], eax - - ; task list - mov dword [TASK_DATA+TASKDATA.mem_start], eax; process base address - inc eax - mov dword [CURRENT_TASK], eax - mov dword [TASK_COUNT], eax - mov [current_slot], SLOT_BASE+256 - mov [TASK_BASE], dword TASK_DATA - mov byte[TASK_DATA+TASKDATA.wnd_number], al ; on screen number - mov dword [TASK_DATA+TASKDATA.pid], eax ; process id number - call init_display mov eax, [def_cursor] mov [SLOT_BASE+APPDATA.cursor], eax @@ -841,9 +848,11 @@ end if movzx ecx, word [boot_y] if lang eq ru add ecx, (10+19*6) shl 16 - 10 ; 'Determining amount of memory' - else + else if lang eq sp + add ecx, (10+25*6) shl 16 - 10 ; 'Determining amount of memory' + else add ecx, (10+17*6) shl 16 - 10 ; 'Determining amount of memory' - end if + end if mov edx, 0xFFFFFF xor edi, edi mov eax, 0x00040000 @@ -912,8 +921,8 @@ end if call fs_execute_from_sysdir ; cmp eax,2 ; continue if a process has been loaded - sub eax, 2 - jz first_app_found + test eax, eax + jns first_app_found mov esi, boot_failed call boot_log @@ -2089,17 +2098,21 @@ sysfn_terminate: ; 18.2 = TERMINATE push ecx cmp ecx, 2 jb noprocessterminate - - cmp ecx, [TASK_COUNT] + mov edx, [TASK_COUNT] + cmp ecx, edx ja noprocessterminate - - shl ecx, 5 mov eax, [TASK_COUNT] + shl ecx, 5 mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] - add ecx, CURRENT_TASK+TASKDATA.state cmp byte [ecx], 9 jz noprocessterminate + push ecx edx + lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] + call request_terminate + pop edx ecx + test eax, eax + jz noprocessterminate ;-------------------------------------- ; terminate all network sockets it used pusha @@ -3476,15 +3489,31 @@ nobackgr: mov edx, [shutdown_processes] cmp [SYS_SHUTDOWN], dl - jne no_mark_system_shutdown + jne noshutdown lea ecx, [edx-1] mov edx, OS_BASE+0x3040 - jecxz @f + jecxz no_mark_system_shutdown ;-------------------------------------- align 4 markz: + push ecx edx + cmp [edx+TASKDATA.state], 9 + jz .nokill + lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] + cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE + jz .nokill + call request_terminate + jmp .common +.nokill: + dec byte [SYS_SHUTDOWN] + xor eax, eax +.common: + pop edx ecx + test eax, eax + jz @f mov [edx+TASKDATA.state], byte 3 +@@: add edx, 0x20 loop markz ;-------------------------------------- @@ -3504,11 +3533,20 @@ align 4 newct: mov cl, [ebx] cmp cl, byte 3 - jz terminate + jz .terminate cmp cl, byte 4 - jz terminate + jnz .noterminate +.terminate: + pushad + call terminate + popad + cmp byte [SYS_SHUTDOWN], 0 + jz .noterminate + dec byte [SYS_SHUTDOWN] + je system_shutdown +.noterminate: add ebx, 0x20 inc esi dec eax @@ -3718,6 +3756,15 @@ set_app_param: mov [esp+32], eax ; return old mask value ret ;----------------------------------------------------------------------------- + +; this is for syscall +proc delay_hs_unprotected + call unprotect_from_terminate + call delay_hs + call protect_from_terminate + ret +endp + align 4 delay_hs: ; delay in 1/100 secs ; ebx = delay time @@ -5606,4 +5653,6 @@ include "data32.inc" __REV__ = __REV uglobals_size = $ - endofcode +if ~ lang eq sp diff16 "end of kernel code",0,$ +end if diff --git a/kernel/branches/net/kernel32.inc b/kernel/branches/net/kernel32.inc index 19395d388b..6f51f00fdd 100644 --- a/kernel/branches/net/kernel32.inc +++ b/kernel/branches/net/kernel32.inc @@ -137,7 +137,7 @@ struct APPDATA ipc_size dd ? event_mask dd ? debugger_slot dd ? - dd ? + terminate_protection dd ? keyboard_mode db ? rb 3 dir_table dd ? diff --git a/kernel/branches/net/kernelsp.inc b/kernel/branches/net/kernelsp.inc new file mode 100644 index 0000000000..48ebca1a28 --- /dev/null +++ b/kernel/branches/net/kernelsp.inc @@ -0,0 +1,4 @@ +; ste archivo debe ser editado con codificaci¢n CP866 + +version db 'Kolibri OS versi¢n 0.7.7.0+ ',13,10,13,10,0 +diff16 "fin del c¢digo del kernel",0,$ diff --git a/kernel/branches/net/memmap.inc b/kernel/branches/net/memmap.inc index bcf2c22043..1bc967dd1d 100644 --- a/kernel/branches/net/memmap.inc +++ b/kernel/branches/net/memmap.inc @@ -1,12 +1,12 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; MEMORY MAP -; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; MEMORY MAP +; ; Boot: ; ; 0:9000 byte bits per pixel @@ -134,24 +134,24 @@ ; FE88 dword address of button list ; FE8C dword memory to use ; FE90 -> FEFF free (112) -; FF00 byte 1 = system shutdown request -; FF01 byte task activation request? -; FFF0 byte >0 if redraw background request from app -; FFF1 byte free -; FFF2 write and read bank in screen -; FFF4 byte 0 if first mouse draw & do not return picture under -; FFF5 byte 1 do not draw pointer +; FF00 byte 1 = system shutdown request +; FF01 byte task activation request? +; FFF0 byte >0 if redraw background request from app +; FFF1 byte free +; FFF2 write and read bank in screen +; FFF4 byte 0 if first mouse draw & do not return picture under +; FFF5 byte 1 do not draw pointer ; FFFF byte do not change task for 1/100 sec. ; ; 0x80010000 -> 6CBFF kernel, 32-bit run-time code (up to 371 Kb) - -; 0x8006CC00 -> 6DBFF stack at boot time (4Kb) -; -; 0x8006DC00 -> 6E5FF free (2560) -; 0x8006E600 -> 6Efff free (2560) -; 0x8006F000 -> 6FFFF main page directory - -; 0x80070000 -> 7FFFF data of retrieved disks and partitions (Mario79) + +; 0x8006CC00 -> 6DBFF stack at boot time (4Kb) +; +; 0x8006DC00 -> 6E5FF free (2560) +; 0x8006E600 -> 6Efff free (2560) +; 0x8006F000 -> 6FFFF main page directory + +; 0x80070000 -> 7FFFF data of retrieved disks and partitions (Mario79) ; 0x80080000 -> 8FFFF additional app info, in 256 byte steps - 256 entries ; ; 00 11db name of app running @@ -201,68 +201,68 @@ ; 0x80280000 -> 281FFF ramdisk fat (8k) ; 0x80282000 -> 283FFF floppy fat (8k) ; -; 0x80284000 -> 28BFFF HDD DMA AREA (32k) -; 0x8028C000 -> 297FFF free (48k) -; -; 0x80298000 -> 29FFFF auxiliary table for background smoothing code (32k) -; -; 0x802A0000 -> 2B00FF wav device buffer (64k) -; 0x802A0000 -> 2B00FF wav device status (256) -; -; 0x802B0100 -> 2B3FFD free (15k7) -; -; 0x802B3FEE -> 2B3FEF button info (64K+ 16 + 2 byte) -; 2B3FEE 0000 word number of buttons -; 2B3FF0 first button entry -; -; button entry at 0x10 -; +0000 word process number -; +0002 word button id number : bits 00-15 -; +0004 word x start +; 0x80284000 -> 28BFFF HDD DMA AREA (32k) +; 0x8028C000 -> 297FFF free (48k) +; +; 0x80298000 -> 29FFFF auxiliary table for background smoothing code (32k) +; +; 0x802A0000 -> 2B00FF wav device buffer (64k) +; 0x802A0000 -> 2B00FF wav device status (256) +; +; 0x802B0100 -> 2B3FFD free (15k7) +; +; 0x802B3FEE -> 2B3FEF button info (64K+ 16 + 2 byte) +; 2B3FEE 0000 word number of buttons +; 2B3FF0 first button entry +; +; button entry at 0x10 +; +0000 word process number +; +0002 word button id number : bits 00-15 +; +0004 word x start ; +0006 word x size ; +0008 word y start -; +000A word y size -; +000C word button id number : bits 16-31 -; -; 0x802C4000 -> 2C9FFF area for fast getting offset to LFB (24k) -; BPSLine_calc_area -; 0x802CA000 -> 2CFFFF area for fast getting offset to _WinMapAddress (24k) -; d_width_calc_area -; -; 0x802D0000 -> 2DFFFF reserved port area (64k) -; +; +000A word y size +; +000C word button id number : bits 16-31 +; +; 0x802C4000 -> 2C9FFF area for fast getting offset to LFB (24k) +; BPSLine_calc_area +; 0x802CA000 -> 2CFFFF area for fast getting offset to _WinMapAddress (24k) +; d_width_calc_area +; +; 0x802D0000 -> 2DFFFF reserved port area (64k) +; ; 0000 dword no of port areas reserved ; 0010 dword process id ; dword start port -; dword end port -; dword 0 -; -; 0x802E0000 -> 2EFFFF irq data area (64k) ;BOOT_VAR -; -; 0x802F0000 -> 2F3FFF tcp memory stack_data_start eth_data_start (16k) -; -; 0x802F4000 -> 30ffff stack_data | stack_data_end (112k) -; -; 0x80310000 -> 317fff resendQ (32k) -; -; 0x80318000 -> 31ffff skin_data (32k) -; -; 0x80320000 -> 323FF3 draw data - 256 entries (4k) -; 00 dword draw limit - x start -; 04 dword draw limit - y start -; 08 dword draw limit - x end -; 0C dword draw limit - y end -; -; 0x8032BFF4 -> 32BFFF background info -; 0x80323FF4 BgrDrawMode -; 0x80323FF8 BgrDataWidth -; 0x80323FFC BgrDataHeight -; -; 0x80324000 page map (length b = memsize shr 15) -; 0x80324000 + b start of static pagetables - -; 0x803FFFFF <- no direct address translation beyond this point -; ============================================================= +; dword end port +; dword 0 +; +; 0x802E0000 -> 2EFFFF irq data area (64k) ;BOOT_VAR +; +; 0x802F0000 -> 2F3FFF tcp memory stack_data_start eth_data_start (16k) +; +; 0x802F4000 -> 30ffff stack_data | stack_data_end (112k) +; +; 0x80310000 -> 317fff resendQ (32k) +; +; 0x80318000 -> 31ffff skin_data (32k) +; +; 0x80320000 -> 323FF3 draw data - 256 entries (4k) +; 00 dword draw limit - x start +; 04 dword draw limit - y start +; 08 dword draw limit - x end +; 0C dword draw limit - y end +; +; 0x8032BFF4 -> 32BFFF background info +; 0x80323FF4 BgrDrawMode +; 0x80323FF8 BgrDataWidth +; 0x80323FFC BgrDataHeight +; +; 0x80324000 page map (length b = memsize shr 15) +; 0x80324000 + b start of static pagetables + +; 0x803FFFFF <- no direct address translation beyond this point +; ============================================================= ; 0x805FF000 -> 5FFF80 TSS ; 0x80600000 -> 601FFF i/o maps diff --git a/kernel/branches/net/network/stack.inc b/kernel/branches/net/network/stack.inc index 2cb3e1b1d1..80b8f48778 100644 --- a/kernel/branches/net/network/stack.inc +++ b/kernel/branches/net/network/stack.inc @@ -291,11 +291,15 @@ stack_handler: align 4 NET_link_changed: + ret + DEBUGF 1,"NET_link_changed: %x\n", ebx align 4 NET_send_event: + ret + DEBUGF 1,"NET_send_event\n" ; Send event to all applications @@ -330,8 +334,7 @@ NET_add_device: DEBUGF 1,"NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list - mov eax, [NET_RUNNING] - cmp eax, MAX_NET_DEVICES + cmp [NET_RUNNING], MAX_NET_DEVICES jae .error ;---------------------------------- diff --git a/kernel/branches/net/video/blitter.inc b/kernel/branches/net/video/blitter.inc index c8334c0ccb..15223ee882 100644 --- a/kernel/branches/net/video/blitter.inc +++ b/kernel/branches/net/video/blitter.inc @@ -1,114 +1,114 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -struct BLITTER_BLOCK - xmin dd ? - ymin dd ? - xmax dd ? - ymax dd ? -ends - - -struct BLITTER - dc RECT - sc RECT - dst_x dd ? ; 32 - dst_y dd ? ; 36 - src_x dd ? ; 40 - src_y dd ? ; 44 - w dd ? ; 48 - h dd ? ; 52 - - bitmap dd ? ; 56 - stride dd ? ; 60 -ends - - - -align 4 -block_clip: -;esi= clip RECT ptr -;edi= RECT ptr -;return code: -;eax= 0 - draw, 1 - don't draw - - push ebx - - mov eax, [edi+RECT.left] - mov ebx, [edi+RECT.right] - mov ecx, [esi+RECT.left] ;clip.left - mov edx, [esi+RECT.right] ;clip.right - - cmp eax, edx ;left >= clip.right - jge .fail - - cmp ebx, ecx ;right < clip.left - jl .fail - - cmp eax, ecx ;left >= clip.left - jae @F - - mov eax, ecx -@@: - mov [edi+RECT.left], eax - - cmp ebx, edx ;right <= clip.right - jle @f - mov ebx, edx -@@: - mov [edi+RECT.right], ebx - - mov eax, [edi+RECT.top] - mov ebx, [edi+RECT.bottom] - mov ecx, [esi+RECT.top] ;clip.top - mov edx, [esi+RECT.bottom] ;clip.bottom - - cmp eax, edx ;top >= clip.bottom - jge .fail - - cmp ebx, ecx ;bottom < clip.top - jl .fail - - cmp eax, ecx ;top >= clip.top - jae @F - - mov eax, ecx -@@: - mov [edi+RECT.top], eax - - cmp ebx, edx ;bottom <= clip.bottom - jle @f - mov ebx, edx -@@: - mov [edi+RECT.bottom], ebx - pop ebx - xor eax, eax - ret -.fail: - pop ebx - mov eax, 1 - ret - - -align 4 -blit_clip: - -.sx0 equ 8 -.sy0 equ 12 -.sx1 equ 16 -.sy1 equ 20 - -.dx0 equ 24 -.dy0 equ 28 -.dx1 equ 32 -.dy1 equ 36 - - - push edi +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +struct BLITTER_BLOCK + xmin dd ? + ymin dd ? + xmax dd ? + ymax dd ? +ends + + +struct BLITTER + dc RECT + sc RECT + dst_x dd ? ; 32 + dst_y dd ? ; 36 + src_x dd ? ; 40 + src_y dd ? ; 44 + w dd ? ; 48 + h dd ? ; 52 + + bitmap dd ? ; 56 + stride dd ? ; 60 +ends + + + +align 4 +block_clip: +;esi= clip RECT ptr +;edi= RECT ptr +;return code: +;eax= 0 - draw, 1 - don't draw + + push ebx + + mov eax, [edi+RECT.left] + mov ebx, [edi+RECT.right] + mov ecx, [esi+RECT.left] ;clip.left + mov edx, [esi+RECT.right] ;clip.right + + cmp eax, edx ;left >= clip.right + jge .fail + + cmp ebx, ecx ;right < clip.left + jl .fail + + cmp eax, ecx ;left >= clip.left + jae @F + + mov eax, ecx +@@: + mov [edi+RECT.left], eax + + cmp ebx, edx ;right <= clip.right + jle @f + mov ebx, edx +@@: + mov [edi+RECT.right], ebx + + mov eax, [edi+RECT.top] + mov ebx, [edi+RECT.bottom] + mov ecx, [esi+RECT.top] ;clip.top + mov edx, [esi+RECT.bottom] ;clip.bottom + + cmp eax, edx ;top >= clip.bottom + jge .fail + + cmp ebx, ecx ;bottom < clip.top + jl .fail + + cmp eax, ecx ;top >= clip.top + jae @F + + mov eax, ecx +@@: + mov [edi+RECT.top], eax + + cmp ebx, edx ;bottom <= clip.bottom + jle @f + mov ebx, edx +@@: + mov [edi+RECT.bottom], ebx + pop ebx + xor eax, eax + ret +.fail: + pop ebx + mov eax, 1 + ret + + +align 4 +blit_clip: + +.sx0 equ 8 +.sy0 equ 12 +.sx1 equ 16 +.sy1 equ 20 + +.dx0 equ 24 +.dy0 equ 28 +.dx1 equ 32 +.dy1 equ 36 + + + push edi push esi push ebx sub esp, 40 @@ -116,58 +116,58 @@ blit_clip: mov ebx, ecx mov edx, [ecx+BLITTER.src_x] mov [esp+.sx0], edx - mov eax, [ecx+BLITTER.src_y] - mov [esp+.sy0], eax - add edx, [ecx+BLITTER.w] - add eax, [ecx+BLITTER.h] - mov [esp+.sx1], edx - mov [esp+.sy1], eax - - lea edi, [esp+.sx0] - lea esi, [ebx+BLITTER.sc] - - call block_clip - test eax, eax - mov esi, 1 - jnz .done - - mov edi, [esp+.sx0] - mov edx, [ebx+BLITTER.dst_x] + mov eax, [ecx+BLITTER.src_y] + mov [esp+.sy0], eax + add edx, [ecx+BLITTER.w] + add eax, [ecx+BLITTER.h] + mov [esp+.sx1], edx + mov [esp+.sy1], eax + + lea edi, [esp+.sx0] + lea esi, [ebx+BLITTER.sc] + + call block_clip + test eax, eax + mov esi, 1 + jnz .done + + mov edi, [esp+.sx0] + mov edx, [ebx+BLITTER.dst_x] add edx, edi sub edx, [ebx+BLITTER.src_x] mov [esp+.dx0], edx mov ecx, [esp+.sy0] mov eax, [ebx+BLITTER.dst_y] - add eax, ecx - sub eax, [ebx+BLITTER.src_y] - mov [esp+.dy0], eax - - sub edx, edi - add edx, [esp+.sx1] - mov [esp+.dx1], edx + add eax, ecx + sub eax, [ebx+BLITTER.src_y] + mov [esp+.dy0], eax + + sub edx, edi + add edx, [esp+.sx1] + mov [esp+.dx1], edx sub eax, ecx - add eax, [esp+.sy1] - mov [esp+.dy1], eax - - lea edi, [esp+.dx0] - lea esi, [ebx+BLITTER.dc] - call block_clip - test eax, eax - mov esi, 1 - jnz .done - - mov edx, [esp+.dx0] - mov eax, [esp+.dx1] - sub eax, edx - mov [ebx+BLITTER.w], eax - - mov eax, [esp+.dy0] - mov ecx, [esp+.dy1] - sub ecx, eax - mov [ebx+BLITTER.h], ecx - + add eax, [esp+.sy1] + mov [esp+.dy1], eax + + lea edi, [esp+.dx0] + lea esi, [ebx+BLITTER.dc] + call block_clip + test eax, eax + mov esi, 1 + jnz .done + + mov edx, [esp+.dx0] + mov eax, [esp+.dx1] + sub eax, edx + mov [ebx+BLITTER.w], eax + + mov eax, [esp+.dy0] + mov ecx, [esp+.dy1] + sub ecx, eax + mov [ebx+BLITTER.h], ecx + mov ecx, [ebx+BLITTER.src_x] add ecx, edx sub ecx, [ebx+BLITTER.dst_x] @@ -177,13 +177,13 @@ blit_clip: add ecx, eax sub ecx, [ebx+BLITTER.dst_y] mov [ebx+BLITTER.src_y], ecx - mov [ebx+BLITTER.dst_x], edx - mov [ebx+BLITTER.dst_y], eax - xor esi, esi -.done: - mov eax, esi - add esp, 40 - pop ebx + mov [ebx+BLITTER.dst_x], edx + mov [ebx+BLITTER.dst_y], eax + xor esi, esi +.done: + mov eax, esi + add esp, 40 + pop ebx pop esi pop edi @@ -197,42 +197,42 @@ purge .dx0 purge .dy0 purge .dx1 purge .dy1 - - ret - -align 4 -blit_32: - push ebp - push edi + + ret + +align 4 +blit_32: + push ebp + push edi push esi push ebx sub esp, 72 - mov eax, [TASK_BASE] - mov ebx, [eax-twdw + WDATA.box.width] - mov edx, [eax-twdw + WDATA.box.height] - inc ebx - inc edx - - xor eax, eax - - mov [esp+BLITTER.dc.left], eax - mov [esp+BLITTER.dc.top], eax - mov [esp+BLITTER.dc.right], ebx - mov [esp+BLITTER.dc.bottom], edx - - mov [esp+BLITTER.sc.left], eax - mov [esp+BLITTER.sc.top], eax - mov eax, [ecx+24] - - mov [esp+BLITTER.sc.right], eax - mov eax, [ecx+28] - - mov [esp+BLITTER.sc.bottom], eax - - mov eax, [ecx] - mov [esp+BLITTER.dst_x], eax - mov eax, [ecx+4] + mov eax, [TASK_BASE] + mov ebx, [eax-twdw + WDATA.box.width] + mov edx, [eax-twdw + WDATA.box.height] + inc ebx + inc edx + + xor eax, eax + + mov [esp+BLITTER.dc.left], eax + mov [esp+BLITTER.dc.top], eax + mov [esp+BLITTER.dc.right], ebx + mov [esp+BLITTER.dc.bottom], edx + + mov [esp+BLITTER.sc.left], eax + mov [esp+BLITTER.sc.top], eax + mov eax, [ecx+24] + + mov [esp+BLITTER.sc.right], eax + mov eax, [ecx+28] + + mov [esp+BLITTER.sc.bottom], eax + + mov eax, [ecx] + mov [esp+BLITTER.dst_x], eax + mov eax, [ecx+4] mov [esp+BLITTER.dst_y], eax mov eax, [ecx+16] @@ -252,42 +252,42 @@ blit_32: mov ecx, esp call blit_clip - test eax, eax - jne .L57 - - mov eax, [TASK_BASE] - - mov ebx, [esp+BLITTER.dst_x] - mov ebp, [esp+BLITTER.dst_y] - add ebx, [eax-twdw + WDATA.box.left] - add ebp, [eax-twdw + WDATA.box.top] - - mov ecx, ebx - add ecx, [esp+BLITTER.w] - shl ecx, 16 - mov cx, bp - add ecx, [esp+BLITTER.h] - - mov edi, ebp - -; imul edi, [_display.pitch] - mov edi, [BPSLine_calc_area+edi*4] -; imul ebp, [_display.width] - mov ebp, [d_width_calc_area+ebp*4] - - add ebp, ebx - add ebp, [_WinMapAddress] - + test eax, eax + jne .L57 + + mov eax, [TASK_BASE] + + mov ebx, [esp+BLITTER.dst_x] + mov ebp, [esp+BLITTER.dst_y] + add ebx, [eax-twdw + WDATA.box.left] + add ebp, [eax-twdw + WDATA.box.top] + + mov ecx, ebx + add ecx, [esp+BLITTER.w] + shl ecx, 16 + mov cx, bp + add ecx, [esp+BLITTER.h] + + mov edi, ebp + +; imul edi, [_display.pitch] + mov edi, [BPSLine_calc_area+edi*4] +; imul ebp, [_display.width] + mov ebp, [d_width_calc_area+ebp*4] + + add ebp, ebx + add ebp, [_WinMapAddress] + mov eax, [esp+BLITTER.src_y] imul eax, [esp+BLITTER.stride] mov esi, [esp+BLITTER.src_x] - lea esi, [eax+esi*4] - add esi, [esp+BLITTER.bitmap] - - mov eax, ecx - mov ecx, [esp+BLITTER.h] - mov edx, [esp+BLITTER.w] - + lea esi, [eax+esi*4] + add esi, [esp+BLITTER.bitmap] + + mov eax, ecx + mov ecx, [esp+BLITTER.h] + mov edx, [esp+BLITTER.w] + test ecx, ecx ;FIXME check clipping jz .L57 @@ -297,52 +297,52 @@ blit_32: cmp [_display.bpp], 32 jne .core_24 - lea edi, [edi+ebx*4] - - mov ebx, [CURRENT_TASK] -align 4 -.outer32: - xor ecx, ecx + lea edi, [edi+ebx*4] -align 4 -.inner32: - cmp [ebp+ecx], bl - jne .skip -;-------------------------------------- - push eax - mov eax, [esi+ecx*4] - -; check for hardware cursor - cmp [_display.select_cursor], select_cursor - je @f - cmp [_display.select_cursor], 0 - jne .no_mouseunder -;-------------------------------------- -align 4 -@@: - push ecx - - mov ecx, [esp+4] - ror ecx, 16 - sub ecx, edx - rol ecx, 16 - sub ecx, [esp+BLITTER.h + 8] - -; check mouse area for putpixel - call [_display.check_mouse] - pop ecx -;-------------------------------------- -align 4 -.no_mouseunder: -; store to real LFB - mov [LFB_BASE+edi+ecx*4], eax - pop eax -;-------------------------------------- -align 4 -.skip: - inc ecx - dec edx - jnz .inner32 + mov ebx, [CURRENT_TASK] +align 4 +.outer32: + xor ecx, ecx + +align 4 +.inner32: + cmp [ebp+ecx], bl + jne .skip +;-------------------------------------- + push eax + mov eax, [esi+ecx*4] + +; check for hardware cursor + cmp [_display.select_cursor], select_cursor + je @f + cmp [_display.select_cursor], 0 + jne .no_mouseunder +;-------------------------------------- +align 4 +@@: + push ecx + + mov ecx, [esp+4] + ror ecx, 16 + sub ecx, edx + rol ecx, 16 + sub ecx, [esp+BLITTER.h + 8] + +; check mouse area for putpixel + call [_display.check_mouse] + pop ecx +;-------------------------------------- +align 4 +.no_mouseunder: +; store to real LFB + mov [LFB_BASE+edi+ecx*4], eax + pop eax +;-------------------------------------- +align 4 +.skip: + inc ecx + dec edx + jnz .inner32 add esi, [esp+BLITTER.stride] add edi, [_display.pitch] @@ -350,14 +350,14 @@ align 4 mov edx, [esp+BLITTER.w] dec [esp+BLITTER.h] - jnz .outer32 - -.done: -; call [draw_pointer] -; call __sys_draw_pointer -.L57: - add esp, 72 - pop ebx + jnz .outer32 + +.done: +; call [draw_pointer] +; call __sys_draw_pointer +.L57: + add esp, 72 + pop ebx pop esi pop edi pop ebp @@ -373,49 +373,49 @@ align 4 mov [esp+64], edi xor ecx, ecx -align 4 -.inner24: - cmp [ebp+ecx], bl - jne .skip_1 -;-------------------------------------- - push eax - mov eax, [esi+ecx*4] - - lea edi, [edi+ecx*2] - -; check for hardware cursor - cmp [_display.select_cursor], select_cursor - je @f - cmp [_display.select_cursor], 0 - jne .no_mouseunder_1 -;-------------------------------------- -align 4 -@@: - push ecx - - mov ecx, [esp+4] - ror ecx, 16 - sub ecx, edx - rol ecx, 16 - sub ecx, [esp+BLITTER.h + 8] - -; check mouse area for putpixel - call [_display.check_mouse] - pop ecx -;-------------------------------------- -align 4 -.no_mouseunder_1: - mov [edi+ecx], ax - shr eax, 16 - mov [edi+ecx+2], al - - pop eax -;-------------------------------------- -align 4 -.skip_1: - mov edi, [esp+64] - inc ecx - dec edx +align 4 +.inner24: + cmp [ebp+ecx], bl + jne .skip_1 +;-------------------------------------- + push eax + mov eax, [esi+ecx*4] + + lea edi, [edi+ecx*2] + +; check for hardware cursor + cmp [_display.select_cursor], select_cursor + je @f + cmp [_display.select_cursor], 0 + jne .no_mouseunder_1 +;-------------------------------------- +align 4 +@@: + push ecx + + mov ecx, [esp+4] + ror ecx, 16 + sub ecx, edx + rol ecx, 16 + sub ecx, [esp+BLITTER.h + 8] + +; check mouse area for putpixel + call [_display.check_mouse] + pop ecx +;-------------------------------------- +align 4 +.no_mouseunder_1: + mov [edi+ecx], ax + shr eax, 16 + mov [edi+ecx+2], al + + pop eax +;-------------------------------------- +align 4 +.skip_1: + mov edi, [esp+64] + inc ecx + dec edx jnz .inner24 add esi, [esp+BLITTER.stride] diff --git a/kernel/branches/net/video/cursors.inc b/kernel/branches/net/video/cursors.inc index f3e5f678c6..547605db9e 100644 --- a/kernel/branches/net/video/cursors.inc +++ b/kernel/branches/net/video/cursors.inc @@ -444,17 +444,17 @@ align 4 .fail2: ret endp -;------------------------------------------------------------------------------ -align 4 -proc delete_cursor stdcall, hcursor:dword - -; DEBUGF 1,'K : delete_cursor %x\n', [hcursor] - - mov esi, [hcursor] - - cmp [esi+CURSOR.magic], 'CURS' - jne .fail - +;------------------------------------------------------------------------------ +align 4 +proc delete_cursor stdcall, hcursor:dword + +; DEBUGF 1,'K : delete_cursor %x\n', [hcursor] + + mov esi, [hcursor] + + cmp [esi+CURSOR.magic], 'CURS' + jne .fail + mov ebx, [CURRENT_TASK] shl ebx, 5 mov ebx, [CURRENT_TASK+ebx+4] @@ -634,14 +634,14 @@ align 4 mov [cur.bottom], edi sub ebx, [x] - sub edi, [y] - inc ebx - inc edi - sub ebx, [_dx] - sub edi, [_dy] - - mov [cur.w], ebx - mov [cur.h], edi + sub edi, [y] + inc ebx + inc edi + sub ebx, [_dx] + sub edi, [_dy] + + mov [cur.w], ebx + mov [cur.h], edi mov [h], edi mov eax, edi @@ -752,14 +752,14 @@ align 4 mov [cur.bottom], edi sub ebx, [x] - sub edi, [y] - inc ebx - inc edi - sub ebx, [_dx] - sub edi, [_dy] - - mov [cur.w], ebx - mov [cur.h], edi + sub edi, [y] + inc ebx + inc edi + sub ebx, [_dx] + sub edi, [_dy] + + mov [cur.w], ebx + mov [cur.h], edi mov [h], edi mov eax, edi @@ -831,16 +831,16 @@ check_mouse_area_for_getpixel_new: cmp ax, [X_UNDER_sub_CUR_hot_x_add_curh] jae .no_mouse_area -;-------------------------------------- - push eax ebx -; offset X - movzx ecx, word [X_UNDER_subtraction_CUR_hot_x] - sub eax, ecx ; x1 -; offset Y - movzx ecx, word [Y_UNDER_subtraction_CUR_hot_y] - sub ebx, ecx ; y1 -;-------------------------------------- -; ebx = offset y +;-------------------------------------- + push eax ebx +; offset X + movzx ecx, word [X_UNDER_subtraction_CUR_hot_x] + sub eax, ecx ; x1 +; offset Y + movzx ecx, word [Y_UNDER_subtraction_CUR_hot_y] + sub ebx, ecx ; y1 +;-------------------------------------- +; ebx = offset y ; eax = offset x imul ebx, [cur.w] ;y add eax, ebx @@ -870,55 +870,55 @@ check_mouse_area_for_putpixel_new: ; ecx = x shl 16 + y ; eax = color ; out: -; eax = new color -;-------------------------------------- -; check for Y - cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] - jae .no_mouse_area - - sub cx, [Y_UNDER_subtraction_CUR_hot_y] - jb .no_mouse_area - - rol ecx, 16 -;-------------------------------------- -; check for X - cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] - jae .no_mouse_area - - sub cx, [X_UNDER_subtraction_CUR_hot_x] - jb .no_mouse_area - - ror ecx, 16 -;-------------------------------------- -align 4 -.1: - push eax -;-------------------------------------- -; ecx = (offset x) shl 16 + (offset y) - push ebx - mov ebx, ecx - shr ebx, 16 ; x - and ecx, 0xffff ; y - - cmp ecx, [cur.h] - jae @f - - cmp ebx, [cur.w] - jb .ok -;-------------------------------------- -align 4 -@@: -; DEBUGF 1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx - pop ebx - jmp .sh ; SORRY! SHIT HAPPENS! -;-------------------------------------- -align 4 -.ok: -; ecx = offset y -; ebx = offset x - push ebx ecx - imul ecx, [cur.w] ;y - add ecx, ebx +; eax = new color +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area + + rol ecx, 16 +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + ror ecx, 16 +;-------------------------------------- +align 4 +.1: + push eax +;-------------------------------------- +; ecx = (offset x) shl 16 + (offset y) + push ebx + mov ebx, ecx + shr ebx, 16 ; x + and ecx, 0xffff ; y + + cmp ecx, [cur.h] + jae @f + + cmp ebx, [cur.w] + jb .ok +;-------------------------------------- +align 4 +@@: +; DEBUGF 1, "K : SHIT HAPPENS: %x %x \n", ecx,ebx + pop ebx + jmp .sh ; SORRY! SHIT HAPPENS! +;-------------------------------------- +align 4 +.ok: +; ecx = offset y +; ebx = offset x + push ebx ecx + imul ecx, [cur.w] ;y + add ecx, ebx mov ebx, ecx shl ecx, 2 cmp [ScreenBPP], byte 24 @@ -948,20 +948,20 @@ align 4 pop ebx - test eax, 0xFF000000 - jz @f - - add esp, 4 - ret -;-------------------------------------- -align 4 -.sh: - mov ecx, -1 -;-------------------------------------- -align 4 -@@: - pop eax -;-------------------------------------- + test eax, 0xFF000000 + jz @f + + add esp, 4 + ret +;-------------------------------------- +align 4 +.sh: + mov ecx, -1 +;-------------------------------------- +align 4 +@@: + pop eax +;-------------------------------------- align 4 .no_mouse_area: ret diff --git a/kernel/branches/net/video/vesa12.inc b/kernel/branches/net/video/vesa12.inc index 69bebe0213..d6034d791b 100644 --- a/kernel/branches/net/video/vesa12.inc +++ b/kernel/branches/net/video/vesa12.inc @@ -1,9 +1,9 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;; VESA12.INC ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; VESA12.INC ;; ;; ;; ;; Vesa 1.2 functions for MenuetOS ;; ;; ;; diff --git a/kernel/branches/net/video/vesa20.inc b/kernel/branches/net/video/vesa20.inc index d57873bbc3..af0ba3f439 100644 --- a/kernel/branches/net/video/vesa20.inc +++ b/kernel/branches/net/video/vesa20.inc @@ -403,44 +403,44 @@ align 4 mov eax, [putimg.ebp+4] call eax cmp [ebp], bl - jne .skip -;-------------------------------------- - push ecx -;-------------------------------------- -align 4 -.sh: - neg ecx - add ecx, [putimg.real_sx_and_abs_cx + 4] -;-------------------------------------- -; check for X - cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] - jae .no_mouse_area - - sub cx, [X_UNDER_subtraction_CUR_hot_x] - jb .no_mouse_area - - shl ecx, 16 - - add ecx, [putimg.real_sy_and_abs_cy + 4] - sub ecx, edi -;-------------------------------------- -; check for Y - cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] - jae .no_mouse_area - - sub cx, [Y_UNDER_subtraction_CUR_hot_y] - jb .no_mouse_area -;-------------------------------------- -; check mouse area for putpixel - call check_mouse_area_for_putpixel_new.1 - cmp ecx, -1 ;SHIT HAPPENS? - jne .no_mouse_area - - mov ecx, [esp] - jmp .sh -;-------------------------------------- -align 4 -.no_mouse_area: + jne .skip +;-------------------------------------- + push ecx +;-------------------------------------- +align 4 +.sh: + neg ecx + add ecx, [putimg.real_sx_and_abs_cx + 4] +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + shl ecx, 16 + + add ecx, [putimg.real_sy_and_abs_cy + 4] + sub ecx, edi +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area +;-------------------------------------- +; check mouse area for putpixel + call check_mouse_area_for_putpixel_new.1 + cmp ecx, -1 ;SHIT HAPPENS? + jne .no_mouse_area + + mov ecx, [esp] + jmp .sh +;-------------------------------------- +align 4 +.no_mouse_area: pop ecx ; store to real LFB mov [LFB_BASE+edx], ax @@ -614,44 +614,44 @@ align 4 mov eax, [putimg.ebp+4] call eax cmp [ebp], bl - jne .skip -;-------------------------------------- - push ecx -;-------------------------------------- -align 4 -.sh: - neg ecx - add ecx, [putimg.real_sx_and_abs_cx + 4] -;-------------------------------------- -; check for X - cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] - jae .no_mouse_area - - sub cx, [X_UNDER_subtraction_CUR_hot_x] - jb .no_mouse_area - - shl ecx, 16 - - add ecx, [putimg.real_sy_and_abs_cy + 4] - sub ecx, edi -;-------------------------------------- -; check for Y - cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] - jae .no_mouse_area - - sub cx, [Y_UNDER_subtraction_CUR_hot_y] - jb .no_mouse_area -;-------------------------------------- -; check mouse area for putpixel - call check_mouse_area_for_putpixel_new.1 - cmp ecx, -1 ;SHIT HAPPENS? - jne .no_mouse_area - - mov ecx, [esp] - jmp .sh -;-------------------------------------- -align 4 -.no_mouse_area: + jne .skip +;-------------------------------------- + push ecx +;-------------------------------------- +align 4 +.sh: + neg ecx + add ecx, [putimg.real_sx_and_abs_cx + 4] +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + shl ecx, 16 + + add ecx, [putimg.real_sy_and_abs_cy + 4] + sub ecx, edi +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area +;-------------------------------------- +; check mouse area for putpixel + call check_mouse_area_for_putpixel_new.1 + cmp ecx, -1 ;SHIT HAPPENS? + jne .no_mouse_area + + mov ecx, [esp] + jmp .sh +;-------------------------------------- +align 4 +.no_mouse_area: pop ecx ; store to real LFB mov [LFB_BASE+edx], eax @@ -782,29 +782,29 @@ Vesa20_putpixel24_new: jne @f ; check mouse area for putpixel test eax, 0x04000000 - jnz @f -;-------------------------------------- -; check for Y - cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] - jae @f - - sub cx, [Y_UNDER_subtraction_CUR_hot_y] - jb @f - - rol ecx, 16 -;-------------------------------------- -; check for X - cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] - jae @f - - sub cx, [X_UNDER_subtraction_CUR_hot_x] - jb @f - - ror ecx, 16 - - call check_mouse_area_for_putpixel_new.1 -;-------------------------------------- -align 4 + jnz @f +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae @f + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb @f + + rol ecx, 16 +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae @f + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb @f + + ror ecx, 16 + + call check_mouse_area_for_putpixel_new.1 +;-------------------------------------- +align 4 @@: ; store to real LFB mov [LFB_BASE+ebx+edi], ax @@ -858,29 +858,29 @@ Vesa20_putpixel32_new: jne @f ; check mouse area for putpixel test eax, 0x04000000 - jnz @f -;-------------------------------------- -; check for Y - cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] - jae @f - - sub cx, [Y_UNDER_subtraction_CUR_hot_y] - jb @f - - rol ecx, 16 -;-------------------------------------- -; check for X - cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] - jae @f - - sub cx, [X_UNDER_subtraction_CUR_hot_x] - jb @f - - ror ecx, 16 - - call check_mouse_area_for_putpixel_new.1 -;-------------------------------------- -align 4 + jnz @f +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae @f + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb @f + + rol ecx, 16 +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae @f + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb @f + + ror ecx, 16 + + call check_mouse_area_for_putpixel_new.1 +;-------------------------------------- +align 4 @@: and eax, 0xffffff ; store to real LFB @@ -1391,30 +1391,30 @@ align 4 jne .skip ;-------------------------------------- mov ecx, [drbar.real_sy_and_abs_cy] - sub ecx, esi -;-------------------------------------- -; check for Y - cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] - jae .no_mouse_area - - sub cx, [Y_UNDER_subtraction_CUR_hot_y] - jb .no_mouse_area - - rol ecx, 16 - add ecx, [drbar.real_sx_and_abs_cx] - sub ecx, edi -;-------------------------------------- -; check for X - cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] - jae .no_mouse_area - - sub cx, [X_UNDER_subtraction_CUR_hot_x] - jb .no_mouse_area - - ror ecx, 16 -;-------------------------------------- -; check mouse area for putpixel - push eax + sub ecx, esi +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area + + rol ecx, 16 + add ecx, [drbar.real_sx_and_abs_cx] + sub ecx, edi +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + ror ecx, 16 +;-------------------------------------- +; check mouse area for putpixel + push eax call check_mouse_area_for_putpixel_new.1 mov [edx], ax shr eax, 16 @@ -1578,30 +1578,30 @@ align 4 jne .skip ;-------------------------------------- mov ecx, [drbar.real_sy_and_abs_cy] - sub ecx, esi -;-------------------------------------- -; check for Y - cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] - jae .no_mouse_area - - sub cx, [Y_UNDER_subtraction_CUR_hot_y] - jb .no_mouse_area - - rol ecx, 16 - add ecx, [drbar.real_sx_and_abs_cx] - sub ecx, edi -;-------------------------------------- -; check for X - cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] - jae .no_mouse_area - - sub cx, [X_UNDER_subtraction_CUR_hot_x] - jb .no_mouse_area - - ror ecx, 16 -;-------------------------------------- -; check mouse area for putpixel - push eax + sub ecx, esi +;-------------------------------------- +; check for Y + cmp cx, [Y_UNDER_sub_CUR_hot_y_add_curh] + jae .no_mouse_area + + sub cx, [Y_UNDER_subtraction_CUR_hot_y] + jb .no_mouse_area + + rol ecx, 16 + add ecx, [drbar.real_sx_and_abs_cx] + sub ecx, edi +;-------------------------------------- +; check for X + cmp cx, [X_UNDER_sub_CUR_hot_x_add_curh] + jae .no_mouse_area + + sub cx, [X_UNDER_subtraction_CUR_hot_x] + jb .no_mouse_area + + ror ecx, 16 +;-------------------------------------- +; check mouse area for putpixel + push eax call check_mouse_area_for_putpixel_new.1 mov [edx], eax pop eax diff --git a/kernel/branches/net/vmodeint.inc b/kernel/branches/net/vmodeint.inc deleted file mode 100644 index 80eb1c0430..0000000000 --- a/kernel/branches/net/vmodeint.inc +++ /dev/null @@ -1,58 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -$Revision$ - - -; -; Call of videomode driver's functions -; -; (Add in System function 21 (and/or 26) as a subfunction 13) -; -; Author: Trans -; Date: 19.07.2003 -; -; Include in MeOS kernel and compile with FASM -; - -uglobal - old_screen_width dd ? - old_screen_height dd ? -endg - -; cmp eax,13 ; CALL VIDEOMODE DRIVER FUNCTIONS - dec ebx - jnz .no_vmode_drv_access - pushd [Screen_Max_X] [Screen_Max_Y] - popd [old_screen_height] [old_screen_width] - or eax,-1 ; If driver is absent then eax does not change - call (VMODE_BASE+0x100) ; Entry point of video driver - mov [esp+36-4],eax - mov [esp+24-4],ebx - mov [esp+32-4],ecx -; mov [esp+28],edx - mov eax,[old_screen_width] - mov ebx,[old_screen_height] - sub eax,[Screen_Max_X] - jnz @f - sub ebx,[Screen_Max_Y] - jz .resolution_wasnt_changed - jmp .lp1 - @@: sub ebx,[Screen_Max_Y] - .lp1: sub [screen_workarea.right],eax - sub [screen_workarea.bottom],ebx - - call repos_windows - xor eax,eax - xor ebx,ebx - mov ecx, [Screen_Max_X] - mov edx, [Screen_Max_Y] - call calculatescreen - - .resolution_wasnt_changed: - ret - .no_vmode_drv_access: diff --git a/kernel/branches/net/vmodeld.inc b/kernel/branches/net/vmodeld.inc deleted file mode 100644 index 3c5e512a23..0000000000 --- a/kernel/branches/net/vmodeld.inc +++ /dev/null @@ -1,35 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -$Revision$ - - -; -; Load of videomode driver in memory -; -; (driver is located at VMODE_BASE - 32kb) // if this area not occuped anything -; -; Author: Trans -; Date: 19.07.2003 -; -; Include in MeOS kernel and compile with FASM -; - - -; LOAD VIDEOMODE DRIVER - ; If vmode.mdr file not found - or eax,-1 ; Driver ID = -1 (not present in system) - mov [VMODE_BASE],eax ; - mov [VMODE_BASE+0x100],byte 0xC3 ; Instruction RETN - driver loop - - stdcall read_file, vmode, VMODE_BASE, 0, 0x8000 ;{SPraid.simba} -; mov esi, vmode -; xor ebx, ebx -; mov ecx, 0x8000 ; size of memory area for driver -; mov edx, VMODE_BASE ; Memory position of driver -; xor ebp, ebp -; call fs_RamdiskRead