RayeR
CZ, 25.10.2011, 12:53 |
An universal way how to flush disk cache? (Developers) |
Hi,
I updated my simple pwrdown utility to support latest intel chipset series 5x and 6x. I'd like also improve it to flush disk cache. Is there some universal way how to do it? Some DOS call? Or do I need exec(cachexxx /flush) for different cache types? --- DOS gives me freedom to unlimited HW access. |
Arjay
25.10.2011, 18:33
@ RayeR
|
An universal way how to flush disk cache? |
> Is there some universal way how to do it?
I started to look into this years ago for a reboot utility, from distant memory I don't believe that there is any straight forward standard.
> Some DOS call?
> Or do I need exec(cachexxx /flush) for different cache types?
See the cache category of Ralph Brown's interrupt list. e.g. for smartdrv (pc-cache) Int 2F/AX=4A10h/BX=0001h |
rr
Berlin, Germany, 25.10.2011, 20:27
@ RayeR
|
An universal way how to flush disk cache? |
Here's Jack Ellis' code for CC.COM (part of his UIDE driver package):
page 59,132
title CC -- Clear Cache.
.386p ;Allow use of 80386 commands.
s equ <short> ;Make conditional jumps "short".
HDISKS equ 00475h ;BIOS hard-disk count address.
;
; Segment Declarations.
;
CODE segment public use16 'CODE'
assume cs:CODE,ds:CODE
org 00100h
;
; Main Program Routine.
;
Start: mov ax,cs ;Set our DS-register.
mov ds,ax
xor ax,ax ;Point ES-reg. to low-memory.
mov es,ax
mov al,es:HDISKS ;Get number of BIOS hard-disks.
or al,al ;Any hard-disks on this system?
jz s Exit ;No, just exit.
mov DiskCt,al ;Set our hard-disk count below.
Next: mov ah,0 ;Do BIOS "reset" for next disk.
mov dl,UnitNo
int 013h
mov ax,cs ;Reset our DS-register.
mov ds,ax
inc UnitNo ;Increment disk unit number.
dec DiskCt ;More disks to go?
jnz s Next ;Yes, go reset next one.
Exit: mov ax,04C00h ;Done -- Exit back to DOS.
int 021h
;
; Program Variables.
;
DiskCt db 0 ;Number of BIOS hard-disks.
UnitNo db 080h ;Current BIOS unit number.
CODE ends
end Start
Source: Jack R. Ellis Drivers --- Forum admin |
RayeR
CZ, 26.10.2011, 04:30
@ rr
|
An universal way how to flush disk cache? |
> Here's Jack Ellis' code for CC.COM (part of his UIDE driver package):
But this code seems to do HDD reset that may flush internal hardware HDD cache (it maybe pretty large on new drives: 32-64MB!) but not software cache like smartdrv, etc.
>Arjay
Hm, seems to be complicated - need to probe or blindly try to flush all posslible cache programs released in entire Universe...
Eric Auer pointed me on his flush.asm which flushes 7 known caches.
I'll see but maybe I rather leave it on user to flush cache because he know the best which cache program he use... --- DOS gives me freedom to unlimited HW access. |
bretjohn
Rio Rancho, NM, 27.10.2011, 02:19
@ RayeR
|
An universal way how to flush disk cache? |
> But this code seems to do HDD reset that may flush internal hardware HDD
> cache (it maybe pretty large on new drives: 32-64MB!) but not software
> cache like smartdrv, etc.
All INT 13h based caching programs should monitor INT 13.00 and flush the software caches as well. The problem is that not all caches are INT 13h based (including SMARTDRV). There are some disadvantages to using an INT 13h based cache, including the fact that not all disks use INT 13h (such as SCSI/ASPI and many USB implementations). Even Jack's routine is not "universal" for flushing INT 13h caches, since it assumes that the hard drive numbers ("UnitNo" in Jack's code) are sequential, which isn't necessarily true.
> Hm, seems to be complicated - need to probe or blindly try to flush all
> posslible cache programs released in entire Universe...
Indeed it is, and that seems to be the only possibility. However, several INT 21h based caches are compatible with SMARTDRV when it comes to flushing. |
rr
Berlin, Germany, 28.10.2011, 21:39
@ rr
|
An universal way how to flush disk cache? |
I received a comment by Jack:
My CC.COM program is "specific" to flushing the cache
within UIDE. UIDE "traps" only reads and writes for
a disk or diskette. Other requests, e.g. format and
write-verify, are "passed" to the BIOS. Before UIDE
"passes" a request, it must flush its cache, since it
does not have logic to determine if the request might
change the data for a disk/diskette. So, CC need do
only a "BIOS reset", that UIDE will pass to the BIOS,
to make UIDE flush its cache. I do NOT know if such
a reset will flush other caches. I rather doubt it! --- Forum admin |
Mpxplay
12.11.2011, 01:24
@ RayeR
|
An universal way how to flush disk cache? |
> Hi,
> I updated my simple
> pwrdown utility to
> support latest intel chipset series 5x and 6x. I'd like also improve it to
> flush disk cache. Is there some universal way how to do it? Some DOS call?
> Or do I need exec(cachexxx /flush) for different cache types?
You can try (from Mpxplay):
AX=0d00h
INT21
It worked with MS-DOS 7 + Norton Cache at me (I don't remember to a smartdrv test) |