diff --git a/libemile/emile_checksum.c b/libemile/emile_checksum.c new file mode 100644 index 0000000..0b04d23 --- /dev/null +++ b/libemile/emile_checksum.c @@ -0,0 +1,41 @@ +static __attribute__((used)) char* rcsid = "$CVSHeader$"; +/* + * + * (c) 2004 Laurent Vivier + * + */ + +#include "libemile.h" + +#ifdef USE_16BIT_CHECKSUM +int emile_checksum(unsigned char *addr, unsigned short length) +{ + int j; + unsigned short sum = 0; + + for (j = 0; j < length; j++) + { + sum += addr[j]; + sum = (sum << 1) | (sum >> 15); + } + if (sum == 0) + sum = 0xFFFF; + + return sum; +} +#else +unsigned short emile_checksum(unsigned char *addr, unsigned int length) +{ + unsigned int sum = 0; + unsigned int i; + + for (i = 0; i < length; i++) + { + sum += addr[i]; + sum <<= 1; + sum |= (sum & 0x00010000) ? 1 : 0; + } + + return sum; +} +#endif diff --git a/libemile/emile_map_dev.c b/libemile/emile_map_dev.c new file mode 100644 index 0000000..169183a --- /dev/null +++ b/libemile/emile_map_dev.c @@ -0,0 +1,19 @@ +static __attribute__((used)) char* rcsid = "$CVSHeader$"; +/* + * + * (c) 2004 Laurent Vivier + * + */ + +#include + +#include "partition.h" +#include "libemile.h" + +char* emile_map_dev(emile_map_t *map) +{ + if (!emile_map_partition_is_valid(map)) + return NULL; + + return map->name; +} diff --git a/libemile/emile_map_get_bootinfo.c b/libemile/emile_map_get_bootinfo.c new file mode 100644 index 0000000..d894e32 --- /dev/null +++ b/libemile/emile_map_get_bootinfo.c @@ -0,0 +1,28 @@ +static __attribute__((used)) char* rcsid = "$CVSHeader$"; +/* + * + * (c) 2004 Laurent Vivier + * + */ + +#include + +#include "partition.h" +#include "libemile.h" + +int emile_map_get_bootinfo(emile_map_t *map, int* bootstart, int *bootsize, + int *bootaddr, int *bootentry, int* checksum, + char* processor) +{ + if (!emile_map_is_valid(map)) + return -1; + + *bootstart = map->partition.LgBootStart; + *bootsize = map->partition.BootSize; + *bootaddr = map->partition.BootAddr; + *bootentry = map->partition.BootEntry; + *checksum = map->partition.BootCksum; + strcpy(processor, map->partition.Processor); + + return 0; +}