diff loadtools/flutil.c @ 56:d98137625c0d

fc-loadtool flash: total_size logic implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 23 Jun 2013 20:50:41 +0000
parents
children a10491da8c3a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadtools/flutil.c	Sun Jun 23 20:50:41 2013 +0000
@@ -0,0 +1,34 @@
+/*
+ * Miscellaneous utility functions for flash support
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "flash.h"
+
+extern struct flash_bank_info flash_bank_info[2];
+
+compute_flash_totsize_nsecs(bank)
+{
+	struct flash_bank_info *bi;
+	struct flash_region_desc *reg;
+
+	bi = flash_bank_info + bank;
+	for (reg = bi->bank_desc->regions; reg->nsectors; reg++) {
+		bi->nsectors += reg->nsectors;
+		bi->total_size += reg->sector_size * reg->nsectors;
+	}
+}
+
+/* the following function is used to verify that total_size is a power of 2 */
+count_ones(word)
+	uint32_t word;
+{
+	int count;
+
+	for (count = 0; word; word >>= 1)
+		count += word & 1;
+	return count;
+}