summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-01-17 09:49:36 -0800
committerJosh Blum <josh@joshknows.com>2012-01-17 09:49:36 -0800
commitb071cbc1841376e26b511f96c205e2dd96789673 (patch)
tree151784f2c8708376a6d1bd343da7e17efac5c0a3
parent1424488061000ddc471c976c2406ff274d14ae99 (diff)
downloaduhd-b071cbc1841376e26b511f96c205e2dd96789673.tar.gz
uhd-b071cbc1841376e26b511f96c205e2dd96789673.tar.bz2
uhd-b071cbc1841376e26b511f96c205e2dd96789673.zip
usrp1: use fixed bit width integer for hash
-rw-r--r--host/lib/usrp/common/fx2_ctrl.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/host/lib/usrp/common/fx2_ctrl.cpp b/host/lib/usrp/common/fx2_ctrl.cpp
index 650fba784..3c6df7079 100644
--- a/host/lib/usrp/common/fx2_ctrl.cpp
+++ b/host/lib/usrp/common/fx2_ctrl.cpp
@@ -22,6 +22,7 @@
#include <uhd/transport/usb_control.hpp>
#include <boost/functional/hash.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/cstdint.hpp>
#include <fstream>
#include <sstream>
#include <string>
@@ -35,6 +36,8 @@ using namespace uhd::usrp;
static const bool load_img_msg = true;
+typedef boost::uint32_t hash_type;
+
/***********************************************************************
* Helper Functions
**********************************************************************/
@@ -44,7 +47,7 @@ static const bool load_img_msg = true;
* \param filename file used to generate hash value
* \return hash value in a size_t type
*/
-static size_t generate_hash(const char *filename)
+static hash_type generate_hash(const char *filename)
{
std::ifstream file(filename);
if (not file){
@@ -63,7 +66,7 @@ static size_t generate_hash(const char *filename)
}
file.close();
- return hash;
+ return hash_type(hash);
}
@@ -140,9 +143,9 @@ public:
{
const char *filename = filestring.c_str();
- size_t hash = generate_hash(filename);
+ hash_type hash = generate_hash(filename);
- size_t loaded_hash; usrp_get_firmware_hash(loaded_hash);
+ hash_type loaded_hash; usrp_get_firmware_hash(loaded_hash);
if (not force and (hash == loaded_hash)) return;
@@ -217,9 +220,9 @@ public:
{
const char *filename = filestring.c_str();
- size_t hash = generate_hash(filename);
+ hash_type hash = generate_hash(filename);
- size_t loaded_hash; usrp_get_fpga_hash(loaded_hash);
+ hash_type loaded_hash; usrp_get_fpga_hash(loaded_hash);
if (hash == loaded_hash) return;
const int ep0_size = 64;
@@ -308,32 +311,32 @@ public:
}
- void usrp_get_firmware_hash(size_t &hash)
+ void usrp_get_firmware_hash(hash_type &hash)
{
UHD_ASSERT_THROW(usrp_control_read(0xa0, USRP_HASH_SLOT_0_ADDR, 0,
- (unsigned char*) &hash, sizeof(size_t)) >= 0);
+ (unsigned char*) &hash, sizeof(hash)) >= 0);
}
- void usrp_set_firmware_hash(size_t hash)
+ void usrp_set_firmware_hash(hash_type hash)
{
UHD_ASSERT_THROW(usrp_control_write(0xa0, USRP_HASH_SLOT_0_ADDR, 0,
- (unsigned char*) &hash, sizeof(size_t)) >= 0);
+ (unsigned char*) &hash, sizeof(hash)) >= 0);
}
- void usrp_get_fpga_hash(size_t &hash)
+ void usrp_get_fpga_hash(hash_type &hash)
{
UHD_ASSERT_THROW(usrp_control_read(0xa0, USRP_HASH_SLOT_1_ADDR, 0,
- (unsigned char*) &hash, sizeof(size_t)) >= 0);
+ (unsigned char*) &hash, sizeof(hash)) >= 0);
}
- void usrp_set_fpga_hash(size_t hash)
+ void usrp_set_fpga_hash(hash_type hash)
{
UHD_ASSERT_THROW(usrp_control_write(0xa0, USRP_HASH_SLOT_1_ADDR, 0,
- (unsigned char*) &hash, sizeof(size_t)) >= 0);
+ (unsigned char*) &hash, sizeof(hash)) >= 0);
}
void usrp_tx_enable(bool on)