Browse Source

fix 3a82h flash env.

Change-Id: Ia562941edec2e5ddb9851666620dc14f63406838
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
master
QiaoChong 6 years ago
parent
commit
58d1ff05b7
  1. 16
      Targets/Bonito3a82h/Bonito/tgt_machdep.c

16
Targets/Bonito3a82h/Bonito/tgt_machdep.c

@ -315,6 +315,7 @@ initmips(unsigned long long raw_memsz)
*/
SBD_DISPLAY("BEV1",0);
bcopy(MipsException, (char *)TLB_MISS_EXC_VEC, MipsExceptionEnd - MipsException);
bcopy(MipsException, (char *)XTLB_MISS_EXC_VEC, MipsExceptionEnd - MipsException);
bcopy(MipsException, (char *)GEN_EXC_VEC, MipsExceptionEnd - MipsException);
CPU_FlushCache();
@ -1045,10 +1046,10 @@ tgt_mapenv(int (*func) __P((char *, char *)))
*/
printf("in envinit\n");
#ifdef NVRAM_IN_FLASH
nvram = (char *)(tgt_flashmap())->fl_map_base;
nvram = (char *)(tgt_flashmap())->fl_map_base + ((unsigned long)(&nvram_offs)-0x8f010000);
printf("nvram=%08x\n",(unsigned int)nvram);
if(fl_devident(nvram, NULL) == 0 ||
cksum(nvram + ((unsigned long)(&nvram_offs)-0x8f010000), NVRAM_SIZE, 0) != 0) {
cksum(nvram, NVRAM_SIZE, 0) != 0) {
#else
nvram = (char *)malloc(512);
nvram_get(nvram);
@ -1058,7 +1059,6 @@ tgt_mapenv(int (*func) __P((char *, char *)))
nvram_invalid = 1;
}
else {
nvram += ((unsigned long)(&nvram_offs)-0x8f010000);
ep = nvram+2;;
while(*ep != 0) {
@ -1141,14 +1141,14 @@ tgt_unsetenv(char *name)
nvram = (char *)(tgt_flashmap())->fl_map_base;
/* Map. Deal with an entire sector even if we only use part of it */
nvram += ((unsigned long)(&nvram_offs)-0x8f010000) & ~(NVRAM_SECSIZE - 1);
nvram += ((unsigned long)(&nvram_offs)-0x8f010000);
nvramsecbuf = (char *)malloc(NVRAM_SECSIZE);
if(nvramsecbuf == 0) {
printf("Warning! Unable to malloc nvrambuffer!\n");
return(-1);
}
memcpy(nvramsecbuf, nvram, NVRAM_SECSIZE);
nvrambuf = nvramsecbuf + (((unsigned long)(&nvram_offs)-0x8f010000) & (NVRAM_SECSIZE - 1));
nvrambuf = nvramsecbuf;
#else
nvramsecbuf = nvrambuf = nvram = (char *)malloc(512);
nvram_get(nvram);
@ -1233,7 +1233,7 @@ tgt_setenv(char *name, char *value)
nvram = (char *)(tgt_flashmap())->fl_map_base;
/* Deal with an entire sector even if we only use part of it */
nvram += ((unsigned long)(&nvram_offs)-0x8f010000) & ~(NVRAM_SECSIZE - 1);
nvram += ((unsigned long)(&nvram_offs)-0x8f010000);
#endif
/* If NVRAM is found to be uninitialized, reinit it. */
@ -1246,7 +1246,7 @@ tgt_setenv(char *name, char *value)
#ifdef NVRAM_IN_FLASH
memcpy(nvramsecbuf, nvram, NVRAM_SECSIZE);
#endif
nvrambuf = nvramsecbuf + (((unsigned long)(&nvram_offs)-0x8f010000) & (NVRAM_SECSIZE - 1));
nvrambuf = nvramsecbuf;
memset(nvrambuf, -1, NVRAM_SIZE);
nvrambuf[2] = '\0';
nvrambuf[3] = '\0';
@ -1284,7 +1284,7 @@ tgt_setenv(char *name, char *value)
#else
memcpy(nvramsecbuf, nvram, NVRAM_SECSIZE);
#endif
nvrambuf = nvramsecbuf + (((unsigned long)(&nvram_offs)-0x8f010000) & (NVRAM_SECSIZE - 1));
nvrambuf = nvramsecbuf;
/* Etheraddr is special case to save space */
if (strcmp("ethaddr", name) == 0) {
char *s = value;

Loading…
Cancel
Save