00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00037 #ifndef LIBBLOCK_LIBBLOCK_H_
00038 #define LIBBLOCK_LIBBLOCK_H_
00039
00040 #include <stdint.h>
00041 #include "../../srv/vfs/vfs.h"
00042 #include <fibril_synch.h>
00043 #include <adt/hash_table.h>
00044 #include <adt/list.h>
00045
00046
00047
00048
00049
00054 #define BLOCK_FLAGS_NONE 0
00055
00060 #define BLOCK_FLAGS_NOREAD 1
00061
00062 typedef struct block {
00064 fibril_mutex_t lock;
00066 unsigned refcnt;
00068 bool dirty;
00070 bool toxic;
00072 fibril_rwlock_t contents_lock;
00074 devmap_handle_t devmap_handle;
00076 aoff64_t lba;
00078 aoff64_t pba;
00080 size_t size;
00082 link_t free_link;
00084 link_t hash_link;
00086 void *data;
00087 } block_t;
00088
00090 enum cache_mode {
00092 CACHE_MODE_WT,
00094 CACHE_MODE_WB
00095 };
00096
00097 extern int block_init(devmap_handle_t, size_t);
00098 extern void block_fini(devmap_handle_t);
00099
00100 extern int block_bb_read(devmap_handle_t, aoff64_t);
00101 extern void *block_bb_get(devmap_handle_t);
00102
00103 extern int block_cache_init(devmap_handle_t, size_t, unsigned, enum cache_mode);
00104 extern int block_cache_fini(devmap_handle_t);
00105
00106 extern int block_get(block_t **, devmap_handle_t, aoff64_t, int);
00107 extern int block_put(block_t *);
00108
00109 extern int block_seqread(devmap_handle_t, size_t *, size_t *, aoff64_t *, void *,
00110 size_t);
00111
00112 extern int block_get_bsize(devmap_handle_t, size_t *);
00113 extern int block_get_nblocks(devmap_handle_t, aoff64_t *);
00114 extern int block_read_direct(devmap_handle_t, aoff64_t, size_t, void *);
00115 extern int block_write_direct(devmap_handle_t, aoff64_t, size_t, const void *);
00116
00117 #endif
00118