#ifndef VARS_H #define VARS_H #include #include #include #include #include #include #include #include #include #include #ifdef CONFIG_HIGHMEM #include //#define GFP_ANEMONE (GFP_ATOMIC | __GFP_HIGHMEM) #endif #define GFP_ANEMONE GFP_ATOMIC #ifdef ARCH_64_BIT //#define Lseek Lseek64 #endif #if !defined(__x86_64__) #define atomic64_t atomic_t #define atomic64_set atomic_set #define atomic64_read atomic_read #define atomic64_inc atomic_inc #define atomic64_dec atomic_dec #endif #define dev_alloc_skb(x) alloc_skb(x, GFP_ANEMONE) #define BROADCAST_MAC "FF:FF:FF:FF:FF:FF" /* Defines common to the whole anemone system, including * computational optimizations by the use of shifts. */ #define BUCKET_SIZE 10 #define HASH_SIZE 11 //2^14 = 16384 buckets, must be a power of two (round it yourself) #define BLOCKSIZE 9 //bits, 512 = 2^9 #define OCTET_BITS 2 //2^2 = 4, (4 bytes, that is) #define OCTET 4 //2^2 = 4, (4 bytes, that is) #define MOD(x, y) (x - (x >> y << y)) #define DIV(x, y) (x >> y) #define MULT(x, y) (x << y) #define ADD(x, y) (x + (1 << y)) #define EQUAL(x, y) (x == (1 << y)) #define GREATERTHAN1(x, y) ((1 << y) > x) #define GREATERTHAN2(x, y) (x > (1 << y)) #define SUB1(x, y) ((1 << y) - x) #define SUB2(x, y) (x - (1 << y)) #define MB(x) (x * 4 / 1024) #define END(x) ((x) ? ((x - 1) - MOD((x - 1), BLOCK_IO_SIZE)) : 0) #define ntohll(x) ((((u64)ntohl(x)) << 32) + ntohl(x >> 32)) #define htonll(x) ((((u64)htonl(x)) << 32) + htonl(x >> 32)) #define USEC(x) (ulong) (x.tv_sec * 1000000 + x.tv_usec) #define LONG(x) ((u32) (x >> 32)), ((u32) x) # define timersub(a, b, result) \ do { \ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ if ((result)->tv_usec < 0) { \ --(result)->tv_sec; \ (result)->tv_usec += 1000000; \ } \ } while (0) /* Message type values */ #define MSGSIZE sizeof(Message) #define KEYSIZE sizeof(PageKey) #define CONNECT 21 #define DISCONNECT 22 #define REPLY_GOOD 23 #define REPLY_BAD 24 #define PAGE_OUT 25 #define PAGE_IN 26 #define PAGE_CLEAR 27 #define PAGE_OUT_REPLY 28 #define PAGE_IN_REPLY 29 #define PAGE_CLEAR_REPLY 30 #define REPLY_FULL 31 /* * Timeout for send and receive broadcast messages * 1=10 ms */ #define SERVER_BROADCAST_TIMEOUT 1000 /* * Timeout for send and receive session messages * 1=10 ms */ #define SESSION_TIMEOUT 1000 #define TYPE_SERVER_BROADCAST 100 #define TYPE_CLIENT_BROADCAST 99 /* broadcast server status */ #define STATUS_GOOD 50 #define STATUS_BAD 51 #define STATUS_UNAVAIL 52 #define true 1 #define false 0 typedef char bool; typedef struct timeval timeval; typedef struct PageKey PageKey; typedef struct Message Message; typedef struct Sessionid Sessionid; extern int debug; extern int hash_size; extern int binary_hash_size; void print_key(PageKey *p); void print_page(int, u8 *); ulong pagekey_hash(void *); bool pagekey_equal(void *, void *); void msg_hton(Message *); void msg_ntoh(Message *); void assert(void *, char *); typedef struct list_head list_head; struct PageKey { u8 client_mac[ETH_ALEN]; ulong offset, vpid; }; /* The structure of a message in the anemone system */ struct Message { u32 type, seq, status, count, offset, vpid, serv_internal_time, server_status, avail_mem, total_mem, session_id, fragbyte, fragment, fragleft, fragsize; }; /* An attempt at doing fixed point computation * in the kernel since there is no floating point in * the kernel. */ #ifndef _IEEE754_SINGLE_BIAS #define _IEEE754_SINGLE_BIAS 0x7f #endif typedef struct { unsigned int mantissa:23; unsigned int exponent:8; unsigned int negative:1; } ieee_float; #endif