view loadtools/flutil.c @ 58:1f9302b6f342

fc-loadtool: started flash/flash2 command implementation
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 24 Jun 2013 06:30:57 +0000
parents d98137625c0d
children a10491da8c3a
line wrap: on
line source

/*
 * 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;
}