u-boot修改main.c实现bootloader里喂狗
来源:互联网 发布:企业网站源码带手机版 编辑:程序博客网 时间:2024/06/08 06:23
#include "../board/cnxt/common/dc_sdkport.h"
#include "../board/cnxt/common/dc_radef_common.h"
#include "../board/cnxt/common/ra_gp.h"
#include "../board/cnxt/common/radef.h"
#include <common.h>
//#include <watchdog.h>
#include <command.h>
#ifdef CONFIG_MODEM_SUPPORT
#include <malloc.h> /* for free() prototype */
#endif
#include "../board/cnxt/common/dc_radef_common.h"
#include "../board/cnxt/common/ra_gp.h"
#include "../board/cnxt/common/radef.h"
#include <common.h>
//#include <watchdog.h>
#include <command.h>
#ifdef CONFIG_MODEM_SUPPORT
#include <malloc.h> /* for free() prototype */
#endif
#ifdef CONFIG_SYS_HUSH_PARSER
#include <hush.h>
#endif
#include <hush.h>
#endif
#include <post.h>
void WATCHDOG_RESET(void)
{
//int i=0;
regwr(RA_GP_OUTPUT0_P,dcreg(RA_GP_OUTPUT0_P)|0x10);
udelay(10);
regwr(RA_GP_OUTPUT0_P,dcreg(RA_GP_OUTPUT0_P)&~0x10);
// printf("wd_reset\n");
}
{
//int i=0;
regwr(RA_GP_OUTPUT0_P,dcreg(RA_GP_OUTPUT0_P)|0x10);
udelay(10);
regwr(RA_GP_OUTPUT0_P,dcreg(RA_GP_OUTPUT0_P)&~0x10);
// printf("wd_reset\n");
}
static int cread_line(const char *const prompt, char *buf, unsigned int *len)
{
unsigned long dog_time=0;
unsigned long num = 0;
unsigned long eol_num = 0;
unsigned long wlen;
char ichar;
int insert = 1;
int esc_len = 0;
char esc_save[8];
int init_len = strlen(buf);
if (init_len)
cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len);
{
unsigned long dog_time=0;
unsigned long num = 0;
unsigned long eol_num = 0;
unsigned long wlen;
char ichar;
int insert = 1;
int esc_len = 0;
char esc_save[8];
int init_len = strlen(buf);
if (init_len)
cread_add_str(buf, init_len, 1, &num, &eol_num, buf, *len);
while (1) {
// printf("gecmd_getch() -1\n");
if(tstc()) //---------------------检测有没有输入
ichar = getcmd_getch();
else //----------------------无输入的时候
{
dog_time++;
if(dog_time>=100000)
{
dog_time=0;
WATCHDOG_RESET();
}
continue;
}
// printf("getcmd_getch() -2\n");
if ((ichar == '\n') || (ichar == '\r')) {
putc('\n');
break;
}
// printf("gecmd_getch() -1\n");
if(tstc()) //---------------------检测有没有输入
ichar = getcmd_getch();
else //----------------------无输入的时候
{
dog_time++;
if(dog_time>=100000)
{
dog_time=0;
WATCHDOG_RESET();
}
continue;
}
// printf("getcmd_getch() -2\n");
if ((ichar == '\n') || (ichar == '\r')) {
putc('\n');
break;
}
/*
* handle standard linux xterm esc sequences for arrow key, etc.
*/
if (esc_len != 0) {
if (esc_len == 1) {
if (ichar == '[') {
esc_save[esc_len] = ichar;
esc_len = 2;
} else {
cread_add_str(esc_save, esc_len, insert,
&num, &eol_num, buf, *len);
esc_len = 0;
}
continue;
}
* handle standard linux xterm esc sequences for arrow key, etc.
*/
if (esc_len != 0) {
if (esc_len == 1) {
if (ichar == '[') {
esc_save[esc_len] = ichar;
esc_len = 2;
} else {
cread_add_str(esc_save, esc_len, insert,
&num, &eol_num, buf, *len);
esc_len = 0;
}
continue;
}
switch (ichar) {
case 'D': /* <- key */
ichar = CTL_CH('b');
esc_len = 0;
break;
case 'C': /* -> key */
ichar = CTL_CH('f');
esc_len = 0;
break; /* pass off to ^F handler */
case 'H': /* Home key */
ichar = CTL_CH('a');
esc_len = 0;
break; /* pass off to ^A handler */
case 'A': /* up arrow */
ichar = CTL_CH('p');
esc_len = 0;
break; /* pass off to ^P handler */
case 'B': /* down arrow */
ichar = CTL_CH('n');
esc_len = 0;
break; /* pass off to ^N handler */
default:
esc_save[esc_len++] = ichar;
cread_add_str(esc_save, esc_len, insert,
&num, &eol_num, buf, *len);
esc_len = 0;
continue;
}
}
ichar = CTL_CH('b');
esc_len = 0;
break;
case 'C': /* -> key */
ichar = CTL_CH('f');
esc_len = 0;
break; /* pass off to ^F handler */
case 'H': /* Home key */
ichar = CTL_CH('a');
esc_len = 0;
break; /* pass off to ^A handler */
case 'A': /* up arrow */
ichar = CTL_CH('p');
esc_len = 0;
break; /* pass off to ^P handler */
case 'B': /* down arrow */
ichar = CTL_CH('n');
esc_len = 0;
break; /* pass off to ^N handler */
default:
esc_save[esc_len++] = ichar;
cread_add_str(esc_save, esc_len, insert,
&num, &eol_num, buf, *len);
esc_len = 0;
continue;
}
}
switch (ichar) {
case 0x1b:
if (esc_len == 0) {
esc_save[esc_len] = ichar;
esc_len = 1;
} else {
puts("impossible condition #876\n");
esc_len = 0;
}
break;
case 0x1b:
if (esc_len == 0) {
esc_save[esc_len] = ichar;
esc_len = 1;
} else {
puts("impossible condition #876\n");
esc_len = 0;
}
break;
case CTL_CH('a'):
BEGINNING_OF_LINE();
break;
case CTL_CH('c'): /* ^C - break */
*buf = '\0'; /* discard input */
return (-1);
case CTL_CH('f'):
if (num < eol_num) {
getcmd_putch(buf[num]);
num++;
}
break;
case CTL_CH('b'):
if (num) {
getcmd_putch(CTL_BACKSPACE);
num--;
}
break;
case CTL_CH('d'):
if (num < eol_num) {
wlen = eol_num - num - 1;
if (wlen) {
memmove(&buf[num], &buf[num+1], wlen);
putnstr(buf + num, wlen);
}
BEGINNING_OF_LINE();
break;
case CTL_CH('c'): /* ^C - break */
*buf = '\0'; /* discard input */
return (-1);
case CTL_CH('f'):
if (num < eol_num) {
getcmd_putch(buf[num]);
num++;
}
break;
case CTL_CH('b'):
if (num) {
getcmd_putch(CTL_BACKSPACE);
num--;
}
break;
case CTL_CH('d'):
if (num < eol_num) {
wlen = eol_num - num - 1;
if (wlen) {
memmove(&buf[num], &buf[num+1], wlen);
putnstr(buf + num, wlen);
}
getcmd_putch(' ');
do {
getcmd_putch(CTL_BACKSPACE);
} while (wlen--);
eol_num--;
}
break;
case CTL_CH('k'):
ERASE_TO_EOL();
break;
case CTL_CH('e'):
REFRESH_TO_EOL();
break;
case CTL_CH('o'):
insert = !insert;
break;
case CTL_CH('x'):
case CTL_CH('u'):
BEGINNING_OF_LINE();
ERASE_TO_EOL();
break;
case DEL:
case DEL7:
case 8:
if (num) {
wlen = eol_num - num;
num--;
memmove(&buf[num], &buf[num+1], wlen);
getcmd_putch(CTL_BACKSPACE);
putnstr(buf + num, wlen);
getcmd_putch(' ');
do {
getcmd_putch(CTL_BACKSPACE);
} while (wlen--);
eol_num--;
}
break;
case CTL_CH('p'):
case CTL_CH('n'):
{
char * hline;
do {
getcmd_putch(CTL_BACKSPACE);
} while (wlen--);
eol_num--;
}
break;
case CTL_CH('k'):
ERASE_TO_EOL();
break;
case CTL_CH('e'):
REFRESH_TO_EOL();
break;
case CTL_CH('o'):
insert = !insert;
break;
case CTL_CH('x'):
case CTL_CH('u'):
BEGINNING_OF_LINE();
ERASE_TO_EOL();
break;
case DEL:
case DEL7:
case 8:
if (num) {
wlen = eol_num - num;
num--;
memmove(&buf[num], &buf[num+1], wlen);
getcmd_putch(CTL_BACKSPACE);
putnstr(buf + num, wlen);
getcmd_putch(' ');
do {
getcmd_putch(CTL_BACKSPACE);
} while (wlen--);
eol_num--;
}
break;
case CTL_CH('p'):
case CTL_CH('n'):
{
char * hline;
esc_len = 0;
if (ichar == CTL_CH('p'))
hline = hist_prev();
else
hline = hist_next();
hline = hist_prev();
else
hline = hist_next();
if (!hline) {
getcmd_cbeep();
continue;
}
getcmd_cbeep();
continue;
}
/* nuke the current line */
/* first, go home */
BEGINNING_OF_LINE();
/* first, go home */
BEGINNING_OF_LINE();
/* erase to end of line */
ERASE_TO_EOL();
ERASE_TO_EOL();
/* copy new line into place and display */
strcpy(buf, hline);
eol_num = strlen(buf);
REFRESH_TO_EOL();
continue;
}
#ifdef CONFIG_AUTO_COMPLETE
case '\t': {
int num2, col;
strcpy(buf, hline);
eol_num = strlen(buf);
REFRESH_TO_EOL();
continue;
}
#ifdef CONFIG_AUTO_COMPLETE
case '\t': {
int num2, col;
/* do not autocomplete when in the middle */
if (num < eol_num) {
getcmd_cbeep();
break;
}
if (num < eol_num) {
getcmd_cbeep();
break;
}
buf[num] = '\0';
col = strlen(prompt) + eol_num;
num2 = num;
if (cmd_auto_complete(prompt, buf, &num2, &col)) {
col = num2 - num;
num += col;
eol_num += col;
}
break;
}
#endif
default:
cread_add_char(ichar, insert, &num, &eol_num, buf, *len);
break;
}
}
*len = eol_num;
buf[eol_num] = '\0'; /* lose the newline */
col = strlen(prompt) + eol_num;
num2 = num;
if (cmd_auto_complete(prompt, buf, &num2, &col)) {
col = num2 - num;
num += col;
eol_num += col;
}
break;
}
#endif
default:
cread_add_char(ichar, insert, &num, &eol_num, buf, *len);
break;
}
}
*len = eol_num;
buf[eol_num] = '\0'; /* lose the newline */
if (buf[0] && buf[0] != CREAD_HIST_CHAR)
cread_add_to_hist(buf);
hist_cur = hist_add_idx;
cread_add_to_hist(buf);
hist_cur = hist_add_idx;
return 0;
}
}
0 0
- u-boot修改main.c实现bootloader里喂狗
- U-BOOT环境变量实现 - BootLoader
- Bootloader U-boot启动
- bootloader之U-boot
- bootloader之u-boot
- bootloader---6.运行U-boot目录examples中的hello_world.c
- Bootloader及u-boot简介
- BootLoader 之U-Boot学习.
- Bootloader及u-boot简介/u-boot系统启动流程
- Bootloader/u-boot的启动模式
- 20、Bootloader(4) -- U-Boot第二阶段分析
- u-boot bootloader 代码学习之关键
- 【嵌入式】探究bootloader,分析u-boot源码
- 【嵌入式】探究bootloader,分析u-boot源码
- u-boot学习(六):自己写bootloader
- 移植U-Boot之BootLoader简介
- bootloader 之U-Boot启动trace
- 探究bootloader,分析u-boot源码
- jsp、struts、spring、mybatis实现前端页面功能模块化拆分
- elk中关于时间的问题
- 学python第一天---环境
- mac 安装mysql + 修改root用户密码 + 及报Access denied for user 'root'@'localhost' (using password:YES)解决办法
- C/C++ OpenCV图像的阈值操作
- u-boot修改main.c实现bootloader里喂狗
- ubuntu gparted不能启动问题解决
- 什么是人月,如何简单估算人月
- Spring Boot系列教程三:使用devtools实现热部署
- storm trident实战 filter,function的使用
- 内核定时器的实现
- 企业小号来啦!统一钉铛2.1新功能升级啦
- python数据分析与挖掘学习笔记(3)_小说文本数据挖掘part2
- Python练手项目0009