*
******************************************************************************/
+#include <config.h>
#include <common.h>
#include <environment.h>
#include <net.h>
-#include <configs/ml300.h>
-#include "xparameters.h"
-#ifdef CFG_ENV_IS_IN_EEPROM
+#ifdef CONFIG_ENV_IS_IN_EEPROM
#include <i2c.h>
#include "xiic_l.h"
u8 pre; /* previous EEPROM data bit */
int i, loc;
- addr = CFG_ENV_OFFSET; /* start from first env address */
+ addr = CONFIG_ENV_OFFSET; /* start from first env address */
n = 0;
pre = 1;
stop = 1;
/* calculate runtime CRC according to ML300 and read back
old CRC stored in the EEPROM */
- while (n < CFG_ENV_SIZE) {
+ while (n < CONFIG_ENV_SIZE) {
receive(addr, buffer, len);
/* found two null chars, end of env */
crc = 0;
n = 0;
addr =
- CFG_ENV_OFFSET - offsetof(env_t, crc) + offsetof(env_t,
+ CONFIG_ENV_OFFSET - offsetof(env_t, crc) + offsetof(env_t,
data);
/* calculate u-boot crc */
while (n < ENV_SIZE) {
static void
ip_ml300(uchar * s, uchar * res)
{
- uchar temp[2];
+ char temp[2];
u8 i;
res[0] = 0x00;
for (i = 0; i < 4; i++) {
sprintf(temp, "%02x", atoi(s));
- s = strchr(s, '.') + 1;
- strcat(res, temp);
+ s = (uchar *)strchr((char *)s, '.') + 1;
+ strcat((char *)res, temp);
}
}
change_null(uchar * s)
{
if (s != NULL) {
- change_null(strchr(s + 1, 255));
- *(strchr(s, 255)) = '\0';
+ change_null((uchar *)strchr((char *)s + 1, 255));
+ *(strchr((char *)s, 255)) = '\0';
}
}
void
convert_env(void)
{
- uchar *s; /* pointer to env value */
- uchar temp[20]; /* temp storage for addresses */
+ char *s; /* pointer to env value */
+ char temp[20]; /* temp storage for addresses */
/* E -> ethaddr */
s = getenv("E");
if (s != NULL) {
sprintf(temp, "%c%c.%c%c.%c%c.%c%c.%c%c.%c%c",
- *s++, *s++, *s++, *s++, *s++, *s++,
- *s++, *s++, *s++, *s++, *s++, *s);
+ s[0], s[1], s[ 2], s[ 3],
+ s[4], s[5], s[ 6], s[ 7],
+ s[8], s[9], s[10], s[11] );
setenv("ethaddr", temp);
setenv("E", NULL);
}
/* I -> ipaddr */
s = getenv("I");
if (s != NULL) {
- sprintf(temp, "%d.%d.%d.%d", axtoi(s), axtoi(s + 2),
- axtoi(s + 4), axtoi(s + 6));
+ sprintf(temp, "%d.%d.%d.%d", axtoi((u8 *)s), axtoi((u8 *)(s + 2)),
+ axtoi((u8 *)(s + 4)), axtoi((u8 *)(s + 6)));
setenv("ipaddr", temp);
setenv("I", NULL);
}
/* S -> serverip */
s = getenv("S");
if (s != NULL) {
- sprintf(temp, "%d.%d.%d.%d", axtoi(s), axtoi(s + 2),
- axtoi(s + 4), axtoi(s + 6));
+ sprintf(temp, "%d.%d.%d.%d", axtoi((u8 *)s), axtoi((u8 *)(s + 2)),
+ axtoi((u8 *)(s + 4)), axtoi((u8 *)(s + 6)));
setenv("serverip", temp);
setenv("S", NULL);
}
static void
save_env(void)
{
- uchar eprom[ENV_SIZE]; /* buffer to be written back to EEPROM */
- uchar *s, temp[20];
- uchar ff[] = { 0xff, 0x00 }; /* dummy null value */
+ char eprom[ENV_SIZE]; /* buffer to be written back to EEPROM */
+ char *s, temp[20];
+ char ff[] = { 0xff, 0x00 }; /* dummy null value */
u32 len; /* length of env to be written to EEPROM */
eprom[0] = 0x00;
s = getenv("ipaddr");
if (s != NULL) {
strcat(eprom, "I=");
- ip_ml300(s, temp);
+ ip_ml300((uchar *)s, (uchar *)temp);
strcat(eprom, temp);
strcat(eprom, ff);
}
s = getenv("serverip");
if (s != NULL) {
strcat(eprom, "S=");
- ip_ml300(s, temp);
+ ip_ml300((uchar *)s, (uchar *)temp);
strcat(eprom, temp);
strcat(eprom, ff);
}
}
len = strlen(eprom); /* find env length without crc */
- change_null(eprom); /* change 0xff to 0x00 */
+ change_null((uchar *)eprom); /* change 0xff to 0x00 */
/* update EEPROM env values if there is enough space */
- if (update_crc(len, eprom) == 0)
- send(CFG_ENV_OFFSET, eprom, len + 6);
+ if (update_crc(len, (uchar *)eprom) == 0)
+ send(CONFIG_ENV_OFFSET, (uchar *)eprom, len + 6);
}
/************************************************************************
/* then read out EEPROM content for runtime u-boot CRC calculation */
receive(addr, buffer, len);
- if (addr + len - CFG_ENV_OFFSET == CFG_ENV_SIZE)
+ if (addr + len - CONFIG_ENV_OFFSET == CONFIG_ENV_SIZE)
/* end of runtime crc read */
++envStep;
return 0;
if (len < 2) {
/* when call getenv_r */
receive(addr, buffer, len);
- } else if (addr + len < CFG_ENV_OFFSET + CFG_ENV_SIZE) {
+ } else if (addr + len < CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) {
/* calling env_relocate(), but don't read out
crc value from EEPROM */
receive(addr, buffer + 4, len);
i2c_write(uchar chip, uint addr, int alen, uchar * buffer, int len)
{
/* save env on last page write called by u-boot */
- if (addr + len >= CFG_ENV_OFFSET + CFG_ENV_SIZE)
+ if (addr + len >= CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
save_env();
return 0;