blob: 203071fc8a66a55b12d161314266dd8752455955 [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{
Timothy Pearson3bfd7cc2015-11-01 02:13:17 -060011 uint8_t index, byte;
12
Eric Biederman8ca8d762003-04-22 19:02:15 +000013 index = inb(RTC_PORT(0)) & 0x80;
14 index |= RTC_BOOT_BYTE;
15 outb(index, RTC_PORT(0));
16
17 byte = inb(RTC_PORT(1));
Eric Biederman8ca8d762003-04-22 19:02:15 +000018
Timothy Pearson3bfd7cc2015-11-01 02:13:17 -060019 if (IS_ENABLED(CONFIG_SKIP_MAX_REBOOT_CNT_CLEAR)) {
20 /* Set the fallback boot bit to allow for recovery if
21 * the payload fails to boot.
22 * It is the responsibility of the payload to reset
23 * the normal boot bit to 1 if desired
24 */
25 byte &= ~RTC_BOOT_NORMAL;
26 } else {
27 /* If we are in normal mode set the boot count to 0 */
28 if (byte & RTC_BOOT_NORMAL)
Timothy Pearson44724082015-03-16 11:47:45 -050029 byte &= 0x0f;
Timothy Pearson3bfd7cc2015-11-01 02:13:17 -060030
31 }
32
Eric Biederman8ca8d762003-04-22 19:02:15 +000033 outb(byte, RTC_PORT(1));
34}
Stefan Reinauer859e8082012-11-30 12:03:46 -080035#else
36static void set_boot_successful(void)
37{
38 /* To be implemented */
39}
40#endif
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000041
42void boot_successful(void)
43{
Stefan Reinauerc1efb902011-10-12 14:30:59 -070044#if CONFIG_FRAMEBUFFER_SET_VESA_MODE && !CONFIG_FRAMEBUFFER_KEEP_VESA_MODE
Stefan Reinauerd650e992010-02-22 04:33:13 +000045 void vbe_textmode_console(void);
46
47 vbe_textmode_console();
48#endif
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000049 /* Remember this was a successful boot */
50 set_boot_successful();
51
52 /* turn off the boot watchdog */
53 watchdog_off();
54}