Krn: Added a new driver for the iso9660 file system

Added a new driver for the iso9660 file system. The driver supports the current version of the disk subsystem and is intended for further translation of IDE ATAPI devices to this driver. The basic version of ISO9660 and the Joliet extension are supported.

git-svn-id: svn://kolibrios.org@10053 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Doczom 2024-05-26 15:22:48 +00:00
parent 55296eb7c8
commit 07d896f571
2 changed files with 1118 additions and 0 deletions

View File

@ -83,6 +83,14 @@ struct DISKFUNC
; Optional, may be NULL. ; Optional, may be NULL.
; unsigned int adjust_cache_size(void* userdata, unsigned int suggested_size); ; unsigned int adjust_cache_size(void* userdata, unsigned int suggested_size);
; Return value: 0 = disable cache, otherwise = used cache size in bytes. ; Return value: 0 = disable cache, otherwise = used cache size in bytes.
LoadTray dd ?
; This pointer to the function which load and unload tray drive.
; Optional, may be NULL
; int LoadTray(void* userdata, int flags);
; flags:
; 0 - load
; 1 - unload
; Return value: one of DISK_STATUS_*
ends ends
; This structure holds information on a medium. ; This structure holds information on a medium.
@ -95,6 +103,8 @@ struct DISKMEDIAINFO
; Size of the sector. ; Size of the sector.
Capacity dq ? Capacity dq ?
; Size of the media in sectors. ; Size of the media in sectors.
LastSessionSector dd ?
; Number last session sectors for CDFS
ends ends
; This structure represents the disk cache. To follow the old implementation, ; This structure represents the disk cache. To follow the old implementation,
@ -599,6 +609,7 @@ disk_media_changed:
; 3a. Call the 'querymedia' callback. ; 3a. Call the 'querymedia' callback.
; .Flags are set to zero for possible future extensions. ; .Flags are set to zero for possible future extensions.
lea edx, [esi+DISK.MediaInfo] lea edx, [esi+DISK.MediaInfo]
and [edx+DISKMEDIAINFO.LastSessionSector], 0
and [edx+DISKMEDIAINFO.Flags], 0 and [edx+DISKMEDIAINFO.Flags], 0
mov al, DISKFUNC.querymedia mov al, DISKFUNC.querymedia
stdcall disk_call_driver, edx stdcall disk_call_driver, edx
@ -1282,6 +1293,9 @@ end virtual
call xfs_create_partition call xfs_create_partition
test eax, eax test eax, eax
jnz .success jnz .success
call iso9660_create_partition
test eax, eax
jnz .success
; 3. No file system has recognized the volume, so just allocate the PARTITION ; 3. No file system has recognized the volume, so just allocate the PARTITION
; structure without extra fields. ; structure without extra fields.
movi eax, sizeof.PARTITION movi eax, sizeof.PARTITION
@ -1490,6 +1504,7 @@ dyndisk_handler:
@@: @@:
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
; partition info
cmp byte [ebx], 1 cmp byte [ebx], 1
jz @f jz @f
cmp byte [ebx], 5 cmp byte [ebx], 5
@ -1502,21 +1517,25 @@ dyndisk_handler:
; was inserted/removed/changed. Otherwise, assume that media status is valid. ; was inserted/removed/changed. Otherwise, assume that media status is valid.
test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION
jz .media_accurate jz .media_accurate
push ecx esi push ecx esi
mov esi, edx mov esi, edx
cmp dword [esp+8], 0 cmp dword [esp+8], 0
jz .test_no_media jz .test_no_media
cmp [esi+DISK.MediaRefCount], 2 cmp [esi+DISK.MediaRefCount], 2
jnz .media_accurate_pop jnz .media_accurate_pop
lea edx, [esi+DISK.MediaInfo] lea edx, [esi+DISK.MediaInfo]
and [edx+DISKMEDIAINFO.Flags], 0 and [edx+DISKMEDIAINFO.Flags], 0
mov al, DISKFUNC.querymedia mov al, DISKFUNC.querymedia
stdcall disk_call_driver, edx stdcall disk_call_driver, edx
test eax, eax test eax, eax
jz .media_accurate_pop jz .media_accurate_pop
stdcall disk_media_dereference ; drop our reference so that disk_media_changed could close the media stdcall disk_media_dereference ; drop our reference so that disk_media_changed could close the media
stdcall disk_media_changed, esi, 0 stdcall disk_media_changed, esi, 0
and dword [esp+8], 0 ; no media and dword [esp+8], 0 ; no media
;jmp .media_accurate_pop
.test_no_media: .test_no_media:
stdcall disk_media_changed, esi, 1 ; issue fake notification stdcall disk_media_changed, esi, 1 ; issue fake notification
; if querymedia() inside disk_media_changed returns error, the notification is ignored ; if querymedia() inside disk_media_changed returns error, the notification is ignored
@ -1524,9 +1543,11 @@ dyndisk_handler:
jz .media_accurate_pop jz .media_accurate_pop
lock inc [esi+DISK.MediaRefCount] lock inc [esi+DISK.MediaRefCount]
mov dword [esp+8], esi mov dword [esp+8], esi
.media_accurate_pop: .media_accurate_pop:
mov edx, esi mov edx, esi
pop esi ecx pop esi ecx
.media_accurate: .media_accurate:
pop eax pop eax
test eax, eax test eax, eax
@ -1688,3 +1709,59 @@ dyndisk_enum_root:
xor eax, eax xor eax, eax
pop edx ; restore register used in file_system_lfn pop edx ; restore register used in file_system_lfn
ret ret
; void fastcall eject_disk_media(const char* str, uint32_t code);
; for load/eject drive
; ecx -> asciiz string disk name (sd0, usbhd0)
; edx = code command(0 - LoadTray 1-EjectTray)
eject_disk_media:
push esi edx ecx
mov ecx, disk_list_mutex
call mutex_lock
; find disk ejected
mov edx, disk_list
.next:
mov edx, [edx]
cmp edx, disk_list
jz .nf
mov ecx, [edx + DISK.Name]
mov esi, [esp]
@@:
lodsb
test al, al
jz @f
or al, 0x20
cmp al, [ecx]
jnz .next
inc ecx
jmp @b
@@:
cmp byte[ecx], al
jnz .next
mov ecx, disk_list_mutex
call mutex_unlock
; found disk
pop ecx edx esi
and edx, 1b
mov al, DISKFUNC.LoadTray
stdcall disk_call_driver, edx ; ecx - code command
ret
.nf:
mov ecx, disk_list_mutex
call mutex_unlock
pop ecx edx esi
ret
; for disk emulation PARTITION structure
; int32_t find_part(char* esi) esi -> name disk and partition
; return number partition or zero for disk and
;find_part:
; mov ecx, disk_list_mutex
;
; ret

File diff suppressed because it is too large Load Diff