util.h 682 Bytes
#ifndef _UTIL_H
#define _UTIL_H

#define PAGE_SIZE 4096

typedef unsigned char page_t[PAGE_SIZE];


// Forces a memory read of the byte at address p. This will result in the byte
// being loaded into cache.
// Note the use of the _volatile_ keyword to avoid compiler optimizations
void force_read(const void *p);

// Flushes the cache line containing
// the provided address
void flush_cache_line(const void *memory);

// Returns the number of clocks taken to
// read the provided byte of memory.
uint64_t time_read(const void *memory);

// Flushes every page of the oracle from the cache
// Intended to reset for a new trial
void flush_oracle(page_t *pages);

#endif /* _UTIL_H */