LizardCache.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) July 15, 1985 10:30:18 pm PDT
DIRECTORY
DragOpsCross USING [TrapIndex, Word],
SparseMemory USING [Base];
LizardCache: CEDAR DEFINITIONS = BEGIN
TrapIndex: TYPE = DragOpsCross.TrapIndex;
Word: TYPE = DragOpsCross.Word;
CacheBase: TYPE = REF CacheBaseRep;
CacheBaseRep: TYPE = RECORD [
sharedBase: SharedBase ← NIL, -- shared base data
private: REFNIL, -- private data to the cache implementation
fetch: CacheFetchProc ← NIL, -- this hook allows the user to intercept cache accesses
store: CacheStoreProc ← NIL, -- this hook allows the user to intercept cache accesses
data: REFNIL, -- private data for clients intercepting fetch & store
stats: CacheStats ← [] -- maintained by the default fetch and store routines
];
SharedBase: TYPE = REF SharedBaseRep;
SharedBaseRep: TYPE = RECORD [
mem: SparseMemory.Base ← NIL,
busyUntil: INT ← 0
];
CacheFetchProc: TYPE = PROC [base: CacheBase, addr: Word, cycle: INT, noEffect: BOOLFALSE] RETURNS [data: Word, status: TrapIndex, rejectCycles: INT];
This is the type of routine that is used to fetch words from the cache. If noEffect, then no change will be made to the cache state or statistics (useful for dumping memory).
CacheStoreProc: TYPE = PROC [base: CacheBase, addr: Word, data: Word, cycle: INT] RETURNS [old: Word, status: TrapIndex, rejectCycles: INT];
This is the type of routine that is used to store words into the cache. The old word is returned to facilitate memory tracing.
CacheStats: TYPE = RECORD [
probes: INT ← 0,
misses: INT ← 0,
mapMisses: INT ← 0,
dirtyWrites: INT ← 0,
rejectCycles: INT ← 0
];
NewBase: PROC [mem: SparseMemory.Base] RETURNS [SharedBase];
Creates a new cache on the specified sparse memory.
NewCache: PROC [shared: SharedBase, lines: [0..4096) ← 0] RETURNS [CacheBase];
Creates a new cache on the specified shared memory. If lines = 0, then the default # of lines is used.
ResetCache: PROC [cache: CacheBase];
Resets the given cache to its initial state.
FlushCache: PROC [cache: CacheBase];
Makes sure that the memory behind the cache is up to date. This operation does not affect the statistics. It should not be used for instruction emulation.
Fetch: PROC [base: CacheBase, addr: Word, cycle: INT, noEffect: BOOLFALSE] RETURNS [data: Word, status: TrapIndex, rejectCycles: INT] = INLINE {
[data, status, rejectCycles] ← base.fetch[base, addr, cycle, noEffect]
};
Store: PROC [base: CacheBase, addr: Word, data: Word, cycle: INT] RETURNS [old: Word, status: TrapIndex, rejectCycles: INT] = INLINE {
[old, status, rejectCycles] ← base.store[base, addr, data, cycle]
};
END.