aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/firmware-utils/src/add_header.c2
-rw-r--r--tools/firmware-utils/src/cyg_crc.h12
-rw-r--r--tools/firmware-utils/src/cyg_crc16.c3
-rw-r--r--tools/firmware-utils/src/cyg_crc32.c10
-rw-r--r--tools/firmware-utils/src/dns313-header.c8
-rw-r--r--tools/firmware-utils/src/fw.h8
-rw-r--r--tools/firmware-utils/src/mkbrnimg.c7
-rw-r--r--tools/firmware-utils/src/mkcasfw.c15
-rw-r--r--tools/firmware-utils/src/mkcsysimg.c15
-rw-r--r--tools/firmware-utils/src/mkmylofw.c8
-rw-r--r--tools/firmware-utils/src/mkrtn56uimg.c2
-rw-r--r--tools/firmware-utils/src/mkwrggimg.c2
-rw-r--r--tools/firmware-utils/src/mkwrgimg.c2
-rw-r--r--tools/firmware-utils/src/mkzynfw.c16
-rw-r--r--tools/firmware-utils/src/sha1.c3
-rw-r--r--tools/firmware-utils/src/sha1.h2
-rw-r--r--tools/firmware-utils/src/spw303v.c6
-rw-r--r--tools/firmware-utils/src/xorimage.c14
18 files changed, 81 insertions, 54 deletions
diff --git a/tools/firmware-utils/src/add_header.c b/tools/firmware-utils/src/add_header.c
index 37775c3e0c..726e54c6bf 100644
--- a/tools/firmware-utils/src/add_header.c
+++ b/tools/firmware-utils/src/add_header.c
@@ -65,7 +65,7 @@ static uint32_t crc32buf(unsigned char *buf, size_t len)
}
struct header {
- unsigned char model[16];
+ char model[16];
uint32_t crc;
};
diff --git a/tools/firmware-utils/src/cyg_crc.h b/tools/firmware-utils/src/cyg_crc.h
index 7b59803446..68669715cf 100644
--- a/tools/firmware-utils/src/cyg_crc.h
+++ b/tools/firmware-utils/src/cyg_crc.h
@@ -74,34 +74,34 @@ typedef uint16_t cyg_uint16;
// Compute a CRC, using the POSIX 1003 definition
__externC cyg_uint32
-cyg_posix_crc32(unsigned char *s, int len);
+cyg_posix_crc32(void *s, int len);
// Gary S. Brown's 32 bit CRC
__externC cyg_uint32
-cyg_crc32(unsigned char *s, int len);
+cyg_crc32(void *s, int len);
// Gary S. Brown's 32 bit CRC, but accumulate the result from a
// previous CRC calculation
__externC cyg_uint32
-cyg_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+cyg_crc32_accumulate(cyg_uint32 crc, void *s, int len);
// Ethernet FCS Algorithm
__externC cyg_uint32
-cyg_ether_crc32(unsigned char *s, int len);
+cyg_ether_crc32(void *s, int len);
// Ethernet FCS algorithm, but accumulate the result from a previous
// CRC calculation.
__externC cyg_uint32
-cyg_ether_crc32_accumulate(cyg_uint32 crc, unsigned char *s, int len);
+cyg_ether_crc32_accumulate(cyg_uint32 crc, void *s, int len);
// 16 bit CRC with polynomial x^16+x^12+x^5+1
__externC cyg_uint16
-cyg_crc16(unsigned char *s, int len);
+cyg_crc16(void *s, int len);
#endif // _SERVICES_CRC_CRC_H_
diff --git a/tools/firmware-utils/src/cyg_crc16.c b/tools/firmware-utils/src/cyg_crc16.c
index 8b3735289f..3861ff03e8 100644
--- a/tools/firmware-utils/src/cyg_crc16.c
+++ b/tools/firmware-utils/src/cyg_crc16.c
@@ -96,8 +96,9 @@ static const cyg_uint16 crc16_tab[] = {
};
cyg_uint16
-cyg_crc16(unsigned char *buf, int len)
+cyg_crc16(void *ptr, int len)
{
+ unsigned char *buf = ptr;
int i;
cyg_uint16 cksum;
diff --git a/tools/firmware-utils/src/cyg_crc32.c b/tools/firmware-utils/src/cyg_crc32.c
index 9462598ae6..f13221e946 100644
--- a/tools/firmware-utils/src/cyg_crc32.c
+++ b/tools/firmware-utils/src/cyg_crc32.c
@@ -127,8 +127,9 @@ static const cyg_uint32 crc32_tab[] = {
/* This is the standard Gary S. Brown's 32 bit CRC algorithm, but
accumulate the CRC into the result of a previous CRC. */
cyg_uint32
-cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+cyg_crc32_accumulate(cyg_uint32 crc32val, void *ptr, int len)
{
+ unsigned char *s = ptr;
int i;
for (i = 0; i < len; i++) {
@@ -139,7 +140,7 @@ cyg_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
/* This is the standard Gary S. Brown's 32 bit CRC algorithm */
cyg_uint32
-cyg_crc32(unsigned char *s, int len)
+cyg_crc32(void *s, int len)
{
return (cyg_crc32_accumulate(0,s,len));
}
@@ -148,8 +149,9 @@ cyg_crc32(unsigned char *s, int len)
result from a previous CRC calculation. This uses the Ethernet FCS
algorithm.*/
cyg_uint32
-cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
+cyg_ether_crc32_accumulate(cyg_uint32 crc32val, void *ptr, int len)
{
+ unsigned char *s = ptr;
int i;
if (s == 0) return 0L;
@@ -164,7 +166,7 @@ cyg_ether_crc32_accumulate(cyg_uint32 crc32val, unsigned char *s, int len)
/* Return a 32-bit CRC of the contents of the buffer, using the
Ethernet FCS algorithm. */
cyg_uint32
-cyg_ether_crc32(unsigned char *s, int len)
+cyg_ether_crc32(void *s, int len)
{
return cyg_ether_crc32_accumulate(0,s,len);
}
diff --git a/tools/firmware-utils/src/dns313-header.c b/tools/firmware-utils/src/dns313-header.c
index c5c70e1bbc..42dd67771d 100644
--- a/tools/firmware-utils/src/dns313-header.c
+++ b/tools/firmware-utils/src/dns313-header.c
@@ -102,9 +102,11 @@ static const uint32_t crc32_table[256] = {
};
static uint32_t crc32(uint32_t crc,
- const unsigned char *buf,
+ const void *data,
unsigned int len)
{
+ const uint8_t *buf = data;
+
crc = crc ^ 0xffffffffUL;
do {
crc = crc32_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
@@ -112,7 +114,7 @@ static uint32_t crc32(uint32_t crc,
return crc ^ 0xffffffffUL;
}
-static void be_wr(unsigned char *buf, uint32_t val)
+static void be_wr(char *buf, uint32_t val)
{
buf[0] = (val >> 24) & 0xFFU;
buf[1] = (val >> 16) & 0xFFU;
@@ -129,7 +131,7 @@ int main(int argc, char **argv)
int ret = 0;
const char *pathin;
const char *pathout;
- unsigned char *buffer;
+ char *buffer;
uint32_t sum;
size_t bufsize;
size_t bytes;
diff --git a/tools/firmware-utils/src/fw.h b/tools/firmware-utils/src/fw.h
index 778143d2c4..c8fb99b467 100644
--- a/tools/firmware-utils/src/fw.h
+++ b/tools/firmware-utils/src/fw.h
@@ -31,15 +31,15 @@
#define PART_NAME_LENGTH 16
typedef struct header {
- uint8_t magic[MAGIC_LENGTH];
- uint8_t version[256];
+ char magic[MAGIC_LENGTH];
+ char version[256];
u_int32_t crc;
u_int32_t pad;
} __attribute__ ((packed)) header_t;
typedef struct part {
- uint8_t magic[MAGIC_LENGTH];
- uint8_t name[PART_NAME_LENGTH];
+ char magic[MAGIC_LENGTH];
+ char name[PART_NAME_LENGTH];
uint8_t pad[12];
u_int32_t memaddr;
u_int32_t index;
diff --git a/tools/firmware-utils/src/mkbrnimg.c b/tools/firmware-utils/src/mkbrnimg.c
index b7a73ff59d..9cddda3575 100644
--- a/tools/firmware-utils/src/mkbrnimg.c
+++ b/tools/firmware-utils/src/mkbrnimg.c
@@ -52,12 +52,13 @@ static void init_crc32()
}
}
-static uint32_t crc32buf(unsigned char *buf, size_t len)
+static uint32_t crc32buf(const void *buf, size_t len)
{
uint32_t crc = 0xFFFFFFFF;
+ const uint8_t *in = buf;
- for (; len; len--, buf++)
- crc = crc32[(uint8_t)crc ^ *buf] ^ (crc >> BPB);
+ for (; len; len--, in++)
+ crc = crc32[(uint8_t)crc ^ *in] ^ (crc >> BPB);
return ~crc;
}
diff --git a/tools/firmware-utils/src/mkcasfw.c b/tools/firmware-utils/src/mkcasfw.c
index 904000c78d..0e7aa17c1b 100644
--- a/tools/firmware-utils/src/mkcasfw.c
+++ b/tools/firmware-utils/src/mkcasfw.c
@@ -463,8 +463,9 @@ csum8_get(struct csum_state *css)
void
-csum16_update(uint8_t *p, uint32_t len, struct csum_state *css)
+csum16_update(void *data, uint32_t len, struct csum_state *css)
{
+ uint8_t *p = data;
uint16_t t;
if (css->odd) {
@@ -524,8 +525,10 @@ csum_init(struct csum_state *css, int size)
}
void
-csum_update(uint8_t *p, uint32_t len, struct csum_state *css)
+csum_update(void *data, uint32_t len, struct csum_state *css)
{
+ uint8_t *p = data;
+
switch (css->size) {
case CSUM_TYPE_8:
csum8_update(p,len,css);
@@ -568,19 +571,21 @@ csum_get(struct csum_state *css)
* routines to write data to the output file
*/
int
-write_out_data(FILE *outfile, uint8_t *data, size_t len,
+write_out_data(FILE *outfile, void *data, size_t len,
struct csum_state *css)
{
+ uint8_t *ptr = data;
+
errno = 0;
- fwrite(data, len, 1, outfile);
+ fwrite(ptr, len, 1, outfile);
if (errno) {
ERRS("unable to write output file");
return ERR_FATAL;
}
if (css) {
- csum_update(data, len, css);
+ csum_update(ptr, len, css);
}
return 0;
diff --git a/tools/firmware-utils/src/mkcsysimg.c b/tools/firmware-utils/src/mkcsysimg.c
index e156f79153..0ddb54c4ec 100644
--- a/tools/firmware-utils/src/mkcsysimg.c
+++ b/tools/firmware-utils/src/mkcsysimg.c
@@ -423,8 +423,9 @@ csum8_get(struct csum_state *css)
void
-csum16_update(uint8_t *p, uint32_t len, struct csum_state *css)
+csum16_update(void *data, uint32_t len, struct csum_state *css)
{
+ uint8_t *p = data;
uint16_t t;
if (css->odd) {
@@ -468,8 +469,10 @@ csum_init(struct csum_state *css, int size)
void
-csum_update(uint8_t *p, uint32_t len, struct csum_state *css)
+csum_update(void *data, uint32_t len, struct csum_state *css)
{
+ uint8_t *p = data;
+
switch (css->size) {
case CSUM_SIZE_8:
csum8_update(p,len,css);
@@ -506,19 +509,21 @@ csum_get(struct csum_state *css)
* routines to write data to the output file
*/
int
-write_out_data(FILE *outfile, uint8_t *data, size_t len,
+write_out_data(FILE *outfile, void *data, size_t len,
struct csum_state *css)
{
+ uint8_t *ptr = data;
+
errno = 0;
- fwrite(data, len, 1, outfile);
+ fwrite(ptr, len, 1, outfile);
if (errno) {
ERRS("unable to write output file");
return ERR_FATAL;
}
if (css) {
- csum_update(data, len, css);
+ csum_update(ptr, len, css);
}
return 0;
diff --git a/tools/firmware-utils/src/mkmylofw.c b/tools/firmware-utils/src/mkmylofw.c
index c049ce436e..5722365ee3 100644
--- a/tools/firmware-utils/src/mkmylofw.c
+++ b/tools/firmware-utils/src/mkmylofw.c
@@ -478,18 +478,20 @@ process_partitions(void)
* routines to write data to the output file
*/
int
-write_out_data(FILE *outfile, uint8_t *data, size_t len, uint32_t *crc)
+write_out_data(FILE *outfile, void *data, size_t len, uint32_t *crc)
{
+ uint8_t *ptr = data;
+
errno = 0;
- fwrite(data, len, 1, outfile);
+ fwrite(ptr, len, 1, outfile);
if (errno) {
errmsg(1,"unable to write output file");
return -1;
}
if (crc) {
- update_crc(data, len, crc);
+ update_crc(ptr, len, crc);
}
return 0;
diff --git a/tools/firmware-utils/src/mkrtn56uimg.c b/tools/firmware-utils/src/mkrtn56uimg.c
index b6c891bbdc..689dc8b375 100644
--- a/tools/firmware-utils/src/mkrtn56uimg.c
+++ b/tools/firmware-utils/src/mkrtn56uimg.c
@@ -67,7 +67,7 @@ typedef struct image_header {
uint8_t ih_type;
uint8_t ih_comp;
union {
- uint8_t ih_name[IH_NMLEN];
+ char ih_name[IH_NMLEN];
asus_t asus;
} tail;
} image_header_t;
diff --git a/tools/firmware-utils/src/mkwrggimg.c b/tools/firmware-utils/src/mkwrggimg.c
index 9995b9a13d..d2c42b02b3 100644
--- a/tools/firmware-utils/src/mkwrggimg.c
+++ b/tools/firmware-utils/src/mkwrggimg.c
@@ -114,7 +114,7 @@ static void get_digest(struct wrgg03_header *header, char *data, int size)
MD5_Update(&ctx, (char *)&header->devname, sizeof(header->devname));
MD5_Update(&ctx, data, size);
- MD5_Final(header->digest, &ctx);
+ MD5_Final((unsigned char *)header->digest, &ctx);
}
int main(int argc, char *argv[])
diff --git a/tools/firmware-utils/src/mkwrgimg.c b/tools/firmware-utils/src/mkwrgimg.c
index 3915d146cf..6ba2fd1577 100644
--- a/tools/firmware-utils/src/mkwrgimg.c
+++ b/tools/firmware-utils/src/mkwrgimg.c
@@ -100,7 +100,7 @@ static void get_digest(struct wrg_header *header, char *data, int size)
MD5_Update(&ctx, (char *)&header->devname, sizeof(header->devname));
MD5_Update(&ctx, data, size);
- MD5_Final(header->digest, &ctx);
+ MD5_Final((unsigned char *)header->digest, &ctx);
}
int main(int argc, char *argv[])
diff --git a/tools/firmware-utils/src/mkzynfw.c b/tools/firmware-utils/src/mkzynfw.c
index 2cd769de2f..365264ca68 100644
--- a/tools/firmware-utils/src/mkzynfw.c
+++ b/tools/firmware-utils/src/mkzynfw.c
@@ -444,8 +444,10 @@ csum_init(struct csum_state *css)
void
-csum_update(uint8_t *p, uint32_t len, struct csum_state *css)
+csum_update(void *data, uint32_t len, struct csum_state *css)
{
+ uint8_t *p = data;
+
if (len == 0)
return;
@@ -499,19 +501,21 @@ csum_buf(uint8_t *p, uint32_t len)
* routines to write data to the output file
*/
int
-write_out_data(FILE *outfile, uint8_t *data, size_t len,
+write_out_data(FILE *outfile, void *data, size_t len,
struct csum_state *css)
{
+ uint8_t *ptr = data;
+
errno = 0;
- fwrite(data, len, 1, outfile);
+ fwrite(ptr, len, 1, outfile);
if (errno) {
ERR("unable to write output file");
return -1;
}
if (css) {
- csum_update(data, len, css);
+ csum_update(ptr, len, css);
}
return 0;
@@ -541,7 +545,7 @@ write_out_padding(FILE *outfile, size_t len, uint8_t padc,
int
-write_out_data_align(FILE *outfile, uint8_t *data, size_t len, size_t align,
+write_out_data_align(FILE *outfile, void *data, size_t len, size_t align,
struct csum_state *css)
{
size_t padlen;
@@ -611,7 +615,7 @@ write_out_mmap(FILE *outfile, struct fw_mmap *mmap, struct csum_state *css)
mh->count=0;
/* Build user data section */
- data = buf+sizeof(*mh);
+ data = (char *)buf + sizeof(*mh);
data += sprintf(data, "Vendor 1 %d", board->vendor);
*data++ = '\0';
data += sprintf(data, "Model 1 %d", BE16_TO_HOST(board->model));
diff --git a/tools/firmware-utils/src/sha1.c b/tools/firmware-utils/src/sha1.c
index 3ab1332992..40cc78ca08 100644
--- a/tools/firmware-utils/src/sha1.c
+++ b/tools/firmware-utils/src/sha1.c
@@ -225,8 +225,9 @@ void sha1_process( sha1_context *ctx, uchar data[64] )
ctx->state[4] += E;
}
-void sha1_update( sha1_context *ctx, uchar *input, uint length )
+void sha1_update( sha1_context *ctx, void *data, uint length )
{
+ uchar *input = data;
ulong left, fill;
if( ! length ) return;
diff --git a/tools/firmware-utils/src/sha1.h b/tools/firmware-utils/src/sha1.h
index 425267a306..990a52765c 100644
--- a/tools/firmware-utils/src/sha1.h
+++ b/tools/firmware-utils/src/sha1.h
@@ -26,7 +26,7 @@ sha1_context;
* Core SHA-1 functions
*/
void sha1_starts( sha1_context *ctx );
-void sha1_update( sha1_context *ctx, uchar *input, uint length );
+void sha1_update( sha1_context *ctx, void *input, uint length );
void sha1_finish( sha1_context *ctx, uchar digest[20] );
/*
diff --git a/tools/firmware-utils/src/spw303v.c b/tools/firmware-utils/src/spw303v.c
index 9638b80a8a..980f41ded6 100644
--- a/tools/firmware-utils/src/spw303v.c
+++ b/tools/firmware-utils/src/spw303v.c
@@ -117,10 +117,12 @@ static char fake_data[] = {
};
-uint32_t crc32(uint32_t crc, uint8_t *data, size_t len)
+uint32_t crc32(uint32_t crc, const void *data, size_t len)
{
+ const uint8_t *in = data;
+
while (len--)
- crc = (crc >> 8) ^ crc32tab[(crc ^ *data++) & 0xFF];
+ crc = (crc >> 8) ^ crc32tab[(crc ^ *in++) & 0xFF];
return crc;
}
diff --git a/tools/firmware-utils/src/xorimage.c b/tools/firmware-utils/src/xorimage.c
index 4d1cd2d5de..e13531ab4a 100644
--- a/tools/firmware-utils/src/xorimage.c
+++ b/tools/firmware-utils/src/xorimage.c
@@ -29,15 +29,17 @@ static char default_pattern[] = "12345678";
static int is_hex_pattern;
-int xor_data(uint8_t *data, size_t len, const uint8_t *pattern, int p_len, int p_off)
+int xor_data(void *data, size_t len, const void *pattern, int p_len, int p_off)
{
- int offset = p_off;
+ const uint8_t *key = pattern;
+ uint8_t *d = data;
+
while (len--) {
- *data ^= pattern[offset];
- data++;
- offset = (offset + 1) % p_len;
+ *d ^= key[p_off];
+ d++;
+ p_off = (p_off + 1) % p_len;
}
- return offset;
+ return p_off;
}