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 | { |
Martin Roth | cbf2bd7 | 2013-07-09 21:51:14 -0600 | [diff] [blame] | 11 | /* Remember I successfully booted by setting |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 12 | * 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 Biederman | 2c018fb | 2003-07-21 20:13:45 +0000 | [diff] [blame] | 22 | byte |= (byte & (1 << 1)) >> 1; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 23 | |
| 24 | /* If we are in normal mode set the boot count to 0 */ |
Timothy Pearson | 4472408 | 2015-03-16 11:47:45 -0500 | [diff] [blame] | 25 | if (!IS_ENABLED(CONFIG_SKIP_MAX_REBOOT_CNT_CLEAR)) |
| 26 | if(byte & 1) |
| 27 | byte &= 0x0f; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 28 | outb(byte, RTC_PORT(1)); |
| 29 | } |
Stefan Reinauer | 859e808 | 2012-11-30 12:03:46 -0800 | [diff] [blame] | 30 | #else |
| 31 | static void set_boot_successful(void) |
| 32 | { |
| 33 | /* To be implemented */ |
| 34 | } |
| 35 | #endif |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 36 | |
| 37 | void boot_successful(void) |
| 38 | { |
Stefan Reinauer | c1efb90 | 2011-10-12 14:30:59 -0700 | [diff] [blame] | 39 | #if CONFIG_FRAMEBUFFER_SET_VESA_MODE && !CONFIG_FRAMEBUFFER_KEEP_VESA_MODE |
Stefan Reinauer | d650e99 | 2010-02-22 04:33:13 +0000 | [diff] [blame] | 40 | void vbe_textmode_console(void); |
| 41 | |
| 42 | vbe_textmode_console(); |
| 43 | #endif |
Yinghai Lu | 13f1c2a | 2005-07-08 02:49:49 +0000 | [diff] [blame] | 44 | /* Remember this was a successful boot */ |
| 45 | set_boot_successful(); |
| 46 | |
| 47 | /* turn off the boot watchdog */ |
| 48 | watchdog_off(); |
| 49 | } |