From 822829ea7082f0cfc1e70e18fcd899eb03941639 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 5 Oct 2011 11:14:40 +0000 Subject: [PATCH] merge trunk git-svn-id: svn://kolibrios.org@2268 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/Kolibri-acpi/blkdev/disk.inc | 1090 +++++++------- .../branches/Kolibri-acpi/boot/bootcode.inc | 48 +- kernel/branches/Kolibri-acpi/boot/booteng.inc | 45 +- kernel/branches/Kolibri-acpi/boot/bootet.inc | 96 +- kernel/branches/Kolibri-acpi/boot/bootge.inc | 95 +- kernel/branches/Kolibri-acpi/boot/bootru.inc | 30 +- kernel/branches/Kolibri-acpi/boot/parsers.inc | 22 +- kernel/branches/Kolibri-acpi/boot/preboot.inc | 2 +- kernel/branches/Kolibri-acpi/build.bat | 4 +- kernel/branches/Kolibri-acpi/const.inc | 25 +- kernel/branches/Kolibri-acpi/data16.inc | 2 +- kernel/branches/Kolibri-acpi/data32.inc | 2 +- .../branches/Kolibri-acpi/docs/sysfuncr.txt | 9 + .../branches/Kolibri-acpi/docs/sysfuncs.txt | 11 + .../Kolibri-acpi/drivers/viasound.asm | 1281 ----------------- .../branches/Kolibri-acpi/drivers/vmode.asm | 736 ---------- .../Kolibri-acpi/drivers/vt823(x).asm | 1281 ----------------- kernel/branches/Kolibri-acpi/gui/window.inc | 85 +- kernel/branches/Kolibri-acpi/kernel.asm | 82 +- kernel/branches/Kolibri-acpi/vmodeint.inc | 58 - kernel/branches/Kolibri-acpi/vmodeld.inc | 35 - 21 files changed, 835 insertions(+), 4204 deletions(-) delete mode 100644 kernel/branches/Kolibri-acpi/drivers/viasound.asm delete mode 100644 kernel/branches/Kolibri-acpi/drivers/vmode.asm delete mode 100644 kernel/branches/Kolibri-acpi/drivers/vt823(x).asm delete mode 100644 kernel/branches/Kolibri-acpi/vmodeint.inc delete mode 100644 kernel/branches/Kolibri-acpi/vmodeld.inc diff --git a/kernel/branches/Kolibri-acpi/blkdev/disk.inc b/kernel/branches/Kolibri-acpi/blkdev/disk.inc index f97ded8172..ab74347b5e 100644 --- a/kernel/branches/Kolibri-acpi/blkdev/disk.inc +++ b/kernel/branches/Kolibri-acpi/blkdev/disk.inc @@ -5,26 +5,26 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 2140 $ +$Revision: 2257 $ ; ============================================================================= ; ================================= Constants ================================= ; ============================================================================= ; Error codes for callback functions. -DISK_STATUS_OK = 0 ; success +DISK_STATUS_OK = 0 ; success DISK_STATUS_GENERAL_ERROR = -1; if no other code is suitable DISK_STATUS_INVALID_CALL = 1 ; invalid input parameters -DISK_STATUS_NO_MEDIA = 2 ; no media present +DISK_STATUS_NO_MEDIA = 2 ; no media present DISK_STATUS_END_OF_MEDIA = 3 ; end of media while reading/writing data ; Driver flags. Represent bits in DISK.DriverFlags. DISK_NO_INSERT_NOTIFICATION = 1 ; Media flags. Represent bits in DISKMEDIAINFO.Flags. DISK_MEDIA_READONLY = 1 -; If we see too many partitions, probably there is some error on the disk. +; If too many partitions are detected,there is probably an error on the disk. ; 256 partitions should be enough for any reasonable use. -; Also, the same number is limiting the number of MBRs to process; if we see -; too many MBRs, probably there is a loop in the MBR structure. +; Also, the same number is limiting the number of MBRs to process; if +; too many MBRs are visible,there probably is a loop in the MBR structure. MAX_NUM_PARTITIONS = 256 ; ============================================================================= @@ -34,17 +34,17 @@ MAX_NUM_PARTITIONS = 256 ; device. They are implemented by a driver. Objects with this structure reside ; in a driver. struct DISKFUNC -.strucsize dd ? +.strucsize dd ? ; Size of the structure. This field is intended for possible extensions of ; this structure. If a new function is added to this structure and a driver ; implements an old version, the caller can detect this by checking .strucsize, ; so the driver remains compatible. -.close dd ? +.close dd ? ; The pointer to the function which frees all driver-specific resources for ; the disk. ; Optional, may be NULL. ; void close(void* userdata); -.closemedia dd ? +.closemedia dd ? ; The pointer to the function which informs the driver that the kernel has ; finished all processing with the current media. If media is removed, the ; driver should decline all requests to that media with DISK_STATUS_NO_MEDIA, @@ -53,24 +53,24 @@ struct DISKFUNC ; function is called. ; Optional, may be NULL (if media is not removable). ; void closemedia(void* userdata); -.querymedia dd ? +.querymedia dd ? ; The pointer to the function which determines capabilities of the media. ; int querymedia(void* userdata, DISKMEDIAINFO* info); ; Return value: one of DISK_STATUS_* -.read dd ? +.read dd ? ; The pointer to the function which reads data from the device. ; int read(void* userdata, void* buffer, __int64 startsector, int* numsectors); ; input: *numsectors = number of sectors to read ; output: *numsectors = number of sectors which were successfully read ; Return value: one of DISK_STATUS_* -.write dd ? +.write dd ? ; The pointer to the function which writes data to the device. ; Optional, may be NULL. ; int write(void* userdata, void* buffer, __int64 startsector, int* numsectors); ; input: *numsectors = number of sectors to write ; output: *numsectors = number of sectors which were successfully written ; Return value: one of DISK_STATUS_* -.flush dd ? +.flush dd ? ; The pointer to the function which flushes the internal device cache. ; Optional, may be NULL. ; int flush(void* userdata); @@ -78,37 +78,37 @@ struct DISKFUNC ; Note that read/write are called by the cache manager, so a driver should not ; create a software cache. This function is implemented for flushing a hardware ; cache, if it exists. -.adjust_cache_size dd ? +.adjust_cache_size dd ? ; The pointer to the function which returns the cache size for this device. ; Optional, may be NULL. ; unsigned int adjust_cache_size(unsigned int suggested_size); ; Return value: 0 = disable cache, otherwise = used cache size in bytes. ends -; This structure holds an information about a media. -; Objects with this structure are allocated by the kernel as a part of DISK -; structure and filled by a driver in the 'querymedia' callback. +; This structure holds information on a medium. +; Objects with this structure are allocated by the kernel as a part of the DISK +; structure and are filled by a driver in the 'querymedia' callback. struct DISKMEDIAINFO -.Flags dd ? +.Flags dd ? ; Combination of DISK_MEDIA_* bits. -.SectorSize dd ? +.SectorSize dd ? ; Size of the sector. -.Capacity dq ? +.Capacity dq ? ; Size of the media in sectors. ends -; This structure represents disk cache. To follow the old implementation, -; there are two distinct caches for a disk, one for "system" data, other +; This structure represents the disk cache. To follow the old implementation, +; there are two distinct caches for a disk, one for "system" data,and the other ; for "application" data. struct DISKCACHE -.Lock MUTEX +.Lock MUTEX ; Lock to protect the cache. ; The following fields are inherited from data32.inc:cache_ideX. .pointer rd 1 .data_size rd 1 ; not use -.data rd 1 +.data rd 1 .sad_size rd 1 -.search_start rd 1 +.search_start rd 1 ends ; This structure represents a disk device and its media for the kernel. @@ -116,23 +116,23 @@ ends ; freed in the 'disk_dereference' function. struct DISK ; Fields of disk object -.Next dd ? -.Prev dd ? +.Next dd ? +.Prev dd ? ; All disk devices are linked in one list with these two fields. ; Head of the list is the 'disk_list' variable. -.Functions dd ? +.Functions dd ? ; Pointer to the 'DISKFUNC' structure with driver functions. -.Name dd ? +.Name dd ? ; Pointer to the string used for accesses through the global filesystem. -.UserData dd ? +.UserData dd ? ; This field is passed to all callback functions so a driver can decide which ; physical device is addressed. -.DriverFlags dd ? +.DriverFlags dd ? ; Bitfield. Currently only DISK_NO_INSERT_NOTIFICATION bit is defined. ; If it is set, the driver will never issue 'disk_media_changed' notification ; with argument set to true, so the kernel must try to detect media during ; requests from the file system. -.RefCount dd ? +.RefCount dd ? ; Count of active references to this structure. One reference is kept during ; the lifetime of the structure between 'disk_add' and 'disk_del'. ; Another reference is taken during any filesystem operation for this disk. @@ -140,37 +140,37 @@ struct DISK ; The structure is destroyed when the reference count decrements to zero: ; this usually occurs in 'disk_del', but can be delayed to the end of last ; filesystem operation, if one is active. -.MediaLock MUTEX +.MediaLock MUTEX ; Lock to protect the MEDIA structure. See the description after ; 'disk_list_mutex' for the locking strategy. ; Fields of media object -.MediaInserted db ? +.MediaInserted db ? ; 0 if media is not inserted, nonzero otherwise. -.MediaUsed db ? +.MediaUsed db ? ; 0 if media fields are not used, nonzero otherwise. If .MediaRefCount is ; nonzero, this field is nonzero too; however, when .MediaRefCount goes ; to zero, there is some time interval during which media object is still used. - align 4 + align 4 ; The following fields are not valid unless either .MediaInserted is nonzero ; or they are accessed from a code which has obtained the reference when ; .MediaInserted was nonzero. -.MediaRefCount dd ? +.MediaRefCount dd ? ; Count of active references to the media object. One reference is kept during ; the lifetime of the media between two calls to 'disk_media_changed'. ; Another reference is taken during any filesystem operation for this media. ; The callback 'closemedia' is called when the reference count decrements to ; zero: this usually occurs in 'disk_media_changed', but can be delayed to the -; end of last filesystem operation, if one is active. -.MediaInfo DISKMEDIAINFO -; This field keeps an information about the current media. -.NumPartitions dd ? +; end of the last filesystem operation, if one is active. +.MediaInfo DISKMEDIAINFO +; This field keeps information on the current media. +.NumPartitions dd ? ; Number of partitions on this media. -.Partitions dd ? +.Partitions dd ? ; Pointer to array of .NumPartitions pointers to PARTITION structures. -.cache_size dd ? +.cache_size dd ? ; inherited from cache_ideX_size -.SysCache DISKCACHE -.AppCache DISKCACHE +.SysCache DISKCACHE +.AppCache DISKCACHE ; Two caches for the disk. ends @@ -178,13 +178,13 @@ ends ; template, the actual contents after common fields is determined by the ; file system code for this partition. struct PARTITION -.FirstSector dq ? +.FirstSector dq ? ; First sector of the partition. -.Length dq ? +.Length dq ? ; Length of the partition in sectors. -.Disk dd ? +.Disk dd ? ; Pointer to parent DISK structure. -.FSUserFunctions dd ? +.FSUserFunctions dd ? ; Handlers for the sysfunction 70h. This field is a pointer to the following ; array. The first dword is a number of supported subfunctions, other dwords ; point to handlers of corresponding subfunctions. @@ -194,23 +194,23 @@ ends ; This is an external structure, it represents an entry in the partition table. struct PARTITION_TABLE_ENTRY -.Bootable db ? +.Bootable db ? ; 80h = bootable partition, 0 = non-bootable partition, other values = invalid -.FirstHead db ? -.FirstSector db ? -.FirstTrack db ? +.FirstHead db ? +.FirstSector db ? +.FirstTrack db ? ; Coordinates of first sector in CHS. -.Type db ? +.Type db ? ; Partition type, one of predefined constants. 0 = empty, several types denote ; extended partition (see process_partition_table_entry), we are not interested ; in other values. -.LastHead db ? -.LastSector db ? -.LastTrack db ? +.LastHead db ? +.LastSector db ? +.LastTrack db ? ; Coordinates of last sector in CHS. -.FirstAbsSector dd ? +.FirstAbsSector dd ? ; Coordinate of first sector in LBA. -.Length dd ? +.Length dd ? ; Length of the partition in sectors. ends @@ -221,15 +221,15 @@ iglobal ; The pseudo-item for the list of all DISK structures. ; Initialized to the empty list. disk_list: - dd disk_list - dd disk_list + dd disk_list + dd disk_list endg uglobal ; This mutex guards all operations with the global list of DISK structures. disk_list_mutex MUTEX -; * There are two dependent objects, a disk and a media. In the simplest case +; * There are two dependent objects, a disk and a media. In the simplest case, ; disk and media are both non-removable. However, in the general case both -; can be removed at any time, simultaneously or only media, this makes things +; can be removed at any time, simultaneously or only media,and this makes things ; complicated. ; * For efficiency, both disk and media objects are located in the one ; structure named DISK. However, logically they are different. @@ -284,14 +284,14 @@ iglobal ; decrements the value when the job is done. Otherwise, it immediately ; decrements the value and uses buffers from the heap, allocated in the ; beginning and freed in the end. -partition_buffer_users dd -1 +partition_buffer_users dd -1 endg uglobal ; The static buffers for MBR, bootsector and fs-temporary sector data. align 16 -mbr_buffer rb 512 -bootsect_buffer rb 512 -fs_tmp_buffer rb 512 +mbr_buffer rb 512 +bootsect_buffer rb 512 +fs_tmp_buffer rb 512 endg iglobal @@ -300,13 +300,13 @@ iglobal ; have the default implementations. align 4 disk_default_callbacks: - dd disk_default_close - dd disk_default_closemedia - dd disk_default_querymedia - dd disk_default_read - dd disk_default_write - dd disk_default_flush - dd disk_default_adjust_cache_size + dd disk_default_close + dd disk_default_closemedia + dd disk_default_querymedia + dd disk_default_read + dd disk_default_write + dd disk_default_flush + dd disk_default_adjust_cache_size endg ; ============================================================================= @@ -332,79 +332,79 @@ endg ; in the operations with other Disk* functions. ; The handle is the pointer to the internal structure DISK. disk_add: - push ebx esi ; save used registers to be stdcall + push ebx esi ; save used registers to be stdcall ; 1. Allocate the DISK structure. ; 1a. Call the heap manager. - push sizeof.DISK - pop eax - call malloc + push sizeof.DISK + pop eax + call malloc ; 1b. Check the result. If allocation failed, return (go to 9) with eax = 0. - test eax, eax - jz .nothing -; 2. Copy disk name to the DISK structure. + test eax, eax + jz .nothing +; 2. Copy the disk name to the DISK structure. ; 2a. Get length of the name, including the terminating zero. - mov ebx, [esp+8+8] ; ebx = pointer to name - push eax ; save allocated pointer to DISK - xor eax, eax ; the argument of malloc() is in eax + mov ebx, [esp+8+8] ; ebx = pointer to name + 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 + inc eax + cmp byte [ebx+eax-1], 0 + jnz @b ; 2b. Call the heap manager. - call malloc + call malloc ; 2c. Check the result. If allocation failed, go to 7. - pop esi ; restore allocated pointer to DISK - test eax, eax - jz .free + 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 + mov [esi+DISK.Name], eax ; 2e. Copy the name. @@: - mov dl, [ebx] - mov [eax], dl - inc ebx - inc eax - test dl, dl - jnz @b + mov dl, [ebx] + mov [eax], dl + inc ebx + inc eax + test dl, dl + jnz @b ; 3. Copy other arguments of the function to the DISK structure. - mov eax, [esp+4+8] - mov [esi+DISK.Functions], eax - mov eax, [esp+12+8] - mov [esi+DISK.UserData], eax - mov eax, [esp+16+8] - mov [esi+DISK.DriverFlags], eax + mov eax, [esp+4+8] + mov [esi+DISK.Functions], eax + mov eax, [esp+12+8] + mov [esi+DISK.UserData], eax + mov eax, [esp+16+8] + mov [esi+DISK.DriverFlags], eax ; 4. Initialize other fields of the DISK structure. ; Media is not inserted, reference counter is 1. - lea ecx, [esi+DISK.MediaLock] - call mutex_init - xor eax, eax - mov dword [esi+DISK.MediaInserted], eax - inc eax - mov [esi+DISK.RefCount], eax + lea ecx, [esi+DISK.MediaLock] + call mutex_init + xor eax, eax + mov dword [esi+DISK.MediaInserted], eax + inc eax + mov [esi+DISK.RefCount], eax ; The DISK structure is initialized. ; 5. Insert the new structure to the global list. ; 5a. Acquire the mutex. - mov ecx, disk_list_mutex - call mutex_lock + mov ecx, disk_list_mutex + call mutex_lock ; 5b. Insert item to the tail of double-linked list. - mov edx, disk_list - list_add_tail esi, edx ;esi= new edx= list head + mov edx, disk_list + list_add_tail esi, edx ;esi= new edx= list head ; 5c. Release the mutex. - call mutex_unlock + call mutex_unlock ; 6. Return with eax = pointer to DISK. - xchg eax, esi - jmp .nothing + xchg eax, esi + jmp .nothing .free: ; Memory allocation for DISK structure succeeded, but for disk name failed. ; 7. Free the DISK structure. - xchg eax, esi - call free + xchg eax, esi + call free ; 8. Return with eax = 0. - xor eax, eax + xor eax, eax .nothing: ; 9. Return. - pop esi ebx ; restore used registers to be stdcall - ret 16 ; purge 4 dword arguments to be stdcall + pop esi ebx ; restore used registers to be stdcall + ret 16 ; purge 4 dword arguments to be stdcall ; This function deletes a disk device from the global filesystem. ; This includes: @@ -415,29 +415,29 @@ 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 + 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+8] ; esi = handle of the disk - stdcall disk_media_changed, esi, 0 + mov esi, [esp+4+8] ; 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 + mov ecx, disk_list_mutex + call mutex_lock ; 2b. Delete item from double-linked list. - mov eax, [esi+DISK.Next] - mov edx, [esi+DISK.Prev] - mov [eax+DISK.Prev], edx - mov [edx+DISK.Next], eax + mov eax, [esi+DISK.Next] + mov edx, [esi+DISK.Prev] + mov [eax+DISK.Prev], edx + mov [edx+DISK.Next], eax ; 2c. Release the mutex. - call mutex_unlock + call mutex_unlock ; 3. The structure still has one reference created in disk_add. Remove this ; reference. If there are no other references, disk_dereference will free the ; structure. - call disk_dereference + call disk_dereference ; 4. Return. - pop esi ; restore used registers to be stdcall - ret 4 ; purge 1 dword argument to be stdcall + pop esi ; restore used registers to be stdcall + ret 4 ; purge 1 dword argument to be stdcall ; This is an internal function which removes a previously obtained reference ; to the disk. If this is the last reference, this function lets the driver @@ -446,21 +446,21 @@ disk_del: disk_dereference: ; 1. Decrement reference counter. Use atomic operation to correctly handle ; possible simultaneous calls. -lock dec [esi+DISK.RefCount] +lock dec [esi+DISK.RefCount] ; 2. If the result is nonzero, there are other references, so nothing to do. ; In this case, return (go to 4). - jnz .nothing + jnz .nothing ; 3. If we are here, we just removed the last reference and must destroy the ; disk object. ; 3a. Call the driver. - mov al, DISKFUNC.close - stdcall disk_call_driver + mov al, DISKFUNC.close + stdcall disk_call_driver ; 3b. Free the structure. - xchg eax, esi - call free + xchg eax, esi + call free ; 4. Return. .nothing: - ret + ret ; This is an internal function which removes a previously obtained reference ; to the media. If this is the last reference, this function calls 'closemedia' @@ -470,10 +470,10 @@ lock dec [esi+DISK.RefCount] disk_media_dereference: ; 1. Decrement reference counter. Use atomic operation to correctly handle ; possible simultaneous calls. -lock dec [esi+DISK.MediaRefCount] +lock dec [esi+DISK.MediaRefCount] ; 2. If the result is nonzero, there are other references, so nothing to do. ; In this case, return (go to 4). - jnz .nothing + jnz .nothing ; 3. If we are here, we just removed the last reference and must destroy the ; media object. ; Note that the same place inside the DISK structure is reused for all media @@ -492,27 +492,27 @@ lock dec [esi+DISK.MediaRefCount] ; does not matter when this flag is cleared. In the second case this flag must ; be cleared after all other actions, including call to 'closemedia'. ; 3a. Free all partitions. - push esi edi - mov edi, [esi+DISK.NumPartitions] - mov esi, [esi+DISK.Partitions] - test edi, edi - jz .nofree + push esi edi + mov edi, [esi+DISK.NumPartitions] + mov esi, [esi+DISK.Partitions] + test edi, edi + jz .nofree .freeloop: - lodsd - call free - dec edi - jnz .freeloop + lodsd + call free + dec edi + jnz .freeloop .nofree: - pop edi esi + pop edi esi ; 3b. Free the cache. - call disk_free_cache + call disk_free_cache ; 3c. Call the driver. - mov al, DISKFUNC.closemedia - stdcall disk_call_driver + mov al, DISKFUNC.closemedia + stdcall disk_call_driver ; 3d. Clear the flag. - mov [esi+DISK.MediaUsed], 0 + mov [esi+DISK.MediaUsed], 0 .nothing: - ret + ret ; This function is called by the driver and informs the kernel that the media ; has changed. If the media is non-removable, it is called exactly once @@ -521,28 +521,28 @@ lock dec [esi+DISK.MediaRefCount] ; [esp+4] = handle of the disk, i.e. the pointer to the DISK structure. ; [esp+8] = new status of the media: zero = no media, nonzero = media inserted. disk_media_changed: - push ebx esi edi ; save used registers to be stdcall + push ebx esi edi ; save used registers to be stdcall ; 1. Remove the existing media, if it is present. - mov esi, [esp+4+12] ; esi = pointer to DISK + mov esi, [esp+4+12] ; esi = pointer to DISK ; 1a. Check whether it is present. Since DISK.MediaInserted is changed only ; in this function and calls to this function are synchronized, no lock is ; required for checking. - cmp [esi+DISK.MediaInserted], 0 - jz .noremove + cmp [esi+DISK.MediaInserted], 0 + jz .noremove ; We really need to remove the media. ; 1b. Acquire mutex. - lea ecx, [esi+DISK.MediaLock] - call mutex_lock + lea ecx, [esi+DISK.MediaLock] + call mutex_lock ; 1c. Clear the flag. - mov [esi+DISK.MediaInserted], 0 + mov [esi+DISK.MediaInserted], 0 ; 1d. Release mutex. - call mutex_unlock + call mutex_unlock ; 1e. Remove the "lifetime" reference and possibly destroy the structure. - call disk_media_dereference + call disk_media_dereference .noremove: ; 2. Test whether there is new media. - cmp dword [esp+8+12], 0 - jz .noinsert + cmp dword [esp+8+12], 0 + jz .noinsert ; Yep, there is. ; 3. Process the new media. We assume that all media fields are available to ; use, see comments in 'disk_media_dereference' (this covers using by previous @@ -550,28 +550,28 @@ disk_media_changed: ; (this covers using by new media referencers). ; 3a. Call the 'querymedia' callback. ; .Flags are set to zero for possible future extensions. - lea edx, [esi+DISK.MediaInfo] - and [edx+DISKMEDIAINFO.Flags], 0 - mov al, DISKFUNC.querymedia - stdcall disk_call_driver, edx + lea edx, [esi+DISK.MediaInfo] + and [edx+DISKMEDIAINFO.Flags], 0 + mov al, DISKFUNC.querymedia + stdcall disk_call_driver, edx ; 3b. Check the result of the callback. Abort if it failed. - test eax, eax - jnz .noinsert + test eax, eax + jnz .noinsert ; 3c. Allocate the cache unless disabled by the driver. Abort if failed. - call disk_init_cache - test al, al - jz .noinsert + call disk_init_cache + test al, al + jz .noinsert ; 3d. Acquire the lifetime reference for the media object. - inc [esi+DISK.MediaRefCount] + inc [esi+DISK.MediaRefCount] ; 3e. Scan for partitions. Ignore result; the list of partitions is valid even ; on errors. - call disk_scan_partitions + call disk_scan_partitions ; 3f. Media is inserted and available for use. - inc [esi+DISK.MediaInserted] + inc [esi+DISK.MediaInserted] .noinsert: ; 4. Return. - pop edi esi ebx ; restore used registers to be stdcall - ret 8 ; purge 2 dword arguments to be stdcall + pop edi esi ebx ; restore used registers to be stdcall + ret 8 ; purge 2 dword arguments to be stdcall ; This function is a thunk for all functions of a disk driver. ; It checks whether the referenced function is implemented in the driver. @@ -582,78 +582,78 @@ disk_media_changed: ; stack is the same as for the corresponding function except that the ; first parameter (void* userdata) is prepended automatically. disk_call_driver: - movzx eax, al ; eax = offset of function in the DISKFUNC structure + movzx eax, al ; eax = offset of function in the DISKFUNC structure ; 1. Prepend the first argument to the stack. - pop ecx ; ecx = return address - push [esi+DISK.UserData] ; add argument - push ecx ; save return address + pop ecx ; ecx = return address + push [esi+DISK.UserData] ; add argument + push ecx ; save return address ; 2. Check that the required function is inside the table. If not, go to 5. - mov ecx, [esi+DISK.Functions] - cmp eax, [ecx+DISKFUNC.strucsize] - jae .default + mov ecx, [esi+DISK.Functions] + cmp eax, [ecx+DISKFUNC.strucsize] + jae .default ; 3. Check that the required function is implemented. If not, go to 5. - mov ecx, [ecx+eax] - test ecx, ecx - jz .default + mov ecx, [ecx+eax] + test ecx, ecx + jz .default ; 4. Jump to the required function. - jmp ecx + jmp ecx .default: ; 5. Driver does not implement the required function; use default implementation. - jmp dword [disk_default_callbacks+eax-4] + jmp dword [disk_default_callbacks+eax-4] ; The default implementation of DISKFUNC.querymedia. disk_default_querymedia: - push DISK_STATUS_INVALID_CALL - pop eax - ret 8 + push DISK_STATUS_INVALID_CALL + pop eax + ret 8 ; The default implementation of DISKFUNC.read and DISKFUNC.write. disk_default_read: disk_default_write: - push DISK_STATUS_INVALID_CALL - pop eax - ret 20 + push DISK_STATUS_INVALID_CALL + pop eax + ret 20 ; The default implementation of DISKFUNC.close, DISKFUNC.closemedia and ; DISKFUNC.flush. disk_default_close: disk_default_closemedia: disk_default_flush: - xor eax, eax - ret 4 + xor eax, eax + ret 4 ; The default implementation of DISKFUNC.adjust_cache_size. disk_default_adjust_cache_size: - mov eax, [esp+4] - ret 4 + mov eax, [esp+4] + ret 4 -; This is an internal function called from 'disk_media_changed' when new media +; 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. disk_scan_partitions: ; 1. Initialize .NumPartitions and .Partitions fields as zeros: empty list. - and [esi+DISK.NumPartitions], 0 - and [esi+DISK.Partitions], 0 + and [esi+DISK.NumPartitions], 0 + and [esi+DISK.Partitions], 0 ; 2. Currently we can work only with 512-bytes sectors. Check this restriction. ; The only exception is 2048-bytes CD/DVD, but they are not supported yet by ; this code. - cmp [esi+DISK.MediaInfo.SectorSize], 512 - jz .doscan - DEBUGF 1,'K : sector size is %d, only 512 is supported\n',[esi+DISK.MediaInfo.SectorSize] - ret + cmp [esi+DISK.MediaInfo.SectorSize], 512 + jz .doscan + DEBUGF 1,'K : sector size is %d, only 512 is supported\n',[esi+DISK.MediaInfo.SectorSize] + ret .doscan: ; 3. Acquire the buffer for MBR and bootsector tests. See the comment before ; the 'partition_buffer_users' variable. - mov ebx, mbr_buffer ; assume the global buffer is free -lock inc [partition_buffer_users] - jz .buffer_acquired ; yes, it is free -lock dec [partition_buffer_users] ; no, we must allocate - stdcall kernel_alloc, 512*3 - test eax, eax - jz .nothing - xchg eax, ebx + mov ebx, mbr_buffer ; assume the global buffer is free +lock inc [partition_buffer_users] + jz .buffer_acquired ; yes, it is free +lock dec [partition_buffer_users] ; no, we must allocate + stdcall kernel_alloc, 512*3 + test eax, eax + jz .nothing + xchg eax, ebx .buffer_acquired: ; MBR/EBRs are organized in the chain. We use a loop over MBR/EBRs, but no ; more than MAX_NUM_PARTITION times. @@ -662,127 +662,127 @@ lock dec [partition_buffer_users] ; no, we must allocate ; [esp] will hold the sector number for current extended partition, if there ; is one. ; [esp+4] will hold the counter that prevents long loops. - push ebp ; save ebp - push MAX_NUM_PARTITIONS ; the counter of max MBRs to process - xor ebp, ebp ; start from sector zero - push ebp ; no extended partition yet + push ebp ; save ebp + push MAX_NUM_PARTITIONS ; the counter of max MBRs to process + xor ebp, ebp ; start from sector zero + push ebp ; no extended partition yet .new_mbr: ; 5. Read the current sector. ; Note that 'read' callback operates with 64-bit sector numbers, so we must ; push additional zero as a high dword of sector number. - mov al, DISKFUNC.read - push 1 - stdcall disk_call_driver, ebx, ebp, 0, esp - pop ecx + mov al, DISKFUNC.read + push 1 + stdcall disk_call_driver, ebx, ebp, 0, esp + pop ecx ; 6. If the read has failed, abort the loop. - dec ecx - jnz .mbr_failed + dec ecx + jnz .mbr_failed ; 7. Check the MBR/EBR signature. If it is wrong, abort the loop. ; Soon we will access the partition table which starts at ebx+0x1BE, ; so we can fill its address right now. If we do it now, then the addressing ; [ecx+0x40] is shorter than [ebx+0x1fe]: one-byte offset vs 4-bytes offset. - lea ecx, [ebx+0x1be] ; ecx -> partition table - cmp word [ecx+0x40], 0xaa55 - jnz .mbr_failed + lea ecx, [ebx+0x1be] ; ecx -> partition table + cmp word [ecx+0x40], 0xaa55 + jnz .mbr_failed ; 8. The MBR is treated differently from EBRs. For MBR we additionally need to ; execute step 9 and possibly step 10. - test ebp, ebp - jnz .mbr -; Partition table can be present or not present. In the first case, we just -; read the MBR. In the second case, we just read the bootsector for some + test ebp, ebp + jnz .mbr +; The partition table can be present or not present. In the first case, we just +; read the MBR. In the second case, we just read the bootsector for a ; filesystem. -; We use the following algorithm to distinguish between these cases. +; The following algorithm is used to distinguish between these cases. ; A. If at least one entry of the partition table is invalid, this is ; a bootsector. See the description of 'is_partition_table_entry' for ; definition of validity. ; B. If all entries are empty (filesystem type field is zero) and the first ; byte is jmp opcode (0EBh or 0E9h), this is a bootsector which happens to ; have zeros in the place of partition table. -; C. Otherwise, this is a MBR. +; C. Otherwise, this is an MBR. ; 9. Test for MBR vs bootsector. ; 9a. Check entries. If any is invalid, go to 10 (rule A). - call is_partition_table_entry - jc .notmbr - add ecx, 10h - call is_partition_table_entry - jc .notmbr - add ecx, 10h - call is_partition_table_entry - jc .notmbr - add ecx, 10h - call is_partition_table_entry - jc .notmbr + call is_partition_table_entry + jc .notmbr + add ecx, 10h + call is_partition_table_entry + jc .notmbr + add ecx, 10h + call is_partition_table_entry + jc .notmbr + add ecx, 10h + call is_partition_table_entry + jc .notmbr ; 9b. Check types of the entries. If at least one is nonzero, go to 11 (rule C). - mov al, [ecx-30h+PARTITION_TABLE_ENTRY.Type] - or al, [ecx-20h+PARTITION_TABLE_ENTRY.Type] - or al, [ecx-10h+PARTITION_TABLE_ENTRY.Type] - or al, [ecx+PARTITION_TABLE_ENTRY.Type] - jnz .mbr + mov al, [ecx-30h+PARTITION_TABLE_ENTRY.Type] + or al, [ecx-20h+PARTITION_TABLE_ENTRY.Type] + or al, [ecx-10h+PARTITION_TABLE_ENTRY.Type] + or al, [ecx+PARTITION_TABLE_ENTRY.Type] + jnz .mbr ; 9c. Empty partition table or bootsector with many zeroes? (rule B) - cmp byte [ebx], 0EBh - jz .notmbr - cmp byte [ebx], 0E9h - jnz .mbr + cmp byte [ebx], 0EBh + jz .notmbr + cmp byte [ebx], 0E9h + jnz .mbr .notmbr: -; 10. This is not MBR. The media is not partitioned. Create one partition +; 10. This is not an MBR. The media is not partitioned. Create one partition ; which covers all the media and abort the loop. - stdcall disk_add_partition, 0, 0, \ - dword [esi+DISK.MediaInfo.Capacity], dword [esi+DISK.MediaInfo.Capacity+4] - jmp .done + stdcall disk_add_partition, 0, 0, \ + dword [esi+DISK.MediaInfo.Capacity], dword [esi+DISK.MediaInfo.Capacity+4] + jmp .done .mbr: ; 11. Process all entries of the new MBR/EBR - lea ecx, [ebx+0x1be] ; ecx -> partition table - push 0 ; assume no extended partition - call process_partition_table_entry - add ecx, 10h - call process_partition_table_entry - add ecx, 10h - call process_partition_table_entry - add ecx, 10h - call process_partition_table_entry - pop ebp + lea ecx, [ebx+0x1be] ; ecx -> partition table + push 0 ; assume no extended partition + call process_partition_table_entry + add ecx, 10h + call process_partition_table_entry + add ecx, 10h + call process_partition_table_entry + add ecx, 10h + call process_partition_table_entry + pop ebp ; 12. Test whether we found a new EBR and should continue the loop. ; 12a. If there was no next EBR, return. - test ebp, ebp - jz .done + test ebp, ebp + jz .done ; Ok, we have EBR. ; 12b. EBRs addresses are relative to the start of extended partition. ; For simplicity, just abort if an 32-bit overflow occurs; large disks ; are most likely partitioned with GPT, not MBR scheme, since the precise ; calculation here would increase limit just twice at the price of big ; compatibility problems. - pop eax ; load extended partition - add ebp, eax - jc .mbr_failed + pop eax ; load extended partition + add ebp, eax + jc .mbr_failed ; 12c. If extended partition has not yet started, start it. - test eax, eax - jnz @f - mov eax, ebp + test eax, eax + jnz @f + mov eax, ebp @@: ; 12c. If the limit is not exceeded, continue the loop. - dec dword [esp] - push eax ; store extended partition - jnz .new_mbr + dec dword [esp] + push eax ; store extended partition + jnz .new_mbr .mbr_failed: .done: ; 13. Cleanup after the loop. - pop eax ; not important anymore - pop eax ; not important anymore - pop ebp ; restore ebp + pop eax ; not important anymore + pop eax ; not important anymore + pop ebp ; restore ebp ; 14. Release the buffer. ; 14a. Test whether it is the global buffer or we have allocated it. - cmp ebx, mbr_buffer - jz .release_partition_buffer + cmp ebx, mbr_buffer + jz .release_partition_buffer ; 14b. If we have allocated it, free it. - xchg eax, ebx - call free - jmp .nothing + xchg eax, ebx + call free + jmp .nothing ; 14c. Otherwise, release reference. .release_partition_buffer: -lock dec [partition_buffer_users] +lock dec [partition_buffer_users] .nothing: ; 15. Return. - ret + ret ; This is an internal function called from disk_scan_partitions. It checks ; whether the entry pointed to by ecx is a valid entry of partition table. @@ -792,33 +792,33 @@ lock dec [partition_buffer_users] ; greater than the real size. is_partition_table_entry: ; 1. Check .Bootable field. - mov al, [ecx+PARTITION_TABLE_ENTRY.Bootable] - and al, 7Fh - jnz .invalid + mov al, [ecx+PARTITION_TABLE_ENTRY.Bootable] + and al, 7Fh + jnz .invalid ; 3. Calculate first sector + length. Note that .FirstAbsSector is relative ; to the MBR/EBR, so the real sum is ebp + .FirstAbsSector + .Length. - mov eax, ebp - xor edx, edx - add eax, [ecx+PARTITION_TABLE_ENTRY.FirstAbsSector] - adc edx, 0 - add eax, [ecx+PARTITION_TABLE_ENTRY.Length] - adc edx, 0 + mov eax, ebp + xor edx, edx + add eax, [ecx+PARTITION_TABLE_ENTRY.FirstAbsSector] + adc edx, 0 + add eax, [ecx+PARTITION_TABLE_ENTRY.Length] + adc edx, 0 ; 4. Divide by two. - shr edx, 1 - rcr eax, 1 + shr edx, 1 + rcr eax, 1 ; 5. Compare with capacity. If the subtraction (edx:eax) - .Capacity does not ; overflow, this is bad. - sub eax, dword [esi+DISK.MediaInfo.Capacity] - sbb edx, dword [esi+DISK.MediaInfo.Capacity+4] - jnc .invalid + sub eax, dword [esi+DISK.MediaInfo.Capacity] + sbb edx, dword [esi+DISK.MediaInfo.Capacity+4] + jnc .invalid .valid: ; 5. Return success: CF is cleared. - clc - ret + clc + ret .invalid: ; 6. Return fail: CF is set. - stc - ret + stc + ret ; This is an internal function called from disk_scan_partitions. It processes ; the entry pointed to by ecx. @@ -831,48 +831,48 @@ is_partition_table_entry: ; fs-specific checks do this more reliably. process_partition_table_entry: ; 1. Check for valid entry. If invalid, return (go to 5). - call is_partition_table_entry - jc .nothing + call is_partition_table_entry + jc .nothing ; 2. Check for empty entry. If invalid, return (go to 5). - mov al, [ecx+PARTITION_TABLE_ENTRY.Type] - test al, al - jz .nothing + mov al, [ecx+PARTITION_TABLE_ENTRY.Type] + test al, al + jz .nothing ; 3. Check for extended partition. If extended, go to 6. irp type,\ - 0x05,\ ; DOS: extended partition - 0x0f,\ ; WIN95: extended partition, LBA-mapped - 0xc5,\ ; DRDOS/secured: extended partition - 0xd5 ; Old Multiuser DOS secured: extended partition + 0x05,\ ; DOS: extended partition + 0x0f,\ ; WIN95: extended partition, LBA-mapped + 0xc5,\ ; DRDOS/secured: extended partition + 0xd5 ; Old Multiuser DOS secured: extended partition { - cmp al, type - jz .extended + cmp al, type + jz .extended } ; 4. If we are here, that is a normal partition. Add it to the list. ; Note that the first sector is relative to MBR/EBR. - mov eax, ebp - xor edx, edx - add eax, [ecx+PARTITION_TABLE_ENTRY.FirstAbsSector] - adc edx, 0 - push ecx - stdcall disk_add_partition, eax, edx, \ - [ecx+PARTITION_TABLE_ENTRY.Length], 0 - pop ecx + mov eax, ebp + xor edx, edx + add eax, [ecx+PARTITION_TABLE_ENTRY.FirstAbsSector] + adc edx, 0 + push ecx + stdcall disk_add_partition, eax, edx, \ + [ecx+PARTITION_TABLE_ENTRY.Length], 0 + pop ecx .nothing: ; 5. Return. - ret + ret .extended: ; 6. If we are here, that is an extended partition. Store the address. - mov eax, [ecx+PARTITION_TABLE_ENTRY.FirstAbsSector] - mov [esp+4], eax - ret + mov eax, [ecx+PARTITION_TABLE_ENTRY.FirstAbsSector] + mov [esp+4], eax + ret ; This is an internal function called from disk_scan_partitions and ; process_partition_table_entry. It adds one partition to the list of ; partitions for the media. proc disk_add_partition stdcall uses ebx edi, start:qword, length:qword ; 1. Check that this partition will not exceed the limit on total number. - cmp [esi+DISK.NumPartitions], MAX_NUM_PARTITIONS - jae .nothing + cmp [esi+DISK.NumPartitions], MAX_NUM_PARTITIONS + jae .nothing ; 2. Check that this partition does not overlap with any already registered ; partition. Since any file system assumes that the disk data will not change ; outside of its control, such overlap could be destructive. @@ -880,88 +880,88 @@ proc disk_add_partition stdcall uses ebx edi, start:qword, length:qword ; to be large, the simple linear search is sufficient. ; 2a. Prepare the loop: edi will point to the current item of .Partitions ; array, ecx will be the current item, ebx will hold number of items left. - mov edi, [esi+DISK.Partitions] - mov ebx, [esi+DISK.NumPartitions] - test ebx, ebx - jz .partitionok + mov edi, [esi+DISK.Partitions] + mov ebx, [esi+DISK.NumPartitions] + test ebx, ebx + jz .partitionok .scan_existing: ; 2b. Get the next partition. - mov ecx, [edi] - add edi, 4 + mov ecx, [edi] + add edi, 4 ; The range [.FirstSector, .FirstSector+.Length) must be either entirely to ; the left of [start, start+length) or entirely to the right. ; 2c. Subtract .FirstSector - start. The possible overflow distinguish between ; cases "to the left" (2e) and "to the right" (2d). - mov eax, dword [ecx+PARTITION.FirstSector] - mov edx, dword [ecx+PARTITION.FirstSector+4] - sub eax, dword [start] - sbb edx, dword [start+4] - jb .less + mov eax, dword [ecx+PARTITION.FirstSector] + mov edx, dword [ecx+PARTITION.FirstSector+4] + sub eax, dword [start] + sbb edx, dword [start+4] + jb .less ; 2d. .FirstSector is greater than or equal to start. Check that .FirstSector ; is greater than or equal to start+length; the subtraction ; (.FirstSector-start) - length must not cause overflow. Go to 2g if life is ; good or to 2f in the other case. - sub eax, dword [length] - sbb edx, dword [length+4] - jb .overlap - jmp .next_existing + sub eax, dword [length] + sbb edx, dword [length+4] + jb .overlap + jmp .next_existing .less: ; 2e. .FirstSector is less than start. Check that .FirstSector+.Length is less ; than or equal to start. If the addition (.FirstSector-start) + .Length does ; not cause overflow, then .FirstSector + .Length is strictly less than start; ; since the equality is also valid, use decrement preliminarily. Go to 2g or ; 2f depending on the overflow. - sub eax, 1 - sbb edx, 0 - add eax, dword [ecx+PARTITION.Length] - adc edx, dword [ecx+PARTITION.Length+4] - jnc .next_existing + sub eax, 1 + sbb edx, 0 + add eax, dword [ecx+PARTITION.Length] + adc edx, dword [ecx+PARTITION.Length+4] + jnc .next_existing .overlap: ; 2f. The partition overlaps with previously registered partition. Say warning ; and return with nothing done. - dbgstr 'two partitions overlap, ignoring the last one' - jmp .nothing + dbgstr 'two partitions overlap, ignoring the last one' + jmp .nothing .next_existing: ; 2g. The partition does not overlap with the current partition. Continue the ; loop. - dec ebx - jnz .scan_existing + dec ebx + jnz .scan_existing .partitionok: ; 3. The partition has passed tests. Reallocate the partitions array for a new ; entry. ; 3a. Call the allocator. - mov eax, [esi+DISK.NumPartitions] - inc eax ; one more entry - shl eax, 2 ; each entry is dword - call malloc + mov eax, [esi+DISK.NumPartitions] + inc eax ; one more entry + shl eax, 2 ; each entry is dword + call malloc ; 3b. Test the result. If failed, return with nothing done. - test eax, eax - jz .nothing + test eax, eax + jz .nothing ; 3c. Copy the old array to the new array. - mov edi, eax - push esi - mov ecx, [esi+DISK.NumPartitions] - mov esi, [esi+DISK.Partitions] - rep movsd - pop esi + mov edi, eax + push esi + mov ecx, [esi+DISK.NumPartitions] + mov esi, [esi+DISK.Partitions] + rep movsd + pop esi ; 3d. Set the field in the DISK structure to the new array. - xchg [esi+DISK.Partitions], eax + xchg [esi+DISK.Partitions], eax ; 3e. Free the old array. - call free + call free ; 4. Recognize the file system. ; 4a. Call the filesystem recognizer. It will allocate the PARTITION structure ; with possible filesystem-specific fields. - call disk_detect_partition + call disk_detect_partition ; 4b. Check return value. If zero, return with list not changed; so far only ; the array was reallocated, this is ok for other code. - test eax, eax - jz .nothing + test eax, eax + jz .nothing ; 5. Insert the new partition to the list. - stosd - inc [esi+DISK.NumPartitions] + stosd + inc [esi+DISK.NumPartitions] ; 6. Return. .nothing: - ret + ret endp ; This is an internal function called from disk_add_partition. @@ -972,29 +972,29 @@ 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 ? +.start dq ? +.length dq ? end virtual ; Currently no file systems are supported, so just allocate the PARTITION ; structure without extra fields. ; 1. Allocate and check result. - push sizeof.PARTITION - pop eax - call malloc - test eax, eax - jz .nothing + push sizeof.PARTITION + pop eax + call malloc + test eax, eax + jz .nothing ; 2. Fill the common fields: copy .start and .length. - 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 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 .nothing: ; 3. Return with eax = pointer to PARTITION or NULL. - ret + ret ; This function is called from file_system_lfn. ; This handler gets the control each time when fn 70 is called @@ -1005,217 +1005,217 @@ end virtual ; but instead pop return address and return directly to the caller ; otherwise simply return dyndisk_handler: - push ebx edi ; save registers used in file_system_lfn + push ebx edi ; save registers used in file_system_lfn ; 1. Acquire the mutex. - mov ecx, disk_list_mutex - call mutex_lock + mov ecx, disk_list_mutex + call mutex_lock ; 2. Loop over the list of DISK structures. ; 2a. Initialize. - mov ebx, disk_list + mov ebx, disk_list .scan: ; 2b. Get the next item. - mov ebx, [ebx+DISK.Next] + mov ebx, [ebx+DISK.Next] ; 2c. Check whether the list is done. If so, go to 3. - cmp ebx, disk_list - jz .notfound + cmp ebx, disk_list + jz .notfound ; 2d. Compare names. If names match, go to 5. - mov edi, [ebx+DISK.Name] - push esi + mov edi, [ebx+DISK.Name] + push esi @@: ; esi points to the name from fs operation; it is terminated by zero or slash. - lodsb - test al, al - jz .eoin_dec - cmp al, '/' - jz .eoin + lodsb + test al, al + jz .eoin_dec + cmp al, '/' + jz .eoin ; edi points to the disk name. - inc edi + inc edi ; edi points to lowercase name, this is a requirement for the driver. ; Characters at esi can have any register. Lowercase the current character. ; This lowercasing works for latin letters and digits; since the disk name ; should not contain other symbols, this is ok. - or al, 20h - cmp al, [edi-1] - jz @b + or al, 20h + cmp al, [edi-1] + jz @b .wrongname: ; 2f. Names don't match. Continue the loop. - pop esi - jmp .scan + pop esi + jmp .scan .notfound: ; The loop is done and no name matches. ; 3. Release the mutex. - call mutex_unlock + call mutex_unlock ; 4. Return normally. - pop edi ebx ; restore registers used in file_system_lfn - ret + pop edi ebx ; restore registers used in file_system_lfn + ret ; part of 2d: the name matches partially, but we must check that this is full ; equality. .eoin_dec: - dec esi + dec esi .eoin: - cmp byte [edi], 0 - jnz .wrongname + cmp byte [edi], 0 + jnz .wrongname ; We found the addressed DISK structure. ; 5. Reference the disk. -lock inc [ebx+DISK.RefCount] +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 + call mutex_unlock ; 7. Acquire the mutex for media object. - pop edi ; restore edi - lea ecx, [ebx+DISK.MediaLock] - call mutex_lock + 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 - cmp [ebx+DISK.MediaInserted], dl - jz @f - mov edx, ebx - inc [ebx+DISK.MediaRefCount] + xor edx, edx + cmp [ebx+DISK.MediaInserted], dl + jz @f + mov edx, ebx + inc [ebx+DISK.MediaRefCount] @@: ; 9. Now we are sure that the media object, if it exists, is not going to die ; at least while we are working with it, so release the mutex for media object. - call mutex_unlock - mov ecx, ebx - pop ebx eax ; restore ebx, pop return address + call mutex_unlock + mov ecx, ebx + pop ebx eax ; restore ebx, pop return address ; 10. Check whether the fs operation wants to enumerate partitions (go to 11) ; or work with some concrete partition (go to 12). - cmp byte [esi], 0 - jnz .haspartition + cmp byte [esi], 0 + jnz .haspartition ; 11. The fs operation wants to enumerate partitions. ; 11a. Only "list directory" operation is applicable to / path. Check ; the operation code. If wrong, go to 13. - cmp dword [ebx], 1 - jnz .access_denied + cmp dword [ebx], 1 + jnz .access_denied ; 11b. If the media is inserted, use 'fs_dyndisk_next' as an enumeration ; procedure. Otherwise, use 'fs_dyndisk_next_nomedia'. - mov esi, fs_dyndisk_next_nomedia - test edx, edx - jz @f - mov esi, fs_dyndisk_next + mov esi, fs_dyndisk_next_nomedia + test edx, edx + jz @f + mov esi, fs_dyndisk_next @@: ; 11c. Let the procedure from fs_lfn.inc do the job. - jmp file_system_lfn.maindir_noesi + jmp file_system_lfn.maindir_noesi .haspartition: ; 12. The fs operation has specified some partition. ; 12a. Store parameters for callback functions. - push edx - push ecx + push edx + push ecx ; 12b. Store callback functions. - push dyndisk_cleanup - push fs_dyndisk - mov edi, esp + push dyndisk_cleanup + push fs_dyndisk + mov edi, esp ; 12c. Let the procedure from fs_lfn.inc do the job. - jmp file_system_lfn.found2 + jmp file_system_lfn.found2 .access_denied: ; 13. Fail the operation with the appropriate code. - mov dword [esp+32], ERROR_ACCESS_DENIED + mov dword [esp+32], ERROR_ACCESS_DENIED .cleanup: ; 14. Cleanup. - mov esi, ecx ; disk*dereference assume that esi points to DISK + mov esi, ecx ; disk*dereference assume that esi points to DISK .cleanup_esi: - test edx, edx ; if there are no media, we didn't reference it - jz @f - call disk_media_dereference + test edx, edx ; if there are no media, we didn't reference it + jz @f + call disk_media_dereference @@: - call disk_dereference + call disk_dereference ; 15. Return. - ret + ret ; This is a callback for cleaning up things called from file_system_lfn.found2. dyndisk_cleanup: - mov esi, [edi+8] - mov edx, [edi+12] - jmp dyndisk_handler.cleanup_esi + mov esi, [edi+8] + mov edx, [edi+12] + jmp dyndisk_handler.cleanup_esi ; This is a callback for enumerating partitions called from ; file_system_lfn.maindir in the case of inserted media. ; It just increments eax until DISK.NumPartitions reached and then ; cleans up. fs_dyndisk_next: - cmp eax, [ecx+DISK.NumPartitions] - jae .nomore - inc eax - clc - ret + cmp eax, [ecx+DISK.NumPartitions] + jae .nomore + inc eax + clc + ret .nomore: - pusha - mov esi, ecx - call disk_media_dereference - call disk_dereference - popa - stc - ret + pusha + mov esi, ecx + call disk_media_dereference + call disk_dereference + popa + stc + ret ; This is a callback for enumerating partitions called from ; file_system_lfn.maindir in the case of missing media. ; In this case we create one pseudo-partition. fs_dyndisk_next_nomedia: - cmp eax, 1 - jae .nomore - inc eax - clc - ret + cmp eax, 1 + jae .nomore + inc eax + clc + ret .nomore: - pusha - mov esi, ecx - call disk_dereference - popa - stc - ret + pusha + mov esi, ecx + call disk_dereference + popa + stc + ret ; This is a callback for doing real work with selected partition. ; Currently this is just placeholder, since no file systems are supported. ; edi = esp -> {dd fs_dyndisk, dd dyndisk_cleanup, dd pointer to DISK, dd media object} ; ecx = partition number, esi+ebp = ASCIIZ name fs_dyndisk: - dec ecx ; convert to zero-based partition index - pop edx edx edx eax ; edx = pointer to DISK, eax = NULL or edx - test eax, eax - jz .nomedia + dec ecx ; convert to zero-based partition index + 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 dword [esp+32], ERROR_UNKNOWN_FS + cmp ecx, [edx+DISK.NumPartitions] + jae .notfound + mov dword [esp+32], ERROR_UNKNOWN_FS .cleanup: - mov esi, edx - call disk_media_dereference - call disk_dereference - ret + mov esi, edx + call disk_media_dereference + call disk_dereference + ret .notfound: - mov dword [esp+32], ERROR_FILE_NOT_FOUND - jmp .cleanup + mov dword [esp+32], ERROR_FILE_NOT_FOUND + jmp .cleanup .nomedia: - test ecx, ecx - jnz .notfound - test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION - jz .deverror + 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 ;;; push ebx - lea ecx, [edx+DISK.MediaLock] - call mutex_lock - cmp [edx+DISK.MediaRefCount], 1 - jnz .noluck - call mutex_unlock - push edx - stdcall disk_media_changed, edx, 1 - pop edx - lea ecx, [edx+DISK.MediaLock] - call mutex_lock - cmp [edx+DISK.MediaInserted], 0 - jz .noluck -lock inc [edx+DISK.MediaRefCount] - call mutex_unlock - xor ecx, ecx - jmp .main + lea ecx, [edx+DISK.MediaLock] + call mutex_lock + cmp [edx+DISK.MediaRefCount], 1 + jnz .noluck + call mutex_unlock + push edx + stdcall disk_media_changed, edx, 1 + pop edx + lea ecx, [edx+DISK.MediaLock] + call mutex_lock + cmp [edx+DISK.MediaInserted], 0 + jz .noluck +lock inc [edx+DISK.MediaRefCount] + call mutex_unlock + xor ecx, ecx + jmp .main .noluck: - call mutex_unlock + call mutex_unlock .deverror: - mov dword [esp+32], ERROR_DEVICE - mov esi, edx - call disk_dereference - ret + mov dword [esp+32], ERROR_DEVICE + mov esi, edx + call disk_dereference + ret ; This function is called from file_system_lfn. ; This handler is called when virtual root is enumerated @@ -1225,34 +1225,34 @@ lock inc [edx+DISK.MediaRefCount] ; out: eax = 0 => no more items ; eax != 0 => buffer pointed to by edi contains name of item dyndisk_enum_root: - push edx ; save register used in file_system_lfn - mov ecx, disk_list_mutex ; it will be useful + push edx ; save register used in file_system_lfn + mov ecx, disk_list_mutex ; it will be useful ; 1. If this is the first call, acquire the mutex and initialize. - test eax, eax - jnz .notfirst - call mutex_lock - mov eax, disk_list + test eax, eax + jnz .notfirst + call mutex_lock + mov eax, disk_list .notfirst: ; 2. Get next item. - mov eax, [eax+DISK.Next] + mov eax, [eax+DISK.Next] ; 3. If there are no more items, go to 6. - cmp eax, disk_list - jz .last + cmp eax, disk_list + jz .last ; 4. Copy name from the DISK structure to edi. - push eax esi - mov esi, [eax+DISK.Name] + push eax esi + mov esi, [eax+DISK.Name] @@: - lodsb - stosb - test al, al - jnz @b - pop esi eax + lodsb + stosb + test al, al + jnz @b + pop esi eax ; 5. Return with eax = item. - pop edx ; restore register used in file_system_lfn - ret + pop edx ; restore register used in file_system_lfn + ret .last: ; 6. Release the mutex and return with eax = 0. - call mutex_unlock - xor eax, eax - pop edx ; restore register used in file_system_lfn - ret + call mutex_unlock + xor eax, eax + pop edx ; restore register used in file_system_lfn + ret diff --git a/kernel/branches/Kolibri-acpi/boot/bootcode.inc b/kernel/branches/Kolibri-acpi/boot/bootcode.inc index 7b5ad14f9d..fb310eb3ac 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootcode.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootcode.inc @@ -552,11 +552,11 @@ end if 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 @@ -584,9 +584,9 @@ end if 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] @@ -674,9 +674,9 @@ end if 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 @@ -784,15 +784,15 @@ end if 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 @@ -947,10 +947,10 @@ end if mov al, [preboot_dma] mov [es:0x901F], al -; VRR_M USE - - mov al,[preboot_vrrm] - mov [es:0x9030], al +;; VRR_M USE +; +; mov al,[preboot_vrrm] +; mov [es:0x9030], al mov [es:0x901E], byte 1 ; BOOT DEVICE diff --git a/kernel/branches/Kolibri-acpi/boot/booteng.inc b/kernel/branches/Kolibri-acpi/boot/booteng.inc index 833cdacdda..ba7184f778 100644 --- a/kernel/branches/Kolibri-acpi/boot/booteng.inc +++ b/kernel/branches/Kolibri-acpi/boot/booteng.inc @@ -23,43 +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 -else -bdev db "Load ramdisk from [1-floppy; 2-kolibri.img]: ",0 end if -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 + 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 @@ -77,21 +61,15 @@ 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 @@ -103,7 +81,9 @@ 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 @@ -116,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/Kolibri-acpi/boot/bootet.inc b/kernel/branches/Kolibri-acpi/boot/bootet.inc index 532b6841b2..51c6bbcc37 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootet.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootet.inc @@ -13,43 +13,24 @@ $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 -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 +novesa db "Ekraan: EGA/CGA",13,10,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 @@ -59,18 +40,12 @@ bdev db "Paigalda m db 13,10,186," " db "4-loo t№hi pilt]: ",0 end if -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 + 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" @@ -85,24 +60,16 @@ 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 @@ -114,14 +81,21 @@ 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/Kolibri-acpi/boot/bootge.inc b/kernel/branches/Kolibri-acpi/boot/bootge.inc index 93d24f0f13..9db178f058 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootge.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootge.inc @@ -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,34 +22,15 @@ d80x25_bottom: line_full_bottom d80x25_bottom_num = 3 -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 +novesa db "Anzeige: EGA/CGA ",13,10,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 @@ -64,18 +40,12 @@ bdev db "Lade die Ramdisk von [1-Diskette; 2-C:\kolibri.img (FAT32);" db 13,10,186," " db "4-create blank image]: ",0 end if -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 + 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" @@ -84,30 +54,22 @@ 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 @@ -119,14 +81,21 @@ 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/Kolibri-acpi/boot/bootru.inc b/kernel/branches/Kolibri-acpi/boot/bootru.inc index 548a71912e..03203c29ee 100644 --- a/kernel/branches/Kolibri-acpi/boot/bootru.inc +++ b/kernel/branches/Kolibri-acpi/boot/bootru.inc @@ -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,11 +28,9 @@ 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 @@ -42,7 +40,9 @@ bdev db " db 13,10,186," " db "4-создать чистый образ]: ",0 end if + prnotfnd db "Ошибка - Видеорежим не найден.",0 + not386 db "Ошибка - Требуется процессор 386+.",0 fatalsel db "Ошибка - Выбранный видеорежим не поддерживается.",0 pres_key db "Нажимите любую клавишу, для перехода в выбор режимов.",0 @@ -61,16 +61,15 @@ 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 @@ -82,22 +81,21 @@ 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 _r2 db 186,' │ 640x480 VGA 16 цветов │ │ ',13,10,0 _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/Kolibri-acpi/boot/parsers.inc b/kernel/branches/Kolibri-acpi/boot/parsers.inc index ea29218e7f..0c83c43b5a 100644 --- a/kernel/branches/Kolibri-acpi/boot/parsers.inc +++ b/kernel/branches/Kolibri-acpi/boot/parsers.inc @@ -5,7 +5,7 @@ ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -$Revision: 1962 $ +$Revision: 2261 $ ; All parsers are called with ds:si -> value of the variable, ; possibly with spaces before, and dx = limit of config file. @@ -57,16 +57,16 @@ parse_vbemode: .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_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 diff --git a/kernel/branches/Kolibri-acpi/boot/preboot.inc b/kernel/branches/Kolibri-acpi/boot/preboot.inc index 04b3d2da8a..b04ea1e364 100644 --- a/kernel/branches/Kolibri-acpi/boot/preboot.inc +++ b/kernel/branches/Kolibri-acpi/boot/preboot.inc @@ -23,7 +23,7 @@ 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) diff --git a/kernel/branches/Kolibri-acpi/build.bat b/kernel/branches/Kolibri-acpi/build.bat index d8a8f5befa..290d05b54a 100644 --- a/kernel/branches/Kolibri-acpi/build.bat +++ b/kernel/branches/Kolibri-acpi/build.bat @@ -1,7 +1,7 @@ @echo off cls set languages=en ru ge et -set drivers=com_mouse emu10k1x ensoniq fm801 infinity sis sound viasound vt823x +set drivers=com_mouse emu10k1x fm801 infinity sis sound viasound vt823x set targets=all kernel drivers skins clean call :Check_Target %1 @@ -73,8 +73,6 @@ goto :eof if not %errorlevel%==0 goto :Error_FasmFailed ) cd .. - move bin\drivers\vmode.obj bin\drivers\vmode.mdr - kpack >nul 2>&1 diff --git a/kernel/branches/Kolibri-acpi/const.inc b/kernel/branches/Kolibri-acpi/const.inc index 6107a6d51d..ad0a26503d 100644 --- a/kernel/branches/Kolibri-acpi/const.inc +++ b/kernel/branches/Kolibri-acpi/const.inc @@ -298,23 +298,22 @@ SB16_Status equ (OS_BASE+0x02B0000) BUTTON_INFO equ (OS_BASE+0x02C0000) RESERVED_PORTS equ (OS_BASE+0x02D0000) -IRQ_SAVE equ (OS_BASE+0x02E0000) -BOOT_VAR equ (OS_BASE+0x02f0000) +BOOT_VAR equ (OS_BASE+0x02E0000) -stack_data_start equ (OS_BASE+0x0300000) -eth_data_start equ (OS_BASE+0x0300000) -stack_data equ (OS_BASE+0x0304000) -stack_data_end equ (OS_BASE+0x031ffff) -resendQ equ (OS_BASE+0x0320000) +stack_data_start equ (OS_BASE+0x02F0000) +eth_data_start equ (OS_BASE+0x02F0000) +stack_data equ (OS_BASE+0x02F4000) +stack_data_end equ (OS_BASE+0x030ffff) +resendQ equ (OS_BASE+0x0310000) -skin_data equ (OS_BASE+0x0328000) -draw_data equ (OS_BASE+0x0330000) +skin_data equ (OS_BASE+0x0318000) +draw_data equ (OS_BASE+0x0320000) -BgrDrawMode equ (OS_BASE+0x0333FF4) -BgrDataWidth equ (OS_BASE+0x0333FF8) -BgrDataHeight equ (OS_BASE+0x0333FFC) +BgrDrawMode equ (OS_BASE+0x0323FF4) +BgrDataWidth equ (OS_BASE+0x0323FF8) +BgrDataHeight equ (OS_BASE+0x0323FFC) -sys_pgmap equ (OS_BASE+0x0334000) +sys_pgmap equ (OS_BASE+0x0324000) UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000) diff --git a/kernel/branches/Kolibri-acpi/data16.inc b/kernel/branches/Kolibri-acpi/data16.inc index 4fbed262ea..b81d8fbee5 100644 --- a/kernel/branches/Kolibri-acpi/data16.inc +++ b/kernel/branches/Kolibri-acpi/data16.inc @@ -78,7 +78,7 @@ config_file_variables: config_variable 'timeout', parse_timeout config_variable 'resolution', parse_resolution config_variable 'vbemode', parse_vbemode - config_variable 'vrr', parse_vrr +; config_variable 'vrr', parse_vrr config_variable 'biosdisks', parse_biosdisks config_variable 'imgfrom', parse_imgfrom dw 0 diff --git a/kernel/branches/Kolibri-acpi/data32.inc b/kernel/branches/Kolibri-acpi/data32.inc index 4a668ffe08..21e4e4686a 100644 --- a/kernel/branches/Kolibri-acpi/data32.inc +++ b/kernel/branches/Kolibri-acpi/data32.inc @@ -141,7 +141,7 @@ char2 db '/sys/FONTS/CHAR2.MT',0 bootpath db '/KOLIBRI ' bootpath2 db 0 vmode db '/sys/drivers/VMODE.MDR',0 -vrr_m db 'VRR_M',0 +;vrr_m db 'VRR_M',0 kernel_file db 'KERNEL MNT' dev_data_path db '/RD/1/DRIVERS/DEVICES.DAT',0 diff --git a/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt b/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt index c28e750130..753fe70335 100644 --- a/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt +++ b/kernel/branches/Kolibri-acpi/docs/sysfuncr.txt @@ -635,6 +635,15 @@ в формате подфункции 2 функции 37 в момент начала нажатия на кнопку, за исключением младшего бита (соответствующего левой кнопке мыши), который сбрасывается. +====================================================================== += Функция 18, подфункция 1 - сделать самым нижним окно потока. ======= +====================================================================== +Параметры: + * eax = 18 - номер функции + * ebx = 1 - номер подфункции + * ecx = номер слота потока +Возвращаемое значение: + * функция не возвращает значения ====================================================================== ==== Функция 18, подфункция 2 - завершить процесс/поток по слоту. ==== diff --git a/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt b/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt index 93165f1f3c..250ee9e764 100644 --- a/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt +++ b/kernel/branches/Kolibri-acpi/docs/sysfuncs.txt @@ -626,6 +626,17 @@ Remarks: as in subfunction 2 of function 37 at the beginning of button press, excluding lower bit, which is cleared. +====================================================================== +===================== Function 18, subfunction 1 ===================== +============= Make deactive the window of the given thread. ========== +====================================================================== +Parameters: + * eax = 18 - function number + * ebx = 1 - subfunction number + * ecx = number of the thread slot +Returned value: + * function does not return value + ====================================================================== = Function 18, subfunction 2 - terminate process/thread by the slot. = ====================================================================== diff --git a/kernel/branches/Kolibri-acpi/drivers/viasound.asm b/kernel/branches/Kolibri-acpi/drivers/viasound.asm deleted file mode 100644 index 18dbef9068..0000000000 --- a/kernel/branches/Kolibri-acpi/drivers/viasound.asm +++ /dev/null @@ -1,1281 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -format MS COFF - -DEBUG equ 1 - -include 'proc32.inc' -include 'imports.inc' - -API_VERSION equ 0x01000100 - -USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices -IRQ_REMAP equ 0 -IRQ_LINE equ 0 - - -;irq 0,1,2,8,12,13 недоступны -; FEDCBA9876543210 -VALID_IRQ equ 1100111011111000b -ATTCH_IRQ equ 0000111010100000b - -if USE_COM_IRQ -ATTCH_IRQ equ 0000111010111000b -end if - -CPU_FREQ equ 2600d - -BIT0 EQU 0x00000001 -BIT1 EQU 0x00000002 -BIT5 EQU 0x00000020 -BIT10 EQU 0x00000400 - -VID_VIA equ 0x1106 - -CTRL_VT82C686 equ 0x3058 -CTRL_VT8233_5 equ 0x3059 - - -CODEC_MASTER_VOL_REG equ 0x02 -CODEC_AUX_VOL equ 0x04 ; -CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume -CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio -CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control -CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate -CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate -CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate - - -;VIA host controller registers set -;; common offsets -VIA_REG_OFFSET_STATUS equ 0x00 ;; byte - channel status - VIA_REG_STAT_ACTIVE equ 0x80 ;; RO - VIA_REG_STAT_PAUSED equ 0x40 ;; RO - VIA_REG_STAT_TRIGGER_QUEUED equ 0x08 ;; RO - VIA_REG_STAT_STOPPED equ 0x04 ;; RWC - VIA_REG_STAT_EOL equ 0x02 ;; RWC - VIA_REG_STAT_FLAG equ 0x01 ;; RWC -VIA_REG_OFFSET_CONTROL equ 0x01 ;; byte - channel control - VIA_REG_CTRL_START equ 0x80 ;; WO - VIA_REG_CTRL_TERMINATE equ 0x40 ;; WO - VIA_REG_CTRL_AUTOSTART equ 0x20 - VIA_REG_CTRL_PAUSE equ 0x08 ;; RW - VIA_REG_CTRL_INT_STOP equ 0x04 - VIA_REG_CTRL_INT_EOL equ 0x02 - VIA_REG_CTRL_INT_FLAG equ 0x01 - VIA_REG_CTRL_RESET equ 0x01 ;; RW - probably reset? undocumented - VIA_REG_CTRL_INT equ (VIA_REG_CTRL_INT_FLAG or \ - VIA_REG_CTRL_INT_EOL or \ - VIA_REG_CTRL_AUTOSTART) -VIA_REG_OFFSET_TYPE equ 0x02 ;; byte - channel type (686 only) - VIA_REG_TYPE_AUTOSTART equ 0x80 ;; RW - autostart at EOL - VIA_REG_TYPE_16BIT equ 0x20 ;; RW - VIA_REG_TYPE_STEREO equ 0x10 ;; RW - VIA_REG_TYPE_INT_LLINE equ 0x00 - VIA_REG_TYPE_INT_LSAMPLE equ 0x04 - VIA_REG_TYPE_INT_LESSONE equ 0x08 - VIA_REG_TYPE_INT_MASK equ 0x0c - VIA_REG_TYPE_INT_EOL equ 0x02 - VIA_REG_TYPE_INT_FLAG equ 0x01 -VIA_REG_OFFSET_TABLE_PTR equ 0x04 ;; dword - channel table pointer -VIA_REG_OFFSET_CURR_PTR equ 0x04 ;; dword - channel current pointer -VIA_REG_OFFSET_STOP_IDX equ 0x08 ;; dword - stop index, channel type, sample rate - VIA8233_REG_TYPE_16BIT equ 0x00200000 ;; RW - VIA8233_REG_TYPE_STEREO equ 0x00100000 ;; RW -VIA_REG_OFFSET_CURR_COUNT equ 0x0c ;; dword - channel current count (24 bit) -VIA_REG_OFFSET_CURR_INDEX equ 0x0f ;; byte - channel current index (for via8233 only) - - -VIADEV_PLAYBACK equ 0x00 -VIADEV_CAPTURE equ 0x10 -VIADEV_FM equ 0x20 - -;; AC'97 ;; -VIA_REG_AC97 equ 0x80 ; dword - VIA_REG_AC97_CODEC_ID_MASK equ 0xC0000000 ;(3<<30) - VIA_REG_AC97_CODEC_ID_SHIFT equ 30 - VIA_REG_AC97_CODEC_ID_PRIMARY equ 0x00 - VIA_REG_AC97_CODEC_ID_SECONDARY equ 0x01 - VIA_REG_AC97_SECONDARY_VALID equ 0x08000000 ;(1<<27) - VIA_REG_AC97_PRIMARY_VALID equ 0x02000000 ;(1<<25) - VIA_REG_AC97_BUSY equ 0x01000000 ;(1<<24) - VIA_REG_AC97_READ equ 0x00800000 ;(1<<23) - VIA_REG_AC97_CMD_SHIFT equ 16 - VIA_REG_AC97_CMD_MASK equ 0x7E - VIA_REG_AC97_DATA_SHIFT equ 0 - VIA_REG_AC97_DATA_MASK equ 0xFFFF - -VIA_REG_SGD_SHADOW equ 0x84 ; dword - -;; via8233-specific registers ;; -VIA_REG_OFS_PLAYBACK_VOLUME_L equ 0x02 ;; byte -VIA_REG_OFS_PLAYBACK_VOLUME_R equ 0x03 ;; byte -VIA_REG_OFS_MULTPLAY_FORMAT equ 0x02 ;; byte - format and channels - VIA_REG_MULTPLAY_FMT_8BIT equ 0x00 - VIA_REG_MULTPLAY_FMT_16BIT equ 0x80 - VIA_REG_MULTPLAY_FMT_CH_MASK equ 0x70 ;; # channels << 4 (valid = 1,2,4,6) -VIA_REG_OFS_CAPTURE_FIFO equ 0x02 ;; byte - bit 6 = fifo enable - VIA_REG_CAPTURE_FIFO_ENABLE equ 0x40 - -VIA_DXS_MAX_VOLUME equ 31 ;; max. volume (attenuation) of reg 0x32/33 - -VIA_TBL_BIT_FLAG equ 0x40000000 -VIA_TBL_BIT_EOL equ 0x80000000 - -;; pci space ;; -VIA_ACLINK_STAT equ 0x40 - ;... - VIA_ACLINK_C00_READY equ 0x01 ; primary codec ready -VIA_ACLINK_CTRL equ 0x41 - VIA_ACLINK_CTRL_ENABLE equ 0x80 ; 0: disable, 1: enable - VIA_ACLINK_CTRL_RESET equ 0x40 ; 0: assert, 1: de-assert - VIA_ACLINK_CTRL_SYNC equ 0x20 ; 0: release SYNC, 1: force SYNC hi - VIA_ACLINK_CTRL_SDO equ 0x10 ; 0: release SDO, 1: force SDO hi - VIA_ACLINK_CTRL_VRA equ 0x08 ; 0: disable VRA, 1: enable VRA - VIA_ACLINK_CTRL_PCM equ 0x04 ; 0: disable PCM, 1: enable PCM - VIA_ACLINK_CTRL_FM equ 0x02 ; via686 only - VIA_ACLINK_CTRL_SB equ 0x01 ; via686 only - VIA_ACLINK_CTRL_INIT equ (VIA_ACLINK_CTRL_ENABLE or \ - VIA_ACLINK_CTRL_RESET or \ - VIA_ACLINK_CTRL_PCM or \ - VIA_ACLINK_CTRL_VRA) -VIA_FUNC_ENABLE equ 0x42 - VIA_FUNC_MIDI_PNP equ 0x80 ; FIXME: it's 0x40 in the datasheet! - VIA_FUNC_MIDI_IRQMASK equ 0x40 ; FIXME: not documented! - VIA_FUNC_RX2C_WRITE equ 0x20 - VIA_FUNC_SB_FIFO_EMPTY equ 0x10 - VIA_FUNC_ENABLE_GAME equ 0x08 - VIA_FUNC_ENABLE_FM equ 0x04 - VIA_FUNC_ENABLE_MIDI equ 0x02 - VIA_FUNC_ENABLE_SB equ 0x01 -VIA_PNP_CONTROL equ 0x43 -VIA_FM_NMI_CTRL equ 0x48 -VIA8233_VOLCHG_CTRL equ 0x48 -VIA8233_SPDIF_CTRL equ 0x49 - VIA8233_SPDIF_DX3 equ 0x08 - VIA8233_SPDIF_SLOT_MASK equ 0x03 - VIA8233_SPDIF_SLOT_1011 equ 0x00 - VIA8233_SPDIF_SLOT_34 equ 0x01 - VIA8233_SPDIF_SLOT_78 equ 0x02 - VIA8233_SPDIF_SLOT_69 equ 0x03 -;] Asper - - -SRV_GETVERSION equ 0 -DEV_PLAY equ 1 -DEV_STOP equ 2 -DEV_CALLBACK equ 3 -DEV_SET_BUFF equ 4 -DEV_NOTIFY equ 5 -DEV_SET_MASTERVOL equ 6 -DEV_GET_MASTERVOL equ 7 -DEV_GET_INFO equ 8 - -struc AC_CNTRL ;AC controller base class -{ .bus dd ? - .devfn dd ? - - .vendor dd ? - .dev_id dd ? - .pci_cmd dd ? - .pci_stat dd ? - - .codec_io_base dd ? - .codec_mem_base dd ? - - .ctrl_io_base dd ? - .ctrl_mem_base dd ? - .cfg_reg dd ? - .int_line dd ? - - .vendor_ids dd ? ;vendor id string - .ctrl_ids dd ? ;hub id string - - .buffer dd ? - - .notify_pos dd ? - .notify_task dd ? - - .lvi_reg dd ? - .ctrl_setup dd ? - .user_callback dd ? - .codec_read16 dd ? - .codec_write16 dd ? - - .ctrl_read8 dd ? - .ctrl_read16 dd ? - .ctrl_read32 dd ? - - .ctrl_write8 dd ? - .ctrl_write16 dd ? - .ctrl_write32 dd ? -} - -struc CODEC ;Audio Chip base class -{ - .chip_id dd ? - .flags dd ? - .status dd ? - - .ac_vendor_ids dd ? ;ac vendor id string - .chip_ids dd ? ;chip model string - - .shadow_flag dd ? - dd ? - - .regs dw ? ; codec registers - .reg_master_vol dw ? ;0x02 - .reg_aux_out_vol dw ? ;0x04 - .reg_mone_vol dw ? ;0x06 - .reg_master_tone dw ? ;0x08 - .reg_beep_vol dw ? ;0x0A - .reg_phone_vol dw ? ;0x0C - .reg_mic_vol dw ? ;0x0E - .reg_line_in_vol dw ? ;0x10 - .reg_cd_vol dw ? ;0x12 - .reg_video_vol dw ? ;0x14 - .reg_aux_in_vol dw ? ;0x16 - .reg_pcm_out_vol dw ? ;0x18 - .reg_rec_select dw ? ;0x1A - .reg_rec_gain dw ? ;0x1C - .reg_rec_gain_mic dw ? ;0x1E - .reg_gen dw ? ;0x20 - .reg_3d_ctrl dw ? ;0X22 - .reg_page dw ? ;0X24 - .reg_powerdown dw ? ;0x26 - .reg_ext_audio dw ? ;0x28 - .reg_ext_st dw ? ;0x2a - .reg_pcm_front_rate dw ? ;0x2c - .reg_pcm_surr_rate dw ? ;0x2e - .reg_lfe_rate dw ? ;0x30 - .reg_pcm_in_rate dw ? ;0x32 - dw ? ;0x34 - .reg_cent_lfe_vol dw ? ;0x36 - .reg_surr_vol dw ? ;0x38 - .reg_spdif_ctrl dw ? ;0x3A - dw ? ;0x3C - dw ? ;0x3E - dw ? ;0x40 - dw ? ;0x42 - dw ? ;0x44 - dw ? ;0x46 - dw ? ;0x48 - dw ? ;0x4A - dw ? ;0x4C - dw ? ;0x4E - dw ? ;0x50 - dw ? ;0x52 - dw ? ;0x54 - dw ? ;0x56 - dw ? ;0x58 - dw ? ;0x5A - dw ? ;0x5C - dw ? ;0x5E - .reg_page_0 dw ? ;0x60 - .reg_page_1 dw ? ;0x62 - .reg_page_2 dw ? ;0x64 - .reg_page_3 dw ? ;0x66 - .reg_page_4 dw ? ;0x68 - .reg_page_5 dw ? ;0x6A - .reg_page_6 dw ? ;0x6C - .reg_page_7 dw ? ;0x6E - dw ? ;0x70 - dw ? ;0x72 - dw ? ;0x74 - dw ? ;0x76 - dw ? ;0x78 - dw ? ;0x7A - .reg_vendor_id_1 dw ? ;0x7C - .reg_vendor_id_2 dw ? ;0x7E - - - .reset dd ? ;virual - .set_master_vol dd ? -} - -struc CTRL_INFO -{ .pci_cmd dd ? - .irq dd ? - .glob_cntrl dd ? - .glob_sta dd ? - .codec_io_base dd ? - .ctrl_io_base dd ? - .codec_mem_base dd ? - .ctrl_mem_base dd ? - .codec_id dd ? -} - -struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? -} - -virtual at 0 - IOCTL IOCTL -end virtual - -EVENT_NOTIFY equ 0x00000200 - -public START -public service_proc -public version - -section '.flat' code readable align 16 - -proc START stdcall, state:dword - - cmp [state], 1 - jne .stop - - if DEBUG - mov esi, msgInit - call SysMsgBoardStr - end if - - call detect_controller - test eax, eax - jz .fail - - if DEBUG - mov esi,[ctrl.vendor_ids] - call SysMsgBoardStr - mov esi, [ctrl.ctrl_ids] - call SysMsgBoardStr - end if - - call init_controller - test eax, eax - jz .fail - - call init_codec - test eax, eax - jz .fail - - call setup_codec - - mov esi, msgPrimBuff - call SysMsgBoardStr - call create_primary_buff - mov esi, msgDone - call SysMsgBoardStr - - if IRQ_REMAP - pushf - cli - - mov ebx, [ctrl.int_line] - in al, 0xA1 - mov ah, al - in al, 0x21 - test ebx, ebx - jz .skip - bts ax, bx ;mask old line -.skip: - bts ax, IRQ_LINE ;mask new ine - out 0x21, al - mov al, ah - out 0xA1, al - - stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE ;remap IRQ - - mov dx, 0x4d0 ;8259 ELCR1 - in al, dx - bts ax, IRQ_LINE - out dx, al ;set level-triggered mode - mov [ctrl.int_line], IRQ_LINE - popf - mov esi, msgRemap - call SysMsgBoardStr - end if - - mov eax, VALID_IRQ - mov ebx, [ctrl.int_line] - mov esi, msgInvIRQ - bt eax, ebx - jnc .fail_msg - mov eax, ATTCH_IRQ - mov esi, msgAttchIRQ - bt eax, ebx - jnc .fail_msg - - stdcall AttachIntHandler, ebx, ac97_irq_VIA, dword 0 -.reg: - stdcall RegService, sz_sound_srv, service_proc - ret -.fail: - if DEBUG - mov esi, msgFail - call SysMsgBoardStr - end if - xor eax, eax - ret -.fail_msg: - call SysMsgBoardStr - xor eax, eax - ret -.stop: - call stop - xor eax, eax - ret -endp - -handle equ IOCTL.handle -io_code equ IOCTL.io_code -input equ IOCTL.input -inp_size equ IOCTL.inp_size -output equ IOCTL.output -out_size equ IOCTL.out_size - -align 4 -proc service_proc stdcall, ioctl:dword - - mov edi, [ioctl] - mov eax, [edi+io_code] - - cmp eax, SRV_GETVERSION - jne @F - mov eax, [edi+output] - cmp [edi+out_size], 4 - jne .fail - - mov [eax], dword API_VERSION - xor eax, eax - ret -@@: - cmp eax, DEV_PLAY - jne @F - if DEBUG - mov esi, msgPlay - call SysMsgBoardStr - end if - call play - ret -@@: - cmp eax, DEV_STOP - jne @F - if DEBUG - mov esi, msgStop - call SysMsgBoardStr - end if - call stop - ret -@@: - cmp eax, DEV_CALLBACK - jne @F - mov ebx, [edi+input] - stdcall set_callback, [ebx] - ret -@@: - cmp eax, DEV_SET_MASTERVOL - jne @F - mov eax, [edi+input] - mov eax, [eax] - call set_master_vol ;eax= vol - ret -@@: - cmp eax, DEV_GET_MASTERVOL - jne @F - mov ebx, [edi+output] - stdcall get_master_vol, ebx - ret -@@: - cmp eax, DEV_GET_INFO - jne @F - mov ebx, [edi+output] - stdcall get_dev_info, ebx - ret -@@: -.fail: - or eax, -1 - ret -endp - -restore handle -restore io_code -restore input -restore inp_size -restore output -restore out_size - - -align 4 -proc ac97_irq_VIA - locals - status db 0 - endl - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS - call [ctrl.ctrl_read8] - test al, VIA_REG_STAT_ACTIVE - jz @f - - and al, VIA_REG_STAT_EOL or VIA_REG_STAT_FLAG or VIA_REG_STAT_STOPPED - mov byte [status], al - - mov ebx, dword [buff_list] - cmp [ctrl.user_callback], 0 - je @f - stdcall [ctrl.user_callback], ebx - @@: - mov al, byte [status] ;; ack ;; - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS - call [ctrl.ctrl_write8] - - ret -endp - - -align 4 -proc create_primary_buff - - stdcall KernelAlloc, 0x10000 - mov [ctrl.buffer], eax - - mov edi, eax - mov ecx, 0x10000/4 - xor eax, eax - cld - rep stosd - - mov eax, [ctrl.buffer] - call GetPgAddr - mov edi, pcmout_bdl - stosd - mov eax, 0x80004000 - stosd - - mov edi, buff_list - mov eax, [ctrl.buffer] - mov ecx, 4 -@@: - mov [edi], eax - mov [edi+16], eax - mov [edi+32], eax - mov [edi+48], eax - mov [edi+64], eax - mov [edi+80], eax - mov [edi+96], eax - mov [edi+112], eax - - ;add eax, 0x4000 - add edi, 4 - loop @B - - stdcall channel_reset, VIADEV_PLAYBACK - stdcall codec_check_ready - - mov eax, pcmout_bdl - mov ebx, eax - call GetPgAddr - and ebx, 0xFFF - add eax, ebx - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_TABLE_PTR - call [ctrl.ctrl_write32] - - stdcall codec_check_ready - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_L - mov eax, 7;31 - call [ctrl.ctrl_write8] - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_R - mov eax, 7;31 - call [ctrl.ctrl_write8] - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX - mov eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000 - mov [ctrl.lvi_reg], 16;0xF;eax - call [ctrl.ctrl_write32] - - stdcall codec_check_ready - ret -endp - - -proc channel_reset channel:dword - mov esi, dword [channel] - mov edx, esi - add edx, VIA_REG_OFFSET_CONTROL - mov eax, VIA_REG_CTRL_PAUSE or VIA_REG_CTRL_TERMINATE or VIA_REG_CTRL_RESET - call [ctrl.ctrl_write8] - - mov edx, esi - add edx, VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_read8] - - mov eax, 50000 ; wait 50 ms - call StallExec - ; disable interrupts - mov edx, esi - add edx, VIA_REG_OFFSET_CONTROL - xor eax, eax - call [ctrl.ctrl_write8] - - ; clear interrupts - mov edx, esi - add edx, VIA_REG_OFFSET_STATUS - mov eax, 0x03 - call [ctrl.ctrl_write8] - - ;outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */ - ; mov edx, esi ;; for via686 - ; add edx, VIA_REG_OFFSET_TYPE - ; mov eax, 0x03 - ; call [ctrl.ctrl_write8] - - ;; outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR)); - ;mov edx, esi - ;add edx, VIA_REG_OFFSET_CURR_PTR - ;xor eax, eax - ;call [ctrl.ctrl_write8] - - ret -endp - - -align 4 -proc detect_controller - locals - last_bus dd ? - bus dd ? - devfn dd ? - endl - - xor eax, eax - mov [bus], eax - inc eax - call PciApi - cmp eax, -1 - je .err - - mov [last_bus], eax - -.next_bus: - and [devfn], 0 -.next_dev: - stdcall PciRead32, [bus], [devfn], dword 0 - test eax, eax - jz .next - cmp eax, -1 - je .next - - mov edi, devices -@@: - mov ebx, [edi] - test ebx, ebx - jz .next - - cmp eax, ebx - je .found - add edi, 12 - jmp @B -.next: - inc [devfn] - cmp [devfn], 256 - jb .next_dev - mov eax, [bus] - inc eax - mov [bus], eax - cmp eax, [last_bus] - jna .next_bus - xor eax, eax - ret -.found: - mov ebx, [bus] - mov [ctrl.bus], ebx - - mov ecx, [devfn] - mov [ctrl.devfn], ecx - - mov edx, eax - and edx, 0xFFFF - mov [ctrl.vendor], edx - shr eax, 16 - mov [ctrl.dev_id], eax - - mov ebx, [edi+4] - mov [ctrl.ctrl_ids], ebx - mov esi, [edi+8] - mov [ctrl.ctrl_setup], esi - - cmp edx, VID_VIA - jne @F - mov [ctrl.vendor_ids], msg_VIA - ret -@@: - -.err: - xor eax, eax - mov [ctrl.vendor_ids], eax ;something wrong ? - ret -endp - -align 4 -proc init_controller - - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 - mov ebx, eax - and eax, 0xFFFF - mov [ctrl.pci_cmd], eax - shr ebx, 16 - mov [ctrl.pci_stat], ebx - - mov esi, msgPciCmd - call SysMsgBoardStr - call dword2str - call SysMsgBoardStr - - mov esi, msgPciStat - call SysMsgBoardStr - mov eax, [ctrl.pci_stat] - call dword2str - call SysMsgBoardStr - - mov esi, msgCtrlIsaIo - call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 - call dword2str - call SysMsgBoardStr - - and eax, 0xFFC0 - mov [ctrl.ctrl_io_base], eax - -.default: - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C - and eax, 0xFF -@@: - mov [ctrl.int_line], eax - - ;stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE ;0x42 - ;mov byte [old_legacy], al - - ;stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_PNP_CONTROL ;0x43 - ;mov byte [old_legacy_cfg], al - - ;mov al, VIA_FUNC_ENABLE_SB or VIA_FUNC_ENABLE_FM - ;xor al, 0xFF - ;and al, byte [old_legacy] - ;and eax, 0xFF - ;stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE, eax ;0x42 - ;mov byte [old_legacy], al - - call [ctrl.ctrl_setup] - xor eax, eax - inc eax - ret -endp - -align 4 -proc set_VIA - mov [ctrl.codec_read16], codec_io_r16 ;virtual - mov [ctrl.codec_write16], codec_io_w16 ;virtual - - mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual - - mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual - ret -endp - - -align 4 -proc init_codec - locals - counter dd ? - endl - - mov esi, msgControl - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL - and eax, 0xFF - call dword2str - call SysMsgBoardStr - - mov esi, msgStatus - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT - and eax, 0xFF - push eax - call dword2str - call SysMsgBoardStr - pop eax - - test eax, VIA_ACLINK_C00_READY - jz .ready - - call reset_codec - test eax, eax - jz .err - -.ready: - xor edx, edx ; ac_reg_0 - call [ctrl.codec_write16] - jmp .done - -.err: - xor eax, eax ; timeout error - ret - -.done: - call detect_codec - - xor eax, eax - inc eax - ret -endp - -align 4 -proc reset_codec - stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, \ - VIA_ACLINK_CTRL_ENABLE or VIA_ACLINK_CTRL_RESET or VIA_ACLINK_CTRL_SYNC - mov eax, 100000 ; wait 100 ms - call StallExec -.cold: - call cold_reset - jnc .ok - - if DEBUG - mov esi, msgCFail - call SysMsgBoardStr - end if - xor eax, eax ; timeout error - ret -.ok: - if DEBUG - mov esi, msgResetOk - call SysMsgBoardStr - end if - xor eax, eax - inc eax - ret -endp - - -align 4 -proc cold_reset - locals - counter dd ? - endl - - stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword 0 - - if DEBUG - mov esi, msgCold - call SysMsgBoardStr - end if - - mov eax, 100000 ; wait 100 ms ;400000 ; wait 400 ms - call StallExec - - ;; ACLink on, deassert ACLink reset, VSR, SGD data out - ;; note - FM data out has trouble with non VRA codecs !! - stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword VIA_ACLINK_CTRL_INIT - - mov [counter], 16 ; total 20*100 ms = 2s -.wait: - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT - test eax, VIA_ACLINK_C00_READY - jnz .ok - - mov eax, 100000 ; wait 100 ms - call StallExec - - dec [counter] - jnz .wait - - if DEBUG - mov esi, msgCRFail - call SysMsgBoardStr - end if - -.fail: - stc - ret -.ok: - mov esi, msgControl - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL - call dword2str - call SysMsgBoardStr - - mov esi, msgStatus - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT - and eax, 0xFF - push eax - call dword2str - call SysMsgBoardStr - pop eax - - test eax, VIA_ACLINK_C00_READY ;CTRL_ST_CREADY - jz .fail - clc - ret -endp - -align 4 -play: - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX - mov eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000 - mov [ctrl.lvi_reg], 16 - call [ctrl.ctrl_write32] - - mov eax, VIA_REG_CTRL_INT - or eax, VIA_REG_CTRL_START - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_write8] - - xor eax, eax - ret - -align 4 -stop: - mov eax, VIA_REG_CTRL_INT - or eax, VIA_REG_CTRL_TERMINATE - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_write8] - - stdcall channel_reset, VIADEV_PLAYBACK - xor eax, eax - ret - -align 4 -proc get_dev_info stdcall, p_info:dword - virtual at esi - CTRL_INFO CTRL_INFO - end virtual - - mov esi, [p_info] - mov eax, [ctrl.int_line] - mov ecx, [ctrl.ctrl_io_base] - mov [CTRL_INFO.irq], eax - mov [CTRL_INFO.ctrl_io_base], ecx - - xor eax, eax - ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_TABLE_PTR - ;call [ctrl.ctrl_read32] - mov [CTRL_INFO.codec_io_base], eax - ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX - ;call [ctrl.ctrl_read32] - mov [CTRL_INFO.codec_mem_base], eax - ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CURR_COUNT - ;call [ctrl.ctrl_read32] - mov [CTRL_INFO.ctrl_mem_base], eax - - mov eax, [codec.chip_id] - mov [CTRL_INFO.codec_id], eax - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_read8] - and eax, 0xFF - mov [CTRL_INFO.glob_cntrl], eax - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS - call [ctrl.ctrl_read8] - and eax, 0xFF - mov [CTRL_INFO.glob_sta], eax - - mov ebx, [ctrl.pci_cmd] - mov [CTRL_INFO.pci_cmd], ebx - ret -endp - -align 4 -proc set_callback stdcall, handler:dword - mov eax, [handler] - mov [ctrl.user_callback], eax - ret -endp - - -align 4 -proc codec_check_ready stdcall - locals - counter dd ? - endl - - mov [counter], 1000 ; total 1000*1 ms = 1s -.wait: - call [ctrl.codec_read16] - test eax, VIA_REG_AC97_BUSY - jz .ok - - mov eax, 1000 ; wait 1 ms - call StallExec - - sub [counter] , 1 - jnz .wait -.err: - mov eax, -1 - ret -.ok: - and eax, 0xFFFF - ret -endp - - -align 4 -proc codec_valid stdcall - stdcall codec_check_ready - ret -endp - -align 4 -proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax - locals - counter dd ? - endl - - ;Use only primary codec. - mov eax, [ac_reg] - and eax, 0x7F - shl eax, VIA_REG_AC97_CMD_SHIFT - or eax, VIA_REG_AC97_PRIMARY_VALID or VIA_REG_AC97_READ - - mov [counter], 3 ; total 3*20 ms = 60ms -.wait: - push eax - call [ctrl.codec_write16] - - mov eax, 20000 ; wait 20 ms - call StallExec - - stdcall codec_valid, - cmp eax, 0 - pop eax - jge .ok - - sub [counter] , 1 - jnz .wait - jmp .err - -.ok: - mov eax, 25000 ; wait 25 ms - call StallExec - - call [ctrl.codec_read16] ;change edx !!! - and eax, 0xFFFF - ret -.err: - if DEBUG - mov esi, msgCInvalid - call SysMsgBoardStr - end if - mov eax, -1 ; invalid codec error - ret -endp - -align 4 -proc codec_write stdcall, ac_reg:dword - ;Use only primary codec. - mov esi, [ac_reg] - mov edx, esi - shl edx, VIA_REG_AC97_CMD_SHIFT - - shl eax, VIA_REG_AC97_DATA_SHIFT - or edx, eax - - mov eax, VIA_REG_AC97_CODEC_ID_PRIMARY ;not VIA_REG_AC97_CODEC_ID_PRIMARY - shl eax, VIA_REG_AC97_CODEC_ID_SHIFT - or edx, eax - - mov eax, edx - mov edx, esi - call [ctrl.codec_write16] - mov [codec.regs+esi], ax - - stdcall codec_check_ready - cmp eax, 0 - jl .err -.ok: - ret -.err: - if DEBUG - mov esi, msgCFail - call SysMsgBoardStr - end if - ;mov eax, -1 ; codec not ready error - ret -endp - -align 4 -proc StallExec - push ecx - push edx - push ebx - push eax - - mov ecx, CPU_FREQ - mul ecx - mov ebx, eax ;low - mov ecx, edx ;high - rdtsc - add ebx, eax - adc ecx, edx -@@: - rdtsc - sub eax, ebx - sbb edx, ecx - js @B - - pop eax - pop ebx - pop edx - pop ecx - ret -endp - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; CONTROLLER IO functions -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -align 4 -proc codec_io_r16 ;r32 - mov edx, [ctrl.ctrl_io_base] - add edx, VIA_REG_AC97 - in eax, dx - ret -endp - -align 4 -proc codec_io_w16 ;w32 - mov edx, [ctrl.ctrl_io_base] - add edx, VIA_REG_AC97 - out dx, eax - ret -endp - -align 4 -proc ctrl_io_r8 - add edx, [ctrl.ctrl_io_base] - in al, dx - ret -endp - -align 4 -proc ctrl_io_r16 - add edx, [ctrl.ctrl_io_base] - in ax, dx - ret -endp - -align 4 -proc ctrl_io_r32 - add edx, [ctrl.ctrl_io_base] - in eax, dx - ret -endp - -align 4 -proc ctrl_io_w8 - add edx, [ctrl.ctrl_io_base] - out dx, al - ret -endp - -align 4 -proc ctrl_io_w16 - add edx, [ctrl.ctrl_io_base] - out dx, ax - ret -endp - -align 4 -proc ctrl_io_w32 - add edx, [ctrl.ctrl_io_base] - out dx, eax - ret -endp - - -align 4 -dword2str: - push eax ebx ecx - mov esi, hex_buff - mov ecx, -8 - @@: - rol eax, 4 - mov ebx, eax - and ebx, 0x0F - mov bl, [ebx+hexletters] - mov [8+esi+ecx], bl - inc ecx - jnz @B - pop ecx ebx eax - ret - -hexletters db '0123456789ABCDEF' -hex_buff db 8 dup(0),13,10,0 - - -include "codec.inc" - -align 4 -devices dd (CTRL_VT82C686 shl 16)+VID_VIA,msg_VT82C686,set_VIA - dd (CTRL_VT8233_5 shl 16)+VID_VIA,msg_VT8233,set_VIA - dd 0 ;terminator - - -version dd (5 shl 16) or (API_VERSION and 0xFFFF) - -msg_VT82C686 db 'VT82C686', 13,10, 0 -msg_VT8233 db 'VT8233', 13,10, 0 -msg_VIA db 'VIA' , 13,10, 0 - -szKernel db 'KERNEL', 0 -sz_sound_srv db 'SOUND',0 - -msgInit db 'detect hardware...',13,10,0 -msgFail db 'device not found',13,10,0 -msgAttchIRQ db 'IRQ line not supported', 13,10, 0 -msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 -msgPlay db 'start play', 13,10,0 -msgStop db 'stop play', 13,10,0 -;msgIRQ db 'AC97 IRQ', 13,10,0 -;msgInitCtrl db 'init controller',13,10,0 -;msgInitCodec db 'init codec',13,10,0 -msgPrimBuff db 'create primary buffer ...',0 -msgDone db 'done',13,10,0 -msgRemap db 'Remap IRQ',13,10,0 -;msgReg db 'set service handler',13,10,0 -;msgOk db 'service installed',13,10,0 -msgCold db 'cold reset',13,10,0 -;msgWarm db 'warm reset',13,10,0 -;msgWRFail db 'warm reset failed',13,10,0 -msgCRFail db 'cold reset failed',13,10,0 -msgCFail db 'codec not ready',13,10,0 -msgCInvalid db 'codec is not valid',13,10,0 ;Asper -msgResetOk db 'reset complete',13,10,0 -msgStatus db 'global status ',0 -msgControl db 'global control ',0 -msgPciCmd db 'PCI command ',0 -msgPciStat db 'PCI status ',0 -msgCtrlIsaIo db 'controller io base ',0 -;msgMixIsaIo db 'codec io base ',0 -;msgCtrlMMIo db 'controller mmio base ',0 -;msgMixMMIo db 'codec mmio base ',0 -;msgIrqMap db 'AC97 irq map as ',0 - - -section '.data' data readable writable align 16 - -pcmout_bdl rq 32 -buff_list rd 32 - -codec CODEC -ctrl AC_CNTRL - -chip_type rb 1 \ No newline at end of file diff --git a/kernel/branches/Kolibri-acpi/drivers/vmode.asm b/kernel/branches/Kolibri-acpi/drivers/vmode.asm deleted file mode 100644 index 9cb0427bbf..0000000000 --- a/kernel/branches/Kolibri-acpi/drivers/vmode.asm +++ /dev/null @@ -1,736 +0,0 @@ -; -; MenuetOS Driver (vmode.mdr) -; Target: Vertical Refresh Rate programming and videomode changing -; -; Author: Trans <<<<<13>>>>> -; Date: 20.07.2003 -; -; Version: 1.0 -; OS: MenuetOS -; Compiler: FASM -; - -OS_BASE equ 0x80000000 - -use32 - -macro align value { rb (value-1) - ($ + value-1) mod value } - - org OS_BASE+0x0328000 - -headerstart=$ - -mdid db 'MDAZ' ; 4 byte id -mdhver dd 0x00 ; header version -mdcode dd MDSTART ; start of code -mdver dd 0x00000001 ; driver version (subversion*65536+version) -mdname db 'Trans VideoDriver' ; 32 bytes of full driver name - times (32-($-mdname)) db ' ' ; - -headerlen=$-headerstart - times (256-headerlen) db 0 ; reserved area for future - -MDSTART: ; start of driver code ( base_adr+256 bytes) -; ebx(=ecx in program): -; 1 - Get DriverInfo and Driver Initial Set -; 2 - Get Current Video Mode With Vertical Refresh Rate -; 3 - Change Video Mode -; 4 - Return at Start System Video Mode -; 5 - Change vertical and horizontal size of visible screen area -; 6 - Change Vert/Hor position visible area on screen (not complete yet) -; -; MAXF - ... -MAXF=5 - -;-------Main Manager------------- - pushad - cmp ebx,1 - jb mdvm_00 - cmp ebx,MAXF - ja mdvm_00 - shl ebx,2 - add ebx,mdvm_func_table - call dword [ebx] - mov [esp+28],eax - mov [esp+24],ecx - mov [esp+20],edx - mov [esp+16],ebx - popad - retn -mdvm_00: - popad - xor eax,eax - dec eax - retn - -; ------Drivers Functions---------- - -align 4 - -; EBX=1 (in applications ECX=1)- Get DriverInfo and Driver Initial Set -; -; IN: ecx (in app. edx) - pointer to 512-bytes info area in application -; OUT: -; -vm_info_init: - push ecx - cmp [mdrvm],dword 0 - jnz .vmii_00 - call vm_safe_reg - call vm_get_initial_videomode - mov eax,[initvm] - mov [currvm],eax - call vm_search_sys_func_table - call vm_get_cur_vert_rate - mov [initrr],eax - call vm_calc_pixelclock - call vm_calc_refrate - inc [mdrvm] -.vmii_00: - pop ecx - call vm_transfer_drv_info - mov ebx,dword [refrate] - mov eax,dword [mdid] ;dword [systlb] - retn - - -align 4 - -; EBX=2 (in applications ECX=2)- Get Current Video Mode -; -; OUT: eax = X_screen*65536+Y_screen -; ebx = current vertical rate -; ecx = current video mode (number) -vm_get_cur_mode: - cmp [mdrvm],dword 0 - jz .vmgcm_00 - call vm_get_cur_vert_rate - mov eax,[OS_BASE+0FE00h] - mov ebx,[OS_BASE+0FE04h] - shl eax,16 - add eax,ebx - add eax,00010001h - mov ebx,[refrate] - mov ecx,[currvm] - retn -.vmgcm_00: - xor eax,eax - dec eax - retn - - -align 4 - -; EBX=3 (in applications ECX=3)- Change Video Mode -; -; IN: ecx = VertRate*65536+VideoMode -; OUT: eax = 0 if no error -; -vm_set_video_mode: - cmp [mdrvm],dword 0 - jz .vmsvm_00 - call vm_set_selected_mode -; xor eax,eax - retn -.vmsvm_00: - xor eax,eax - dec eax - retn - - -align 4 - -; EBX=4 (in applications ECX=4)- Return at Start System Video Mode -; -; IN: -; OUT: eax = = 0 if no error -; -vm_restore_init_video_mode: - cmp [mdrvm],dword 0 - jz .vmrivm_00 - call vm_restore_reg - xor eax,eax - retn -.vmrivm_00: - xor eax,eax - dec eax - retn - - -align 4 - -; EBX=5 (in applications ECX=5)- Change vertical and horizontal size -; of visible screen area -; IN: ecx (in app. edx) = 0/1 - -/+ horizontal size on 1 position -; = 2/3 - -/+ vertical size on 1 position (8 pixels) -; ^-^----- not complete yet -; OUT: eax = = 0 if no error -; -vm_change_screen_size: - cmp [mdrvm],dword 0 - jz .vmcss_00 - cmp cl,1 - ja .vmcss_01 - mov eax,ecx - call vm_inc_dec_width - xor eax,eax - retn -.vmcss_01: - and ecx,01h - mov eax,ecx -; call vm_inc_dec_high ; not complete yet - xor eax,eax - retn -.vmcss_00: - xor eax,eax - dec eax - retn - - -align 4 - -; EBX=6 (in applications ECX=6)- Change Vert/Hor position visible area on screen -; -; IN: ecx (in app. edx) = 0/1 - -/+ horizontal position on 1 point -; = 2/3 - -/+ vertical position on 1 pixel -; ^-^----- not complete yet -; OUT: eax = 0 if no error -; -vm_change_position_screen: - cmp [mdrvm],dword 0 - jz .vmcps_00 - ; ... - xor eax,eax - retn -.vmcps_00: - xor eax,eax - dec eax - retn - - -;-----Drivers Subfunctions--------- - -; -; Searching i40 system functions pointer table in kernel area location -; -vm_search_sys_func_table: - push eax ; eax - current value - push ecx ; ecx - will be counter of equevalent value - push edx ; edx - last value - push esi ; esi - current address - xor ecx,ecx - mov esi,OS_BASE+010000h ; Start address of kernel location - lodsd - mov edx,eax - cld -.vmssft_00: - cmp esi,OS_BASE+30000h - ja .vmssft_03 - inc ecx - lodsd - cmp edx,eax - mov edx,eax - je .vmssft_00 - cmp ecx,128 - ja .vmssft_02 -.vmssft_01: - xor ecx,ecx - jmp .vmssft_00 -.vmssft_02: - cmp edx,0 - je .vmssft_01 - sub esi,256*4-1 - mov [systlb],esi - xor ecx,ecx -.vmssft_03_0: - inc ecx - lodsd - cmp edx,eax - mov edx,eax - jne .vmssft_03_0 - mov esi,dword [systlb] - cmp cx,60 - jae .vmssft_03 - add esi,256*4-4 - lodsb - mov edx,eax - jmp .vmssft_01 -.vmssft_03: - mov [systlb],esi - pop esi - pop edx - pop ecx - pop eax - retn - -; IN: -; OUT: eax= vertical rate in Hz -vm_get_cur_vert_rate: - push edx - push ebx - xor eax,eax - mov edx,eax - mov ebx,eax - mov dx,03DAh -.vmgcvt_00: - in al,dx - test al,8 - jz .vmgcvt_00 -.vmgcvt_01: - in al,dx - test al,8 - jnz .vmgcvt_01 - mov ebx,edx - rdtsc - mov edx,ebx - mov ebx,eax -.vmgcvt_02: - in al,dx - test al,8 - jz .vmgcvt_02 -.vmgcvt_03: - in al,dx - test al,8 - jnz .vmgcvt_03 - rdtsc - sub eax,ebx - mov ebx,eax - mov eax,[OS_BASE+0F600h] - xor edx,edx - div ebx - inc eax - mov [refrate],eax - pop ebx - pop edx - retn - -vm_calc_pixelclock: - push ebx - push edx - xor eax,eax - mov al,[_00] - add ax,5 - shl eax,3 - xor ebx,ebx - mov bl,[_06] - mov bh,[_07] - and bh,00100001b - btr bx,13 - jnc .vmcpc_00 - or bh,2 -.vmcpc_00: - xor edx,edx - mul ebx - xor edx,edx - mul [initrr] - mov [pclock],eax - pop edx - pop ebx - retn - -; -; Safe of initial CRTC state -; -vm_safe_reg: - push edx - push ebx - push ecx - push edi - cli - mov dx,3d4h ; CRTC - mov al,11h - out dx,al - inc dx - in al,dx - and al,7fh - out dx,al ; Clear protection bit - dec dx - xor ecx,ecx - mov cl,19h - xor bl,bl - mov edi,CRTCreg -.vmsr_00: - mov al,bl - out dx,al - inc dx - in al,dx - dec dx - stosb - inc bl - loop .vmsr_00 - sti - pop edi - pop ecx - pop ebx - pop edx - retn - -; -; Restore of initial CRTC state -; -vm_restore_reg: - push eax - push ebx - push edx - push esi - mov eax,[oldX] - mov [OS_BASE+0FE00h],eax - mov eax,[oldY] - mov [OS_BASE+0FE04h],eax - mov dx,03dah -.vmrr_00: - in al,dx - test al,8 - jnz .vmrr_00 -.vmrr_01: - in al,dx - test al,8 - jnz .vmrr_01 - cli - mov dx,03c4h - mov ax,0101h - out dx,ax - mov dx,3d4h ; CRTC - mov al,11h - out dx,al - inc dx - in al,dx - and al,7fh ; Clear Protection bit - out dx,al - dec dx - xor ecx,ecx - mov cl,19h - mov esi,CRTCreg - xor bl,bl -.vmrr_02: - lodsb - mov ah,al - mov al,bl - out dx,ax - inc bl - loop .vmrr_02 - sti -; call ref_screen - pop esi - pop edx - pop ecx - pop eax - retn - -; Calculate of possible vertical refrash rate -; (light version of function) -vm_calc_refrate: - push ebx - push ecx - push edx - push edi - push esi - mov eax,[pclock] - xor edx,edx - mov edi,_m1 - mov ebx,eax - mov ecx,(1696*1065) - div ecx - xor edx,edx - stosw - add edi,8 - mov eax,ebx - mov ecx,(1344*804) - div ecx - xor edx,edx - stosw - add edi,8 - mov eax,ebx - mov ecx,(1056*636) - div ecx - xor edx,edx - stosw - add edi,8 - mov eax,ebx - mov ecx,(800*524) - div ecx - xor edx,edx - stosw - mov edi,_m1 - mov esi,edi - mov ecx,5*4 -.vmcrr_00: - lodsw - cmp ax,55 - jb .vmcrr_01 - stosw - loop .vmcrr_00 - pop esi - pop edi - pop edx - pop ecx - pop ebx - retn -.vmcrr_01: - xor ax,ax - stosw - loop .vmcrr_00 - pop esi - pop edi - pop edx - pop ecx - pop ebx - retn - -vm_get_initial_videomode: - push eax - mov eax,dword [OS_BASE+0FE00h] - mov [oldX],eax - mov eax,dword [OS_BASE+0FE04h] - mov [oldY],eax - mov eax,dword [OS_BASE+0FE0Ch] ; initial video mode - and ax,01FFh - mov dword [initvm],eax - pop eax - retn - - -; IN: eax = 0/1 - -/+ 1 position of width -vm_inc_dec_width: - push ebx - push edx - mov ebx,eax - mov dx,3d4h ; CRTC - mov al,11h - out dx,al - inc dx - in al,dx - and al,7fh ; Clear Protection bit - out dx,al - dec dx - xor al,al - out dx,al - inc dx - in al,dx - dec al - cmp bl,0 - jnz .vmidr_00 - inc al - inc al -.vmidr_00: - out dx,al - pop edx - pop ebx - retn - -; -; Copy driver info to application area -; -; IN: ecx (in app. edx) - pointer to 512-bytes info area in application -; OUT: -vm_transfer_drv_info: - push ecx - push edi - push esi - mov eax,ecx - xor ecx,ecx - mov cl,32/4 - mov esi,mdname - mov edi,drvname - rep movsd - mov ecx,eax - mov eax,[mdver] - mov [drvver],eax - mov edi,[OS_BASE+3010h] - mov edi,[edi+10h] - add edi,ecx - mov esi,drvinfo - xor ecx,ecx - mov cx,512 - rep movsb - pop esi - pop edi - pop ecx - retn - - -; -; Set selected video mode -; (light version) -; -; IN: ecx = VertRate*65536+VideoMode -; -vm_set_selected_mode: - push edx - push ecx - push esi - ror ecx,16 - cmp cx,00h - je .vmssm_03 - rol ecx,16 - mov eax,ecx - shl eax,16 - shr eax,16 - mov [currvm],eax - cmp cx,112h - jne .vmssm_00 - mov esi,mode0 - mov ecx,639 - mov edx,479 - jmp .vmssm_st00 -.vmssm_00: - cmp cx,115h - jne .vmssm_01 - mov esi,mode1 - mov ecx,799 - mov edx,599 - jmp .vmssm_st00 -.vmssm_01: - cmp cx,118h - jne .vmssm_02 - mov esi,mode2 - mov ecx,1023 - mov edx,767 - jmp .vmssm_st00 -.vmssm_02: - cmp cx,11Bh - jne .vmssm_03 - mov esi,mode2 - mov ecx,1279 - mov edx,1023 - jmp .vmssm_st00 -.vmssm_03: - xor eax,eax - dec eax - pop esi - pop ecx - pop edx - retn -.vmssm_st00: - mov [OS_BASE+0FE00h],ecx - mov [OS_BASE+0FE04h],edx - cli - mov dx,03c4h - lodsw - out dx,ax - mov dx,03d4h - mov al,11h - out dx,al - inc dx - in al,dx - and al,7fh - out dx,al - dec dx - mov ecx,13 -.vmssm_st01: - lodsw - out dx,ax - loop .vmssm_st01 - sti - xor eax,eax - pop esi - pop ecx - pop edx - retn - - -;------------DATA AREA--------------- -align 4 - -mdvm_func_table: - dd MDSTART - dd vm_info_init, vm_get_cur_mode - dd vm_set_video_mode, vm_restore_init_video_mode - dd vm_change_screen_size, vm_change_position_screen - - -CRTCreg: -_00 db ? -_01 db ? -_02 db ? -_03 db ? -_04 db ? -_05 db ? -_06 db ? -_07 db ? -_08 db ? -_09 db ? -_0a db ? -_0b db ? -_0c db ? -_0d db ? -_0e db ? -_0f db ? -_10 db ? -_11 db ? -_12 db ? -_13 db ? -_14 db ? -_15 db ? -_16 db ? -_17 db ? -_18 db ? -_19 db ? - -align 4 - -oldX dd ? -oldY dd ? -initvm dd ? -currvm dd 0 -refrate dd 0 -initrr dd 0 -systlb dd 0 -pclock dd ? -mdrvm dd 0 ; 0 - not drv init yet, 1 - already drv init - - -drvinfo: -drvname: times 32 db ' ' -drvver dd 0 - times (32-($-drvver))/4 dd 0 -drvmode dw 011Bh,0118h,0115h,0112h - times (64-($-drvmode))/2 dw 00h -_m1 dw 0,0,0,0,0 -_m2 dw 0,0,0,0,0 -_m3 dw 0,0,0,0,0 -_m4 dw 0,0,0,0,0 -_m5 dw 0,0,0,0,0 - times (512-($-drvinfo)) db 0 -drvinfoend: - - -;1280x1024 - 11Bh -mode3: - dw 0101h - dw 0d000h,9f01h,9f02h,9303h,0a904h,1905h,2806h,5a07h - dw 0110h,8411h,0ff12h,0ff15h,2916h - -;1024x768 - 118h -mode2: - dw 0101h - dw 0a400h,7f01h,7f02h,8703h,8404h,9505h,2406h,0f507h - dw 0310h,8911h,0ff12h,0ff15h,2516h - -;800x600 - 115h -mode1: - dw 0101h - dw 8000h,6301h,6302h,8303h,6a04h,1a05h,7206h,0f007h - dw 5910h,8d11h,5712h,5715h,7316h - -;640x480 - 112h, 12h -mode0: - dw 0101h - dw 6000h,4f01h,4f02h,8303h,5304h,9f05h,00b06h,3e07h - dw 0ea10h,8c11h,0df12h,0df15h,0c16h - -; 640x400 -;mymode0: -; dw 0101h -;_0_7 dw 5f00h,4f01h,4f02h,8303h,5304h,9f05h,0BF06h,1f07h -; dw 9c10h,8e11h,8f12h,9615h,0B916h ;,4013h - -; 640x800 -;mymode1: -; dw 0101h -; dw 5f00h,4f01h,4f02h,8003h,5004h,9f05h,06006h,0FF07h -; dw 2d10h,8f11h,2012h,2615h,05716h ;,4013h - - -DRVM_END: - diff --git a/kernel/branches/Kolibri-acpi/drivers/vt823(x).asm b/kernel/branches/Kolibri-acpi/drivers/vt823(x).asm deleted file mode 100644 index 18dbef9068..0000000000 --- a/kernel/branches/Kolibri-acpi/drivers/vt823(x).asm +++ /dev/null @@ -1,1281 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; -;; Distributed under terms of the GNU General Public License ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -format MS COFF - -DEBUG equ 1 - -include 'proc32.inc' -include 'imports.inc' - -API_VERSION equ 0x01000100 - -USE_COM_IRQ equ 0 ;make irq 3 and irq 4 available for PCI devices -IRQ_REMAP equ 0 -IRQ_LINE equ 0 - - -;irq 0,1,2,8,12,13 недоступны -; FEDCBA9876543210 -VALID_IRQ equ 1100111011111000b -ATTCH_IRQ equ 0000111010100000b - -if USE_COM_IRQ -ATTCH_IRQ equ 0000111010111000b -end if - -CPU_FREQ equ 2600d - -BIT0 EQU 0x00000001 -BIT1 EQU 0x00000002 -BIT5 EQU 0x00000020 -BIT10 EQU 0x00000400 - -VID_VIA equ 0x1106 - -CTRL_VT82C686 equ 0x3058 -CTRL_VT8233_5 equ 0x3059 - - -CODEC_MASTER_VOL_REG equ 0x02 -CODEC_AUX_VOL equ 0x04 ; -CODEC_PCM_OUT_REG equ 0x18 ; PCM output volume -CODEC_EXT_AUDIO_REG equ 0x28 ; extended audio -CODEC_EXT_AUDIO_CTRL_REG equ 0x2a ; extended audio control -CODEC_PCM_FRONT_DACRATE_REG equ 0x2c ; PCM out sample rate -CODEC_PCM_SURND_DACRATE_REG equ 0x2e ; surround sound sample rate -CODEC_PCM_LFE_DACRATE_REG equ 0x30 ; LFE sample rate - - -;VIA host controller registers set -;; common offsets -VIA_REG_OFFSET_STATUS equ 0x00 ;; byte - channel status - VIA_REG_STAT_ACTIVE equ 0x80 ;; RO - VIA_REG_STAT_PAUSED equ 0x40 ;; RO - VIA_REG_STAT_TRIGGER_QUEUED equ 0x08 ;; RO - VIA_REG_STAT_STOPPED equ 0x04 ;; RWC - VIA_REG_STAT_EOL equ 0x02 ;; RWC - VIA_REG_STAT_FLAG equ 0x01 ;; RWC -VIA_REG_OFFSET_CONTROL equ 0x01 ;; byte - channel control - VIA_REG_CTRL_START equ 0x80 ;; WO - VIA_REG_CTRL_TERMINATE equ 0x40 ;; WO - VIA_REG_CTRL_AUTOSTART equ 0x20 - VIA_REG_CTRL_PAUSE equ 0x08 ;; RW - VIA_REG_CTRL_INT_STOP equ 0x04 - VIA_REG_CTRL_INT_EOL equ 0x02 - VIA_REG_CTRL_INT_FLAG equ 0x01 - VIA_REG_CTRL_RESET equ 0x01 ;; RW - probably reset? undocumented - VIA_REG_CTRL_INT equ (VIA_REG_CTRL_INT_FLAG or \ - VIA_REG_CTRL_INT_EOL or \ - VIA_REG_CTRL_AUTOSTART) -VIA_REG_OFFSET_TYPE equ 0x02 ;; byte - channel type (686 only) - VIA_REG_TYPE_AUTOSTART equ 0x80 ;; RW - autostart at EOL - VIA_REG_TYPE_16BIT equ 0x20 ;; RW - VIA_REG_TYPE_STEREO equ 0x10 ;; RW - VIA_REG_TYPE_INT_LLINE equ 0x00 - VIA_REG_TYPE_INT_LSAMPLE equ 0x04 - VIA_REG_TYPE_INT_LESSONE equ 0x08 - VIA_REG_TYPE_INT_MASK equ 0x0c - VIA_REG_TYPE_INT_EOL equ 0x02 - VIA_REG_TYPE_INT_FLAG equ 0x01 -VIA_REG_OFFSET_TABLE_PTR equ 0x04 ;; dword - channel table pointer -VIA_REG_OFFSET_CURR_PTR equ 0x04 ;; dword - channel current pointer -VIA_REG_OFFSET_STOP_IDX equ 0x08 ;; dword - stop index, channel type, sample rate - VIA8233_REG_TYPE_16BIT equ 0x00200000 ;; RW - VIA8233_REG_TYPE_STEREO equ 0x00100000 ;; RW -VIA_REG_OFFSET_CURR_COUNT equ 0x0c ;; dword - channel current count (24 bit) -VIA_REG_OFFSET_CURR_INDEX equ 0x0f ;; byte - channel current index (for via8233 only) - - -VIADEV_PLAYBACK equ 0x00 -VIADEV_CAPTURE equ 0x10 -VIADEV_FM equ 0x20 - -;; AC'97 ;; -VIA_REG_AC97 equ 0x80 ; dword - VIA_REG_AC97_CODEC_ID_MASK equ 0xC0000000 ;(3<<30) - VIA_REG_AC97_CODEC_ID_SHIFT equ 30 - VIA_REG_AC97_CODEC_ID_PRIMARY equ 0x00 - VIA_REG_AC97_CODEC_ID_SECONDARY equ 0x01 - VIA_REG_AC97_SECONDARY_VALID equ 0x08000000 ;(1<<27) - VIA_REG_AC97_PRIMARY_VALID equ 0x02000000 ;(1<<25) - VIA_REG_AC97_BUSY equ 0x01000000 ;(1<<24) - VIA_REG_AC97_READ equ 0x00800000 ;(1<<23) - VIA_REG_AC97_CMD_SHIFT equ 16 - VIA_REG_AC97_CMD_MASK equ 0x7E - VIA_REG_AC97_DATA_SHIFT equ 0 - VIA_REG_AC97_DATA_MASK equ 0xFFFF - -VIA_REG_SGD_SHADOW equ 0x84 ; dword - -;; via8233-specific registers ;; -VIA_REG_OFS_PLAYBACK_VOLUME_L equ 0x02 ;; byte -VIA_REG_OFS_PLAYBACK_VOLUME_R equ 0x03 ;; byte -VIA_REG_OFS_MULTPLAY_FORMAT equ 0x02 ;; byte - format and channels - VIA_REG_MULTPLAY_FMT_8BIT equ 0x00 - VIA_REG_MULTPLAY_FMT_16BIT equ 0x80 - VIA_REG_MULTPLAY_FMT_CH_MASK equ 0x70 ;; # channels << 4 (valid = 1,2,4,6) -VIA_REG_OFS_CAPTURE_FIFO equ 0x02 ;; byte - bit 6 = fifo enable - VIA_REG_CAPTURE_FIFO_ENABLE equ 0x40 - -VIA_DXS_MAX_VOLUME equ 31 ;; max. volume (attenuation) of reg 0x32/33 - -VIA_TBL_BIT_FLAG equ 0x40000000 -VIA_TBL_BIT_EOL equ 0x80000000 - -;; pci space ;; -VIA_ACLINK_STAT equ 0x40 - ;... - VIA_ACLINK_C00_READY equ 0x01 ; primary codec ready -VIA_ACLINK_CTRL equ 0x41 - VIA_ACLINK_CTRL_ENABLE equ 0x80 ; 0: disable, 1: enable - VIA_ACLINK_CTRL_RESET equ 0x40 ; 0: assert, 1: de-assert - VIA_ACLINK_CTRL_SYNC equ 0x20 ; 0: release SYNC, 1: force SYNC hi - VIA_ACLINK_CTRL_SDO equ 0x10 ; 0: release SDO, 1: force SDO hi - VIA_ACLINK_CTRL_VRA equ 0x08 ; 0: disable VRA, 1: enable VRA - VIA_ACLINK_CTRL_PCM equ 0x04 ; 0: disable PCM, 1: enable PCM - VIA_ACLINK_CTRL_FM equ 0x02 ; via686 only - VIA_ACLINK_CTRL_SB equ 0x01 ; via686 only - VIA_ACLINK_CTRL_INIT equ (VIA_ACLINK_CTRL_ENABLE or \ - VIA_ACLINK_CTRL_RESET or \ - VIA_ACLINK_CTRL_PCM or \ - VIA_ACLINK_CTRL_VRA) -VIA_FUNC_ENABLE equ 0x42 - VIA_FUNC_MIDI_PNP equ 0x80 ; FIXME: it's 0x40 in the datasheet! - VIA_FUNC_MIDI_IRQMASK equ 0x40 ; FIXME: not documented! - VIA_FUNC_RX2C_WRITE equ 0x20 - VIA_FUNC_SB_FIFO_EMPTY equ 0x10 - VIA_FUNC_ENABLE_GAME equ 0x08 - VIA_FUNC_ENABLE_FM equ 0x04 - VIA_FUNC_ENABLE_MIDI equ 0x02 - VIA_FUNC_ENABLE_SB equ 0x01 -VIA_PNP_CONTROL equ 0x43 -VIA_FM_NMI_CTRL equ 0x48 -VIA8233_VOLCHG_CTRL equ 0x48 -VIA8233_SPDIF_CTRL equ 0x49 - VIA8233_SPDIF_DX3 equ 0x08 - VIA8233_SPDIF_SLOT_MASK equ 0x03 - VIA8233_SPDIF_SLOT_1011 equ 0x00 - VIA8233_SPDIF_SLOT_34 equ 0x01 - VIA8233_SPDIF_SLOT_78 equ 0x02 - VIA8233_SPDIF_SLOT_69 equ 0x03 -;] Asper - - -SRV_GETVERSION equ 0 -DEV_PLAY equ 1 -DEV_STOP equ 2 -DEV_CALLBACK equ 3 -DEV_SET_BUFF equ 4 -DEV_NOTIFY equ 5 -DEV_SET_MASTERVOL equ 6 -DEV_GET_MASTERVOL equ 7 -DEV_GET_INFO equ 8 - -struc AC_CNTRL ;AC controller base class -{ .bus dd ? - .devfn dd ? - - .vendor dd ? - .dev_id dd ? - .pci_cmd dd ? - .pci_stat dd ? - - .codec_io_base dd ? - .codec_mem_base dd ? - - .ctrl_io_base dd ? - .ctrl_mem_base dd ? - .cfg_reg dd ? - .int_line dd ? - - .vendor_ids dd ? ;vendor id string - .ctrl_ids dd ? ;hub id string - - .buffer dd ? - - .notify_pos dd ? - .notify_task dd ? - - .lvi_reg dd ? - .ctrl_setup dd ? - .user_callback dd ? - .codec_read16 dd ? - .codec_write16 dd ? - - .ctrl_read8 dd ? - .ctrl_read16 dd ? - .ctrl_read32 dd ? - - .ctrl_write8 dd ? - .ctrl_write16 dd ? - .ctrl_write32 dd ? -} - -struc CODEC ;Audio Chip base class -{ - .chip_id dd ? - .flags dd ? - .status dd ? - - .ac_vendor_ids dd ? ;ac vendor id string - .chip_ids dd ? ;chip model string - - .shadow_flag dd ? - dd ? - - .regs dw ? ; codec registers - .reg_master_vol dw ? ;0x02 - .reg_aux_out_vol dw ? ;0x04 - .reg_mone_vol dw ? ;0x06 - .reg_master_tone dw ? ;0x08 - .reg_beep_vol dw ? ;0x0A - .reg_phone_vol dw ? ;0x0C - .reg_mic_vol dw ? ;0x0E - .reg_line_in_vol dw ? ;0x10 - .reg_cd_vol dw ? ;0x12 - .reg_video_vol dw ? ;0x14 - .reg_aux_in_vol dw ? ;0x16 - .reg_pcm_out_vol dw ? ;0x18 - .reg_rec_select dw ? ;0x1A - .reg_rec_gain dw ? ;0x1C - .reg_rec_gain_mic dw ? ;0x1E - .reg_gen dw ? ;0x20 - .reg_3d_ctrl dw ? ;0X22 - .reg_page dw ? ;0X24 - .reg_powerdown dw ? ;0x26 - .reg_ext_audio dw ? ;0x28 - .reg_ext_st dw ? ;0x2a - .reg_pcm_front_rate dw ? ;0x2c - .reg_pcm_surr_rate dw ? ;0x2e - .reg_lfe_rate dw ? ;0x30 - .reg_pcm_in_rate dw ? ;0x32 - dw ? ;0x34 - .reg_cent_lfe_vol dw ? ;0x36 - .reg_surr_vol dw ? ;0x38 - .reg_spdif_ctrl dw ? ;0x3A - dw ? ;0x3C - dw ? ;0x3E - dw ? ;0x40 - dw ? ;0x42 - dw ? ;0x44 - dw ? ;0x46 - dw ? ;0x48 - dw ? ;0x4A - dw ? ;0x4C - dw ? ;0x4E - dw ? ;0x50 - dw ? ;0x52 - dw ? ;0x54 - dw ? ;0x56 - dw ? ;0x58 - dw ? ;0x5A - dw ? ;0x5C - dw ? ;0x5E - .reg_page_0 dw ? ;0x60 - .reg_page_1 dw ? ;0x62 - .reg_page_2 dw ? ;0x64 - .reg_page_3 dw ? ;0x66 - .reg_page_4 dw ? ;0x68 - .reg_page_5 dw ? ;0x6A - .reg_page_6 dw ? ;0x6C - .reg_page_7 dw ? ;0x6E - dw ? ;0x70 - dw ? ;0x72 - dw ? ;0x74 - dw ? ;0x76 - dw ? ;0x78 - dw ? ;0x7A - .reg_vendor_id_1 dw ? ;0x7C - .reg_vendor_id_2 dw ? ;0x7E - - - .reset dd ? ;virual - .set_master_vol dd ? -} - -struc CTRL_INFO -{ .pci_cmd dd ? - .irq dd ? - .glob_cntrl dd ? - .glob_sta dd ? - .codec_io_base dd ? - .ctrl_io_base dd ? - .codec_mem_base dd ? - .ctrl_mem_base dd ? - .codec_id dd ? -} - -struc IOCTL -{ .handle dd ? - .io_code dd ? - .input dd ? - .inp_size dd ? - .output dd ? - .out_size dd ? -} - -virtual at 0 - IOCTL IOCTL -end virtual - -EVENT_NOTIFY equ 0x00000200 - -public START -public service_proc -public version - -section '.flat' code readable align 16 - -proc START stdcall, state:dword - - cmp [state], 1 - jne .stop - - if DEBUG - mov esi, msgInit - call SysMsgBoardStr - end if - - call detect_controller - test eax, eax - jz .fail - - if DEBUG - mov esi,[ctrl.vendor_ids] - call SysMsgBoardStr - mov esi, [ctrl.ctrl_ids] - call SysMsgBoardStr - end if - - call init_controller - test eax, eax - jz .fail - - call init_codec - test eax, eax - jz .fail - - call setup_codec - - mov esi, msgPrimBuff - call SysMsgBoardStr - call create_primary_buff - mov esi, msgDone - call SysMsgBoardStr - - if IRQ_REMAP - pushf - cli - - mov ebx, [ctrl.int_line] - in al, 0xA1 - mov ah, al - in al, 0x21 - test ebx, ebx - jz .skip - bts ax, bx ;mask old line -.skip: - bts ax, IRQ_LINE ;mask new ine - out 0x21, al - mov al, ah - out 0xA1, al - - stdcall PciWrite8, 0, 0xF8, 0x61, IRQ_LINE ;remap IRQ - - mov dx, 0x4d0 ;8259 ELCR1 - in al, dx - bts ax, IRQ_LINE - out dx, al ;set level-triggered mode - mov [ctrl.int_line], IRQ_LINE - popf - mov esi, msgRemap - call SysMsgBoardStr - end if - - mov eax, VALID_IRQ - mov ebx, [ctrl.int_line] - mov esi, msgInvIRQ - bt eax, ebx - jnc .fail_msg - mov eax, ATTCH_IRQ - mov esi, msgAttchIRQ - bt eax, ebx - jnc .fail_msg - - stdcall AttachIntHandler, ebx, ac97_irq_VIA, dword 0 -.reg: - stdcall RegService, sz_sound_srv, service_proc - ret -.fail: - if DEBUG - mov esi, msgFail - call SysMsgBoardStr - end if - xor eax, eax - ret -.fail_msg: - call SysMsgBoardStr - xor eax, eax - ret -.stop: - call stop - xor eax, eax - ret -endp - -handle equ IOCTL.handle -io_code equ IOCTL.io_code -input equ IOCTL.input -inp_size equ IOCTL.inp_size -output equ IOCTL.output -out_size equ IOCTL.out_size - -align 4 -proc service_proc stdcall, ioctl:dword - - mov edi, [ioctl] - mov eax, [edi+io_code] - - cmp eax, SRV_GETVERSION - jne @F - mov eax, [edi+output] - cmp [edi+out_size], 4 - jne .fail - - mov [eax], dword API_VERSION - xor eax, eax - ret -@@: - cmp eax, DEV_PLAY - jne @F - if DEBUG - mov esi, msgPlay - call SysMsgBoardStr - end if - call play - ret -@@: - cmp eax, DEV_STOP - jne @F - if DEBUG - mov esi, msgStop - call SysMsgBoardStr - end if - call stop - ret -@@: - cmp eax, DEV_CALLBACK - jne @F - mov ebx, [edi+input] - stdcall set_callback, [ebx] - ret -@@: - cmp eax, DEV_SET_MASTERVOL - jne @F - mov eax, [edi+input] - mov eax, [eax] - call set_master_vol ;eax= vol - ret -@@: - cmp eax, DEV_GET_MASTERVOL - jne @F - mov ebx, [edi+output] - stdcall get_master_vol, ebx - ret -@@: - cmp eax, DEV_GET_INFO - jne @F - mov ebx, [edi+output] - stdcall get_dev_info, ebx - ret -@@: -.fail: - or eax, -1 - ret -endp - -restore handle -restore io_code -restore input -restore inp_size -restore output -restore out_size - - -align 4 -proc ac97_irq_VIA - locals - status db 0 - endl - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS - call [ctrl.ctrl_read8] - test al, VIA_REG_STAT_ACTIVE - jz @f - - and al, VIA_REG_STAT_EOL or VIA_REG_STAT_FLAG or VIA_REG_STAT_STOPPED - mov byte [status], al - - mov ebx, dword [buff_list] - cmp [ctrl.user_callback], 0 - je @f - stdcall [ctrl.user_callback], ebx - @@: - mov al, byte [status] ;; ack ;; - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS - call [ctrl.ctrl_write8] - - ret -endp - - -align 4 -proc create_primary_buff - - stdcall KernelAlloc, 0x10000 - mov [ctrl.buffer], eax - - mov edi, eax - mov ecx, 0x10000/4 - xor eax, eax - cld - rep stosd - - mov eax, [ctrl.buffer] - call GetPgAddr - mov edi, pcmout_bdl - stosd - mov eax, 0x80004000 - stosd - - mov edi, buff_list - mov eax, [ctrl.buffer] - mov ecx, 4 -@@: - mov [edi], eax - mov [edi+16], eax - mov [edi+32], eax - mov [edi+48], eax - mov [edi+64], eax - mov [edi+80], eax - mov [edi+96], eax - mov [edi+112], eax - - ;add eax, 0x4000 - add edi, 4 - loop @B - - stdcall channel_reset, VIADEV_PLAYBACK - stdcall codec_check_ready - - mov eax, pcmout_bdl - mov ebx, eax - call GetPgAddr - and ebx, 0xFFF - add eax, ebx - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_TABLE_PTR - call [ctrl.ctrl_write32] - - stdcall codec_check_ready - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_L - mov eax, 7;31 - call [ctrl.ctrl_write8] - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFS_PLAYBACK_VOLUME_R - mov eax, 7;31 - call [ctrl.ctrl_write8] - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX - mov eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000 - mov [ctrl.lvi_reg], 16;0xF;eax - call [ctrl.ctrl_write32] - - stdcall codec_check_ready - ret -endp - - -proc channel_reset channel:dword - mov esi, dword [channel] - mov edx, esi - add edx, VIA_REG_OFFSET_CONTROL - mov eax, VIA_REG_CTRL_PAUSE or VIA_REG_CTRL_TERMINATE or VIA_REG_CTRL_RESET - call [ctrl.ctrl_write8] - - mov edx, esi - add edx, VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_read8] - - mov eax, 50000 ; wait 50 ms - call StallExec - ; disable interrupts - mov edx, esi - add edx, VIA_REG_OFFSET_CONTROL - xor eax, eax - call [ctrl.ctrl_write8] - - ; clear interrupts - mov edx, esi - add edx, VIA_REG_OFFSET_STATUS - mov eax, 0x03 - call [ctrl.ctrl_write8] - - ;outb(0x00, VIADEV_REG(viadev, OFFSET_TYPE)); /* for via686 */ - ; mov edx, esi ;; for via686 - ; add edx, VIA_REG_OFFSET_TYPE - ; mov eax, 0x03 - ; call [ctrl.ctrl_write8] - - ;; outl(0, VIADEV_REG(viadev, OFFSET_CURR_PTR)); - ;mov edx, esi - ;add edx, VIA_REG_OFFSET_CURR_PTR - ;xor eax, eax - ;call [ctrl.ctrl_write8] - - ret -endp - - -align 4 -proc detect_controller - locals - last_bus dd ? - bus dd ? - devfn dd ? - endl - - xor eax, eax - mov [bus], eax - inc eax - call PciApi - cmp eax, -1 - je .err - - mov [last_bus], eax - -.next_bus: - and [devfn], 0 -.next_dev: - stdcall PciRead32, [bus], [devfn], dword 0 - test eax, eax - jz .next - cmp eax, -1 - je .next - - mov edi, devices -@@: - mov ebx, [edi] - test ebx, ebx - jz .next - - cmp eax, ebx - je .found - add edi, 12 - jmp @B -.next: - inc [devfn] - cmp [devfn], 256 - jb .next_dev - mov eax, [bus] - inc eax - mov [bus], eax - cmp eax, [last_bus] - jna .next_bus - xor eax, eax - ret -.found: - mov ebx, [bus] - mov [ctrl.bus], ebx - - mov ecx, [devfn] - mov [ctrl.devfn], ecx - - mov edx, eax - and edx, 0xFFFF - mov [ctrl.vendor], edx - shr eax, 16 - mov [ctrl.dev_id], eax - - mov ebx, [edi+4] - mov [ctrl.ctrl_ids], ebx - mov esi, [edi+8] - mov [ctrl.ctrl_setup], esi - - cmp edx, VID_VIA - jne @F - mov [ctrl.vendor_ids], msg_VIA - ret -@@: - -.err: - xor eax, eax - mov [ctrl.vendor_ids], eax ;something wrong ? - ret -endp - -align 4 -proc init_controller - - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4 - mov ebx, eax - and eax, 0xFFFF - mov [ctrl.pci_cmd], eax - shr ebx, 16 - mov [ctrl.pci_stat], ebx - - mov esi, msgPciCmd - call SysMsgBoardStr - call dword2str - call SysMsgBoardStr - - mov esi, msgPciStat - call SysMsgBoardStr - mov eax, [ctrl.pci_stat] - call dword2str - call SysMsgBoardStr - - mov esi, msgCtrlIsaIo - call SysMsgBoardStr - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10 - call dword2str - call SysMsgBoardStr - - and eax, 0xFFC0 - mov [ctrl.ctrl_io_base], eax - -.default: - stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C - and eax, 0xFF -@@: - mov [ctrl.int_line], eax - - ;stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE ;0x42 - ;mov byte [old_legacy], al - - ;stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_PNP_CONTROL ;0x43 - ;mov byte [old_legacy_cfg], al - - ;mov al, VIA_FUNC_ENABLE_SB or VIA_FUNC_ENABLE_FM - ;xor al, 0xFF - ;and al, byte [old_legacy] - ;and eax, 0xFF - ;stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_FUNC_ENABLE, eax ;0x42 - ;mov byte [old_legacy], al - - call [ctrl.ctrl_setup] - xor eax, eax - inc eax - ret -endp - -align 4 -proc set_VIA - mov [ctrl.codec_read16], codec_io_r16 ;virtual - mov [ctrl.codec_write16], codec_io_w16 ;virtual - - mov [ctrl.ctrl_read8 ], ctrl_io_r8 ;virtual - mov [ctrl.ctrl_read16], ctrl_io_r16 ;virtual - mov [ctrl.ctrl_read32], ctrl_io_r32 ;virtual - - mov [ctrl.ctrl_write8 ], ctrl_io_w8 ;virtual - mov [ctrl.ctrl_write16], ctrl_io_w16 ;virtual - mov [ctrl.ctrl_write32], ctrl_io_w32 ;virtual - ret -endp - - -align 4 -proc init_codec - locals - counter dd ? - endl - - mov esi, msgControl - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL - and eax, 0xFF - call dword2str - call SysMsgBoardStr - - mov esi, msgStatus - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT - and eax, 0xFF - push eax - call dword2str - call SysMsgBoardStr - pop eax - - test eax, VIA_ACLINK_C00_READY - jz .ready - - call reset_codec - test eax, eax - jz .err - -.ready: - xor edx, edx ; ac_reg_0 - call [ctrl.codec_write16] - jmp .done - -.err: - xor eax, eax ; timeout error - ret - -.done: - call detect_codec - - xor eax, eax - inc eax - ret -endp - -align 4 -proc reset_codec - stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, \ - VIA_ACLINK_CTRL_ENABLE or VIA_ACLINK_CTRL_RESET or VIA_ACLINK_CTRL_SYNC - mov eax, 100000 ; wait 100 ms - call StallExec -.cold: - call cold_reset - jnc .ok - - if DEBUG - mov esi, msgCFail - call SysMsgBoardStr - end if - xor eax, eax ; timeout error - ret -.ok: - if DEBUG - mov esi, msgResetOk - call SysMsgBoardStr - end if - xor eax, eax - inc eax - ret -endp - - -align 4 -proc cold_reset - locals - counter dd ? - endl - - stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword 0 - - if DEBUG - mov esi, msgCold - call SysMsgBoardStr - end if - - mov eax, 100000 ; wait 100 ms ;400000 ; wait 400 ms - call StallExec - - ;; ACLink on, deassert ACLink reset, VSR, SGD data out - ;; note - FM data out has trouble with non VRA codecs !! - stdcall PciWrite8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL, dword VIA_ACLINK_CTRL_INIT - - mov [counter], 16 ; total 20*100 ms = 2s -.wait: - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT - test eax, VIA_ACLINK_C00_READY - jnz .ok - - mov eax, 100000 ; wait 100 ms - call StallExec - - dec [counter] - jnz .wait - - if DEBUG - mov esi, msgCRFail - call SysMsgBoardStr - end if - -.fail: - stc - ret -.ok: - mov esi, msgControl - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_CTRL - call dword2str - call SysMsgBoardStr - - mov esi, msgStatus - call SysMsgBoardStr - stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword VIA_ACLINK_STAT - and eax, 0xFF - push eax - call dword2str - call SysMsgBoardStr - pop eax - - test eax, VIA_ACLINK_C00_READY ;CTRL_ST_CREADY - jz .fail - clc - ret -endp - -align 4 -play: - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX - mov eax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000 - mov [ctrl.lvi_reg], 16 - call [ctrl.ctrl_write32] - - mov eax, VIA_REG_CTRL_INT - or eax, VIA_REG_CTRL_START - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_write8] - - xor eax, eax - ret - -align 4 -stop: - mov eax, VIA_REG_CTRL_INT - or eax, VIA_REG_CTRL_TERMINATE - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_write8] - - stdcall channel_reset, VIADEV_PLAYBACK - xor eax, eax - ret - -align 4 -proc get_dev_info stdcall, p_info:dword - virtual at esi - CTRL_INFO CTRL_INFO - end virtual - - mov esi, [p_info] - mov eax, [ctrl.int_line] - mov ecx, [ctrl.ctrl_io_base] - mov [CTRL_INFO.irq], eax - mov [CTRL_INFO.ctrl_io_base], ecx - - xor eax, eax - ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_TABLE_PTR - ;call [ctrl.ctrl_read32] - mov [CTRL_INFO.codec_io_base], eax - ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STOP_IDX - ;call [ctrl.ctrl_read32] - mov [CTRL_INFO.codec_mem_base], eax - ;mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CURR_COUNT - ;call [ctrl.ctrl_read32] - mov [CTRL_INFO.ctrl_mem_base], eax - - mov eax, [codec.chip_id] - mov [CTRL_INFO.codec_id], eax - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_CONTROL - call [ctrl.ctrl_read8] - and eax, 0xFF - mov [CTRL_INFO.glob_cntrl], eax - - mov edx, VIADEV_PLAYBACK +VIA_REG_OFFSET_STATUS - call [ctrl.ctrl_read8] - and eax, 0xFF - mov [CTRL_INFO.glob_sta], eax - - mov ebx, [ctrl.pci_cmd] - mov [CTRL_INFO.pci_cmd], ebx - ret -endp - -align 4 -proc set_callback stdcall, handler:dword - mov eax, [handler] - mov [ctrl.user_callback], eax - ret -endp - - -align 4 -proc codec_check_ready stdcall - locals - counter dd ? - endl - - mov [counter], 1000 ; total 1000*1 ms = 1s -.wait: - call [ctrl.codec_read16] - test eax, VIA_REG_AC97_BUSY - jz .ok - - mov eax, 1000 ; wait 1 ms - call StallExec - - sub [counter] , 1 - jnz .wait -.err: - mov eax, -1 - ret -.ok: - and eax, 0xFFFF - ret -endp - - -align 4 -proc codec_valid stdcall - stdcall codec_check_ready - ret -endp - -align 4 -proc codec_read stdcall, ac_reg:dword ; reg = edx, reval = eax - locals - counter dd ? - endl - - ;Use only primary codec. - mov eax, [ac_reg] - and eax, 0x7F - shl eax, VIA_REG_AC97_CMD_SHIFT - or eax, VIA_REG_AC97_PRIMARY_VALID or VIA_REG_AC97_READ - - mov [counter], 3 ; total 3*20 ms = 60ms -.wait: - push eax - call [ctrl.codec_write16] - - mov eax, 20000 ; wait 20 ms - call StallExec - - stdcall codec_valid, - cmp eax, 0 - pop eax - jge .ok - - sub [counter] , 1 - jnz .wait - jmp .err - -.ok: - mov eax, 25000 ; wait 25 ms - call StallExec - - call [ctrl.codec_read16] ;change edx !!! - and eax, 0xFFFF - ret -.err: - if DEBUG - mov esi, msgCInvalid - call SysMsgBoardStr - end if - mov eax, -1 ; invalid codec error - ret -endp - -align 4 -proc codec_write stdcall, ac_reg:dword - ;Use only primary codec. - mov esi, [ac_reg] - mov edx, esi - shl edx, VIA_REG_AC97_CMD_SHIFT - - shl eax, VIA_REG_AC97_DATA_SHIFT - or edx, eax - - mov eax, VIA_REG_AC97_CODEC_ID_PRIMARY ;not VIA_REG_AC97_CODEC_ID_PRIMARY - shl eax, VIA_REG_AC97_CODEC_ID_SHIFT - or edx, eax - - mov eax, edx - mov edx, esi - call [ctrl.codec_write16] - mov [codec.regs+esi], ax - - stdcall codec_check_ready - cmp eax, 0 - jl .err -.ok: - ret -.err: - if DEBUG - mov esi, msgCFail - call SysMsgBoardStr - end if - ;mov eax, -1 ; codec not ready error - ret -endp - -align 4 -proc StallExec - push ecx - push edx - push ebx - push eax - - mov ecx, CPU_FREQ - mul ecx - mov ebx, eax ;low - mov ecx, edx ;high - rdtsc - add ebx, eax - adc ecx, edx -@@: - rdtsc - sub eax, ebx - sbb edx, ecx - js @B - - pop eax - pop ebx - pop edx - pop ecx - ret -endp - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; CONTROLLER IO functions -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -align 4 -proc codec_io_r16 ;r32 - mov edx, [ctrl.ctrl_io_base] - add edx, VIA_REG_AC97 - in eax, dx - ret -endp - -align 4 -proc codec_io_w16 ;w32 - mov edx, [ctrl.ctrl_io_base] - add edx, VIA_REG_AC97 - out dx, eax - ret -endp - -align 4 -proc ctrl_io_r8 - add edx, [ctrl.ctrl_io_base] - in al, dx - ret -endp - -align 4 -proc ctrl_io_r16 - add edx, [ctrl.ctrl_io_base] - in ax, dx - ret -endp - -align 4 -proc ctrl_io_r32 - add edx, [ctrl.ctrl_io_base] - in eax, dx - ret -endp - -align 4 -proc ctrl_io_w8 - add edx, [ctrl.ctrl_io_base] - out dx, al - ret -endp - -align 4 -proc ctrl_io_w16 - add edx, [ctrl.ctrl_io_base] - out dx, ax - ret -endp - -align 4 -proc ctrl_io_w32 - add edx, [ctrl.ctrl_io_base] - out dx, eax - ret -endp - - -align 4 -dword2str: - push eax ebx ecx - mov esi, hex_buff - mov ecx, -8 - @@: - rol eax, 4 - mov ebx, eax - and ebx, 0x0F - mov bl, [ebx+hexletters] - mov [8+esi+ecx], bl - inc ecx - jnz @B - pop ecx ebx eax - ret - -hexletters db '0123456789ABCDEF' -hex_buff db 8 dup(0),13,10,0 - - -include "codec.inc" - -align 4 -devices dd (CTRL_VT82C686 shl 16)+VID_VIA,msg_VT82C686,set_VIA - dd (CTRL_VT8233_5 shl 16)+VID_VIA,msg_VT8233,set_VIA - dd 0 ;terminator - - -version dd (5 shl 16) or (API_VERSION and 0xFFFF) - -msg_VT82C686 db 'VT82C686', 13,10, 0 -msg_VT8233 db 'VT8233', 13,10, 0 -msg_VIA db 'VIA' , 13,10, 0 - -szKernel db 'KERNEL', 0 -sz_sound_srv db 'SOUND',0 - -msgInit db 'detect hardware...',13,10,0 -msgFail db 'device not found',13,10,0 -msgAttchIRQ db 'IRQ line not supported', 13,10, 0 -msgInvIRQ db 'IRQ line not assigned or invalid', 13,10, 0 -msgPlay db 'start play', 13,10,0 -msgStop db 'stop play', 13,10,0 -;msgIRQ db 'AC97 IRQ', 13,10,0 -;msgInitCtrl db 'init controller',13,10,0 -;msgInitCodec db 'init codec',13,10,0 -msgPrimBuff db 'create primary buffer ...',0 -msgDone db 'done',13,10,0 -msgRemap db 'Remap IRQ',13,10,0 -;msgReg db 'set service handler',13,10,0 -;msgOk db 'service installed',13,10,0 -msgCold db 'cold reset',13,10,0 -;msgWarm db 'warm reset',13,10,0 -;msgWRFail db 'warm reset failed',13,10,0 -msgCRFail db 'cold reset failed',13,10,0 -msgCFail db 'codec not ready',13,10,0 -msgCInvalid db 'codec is not valid',13,10,0 ;Asper -msgResetOk db 'reset complete',13,10,0 -msgStatus db 'global status ',0 -msgControl db 'global control ',0 -msgPciCmd db 'PCI command ',0 -msgPciStat db 'PCI status ',0 -msgCtrlIsaIo db 'controller io base ',0 -;msgMixIsaIo db 'codec io base ',0 -;msgCtrlMMIo db 'controller mmio base ',0 -;msgMixMMIo db 'codec mmio base ',0 -;msgIrqMap db 'AC97 irq map as ',0 - - -section '.data' data readable writable align 16 - -pcmout_bdl rq 32 -buff_list rd 32 - -codec CODEC -ctrl AC_CNTRL - -chip_type rb 1 \ No newline at end of file diff --git a/kernel/branches/Kolibri-acpi/gui/window.inc b/kernel/branches/Kolibri-acpi/gui/window.inc index 3ed545ab66..8bfc01ca42 100644 --- a/kernel/branches/Kolibri-acpi/gui/window.inc +++ b/kernel/branches/Kolibri-acpi/gui/window.inc @@ -1163,7 +1163,7 @@ sys_window_end_moving_handler: ;/////////////////////////////////////////////// ;> esi = process slot ;------------------------------------------------------------------------------ mov edi, ebx - call window._.draw_negative_box + call window._.end_moving__box mov edi, esi shl edi, 5 @@ -1306,18 +1306,7 @@ end if mov ecx, 4 repz cmpsd pop edi - jnz @f - - mov edi,eax - mov eax, [edi + BOX.left - 2] - mov ax, word[edi + BOX.left] - add ax, word[edi + BOX.width] - mov ebx, [edi + BOX.top - 2] - mov bx, word[edi + BOX.top] - add bx, word[edi + BOX.height] - xor esi,esi - call draw_rectangle.forced - jmp .exit + jz .exit @@: add esp, -BOX.sizeof @@ -1823,6 +1812,9 @@ window._.window_activate: ;//////////////////////////////////////////////////// ; if type of current active window is 3 or 4, it must be redrawn mov ebx, [TASK_COUNT] + +; DEBUGF 1, "K : TASK_COUNT (0x%x)\n", ebx + movzx ebx, word[WIN_POS + ebx * 2] shl ebx, 5 add eax, window_data @@ -1849,6 +1841,13 @@ window._.window_activate: ;//////////////////////////////////////////////////// cmp eax, [TASK_COUNT] jae .move_self_up inc eax + +; push ebx +; xor ebx,ebx +; mov bx,[WIN_STACK + eax * 2] +; DEBUGF 1, "K : DEC WIN_STACK (0x%x)\n",ebx +; pop ebx + cmp [WIN_STACK + eax * 2], bx jbe .next_stack_window dec word[WIN_STACK + eax * 2] @@ -1881,6 +1880,53 @@ window._.window_activate: ;//////////////////////////////////////////////////// pop ebx eax ret +;------------------------------------------------------------------------------ +window._.window_deactivate: ;//////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +;? Deactivate window +;------------------------------------------------------------------------------ +;> esi = pointer to WIN_POS+ window data +;------------------------------------------------------------------------------ + push eax ebx +;------------------------------------------------------------------------------ +.move_others_up: + ; ax <- process no + movzx ebx, word[esi] + ; ax <- position in window stack + movzx ebx, word[WIN_STACK + ebx * 2] + ; up others + xor eax, eax +.next_stack_window: + cmp eax, [TASK_COUNT] + jae .move_self_down + inc eax + cmp [WIN_STACK + eax * 2], bx + jae .next_stack_window + inc word[WIN_STACK + eax * 2] + jmp .next_stack_window +;---------------------------------------------- +.move_self_down: + movzx ebx, word[esi] + ; this is the last (and the low) + mov [WIN_STACK + ebx * 2], word 1 + ; update on screen - window stack + xor eax, eax +.next_window_pos: + cmp eax, [TASK_COUNT] + jae .reset_vars + inc eax + movzx ebx, word[WIN_STACK + eax * 2] + mov [WIN_POS + ebx * 2], ax + jmp .next_window_pos +;----------------------------------------------- +.reset_vars: + mov byte[KEY_COUNT], 0 + mov byte[BTN_COUNT], 0 + mov word[MOUSE_SCROLL_H], 0 + mov word[MOUSE_SCROLL_V], 0 + pop ebx eax + ret +;------------------------------------------------------------------------------ align 4 ;------------------------------------------------------------------------------ window._.check_window_draw: ;////////////////////////////////////////////////// @@ -2084,13 +2130,24 @@ window._.draw_negative_box: ;////////////////////////////////////////////////// ;> edi = pointer to BOX struct ;------------------------------------------------------------------------------ push eax ebx esi + mov esi, 0x01000000 +.1: mov eax, [edi + BOX.left - 2] mov ax, word[edi + BOX.left] add ax, word[edi + BOX.width] mov ebx, [edi + BOX.top - 2] mov bx, word[edi + BOX.top] add bx, word[edi + BOX.height] - mov esi, 0x01000000 call draw_rectangle.forced pop esi ebx eax ret +;------------------------------------------------------------------------------ +window._.end_moving__box: ;////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +;? Draw positive box +;------------------------------------------------------------------------------ +;> edi = pointer to BOX struct +;------------------------------------------------------------------------------ + push eax ebx esi + xor esi,esi + jmp window._.draw_negative_box.1 \ No newline at end of file diff --git a/kernel/branches/Kolibri-acpi/kernel.asm b/kernel/branches/Kolibri-acpi/kernel.asm index f25d65c803..634c50a2ce 100644 --- a/kernel/branches/Kolibri-acpi/kernel.asm +++ b/kernel/branches/Kolibri-acpi/kernel.asm @@ -867,17 +867,17 @@ end if ; LOAD FIRST APPLICATION cli - cmp byte [BOOT_VAR+0x9030],1 - jne no_load_vrr_m +; cmp byte [BOOT_VAR+0x9030],1 +; jne no_load_vrr_m - mov ebp, vrr_m - call fs_execute_from_sysdir - -; cmp eax,2 ; if vrr_m app found (PID=2) - sub eax,2 - jz first_app_found - -no_load_vrr_m: +; mov ebp, vrr_m +; call fs_execute_from_sysdir +; +;; cmp eax,2 ; if vrr_m app found (PID=2) +; sub eax,2 +; jz first_app_found +; +;no_load_vrr_m: mov ebp, firstapp call fs_execute_from_sysdir @@ -1935,7 +1935,7 @@ sys_end: iglobal align 4 sys_system_table: - dd exit_for_anyone ; 1 = obsolete + dd sysfn_deactivate ; 1 = deactivate window dd sysfn_terminate ; 2 = terminate thread dd sysfn_activate ; 3 = activate window dd sysfn_getidletime ; 4 = get idle time @@ -1960,7 +1960,7 @@ sys_system_table: dd sysfn_min_rest_window ; 22 = minimize and restore any window sysfn_num = ($ - sys_system_table)/4 endg - +;------------------------------------------------------------------------------ sys_system: dec ebx cmp ebx, sysfn_num @@ -1968,8 +1968,7 @@ sys_system: jmp dword [sys_system_table + ebx*4] @@: ret - - +;------------------------------------------------------------------------------ sysfn_shutdown: ; 18.9 = system shutdown cmp ecx,1 jl exit_for_anyone @@ -1986,7 +1985,7 @@ sysfn_shutdown: ; 18.9 = system shutdown uglobal shutdown_processes: dd 0x0 endg - +;------------------------------------------------------------------------------ sysfn_terminate: ; 18.2 = TERMINATE cmp ecx,2 jb noprocessterminate @@ -2010,7 +2009,7 @@ sysfn_terminate: ; 18.2 = TERMINATE noatsc: noprocessterminate: ret - +;------------------------------------------------------------------------------ sysfn_terminate2: ;lock application_table_status mutex .table_status: @@ -2037,7 +2036,34 @@ sysfn_terminate2: mov [application_table_status],0 or dword [esp+32],-1 ret +;------------------------------------------------------------------------------ +sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW + cmp ecx,2 + jb .nowindowdeactivate + cmp ecx,[TASK_COUNT] + ja .nowindowdeactivate + + movzx esi, word [WIN_STACK + ecx*2] + cmp esi, 1 + je .nowindowdeactivate ; already deactive + mov edi, ecx + shl edi, 5 + add edi, window_data + movzx esi, word [WIN_STACK + ecx * 2] + lea esi, [WIN_POS + esi * 2] + call window._.window_deactivate + + xor eax, eax + mov byte[MOUSE_BACKGROUND], al + mov byte[DONT_DRAW_MOUSE], al + mov byte[MOUSE_DOWN], 0 + + call syscall_display_settings._.calculate_whole_screen + call syscall_display_settings._.redraw_whole_screen +.nowindowdeactivate: + ret + ;------------------------------------------------------------------------------ sysfn_activate: ; 18.3 = ACTIVATE WINDOW cmp ecx,2 jb .nowindowactivate @@ -2058,28 +2084,29 @@ sysfn_activate: ; 18.3 = ACTIVATE WINDOW call waredraw .nowindowactivate: ret - +;------------------------------------------------------------------------------ sysfn_getidletime: ; 18.4 = GET IDLETIME mov eax,[idleusesec] mov [esp+32], eax ret - +;------------------------------------------------------------------------------ sysfn_getcpuclock: ; 18.5 = GET TSC/SEC mov eax,[CPU_FREQ] mov [esp+32], eax ret - +;------------------------------------------------------------------------------ ; SAVE ramdisk to /hd/1/menuet.img ;!!!!!!!!!!!!!!!!!!!!!!!! include 'blkdev/rdsave.inc' ;!!!!!!!!!!!!!!!!!!!!!!!! +;------------------------------------------------------------------------------ align 4 sysfn_getactive: ; 18.7 = get active window mov eax, [TASK_COUNT] movzx eax, word [WIN_POS + eax*2] mov [esp+32],eax ret - +;------------------------------------------------------------------------------ sysfn_sound_flag: ; 18.8 = get/set sound_flag ; cmp ecx,1 dec ecx @@ -2094,10 +2121,11 @@ sysfn_sound_flag: ; 18.8 = get/set sound_flag xor byte [sound_flag], 1 nosoundflag: ret - +;------------------------------------------------------------------------------ sysfn_minimize: ; 18.10 = minimize window mov [window_minimize],1 ret +;------------------------------------------------------------------------------ align 4 sysfn_getdiskinfo: ; 18.11 = get disk info table ; cmp ecx,1 @@ -2122,18 +2150,18 @@ sysfn_getdiskinfo: ; 18.11 = get disk info table cld rep movsd ret - +;------------------------------------------------------------------------------ sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) and dword [esp+32], 0 ret - +;------------------------------------------------------------------------------ sysfn_getversion: ; 18.13 = get kernel ID and version mov edi,ecx mov esi,version_inf mov ecx,version_end-version_inf rep movsb ret - +;------------------------------------------------------------------------------ sysfn_waitretrace: ; 18.14 = sys wait retrace ;wait retrace functions sys_wait_retrace: @@ -2144,7 +2172,7 @@ sysfn_waitretrace: ; 18.14 = sys wait retrace jz WaitRetrace_loop and [esp+32],dword 0 ret - +;------------------------------------------------------------------------------ align 4 sysfn_centermouse: ; 18.15 = mouse centered ; removed here by @@ -2163,8 +2191,8 @@ sysfn_centermouse: ; 18.15 = mouse centered xor eax,eax and [esp+32],eax ; pop eax - ret +;------------------------------------------------------------------------------ align 4 sysfn_mouse_acceleration: ; 18.19 = set/get mouse features test ecx,ecx ; get mouse speed factor @@ -2211,7 +2239,7 @@ sysfn_mouse_acceleration: ; 18.19 = set/get mouse features mov [mouse_active],1 .end: ret - +;------------------------------------------------------------------------------ sysfn_getfreemem: mov eax, [pg_data.pages_free] shl eax, 2 diff --git a/kernel/branches/Kolibri-acpi/vmodeint.inc b/kernel/branches/Kolibri-acpi/vmodeint.inc deleted file mode 100644 index 80eb1c0430..0000000000 --- a/kernel/branches/Kolibri-acpi/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/Kolibri-acpi/vmodeld.inc b/kernel/branches/Kolibri-acpi/vmodeld.inc deleted file mode 100644 index 3c5e512a23..0000000000 --- a/kernel/branches/Kolibri-acpi/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