Browse Source

3aserver add wdt env.

Change-Id: I954b5c39e94fd9ac7337f3c27b13dd47aa8f0362
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
master
QiaoChong 7 years ago
committed by Chong Qiao
parent
commit
1567117e55
  1. 12
      Targets/Bonito3aserver/Bonito/tgt_machdep.c
  2. 14
      Targets/Bonito3aserver/dev/irq.c
  3. 2
      Targets/Bonito3aserver/include/bonito.h

12
Targets/Bonito3aserver/Bonito/tgt_machdep.c

@ -421,6 +421,7 @@ extern unsigned long long memorysize_high_n3;
extern char MipsException[], MipsExceptionEnd[];
unsigned char hwethadr[6];
static unsigned short wdt;
void initmips(unsigned int raw_memsz);
@ -444,6 +445,7 @@ initmips(unsigned int raw_memsz)
bcopy(MipsException, (char *)TLB_MISS_EXC_VEC, MipsExceptionEnd - MipsException);
bcopy(MipsException, (char *)GEN_EXC_VEC, MipsExceptionEnd - MipsException);
CPU_ConfigCache();
CPU_FlushCache();
#ifndef ROM_EXCEPTION
@ -1203,7 +1205,7 @@ tgt_devinit()
}
#if 1
CPU_ConfigCache();
//CPU_ConfigCache();
#else
{
#define CTYPE_HAS_L2 0x100
@ -1979,6 +1981,10 @@ tgt_mapenv(int (*func) __P((char *, char *)))
nomsg_on_serial=1;
}
bcopy(&nvram[WDT_OFFS], &wdt, 2);
sprintf(env, "%d", (wdt==0||wdt==0xffff)?300:wdt);
(*func)("wdt", env);
#ifndef NVRAM_IN_FLASH
free(nvram);
#endif
@ -2199,6 +2205,8 @@ tgt_mapenv(int (*func) __P((char *, char *)))
}
else if (strcmp("NOMSG_ON_SERIAL", name) == 0) {
nvramsecbuf[NOMSG_OFFS]=(value[0]=='0')?0xff:0x5a;
} else if (strcmp("wdt", name) == 0) {
wdt = strtoul(value,0,0);
} else {
ep = nvrambuf+2;
if(*ep != '\0') {
@ -2250,7 +2258,7 @@ tgt_mapenv(int (*func) __P((char *, char *)))
cksum(nvrambuf, NVRAM_SIZE, 1);
bcopy(hwethadr, &nvramsecbuf[ETHER_OFFS], 6);
bcopy(&wdt, &nvramsecbuf[WDT_OFFS], 2);
#ifdef NVRAM_IN_FLASH
if(fl_erase_device(nvram, NVRAM_SECSIZE, FALSE)) {
printf("Error! Nvram erase failed!\n");

14
Targets/Bonito3aserver/dev/irq.c

@ -1,6 +1,7 @@
#include <pmon.h>
#include <errno.h>
#include <asm/mipsregs.h>
#include "include/bonito.h"
#define ST0_IM 0x0000ff00
#define CAUSEF_IP7 ( 1 << 15)
#define CAUSEF_IP6 ( 1 << 14)
@ -14,7 +15,7 @@ static int wdt_enable()
int d = *(volatile int *)0xbfe0011c;
int oe= *(volatile int *)0xbfe00120;
d=(d&~0x2000)|0x38;
oe=oe&~0x2038;
oe=oe&~0x6038;
*(volatile int *)0xbfe0011c = d;
*(volatile int *)0xbfe00120 = oe;
return 0;
@ -25,7 +26,7 @@ static int wdt_disable()
int d = *(volatile int *)0xbfe0011c;
int oe= *(volatile int *)0xbfe00120;
d=(d|0x2008)&~0x30;
oe=oe&~0x2038;
oe=oe&~0x6038;
*(volatile int *)0xbfe0011c = d;
*(volatile int *)0xbfe00120 = oe;
@ -37,7 +38,7 @@ static int wdt_feed()
int d = *(volatile int *)0xbfe0011c;
int oe= *(volatile int *)0xbfe00120;
int d0, d1;
oe=oe&~0x2038;
oe=oe&~0x6038;
d0=d&~(1<<14);
d1=d|(1<<14);
*(volatile int *)0xbfe0011c = d0;
@ -46,6 +47,7 @@ d1=d|(1<<14);
}
#define IRQ_HZ 4
static int wdt_timeout;
void plat_irq_dispatch(struct trapframe *frame)
{
@ -57,7 +59,7 @@ void plat_irq_dispatch(struct trapframe *frame)
static int cnt=0;
//tgt_printf("cnt %d\n",cnt++);
write_c0_compare(read_c0_count()+400000000/IRQ_HZ);
if(cnt<60*IRQ_HZ)
if(cnt<wdt_timeout*IRQ_HZ)
wdt_feed();
}
else
@ -70,9 +72,13 @@ void plat_irq_dispatch(struct trapframe *frame)
void init_IRQ()
{
int wdt;
write_c0_compare(400000000/4);
write_c0_count(0);
set_c0_status(0x8001);
wdt = *(unsigned short *)(0xbfc00000+NVRAM_OFFS+WDT_OFFS);
if(wdt==0xffff||wdt==0) wdt_timeout=300;
else wdt_timeout=wdt;
wdt_enable();
}

2
Targets/Bonito3aserver/include/bonito.h

@ -61,12 +61,14 @@ extern char *heaptop;
# define NVRAM_OFFS 0x000fd800
# define ETHER_OFFS 494 /* Ethernet address base */
# define NOMSG_OFFS ETHER_OFFS+6 /* Ethernet address base */
# define WDT_OFFS NOMSG_OFFS+2
#else /* Use clock ram, 256 bytes only */
# define NVRAM_SIZE 108
# define NVRAM_SECSIZE 128 /* Helper */
# define NVRAM_OFFS 0
# define ETHER_OFFS NVRAM_SIZE /* Ethernet address base */
# define NOMSG_OFFS ETHER_OFFS+6 /* Ethernet address base */
# define WDT_OFFS NOMSG_OFFS+2
#endif

Loading…
Cancel
Save