diff --git a/hammersuite/src/main.c b/hammersuite/src/main.c index ee43eda..ee61173 100644 --- a/hammersuite/src/main.c +++ b/hammersuite/src/main.c @@ -1,114 +1,119 @@ #include "stdio.h" // #include /* for rdtsc, rdtscp, clflush */ -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include -#include "include/utils.h" -#include "include/types.h" #include "include/allocator.h" -#include "include/memory.h" #include "include/dram-address.h" #include "include/hammer-suite.h" +#include "include/memory.h" #include "include/params.h" +#include "include/types.h" +#include "include/utils.h" ProfileParams *p; // DRAMLayout g_mem_layout = {{{0x4080,0x88000,0x110000,0x220000,0x440000,0x4b300}, 6}, 0xffff80000, ((1<<13)-1)}; // DRAMLayout g_mem_layout = { {{0x2040, 0x44000, 0x88000, 0x110000, 0x220000}, 5}, 0xffffc0000, ((1 << 13) - 1) }; // DRAMLayout g_mem_layout = {{{0x2040,0x24000,0x48000,0x90000},4}, 0xffffe0000, ((1<<13)-1)}; -DRAMLayout g_mem_layout = {{{0x4080,0x48000,0x90000,0x120000,0x1b300}, 5}, 0xffffc0000, ROW_SIZE-1}; +DRAMLayout g_mem_layout = { + {{0x5400, 0x82600}, 2}, + 0xffff00000, + ROW_SIZE - 1 +}; -void read_config(SessionConfig * cfg, char *f_name) +void +read_config(SessionConfig *cfg, char *f_name) { - FILE *fp = fopen(f_name, "rb"); - int p_size; - size_t res; - assert(fp != NULL); - res = fread(cfg, sizeof(SessionConfig), 1, fp); - assert(res == 1); - fclose(fp); - return; + FILE *fp = fopen(f_name, "rb"); + int p_size; + size_t res; + assert(fp != NULL); + res = fread(cfg, sizeof(SessionConfig), 1, fp); + assert(res == 1); + fclose(fp); + return; } -void gmem_dump() +void +gmem_dump() { - FILE *fp = fopen("g_mem_dump.bin", "wb+"); - fwrite(&g_mem_layout, sizeof(DRAMLayout), 1, fp); - fclose(fp); + FILE *fp = fopen("g_mem_dump.bin", "wb+"); + fwrite(&g_mem_layout, sizeof(DRAMLayout), 1, fp); + fclose(fp); #ifdef DEBUG - DRAMLayout tmp; - fp = fopen("g_mem_dump.bin", "rb"); - fread(&tmp, sizeof(DRAMLayout), 1, fp); - fclose(fp); + DRAMLayout tmp; + fp = fopen("g_mem_dump.bin", "rb"); + fread(&tmp, sizeof(DRAMLayout), 1, fp); + fclose(fp); - assert(tmp->h_fns->len == g_mem_layout->h_fns->len); - assert(tmp->bank == g_mem_layout->bank); - assert(tmp->row == g_mem_layout->row); - assert(tmp->col == g_mem_layout->col); + assert(tmp->h_fns->len == g_mem_layout->h_fns->len); + assert(tmp->bank == g_mem_layout->bank); + assert(tmp->row == g_mem_layout->row); + assert(tmp->col == g_mem_layout->col); #endif } -int main(int argc, char **argv) +int +main(int argc, char **argv) { - srand(time(NULL)); - p = (ProfileParams*)malloc(sizeof(ProfileParams)); - if (p == NULL) { - fprintf(stderr, "[ERROR] Memory allocation\n"); - exit(1); - } + srand(time(NULL)); + p = (ProfileParams *) malloc(sizeof(ProfileParams)); + if (p == NULL) { + fprintf(stderr, "[ERROR] Memory allocation\n"); + exit(1); + } - if(process_argv(argc, argv, p) == -1) { - free(p); - exit(1); - } + if (process_argv(argc, argv, p) == -1) { + free(p); + exit(1); + } - MemoryBuffer mem = { - .buffer = NULL, - .physmap = NULL, - .fd = p->huge_fd, - .size = p->m_size, - .align = p->m_align, - .flags = p->g_flags & MEM_MASK - }; + MemoryBuffer mem = { + .buffer = NULL, + .physmap = NULL, + .fd = p->huge_fd, + .size = p->m_size, + .align = p->m_align, + .flags = p->g_flags & MEM_MASK}; - alloc_buffer(&mem); - set_physmap(&mem); - gmem_dump(); + alloc_buffer(&mem); + set_physmap(&mem); + gmem_dump(); - SessionConfig s_cfg; - memset(&s_cfg, 0, sizeof(SessionConfig)); - if (p->g_flags & F_CONFIG) { - read_config(&s_cfg, p->conf_file); - } else { - // HARDCODED values - s_cfg.h_rows = PATT_LEN; - s_cfg.h_rounds = p->rounds; - s_cfg.h_cfg = N_SIDED; - s_cfg.d_cfg = RANDOM; - s_cfg.base_off = p->base_off; - s_cfg.aggr_n = p->aggr; - } + SessionConfig s_cfg; + memset(&s_cfg, 0, sizeof(SessionConfig)); + if (p->g_flags & F_CONFIG) { + read_config(&s_cfg, p->conf_file); + } else { + // HARDCODED values + s_cfg.h_rows = PATT_LEN; + s_cfg.h_rounds = p->rounds; + s_cfg.h_cfg = N_SIDED; + s_cfg.d_cfg = RANDOM; + s_cfg.base_off = p->base_off; + s_cfg.aggr_n = p->aggr; + } - if (p->fuzzing) { - fuzzing_session(&s_cfg, &mem); - } else { - hammer_session(&s_cfg, &mem); - } + if (p->fuzzing) { + fuzzing_session(&s_cfg, &mem); + } else { + hammer_session(&s_cfg, &mem); + } - close(p->huge_fd); - return 0; + close(p->huge_fd); + return 0; }