| 1 |
|
| 2 |
|
| 3 |
#include <device/mmio.h> |
| 4 |
#include <assert.h> |
| 5 |
#include <bootstate.h> |
| 6 |
#include <console/console.h> |
| 7 |
#include <ec/google/chromeec/ec.h> |
| 8 |
#include <elog.h> |
| 9 |
#include <reset.h> |
| 10 |
#include <symbols.h> |
| 11 |
|
| 12 |
#include "chromeos.h" |
| 13 |
|
| 14 |
#define WATCHDOG_TOMBSTONE_MAGIC 0x9d2f41a7 |
| 15 |
|
| 16 |
static void elog_handle_watchdog_tombstone(void *unused) |
| 17 |
{ |
| 18 |
bool flag = false; |
| 19 |
|
| 20 |
if (CONFIG(CHROMEOS_USE_EC_WATCHDOG_FLAG)) |
| 21 |
flag |= google_chromeec_get_ap_watchdog_flag(); |
| 22 |
|
| 23 |
flag |= reset_watchdog_tombstone(); |
| 24 |
|
| 25 |
if (flag) |
| 26 |
elog_add_event(ELOG_TYPE_ASYNC_HW_TIMER_EXPIRED); |
| 27 |
} |
| 28 |
|
| 29 |
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, |
| 30 |
elog_handle_watchdog_tombstone, NULL); |
| 31 |
|
| 32 |
bool reset_watchdog_tombstone(void) |
| 33 |
{ |
| 34 |
if (!REGION_SIZE(watchdog_tombstone)) |
| 35 |
return false; |
| 36 |
|
| 37 |
bool flag = (read32(_watchdog_tombstone) == WATCHDOG_TOMBSTONE_MAGIC); |
| 38 |
write32(_watchdog_tombstone, 0); |
| 39 |
return flag; |
| 40 |
} |
| 41 |
|
| 42 |
void mark_watchdog_tombstone(void) |
| 43 |
{ |
| 44 |
assert(REGION_SIZE(watchdog_tombstone)); |
| 45 |
write32(_watchdog_tombstone, WATCHDOG_TOMBSTONE_MAGIC); |
| 46 |
} |
| 47 |
|
| 48 |
void reboot_from_watchdog(void) |
| 49 |
{ |
| 50 |
printk(BIOS_INFO, "Last reset was watchdog, reboot again to reset TPM!\n"); |
| 51 |
mark_watchdog_tombstone(); |
| 52 |
board_reset(); |
| 53 |
} |