home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUIN
/
SFECACHE.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
7KB
|
236 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 280 of 360
From : Max Maischein 2:249/6.17 29 May 93 21:24
To : Steven Tallent 1:3811/210.0
Subj : Hard/Cold Reboot //// Flushing the write behind cache
────────────────────────────────────────────────────────────────────────────────
> Would PASCAL source to reproduce this program be off-topic, do you
> think,
Since this theme gets overhand, I repost my unit which flushes Smartdrive if
included in your program.
The code is based on other code courtesy of Norbert Igl, and sorry for the
german remarks :-)
-max}
Unit SfeCache;
{
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓∙── ──∙▓▓▓▓
▓▓▓│ │░░▓▓
▓▓▓ Max Maischein 2:249/6.17 ░░▓▓
▓▓▓ ░░▓▓
▓▓▓ Diese Unit implementiert einen 'tomatischen Flush Aufruf an ░░▓▓
▓▓▓ eventuell residente Caches wie zum Bleistift SmartDrive oder ░░▓▓
▓▓▓ Norton Cache. Sie ( dir Unit ) basiert auf Code von Norbert Igl, ░░▓▓
▓▓▓ ich habe die nötigen aufrufe zum Cache flushing eingebaut.Das ░░▓▓
▓▓▓ Ganze Zeugs ist ungetestet, sollte aber funktionieren, da es ░░▓▓
▓▓▓ nicht viel gibt, was schiefgehen kann. Wenn ihr euch aber auf ░░▓▓
▓▓▓ WriteCaches beim Programmieren voll verlasst, dann Gnade euch ░░▓▓
▓▓▓ Gott ! ░░▓▓
▓▓▓ Al says : "Save early, save often !" ░░▓▓
▓▓▓ ░░▓▓
▓▓▓ Die Function FlushCache wird von der Unit auch exportiert, und ░░▓▓
▓▓▓ kann auch vom Programm aus aufgerufen werden. Sie ist als Pointer ░░▓▓
▓▓▓ auf eine Procedure implementiert, und dieser zeigt auf die ░░▓▓
▓▓▓ aktuelle ( anwendbare ) Flush Procedure für das vorliegende ░░▓▓
▓▓▓ Cache. ░░▓▓
▓▓▓ ░░▓▓
▓▓▓ This piece of code is donated to the public domain, but I request ░░▓▓
▓▓▓ that, if you use this code, you mention me in the DOCs somewhere. ░░▓▓
▓▓▓ ░░▓▓
▓▓▓ -max ░░▓▓
▓▓▓│ │░░▓▓
▓▓▓∙── ──∙░░▓▓
▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
}
Interface
Implementation
Uses DOS
;
Const AktCache : Byte = 0;
Type FlushProc = Procedure;
Var FlushCache : FlushProc;
Function SmartDrv_exe : Boolean;
Var Found : Boolean;
Begin
Found := False;
Asm
push bp
stc
mov ax, 4A10h
xor bx, bx
int 2Fh
pop bp
jc @NoSmartDrive
cmp ax, 0BABEh
jne @NoSmartDrive
mov Found, True
@NoSmartDrive:
End;
SmartDrv_exe := Found;
End;
Function CompaqPro : Boolean;
Var OK : Boolean;
Begin
CompaqPro := False;
OK := False;
Asm
mov ax, 0F400h
int 16h
cmp ah, 0E2h
jne @NoCache
or al, al
je @NoCache
cmp al, 2
ja @NoCache
mov OK, 1
@NoCache:
End;
CompaqPro := OK;
End;
Function PC6 : Boolean; { PCTools v6, v5 }
Var OK : Boolean;
Begin
PC6 := False;
OK := False;
Asm
mov ax, 0FFA5h
mov cx, 01111h
int 16h
or ch, ch
jne @NoCache
mov OK, 1
@NoCache:
End;
PC6 := OK;
End;
Function PC5 : Boolean;
Var OK : Boolean;
Begin
PC5 := False;
OK := False;
Asm
mov ax, 02BFFh
mov cx, 'CX';
int 21h
or al, al
jne @NoCache
mov ok, 1
@NoCache:
End;
PC5 := OK;
End;
Function HyperDsk : Boolean; { 4.20+ ... }
Var OK : Boolean;
Begin
Hyperdsk := False;
OK := False;
Asm
mov ax, 0DF00h
mov bx, 'DH'
int 02Fh
cmp al, 0FFh
jne @NoCache
cmp cx, 05948h
jne @NoCache
mov OK, 1
@NoCache:
End;
HyperDSK := OK;
End;
Function QCache : Boolean;
Var OK : Boolean;
Begin
QCache := False;
OK := False;
Asm
mov ah, 027h
xor bx, bx
int 013h
or bx, bx
je @NoCache
mov OK, 1
@NoCache:
End;
QCache := OK;
End;
Procedure FlushSD_sys; Far;
Var F : File;
B : Byte;
Begin
Assign( F, 'SMARTAAR' );
Reset( F );
B := 0;
Asm
push ds
mov ax, 04403h
mov bx, FileRec( F ).Handle
mov cx, 1
int 21h
pop ds
End;
End;
Procedure FlushSD_exe; Far;
Begin
Asm
mov ax, 04A10h
mov bx, 1
int 2Fh
End;
End;
Procedure FlushPC6; Far;
Begin
Asm
mov ax, 0F5A5h
mov cx, -1
int 16h
End;
End;
Procedure FlushPC5; Far;
Begin
Asm
mov ah, 0A1h
mov si, 04358h
int 13h
End;
End;
Procedure FlushNoCache; Far;
Begin
End;
Begin
Writeln( '■ DISK-CACHE-FUSH v1.00 Norbert Igl & Max Maischein ''3/93');
If SmartDrv_exe
then FlushCache := FlushSD_exe
else
If PC6
then FlushCache := FlushPC6
else
If PC5
then FlushCache := FlushPC5
else FlushCache := FlushNoCache;
FlushCache;
End.