util.h 741 Bytes
#ifndef _UTIL_H
#define _UTIL_H

#include <stdint.h>

#define PAGE_SIZE 4096

typedef uint8_t page_t[PAGE_SIZE];

/**
 * Forces a memory read of the byte at the given address.
 * This will load the byte at the address into the cache.
 */
void force_read(const void *address);

/**
 * Evicts any cache line currently storing the given address.
 * This ensures that the byte at the address is no longer in the cache.
 */
void flush_cache_line(const void *address);

/**
 * Counts the number of processor clocks elapsed when reading a byte at the given address.
 * Note that the number of clocks can be quite large
 * if the process happens to be interrupted in this function.
 */
uint64_t time_read(const void *address);

#endif /* _UTIL_H */