Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 1 | #include <console/console.h> |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 2 | #include <fallback.h> |
| 3 | #include <watchdog.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 4 | #include <arch/io.h> |
| 5 | |
Stefan Reinauer | 859e808 | 2012-11-30 12:03:46 -0800 | [diff] [blame] | 6 | #if CONFIG_PC80_SYSTEM |
| 7 | #include <pc80/mc146818rtc.h> |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 8 | |
Stefan Reinauer | 859e808 | 2012-11-30 12:03:46 -0800 | [diff] [blame] | 9 | static void set_boot_successful(void) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 10 | { |
Timothy Pearson | 3bfd7cc | 2015-11-01 02:13:17 -0600 | [diff] [blame^] | 11 | uint8_t index, byte; |
| 12 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 13 | 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 Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 18 | |
Timothy Pearson | 3bfd7cc | 2015-11-01 02:13:17 -0600 | [diff] [blame^] | 19 | 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 Pearson | 4472408 | 2015-03-16 11:47:45 -0500 | [diff] [blame] | 29 | byte &= 0x0f; |
Timothy Pearson | 3bfd7cc | 2015-11-01 02:13:17 -0600 | [diff] [blame^] | 30 | |
| 31 | } |
| 32 | |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 33 | outb(byte, RTC_PORT(1)); |
| 34 | } |
Stefan Reinauer | 859e808 | 2012-11-30 12:03:46 -0800 | [diff] [blame] | 35 | #else |
| 36 | static void set_boot_successful(void) |
| 37 | { |
| 38 | /* To be implemented */ |
| 39 | } |
| 40 | #endif |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 41 | |
| 42 | void boot_successful(void) |
| 43 | { |
Stefan Reinauer | c1efb90 | 2011-10-12 14:30:59 -0700 | [diff] [blame] | 44 | #if CONFIG_FRAMEBUFFER_SET_VESA_MODE && !CONFIG_FRAMEBUFFER_KEEP_VESA_MODE |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 45 | void vbe_textmode_console(void); |
| 46 | |
| 47 | vbe_textmode_console(); |
| 48 | #endif |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 49 | /* Remember this was a successful boot */ |
| 50 | set_boot_successful(); |
| 51 | |
| 52 | /* turn off the boot watchdog */ |
| 53 | watchdog_off(); |
| 54 | } |