00001 #ifndef CACHE_H
00002 #define CACHE_H
00003
00004 #include "vt.h"
00005 #include "misc.h"
00006 #include "dllist.h"
00007
00008 #define HASH_SIZE 113
00009
00010 struct cache
00011 {
00012 struct dl_head hash[HASH_SIZE];
00013 int erc;
00014 int npages;
00015 u16 hi_subno[0x9ff + 1];
00016 struct cache_ops *op;
00017 };
00018
00019 struct cache_page
00020 {
00021 struct dl_node node[1];
00022 struct vt_page page[1];
00023 };
00024
00025 struct cache_ops
00026 {
00027 void (*close)(struct cache *ca);
00028 struct vt_page *(*get)(struct cache *ca, int pgno, int subno);
00029 struct vt_page *(*put)(struct cache *ca, struct vt_page *vtp);
00030 void (*reset)(struct cache *ca);
00031 struct vt_page *(*foreach_pg)(struct cache *ca, int pgno, int subno,
00032 int dir, int (*func)(), void *data);
00033 int (*mode)(struct cache *ca, int mode, int arg);
00034 };
00035
00036 struct cache *cache_open(void);
00037
00038 #define CACHE_MODE_ERC 1
00039
00040 #endif