mirror of
https://github.com/vivier/EMILE.git
synced 2024-12-22 10:29:31 +00:00
First revision
This commit is contained in:
parent
efcd323152
commit
3255f348a4
41
libemile/emile_checksum.c
Normal file
41
libemile/emile_checksum.c
Normal 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
19
libemile/emile_map_dev.c
Normal 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;
|
||||
}
|
28
libemile/emile_map_get_bootinfo.c
Normal file
28
libemile/emile_map_get_bootinfo.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user