File: cache.h

package info (click to toggle)
alevt 1%3A1.6.1-7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 840 kB
  • ctags: 662
  • sloc: sh: 6,411; ansic: 6,256; makefile: 112; perl: 104
file content (40 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef CACHE_H
#define CACHE_H

#include "vt.h"
#include "misc.h"
#include "dllist.h"

#define HASH_SIZE	113

struct cache
{
    struct dl_head hash[HASH_SIZE];
    int erc;			// error reduction circuit on
    int npages;
    u16 hi_subno[0x9ff + 1];	// 0:pg not in cache, 1-3f80:highest subno + 1
    struct cache_ops *op;
};

struct cache_page
{
    struct dl_node node[1];
    struct vt_page page[1];
};

struct cache_ops
{
    void (*close)(struct cache *ca);
    struct vt_page *(*get)(struct cache *ca, int pgno, int subno);
    struct vt_page *(*put)(struct cache *ca, struct vt_page *vtp);
    void (*reset)(struct cache *ca);
    struct vt_page *(*foreach_pg)(struct cache *ca, int pgno, int subno,
					    int dir, int (*func)(), void *data);
    int (*mode)(struct cache *ca, int mode, int arg);
};

struct cache *cache_open(void);

#define CACHE_MODE_ERC	1

#endif