Rev 2465 | Rev 3232 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2465 | Rev 2987 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | fs_read32_sys: |
16 | fs_read32_sys: |
17 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
17 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
18 | ; this request should be processed by hd_read. |
18 | ; this request should be processed by hd_read. |
19 | cmp [ebp+PARTITION.Disk], 'old' |
19 | cmp [ebp+PARTITION.Disk], 'old' |
20 | jnz @f |
20 | jnz @f |
- | 21 | add eax, dword [ebp+PARTITION.FirstSector] |
|
21 | mov [hdd_appl_data], 0 |
22 | mov [hdd_appl_data], 0 |
22 | call hd_read |
23 | call hd_read |
23 | mov [hdd_appl_data], 1 ; restore to default state |
24 | mov [hdd_appl_data], 1 ; restore to default state |
- | 25 | mov eax, [hd_error] |
|
24 | ret |
26 | ret |
25 | @@: |
27 | @@: |
26 | ; In the normal case, save ecx, set ecx to SysCache and let the common part |
28 | ; In the normal case, save ecx, set ecx to SysCache and let the common part |
27 | ; do its work. |
29 | ; do its work. |
28 | push ecx |
30 | push ecx |
Line 39... | Line 41... | ||
39 | fs_read32_app: |
41 | fs_read32_app: |
40 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
42 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
41 | ; this request should be processed by hd_read. |
43 | ; this request should be processed by hd_read. |
42 | cmp [ebp+PARTITION.Disk], 'old' |
44 | cmp [ebp+PARTITION.Disk], 'old' |
43 | jnz @f |
45 | jnz @f |
- | 46 | add eax, dword [ebp+PARTITION.FirstSector] |
|
44 | mov [hdd_appl_data], 1 |
47 | mov [hdd_appl_data], 1 |
45 | jmp hd_read |
48 | call hd_read |
- | 49 | mov eax, [hd_error] |
|
- | 50 | ret |
|
46 | @@: |
51 | @@: |
47 | ; In the normal case, save ecx, set ecx to AppCache and let the common part |
52 | ; In the normal case, save ecx, set ecx to AppCache and let the common part |
48 | ; do its work. |
53 | ; do its work. |
49 | push ecx |
54 | push ecx |
50 | mov ecx, [ebp+PARTITION.Disk] |
55 | mov ecx, [ebp+PARTITION.Disk] |
Line 61... | Line 66... | ||
61 | mov eax, DISK_STATUS_END_OF_MEDIA |
66 | mov eax, DISK_STATUS_END_OF_MEDIA |
62 | pop ecx |
67 | pop ecx |
63 | ret |
68 | ret |
64 | @@: |
69 | @@: |
65 | ; 2. Get the absolute sector on the disk. |
70 | ; 2. Get the absolute sector on the disk. |
66 | push edx |
71 | push edx esi |
67 | xor edx, edx |
72 | xor edx, edx |
68 | add eax, dword [ebp+PARTITION.FirstSector] |
73 | add eax, dword [ebp+PARTITION.FirstSector] |
69 | adc edx, dword [ebp+PARTITION.FirstSector+4] |
74 | adc edx, dword [ebp+PARTITION.FirstSector+4] |
70 | ; 3. If there is no cache for this disk, just pass the request to the driver. |
75 | ; 3. If there is no cache for this disk, just pass the request to the driver. |
71 | cmp [ecx+DISKCACHE.pointer], 0 |
76 | cmp [ecx+DISKCACHE.pointer], 0 |
Line 73... | Line 78... | ||
73 | push 1 |
78 | push 1 |
74 | push esp ; numsectors |
79 | push esp ; numsectors |
75 | push edx ; startsector |
80 | push edx ; startsector |
76 | push eax ; startsector |
81 | push eax ; startsector |
77 | push ebx ; buffer |
82 | push ebx ; buffer |
- | 83 | mov esi, [ebp+PARTITION.Disk] |
|
78 | mov al, DISKFUNC.read |
84 | mov al, DISKFUNC.read |
79 | call disk_call_driver |
85 | call disk_call_driver |
80 | pop ecx |
86 | pop ecx |
81 | pop edx |
87 | pop esi edx |
82 | pop ecx |
88 | pop ecx |
83 | ret |
89 | ret |
84 | .scancache: |
90 | .scancache: |
85 | ; 4. Scan the cache. |
91 | ; 4. Scan the cache. |
86 | push esi edi ecx ; scan cache |
92 | push edi ecx ; scan cache |
87 | push edx eax |
93 | push edx eax |
88 | virtual at esp |
94 | virtual at esp |
89 | .sector_lo dd ? |
95 | .sector_lo dd ? |
90 | .sector_hi dd ? |
96 | .sector_hi dd ? |
91 | .cache dd ? |
97 | .cache dd ? |
Line 181... | Line 187... | ||
181 | fs_write32_sys: |
187 | fs_write32_sys: |
182 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
188 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
183 | ; this request should be processed by hd_write. |
189 | ; this request should be processed by hd_write. |
184 | cmp [ebp+PARTITION.Disk], 'old' |
190 | cmp [ebp+PARTITION.Disk], 'old' |
185 | jnz @f |
191 | jnz @f |
- | 192 | add eax, dword [ebp+PARTITION.FirstSector] |
|
186 | mov [hdd_appl_data], 0 |
193 | mov [hdd_appl_data], 0 |
187 | call hd_write |
194 | call hd_write |
188 | mov [hdd_appl_data], 1 ; restore to default state |
195 | mov [hdd_appl_data], 1 ; restore to default state |
- | 196 | mov eax, [hd_error] |
|
189 | ret |
197 | ret |
190 | @@: |
198 | @@: |
191 | ; In the normal case, save ecx, set ecx to SysCache and let the common part |
199 | ; In the normal case, save ecx, set ecx to SysCache and let the common part |
192 | ; do its work. |
200 | ; do its work. |
193 | push ecx |
201 | push ecx |
Line 204... | Line 212... | ||
204 | fs_write32_app: |
212 | fs_write32_app: |
205 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
213 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
206 | ; this request should be processed by hd_write. |
214 | ; this request should be processed by hd_write. |
207 | cmp [ebp+PARTITION.Disk], 'old' |
215 | cmp [ebp+PARTITION.Disk], 'old' |
208 | jnz @f |
216 | jnz @f |
- | 217 | add eax, dword [ebp+PARTITION.FirstSector] |
|
209 | mov [hdd_appl_data], 1 |
218 | mov [hdd_appl_data], 1 |
210 | jmp hd_write |
219 | call hd_write |
- | 220 | mov eax, [hd_error] |
|
- | 221 | ret |
|
211 | @@: |
222 | @@: |
212 | ; In the normal case, save ecx, set ecx to AppCache and let the common part |
223 | ; In the normal case, save ecx, set ecx to AppCache and let the common part |
213 | ; do its work. |
224 | ; do its work. |
214 | push ecx |
225 | push ecx |
215 | mov ecx, [ebp+PARTITION.Disk] |
226 | mov ecx, [ebp+PARTITION.Disk] |
Line 225... | Line 236... | ||
225 | ja @f |
236 | ja @f |
226 | mov eax, DISK_STATUS_END_OF_MEDIA |
237 | mov eax, DISK_STATUS_END_OF_MEDIA |
227 | pop ecx |
238 | pop ecx |
228 | ret |
239 | ret |
229 | @@: |
240 | @@: |
230 | push edx |
241 | push edx esi |
231 | ; 2. Get the absolute sector on the disk. |
242 | ; 2. Get the absolute sector on the disk. |
232 | xor edx, edx |
243 | xor edx, edx |
233 | add eax, dword [ebp+PARTITION.FirstSector] |
244 | add eax, dword [ebp+PARTITION.FirstSector] |
234 | adc edx, dword [ebp+PARTITION.FirstSector+4] |
245 | adc edx, dword [ebp+PARTITION.FirstSector+4] |
235 | ; 3. If there is no cache for this disk, just pass request to the driver. |
246 | ; 3. If there is no cache for this disk, just pass request to the driver. |
Line 238... | Line 249... | ||
238 | push 1 |
249 | push 1 |
239 | push esp ; numsectors |
250 | push esp ; numsectors |
240 | push edx ; startsector |
251 | push edx ; startsector |
241 | push eax ; startsector |
252 | push eax ; startsector |
242 | push ebx ; buffer |
253 | push ebx ; buffer |
- | 254 | mov esi, [ebp+PARTITION.Disk] |
|
243 | mov al, DISKFUNC.write |
255 | mov al, DISKFUNC.write |
244 | call disk_call_driver |
256 | call disk_call_driver |
245 | pop ecx |
257 | pop ecx |
246 | pop edx |
258 | pop esi edx |
247 | pop ecx |
259 | pop ecx |
248 | ret |
260 | ret |
249 | .scancache: |
261 | .scancache: |
250 | ; 4. Scan the cache. |
262 | ; 4. Scan the cache. |
251 | push esi edi ecx ; scan cache |
263 | push edi ecx ; scan cache |
252 | push edx eax |
264 | push edx eax |
253 | virtual at esp |
265 | virtual at esp |
254 | .sector_lo dd ? |
266 | .sector_lo dd ? |
255 | .sector_hi dd ? |
267 | .sector_hi dd ? |
256 | .cache dd ? |
268 | .cache dd ? |
Line 346... | Line 358... | ||
346 | add eax, [esi+DISKCACHE.pointer] |
358 | add eax, [esi+DISKCACHE.pointer] |
347 | cmp dword [eax+8], 2 |
359 | cmp dword [eax+8], 2 |
348 | jb .found_slot ; it's empty or read |
360 | jb .found_slot ; it's empty or read |
349 | dec ecx |
361 | dec ecx |
350 | jnz .search_for_empty |
362 | jnz .search_for_empty |
351 | call write_cache64 ; no empty slots found, write all |
363 | stdcall write_cache64, [ebp+PARTITION.Disk] ; no empty slots found, write all |
352 | test eax, eax |
364 | test eax, eax |
353 | jne .found_slot_access_denied |
365 | jne .found_slot_access_denied |
354 | jmp .search_again ; and start again |
366 | jmp .search_again ; and start again |
355 | .found_slot: |
367 | .found_slot: |
356 | mov [esi+DISKCACHE.search_start], edi |
368 | mov [esi+DISKCACHE.search_start], edi |
357 | xor eax, eax ; success |
369 | xor eax, eax ; success |
358 | .found_slot_access_denied: |
370 | .found_slot_access_denied: |
359 | ret |
371 | ret |
Line 360... | Line 372... | ||
360 | 372 | ||
361 | ; This function is intended to replace the old 'write_cache' function. |
373 | ; This function is intended to replace the old 'write_cache' function. |
362 | proc write_cache64 uses ecx edx esi edi |
374 | proc write_cache64 uses ecx edx esi edi, disk:dword |
363 | locals |
375 | locals |
364 | cache_chain_started dd ? |
376 | cache_chain_started dd ? |
365 | cache_chain_size dd ? |
377 | cache_chain_size dd ? |
366 | cache_chain_pos dd ? |
378 | cache_chain_pos dd ? |
Line 430... | Line 442... | ||
430 | jnz .write_cache_more |
442 | jnz .write_cache_more |
431 | call .flush_cache_chain |
443 | call .flush_cache_chain |
432 | test eax, eax |
444 | test eax, eax |
433 | jnz .nothing |
445 | jnz .nothing |
434 | .flush: |
446 | .flush: |
435 | mov esi, [ebp] |
447 | mov esi, [disk] |
436 | mov esi, [esi+PARTITION.Disk] |
- | |
437 | mov al, DISKFUNC.flush |
448 | mov al, DISKFUNC.flush |
438 | call disk_call_driver |
449 | call disk_call_driver |
439 | .nothing: |
450 | .nothing: |
440 | ret |
451 | ret |
Line 588... | Line 599... | ||
588 | test eax, eax |
599 | test eax, eax |
589 | jz .nothing |
600 | jz .nothing |
590 | stdcall kernel_free, eax |
601 | stdcall kernel_free, eax |
591 | .nothing: |
602 | .nothing: |
592 | ret |
603 | ret |
- | 604 | ||
- | 605 | ; This function flushes all modified data from both caches for the given DISK. |
|
- | 606 | ; esi = pointer to DISK |
|
- | 607 | disk_sync: |
|
- | 608 | ; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure, |
|
- | 609 | ; this request should be processed by write_cache. |
|
- | 610 | cmp esi, 'old' |
|
- | 611 | jnz @f |
|
- | 612 | mov [hdd_appl_data], 0 |
|
- | 613 | call write_cache |
|
- | 614 | mov [hdd_appl_data], 1 |
|
- | 615 | jmp write_cache |
|
- | 616 | @@: |
|
- | 617 | ; The algorithm is straightforward. |
|
- | 618 | push esi |
|
- | 619 | push esi ; for second write_cache64 |
|
- | 620 | push esi ; for first write_cache64 |
|
- | 621 | add esi, DISK.SysCache |
|
- | 622 | call write_cache64 |
|
- | 623 | add esi, DISK.AppCache - DISK.SysCache |
|
- | 624 | call write_cache64 |
|
- | 625 | pop esi |
|
- | 626 | ret |