grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / filesys / fat / cache.h
blob6b5806f750f22d9546e8d48d08b56b201a47cfd3
1 /*
2 Copyright © 2010-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Disk cache.
6 */
8 #ifndef CACHE_H
9 #define CACHE_H
11 #include <exec/types.h>
12 #include <exec/lists.h>
14 struct BlockRange
16 struct MinNode node1; /* links into hash table */
17 struct MinNode node2; /* links into free and dirty lists */
18 ULONG use_count; /* number of users of this block */
19 UWORD state;
20 ULONG num; /* start block number */
21 UBYTE *data; /* actual block data */
24 struct Cache
26 struct ExecBase *sys_base;
27 struct DosLibrary *dos_base;
28 APTR priv; /* private data sent to AccessDisk() */
29 ULONG block_count; /* number of blocks allocated */
30 ULONG block_size; /* size of a disk block */
31 ULONG hash_size; /* size of hash table */
32 struct BlockRange **blocks; /* array of pointers to all blocks */
33 struct MinList *hash_table; /* hash table of all valid cache blocks */
34 struct MinList dirty_list; /* the dirty list */
35 struct MinList free_list; /* the free list */
38 /* Block states */
40 #define BS_EMPTY 0
41 #define BS_VALID 1
42 #define BS_DIRTY 2
44 /* Prototypes */
46 APTR Cache_CreateCache(APTR priv, ULONG hash_size, ULONG block_count,
47 ULONG block_size, struct ExecBase *sys_base, struct DosLibrary *dos_base);
48 VOID Cache_DestroyCache(APTR cache);
49 APTR Cache_GetBlock(APTR cache, ULONG blockNum, UBYTE **data);
50 VOID Cache_FreeBlock(APTR cache, APTR block);
51 VOID Cache_MarkBlockDirty(APTR cache, APTR block);
52 BOOL Cache_Flush(APTR cache);
54 LONG AccessDisk(BOOL do_write, ULONG num, ULONG nblocks, ULONG block_size,
55 UBYTE *data, APTR priv);
57 #endif