Rev 3913 | Rev 4437 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3913 | Rev 4273 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2011-2012. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 3913 $ |
8 | $Revision: 4273 $ |
9 | 9 | ||
10 | ; ============================================================================= |
10 | ; ============================================================================= |
11 | ; ================================= Constants ================================= |
11 | ; ================================= Constants ================================= |
Line 1211... | Line 1211... | ||
1211 | ; Currently this is just placeholder, since no file systems are supported. |
1211 | ; Currently this is just placeholder, since no file systems are supported. |
1212 | ; edi = esp -> {dd fs_dyndisk, dd dyndisk_cleanup, dd pointer to DISK, dd media object} |
1212 | ; edi = esp -> {dd fs_dyndisk, dd dyndisk_cleanup, dd pointer to DISK, dd media object} |
1213 | ; ecx = partition number, esi+ebp = ASCIIZ name |
1213 | ; ecx = partition number, esi+ebp = ASCIIZ name |
1214 | fs_dyndisk: |
1214 | fs_dyndisk: |
1215 | dec ecx ; convert to zero-based partition index |
1215 | dec ecx ; convert to zero-based partition index |
1216 | pop edx edx edx eax ; edx = pointer to DISK, eax = NULL or edx |
1216 | pop edx edx edx ; edx = pointer to DISK, dword [esp] = NULL or edx |
- | 1217 | ; If the driver does not support insert notifications and we are the only fs |
|
- | 1218 | ; operation with this disk, ask the driver whether the media |
|
- | 1219 | ; was inserted/removed/changed. Otherwise, assume that media status is valid. |
|
- | 1220 | test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION |
|
- | 1221 | jz .media_accurate |
|
- | 1222 | push ecx esi |
|
- | 1223 | mov esi, edx |
|
- | 1224 | cmp dword [esp+8], 0 |
|
- | 1225 | jz .test_no_media |
|
- | 1226 | cmp [esi+DISK.MediaRefCount], 2 |
|
- | 1227 | jnz .media_accurate_pop |
|
- | 1228 | lea edx, [esi+DISK.MediaInfo] |
|
- | 1229 | and [edx+DISKMEDIAINFO.Flags], 0 |
|
- | 1230 | mov al, DISKFUNC.querymedia |
|
- | 1231 | stdcall disk_call_driver, edx |
|
- | 1232 | test eax, eax |
|
- | 1233 | jz .media_accurate_pop |
|
- | 1234 | stdcall disk_media_dereference ; drop our reference so that disk_media_changed could close the media |
|
- | 1235 | stdcall disk_media_changed, esi, 0 |
|
- | 1236 | and dword [esp+8], 0 ; no media |
|
- | 1237 | .test_no_media: |
|
- | 1238 | stdcall disk_media_changed, esi, 1 ; issue fake notification |
|
- | 1239 | ; if querymedia() inside disk_media_changed returns error, the notification is ignored |
|
- | 1240 | cmp [esi+DISK.MediaInserted], 0 |
|
- | 1241 | jz .media_accurate_pop |
|
- | 1242 | lock inc [esi+DISK.MediaRefCount] |
|
- | 1243 | mov dword [esp+8], esi |
|
- | 1244 | .media_accurate_pop: |
|
- | 1245 | mov edx, esi |
|
- | 1246 | pop esi ecx |
|
- | 1247 | .media_accurate: |
|
- | 1248 | pop eax |
|
1217 | test eax, eax |
1249 | test eax, eax |
1218 | jz .nomedia |
1250 | jz .nomedia |
1219 | .main: |
1251 | .main: |
1220 | cmp ecx, [edx+DISK.NumPartitions] |
1252 | cmp ecx, [edx+DISK.NumPartitions] |
1221 | jae .notfound |
1253 | jae .notfound |
Line 1250... | Line 1282... | ||
1250 | mov dword [esp+32], ERROR_UNSUPPORTED_FS |
1282 | mov dword [esp+32], ERROR_UNSUPPORTED_FS |
1251 | jmp .cleanup |
1283 | jmp .cleanup |
1252 | .nomedia: |
1284 | .nomedia: |
1253 | test ecx, ecx |
1285 | test ecx, ecx |
1254 | jnz .notfound |
1286 | jnz .notfound |
1255 | test byte [edx+DISK.DriverFlags], DISK_NO_INSERT_NOTIFICATION |
- | |
1256 | jz .deverror |
- | |
1257 | ; if the driver does not support insert notifications and we are the only fs |
- | |
1258 | ; operation with this disk, issue the fake insert notification; if media is |
- | |
1259 | ; still not inserted, 'disk_media_changed' will detect this and do nothing |
- | |
1260 | lea ecx, [edx+DISK.MediaLock] |
- | |
1261 | call mutex_lock |
- | |
1262 | cmp [edx+DISK.MediaRefCount], 1 |
- | |
1263 | jnz .noluck |
- | |
1264 | call mutex_unlock |
- | |
1265 | push edx |
- | |
1266 | stdcall disk_media_changed, edx, 1 |
- | |
1267 | pop edx |
- | |
1268 | lea ecx, [edx+DISK.MediaLock] |
- | |
1269 | call mutex_lock |
- | |
1270 | cmp [edx+DISK.MediaInserted], 0 |
- | |
1271 | jz .noluck |
- | |
1272 | lock inc [edx+DISK.MediaRefCount] |
- | |
1273 | call mutex_unlock |
- | |
1274 | xor ecx, ecx |
- | |
1275 | jmp .main |
- | |
1276 | .noluck: |
- | |
1277 | call mutex_unlock |
- | |
1278 | .deverror: |
- | |
1279 | mov dword [esp+32], ERROR_DEVICE |
1287 | mov dword [esp+32], ERROR_DEVICE |
1280 | mov esi, edx |
1288 | mov esi, edx |
1281 | call disk_dereference |
1289 | call disk_dereference |
1282 | ret |
1290 | ret |