First revision

This commit is contained in:
Laurent Vivier 2005-02-02 14:25:30 +00:00
parent efcd323152
commit 3255f348a4
3 changed files with 88 additions and 0 deletions

41
libemile/emile_checksum.c Normal file
View File

@ -0,0 +1,41 @@
static __attribute__((used)) char* rcsid = "$CVSHeader$";
/*
*
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
*
*/
#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

19
libemile/emile_map_dev.c Normal file
View File

@ -0,0 +1,19 @@
static __attribute__((used)) char* rcsid = "$CVSHeader$";
/*
*
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
*
*/
#include <stdio.h>
#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;
}

View File

@ -0,0 +1,28 @@
static __attribute__((used)) char* rcsid = "$CVSHeader$";
/*
*
* (c) 2004 Laurent Vivier <LaurentVivier@wanadoo.fr>
*
*/
#include <string.h>
#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;
}