cache.h 873 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef CACHE_H
  2. #define CACHE_H
  3. #include "vt.h"
  4. #include "misc.h"
  5. #include "dllist.h"
  6. #define HASH_SIZE 113
  7. struct cache
  8. {
  9. struct dl_head hash[HASH_SIZE];
  10. int erc; // error reduction circuit on
  11. int npages;
  12. u16 hi_subno[0x9ff + 1]; // 0:pg not in cache, 1-3f80:highest subno + 1
  13. struct cache_ops *op;
  14. };
  15. struct cache_page
  16. {
  17. struct dl_node node[1];
  18. struct vt_page page[1];
  19. };
  20. struct cache_ops
  21. {
  22. void (*close)(struct cache *ca);
  23. struct vt_page *(*get)(struct cache *ca, int pgno, int subno);
  24. struct vt_page *(*put)(struct cache *ca, struct vt_page *vtp);
  25. void (*reset)(struct cache *ca);
  26. struct vt_page *(*foreach_pg)(struct cache *ca, int pgno, int subno, int dir,
  27. int (*func)(), void *data);
  28. int (*mode)(struct cache *ca, int mode, int arg);
  29. };
  30. struct cache *cache_open(void);
  31. #define CACHE_MODE_ERC 1
  32. #endif