comparison 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
comparison
equal deleted inserted replaced
55:278052b6afda 56:d98137625c0d
1 /*
2 * Miscellaneous utility functions for flash support
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <stdint.h>
8 #include <stdlib.h>
9 #include "flash.h"
10
11 extern struct flash_bank_info flash_bank_info[2];
12
13 compute_flash_totsize_nsecs(bank)
14 {
15 struct flash_bank_info *bi;
16 struct flash_region_desc *reg;
17
18 bi = flash_bank_info + bank;
19 for (reg = bi->bank_desc->regions; reg->nsectors; reg++) {
20 bi->nsectors += reg->nsectors;
21 bi->total_size += reg->sector_size * reg->nsectors;
22 }
23 }
24
25 /* the following function is used to verify that total_size is a power of 2 */
26 count_ones(word)
27 uint32_t word;
28 {
29 int count;
30
31 for (count = 0; word; word >>= 1)
32 count += word & 1;
33 return count;
34 }