grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / filesys / cdfs / bcache.h
blob9d19459ca9a86a7c090db34aa884c2545b59dbc1
1 /*
2 * Copyright (C) 2013, The AROS Development Team
3 * All right reserved.
4 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
6 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
7 */
9 /* 'BCache' is a trivial write-through cache for block devices.
12 #ifndef BCACHE_H
13 #define BCACHE_H
15 #include <exec/io.h>
16 #include <dos/filehandler.h>
18 /* DO NOT ALLOCATE NOR FREE THIS STRUCTURE MANUALLY!
20 * Feel free to add to other lists - bc_Node is for your use!
22 struct BCache {
23 struct Node bc_Node;
24 /* The following are for quick reference only - DO NOT MODIFY! */
25 ULONG bc_BlockSize; /* In bytes */
26 ULONG bc_Blocks; /* # of blocks in the FSSM range */
27 /* The rest is internally used by BCache */
30 /* Create a buffer cache, based off of a FileSysStartupMsg.
31 * Note that:
32 * bc_BlockSize will be fsm_Environ[DE_BLOCKSIZE]*4
33 * (default - 512)
34 * bc_Blocks is the number of blocks from DE_LOWCYL to DE_HIGHCYL
35 * (default - total # of blocks on the disk)
37 LONG BCache_Create(struct ExecBase *sysBase, struct FileSysStartupMsg *fssm, struct BCache **bcache);
39 /* Dispose of the cache, and close the underlying device
41 * NOTE: This does *not* call Remove() on bc_Node - do that
42 * before calling this routine!
44 VOID BCache_Delete(struct BCache *bcache);
46 /* Extend the cache by 'numbuffers' blocks
48 LONG BCache_Extend(struct BCache *bcache, LONG numbuffers);
50 /* Drop all cache
51 * returns:
52 * RETURN_OK - Cache flushed, disk present
53 * ERROR_NO_DISK - Cache flushed, no disk present
55 LONG BCache_Invalidate(struct BCache *bcache);
57 /* Determine state of underlying media
58 * RETURN_OK - No change since last invalidate
59 * RETURN_WARN - Disk has changed, but a disk is present
60 * ERROR_NO_DISK - No disk present
62 LONG BCache_Present(struct BCache *bcache);
64 /* Read block from disk, give pointer to the cached buffer
65 * returns:
66 * RETURN_OK - Disk present
67 * Data read from disk
68 * RETURN_WARN - Disk has changed since last BCache_Invalidate();
69 * No data read from disk
70 * ERROR_NO_DISK - No disk present
71 * No data read from disk
72 * any other - Disk read error
73 * Partial data read from disk
75 LONG BCache_Read(struct BCache *bcache, ULONG block, UBYTE **buffer);
77 /* Write buffer to blocks on the disk.
78 * returns:
79 * RETURN_OK - Disk present
80 * Data written to disk
81 * RETURN_WARN - Disk has changed since last BCache_Invalidate();
82 * No data written to disk
83 * ERROR_NO_DISK - No disk present
84 * No data written to disk
85 * any other - Disk write error
86 * Partial data written to disk
88 LONG BCache_Write(struct BCache *bcache, ULONG block, CONST UBYTE *buffer);
90 #endif /* BLOCKCACHE_H */