]> Git Repo - J-u-boot.git/blame - boot/bootretry.c
Merge patch series "Enable AVS support for AM68, AM69 and J784S4"
[J-u-boot.git] / boot / bootretry.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
0098e179
SG
2/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, [email protected].
0098e179
SG
5 */
6
03de305e 7#include <stdio.h>
0098e179
SG
8#include <bootretry.h>
9#include <cli.h>
7b51b576 10#include <env.h>
0098e179 11#include <errno.h>
1045315d 12#include <time.h>
03de305e 13#include <vsprintf.h>
0098e179
SG
14#include <watchdog.h>
15
0098e179
SG
16static uint64_t endtime; /* must be set, default is instant timeout */
17static int retry_time = -1; /* -1 so can call readline before main_loop */
18
19/***************************************************************************
20 * initialize command line timeout
21 */
b26440f1 22void bootretry_init_cmd_timeout(void)
0098e179 23{
00caae6d 24 char *s = env_get("bootretry");
0098e179
SG
25
26 if (s != NULL)
27 retry_time = (int)simple_strtol(s, NULL, 10);
28 else
29 retry_time = CONFIG_BOOT_RETRY_TIME;
30
31 if (retry_time >= 0 && retry_time < CONFIG_BOOT_RETRY_MIN)
32 retry_time = CONFIG_BOOT_RETRY_MIN;
33}
34
35/***************************************************************************
36 * reset command line timeout to retry_time seconds
37 */
b26440f1 38void bootretry_reset_cmd_timeout(void)
0098e179
SG
39{
40 endtime = endtick(retry_time);
41}
42
43int bootretry_tstc_timeout(void)
44{
45 while (!tstc()) { /* while no incoming data */
46 if (retry_time >= 0 && get_ticks() > endtime)
47 return -ETIMEDOUT;
29caf930 48 schedule();
0098e179
SG
49 }
50
51 return 0;
52}
53
54void bootretry_dont_retry(void)
55{
56 retry_time = -1;
57}
This page took 0.348553 seconds and 4 git commands to generate.