blob: 74572df323f3a33a6735b4e0be0d94ec96ca8004 [file] [log] [blame]
Eric Biederman8ca8d762003-04-22 19:02:15 +00001#include <console/console.h>
Stefan Reinauerde3206a2010-02-22 06:09:43 +00002#include <fallback.h>
3#include <watchdog.h>
Eric Biederman8ca8d762003-04-22 19:02:15 +00004#include <arch/io.h>
5
Stefan Reinauer859e8082012-11-30 12:03:46 -08006#if CONFIG_PC80_SYSTEM
7#include <pc80/mc146818rtc.h>
Yinghai Lu13f1c2a2005-07-08 02:49:49 +00008
Stefan Reinauer859e8082012-11-30 12:03:46 -08009static void set_boot_successful(void)
Eric Biederman8ca8d762003-04-22 19:02:15 +000010{
Martin Rothcbf2bd72013-07-09 21:51:14 -060011 /* Remember I successfully booted by setting
Eric Biederman8ca8d762003-04-22 19:02:15 +000012 * the initial boot direction
13 * to the direction that I booted.
14 */
15 unsigned char index, byte;
16 index = inb(RTC_PORT(0)) & 0x80;
17 index |= RTC_BOOT_BYTE;
18 outb(index, RTC_PORT(0));
19
20 byte = inb(RTC_PORT(1));
21 byte &= 0xfe;
Eric Biederman2c018fb2003-07-21 20:13:45 +000022 byte |= (byte & (1 << 1)) >> 1;
Eric Biederman8ca8d762003-04-22 19:02:15 +000023
24 /* If we are in normal mode set the boot count to 0 */
Timothy Pearson44724082015-03-16 11:47:45 -050025 if (!IS_ENABLED(CONFIG_SKIP_MAX_REBOOT_CNT_CLEAR))
26 if(byte & 1)
27 byte &= 0x0f;
Eric Biederman8ca8d762003-04-22 19:02:15 +000028 outb(byte, RTC_PORT(1));
29}
Stefan Reinauer859e8082012-11-30 12:03:46 -080030#else
31static void set_boot_successful(void)
32{
33 /* To be implemented */
34}
35#endif
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000036
37void boot_successful(void)
38{
Stefan Reinauerc1efb902011-10-12 14:30:59 -070039#if CONFIG_FRAMEBUFFER_SET_VESA_MODE && !CONFIG_FRAMEBUFFER_KEEP_VESA_MODE
Stefan Reinauerd650e992010-02-22 04:33:13 +000040 void vbe_textmode_console(void);
41
42 vbe_textmode_console();
43#endif
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000044 /* Remember this was a successful boot */
45 set_boot_successful();
46
47 /* turn off the boot watchdog */
48 watchdog_off();
49}