1/* 2 * Copyright (c) 2011, ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef BCACHED_H 11#define BCACHED_H 12 13#include <barrelfish/barrelfish.h> 14#include <barrelfish/bulk_transfer.h> 15#include <vfs/vfs.h> 16 17#ifdef WITH_SHARED_CACHE 18# define CACHE_SIZE (1U << 28) // 256MB 19//# define CACHE_SIZE (1U << 21) // 2MB 20#else 21# define CACHE_SIZE (1U << 24) // 16MB 22#endif 23#define NUM_BLOCKS (CACHE_SIZE / BUFFER_CACHE_BLOCK_SIZE) 24 25struct bcache_state { 26 struct bulk_transfer bt; 27}; 28 29extern struct capref cache_memory; 30extern size_t cache_size, block_size; 31extern void *cache_pool; 32 33errval_t start_service(void); 34 35typedef enum { 36 KEY_EXISTS, 37 KEY_MISSING, 38 KEY_INTRANSIT 39} key_state_t; 40key_state_t cache_lookup(const char *key, size_t key_len, uintptr_t *index, uintptr_t *length); 41 42uintptr_t cache_allocate(const char *key, size_t key_len); 43void cache_update(uintptr_t index, uintptr_t length); 44 45void cache_register_wait(uintptr_t index, void *b); 46void *cache_get_next_waiter(uintptr_t index); 47 48uint64_t cache_get_block_length(uintptr_t index); 49 50void print_stats(void); 51 52#endif 53