From 1567117e551eb6c1256d4f03bccbd150f9c5f839 Mon Sep 17 00:00:00 2001 From: QiaoChong Date: Thu, 29 Jun 2017 19:19:08 +0800 Subject: [PATCH] 3aserver add wdt env. Change-Id: I954b5c39e94fd9ac7337f3c27b13dd47aa8f0362 Signed-off-by: QiaoChong --- Targets/Bonito3aserver/Bonito/tgt_machdep.c | 12 ++++++++++-- Targets/Bonito3aserver/dev/irq.c | 14 ++++++++++---- Targets/Bonito3aserver/include/bonito.h | 2 ++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Targets/Bonito3aserver/Bonito/tgt_machdep.c b/Targets/Bonito3aserver/Bonito/tgt_machdep.c index 76587da8..59ccee36 100644 --- a/Targets/Bonito3aserver/Bonito/tgt_machdep.c +++ b/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"); diff --git a/Targets/Bonito3aserver/dev/irq.c b/Targets/Bonito3aserver/dev/irq.c index 2b3c6065..147d5d26 100644 --- a/Targets/Bonito3aserver/dev/irq.c +++ b/Targets/Bonito3aserver/dev/irq.c @@ -1,6 +1,7 @@ #include #include #include +#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