From f141a79d805acbab07876d9f007e8809603718b5 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Wed, 10 Jun 2015 12:30:58 -0400 Subject: generate core_selector, probe FPGA for cores at software startup --- sw/tc_eim.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sw/tc_eim.c') diff --git a/sw/tc_eim.c b/sw/tc_eim.c index 8ef4f06..87e90d1 100644 --- a/sw/tc_eim.c +++ b/sw/tc_eim.c @@ -45,12 +45,13 @@ #include "cryptech.h" static int debug = 0; -static int inited = 0; /* ---------------- EIM low-level code ---------------- */ static int init(void) { + static int inited = 0; + if (inited) return 0; @@ -84,11 +85,11 @@ void tc_set_debug(int onoff) debug = onoff; } -static void dump(char *label, const uint8_t *buf, size_t len) +static void dump(char *label, off_t addr, const uint8_t *buf, size_t len) { if (debug) { int i; - printf("%s [", label); + printf("%s %04x [", label, (unsigned int)addr); for (i = 0; i < len; ++i) printf(" %02x", buf[i]); printf(" ]\n"); @@ -100,10 +101,9 @@ int tc_write(off_t offset, const uint8_t *buf, size_t len) if (init() != 0) return -1; - dump("write ", buf, len); + dump("write ", offset, buf, len); - offset = eim_offset(offset); - for (; len > 0; offset += 4, buf += 4, len -= 4) { + for (offset = eim_offset(offset); len > 0; offset += 4, buf += 4, len -= 4) { uint32_t val; val = htonl(*(uint32_t *)buf); eim_write_32(offset, &val); @@ -114,20 +114,20 @@ int tc_write(off_t offset, const uint8_t *buf, size_t len) int tc_read(off_t offset, uint8_t *buf, size_t len) { + off_t off; uint8_t *rbuf = buf; int rlen = len; if (init() != 0) return -1; - offset = eim_offset(offset); - for (; rlen > 0; offset += 4, rbuf += 4, rlen -= 4) { + for (off = eim_offset(offset); rlen > 0; off += 4, rbuf += 4, rlen -= 4) { uint32_t val; - eim_read_32(offset, &val); + eim_read_32(off, &val); *(uint32_t *)rbuf = ntohl(val); } - dump("read ", buf, len); + dump("read ", offset, buf, len); return 0; } @@ -142,7 +142,7 @@ int tc_expected(off_t offset, const uint8_t *expected, size_t len) perror("malloc"); return 1; } - dump("expect", expected, len); + dump("expect", offset, expected, len); if (tc_read(offset, buf, len) != 0) goto errout; -- cgit v1.2.3 From 026fc461d9791bc360036f1269d0f6d61c45d179 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 23 Sep 2015 16:31:28 -0400 Subject: Trailing whitespace cleanup. --- sw/tc_eim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sw/tc_eim.c') diff --git a/sw/tc_eim.c b/sw/tc_eim.c index 87e90d1..76972cd 100644 --- a/sw/tc_eim.c +++ b/sw/tc_eim.c @@ -1,11 +1,11 @@ -/* +/* * tc_eim.c * -------- * This module contains common code to talk to the FPGA over the EIM bus. - * + * * Author: Paul Selkirk * Copyright (c) 2014-2015, NORDUnet A/S All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: -- cgit v1.2.3